@@ -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 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } else { |
92 | 92 | sort($files); |
93 | 93 | start_table(); |
94 | - table_header("Name<br><p class=\"text-muted\">(click to view)</p>", "Modified", "Size (bytes)", "MD5", "Delete","Download"); |
|
94 | + table_header("Name<br><p class=\"text-muted\">(click to view)</p>", "Modified", "Size (bytes)", "MD5", "Delete", "Download"); |
|
95 | 95 | foreach ($files as $f) { |
96 | 96 | $path = "$dir/$f"; |
97 | 97 | list($error, $size, $md5) = sandbox_parse_link_file($path); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $s = stat($tmp_name); |
142 | 142 | $size = $s['size']; |
143 | 143 | list($exist, $elf) = sandbox_lf_exist($user, $md5); |
144 | - if ($exist){ |
|
144 | + if ($exist) { |
|
145 | 145 | $notice .= "<strong>Notice:</strong> Invalid Upload<br/>"; |
146 | 146 | $notice .= "You are trying to upload file <strong>$name</strong><br/>"; |
147 | 147 | $notice .= "Another file <strong>$elf</strong> with the same content (md5: $md5) already exists!<br/>"; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | list_files($user, $notice); |
163 | 163 | } |
164 | 164 | |
165 | -<<<<<<< HEAD |
|
165 | +<< << <<< HEAD |
|
166 | 166 | ======= |
167 | 167 | function add_file($user) { |
168 | 168 | $dir = sandbox_dir($user); |
@@ -141,7 +141,7 @@ |
||
141 | 141 | $s = stat($tmp_name); |
142 | 142 | $size = $s['size']; |
143 | 143 | list($exist, $elf) = sandbox_lf_exist($user, $md5); |
144 | - if ($exist){ |
|
144 | + if ($exist) { |
|
145 | 145 | $notice .= "<strong>Notice:</strong> Invalid Upload<br/>"; |
146 | 146 | $notice .= "You are trying to upload file <strong>$name</strong><br/>"; |
147 | 147 | $notice .= "Another file <strong>$elf</strong> with the same content (md5: $md5) already exists!<br/>"; |
@@ -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 | // |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | function url_base() { |
145 | - return is_https()?secure_url_base():URL_BASE; |
|
145 | + return is_https() ?secure_url_base() : URL_BASE; |
|
146 | 146 | } |
147 | 147 | |
148 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
148 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
149 | 149 | global $master_url; |
150 | 150 | |
151 | 151 | // the following allows independent login for projects on the same server |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | $path = substr($path, 0, -1); |
157 | 157 | $path .= "_ops/"; |
158 | 158 | } |
159 | - $expire = $permanent?time()+3600*24*365:0; |
|
159 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
160 | 160 | setcookie($name, $value, $expire, $path, |
161 | 161 | '', |
162 | - is_https(), // if this page is secure, make cookie secure |
|
162 | + is_https(), // if this page is secure, make cookie secure |
|
163 | 163 | true // httponly; no JS access |
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
167 | -function clear_cookie($name, $ops=false) { |
|
167 | +function clear_cookie($name, $ops = false) { |
|
168 | 168 | global $master_url; |
169 | 169 | $url = parse_url($master_url); |
170 | 170 | $path = $url['path']; |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | $path = substr($path, 0, -1); |
173 | 173 | $path .= "_ops/"; |
174 | 174 | } |
175 | - setcookie($name, '', time()-3600, $path); |
|
175 | + setcookie($name, '', time() - 3600, $path); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $g_logged_in_user = null; |
179 | 179 | $got_logged_in_user = false; |
180 | 180 | |
181 | -function get_logged_in_user($must_be_logged_in=true) { |
|
181 | +function get_logged_in_user($must_be_logged_in = true) { |
|
182 | 182 | global $g_logged_in_user, $got_logged_in_user; |
183 | 183 | if ($got_logged_in_user) { |
184 | 184 | // this could have been called earlier with $must_be_logged_in false |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $next_url = $_SERVER['REQUEST_URI']; |
205 | 205 | $n = strrpos($next_url, "/"); |
206 | 206 | if ($n) { |
207 | - $next_url = substr($next_url, $n+1); |
|
207 | + $next_url = substr($next_url, $n + 1); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | $next_url = urlencode($next_url); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | return $g_logged_in_user; |
216 | 216 | } |
217 | 217 | |
218 | -function show_login_info($prefix="") { |
|
218 | +function show_login_info($prefix = "") { |
|
219 | 219 | $user = get_logged_in_user(false); |
220 | 220 | if ($user) { |
221 | 221 | $url_tokens = url_tokens($user->authenticator); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | -$cache_control_extra=""; |
|
228 | +$cache_control_extra = ""; |
|
229 | 229 | $is_login_page = false; |
230 | 230 | |
231 | 231 | // Call this to start pages. |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | // with an existing web framework can more easily do so. |
238 | 238 | // To do so, define page_head() in the project include file. |
239 | 239 | // |
240 | -if (!function_exists("page_head")){ |
|
240 | +if (!function_exists("page_head")) { |
|
241 | 241 | function page_head( |
242 | 242 | $title, |
243 | 243 | // page title. Put in <title>, used as title for browser tab. |
244 | - $body_attrs=null, |
|
244 | + $body_attrs = null, |
|
245 | 245 | // <body XXXX> |
246 | 246 | // e.g. Javascript to put focus in an input field |
247 | 247 | // (onload="document.form.foo.focus()") |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | // if set, include schedulers.txt. |
251 | 251 | // also pass to project_banner() in case you want a different |
252 | 252 | // header for your main page. |
253 | - $url_prefix="", |
|
253 | + $url_prefix = "", |
|
254 | 254 | // prepend this to links. |
255 | 255 | // Use for web pages not in the top directory |
256 | - $head_extra=null |
|
256 | + $head_extra = null |
|
257 | 257 | // extra stuff to put in <head>. E.g.: |
258 | 258 | // reCAPTCHA code (create_profile.php) |
259 | 259 | // bbcode javascript (forums) |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | header("Content-type: text/html; charset=utf-8"); |
276 | 276 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
277 | 277 | // Date in the past |
278 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
278 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
279 | 279 | // always modified |
280 | 280 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
281 | 281 | // for HTTP/1.1 |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | if ($head_extra) { |
297 | 297 | echo "\n$head_extra\n"; |
298 | 298 | } |
299 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
299 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
300 | 300 | readfile("schedulers.txt"); |
301 | 301 | } |
302 | 302 | |
303 | - $t = $title?$title:PROJECT; |
|
303 | + $t = $title ? $title : PROJECT; |
|
304 | 304 | echo "<title>$t</title>\n"; |
305 | 305 | echo ' |
306 | 306 | <meta charset="utf-8"> |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | echo '<div class="container-fluid"> |
358 | 358 | '; |
359 | 359 | |
360 | - switch($title) { //kludge |
|
360 | + switch ($title) { //kludge |
|
361 | 361 | case tra("Log in"): |
362 | 362 | case tra("Create an account"): |
363 | 363 | case tra("Server status page"): |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | |
373 | 373 | // See the comments for page_head() |
374 | 374 | // |
375 | -if (!function_exists("page_tail")){ |
|
375 | +if (!function_exists("page_tail")) { |
|
376 | 376 | function page_tail( |
377 | - $show_date=false, |
|
377 | + $show_date = false, |
|
378 | 378 | // true for pages that are generated periodically rather than on the fly |
379 | - $url_prefix="", |
|
379 | + $url_prefix = "", |
|
380 | 380 | // use for pages not at top level |
381 | - $is_main=false |
|
381 | + $is_main = false |
|
382 | 382 | // passed to project_footer; |
383 | 383 | ) { |
384 | 384 | echo "<br>\n"; |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | -function display_cvs_versions(){ |
|
396 | +function display_cvs_versions() { |
|
397 | 397 | global $cvs_version_tracker; |
398 | 398 | echo "\n<!-- SVN VERSIONS -->\n"; |
399 | - for ($i=0;$i<sizeof($cvs_version_tracker);$i++) { |
|
399 | + for ($i = 0; $i < sizeof($cvs_version_tracker); $i++) { |
|
400 | 400 | echo "<!-- ".$cvs_version_tracker[$i]." -->\n"; |
401 | 401 | } |
402 | 402 | } |
@@ -421,23 +421,23 @@ discard block |
||
421 | 421 | // takes argument in second and returns a human formatted time string |
422 | 422 | // in the form 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 | $days = (int)($x/86400); |
426 | - $hours = (int)(($x-$days*86400)/3600); |
|
427 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
428 | - $seconds = (int)($x % 60); |
|
426 | + $hours = (int)(($x - $days*86400)/3600); |
|
427 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
428 | + $seconds = (int)($x%60); |
|
429 | 429 | |
430 | 430 | $datestring = ""; |
431 | 431 | if ($days) { |
432 | 432 | $datestring .= "$days ".tra("days")." "; |
433 | 433 | } |
434 | - if ($res>0 && ($hours || strlen($datestring))) { |
|
434 | + if ($res > 0 && ($hours || strlen($datestring))) { |
|
435 | 435 | $datestring .= "$hours ".tra("hours")." "; |
436 | 436 | } |
437 | - if ($res>1 && ($minutes || strlen($datestring))) { |
|
437 | + if ($res > 1 && ($minutes || strlen($datestring))) { |
|
438 | 438 | $datestring .= "$minutes ".tra("min")." "; |
439 | 439 | } |
440 | - if ($res>2 && ($seconds)) { |
|
440 | + if ($res > 2 && ($seconds)) { |
|
441 | 441 | $datestring .= "$seconds ".tra("sec")." "; |
442 | 442 | } |
443 | 443 | |
@@ -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', $x) . " UTC"; |
|
455 | + return gmdate('j M Y, G:i:s', $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 { |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | define('VALUE_ATTRS', 'style="padding-left:12px"'); |
529 | 529 | define('VALUE_ATTRS_ERR', 'class="danger" style="padding-left:12px"'); |
530 | 530 | |
531 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
532 | - if ($x==="") $x="<br>"; |
|
533 | - if ($y==="") $y="<br>"; |
|
534 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
531 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
532 | + if ($x === "") $x = "<br>"; |
|
533 | + if ($y === "") $y = "<br>"; |
|
534 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
535 | 535 | echo "<tr> |
536 | 536 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
537 | 537 | <td $attrs >$y</td> |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | "; |
540 | 540 | } |
541 | 541 | |
542 | -function row2_init($x, $y, $lwidth='40%') { |
|
542 | +function row2_init($x, $y, $lwidth = '40%') { |
|
543 | 543 | echo '<tr> |
544 | 544 | <td class="text-right " width="'.$lwidth.'" style="padding-right: 20px;">'.$x.'</td> |
545 | 545 | <td '.VALUE_ATTRS.'>'.$y.' |
@@ -562,20 +562,20 @@ discard block |
||
562 | 562 | echo "</tr>\n"; |
563 | 563 | } |
564 | 564 | |
565 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
565 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
566 | 566 | |
567 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
567 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
568 | 568 | echo "<tr>"; |
569 | 569 | $i = 0; |
570 | 570 | foreach ($x as $h) { |
571 | - $a = $attrs?$attrs[$i]:""; |
|
571 | + $a = $attrs ? $attrs[$i] : ""; |
|
572 | 572 | echo "<th $a class=\"$class\">$h</th>"; |
573 | 573 | $i++; |
574 | 574 | } |
575 | 575 | echo "</tr>\n"; |
576 | 576 | } |
577 | 577 | |
578 | -function row_heading($x, $class='bg-primary') { |
|
578 | +function row_heading($x, $class = 'bg-primary') { |
|
579 | 579 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
580 | 580 | ', $class, $x |
581 | 581 | ); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
636 | 636 | // is cut short. |
637 | 637 | |
638 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
638 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
639 | 639 | $words = explode($delimiter, $sentence); |
640 | 640 | $total_chars = 0; |
641 | 641 | $trunc = false; |
@@ -718,8 +718,8 @@ discard block |
||
718 | 718 | |
719 | 719 | // returns null if the arg is optional and missing |
720 | 720 | // |
721 | -function get_int($name, $optional=false) { |
|
722 | - $x=null; |
|
721 | +function get_int($name, $optional = false) { |
|
722 | + $x = null; |
|
723 | 723 | if (isset($_GET[$name])) $x = $_GET[$name]; |
724 | 724 | if (!is_numeric($x)) { |
725 | 725 | if ($optional) { |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | // returns null if the arg is optional and missing |
740 | 740 | // |
741 | -function post_num($name, $optional=false) { |
|
741 | +function post_num($name, $optional = false) { |
|
742 | 742 | $x = null; |
743 | 743 | if (isset($_POST[$name])) $x = $_POST[$name]; |
744 | 744 | if (!is_numeric($x)) { |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | |
754 | 754 | // returns null if the arg is optional and missing |
755 | 755 | // |
756 | -function post_int($name, $optional=false) { |
|
756 | +function post_int($name, $optional = false) { |
|
757 | 757 | $x = post_num($name, $optional); |
758 | 758 | if (is_null($x)) return null; |
759 | 759 | $y = (int)$x; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | } |
772 | 772 | } |
773 | 773 | |
774 | -function get_str($name, $optional=false) { |
|
774 | +function get_str($name, $optional = false) { |
|
775 | 775 | if (isset($_GET[$name])) { |
776 | 776 | $x = $_GET[$name]; |
777 | 777 | } else { |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | return undo_magic_quotes($x); |
784 | 784 | } |
785 | 785 | |
786 | -function post_str($name, $optional=false) { |
|
786 | +function post_str($name, $optional = false) { |
|
787 | 787 | if (isset($_POST[$name])) { |
788 | 788 | $x = $_POST[$name]; |
789 | 789 | } else { |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | return undo_magic_quotes($x); |
796 | 796 | } |
797 | 797 | |
798 | -function post_arr($name, $optional=false) { |
|
798 | +function post_arr($name, $optional = false) { |
|
799 | 799 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
800 | 800 | $x = $_POST[$name]; |
801 | 801 | } else { |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | // the mb_* functions are not included by default |
812 | 812 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
813 | 813 | |
814 | - for ($i=0; $i<strlen($str); $i++) { |
|
814 | + for ($i = 0; $i < strlen($str); $i++) { |
|
815 | 815 | $c = ord(substr($str, $i)); |
816 | 816 | if ($c < 32 || $c > 127) return false; |
817 | 817 | } |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
836 | 836 | // if no value was entered and this is ok |
837 | 837 | // |
838 | - if ($number=='' && !$low) return true; |
|
838 | + if ($number == '' && !$low) return true; |
|
839 | 839 | |
840 | 840 | // the supplied value contains alphabetic characters |
841 | 841 | // |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | |
853 | 853 | // Generate a "select" element from an array of values |
854 | 854 | // |
855 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
855 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
856 | 856 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
857 | 857 | |
858 | 858 | foreach ($array as $key => $value) { |
@@ -877,12 +877,12 @@ discard block |
||
877 | 877 | return $str; |
878 | 878 | } |
879 | 879 | |
880 | -function strip_bbcode($string){ |
|
881 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
880 | +function strip_bbcode($string) { |
|
881 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | function current_url() { |
885 | - $url = is_https()?'https':'http'; |
|
885 | + $url = is_https() ? 'https' : 'http'; |
|
886 | 886 | $url .= "://"; |
887 | 887 | $url .= $_SERVER['SERVER_NAME']; |
888 | 888 | $url .= ":".$_SERVER['SERVER_PORT']; |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | // @param class The optional CSS class of the button. Defaults to a standard button |
904 | 904 | // |
905 | 905 | |
906 | -function button_text($url, $text, $desc=null, $class="btn-success btn-sm") { |
|
906 | +function button_text($url, $text, $desc = null, $class = "btn-success btn-sm") { |
|
907 | 907 | if (!$desc) { |
908 | 908 | $desc = $text; |
909 | 909 | } |
@@ -912,19 +912,19 @@ discard block |
||
912 | 912 | ); |
913 | 913 | } |
914 | 914 | |
915 | -function show_button($url, $text, $desc=null, $class="btn-success btn-sm") { |
|
915 | +function show_button($url, $text, $desc = null, $class = "btn-success btn-sm") { |
|
916 | 916 | echo button_text($url, $text, $desc, $class); |
917 | 917 | } |
918 | 918 | |
919 | 919 | // for places with a bunch of buttons, like forum posts |
920 | 920 | // |
921 | -function show_button_small($url, $text, $desc=null) { |
|
921 | +function show_button_small($url, $text, $desc = null) { |
|
922 | 922 | echo button_text($url, $text, $desc, "btn-primary btn-xs"); |
923 | 923 | } |
924 | 924 | |
925 | 925 | // used for showing icons |
926 | 926 | // |
927 | -function show_image($src, $title, $alt, $height=null) { |
|
927 | +function show_image($src, $title, $alt, $height = null) { |
|
928 | 928 | $h = ""; |
929 | 929 | if ($height) { |
930 | 930 | $h = "height=\"$height\""; |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | // tries instead to connect to <replica_db_host> if tag exists. |
962 | 962 | // DEPRECATED - use boinc_db.inc |
963 | 963 | // |
964 | -function db_init($try_replica=false) { |
|
964 | +function db_init($try_replica = false) { |
|
965 | 965 | check_web_stopped(); |
966 | 966 | $retval = db_init_aux($try_replica); |
967 | 967 | if ($retval == 1) { |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | function sanitize_numeric($x) { |
1055 | 1055 | if (is_numeric($x)) { |
1056 | 1056 | return $x; |
1057 | - } else if (trim($x) == '' ) { |
|
1057 | + } else if (trim($x) == '') { |
|
1058 | 1058 | return ''; |
1059 | 1059 | } else { |
1060 | 1060 | return "not numeric"; |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | return $c/(200/24); |
1079 | 1079 | } |
1080 | 1080 | |
1081 | -function do_download($path,$name="") { |
|
1082 | - if (strcmp($name,"") == 0) { |
|
1083 | - $name=basename($path); |
|
1081 | +function do_download($path, $name = "") { |
|
1082 | + if (strcmp($name, "") == 0) { |
|
1083 | + $name = basename($path); |
|
1084 | 1084 | } |
1085 | 1085 | header('Content-Description: File Transfer'); |
1086 | 1086 | header('Content-Type: application/octet-stream'); |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | header('Expires: 0'); |
1090 | 1090 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1091 | 1091 | header('Pragma: public'); |
1092 | - header('Content-Length: ' . filesize($path)); |
|
1092 | + header('Content-Length: '.filesize($path)); |
|
1093 | 1093 | flush(); |
1094 | 1094 | readfile($path); |
1095 | 1095 | } |
@@ -1138,10 +1138,10 @@ discard block |
||
1138 | 1138 | // Otherwise return 0. |
1139 | 1139 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1140 | 1140 | // |
1141 | -function boinc_client_version(){ |
|
1141 | +function boinc_client_version() { |
|
1142 | 1142 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1143 | 1143 | $x = $_SERVER['HTTP_USER_AGENT']; |
1144 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1144 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1145 | 1145 | if (preg_match($e, $x, $matches)) { |
1146 | 1146 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
1147 | 1147 | } |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | $rem_name = $name."_remaining"; |
1171 | 1171 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
1172 | 1172 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
1173 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1173 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1174 | 1174 | ; |
1175 | 1175 | } |
1176 | 1176 | |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | // use the following around text with long lines, |
1201 | 1201 | // to limit the width and make it more readable. |
1202 | 1202 | // |
1203 | -function text_start($width=640) { |
|
1203 | +function text_start($width = 640) { |
|
1204 | 1204 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
1205 | 1205 | } |
1206 | 1206 | function text_end() { |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | function cert_filename() { |
1223 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
1223 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | // if user hasn't validated their email addr, tell them to |
@@ -1237,6 +1237,6 @@ discard block |
||
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
1240 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
1240 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
1241 | 1241 | |
1242 | 1242 | ?> |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | abstract class PREF { |
45 | - public $desc; // short description |
|
46 | - public $tooltip; // longer description, shown as tooltip |
|
47 | - public $tag; // the pref's primary XML tag |
|
45 | + public $desc; // short description |
|
46 | + public $tooltip; // longer description, shown as tooltip |
|
47 | + public $tag; // the pref's primary XML tag |
|
48 | 48 | function __construct($desc, $tooltip, $tag) { |
49 | 49 | $this->desc = $desc; |
50 | 50 | $this->tooltip = $tooltip; |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | |
123 | 123 | class PREF_BOOL extends PREF { |
124 | 124 | public $default; |
125 | - public $invert; // show to user in opposite sense |
|
126 | - function __construct($desc, $tooltip, $tag, $default, $invert=false) { |
|
125 | + public $invert; // show to user in opposite sense |
|
126 | + function __construct($desc, $tooltip, $tag, $default, $invert = false) { |
|
127 | 127 | $this->default = $default; |
128 | 128 | $this->invert = $invert; |
129 | 129 | parent::__construct($desc, $tooltip, $tag); |
130 | 130 | } |
131 | 131 | function show_value($prefs) { |
132 | 132 | $tag = $this->tag; |
133 | - $v = $this->invert?!$prefs->$tag:$prefs->$tag; |
|
133 | + $v = $this->invert ? !$prefs->$tag : $prefs->$tag; |
|
134 | 134 | echo "<td>".readonly_checkbox($v)."</td>"; |
135 | 135 | } |
136 | 136 | function show_form($prefs, $error) { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | echo "<td ".VALUE_ATTRS.">" |
144 | 144 | ."<input type=checkbox name=$this->tag " |
145 | - . ($checked?"checked":"") |
|
145 | + . ($checked ? "checked" : "") |
|
146 | 146 | ."></td> |
147 | 147 | "; |
148 | 148 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | function xml_string($prefs) { |
156 | 156 | $tag = $this->tag; |
157 | 157 | return "<$tag>" |
158 | - .($prefs->$tag?"1":"0") |
|
158 | + .($prefs->$tag ? "1" : "0") |
|
159 | 159 | ."</$tag>\n"; |
160 | 160 | } |
161 | 161 | function xml_parse(&$prefs, $name, $text) { |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | public $consent_type_id; // the consent_type_id from the consent_type table |
176 | 176 | public $consent_name; // the consent_name to configure |
177 | 177 | public $default; |
178 | - public $invert; // show to user in opposite sense |
|
178 | + public $invert; // show to user in opposite sense |
|
179 | 179 | |
180 | - function __construct($desc, $tooltip, $tag, $consent_type_id, $consent_name, $default, $invert=false) { |
|
180 | + function __construct($desc, $tooltip, $tag, $consent_type_id, $consent_name, $default, $invert = false) { |
|
181 | 181 | $this->consent_type_id = $consent_type_id; |
182 | 182 | $this->consent_name = $consent_name; |
183 | 183 | $this->default = $default; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } else { |
235 | 235 | $value = false; |
236 | 236 | } |
237 | - echo "<td>" . readonly_checkbox($value) . "</td>"; |
|
237 | + echo "<td>".readonly_checkbox($value)."</td>"; |
|
238 | 238 | } |
239 | 239 | function show_form($user, $error) { |
240 | 240 | $consent_type_id = $this->consent_type_id; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | echo "<td ".VALUE_ATTRS.">" |
252 | 252 | ."<input type=checkbox name=$this->tag " |
253 | - . ($checked?"checked":"") |
|
253 | + . ($checked ? "checked" : "") |
|
254 | 254 | ."></td> |
255 | 255 | "; |
256 | 256 | } |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | // to this consent type. |
268 | 268 | $cr = BoincLatestConsent::lookup("userid={$user->id} AND consent_type_id='${consent_type_id}'"); |
269 | 269 | |
270 | - if ( (($cr) and ($cr->consent_flag!=$flag)) or |
|
271 | - (!$cr) ) { |
|
270 | + if ((($cr) and ($cr->consent_flag != $flag)) or |
|
271 | + (!$cr)) { |
|
272 | 272 | $rc = consent_to_a_policy($user, $consent_type_id, $flag, 0, 'Webform', time()); |
273 | 273 | if (!$rc) { |
274 | 274 | error_page("Database error"); |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | // this is the value if they check the box |
305 | 305 | public $scale; |
306 | 306 | |
307 | - function __construct($suffix, $min, $max, $default, $scale=1, $default2=0) { |
|
307 | + function __construct($suffix, $min, $max, $default, $scale = 1, $default2 = 0) { |
|
308 | 308 | $this->suffix = " $suffix"; |
309 | 309 | $this->min = $min; |
310 | 310 | $this->max = $max; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $v .= "$this->suffix "; |
324 | 324 | return $v; |
325 | 325 | } |
326 | - function form_str($tag, $v, $had_error, $disabled=false, $id=null) { |
|
326 | + function form_str($tag, $v, $had_error, $disabled = false, $id = null) { |
|
327 | 327 | if (is_numeric($v)) { |
328 | 328 | $v /= $this->scale; |
329 | 329 | if (!$had_error && ($v < $this->min || $v > $this->max)) { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | } |
332 | 332 | } |
333 | 333 | if ($disabled) $v = ""; |
334 | - $i = $id?"id=\"$id\"":""; |
|
334 | + $i = $id ? "id=\"$id\"" : ""; |
|
335 | 335 | return '<input type="text" size="5" class="form-control input-sm" name="'.$tag.'" value="'.$v."\" $disabled $i> $this->suffix "; |
336 | 336 | } |
337 | 337 | function form_convert($in, &$out, &$error) { |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | $text_id = $this->tag; |
455 | 455 | $default = $this->num_spec->get_default(); |
456 | 456 | $val = $prefs->$tag; |
457 | - $c = $val?"checked":""; |
|
458 | - $d = $val?"":"disabled"; |
|
457 | + $c = $val ? "checked" : ""; |
|
458 | + $d = $val ? "" : "disabled"; |
|
459 | 459 | echo "<td $attrs>" |
460 | 460 | ."<input type=checkbox id=$checkbox_id onClick=\"checkbox_clicked('$checkbox_id', '$text_id', $default)\" $c> " |
461 | 461 | .$this->num_spec->form_str($tag, $prefs->$tag, $had_error, $d, $text_id) |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | function hour_select($x, $name, $id, $d) { |
569 | 569 | $s = ""; |
570 | 570 | $s .= "<select class=\"selectbox form-control input-sm\" name=$name id=$id $d>\n"; |
571 | - for ($i=0; $i<24; $i++) { |
|
572 | - $sel = ($x == $i)?"selected":""; |
|
571 | + for ($i = 0; $i < 24; $i++) { |
|
572 | + $sel = ($x == $i) ? "selected" : ""; |
|
573 | 573 | $s .= "<option value=$i $sel> $i:00"; |
574 | 574 | } |
575 | 575 | $s .= "</select>\n"; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | |
671 | 671 | // row_defs - Display a value for all 4 venues in one row |
672 | 672 | // |
673 | -function row_defs($pre, $item, $post, $type, $prefs, $tooltip=null) { |
|
673 | +function row_defs($pre, $item, $post, $type, $prefs, $tooltip = null) { |
|
674 | 674 | $gen = $prefs->$item; |
675 | 675 | $hom = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--"; |
676 | 676 | $schl = (isset($prefs->school) && isset($prefs->school->$item)) ? $prefs->school->$item : "--"; |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | echo "<tr>"; |
683 | 683 | } |
684 | 684 | echo "<td ".NAME_ATTRS.">$pre</td>"; |
685 | - row_field($gen, $type); |
|
686 | - row_field($hom, $type); |
|
685 | + row_field($gen, $type); |
|
686 | + row_field($hom, $type); |
|
687 | 687 | row_field($schl, $type); |
688 | - row_field($wrk, $type); |
|
688 | + row_field($wrk, $type); |
|
689 | 689 | echo "<td align=left>$post</td></tr>\n"; |
690 | 690 | } |
691 | 691 | |
@@ -695,16 +695,16 @@ discard block |
||
695 | 695 | function row_field($value, $type) { |
696 | 696 | echo "<td>"; |
697 | 697 | $type = $value === "--" ? "--" : $type; |
698 | - switch($type) { |
|
698 | + switch ($type) { |
|
699 | 699 | case "yesno": |
700 | - echo $value ?tra("yes"):tra("no"); |
|
700 | + echo $value ?tra("yes") : tra("no"); |
|
701 | 701 | break; |
702 | 702 | case "noyes": |
703 | - echo $value ?tra("no"):tra("yes"); |
|
703 | + echo $value ?tra("no") : tra("yes"); |
|
704 | 704 | break; |
705 | 705 | case "limit": |
706 | 706 | $x = max_bytes_display_mode($value); |
707 | - $y = "$x " . BYTE_ABBR; |
|
707 | + $y = "$x ".BYTE_ABBR; |
|
708 | 708 | echo $x ? "$y" : tra("no limit"); |
709 | 709 | break; |
710 | 710 | case "minutes": |