@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | $db = BoincDb::get(); |
209 | 209 | return $db->update($this, 'user', $clause); |
210 | 210 | } |
211 | - static function enum($where_clause, $order_clause=null) { |
|
211 | + static function enum($where_clause, $order_clause = null) { |
|
212 | 212 | $db = BoincDb::get(); |
213 | 213 | return $db->enum('user', 'BoincUser', $where_clause, $order_clause); |
214 | 214 | } |
215 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
215 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
216 | 216 | $db = BoincDb::get(); |
217 | 217 | return $db->enum_fields( |
218 | 218 | 'user', 'BoincUser', $fields, $where_clause, $order_clause |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $db = BoincDb::get(); |
262 | 262 | return $db->update($this, 'team', $clause); |
263 | 263 | } |
264 | - static function enum($where_clause, $order_clause=null) { |
|
264 | + static function enum($where_clause, $order_clause = null) { |
|
265 | 265 | $db = BoincDb::get(); |
266 | 266 | return $db->enum('team', 'BoincTeam', $where_clause, $order_clause); |
267 | 267 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $db = BoincDb::get(); |
287 | 287 | return $db->max('team', $field); |
288 | 288 | } |
289 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
289 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
290 | 290 | $db = BoincDb::get(); |
291 | 291 | return $db->enum_fields( |
292 | 292 | 'team', 'BoincTeam', $fields, $where_clause, $order_clause |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | $db = BoincDb::get(); |
323 | 323 | return $db->delete($this, 'host'); |
324 | 324 | } |
325 | - static function enum($where_clause, $order_clause=null) { |
|
325 | + static function enum($where_clause, $order_clause = null) { |
|
326 | 326 | $db = BoincDb::get(); |
327 | 327 | return $db->enum('host', 'BoincHost', $where_clause, $order_clause); |
328 | 328 | } |
329 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
329 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
330 | 330 | $db = BoincDb::get(); |
331 | 331 | return $db->enum_fields( |
332 | 332 | 'host', 'BoincHost', $fields, $where_clause, $order_clause |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | $db = BoincDb::get(); |
446 | 446 | return $db->update($this, 'app', $clause); |
447 | 447 | } |
448 | - static function sum($field, $clause=null) { |
|
448 | + static function sum($field, $clause = null) { |
|
449 | 449 | $db = BoincDb::get(); |
450 | 450 | return $db->sum('app', $field, $clause); |
451 | 451 | } |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | $db = BoincDb::get(); |
502 | 502 | return $db->insert('profile', $clause); |
503 | 503 | } |
504 | - static function enum($where_clause=null, $order_clause=null) { |
|
504 | + static function enum($where_clause = null, $order_clause = null) { |
|
505 | 505 | $db = BoincDb::get(); |
506 | 506 | return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause); |
507 | 507 | } |
508 | - static function enum_fields($fields, $where_clause=null, $order_clause=null) { |
|
508 | + static function enum_fields($fields, $where_clause = null, $order_clause = null) { |
|
509 | 509 | $db = BoincDb::get(); |
510 | 510 | return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause); |
511 | 511 | } |
@@ -889,12 +889,12 @@ discard block |
||
889 | 889 | return $db->enum('consent', 'BoincConsent', $where_clause); |
890 | 890 | } |
891 | 891 | |
892 | - static function insert ($clause) { |
|
892 | + static function insert($clause) { |
|
893 | 893 | $db = BoincDb::get(); |
894 | 894 | return $db->insert('consent', $clause); |
895 | 895 | } |
896 | 896 | |
897 | - static function update ($clause) { |
|
897 | + static function update($clause) { |
|
898 | 898 | $db = BoincDb::get(); |
899 | 899 | return $db->update_aux('consent', $clause); |
900 | 900 | } |
@@ -918,17 +918,17 @@ discard block |
||
918 | 918 | return $db->lookup('consent_type', 'BoincConsentType', $clause); |
919 | 919 | } |
920 | 920 | |
921 | - static function enum($where_clause, $order_clause=null) { |
|
921 | + static function enum($where_clause, $order_clause = null) { |
|
922 | 922 | $db = BoincDb::get(); |
923 | 923 | return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause); |
924 | 924 | } |
925 | 925 | |
926 | - static function insert ($clause) { |
|
926 | + static function insert($clause) { |
|
927 | 927 | $db = BoincDb::get(); |
928 | 928 | return $db->insert('consent_type', $clause); |
929 | 929 | } |
930 | 930 | |
931 | - static function update ($clause) { |
|
931 | + static function update($clause) { |
|
932 | 932 | $db = BoincDb::get(); |
933 | 933 | return $db->update_aux('consent_type', $clause); |
934 | 934 | } |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | return $db->lookup('latest_consent', 'BoincLatestConsent', $clause); |
954 | 954 | } |
955 | 955 | |
956 | - static function enum($where_clause, $order_clause=null) { |
|
956 | + static function enum($where_clause, $order_clause = null) { |
|
957 | 957 | $db = BoincDb::get(); |
958 | 958 | return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause); |
959 | 959 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | // apply this to any user-supplied strings used in queries |
965 | 965 | // |
966 | 966 | function boinc_real_escape_string($x) { |
967 | - if (version_compare(phpversion(),"4.3.0")>=0) { |
|
967 | + if (version_compare(phpversion(), "4.3.0") >= 0) { |
|
968 | 968 | return BoincDb::escape_string($x); |
969 | 969 | } else { |
970 | 970 | $x = str_replace("'", "\'", $x); |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | "; |
47 | 47 | } |
48 | 48 | |
49 | -function xml_error($num=-1, $msg=null, $file=null, $line=null) { |
|
49 | +function xml_error($num = -1, $msg = null, $file = null, $line = null) { |
|
50 | 50 | global $xml_outer_tag; |
51 | 51 | if (!$msg) { |
52 | - switch($num) { |
|
52 | + switch ($num) { |
|
53 | 53 | case -112: $msg = "Invalid XML"; break; |
54 | 54 | case -136: $msg = "Not found"; break; |
55 | 55 | case -137: $msg = "Name or email address is not unique"; break; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // If it's a single-tag element, and it's present, just return the tag |
96 | 96 | // |
97 | 97 | function parse_element($xml, $tag) { |
98 | - $closetag = "</" . substr($tag,1); |
|
98 | + $closetag = "</".substr($tag, 1); |
|
99 | 99 | $x = strstr($xml, $tag); |
100 | 100 | if ($x) { |
101 | 101 | if (strstr($tag, "/>")) return $tag; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | |
112 | 112 | function parse_next_element($xml, $tag, &$cursor) { |
113 | 113 | $element = null; |
114 | - $closetag = "</" . substr($tag,1); |
|
115 | - $pos = substr($xml,$cursor); |
|
114 | + $closetag = "</".substr($tag, 1); |
|
115 | + $pos = substr($xml, $cursor); |
|
116 | 116 | $x = strstr($pos, $tag); |
117 | 117 | if ($x) { |
118 | 118 | if (strstr($tag, "/>")) return $tag; |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | // |
38 | 38 | $config = get_config(); |
39 | 39 | global $master_url; |
40 | -$master_url = parse_config($config , "<master_url>"); |
|
40 | +$master_url = parse_config($config, "<master_url>"); |
|
41 | 41 | $recaptcha_public_key = parse_config($config, "<recaptcha_public_key>"); |
42 | 42 | $recaptcha_private_key = parse_config($config, "<recaptcha_private_key>"); |
43 | 43 | |
44 | 44 | // the following default to on |
45 | 45 | // |
46 | 46 | $x = parse_config($config, "<user_country>"); |
47 | -define('USER_COUNTRY', ($x===null)?1:(int)$x); |
|
47 | +define('USER_COUNTRY', ($x === null) ? 1 : (int)$x); |
|
48 | 48 | |
49 | 49 | $x = parse_config($config, "<user_url>"); |
50 | -define('USER_URL', ($x===null)?1:(int)$x); |
|
50 | +define('USER_URL', ($x === null) ? 1 : (int)$x); |
|
51 | 51 | |
52 | 52 | // don't allow /... at the end of URL |
53 | 53 | // |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | function url_base() { |
144 | - return is_https()?secure_url_base():URL_BASE; |
|
144 | + return is_https() ?secure_url_base() : URL_BASE; |
|
145 | 145 | } |
146 | 146 | |
147 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
147 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
148 | 148 | global $master_url; |
149 | 149 | |
150 | 150 | // the following allows independent login for projects on the same server |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | $path = substr($path, 0, -1); |
156 | 156 | $path .= "_ops/"; |
157 | 157 | } |
158 | - $expire = $permanent?time()+3600*24*365:0; |
|
158 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
159 | 159 | setcookie($name, $value, $expire, $path); |
160 | 160 | } |
161 | 161 | |
162 | -function clear_cookie($name, $ops=false) { |
|
162 | +function clear_cookie($name, $ops = false) { |
|
163 | 163 | global $master_url; |
164 | 164 | $url = parse_url($master_url); |
165 | 165 | $path = $url['path']; |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | $path = substr($path, 0, -1); |
168 | 168 | $path .= "_ops/"; |
169 | 169 | } |
170 | - setcookie($name, '', time()-3600, $path); |
|
170 | + setcookie($name, '', time() - 3600, $path); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | $g_logged_in_user = null; |
174 | 174 | $got_logged_in_user = false; |
175 | 175 | |
176 | -function get_logged_in_user($must_be_logged_in=true) { |
|
176 | +function get_logged_in_user($must_be_logged_in = true) { |
|
177 | 177 | global $g_logged_in_user, $got_logged_in_user; |
178 | 178 | if ($got_logged_in_user) { |
179 | 179 | // this could have been called earlier with $must_be_logged_in false |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $next_url = $_SERVER['REQUEST_URI']; |
200 | 200 | $n = strrpos($next_url, "/"); |
201 | 201 | if ($n) { |
202 | - $next_url = substr($next_url, $n+1); |
|
202 | + $next_url = substr($next_url, $n + 1); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | $next_url = urlencode($next_url); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | return $g_logged_in_user; |
211 | 211 | } |
212 | 212 | |
213 | -function show_login_info($prefix="") { |
|
213 | +function show_login_info($prefix = "") { |
|
214 | 214 | $user = get_logged_in_user(false); |
215 | 215 | if ($user) { |
216 | 216 | $url_tokens = url_tokens($user->authenticator); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | -$cache_control_extra=""; |
|
223 | +$cache_control_extra = ""; |
|
224 | 224 | $is_login_page = false; |
225 | 225 | |
226 | 226 | // Call this to start pages. |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | // with an existing web framework can more easily do so. |
233 | 233 | // To do so, define page_head() in the project include file. |
234 | 234 | // |
235 | -if (!function_exists("page_head")){ |
|
235 | +if (!function_exists("page_head")) { |
|
236 | 236 | function page_head( |
237 | 237 | $title, |
238 | 238 | // page title. Put in <title>, used as title for browser tab. |
239 | - $body_attrs=null, |
|
239 | + $body_attrs = null, |
|
240 | 240 | // <body XXXX> |
241 | 241 | // e.g. Javascript to put focus in an input field |
242 | 242 | // (onload="document.form.foo.focus()") |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | // if set, include schedulers.txt. |
246 | 246 | // also pass to project_banner() in case you want a different |
247 | 247 | // header for your main page. |
248 | - $url_prefix="", |
|
248 | + $url_prefix = "", |
|
249 | 249 | // prepend this to links. |
250 | 250 | // Use for web pages not in the top directory |
251 | - $head_extra=null |
|
251 | + $head_extra = null |
|
252 | 252 | // extra stuff to put in <head>. E.g.: |
253 | 253 | // reCAPTCHA code (create_profile.php) |
254 | 254 | // bbcode javascript (forums) |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | header("Content-type: text/html; charset=utf-8"); |
271 | 271 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
272 | 272 | // Date in the past |
273 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
273 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
274 | 274 | // always modified |
275 | 275 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
276 | 276 | // for HTTP/1.1 |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | if ($head_extra) { |
292 | 292 | echo "\n$head_extra\n"; |
293 | 293 | } |
294 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
294 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
295 | 295 | readfile("schedulers.txt"); |
296 | 296 | } |
297 | 297 | |
298 | - $t = $title?$title:PROJECT; |
|
298 | + $t = $title ? $title : PROJECT; |
|
299 | 299 | echo "<title>$t</title>\n"; |
300 | 300 | echo ' |
301 | 301 | <meta charset="utf-8"> |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | echo '<div class="container-fluid"> |
353 | 353 | '; |
354 | 354 | |
355 | - switch($title) { //kludge |
|
355 | + switch ($title) { //kludge |
|
356 | 356 | case tra("Log in"): |
357 | 357 | case tra("Create an account"): |
358 | 358 | case tra("Server status page"): |
@@ -367,13 +367,13 @@ discard block |
||
367 | 367 | |
368 | 368 | // See the comments for page_head() |
369 | 369 | // |
370 | -if (!function_exists("page_tail")){ |
|
370 | +if (!function_exists("page_tail")) { |
|
371 | 371 | function page_tail( |
372 | - $show_date=false, |
|
372 | + $show_date = false, |
|
373 | 373 | // true for pages that are generated periodically rather than on the fly |
374 | - $url_prefix="", |
|
374 | + $url_prefix = "", |
|
375 | 375 | // use for pages not at top level |
376 | - $is_main=false |
|
376 | + $is_main = false |
|
377 | 377 | // passed to project_footer; |
378 | 378 | ) { |
379 | 379 | echo "<br>\n"; |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | -function display_cvs_versions(){ |
|
391 | +function display_cvs_versions() { |
|
392 | 392 | global $cvs_version_tracker; |
393 | 393 | echo "\n<!-- SVN VERSIONS -->\n"; |
394 | - for ($i=0;$i<sizeof($cvs_version_tracker);$i++) { |
|
394 | + for ($i = 0; $i < sizeof($cvs_version_tracker); $i++) { |
|
395 | 395 | echo "<!-- ".$cvs_version_tracker[$i]." -->\n"; |
396 | 396 | } |
397 | 397 | } |
@@ -416,23 +416,23 @@ discard block |
||
416 | 416 | // takes argument in second and returns a human formatted time string |
417 | 417 | // in the form D days + h Hours + m Min + s sec. |
418 | 418 | |
419 | -function time_diff($x, $res=3) { |
|
419 | +function time_diff($x, $res = 3) { |
|
420 | 420 | $days = (int)($x/86400); |
421 | - $hours = (int)(($x-$days*86400)/3600); |
|
422 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
423 | - $seconds = (int)($x % 60); |
|
421 | + $hours = (int)(($x - $days*86400)/3600); |
|
422 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
423 | + $seconds = (int)($x%60); |
|
424 | 424 | |
425 | 425 | $datestring = ""; |
426 | 426 | if ($days) { |
427 | 427 | $datestring .= "$days ".tra("days")." "; |
428 | 428 | } |
429 | - if ($res>0 && ($hours || strlen($datestring))) { |
|
429 | + if ($res > 0 && ($hours || strlen($datestring))) { |
|
430 | 430 | $datestring .= "$hours ".tra("hours")." "; |
431 | 431 | } |
432 | - if ($res>1 && ($minutes || strlen($datestring))) { |
|
432 | + if ($res > 1 && ($minutes || strlen($datestring))) { |
|
433 | 433 | $datestring .= "$minutes ".tra("min")." "; |
434 | 434 | } |
435 | - if ($res>2 && ($seconds)) { |
|
435 | + if ($res > 2 && ($seconds)) { |
|
436 | 436 | $datestring .= "$seconds ".tra("sec")." "; |
437 | 437 | } |
438 | 438 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | |
448 | 448 | function time_str($x) { |
449 | 449 | if ($x == 0) return "---"; |
450 | - return gmdate('j M Y, G:i:s', $x) . " UTC"; |
|
450 | + return gmdate('j M Y, G:i:s', $x)." UTC"; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | function local_time_str($x) { |
@@ -459,14 +459,14 @@ discard block |
||
459 | 459 | return time_str($x); |
460 | 460 | } |
461 | 461 | |
462 | -function start_table_str($class="", $style="") { |
|
463 | - $s = $style?'style="'.$style.'"':''; |
|
462 | +function start_table_str($class = "", $style = "") { |
|
463 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
464 | 464 | return '<div class="table"> |
465 | 465 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
466 | 466 | '; |
467 | 467 | } |
468 | 468 | |
469 | -function start_table($class="", $style="") { |
|
469 | +function start_table($class = "", $style = "") { |
|
470 | 470 | echo start_table_str($class, $style); |
471 | 471 | } |
472 | 472 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | echo "</tr>\n"; |
512 | 512 | } |
513 | 513 | |
514 | -function row1($x, $ncols=2, $class="heading") { |
|
514 | +function row1($x, $ncols = 2, $class = "heading") { |
|
515 | 515 | if ($class == "heading") { |
516 | 516 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
517 | 517 | } else { |
@@ -523,10 +523,10 @@ discard block |
||
523 | 523 | define('VALUE_ATTRS', 'style="padding-left:12px"'); |
524 | 524 | define('VALUE_ATTRS_ERR', 'class="danger" style="padding-left:12px"'); |
525 | 525 | |
526 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
527 | - if ($x==="") $x="<br>"; |
|
528 | - if ($y==="") $y="<br>"; |
|
529 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
526 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
527 | + if ($x === "") $x = "<br>"; |
|
528 | + if ($y === "") $y = "<br>"; |
|
529 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
530 | 530 | echo "<tr> |
531 | 531 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
532 | 532 | <td $attrs >$y</td> |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | "; |
535 | 535 | } |
536 | 536 | |
537 | -function row2_init($x, $y, $lwidth='40%') { |
|
537 | +function row2_init($x, $y, $lwidth = '40%') { |
|
538 | 538 | echo '<tr> |
539 | 539 | <td class="text-right " width="'.$lwidth.'" style="padding-right: 20px;">'.$x.'</td> |
540 | 540 | <td '.VALUE_ATTRS.'>'.$y.' |
@@ -557,20 +557,20 @@ discard block |
||
557 | 557 | echo "</tr>\n"; |
558 | 558 | } |
559 | 559 | |
560 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
560 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
561 | 561 | |
562 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
562 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
563 | 563 | echo "<tr>"; |
564 | 564 | $i = 0; |
565 | 565 | foreach ($x as $h) { |
566 | - $a = $attrs?$attrs[$i]:""; |
|
566 | + $a = $attrs ? $attrs[$i] : ""; |
|
567 | 567 | echo "<th $a class=\"$class\">$h</th>"; |
568 | 568 | $i++; |
569 | 569 | } |
570 | 570 | echo "</tr>\n"; |
571 | 571 | } |
572 | 572 | |
573 | -function row_heading($x, $class='bg-primary') { |
|
573 | +function row_heading($x, $class = 'bg-primary') { |
|
574 | 574 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
575 | 575 | ', $class, $x |
576 | 576 | ); |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
631 | 631 | // is cut short. |
632 | 632 | |
633 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
633 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
634 | 634 | $words = explode($delimiter, $sentence); |
635 | 635 | $total_chars = 0; |
636 | 636 | $trunc = false; |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | |
714 | 714 | // returns null if the arg is optional and missing |
715 | 715 | // |
716 | -function get_int($name, $optional=false) { |
|
717 | - $x=null; |
|
716 | +function get_int($name, $optional = false) { |
|
717 | + $x = null; |
|
718 | 718 | if (isset($_GET[$name])) $x = $_GET[$name]; |
719 | 719 | if (!is_numeric($x)) { |
720 | 720 | if ($optional) { |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | |
734 | 734 | // returns null if the arg is optional and missing |
735 | 735 | // |
736 | -function post_num($name, $optional=false) { |
|
736 | +function post_num($name, $optional = false) { |
|
737 | 737 | $x = null; |
738 | 738 | if (isset($_POST[$name])) $x = $_POST[$name]; |
739 | 739 | if (!is_numeric($x)) { |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | |
749 | 749 | // returns null if the arg is optional and missing |
750 | 750 | // |
751 | -function post_int($name, $optional=false) { |
|
751 | +function post_int($name, $optional = false) { |
|
752 | 752 | $x = post_num($name, $optional); |
753 | 753 | if (is_null($x)) return null; |
754 | 754 | $y = (int)$x; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | } |
767 | 767 | } |
768 | 768 | |
769 | -function get_str($name, $optional=false) { |
|
769 | +function get_str($name, $optional = false) { |
|
770 | 770 | if (isset($_GET[$name])) { |
771 | 771 | $x = $_GET[$name]; |
772 | 772 | } else { |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | return undo_magic_quotes($x); |
779 | 779 | } |
780 | 780 | |
781 | -function post_str($name, $optional=false) { |
|
781 | +function post_str($name, $optional = false) { |
|
782 | 782 | if (isset($_POST[$name])) { |
783 | 783 | $x = $_POST[$name]; |
784 | 784 | } else { |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | return undo_magic_quotes($x); |
791 | 791 | } |
792 | 792 | |
793 | -function post_arr($name, $optional=false) { |
|
793 | +function post_arr($name, $optional = false) { |
|
794 | 794 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
795 | 795 | $x = $_POST[$name]; |
796 | 796 | } else { |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | // the mb_* functions are not included by default |
807 | 807 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
808 | 808 | |
809 | - for ($i=0; $i<strlen($str); $i++) { |
|
809 | + for ($i = 0; $i < strlen($str); $i++) { |
|
810 | 810 | $c = ord(substr($str, $i)); |
811 | 811 | if ($c < 32 || $c > 127) return false; |
812 | 812 | } |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
831 | 831 | // if no value was entered and this is ok |
832 | 832 | // |
833 | - if ($number=='' && !$low) return true; |
|
833 | + if ($number == '' && !$low) return true; |
|
834 | 834 | |
835 | 835 | // the supplied value contains alphabetic characters |
836 | 836 | // |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | |
848 | 848 | // Generate a "select" element from an array of values |
849 | 849 | // |
850 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
850 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
851 | 851 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
852 | 852 | |
853 | 853 | foreach ($array as $key => $value) { |
@@ -872,8 +872,8 @@ discard block |
||
872 | 872 | return $str; |
873 | 873 | } |
874 | 874 | |
875 | -function strip_bbcode($string){ |
|
876 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
875 | +function strip_bbcode($string) { |
|
876 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | function current_url() { |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | // @param class The optional CSS class of the button. Defaults to a standard button |
902 | 902 | // |
903 | 903 | |
904 | -function button_text($url, $text, $desc=null, $class="btn-success btn-sm") { |
|
904 | +function button_text($url, $text, $desc = null, $class = "btn-success btn-sm") { |
|
905 | 905 | if (!$desc) { |
906 | 906 | $desc = $text; |
907 | 907 | } |
@@ -910,19 +910,19 @@ discard block |
||
910 | 910 | ); |
911 | 911 | } |
912 | 912 | |
913 | -function show_button($url, $text, $desc=null, $class="btn-success btn-sm") { |
|
913 | +function show_button($url, $text, $desc = null, $class = "btn-success btn-sm") { |
|
914 | 914 | echo button_text($url, $text, $desc, $class); |
915 | 915 | } |
916 | 916 | |
917 | 917 | // for places with a bunch of buttons, like forum posts |
918 | 918 | // |
919 | -function show_button_small($url, $text, $desc=null) { |
|
919 | +function show_button_small($url, $text, $desc = null) { |
|
920 | 920 | echo button_text($url, $text, $desc, "btn-primary btn-xs"); |
921 | 921 | } |
922 | 922 | |
923 | 923 | // used for showing icons |
924 | 924 | // |
925 | -function show_image($src, $title, $alt, $height=null) { |
|
925 | +function show_image($src, $title, $alt, $height = null) { |
|
926 | 926 | $h = ""; |
927 | 927 | if ($height) { |
928 | 928 | $h = "height=\"$height\""; |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | // tries instead to connect to <replica_db_host> if tag exists. |
960 | 960 | // DEPRECATED - use boinc_db.inc |
961 | 961 | // |
962 | -function db_init($try_replica=false) { |
|
962 | +function db_init($try_replica = false) { |
|
963 | 963 | check_web_stopped(); |
964 | 964 | $retval = db_init_aux($try_replica); |
965 | 965 | if ($retval == 1) { |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | function sanitize_numeric($x) { |
1031 | 1031 | if (is_numeric($x)) { |
1032 | 1032 | return $x; |
1033 | - } else if (trim($x) == '' ) { |
|
1033 | + } else if (trim($x) == '') { |
|
1034 | 1034 | return ''; |
1035 | 1035 | } else { |
1036 | 1036 | return "not numeric"; |
@@ -1053,9 +1053,9 @@ discard block |
||
1053 | 1053 | return $c/(200/24); |
1054 | 1054 | } |
1055 | 1055 | |
1056 | -function do_download($path,$name="") { |
|
1057 | - if (strcmp($name,"") == 0) { |
|
1058 | - $name=basename($path); |
|
1056 | +function do_download($path, $name = "") { |
|
1057 | + if (strcmp($name, "") == 0) { |
|
1058 | + $name = basename($path); |
|
1059 | 1059 | } |
1060 | 1060 | header('Content-Description: File Transfer'); |
1061 | 1061 | header('Content-Type: application/octet-stream'); |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | header('Expires: 0'); |
1065 | 1065 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1066 | 1066 | header('Pragma: public'); |
1067 | - header('Content-Length: ' . filesize($path)); |
|
1067 | + header('Content-Length: '.filesize($path)); |
|
1068 | 1068 | flush(); |
1069 | 1069 | readfile($path); |
1070 | 1070 | } |
@@ -1113,10 +1113,10 @@ discard block |
||
1113 | 1113 | // Otherwise return 0. |
1114 | 1114 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1115 | 1115 | // |
1116 | -function boinc_client_version(){ |
|
1116 | +function boinc_client_version() { |
|
1117 | 1117 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1118 | 1118 | $x = $_SERVER['HTTP_USER_AGENT']; |
1119 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1119 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1120 | 1120 | if (preg_match($e, $x, $matches)) { |
1121 | 1121 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
1122 | 1122 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | $rem_name = $name."_remaining"; |
1146 | 1146 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
1147 | 1147 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
1148 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1148 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1149 | 1149 | ; |
1150 | 1150 | } |
1151 | 1151 | |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | // use the following around text with long lines, |
1176 | 1176 | // to limit the width and make it more readable. |
1177 | 1177 | // |
1178 | -function text_start($width=640) { |
|
1178 | +function text_start($width = 640) { |
|
1179 | 1179 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
1180 | 1180 | } |
1181 | 1181 | function text_end() { |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | function cert_filename() { |
1195 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
1195 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | // if user hasn't validated their email addr, tell them to |
@@ -1209,6 +1209,6 @@ discard block |
||
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | |
1212 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
1212 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
1213 | 1213 | |
1214 | 1214 | ?> |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $avg = round($app->info->avg, 2); |
181 | 181 | $min = round($app->info->min, 2); |
182 | 182 | $max = round($app->info->max, 2); |
183 | - $x = $max?"$avg ($min - $max)":"---"; |
|
183 | + $x = $max ? "$avg ($min - $max)" : "---"; |
|
184 | 184 | $u = $app->info->users; |
185 | 185 | } else { |
186 | 186 | $x = '---'; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $cmd = trim($cmd); |
274 | 274 | $x = explode(" ", $cmd); |
275 | 275 | $prog = $x[0]; |
276 | - $pidname = $prog . '.pid'; |
|
276 | + $pidname = $prog.'.pid'; |
|
277 | 277 | } |
278 | 278 | $path = "../../pid_$host/$pidname"; |
279 | 279 | if (is_file($path)) { |
@@ -314,12 +314,12 @@ discard block |
||
314 | 314 | } |
315 | 315 | $master_host = $u["host"]; |
316 | 316 | if ($config->www_host) { |
317 | - $web_host = trim((string) $config->www_host); |
|
317 | + $web_host = trim((string)$config->www_host); |
|
318 | 318 | } else { |
319 | 319 | $web_host = $main_host; |
320 | 320 | } |
321 | 321 | if ($config->sched_host) { |
322 | - $sched_host = trim((string) $config->sched_host); |
|
322 | + $sched_host = trim((string)$config->sched_host); |
|
323 | 323 | } else { |
324 | 324 | $sched_host = $main_host; |
325 | 325 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | // the upload and download servers are sort of daemons too |
331 | 331 | // |
332 | - $url = trim((string) $config->download_url); |
|
332 | + $url = trim((string)$config->download_url); |
|
333 | 333 | $u = parse_url($url); |
334 | 334 | $h = $u["host"]; |
335 | 335 | if ($h == $master_host) { |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | } else { |
342 | 342 | $have_remote = true; |
343 | 343 | } |
344 | - $url = trim((string) $config->upload_url); |
|
344 | + $url = trim((string)$config->upload_url); |
|
345 | 345 | $u = parse_url($url); |
346 | 346 | $h = $u["host"]; |
347 | 347 | if ($h == $master_host) { |
348 | 348 | $y = new StdClass; |
349 | 349 | $y->cmd = "Upload server"; |
350 | 350 | $y->host = $h; |
351 | - $y->status = !file_exists("../../stop_upload");; |
|
351 | + $y->status = !file_exists("../../stop_upload"); ; |
|
352 | 352 | $local_daemons[] = $y; |
353 | 353 | } else { |
354 | 354 | $have_remote = true; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $y = new StdClass; |
361 | 361 | $y->cmd = "Scheduler"; |
362 | 362 | $y->host = $sched_host; |
363 | - $y->status = !file_exists("../../stop_sched");; |
|
363 | + $y->status = !file_exists("../../stop_sched"); ; |
|
364 | 364 | $local_daemons[] = $y; |
365 | 365 | } else { |
366 | 366 | $have_remote = true; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $disabled_daemons[] = $x; |
377 | 377 | continue; |
378 | 378 | } |
379 | - $host = $d->host?(string)$d->host:$main_host; |
|
379 | + $host = $d->host ? (string)$d->host : $main_host; |
|
380 | 380 | if ($host != $web_host) { |
381 | 381 | $have_remote = true; |
382 | 382 | continue; |