@@ -218,13 +218,13 @@ |
||
| 218 | 218 | function get_file($user) { |
| 219 | 219 | $dir = sandbox_dir($user); |
| 220 | 220 | $url = post_str('url'); |
| 221 | - if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { |
|
| 221 | + if (filter_var($url, FILTER_VALIDATE_URL) === false) { |
|
| 222 | 222 | error_page('Not a valid URL'); |
| 223 | 223 | } |
| 224 | 224 | $fname = basename($url); |
| 225 | 225 | $path = "$dir/$fname"; |
| 226 | 226 | if (file_exists($path)) { |
| 227 | - error_page("File $fname exists; delete it first."); |
|
| 227 | + error_page("file $fname exists; delete it first."); |
|
| 228 | 228 | } |
| 229 | 229 | copy($url, $path); |
| 230 | 230 | $notice = "Fetched file from <strong>$url</strong><br/>"; |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | // Check if consent to terms of use has been given. |
| 195 | 195 | // |
| 196 | - $myconsent = FALSE; |
|
| 196 | + $myconsent = false; |
|
| 197 | 197 | list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL); |
| 198 | 198 | if ($checkct and check_termsofuse()) { |
| 199 | 199 | $agree = post_str("agree_to_terms_of_use", true); |
| 200 | 200 | if (!$agree) { |
| 201 | 201 | error_page(tra("You have not agreed to our terms of use. Please agree to the terms of use by navigating back to the previous page, in order to create your account")); |
| 202 | 202 | } |
| 203 | - $myconsent = TRUE; |
|
| 203 | + $myconsent = true; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // see whether the new account should be pre-enrolled in a team, |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $team = BoincTeam::lookup_id($teamid); |
| 212 | 212 | $clone_user = BoincUser::lookup_id($team->userid); |
| 213 | 213 | if (!$clone_user) { |
| 214 | - error_page("User $team->userid not found"); |
|
| 214 | + error_page("user $team->userid not found"); |
|
| 215 | 215 | } |
| 216 | 216 | $project_prefs = $clone_user->project_prefs; |
| 217 | 217 | } else { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | require_once("../inc/boinc_db.inc"); |
| 22 | 22 | require_once("../inc/util.inc"); |
| 23 | 23 | |
| 24 | -define('CONSENT_TYPE_ENROLL','ENROLL'); |
|
| 24 | +define('CONSENT_TYPE_ENROLL', 'ENROLL'); |
|
| 25 | 25 | |
| 26 | 26 | function check_termsofuse() { |
| 27 | 27 | return defined('TERMSOFUSE_FILE') and file_exists(TERMSOFUSE_FILE); |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | $source, $ctime = 0 |
| 33 | 33 | ) { |
| 34 | 34 | $mys = BoincDb::escape_string($source); |
| 35 | - if ($ctime==0) { |
|
| 35 | + if ($ctime == 0) { |
|
| 36 | 36 | $mytime = $user->create_time; |
| 37 | 37 | } else { |
| 38 | 38 | $mytime = $ctime; |
| 39 | 39 | } |
| 40 | 40 | return BoincConsent::insert( |
| 41 | - "(userid, consent_type_id, consent_time, consent_flag, consent_not_required, source) " . |
|
| 41 | + "(userid, consent_type_id, consent_time, consent_flag, consent_not_required, source) ". |
|
| 42 | 42 | "values($user->id, $consent_type_id, $mytime, $consent_flag, $consent_not_required, '$mys')" |
| 43 | 43 | ); |
| 44 | 44 | |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | // The integer is the consent_type_id- the id from consent_type table. |
| 66 | 66 | // If the boolean is FALSE, the integer returned is -1. |
| 67 | 67 | // |
| 68 | -function check_consent_type($name, $checkenabled=TRUE) { |
|
| 68 | +function check_consent_type($name, $checkenabled = TRUE) { |
|
| 69 | 69 | $name = BoincDb::escape_string($name); |
| 70 | 70 | $ct = BoincConsentType::lookup("shortname = '$name'"); |
| 71 | - if ($ct and ( !$checkenabled or ($ct->enabled)) ) { |
|
| 71 | + if ($ct and (!$checkenabled or ($ct->enabled))) { |
|
| 72 | 72 | return array(TRUE, $ct->id); |
| 73 | 73 | } |
| 74 | 74 | return array(FALSE, -1); |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | "userid=$user->id AND consent_type_id=$ctid AND consent_flag=1" |
| 53 | 53 | ); |
| 54 | 54 | if ($consent_result) { |
| 55 | - return TRUE; |
|
| 55 | + return true; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | - return FALSE; |
|
| 58 | + return false; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Check if a particular consent_type name is available. |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | // The integer is the consent_type_id- the id from consent_type table. |
| 66 | 66 | // If the boolean is FALSE, the integer returned is -1. |
| 67 | 67 | // |
| 68 | -function check_consent_type($name, $checkenabled=TRUE) { |
|
| 68 | +function check_consent_type($name, $checkenabled=true) { |
|
| 69 | 69 | $name = BoincDb::escape_string($name); |
| 70 | 70 | $ct = BoincConsentType::lookup("shortname = '$name'"); |
| 71 | 71 | if ($ct and ( !$checkenabled or ($ct->enabled)) ) { |
| 72 | - return array(TRUE, $ct->id); |
|
| 72 | + return array(true, $ct->id); |
|
| 73 | 73 | } |
| 74 | - return array(FALSE, -1); |
|
| 74 | + return array(false, -1); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // When a user uses the Web site to login, this function checks the |
@@ -33,17 +33,17 @@ discard block |
||
| 33 | 33 | // |
| 34 | 34 | $config = get_config(); |
| 35 | 35 | global $master_url; |
| 36 | -$master_url = parse_config($config , "<master_url>"); |
|
| 36 | +$master_url = parse_config($config, "<master_url>"); |
|
| 37 | 37 | $recaptcha_public_key = parse_config($config, "<recaptcha_public_key>"); |
| 38 | 38 | $recaptcha_private_key = parse_config($config, "<recaptcha_private_key>"); |
| 39 | 39 | |
| 40 | 40 | // Set parameters to defaults if not defined in config.xml |
| 41 | 41 | |
| 42 | 42 | $x = parse_config($config, "<user_country>"); |
| 43 | -define('USER_COUNTRY', ($x===null)?1:(int)$x); |
|
| 43 | +define('USER_COUNTRY', ($x === null) ? 1 : (int)$x); |
|
| 44 | 44 | |
| 45 | 45 | $x = parse_config($config, "<user_url>"); |
| 46 | -define('USER_URL', ($x===null)?1:(int)$x); |
|
| 46 | +define('USER_URL', ($x === null) ? 1 : (int)$x); |
|
| 47 | 47 | |
| 48 | 48 | // Set parameters to defaults if not defined in project.inc |
| 49 | 49 | |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | function url_base() { |
| 154 | - return is_https()?secure_url_base():URL_BASE; |
|
| 154 | + return is_https() ?secure_url_base() : URL_BASE; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
| 157 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
| 158 | 158 | global $master_url; |
| 159 | 159 | |
| 160 | 160 | // the following allows independent login for projects on the same server |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | $path = substr($path, 0, -1); |
| 166 | 166 | $path .= "_ops/"; |
| 167 | 167 | } |
| 168 | - $expire = $permanent?time()+3600*24*365:0; |
|
| 168 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
| 169 | 169 | setcookie($name, $value, $expire, $path, |
| 170 | 170 | '', |
| 171 | - is_https(), // if this page is secure, make cookie secure |
|
| 171 | + is_https(), // if this page is secure, make cookie secure |
|
| 172 | 172 | true // httponly; no JS access |
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | -function clear_cookie($name, $ops=false) { |
|
| 176 | +function clear_cookie($name, $ops = false) { |
|
| 177 | 177 | global $master_url; |
| 178 | 178 | $url = parse_url($master_url); |
| 179 | 179 | $path = $url['path']; |
@@ -181,13 +181,13 @@ discard block |
||
| 181 | 181 | $path = substr($path, 0, -1); |
| 182 | 182 | $path .= "_ops/"; |
| 183 | 183 | } |
| 184 | - setcookie($name, '', time()-3600, $path); |
|
| 184 | + setcookie($name, '', time() - 3600, $path); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $g_logged_in_user = null; |
| 188 | 188 | $got_logged_in_user = false; |
| 189 | 189 | |
| 190 | -function get_logged_in_user($must_be_logged_in=true) { |
|
| 190 | +function get_logged_in_user($must_be_logged_in = true) { |
|
| 191 | 191 | global $g_logged_in_user, $got_logged_in_user; |
| 192 | 192 | if ($got_logged_in_user) { |
| 193 | 193 | // this could have been called earlier with $must_be_logged_in false |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $next_url = $_SERVER['REQUEST_URI']; |
| 214 | 214 | $n = strrpos($next_url, "/"); |
| 215 | 215 | if ($n) { |
| 216 | - $next_url = substr($next_url, $n+1); |
|
| 216 | + $next_url = substr($next_url, $n + 1); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | $next_url = urlencode($next_url); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | return $g_logged_in_user; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | -function show_login_info($prefix="") { |
|
| 227 | +function show_login_info($prefix = "") { |
|
| 228 | 228 | $user = get_logged_in_user(false); |
| 229 | 229 | if ($user) { |
| 230 | 230 | $url_tokens = url_tokens($user->authenticator); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | -$cache_control_extra=""; |
|
| 237 | +$cache_control_extra = ""; |
|
| 238 | 238 | $is_login_page = false; |
| 239 | 239 | |
| 240 | 240 | // Call this to start pages. |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | // with an existing web framework can more easily do so. |
| 247 | 247 | // To do so, define page_head() in the project include file. |
| 248 | 248 | // |
| 249 | -if (!function_exists("page_head")){ |
|
| 249 | +if (!function_exists("page_head")) { |
|
| 250 | 250 | function page_head( |
| 251 | 251 | $title, |
| 252 | 252 | // page title. Put in <title>, used as title for browser tab. |
| 253 | - $body_attrs=null, |
|
| 253 | + $body_attrs = null, |
|
| 254 | 254 | // <body XXXX> |
| 255 | 255 | // e.g. Javascript to put focus in an input field |
| 256 | 256 | // (onload="document.form.foo.focus()") |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | // if set, include schedulers.txt. |
| 260 | 260 | // also pass to project_banner() in case you want a different |
| 261 | 261 | // header for your main page. |
| 262 | - $url_prefix="", |
|
| 262 | + $url_prefix = "", |
|
| 263 | 263 | // prepend this to links. |
| 264 | 264 | // Use for web pages not in the top directory |
| 265 | - $head_extra=null |
|
| 265 | + $head_extra = null |
|
| 266 | 266 | // extra stuff to put in <head>. E.g.: |
| 267 | 267 | // reCAPTCHA code (create_profile.php) |
| 268 | 268 | // bbcode javascript (forums) |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | header("Content-type: text/html; charset=utf-8"); |
| 285 | 285 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
| 286 | 286 | // Date in the past |
| 287 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
| 287 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
| 288 | 288 | // always modified |
| 289 | 289 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
| 290 | 290 | // for HTTP/1.1 |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | if ($head_extra) { |
| 306 | 306 | echo "\n$head_extra\n"; |
| 307 | 307 | } |
| 308 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
| 308 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
| 309 | 309 | readfile("schedulers.txt"); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - $t = $title?$title:PROJECT; |
|
| 312 | + $t = $title ? $title : PROJECT; |
|
| 313 | 313 | echo "<title>$t</title>\n"; |
| 314 | 314 | echo ' |
| 315 | 315 | <meta charset="utf-8"> |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | echo '<div class="container-fluid"> |
| 366 | 366 | '; |
| 367 | 367 | |
| 368 | - switch($title) { //kludge |
|
| 368 | + switch ($title) { //kludge |
|
| 369 | 369 | case tra("Log in"): |
| 370 | 370 | case tra("Create an account"): |
| 371 | 371 | case tra("Server status page"): |
@@ -380,13 +380,13 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | // See the comments for page_head() |
| 382 | 382 | // |
| 383 | -if (!function_exists("page_tail")){ |
|
| 383 | +if (!function_exists("page_tail")) { |
|
| 384 | 384 | function page_tail( |
| 385 | - $show_date=false, |
|
| 385 | + $show_date = false, |
|
| 386 | 386 | // true for pages that are generated periodically rather than on the fly |
| 387 | - $url_prefix="", |
|
| 387 | + $url_prefix = "", |
|
| 388 | 388 | // use for pages not at top level |
| 389 | - $is_main=false |
|
| 389 | + $is_main = false |
|
| 390 | 390 | // passed to project_footer; |
| 391 | 391 | ) { |
| 392 | 392 | echo "<br>\n"; |
@@ -421,24 +421,24 @@ discard block |
||
| 421 | 421 | // convert time interval in seconds to a string of the form |
| 422 | 422 | // 'D days h hours m min s sec'. |
| 423 | 423 | |
| 424 | -function time_diff($x, $res=3) { |
|
| 424 | +function time_diff($x, $res = 3) { |
|
| 425 | 425 | $x = (int)$x; |
| 426 | 426 | $days = (int)($x/86400); |
| 427 | - $hours = (int)(($x-$days*86400)/3600); |
|
| 428 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
| 429 | - $seconds = $x % 60; |
|
| 427 | + $hours = (int)(($x - $days*86400)/3600); |
|
| 428 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
| 429 | + $seconds = $x%60; |
|
| 430 | 430 | |
| 431 | 431 | $s = ""; |
| 432 | 432 | if ($days) { |
| 433 | 433 | $s .= "$days ".tra("days")." "; |
| 434 | 434 | } |
| 435 | - if ($res>0 && ($hours || strlen($s))) { |
|
| 435 | + if ($res > 0 && ($hours || strlen($s))) { |
|
| 436 | 436 | $s .= "$hours ".tra("hours")." "; |
| 437 | 437 | } |
| 438 | - if ($res>1 && ($minutes || strlen($s))) { |
|
| 438 | + if ($res > 1 && ($minutes || strlen($s))) { |
|
| 439 | 439 | $s .= "$minutes ".tra("min")." "; |
| 440 | 440 | } |
| 441 | - if ($res>2) { |
|
| 441 | + if ($res > 2) { |
|
| 442 | 442 | $s .= "$seconds ".tra("sec")." "; |
| 443 | 443 | } |
| 444 | 444 | return $s; |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | function time_str($x) { |
| 454 | 454 | if ($x == 0) return "---"; |
| 455 | - return gmdate('j M Y, G:i:s', (int)$x) . " UTC"; |
|
| 455 | + return gmdate('j M Y, G:i:s', (int)$x)." UTC"; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | function local_time_str($x) { |
@@ -464,14 +464,14 @@ discard block |
||
| 464 | 464 | return time_str($x); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | -function start_table_str($class="", $style="") { |
|
| 468 | - $s = $style?'style="'.$style.'"':''; |
|
| 467 | +function start_table_str($class = "", $style = "") { |
|
| 468 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
| 469 | 469 | return '<div class="table"> |
| 470 | 470 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
| 471 | 471 | '; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | -function start_table($class="", $style="") { |
|
| 474 | +function start_table($class = "", $style = "") { |
|
| 475 | 475 | echo start_table_str($class, $style); |
| 476 | 476 | } |
| 477 | 477 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | echo "</tr>\n"; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | -function row1($x, $ncols=2, $class="heading") { |
|
| 519 | +function row1($x, $ncols = 2, $class = "heading") { |
|
| 520 | 520 | if ($class == "heading") { |
| 521 | 521 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
| 522 | 522 | } else { |
@@ -530,10 +530,10 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | // a table row with 2 columns, with the left on right-aligned |
| 532 | 532 | |
| 533 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
| 534 | - if ($x==="") $x="<br>"; |
|
| 535 | - if ($y==="") $y="<br>"; |
|
| 536 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
| 533 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
| 534 | + if ($x === "") $x = "<br>"; |
|
| 535 | + if ($y === "") $y = "<br>"; |
|
| 536 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
| 537 | 537 | echo "<tr> |
| 538 | 538 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
| 539 | 539 | <td $attrs >$y</td> |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | // output the first part of row2(); |
| 545 | 545 | // then write the content, followed by </td></tr> |
| 546 | 546 | |
| 547 | -function row2_init($x, $lwidth='40%') { |
|
| 547 | +function row2_init($x, $lwidth = '40%') { |
|
| 548 | 548 | echo sprintf('<tr> |
| 549 | 549 | <td width="%s" %s>%s</td> |
| 550 | 550 | <td %s>', |
@@ -560,31 +560,31 @@ discard block |
||
| 560 | 560 | echo "<tr><td>$string</td></tr>"; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | -function row_array($x, $attrs=null) { |
|
| 563 | +function row_array($x, $attrs = null) { |
|
| 564 | 564 | echo "<tr>\n"; |
| 565 | 565 | $i = 0; |
| 566 | 566 | foreach ($x as $h) { |
| 567 | - $a = $attrs?$attrs[$i]:""; |
|
| 567 | + $a = $attrs ? $attrs[$i] : ""; |
|
| 568 | 568 | echo "<td $a>$h</td>\n"; |
| 569 | 569 | $i++; |
| 570 | 570 | } |
| 571 | 571 | echo "</tr>\n"; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
| 574 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
| 575 | 575 | |
| 576 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
| 576 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
| 577 | 577 | echo "<tr>"; |
| 578 | 578 | $i = 0; |
| 579 | 579 | foreach ($x as $h) { |
| 580 | - $a = $attrs?$attrs[$i]:""; |
|
| 580 | + $a = $attrs ? $attrs[$i] : ""; |
|
| 581 | 581 | echo "<th $a class=\"$class\">$h</th>"; |
| 582 | 582 | $i++; |
| 583 | 583 | } |
| 584 | 584 | echo "</tr>\n"; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | -function row_heading($x, $class='bg-primary') { |
|
| 587 | +function row_heading($x, $class = 'bg-primary') { |
|
| 588 | 588 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
| 589 | 589 | ', $class, $x |
| 590 | 590 | ); |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
| 645 | 645 | // is cut short. |
| 646 | 646 | |
| 647 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
| 647 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
| 648 | 648 | $words = explode($delimiter, $sentence); |
| 649 | 649 | $total_chars = 0; |
| 650 | 650 | $trunc = false; |
@@ -727,8 +727,8 @@ discard block |
||
| 727 | 727 | |
| 728 | 728 | // returns null if the arg is optional and missing |
| 729 | 729 | // |
| 730 | -function get_int($name, $optional=false) { |
|
| 731 | - $x=null; |
|
| 730 | +function get_int($name, $optional = false) { |
|
| 731 | + $x = null; |
|
| 732 | 732 | if (isset($_GET[$name])) $x = $_GET[$name]; |
| 733 | 733 | if (!is_numeric($x)) { |
| 734 | 734 | if ($optional) { |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | |
| 748 | 748 | // returns null if the arg is optional and missing |
| 749 | 749 | // |
| 750 | -function post_num($name, $optional=false) { |
|
| 750 | +function post_num($name, $optional = false) { |
|
| 751 | 751 | $x = null; |
| 752 | 752 | if (isset($_POST[$name])) $x = $_POST[$name]; |
| 753 | 753 | if (!is_numeric($x)) { |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | |
| 763 | 763 | // returns null if the arg is optional and missing |
| 764 | 764 | // |
| 765 | -function post_int($name, $optional=false) { |
|
| 765 | +function post_int($name, $optional = false) { |
|
| 766 | 766 | $x = post_num($name, $optional); |
| 767 | 767 | if (is_null($x)) return null; |
| 768 | 768 | $y = (int)$x; |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | -function get_str($name, $optional=false) { |
|
| 783 | +function get_str($name, $optional = false) { |
|
| 784 | 784 | if (isset($_GET[$name])) { |
| 785 | 785 | $x = $_GET[$name]; |
| 786 | 786 | } else { |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | return undo_magic_quotes($x); |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | -function post_str($name, $optional=false) { |
|
| 795 | +function post_str($name, $optional = false) { |
|
| 796 | 796 | if (isset($_POST[$name])) { |
| 797 | 797 | $x = $_POST[$name]; |
| 798 | 798 | } else { |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | return undo_magic_quotes($x); |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | -function post_arr($name, $optional=false) { |
|
| 807 | +function post_arr($name, $optional = false) { |
|
| 808 | 808 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
| 809 | 809 | $x = $_POST[$name]; |
| 810 | 810 | } else { |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | // the mb_* functions are not included by default |
| 821 | 821 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
| 822 | 822 | |
| 823 | - for ($i=0; $i<strlen($str); $i++) { |
|
| 823 | + for ($i = 0; $i < strlen($str); $i++) { |
|
| 824 | 824 | $c = ord(substr($str, $i)); |
| 825 | 825 | if ($c < 32 || $c > 127) return false; |
| 826 | 826 | } |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
| 845 | 845 | // if no value was entered and this is ok |
| 846 | 846 | // |
| 847 | - if ($number=='' && !$low) return true; |
|
| 847 | + if ($number == '' && !$low) return true; |
|
| 848 | 848 | |
| 849 | 849 | // the supplied value contains alphabetic characters |
| 850 | 850 | // |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | // Generate a "select" element from an array of values |
| 863 | 863 | // |
| 864 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
| 864 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
| 865 | 865 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
| 866 | 866 | |
| 867 | 867 | foreach ($array as $key => $value) { |
@@ -886,12 +886,12 @@ discard block |
||
| 886 | 886 | return $str; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | -function strip_bbcode($string){ |
|
| 890 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
| 889 | +function strip_bbcode($string) { |
|
| 890 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | function current_url() { |
| 894 | - $url = is_https()?'https':'http'; |
|
| 894 | + $url = is_https() ? 'https' : 'http'; |
|
| 895 | 895 | $url .= "://"; |
| 896 | 896 | $url .= $_SERVER['SERVER_NAME']; |
| 897 | 897 | $url .= ":".$_SERVER['SERVER_PORT']; |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | // the colors for bootstrap's btn-success are almost illegible; |
| 910 | 910 | // the green is too light. Use a darker green. |
| 911 | 911 | // |
| 912 | -function button_style($color='green', $font_size=null) { |
|
| 912 | +function button_style($color = 'green', $font_size = null) { |
|
| 913 | 913 | $fs = ''; |
| 914 | 914 | if ($font_size) { |
| 915 | 915 | $fs = sprintf('; font-size:%dpx', $font_size); |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | // class: class of the button, e.g. btn |
| 929 | 929 | // extra: Additional text in href tag |
| 930 | 930 | // |
| 931 | -function button_text($url, $text, $desc=null, $class=null, $extra='') { |
|
| 931 | +function button_text($url, $text, $desc = null, $class = null, $extra = '') { |
|
| 932 | 932 | if (!$desc) { |
| 933 | 933 | $desc = $text; |
| 934 | 934 | } |
@@ -943,23 +943,23 @@ discard block |
||
| 943 | 943 | ); |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | -function button_text_small($url, $text, $desc=null) { |
|
| 946 | +function button_text_small($url, $text, $desc = null) { |
|
| 947 | 947 | return button_text($url, $text, $desc, "btn btn-xs", button_style()); |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | -function show_button($url, $text, $desc=null, $class=null, $extra=null) { |
|
| 950 | +function show_button($url, $text, $desc = null, $class = null, $extra = null) { |
|
| 951 | 951 | echo button_text($url, $text, $desc, $class, $extra); |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | // for places with a bunch of buttons, like forum posts |
| 955 | 955 | // |
| 956 | -function show_button_small($url, $text, $desc=null) { |
|
| 956 | +function show_button_small($url, $text, $desc = null) { |
|
| 957 | 957 | echo button_text_small($url, $text, $desc); |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | // used for showing icons |
| 961 | 961 | // |
| 962 | -function show_image($src, $title, $alt, $height=null) { |
|
| 962 | +function show_image($src, $title, $alt, $height = null) { |
|
| 963 | 963 | $h = ""; |
| 964 | 964 | if ($height) { |
| 965 | 965 | $h = "height=\"$height\""; |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | // tries instead to connect to <replica_db_host> if tag exists. |
| 997 | 997 | // DEPRECATED - use boinc_db.inc |
| 998 | 998 | // |
| 999 | -function db_init($try_replica=false) { |
|
| 999 | +function db_init($try_replica = false) { |
|
| 1000 | 1000 | check_web_stopped(); |
| 1001 | 1001 | $retval = db_init_aux($try_replica); |
| 1002 | 1002 | if ($retval == 1) { |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | // Check this to avoid XSS vulnerability |
| 1073 | 1073 | // |
| 1074 | 1074 | function sanitize_sort_by($x) { |
| 1075 | - switch($x) { |
|
| 1075 | + switch ($x) { |
|
| 1076 | 1076 | case 'expavg_credit': |
| 1077 | 1077 | case 'total_credit': |
| 1078 | 1078 | return; |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | function do_download($path) { |
| 1093 | - $name=basename($path); |
|
| 1093 | + $name = basename($path); |
|
| 1094 | 1094 | header('Content-Description: File Transfer'); |
| 1095 | 1095 | header('Content-Type: application/octet-stream'); |
| 1096 | 1096 | header('Content-Disposition: attachment; filename='.$name); |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | header('Expires: 0'); |
| 1099 | 1099 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 1100 | 1100 | header('Pragma: public'); |
| 1101 | - header('Content-Length: ' . filesize($path)); |
|
| 1101 | + header('Content-Length: '.filesize($path)); |
|
| 1102 | 1102 | flush(); |
| 1103 | 1103 | readfile($path); |
| 1104 | 1104 | } |
@@ -1147,10 +1147,10 @@ discard block |
||
| 1147 | 1147 | // Otherwise return 0. |
| 1148 | 1148 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
| 1149 | 1149 | // |
| 1150 | -function boinc_client_version(){ |
|
| 1150 | +function boinc_client_version() { |
|
| 1151 | 1151 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
| 1152 | 1152 | $x = $_SERVER['HTTP_USER_AGENT']; |
| 1153 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
| 1153 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
| 1154 | 1154 | if (preg_match($e, $x, $matches)) { |
| 1155 | 1155 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
| 1156 | 1156 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | $rem_name = $name."_remaining"; |
| 1180 | 1180 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
| 1181 | 1181 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
| 1182 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
| 1182 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
| 1183 | 1183 | ; |
| 1184 | 1184 | } |
| 1185 | 1185 | |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | // use the following around text with long lines, |
| 1210 | 1210 | // to limit the width and make it more readable. |
| 1211 | 1211 | // |
| 1212 | -function text_start($width=640) { |
|
| 1212 | +function text_start($width = 640) { |
|
| 1213 | 1213 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
| 1214 | 1214 | } |
| 1215 | 1215 | function text_end() { |
@@ -1235,7 +1235,7 @@ discard block |
||
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | function cert_filename() { |
| 1238 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
| 1238 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | // if user hasn't validated their email addr, tell them to |