diff --git a/html/inc/boinc_db.inc b/html/inc/boinc_db.inc index f5868fddc63..eb4d91e9295 100644 --- a/html/inc/boinc_db.inc +++ b/html/inc/boinc_db.inc @@ -143,6 +143,7 @@ class BoincDb extends DbConn { } static function escape_string($string) { + if (!$string) return ''; $db = self::get(); return $db->base_escape_string(trim($string)); } diff --git a/html/inc/user.inc b/html/inc/user.inc index cb0bc7e4bf9..26d6ba8bebb 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -249,11 +249,9 @@ function show_user_info_private($user) { } row2(tra("Email address"), $email_text); } - if (USER_URL) { - if ($user->url) { - $u = normalize_user_url($user->url); - row2(tra("URL"), sprintf('%s', $u, $u)); - } + if (USER_URL && $user->url) { + $u = normalize_user_url($user->url); + row2(tra("URL"), sprintf('%s', $u, $u)); } if (USER_COUNTRY) { row2(tra("Country"), $user->country); @@ -461,14 +459,12 @@ function show_user_summary_public($user) { if (USER_COUNTRY) { row2(tra("Country"), $user->country); } - if (USER_URL) { + if (USER_URL && $user->url) { // don't show URL if user has no recent credit (spam suppression) // - if ($user->url) { - if (!NO_COMPUTING || $user->expavg_credit > 1) { - $u = normalize_user_url($user->url); - row2(tra("URL"), sprintf('%s', $u, $u)); - } + if (!NO_COMPUTING || $user->expavg_credit > 1) { + $u = normalize_user_url($user->url); + row2(tra("URL"), sprintf('%s', $u, $u)); } } if (!NO_COMPUTING) { diff --git a/html/inc/util.inc b/html/inc/util.inc index 7fd3d7f822b..cbfef28bc0c 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -443,17 +443,17 @@ function time_diff($x, $res=3) { function date_str($x) { if ($x == 0) return "---"; - return gmdate('j M Y', $x); + return gmdate('j M Y', (int)$x); } function time_str($x) { if ($x == 0) return "---"; - return gmdate('j M Y, G:i:s', $x) . " UTC"; + return gmdate('j M Y, G:i:s', (int)$x) . " UTC"; } function local_time_str($x) { if ($x == 0) return "---"; - return date('j M Y, H:i T', $x); + return date('j M Y, H:i T', (int)$x); } function pretty_time_str($x) { @@ -1034,13 +1034,10 @@ function sanitize_tags($x) { } function sanitize_numeric($x) { - if (is_numeric($x)) { - return $x; - } else if (trim($x) == '' ) { + if (!$x || !is_numeric($x)) { return ''; - } else { - return "not numeric"; } + return $x; } function sanitize_email($x) { diff --git a/html/inc/xml.inc b/html/inc/xml.inc index b6e289e17e1..7f2cf8e21e9 100644 --- a/html/inc/xml.inc +++ b/html/inc/xml.inc @@ -116,7 +116,7 @@ function show_user_xml($user, $show_hosts) { if (USER_COUNTRY) { echo " $user->country\n"; } - if (USER_URL) { + if (USER_URL && $user->url) { $url = normalize_user_url($user->url); echo " ".htmlspecialchars($url)."\n"; } @@ -126,7 +126,6 @@ function show_user_xml($user, $show_hosts) { function show_team_member($user, $creditonly = false) { if ($creditonly && !$user->total_credit) { return; } $cpid = md5($user->cross_project_id.$user->email_addr); - $url = normalize_user_url($user->url); echo " $user->id $cpid @@ -141,7 +140,7 @@ function show_team_member($user, $creditonly = false) { if (USER_COUNTRY) { echo " $user->country\n"; } - if (USER_URL) { + if (USER_URL && $user->url) { $url = normalize_user_url($user->url); echo " ".htmlspecialchars($url)."\n"; } diff --git a/html/user/server_status.php b/html/user/server_status.php index 36bf33644ac..4c04766679f 100644 --- a/html/user/server_status.php +++ b/html/user/server_status.php @@ -113,57 +113,57 @@ function show_status_html($x) { $daemons = $x->daemons; start_table(); echo "\n"; - echo " -

".tra("Server status")."

- "; - start_table('table-striped'); - table_header(tra("Program"), tra("Host"), tra("Status")); - foreach ($daemons->local_daemons as $d) { - daemon_html($d); - } - foreach ($daemons->remote_daemons as $d) { - daemon_html($d); - } - foreach ($daemons->disabled_daemons as $d) { - daemon_html($d); - } - end_table(); + echo " +

".tra("Server status")."

+ "; + start_table('table-striped'); + table_header(tra("Program"), tra("Host"), tra("Status")); + foreach ($daemons->local_daemons as $d) { + daemon_html($d); + } + foreach ($daemons->remote_daemons as $d) { + daemon_html($d); + } + foreach ($daemons->disabled_daemons as $d) { + daemon_html($d); + } + end_table(); - if ($daemons->cached_time) { - echo "
Remote daemon status as of ", time_str($daemons->cached_time); - } - if ($daemons->missing_remote_status) { - echo "
Status of remote daemons is missing\n"; - } - if (function_exists('server_status_project_info')) { - echo "
"; - server_status_project_info(); - } + if ($daemons->cached_time) { + echo "
Remote daemon status as of ", time_str($daemons->cached_time); + } + if ($daemons->missing_remote_status) { + echo "
Status of remote daemons is missing\n"; + } + if (function_exists('server_status_project_info')) { + echo "
"; + server_status_project_info(); + } echo "\n"; - echo "

".tra("Computing status")."

\n"; - echo "

".tra("Work")."

\n"; - start_table('table-striped'); - item_html("Tasks ready to send", $j->results_ready_to_send); - item_html("Tasks in progress", $j->results_in_progress); - item_html("Workunits waiting for validation", $j->wus_need_validate); - item_html("Workunits waiting for assimilation", $j->wus_need_assimilate); - item_html("Workunits waiting for file deletion", $j->wus_need_file_delete); - item_html("Tasks waiting for file deletion", $j->results_need_file_delete); - item_html("Transitioner backlog (hours)", number_format($j->transitioner_backlog, 2)); - end_table(); - echo "

".tra("Users")."

\n"; - start_table('table-striped'); - item_html("With credit", $j->users_with_credit); - item_html("With recent credit", $j->users_with_recent_credit); - item_html("Registered in past 24 hours", $j->users_past_24_hours); - end_table(); - echo "

".tra("Computers")."

\n"; - start_table('table-striped'); - item_html("With credit", $j->hosts_with_credit); - item_html("With recent credit", $j->hosts_with_recent_credit); - item_html("Registered in past 24 hours", $j->hosts_past_24_hours); - item_html("Current GigaFLOPS", round($j->flops, 2)); - end_table(); + echo "

".tra("Computing status")."

\n"; + echo "

".tra("Work")."

\n"; + start_table('table-striped'); + item_html("Tasks ready to send", $j->results_ready_to_send); + item_html("Tasks in progress", $j->results_in_progress); + item_html("Workunits waiting for validation", $j->wus_need_validate); + item_html("Workunits waiting for assimilation", $j->wus_need_assimilate); + item_html("Workunits waiting for file deletion", $j->wus_need_file_delete); + item_html("Tasks waiting for file deletion", $j->results_need_file_delete); + item_html("Transitioner backlog (hours)", number_format($j->transitioner_backlog, 2)); + end_table(); + echo "

".tra("Users")."

\n"; + start_table('table-striped'); + item_html("With credit", $j->users_with_credit); + item_html("With recent credit", $j->users_with_recent_credit); + item_html("Registered in past 24 hours", $j->users_past_24_hours); + end_table(); + echo "

".tra("Computers")."

\n"; + start_table('table-striped'); + item_html("With credit", $j->hosts_with_credit); + item_html("With recent credit", $j->hosts_with_recent_credit); + item_html("Registered in past 24 hours", $j->hosts_past_24_hours); + item_html("Current GigaFLOPS", round($j->flops, 2)); + end_table(); echo "\n"; end_table(); echo "

".tra("Tasks by application")."

\n"; @@ -426,7 +426,12 @@ function get_job_status() { AND received_time > (unix_timestamp()-86400) " ); - $app->info = $info; + // $info fields will be null if app has no results + if ($info->avg) { + $app->info = $info; + } else { + $app->info = null; + } $app->unsent = BoincResult::count("appid=$app->id and server_state=2"); $app->in_progress = BoincResult::count("appid=$app->id and server_state=4"); }