mirror of https://github.com/BOINC/boinc.git
user web: change remaining occurrences of fullpage caching to object cache. start_cache() and end_cache() are now deprecated.
svn path=/trunk/boinc/; revision=23230
This commit is contained in:
parent
e858e7bcfa
commit
c819d552c0
|
@ -1581,8 +1581,22 @@ Rytis 12 Mar 2011
|
|||
top_users.php
|
||||
view_profile.php
|
||||
|
||||
David 12 Mar 2001
|
||||
David 12 Mar 2011
|
||||
- move client simulator PHP code to doc/sim
|
||||
|
||||
doc/sim/
|
||||
various
|
||||
|
||||
Rytis 13 Mar 2011
|
||||
- user web: change remaining occurrences of fullpage caching to object
|
||||
cache. start_cache() and end_cache() are now deprecated.
|
||||
|
||||
html/
|
||||
inc/
|
||||
cache.inc
|
||||
team.inc
|
||||
user/
|
||||
download_network.php
|
||||
server_status.php
|
||||
team_members.php
|
||||
userw.php
|
||||
|
|
|
@ -167,8 +167,10 @@ function get_cached_data($max_age, $params=""){
|
|||
if ($max_age) {
|
||||
if (defined('MEMCACHE_SERVERS')) {
|
||||
$cache = BoincMemcache::get()->get($path);
|
||||
if ($cache) {
|
||||
return $cache->content;
|
||||
if ($cache['content']) {
|
||||
return $cache['content'];
|
||||
} else {
|
||||
return $cache;
|
||||
}
|
||||
} else {
|
||||
cache_check_diskspace();
|
||||
|
@ -181,6 +183,7 @@ function get_cached_data($max_age, $params=""){
|
|||
return false; //No data was cached, just return
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
function start_cache($max_age, $params=""){
|
||||
global $no_cache, $caching, $memcache;
|
||||
|
||||
|
@ -242,7 +245,7 @@ function start_cache($max_age, $params=""){
|
|||
}
|
||||
|
||||
// write output buffer both to client and to cache
|
||||
//
|
||||
// DEPRECATED
|
||||
function end_cache($max_age,$params=""){
|
||||
global $no_cache;
|
||||
if ($no_cache) return;
|
||||
|
@ -276,8 +279,7 @@ function set_cached_data($max_age, $data, $params=""){
|
|||
$path = get_path($params);
|
||||
if (defined('MEMCACHE_SERVERS')) {
|
||||
$cache = array('content' => $data, 'timestamp' => time());
|
||||
ob_end_flush();
|
||||
$cache = BoincMemcache::get()->set($path, $cache, $max_age);
|
||||
BoincMemcache::get()->set($path, $cache, $max_age);
|
||||
} else {
|
||||
$fhandle = fopen($path, "w");
|
||||
fwrite($fhandle, $data);
|
||||
|
|
|
@ -225,11 +225,16 @@ function display_team_members($team, $offset, $sort_by) {
|
|||
<th>'.tra('Country').'</th>
|
||||
</tr>
|
||||
';
|
||||
|
||||
if ($nosort) {
|
||||
$users = BoincUser::enum("teamid=$team->id limit $offset,$n");
|
||||
} else {
|
||||
$users = BoincUser::enum("teamid=$team->id order by $sort_clause limit $offset,$n");
|
||||
|
||||
$cache_args = "teamid=".$team->id."&mosort=".$nosort."&order=".$sort_clause."&limit=".$offset."_".$n;
|
||||
$users = unserialize(get_cached_data(TEAM_PAGE_TTL, $cache_args));
|
||||
if (!$users) {
|
||||
if ($nosort) {
|
||||
$users = BoincUser::enum("teamid=$team->id limit $offset,$n");
|
||||
} else {
|
||||
$users = BoincUser::enum("teamid=$team->id order by $sort_clause limit $offset,$n");
|
||||
}
|
||||
set_cached_data(TEAM_PAGE_TTL, serialize($users), $cache_args);
|
||||
}
|
||||
|
||||
$j = $offset + 1;
|
||||
|
|
|
@ -22,7 +22,6 @@ require_once("../inc/cache.inc");
|
|||
|
||||
check_get_args(array());
|
||||
|
||||
start_cache(3600);
|
||||
page_head(tra("Download BOINC add-on software"));
|
||||
echo "
|
||||
<p>" .
|
||||
|
@ -40,17 +39,18 @@ If this is not enough you should contact the author.").
|
|||
</ul>
|
||||
";
|
||||
|
||||
$httpFile = @fopen("http://boinc.berkeley.edu/addons.php?strip_header=true", "rb");
|
||||
if (!$httpFile){
|
||||
echo "";
|
||||
} else {
|
||||
fpassthru($httpFile);
|
||||
fclose($httpFile);
|
||||
$httpFile = unserialize(get_cached_data(3600));
|
||||
if (!$httpFile) {
|
||||
$httpFile = @file_get_contents("http://boinc.berkeley.edu/addons.php?strip_header=true");
|
||||
if ($httpFile) {
|
||||
set_cached_data(3600, serialize($httpFile));
|
||||
}
|
||||
}
|
||||
echo $httpFile;
|
||||
|
||||
echo "
|
||||
<p><p>
|
||||
";
|
||||
page_tail();
|
||||
end_cache(3600);
|
||||
|
||||
?>
|
||||
|
|
|
@ -58,11 +58,6 @@ check_get_args(array("xml"));
|
|||
|
||||
$xml = get_int("xml", true);
|
||||
|
||||
$cache_args = $languages_in_use[0];
|
||||
if ($xml) $cache_args = "xml=1";
|
||||
$cache_period = 3600;
|
||||
start_cache($cache_period, $cache_args);
|
||||
|
||||
// daemon status outputs: 1 (running) 0 (not running) or -1 (disabled)
|
||||
//
|
||||
function daemon_status($host, $pidname, $progname, $disabled) {
|
||||
|
@ -128,45 +123,68 @@ function show_counts($key, $xmlkey, $value) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
function get_mysql_count ($query) {
|
||||
$result = mysql_query("select count(*) as count from " . $query);
|
||||
$count = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
return $count->count;
|
||||
function get_mysql_count($query) {
|
||||
$count = unserialize(get_cached_data(3600, "get_mysql_count".$query));
|
||||
if ($count == false) {
|
||||
$result = mysql_query("select count(*) as count from " . $query);
|
||||
$count = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
$count = $count->count;
|
||||
set_cached_data(3600, serialize($count), "get_mysql_count".$query);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
function get_mysql_value ($query) {
|
||||
$result = mysql_query($query);
|
||||
$row = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
return $row->value;
|
||||
function get_mysql_value($query) {
|
||||
$value = unserialize(get_cached_data(3600, "get_mysql_value".$query));
|
||||
if ($value == false) {
|
||||
$result = mysql_query($query);
|
||||
$row = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
$value = $row->value;
|
||||
set_cached_data(3600, serialize($value), "get_mysql_value".$query);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function get_mysql_assoc($query) {
|
||||
$sql = "SELECT * FROM app WHERE deprecated != 1";
|
||||
$result = mysql_query($sql);
|
||||
while($row = mysql_fetch_assoc($result)) {
|
||||
$assoc[] = $row;
|
||||
$assoc = unserialize(get_cached_data(3600, "get_mysql_assoc".$query));
|
||||
if ($assoc == false) {
|
||||
$sql = "SELECT * FROM app WHERE deprecated != 1";
|
||||
$result = mysql_query($sql);
|
||||
while($row = mysql_fetch_assoc($result)) {
|
||||
$assoc[] = $row;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
set_cached_data(3600, serialize($assoc), "get_mysql_assoc".$query);
|
||||
}
|
||||
mysql_free_result($result);
|
||||
return $assoc;
|
||||
}
|
||||
|
||||
function get_mysql_user ($clause) {
|
||||
$result = mysql_query("select count(userid) as userid from (SELECT distinct userid FROM result where validate_state=1 and received_time > (unix_timestamp()-(3600*24*1)) " . $clause . ") t");
|
||||
$count = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
return $count->userid;
|
||||
function get_mysql_user($clause) {
|
||||
$count = unserialize(get_cached_data(3600, "get_mysql_user".$clause));
|
||||
if ($count == false) {
|
||||
$result = mysql_query("select count(userid) as userid from (SELECT distinct userid FROM result where validate_state=1 and received_time > (unix_timestamp()-(3600*24*1)) " . $clause . ") t");
|
||||
$count = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
$count = $count->userid;
|
||||
set_cached_data(3600, serialize($count), "get_mysql_user".$clause);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
function get_cpu_time ($appid) {
|
||||
$result = mysql_query("
|
||||
Select ceil(avg(cpu_time)/3600*100)/100 as cpu_time,
|
||||
ceil(min(cpu_time)/3600*100)/100 as min,
|
||||
ceil(max(cpu_time)/3600*100)/100 as max
|
||||
from (SELECT cpu_time FROM `result` WHERE appid = $appid and validate_state =1 and received_time > (unix_timestamp()-(3600*24)) ORDER BY `received_time` DESC limit 100) t");
|
||||
$count = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
function get_cpu_time($appid) {
|
||||
$count = unserialize(get_cached_data(3600, "get_cpu_time".$appid));
|
||||
if ($count == false) {
|
||||
$result = mysql_query("
|
||||
Select ceil(avg(cpu_time)/3600*100)/100 as cpu_time,
|
||||
ceil(min(cpu_time)/3600*100)/100 as min,
|
||||
ceil(max(cpu_time)/3600*100)/100 as max
|
||||
from (SELECT cpu_time FROM `result` WHERE appid = $appid and validate_state =1 and received_time > (unix_timestamp()-(3600*24)) ORDER BY `received_time` DESC limit 100) t");
|
||||
$count = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
set_cached_data(3600, serialize($count), "get_cpu_time".$appid);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
@ -340,12 +358,16 @@ if ($retval) {
|
|||
get_mysql_count("result where file_delete_state=1")
|
||||
);
|
||||
|
||||
$result = mysql_query("select MIN(transition_time) as min from workunit");
|
||||
$min = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
$gap = (time() - $min->min)/3600;
|
||||
if (($gap < 0) || ($min->min == 0)) {
|
||||
$gap = 0;
|
||||
$gap = unserialize(get_cached_data(3600, "transitioner_backlog"));
|
||||
if ($gap === false) {
|
||||
$result = mysql_query("select MIN(transition_time) as min from workunit");
|
||||
$min = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
$gap = (time() - $min->min)/3600;
|
||||
if (($gap < 0) || ($min->min == 0)) {
|
||||
$gap = 0;
|
||||
}
|
||||
set_cached_data(3600, serialize($gap), "transitioner_backlog");
|
||||
}
|
||||
show_counts(
|
||||
tra("Transitioner backlog (hours)"),
|
||||
|
@ -441,5 +463,4 @@ if ($xml) {
|
|||
page_tail();
|
||||
}
|
||||
|
||||
end_cache($cache_period, $cache_args);
|
||||
?>
|
||||
|
|
|
@ -37,15 +37,15 @@ if ($offset > 1000) {
|
|||
|
||||
$teamid = get_int("teamid");
|
||||
|
||||
$cache_args = "teamid=$teamid&offset=$offset&sort_by=$sort_by";
|
||||
start_cache(TEAM_PAGE_TTL, $cache_args);
|
||||
|
||||
$team = BoincTeam::lookup_id($teamid);
|
||||
$cache_args = "teamid=$teamid";
|
||||
$team = unserialize(get_cached_data(TEAM_PAGE_TTL, $cache_args));
|
||||
if (!$team) {
|
||||
$team = BoincTeam::lookup_id($teamid);
|
||||
set_cached_data(TEAM_PAGE_TTL, serialize($team), $cache_args);
|
||||
}
|
||||
|
||||
page_head(tra("Members of %1", "<a href=team_display.php?teamid=$teamid>$team->name</a>"));
|
||||
display_team_members($team, $offset, $sort_by);
|
||||
page_tail();
|
||||
|
||||
end_cache(TEAM_PAGE_TTL, $cache_args);
|
||||
|
||||
?>
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once("../inc/util.inc");
|
||||
require_once("../inc/db.inc");
|
||||
require_once("../inc/wap.inc");
|
||||
require_once("../inc/cache.inc");
|
||||
|
||||
check_get_args(array("id"));
|
||||
|
||||
|
@ -29,45 +27,46 @@ function show_credit_wap($user) {
|
|||
return $retstr;
|
||||
}
|
||||
|
||||
function show_user_wap($user) {
|
||||
wap_begin();
|
||||
if (!$user) {
|
||||
echo "<br/>".tra("User not found!")."<br/>";
|
||||
wap_end();
|
||||
return;
|
||||
}
|
||||
|
||||
function show_user_wap($userid) {
|
||||
wap_begin();
|
||||
|
||||
$cache = unserialize(get_cached_data(USER_PAGE_TTL, "userid=".$userid));
|
||||
if (!$cache) {
|
||||
$cache = new stdClass;
|
||||
$cache->user = BoincUser::lookup_id($userid);
|
||||
if ($cache->user->teamid) {
|
||||
$cache->team = BoincTeam::lookup_id($cache->user->teamid);
|
||||
}
|
||||
$cache->wap_timestamp = wap_timestamp();
|
||||
set_cached_data(USER_PAGE_TTL, serialize($cache), "userid=".$userid);
|
||||
}
|
||||
|
||||
if (!$cache->user) {
|
||||
echo "<br/>".tra("User not found!")."<br/>";
|
||||
wap_end();
|
||||
return;
|
||||
}
|
||||
|
||||
// keep a 'running tab' in wapstr in case exceeds 1K WAP limit
|
||||
|
||||
$wapstr = PROJECT . "<br/>".tra("Account Data<br/>for %1<br/>Time:", $user->name)." " . wap_timestamp();
|
||||
$wapstr .= show_credit_wap($user);
|
||||
if ($user->teamid) {
|
||||
$team = BoincTeam::lookup_id($user->teamid);
|
||||
$wapstr .= "<br/>".tra("Team:")." $team->name<br/>";
|
||||
$wapstr .= tra("Team TotCred:")." " . format_credit($team->total_credit) . "<br/>";
|
||||
$wapstr .= tra("Team AvgCred:")." " . format_credit($team->expavg_credit) . "<br/>";
|
||||
|
||||
$wapstr = PROJECT."<br/>".tra("Account Data<br/>for %1<br/>Time:", $cache->user->name)." ".$cache->wap_timestamp;
|
||||
$wapstr .= show_credit_wap($cache->user);
|
||||
if ($cache->user->teamid) {
|
||||
$wapstr .= "<br/>".tra("Team:")." ".$cache->team->name."<br/>";
|
||||
$wapstr .= tra("Team TotCred:")." " . format_credit($cache->team->total_credit) . "<br/>";
|
||||
$wapstr .= tra("Team AvgCred:")." " . format_credit($cache->team->expavg_credit) . "<br/>";
|
||||
} else {
|
||||
$wapstr .= "<br/>".tra("Team: None")."<br/>";
|
||||
}
|
||||
|
||||
// don't want to send more than 1KB probably?
|
||||
if (strlen($wapstr)>1024) {
|
||||
echo substr($wapstr,0,1024);
|
||||
} else {
|
||||
echo $wapstr;
|
||||
}
|
||||
|
||||
wap_end();
|
||||
|
||||
// don't want to send more than 1KB probably?
|
||||
if (strlen($wapstr) > 1024) {
|
||||
$wapstr = substr($wapstr, 0, 1024);
|
||||
}
|
||||
|
||||
echo $wapstr;
|
||||
wap_end();
|
||||
}
|
||||
|
||||
$userid = get_int('id');
|
||||
show_user_wap(get_int('id'));
|
||||
|
||||
$cache_args = "userid=".$userid;
|
||||
start_cache(USER_PAGE_TTL, $cache_args);
|
||||
|
||||
$user = BoincUser::lookup_id($userid);
|
||||
show_user_wap($user);
|
||||
|
||||
end_cache(USER_PAGE_TTL, $cache_args);
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue