Skip to content

Commit

Permalink
Merge pull request #5470 from BOINC/dpa_php8_2
Browse files Browse the repository at this point in the history
web: fix some PHP8 warnings
  • Loading branch information
AenBleidd authored Dec 22, 2023
2 parents 59a5224 + 2b0c173 commit ab7fefa
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 72 deletions.
1 change: 1 addition & 0 deletions html/inc/boinc_db.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
18 changes: 7 additions & 11 deletions html/inc/user.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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('<a href="%s">%s</a>', $u, $u));
}
if (USER_URL && $user->url) {
$u = normalize_user_url($user->url);
row2(tra("URL"), sprintf('<a href="%s">%s</a>', $u, $u));
}
if (USER_COUNTRY) {
row2(tra("Country"), $user->country);
Expand Down Expand Up @@ -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('<a href="%s">%s</a>', $u, $u));
}
if (!NO_COMPUTING || $user->expavg_credit > 1) {
$u = normalize_user_url($user->url);
row2(tra("URL"), sprintf('<a href="%s">%s</a>', $u, $u));
}
}
if (!NO_COMPUTING) {
Expand Down
13 changes: 5 additions & 8 deletions html/inc/util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions html/inc/xml.inc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function show_user_xml($user, $show_hosts) {
if (USER_COUNTRY) {
echo " <country>$user->country</country>\n";
}
if (USER_URL) {
if (USER_URL && $user->url) {
$url = normalize_user_url($user->url);
echo " <url>".htmlspecialchars($url)."</url>\n";
}
Expand All @@ -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>$user->id</id>
<cpid>$cpid</cpid>
Expand All @@ -141,7 +140,7 @@ function show_team_member($user, $creditonly = false) {
if (USER_COUNTRY) {
echo " <country>$user->country</country>\n";
}
if (USER_URL) {
if (USER_URL && $user->url) {
$url = normalize_user_url($user->url);
echo " <url>".htmlspecialchars($url)."</url>\n";
}
Expand Down
105 changes: 55 additions & 50 deletions html/user/server_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,57 +113,57 @@ function show_status_html($x) {
$daemons = $x->daemons;
start_table();
echo "<tr><td>\n";
echo "
<h3>".tra("Server status")."</h3>
";
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 "
<h3>".tra("Server status")."</h3>
";
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 "<br>Remote daemon status as of ", time_str($daemons->cached_time);
}
if ($daemons->missing_remote_status) {
echo "<br>Status of remote daemons is missing\n";
}
if (function_exists('server_status_project_info')) {
echo "<br>";
server_status_project_info();
}
if ($daemons->cached_time) {
echo "<br>Remote daemon status as of ", time_str($daemons->cached_time);
}
if ($daemons->missing_remote_status) {
echo "<br>Status of remote daemons is missing\n";
}
if (function_exists('server_status_project_info')) {
echo "<br>";
server_status_project_info();
}
echo "</td><td>\n";
echo "<h3>".tra("Computing status")."</h3>\n";
echo "<h4>".tra("Work")."</h4>\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 "<h4>".tra("Users")."</h4>\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 "<h4>".tra("Computers")."</h4>\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 "<h3>".tra("Computing status")."</h3>\n";
echo "<h4>".tra("Work")."</h4>\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 "<h4>".tra("Users")."</h4>\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 "<h4>".tra("Computers")."</h4>\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 "</td></tr>\n";
end_table();
echo "<h3>".tra("Tasks by application")."</h3>\n";
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit ab7fefa

Please sign in to comment.