From 307b4538d6ba1cd2c62d956a4310303cdb99847c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 8 Jan 2014 17:17:07 -0800 Subject: [PATCH] get_project_config.php: use DB abstraction layer. From Janus. --- html/user/get_project_config.php | 60 ++++++++++++-------------------- html/user/server_status.php | 19 +++++----- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/html/user/get_project_config.php b/html/user/get_project_config.php index a52ac6eba0..9e89d867a5 100644 --- a/html/user/get_project_config.php +++ b/html/user/get_project_config.php @@ -26,34 +26,24 @@ xml_header(); // and update it every hour if possible. // function show_platforms() { - $path = "../cache/platform_list.xml"; - $mtime = @filemtime($path); - if ($mtime && (time() - $mtime) < 3600) { - @readfile($path); - } else { - require_once("../inc/db.inc"); - $retval = db_init_aux(true); - if (!$retval) { - $query = 'select name, user_friendly_name, plan_class from platform, app_version where app_version.platformid = platform.id and app_version.deprecated=0 group by name, plan_class'; - $result = mysql_query($query); - $f = fopen($path, "w"); - fwrite($f, "\n"); - while ($p = mysql_fetch_object($result)) { - if ($p->plan_class) { - $pc = " $p->plan_class\n"; - } else { - $pc = ""; - } - fwrite($f, - " \n $p->name\n $p->user_friendly_name\n$pc \n" - ); - } - mysql_free_result($result); - fwrite($f, "\n"); - fclose($f); - @readfile($path); + $xmlFragment = unserialize(get_cached_data(3600, "project_config_platform_xml")); + if ($xmlFragment==false){ + $platforms = BoincDB::get()->enum_fields("platform, app_version", "BoincPlatform", "name, user_friendly_name, plan_class", "app_version.platformid = platform.id and app_version.deprecated=0 group by name, plan_class", ""); + $xmlFragment = " "; + foreach ($platforms as $platform){ + $xmlFragment .= " + + $platform->name + $platform->user_friendly_name"; + if ($platform->plan_class) $xmlFragment .= " + $platform->plan_class\n"; + $xmlFragment .= " + "; } + $xmlFragment .= "\n \n"; + set_cached_data(3600, serialize($xmlFragment), "project_config_platform_xml"); } + echo $xmlFragment; } $config = get_config(); @@ -71,7 +61,7 @@ echo " $master_url "; -$local_revision = trim(file_get_contents("../../local.revision")); +$local_revision = @trim(file_get_contents("../../local.revision")); if ($local_revision) { echo "$local_revision\n"; } @@ -82,7 +72,7 @@ if (web_stopped()) { 1 "; } else { - echo "0\n"; + echo " 0\n"; } if ($disable_account_creation || defined('INVITE_CODES')) { @@ -93,14 +83,12 @@ if (defined('INVITE_CODES')) { echo " \n"; } -echo " - $min_passwd_length -"; +echo " $min_passwd_length\n"; if (sched_stopped()) { - echo "1\n"; + echo " 1\n"; } else { - echo "0\n"; + echo " 0\n"; } $min_core_client_version = parse_config($config, ""); @@ -114,12 +102,10 @@ $tou_file = "../../terms_of_use.txt"; if (file_exists($tou_file)) { $terms_of_use = trim(file_get_contents($tou_file)); if ($terms_of_use) { - echo "\n$terms_of_use\n\n"; + echo " \n$terms_of_use\n\n"; } } -echo " - -"; +echo ""; ?> diff --git a/html/user/server_status.php b/html/user/server_status.php index d65f193c1d..762a808296 100644 --- a/html/user/server_status.php +++ b/html/user/server_status.php @@ -160,16 +160,17 @@ function get_runtime_info($appid) { $info = unserialize(get_cached_data(3600, "get_runtime_info".$appid)); if ($info == false) { $info = BoincDB::get()->lookup_fields("result", "stdClass", - "ceil(avg(elapsed_time)/3600*100)/100 as avg, - ceil(min(elapsed_time)/3600*100)/100 as min, - ceil(max(elapsed_time)/3600*100)/100 as max, - count(distinct userid) as users", - "appid = $appid - AND validate_state=1 - AND received_time > (unix_timestamp()-(3600*24)) - GROUP BY appid"); + "ceil(avg(elapsed_time)/3600*100)/100 as avg, + ceil(min(elapsed_time)/3600*100)/100 as min, + ceil(max(elapsed_time)/3600*100)/100 as max, + count(distinct userid) as users", + "appid = $appid + AND validate_state=1 + AND received_time > (unix_timestamp()-(3600*24)) + " + ); if (!$info){ - // No workunits found recently + // No recent jobs sound $info = new stdClass; $info->avg = $info->min = $info->max = $info->users = 0; }