Skip to content

Commit

Permalink
Merge pull request #5475 from BOINC/dpa_php8_3
Browse files Browse the repository at this point in the history
Fix some PHP8 warnings
  • Loading branch information
AenBleidd authored Dec 27, 2023
2 parents aa0ced8 + 0fa6016 commit be61930
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
27 changes: 14 additions & 13 deletions html/inc/util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -414,30 +414,30 @@ function error_page($msg) {
exit();
}

// takes argument in second and returns a human formatted time string
// in the form D days + h Hours + m Min + s sec.
// convert time interval in seconds to a string of the form
// 'D days h hours m min s sec'.

function time_diff($x, $res=3) {
$x = (int)$x;
$days = (int)($x/86400);
$hours = (int)(($x-$days*86400)/3600);
$minutes = (int)(($x-$days*86400-$hours*3600)/60);
$seconds = (int)($x % 60);
$seconds = $x % 60;

$datestring = "";
$s = "";
if ($days) {
$datestring .= "$days ".tra("days")." ";
$s .= "$days ".tra("days")." ";
}
if ($res>0 && ($hours || strlen($datestring))) {
$datestring .= "$hours ".tra("hours")." ";
if ($res>0 && ($hours || strlen($s))) {
$s .= "$hours ".tra("hours")." ";
}
if ($res>1 && ($minutes || strlen($datestring))) {
$datestring .= "$minutes ".tra("min")." ";
if ($res>1 && ($minutes || strlen($s))) {
$s .= "$minutes ".tra("min")." ";
}
if ($res>2 && ($seconds)) {
$datestring .= "$seconds ".tra("sec")." ";
if ($res>2) {
$s .= "$seconds ".tra("sec")." ";
}

return $datestring;
return $s;
}


Expand Down Expand Up @@ -1019,6 +1019,7 @@ function get_app_types() {
// "next_url" arguments (must be local, not full URLs)
//
function sanitize_local_url($x) {
if (!$x) return $x;
$x = trim($x, "/");
if (strstr($x, "/")) return "";
if (strstr($x, "<")) return "";
Expand Down
17 changes: 15 additions & 2 deletions html/user/am_set_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.

// Handler for an RPC (used by account managers)
// to change attributes of an account.
// This probably shouldn't exist.

require_once("../inc/boinc_db.inc");
require_once("../inc/xml.inc");
require_once("../inc/team.inc");
Expand All @@ -27,6 +31,7 @@
// for now, just make sure it has the given start and end tags,
// and at least one \n in the middle.
// Ideally, we'd like to check that it's valid XML
// WHY NOT USE simplexml_load_string()??
//
function bad_xml($text, $start, $end) {
$text = trim($text);
Expand Down Expand Up @@ -129,19 +134,27 @@ function success($x) {
$show_hosts = BoincDb::escape_string($show_hosts);
$venue = BoincDb::escape_string($venue);
$send_changed_email_to_user = false;
$email_addr = strtolower($email_addr);
if ($email_addr) {
$email_addr = strtolower($email_addr);
}
if ($email_addr && $email_addr != $user->email_addr) {
// is addr already in use?
//
$tmpuser = BoincUser::lookup_email_addr($email_addr);
if ($tmpuser) {
xml_error(ERR_DB_NOT_UNIQUE, "There's already an account with that email address.");
}

//check if the email address is included in previous_email_addr window.
// did another account use this addr previously?
// WHY CHECK THIS???
//
$tmpuser = BoincUser::lookup_prev_email_addr($email_addr);
if ($tmpuser) {
xml_error(ERR_DB_NOT_UNIQUE, "Email address is already in use");
}

// see if email addr was changed too recently
//
if ($user->email_addr_change_time + 604800 > time()) {
xml_error(ERR_BAD_EMAIL_ADDR, "Email address was changed within the past 7 days, please look for an email to $user->previous_email_addr if this email change is incorrect.");
}
Expand Down

0 comments on commit be61930

Please sign in to comment.