mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=3944
This commit is contained in:
parent
a7a656299d
commit
fd201edeca
|
@ -28,57 +28,60 @@ function get_path($params) {
|
|||
}
|
||||
|
||||
function start_cache($max_age, $params=""){
|
||||
$path = get_path($params);
|
||||
$request = getallheaders();
|
||||
// Check to see if this is a conditional fetch.
|
||||
$lastmodified = @filemtime($path);
|
||||
if ($max_age) {
|
||||
$path = get_path($params);
|
||||
$request = getallheaders();
|
||||
// Check to see if this is a conditional fetch.
|
||||
$lastmodified = @filemtime($path);
|
||||
|
||||
$if_modified_since = isset($request['If-Modified-Since']) ?
|
||||
$if_modified_since = isset($request['If-Modified-Since']) ?
|
||||
(explode(';',$request['If-Modified-Since'])) :
|
||||
false;
|
||||
|
||||
if ($if_modified_since) {
|
||||
$if_modified_since=strtotime($if_modified_since[0]);
|
||||
}
|
||||
if ($if_modified_since) {
|
||||
$if_modified_since=strtotime($if_modified_since[0]);
|
||||
}
|
||||
|
||||
if ($if_modified_since && ($if_modified_since == $lastmodified)) {
|
||||
Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT");
|
||||
Header('HTTP/1.0 304 Not Modified');
|
||||
exit;
|
||||
}
|
||||
if ($if_modified_since && ($if_modified_since == $lastmodified)) {
|
||||
Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT");
|
||||
Header('HTTP/1.0 304 Not Modified');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($lastmodified<time()-$max_age){
|
||||
// If cached version is too old (or non-existent)
|
||||
// generate the page and write to cache
|
||||
//
|
||||
ob_start();
|
||||
ob_implicit_flush(0);
|
||||
Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
Header("Expires: " . gmdate("D, d M Y H:i:s",time()+$max_age) . " GMT");
|
||||
Header("Cache-Control: public, max-age=" . $max_age);
|
||||
} else {
|
||||
// Otherwise serve the cached version and exit
|
||||
//
|
||||
if (strstr($params, "format=xml")) {
|
||||
header('Content-type: text/xml');
|
||||
}
|
||||
Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT");
|
||||
Header("Expires: " . gmdate("D, d M Y H:i:s",$lastmodified+$max_age) . " GMT");
|
||||
Header("Cache-Control: public, max-age=" . $max_age );
|
||||
readfile($path);
|
||||
exit;
|
||||
}
|
||||
if ($lastmodified<time()-$max_age){
|
||||
// If cached version is too old (or non-existent)
|
||||
// generate the page and write to cache
|
||||
//
|
||||
ob_start();
|
||||
ob_implicit_flush(0);
|
||||
Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
Header("Expires: " . gmdate("D, d M Y H:i:s",time()+$max_age) . " GMT");
|
||||
Header("Cache-Control: public, max-age=" . $max_age);
|
||||
} else {
|
||||
// Otherwise serve the cached version and exit
|
||||
//
|
||||
if (strstr($params, "format=xml")) {
|
||||
header('Content-type: text/xml');
|
||||
}
|
||||
Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT");
|
||||
Header("Expires: " . gmdate("D, d M Y H:i:s",$lastmodified+$max_age) . " GMT");
|
||||
Header("Cache-Control: public, max-age=" . $max_age );
|
||||
readfile($path);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write output buffer both to client and to cache
|
||||
//
|
||||
function end_cache($params=""){
|
||||
$path = get_path($params);
|
||||
$fhandle=fopen($path, "w");
|
||||
$page=ob_get_contents();
|
||||
ob_end_flush();
|
||||
fwrite($fhandle, $page);
|
||||
fclose($fhandle);
|
||||
function end_cache($max_age,$params=""){
|
||||
if ($max_age) {
|
||||
$path = get_path($params);
|
||||
$fhandle=fopen($path, "w");
|
||||
$page=ob_get_contents();
|
||||
ob_end_flush();
|
||||
fwrite($fhandle, $page);
|
||||
fclose($fhandle);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -5,10 +5,14 @@
|
|||
require_once("../inc/db.inc");
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/host.inc");
|
||||
require_once("../inc/cache.inc");
|
||||
|
||||
db_init();
|
||||
$userid = $_GET["userid"];
|
||||
if ($userid) {
|
||||
$cache_args = "userid=$userid";
|
||||
$caching=true;
|
||||
start_cache(USER_PAGE_TTL,$cache_args);
|
||||
$result = mysql_query("select * from user where id=$userid");
|
||||
$user = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
|
@ -17,10 +21,12 @@
|
|||
user_host_table_start(false);
|
||||
} else {
|
||||
echo "Hidden\n";
|
||||
end_cache($cache_args);
|
||||
exit();
|
||||
}
|
||||
$private = false;
|
||||
} else {
|
||||
$caching=false;
|
||||
$user = get_logged_in_user();
|
||||
$userid = $user->id;
|
||||
page_head("Your computers");
|
||||
|
@ -36,4 +42,5 @@
|
|||
mysql_free_result($result);
|
||||
echo "</table>\n";
|
||||
page_tail();
|
||||
if ($caching) end_cache($cache_args);
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue