Passed
Push — master ( ebd933...f440ac )
by Vitalii
09:08 queued 14s
created
html/inc/pm.inc 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     return $x;
50 50
 }
51 51
 
52
-function pm_team_form($user, $teamid, $error=null) {
52
+function pm_team_form($user, $teamid, $error = null) {
53 53
     global $bbcode_html, $bbcode_js;
54 54
     $team = BoincTeam::lookup_id($teamid);
55 55
     if (!$team) {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         error_page("not admin");
60 60
     }
61 61
 
62
-    page_head(tra("Send message to team"),'','','', $bbcode_js);
62
+    page_head(tra("Send message to team"), '', '', '', $bbcode_js);
63 63
 
64 64
     $subject = post_str("subject", true);
65 65
     $content = post_str("content", true);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 function pm_form_page($replyto, $userid, $error = null) {
112 112
     global $bbcode_html, $bbcode_js;
113 113
     global $g_logged_in_user;
114
-    page_head(tra("Send private message"),'','','', $bbcode_js);
114
+    page_head(tra("Send private message"), '', '', '', $bbcode_js);
115 115
 
116 116
     if (post_str("preview", true) == tra("Preview")) {
117 117
         $content = post_str("content", true);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         if (!$user) {
136 136
             error_page("Sender no longer exists");
137 137
         }
138
-        $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")";
138
+        $writeto = UNIQUE_USER_NAME ? $user->name : $userid." (".$user->name.")";
139 139
         $subject = $message->subject;
140 140
         if (substr($subject, 0, 3) != "re:") {
141 141
             $subject = "re: ".$subject;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         if (!$user) {
146 146
             error_page("Sender no longer exists");
147 147
         }
148
-        $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")";
148
+        $writeto = UNIQUE_USER_NAME ? $user->name : $userid." (".$user->name.")";
149 149
     } else {
150 150
         $writeto = sanitize_tags(post_str("to", true));
151 151
         $subject = post_str("subject", true);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 function send_pm_notification_email(
201 201
     $logged_in_user, $to_user, $subject, $content
202 202
 ) {
203
-    $message  = "
203
+    $message = "
204 204
 You have received a new private message at ".PROJECT.".
205 205
 
206 206
 From: $logged_in_user->name (ID $logged_in_user->id)
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     $pm = BoincPrivateMessage::lookup_id($notify->opaque);
231 231
     $from_user = BoincUser::lookup_id($pm->senderid);
232 232
     if (!$pm || !$from_user) return null;
233
-    return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject";
233
+    return "<a href=pm.php>".tra("Private message%1 from %2, subject:", "</a>", $from_user->name)." $pm->subject";
234 234
 }
235 235
 
236 236
 function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) {
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 
295 295
 function pm_email_remind($user) {
296 296
     if (!$user->prefs->pm_notification) {
297
-        return "<br><small>" .
297
+        return "<br><small>".
298 298
             tra(
299 299
                 "For email notification, %1 edit community prefs %2",
300 300
                 '<a href="edit_forum_preferences_form.php">', '</a>'
301
-            ) .
301
+            ).
302 302
             "</small>"
303 303
         ;
304 304
     }
@@ -324,5 +324,5 @@  discard block
 block discarded – undo
324 324
     }
325 325
 }
326 326
 
327
-$cvs_version_tracker[]="\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $";
327
+$cvs_version_tracker[] = "\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $";
328 328
 ?>
Please login to merge, or discard this patch.
html/inc/util.inc 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -33,17 +33,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,11 +165,11 @@  discard block
 block discarded – undo
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 171
 
172
-function clear_cookie($name, $ops=false) {
172
+function clear_cookie($name, $ops = false) {
173 173
     global $master_url;
174 174
     $url = parse_url($master_url);
175 175
     $path = $url['path'];
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
         $path = substr($path, 0, -1);
178 178
         $path .= "_ops/";
179 179
     }
180
-    setcookie($name, '', time()-3600, $path);
180
+    setcookie($name, '', time() - 3600, $path);
181 181
 }
182 182
 
183 183
 $g_logged_in_user = null;
184 184
 $got_logged_in_user = false;
185 185
 
186
-function get_logged_in_user($must_be_logged_in=true) {
186
+function get_logged_in_user($must_be_logged_in = true) {
187 187
     global $g_logged_in_user, $got_logged_in_user;
188 188
     if ($got_logged_in_user) {
189 189
         // this could have been called earlier with $must_be_logged_in false
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             $next_url = $_SERVER['REQUEST_URI'];
210 210
             $n = strrpos($next_url, "/");
211 211
             if ($n) {
212
-                $next_url = substr($next_url, $n+1);
212
+                $next_url = substr($next_url, $n + 1);
213 213
             }
214 214
         }
215 215
         $next_url = urlencode($next_url);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     return $g_logged_in_user;
221 221
 }
222 222
 
223
-function show_login_info($prefix="") {
223
+function show_login_info($prefix = "") {
224 224
     $user = get_logged_in_user(false);
225 225
     if ($user) {
226 226
         $url_tokens = url_tokens($user->authenticator);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     }
231 231
 }
232 232
 
233
-$cache_control_extra="";
233
+$cache_control_extra = "";
234 234
 $is_login_page = false;
235 235
 
236 236
 // Call this to start pages.
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 // with an existing web framework can more easily do so.
243 243
 // To do so, define page_head() in the project include file.
244 244
 //
245
-if (!function_exists("page_head")){
245
+if (!function_exists("page_head")) {
246 246
 function page_head(
247 247
     $title,
248 248
         // page title. Put in <title>, used as title for browser tab.
249
-    $body_attrs=null,
249
+    $body_attrs = null,
250 250
         // <body XXXX>
251 251
         // e.g. Javascript to put focus in an input field
252 252
         // (onload="document.form.foo.focus()")
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
         // if set, include schedulers.txt.
256 256
         // also pass to project_banner() in case you want a different
257 257
         // header for your main page.
258
-    $url_prefix="",
258
+    $url_prefix = "",
259 259
         // prepend this to links.
260 260
         // Use for web pages not in the top directory
261
-    $head_extra=null
261
+    $head_extra = null
262 262
         // extra stuff to put in <head>. E.g.:
263 263
         // reCAPTCHA code (create_profile.php)
264 264
         // bbcode javascript (forums)
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         header("Content-type: text/html; charset=utf-8");
281 281
         header("Expires: Mon, 26 Jul 1997 05:00:00 UTC");
282 282
             // Date in the past
283
-        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC");
283
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC");
284 284
             // always modified
285 285
         header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0");
286 286
             // for HTTP/1.1
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
     if ($head_extra) {
302 302
         echo "\n$head_extra\n";
303 303
     }
304
-    if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) {
304
+    if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) {
305 305
         readfile("schedulers.txt");
306 306
     }
307 307
 
308
-    $t = $title?$title:PROJECT;
308
+    $t = $title ? $title : PROJECT;
309 309
     echo "<title>$t</title>\n";
310 310
     echo '
311 311
         <meta charset="utf-8">
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     echo '<div class="container-fluid">
363 363
     ';
364 364
 
365
-    switch($title) {    //kludge
365
+    switch ($title) {    //kludge
366 366
     case tra("Log in"):
367 367
     case tra("Create an account"):
368 368
     case tra("Server status page"):
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
 
378 378
 // See the comments for page_head()
379 379
 //
380
-if (!function_exists("page_tail")){
380
+if (!function_exists("page_tail")) {
381 381
 function page_tail(
382
-    $show_date=false,
382
+    $show_date = false,
383 383
         // true for pages that are generated periodically rather than on the fly
384
-    $url_prefix="",
384
+    $url_prefix = "",
385 385
         // use for pages not at top level
386
-    $is_main=false
386
+    $is_main = false
387 387
         // passed to project_footer;
388 388
 ) {
389 389
     echo "<br>\n";
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
 }
399 399
 }
400 400
 
401
-function display_cvs_versions(){
401
+function display_cvs_versions() {
402 402
     global $cvs_version_tracker;
403 403
     echo "\n<!-- SVN VERSIONS -->\n";
404
-    for ($i=0;$i<sizeof($cvs_version_tracker);$i++) {
404
+    for ($i = 0; $i < sizeof($cvs_version_tracker); $i++) {
405 405
         echo "<!-- ".$cvs_version_tracker[$i]." -->\n";
406 406
     }
407 407
 }
@@ -426,24 +426,24 @@  discard block
 block discarded – undo
426 426
 // convert time interval in seconds to a string of the form
427 427
 // 'D days h hours m min s sec'.
428 428
 
429
-function time_diff($x, $res=3) {
429
+function time_diff($x, $res = 3) {
430 430
     $x = (int)$x;
431 431
     $days    = (int)($x/86400);
432
-    $hours   = (int)(($x-$days*86400)/3600);
433
-    $minutes = (int)(($x-$days*86400-$hours*3600)/60);
434
-    $seconds = $x % 60;
432
+    $hours   = (int)(($x - $days*86400)/3600);
433
+    $minutes = (int)(($x - $days*86400 - $hours*3600)/60);
434
+    $seconds = $x%60;
435 435
 
436 436
     $s = "";
437 437
     if ($days) {
438 438
         $s .= "$days ".tra("days")." ";
439 439
     }
440
-    if ($res>0 && ($hours || strlen($s))) {
440
+    if ($res > 0 && ($hours || strlen($s))) {
441 441
         $s .= "$hours ".tra("hours")." ";
442 442
     }
443
-    if ($res>1 && ($minutes || strlen($s))) {
443
+    if ($res > 1 && ($minutes || strlen($s))) {
444 444
         $s .= "$minutes ".tra("min")." ";
445 445
     }
446
-    if ($res>2) {
446
+    if ($res > 2) {
447 447
         $s .= "$seconds ".tra("sec")." ";
448 448
     }
449 449
     return $s;
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 
458 458
 function time_str($x) {
459 459
     if ($x == 0) return "---";
460
-    return gmdate('j M Y, G:i:s', (int)$x) . " UTC";
460
+    return gmdate('j M Y, G:i:s', (int)$x)." UTC";
461 461
 }
462 462
 
463 463
 function local_time_str($x) {
@@ -469,14 +469,14 @@  discard block
 block discarded – undo
469 469
     return time_str($x);
470 470
 }
471 471
 
472
-function start_table_str($class="", $style="") {
473
-    $s = $style?'style="'.$style.'"':'';
472
+function start_table_str($class = "", $style = "") {
473
+    $s = $style ? 'style="'.$style.'"' : '';
474 474
     return '<div class="table">
475 475
       <table '.$s.' width="100%" class="table table-condensed '.$class.'" >
476 476
     ';
477 477
 }
478 478
 
479
-function start_table($class="", $style="") {
479
+function start_table($class = "", $style = "") {
480 480
     echo start_table_str($class, $style);
481 481
 }
482 482
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
     echo "</tr>\n";
522 522
 }
523 523
 
524
-function row1($x, $ncols=2, $class="heading") {
524
+function row1($x, $ncols = 2, $class = "heading") {
525 525
     if ($class == "heading") {
526 526
         echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n";
527 527
     } else {
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
 
536 536
 // a table row with 2 columns, with the left on right-aligned
537 537
 
538
-function row2($x, $y, $show_error=false, $lwidth='40%') {
539
-    if ($x==="") $x="<br>";
540
-    if ($y==="") $y="<br>";
541
-    $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS;
538
+function row2($x, $y, $show_error = false, $lwidth = '40%') {
539
+    if ($x === "") $x = "<br>";
540
+    if ($y === "") $y = "<br>";
541
+    $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
542 542
     echo "<tr>
543 543
         <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td>
544 544
         <td $attrs >$y</td>
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 // output the first part of row2();
550 550
 // then write the content, followed by </td></tr>
551 551
 
552
-function row2_init($x, $lwidth='40%') {
552
+function row2_init($x, $lwidth = '40%') {
553 553
     echo sprintf('<tr>
554 554
         <td width="%s" %s>%s</td>
555 555
         <td %s>',
@@ -565,31 +565,31 @@  discard block
 block discarded – undo
565 565
     echo "<tr><td>$string</td></tr>";
566 566
 }
567 567
 
568
-function row_array($x, $attrs=null) {
568
+function row_array($x, $attrs = null) {
569 569
     echo "<tr>\n";
570 570
     $i = 0;
571 571
     foreach ($x as $h) {
572
-        $a = $attrs?$attrs[$i]:"";
572
+        $a = $attrs ? $attrs[$i] : "";
573 573
         echo "<td $a>$h</td>\n";
574 574
         $i++;
575 575
     }
576 576
     echo "</tr>\n";
577 577
 }
578 578
 
579
-define ('ALIGN_RIGHT', 'style="text-align:right;"');
579
+define('ALIGN_RIGHT', 'style="text-align:right;"');
580 580
 
581
-function row_heading_array($x, $attrs=null, $class='bg-primary') {
581
+function row_heading_array($x, $attrs = null, $class = 'bg-primary') {
582 582
     echo "<tr>";
583 583
     $i = 0;
584 584
     foreach ($x as $h) {
585
-        $a = $attrs?$attrs[$i]:"";
585
+        $a = $attrs ? $attrs[$i] : "";
586 586
         echo "<th $a class=\"$class\">$h</th>";
587 587
         $i++;
588 588
     }
589 589
     echo "</tr>\n";
590 590
 }
591 591
 
592
-function row_heading($x, $class='bg-primary') {
592
+function row_heading($x, $class = 'bg-primary') {
593 593
     echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr>
594 594
         ', $class, $x
595 595
     );
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 // If $ellipsis is true, then an ellipsis is added to any sentence which
650 650
 // is cut short.
651 651
 
652
-function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) {
652
+function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) {
653 653
     $words = explode($delimiter, $sentence);
654 654
     $total_chars = 0;
655 655
     $trunc = false;
@@ -732,8 +732,8 @@  discard block
 block discarded – undo
732 732
 
733 733
 // returns null if the arg is optional and missing
734 734
 //
735
-function get_int($name, $optional=false) {
736
-    $x=null;
735
+function get_int($name, $optional = false) {
736
+    $x = null;
737 737
     if (isset($_GET[$name])) $x = $_GET[$name];
738 738
     if (!is_numeric($x)) {
739 739
         if ($optional) {
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 
753 753
 // returns null if the arg is optional and missing
754 754
 //
755
-function post_num($name, $optional=false) {
755
+function post_num($name, $optional = false) {
756 756
     $x = null;
757 757
     if (isset($_POST[$name])) $x = $_POST[$name];
758 758
     if (!is_numeric($x)) {
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 
768 768
 // returns null if the arg is optional and missing
769 769
 //
770
-function post_int($name, $optional=false) {
770
+function post_int($name, $optional = false) {
771 771
     $x = post_num($name, $optional);
772 772
     if (is_null($x)) return null;
773 773
     $y = (int)$x;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
     }
786 786
 }
787 787
 
788
-function get_str($name, $optional=false) {
788
+function get_str($name, $optional = false) {
789 789
     if (isset($_GET[$name])) {
790 790
         $x = $_GET[$name];
791 791
     } else {
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
     return undo_magic_quotes($x);
798 798
 }
799 799
 
800
-function post_str($name, $optional=false) {
800
+function post_str($name, $optional = false) {
801 801
     if (isset($_POST[$name])) {
802 802
         $x = $_POST[$name];
803 803
     } else {
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
     return undo_magic_quotes($x);
810 810
 }
811 811
 
812
-function post_arr($name, $optional=false) {
812
+function post_arr($name, $optional = false) {
813 813
     if (isset($_POST[$name]) && is_array($_POST[$name])) {
814 814
         $x = $_POST[$name];
815 815
     } else {
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     // the mb_* functions are not included by default
826 826
     // return (mb_detect_encoding($passwd) -= 'ASCII');
827 827
 
828
-    for ($i=0; $i<strlen($str); $i++) {
828
+    for ($i = 0; $i < strlen($str); $i++) {
829 829
         $c = ord(substr($str, $i));
830 830
         if ($c < 32 || $c > 127) return false;
831 831
     }
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     $number = str_replace(',', '.', $number); // replace the german decimal separator
850 850
     // if no value was entered and this is ok
851 851
     //
852
-    if ($number=='' && !$low) return true;
852
+    if ($number == '' && !$low) return true;
853 853
 
854 854
     // the supplied value contains alphabetic characters
855 855
     //
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 
867 867
 // Generate a "select" element from an array of values
868 868
 //
869
-function select_from_array($name, $array, $selection=null, $width=240) {
869
+function select_from_array($name, $array, $selection = null, $width = 240) {
870 870
     $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"';
871 871
 
872 872
     foreach ($array as $key => $value) {
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
     return $str;
892 892
 }
893 893
 
894
-function strip_bbcode($string){
895
-    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string);
894
+function strip_bbcode($string) {
895
+    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string);
896 896
 }
897 897
 
898 898
 function current_url() {
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 // the colors for bootstrap' btn-success are almost illegible;
918 918
 // the green is too light.  Use a darker green.
919 919
 //
920
-function button_style($color='green', $font_size=null) {
920
+function button_style($color = 'green', $font_size = null) {
921 921
     $fs = '';
922 922
     if ($font_size) {
923 923
         $fs = sprintf('; font-size:%dpx', $font_size);
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 // class: class of the button, e.g. btn
937 937
 // extra: Additional text in href tag
938 938
 //
939
-function button_text($url, $text, $desc=null, $class=null, $extra='') {
939
+function button_text($url, $text, $desc = null, $class = null, $extra = '') {
940 940
     if (!$desc) {
941 941
         $desc = $text;
942 942
     }
@@ -951,19 +951,19 @@  discard block
 block discarded – undo
951 951
     );
952 952
 }
953 953
 
954
-function show_button($url, $text, $desc=null, $class=null, $extra=null) {
954
+function show_button($url, $text, $desc = null, $class = null, $extra = null) {
955 955
     echo button_text($url, $text, $desc, $class, $extra);
956 956
 }
957 957
 
958 958
 // for places with a bunch of buttons, like forum posts
959 959
 //
960
-function show_button_small($url, $text, $desc=null) {
960
+function show_button_small($url, $text, $desc = null) {
961 961
     echo button_text($url, $text, $desc, "btn btn-xs", button_style());
962 962
 }
963 963
 
964 964
 // used for showing icons
965 965
 //
966
-function show_image($src, $title, $alt, $height=null) {
966
+function show_image($src, $title, $alt, $height = null) {
967 967
     $h = "";
968 968
     if ($height) {
969 969
         $h = "height=\"$height\"";
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 // tries instead to connect to <replica_db_host> if tag exists.
1001 1001
 // DEPRECATED - use boinc_db.inc
1002 1002
 //
1003
-function db_init($try_replica=false) {
1003
+function db_init($try_replica = false) {
1004 1004
     check_web_stopped();
1005 1005
     $retval = db_init_aux($try_replica);
1006 1006
     if ($retval == 1) {
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 // Check this to avoid XSS vulnerability
1117 1117
 //
1118 1118
 function sanitize_sort_by($x) {
1119
-    switch($x) {
1119
+    switch ($x) {
1120 1120
     case 'expavg_credit':
1121 1121
     case 'total_credit':
1122 1122
         return;
@@ -1133,9 +1133,9 @@  discard block
 block discarded – undo
1133 1133
     return $c/(200/24);
1134 1134
 }
1135 1135
 
1136
-function do_download($path,$name="") {
1137
-    if (strcmp($name,"") == 0) {
1138
-        $name=basename($path);
1136
+function do_download($path, $name = "") {
1137
+    if (strcmp($name, "") == 0) {
1138
+        $name = basename($path);
1139 1139
     }
1140 1140
     header('Content-Description: File Transfer');
1141 1141
     header('Content-Type: application/octet-stream');
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
     header('Expires: 0');
1145 1145
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1146 1146
     header('Pragma: public');
1147
-    header('Content-Length: ' . filesize($path));
1147
+    header('Content-Length: '.filesize($path));
1148 1148
     flush();
1149 1149
     readfile($path);
1150 1150
 }
@@ -1193,10 +1193,10 @@  discard block
 block discarded – undo
1193 1193
 // Otherwise return 0.
1194 1194
 // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)"
1195 1195
 //
1196
-function boinc_client_version(){
1196
+function boinc_client_version() {
1197 1197
     if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0;
1198 1198
     $x = $_SERVER['HTTP_USER_AGENT'];
1199
-    $e =  "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1199
+    $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1200 1200
     if (preg_match($e, $x, $matches)) {
1201 1201
         return $matches[1]*10000 + $matches[2]*100 + $matches[3];
1202 1202
     }
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
     $rem_name = $name."_remaining";
1226 1226
     return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\"
1227 1227
         onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea>
1228
-        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1228
+        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1229 1229
     ;
1230 1230
 }
1231 1231
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 // use the following around text with long lines,
1256 1256
 // to limit the width and make it more readable.
1257 1257
 //
1258
-function text_start($width=640) {
1258
+function text_start($width = 640) {
1259 1259
     echo sprintf("<div style=\"max-width: %dpx;\">\n", $width);
1260 1260
 }
1261 1261
 function text_end() {
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 }
1282 1282
 
1283 1283
 function cert_filename() {
1284
-    return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php";
1284
+    return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php";
1285 1285
 }
1286 1286
 
1287 1287
 // if user hasn't validated their email addr, tell them to
@@ -1298,6 +1298,6 @@  discard block
 block discarded – undo
1298 1298
     }
1299 1299
 }
1300 1300
 
1301
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
1301
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
1302 1302
 
1303 1303
 ?>
Please login to merge, or discard this patch.
html/inc/forum_db.inc 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         $db = BoincDb::get();
28 28
         return $db->lookup('category', 'BoincCategory', $clause);
29 29
     }
30
-    static function enum($clause=null) {
30
+    static function enum($clause = null) {
31 31
         $db = BoincDb::get();
32 32
         return $db->enum('category', 'BoincCategory', $clause);
33 33
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $db = BoincDb::get();
79 79
         return $db->update($this, 'thread', $clause);
80 80
     }
81
-    static function enum($clause="") {
81
+    static function enum($clause = "") {
82 82
         $db = BoincDb::get();
83 83
         return $db->enum('thread', 'BoincThread', $clause);
84 84
     }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $db = BoincDb::get();
143 143
         $ret = $db->insert('forum_preferences', $clause);
144 144
     }
145
-    static function lookup(&$user, $nocache=false) {
145
+    static function lookup(&$user, $nocache = false) {
146 146
         if (!$user) return;
147 147
         if (isset($user->prefs)) return;
148 148
         if (!$nocache && isset(self::$cache[$user->id])) {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         $user->prefs = $prefs;
165 165
     }
166 166
     function privilege($specialbit) {
167
-         return (substr($this->special_user, $specialbit,1)==1);
167
+         return (substr($this->special_user, $specialbit, 1) == 1);
168 168
     }
169 169
     function update($clause) {
170 170
         $db = BoincDb::get();
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         $db = BoincDb::get();
176 176
         return $db->delete_aux('forum_preferences', "userid=$this->userid");
177 177
     }
178
-    static function enum($clause=null) {
178
+    static function enum($clause = null) {
179 179
         $db = BoincDb::get();
180 180
         return $db->enum('forum_preferences', 'BoincForumPrefs', $clause);
181 181
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
         //
216 216
         $fl = BoincForumLogging::lookup(0, 0);
217 217
         if ($fl) {
218
-            if ($fl->timestamp<time()-MAX_FORUM_LOGGING_TIME){
219
-                BoincForumLogging::delete_aux("timestamp<'".(time()-MAX_FORUM_LOGGING_TIME)."' and userid != 0");
218
+            if ($fl->timestamp < time() - MAX_FORUM_LOGGING_TIME) {
219
+                BoincForumLogging::delete_aux("timestamp<'".(time() - MAX_FORUM_LOGGING_TIME)."' and userid != 0");
220 220
                 BoincForumLogging::replace(0, 0, time());
221 221
             }
222 222
         } else {
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
     }
327 327
 }
328 328
 
329
-define ('NOTIFY_FRIEND_REQ', 1);
330
-define ('NOTIFY_FRIEND_ACCEPT', 2);
331
-define ('NOTIFY_PM', 3);
332
-define ('NOTIFY_SUBSCRIBED_THREAD', 4);
333
-define ('NOTIFY_SUBSCRIBED_FORUM', 5);
329
+define('NOTIFY_FRIEND_REQ', 1);
330
+define('NOTIFY_FRIEND_ACCEPT', 2);
331
+define('NOTIFY_PM', 3);
332
+define('NOTIFY_SUBSCRIBED_THREAD', 4);
333
+define('NOTIFY_SUBSCRIBED_FORUM', 5);
334 334
 
335 335
 ?>
Please login to merge, or discard this patch.
html/inc/forum_email.inc 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 // - project forums: everyone in POST_REPORT_EMAILS
25 25
 // - team message board: team founder and admins
26 26
 //
27
-function mail_report_list($forum, $subject, $body, $must_send=false) {
27
+function mail_report_list($forum, $subject, $body, $must_send = false) {
28 28
     $success = true;
29 29
     switch ($forum->parent_type) {
30 30
     case 0:
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 function send_moderation_email($forum, $post, $thread, $explanation, $action) {
66 66
     global $master_url;
67 67
 
68
-    $moderator=get_logged_in_user();
68
+    $moderator = get_logged_in_user();
69 69
     $body = "";
70 70
     $user = BoincUser::lookup_id($post->user);
71 71
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 // There's a new post in the thread, which the user is subscribed to.
127 127
 // send them an email notifying them.
128 128
 //
129
-function send_thread_notification_email($thread, $user){
130
-    $title = PROJECT . ": there is a new post in '". $thread->title ."'";
131
-    $link = secure_url_base() . "forum_thread.php?id=" . $thread->id;
132
-    $body = "A " . PROJECT . " user has posted to the thread
133
-\"" . $thread->title . "\".\n"
129
+function send_thread_notification_email($thread, $user) {
130
+    $title = PROJECT.": there is a new post in '".$thread->title."'";
131
+    $link = secure_url_base()."forum_thread.php?id=".$thread->id;
132
+    $body = "A ".PROJECT." user has posted to the thread
133
+\"" . $thread->title."\".\n"
134 134
            ."To view the updated thread, visit:\n$link
135 135
 
136 136
 --------------------------
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 // There's a new thread in the forum, which the user is subscribed to.
145 145
 // send them an email notifying them.
146 146
 //
147
-function send_forum_notification_email($forum, $user){
148
-    $title = PROJECT . ": there is a new thread in '". $forum->title ."'";
149
-    $link = secure_url_base() . "forum_forum.php?id=" . $forum->id;
150
-    $body = "A " . PROJECT . " user has added a thread to the forum
151
-\"" . $thread->title . "\".\n"
147
+function send_forum_notification_email($forum, $user) {
148
+    $title = PROJECT.": there is a new thread in '".$forum->title."'";
149
+    $link = secure_url_base()."forum_forum.php?id=".$forum->id;
150
+    $body = "A ".PROJECT." user has added a thread to the forum
151
+\"" . $thread->title."\".\n"
152 152
            ."To view the updated forum, visit:\n$link
153 153
 
154 154
 --------------------------
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
 //////////////////// a user clicks the red "x" to report a post ///////////
163 163
 //
164
-function send_report_post_email($user, $forum, $thread,  $post, $message) {
164
+function send_report_post_email($user, $forum, $thread, $post, $message) {
165 165
 	global $master_url;
166 166
 
167 167
     $body = "";
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 //
220 220
 function send_banish_vote_email($user, $duration, $reason, $end_time) {
221 221
 	global $master_url;
222
-    $now=time();
222
+    $now = time();
223 223
     $subject = PROJECT." banishment vote underway";
224 224
     $vote_url = $master_url."forum_banishment_vote.php";
225 225
     $body = "
226 226
 A vote has been started to banish you
227 227
 from the ".PROJECT." message boards until ".date('M j,
228
-Y G:i', $duration+$now).",
228
+Y G:i', $duration + $now).",
229 229
 because your postings have not followed our guidelines.
230 230
 
231
-This vote will last until ".date('M j, Y G:i',$end_time)." or until a majority
231
+This vote will last until ".date('M j, Y G:i', $end_time)." or until a majority
232 232
 decision has been reached.  If the vote does not result in banishment, you will be
233 233
 able to resume posting at that time.
234 234
     ";
Please login to merge, or discard this patch.
html/user/forum_forum.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 require_once('../inc/forum.inc');
24 24
 require_once('../inc/pm.inc');
25 25
 
26
-function forum_page($forum, $user, $msg=null) {
26
+function forum_page($forum, $user, $msg = null) {
27 27
     global $forum_sort_styles;
28 28
     $sort_style = get_int("sort", true);
29 29
     $start = get_int("start", true);
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
     if (!$sort_style) {
48 48
         // get the sort style either from the logged in user or a cookie
49
-        if ($user){
49
+        if ($user) {
50 50
             $sort_style = $user->prefs->forum_sorting;
51 51
         } else {
52 52
             list($sort_style, $thread_style) = parse_forum_cookie();
53 53
         }
54 54
     } else {
55 55
         // set the sort style
56
-        if ($user){
56
+        if ($user) {
57 57
             $user->prefs->forum_sorting = $sort_style;
58 58
             $user->prefs->update("forum_sorting=$sort_style");
59 59
         } else {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         echo "<td><a href=\"forum_thread.php?id=$thread->id\">$title</a><br></td>";
243 243
 
244 244
         echo '
245
-            <td>'.($thread->replies+1).'</td>
245
+            <td>'.($thread->replies + 1).'</td>
246 246
             <td>'.user_links($owner, BADGE_HEIGHT_SMALL).'</td>
247 247
             <td>'.$thread->views.'</td>
248 248
             <td>'.time_diff_str($thread->timestamp, time()).'</td>
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         flush();
252 252
     }
253 253
     end_table();
254
-    echo "<br>$page_nav";    // show page links
254
+    echo "<br>$page_nav"; // show page links
255 255
 }
256 256
 
257 257
 $id = get_int("id");
Please login to merge, or discard this patch.
html/ops/delete_user.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 die("Delete this line first\n");
29 29
 
30 30
 if (is_numeric($argv[1])) {
31
-    $user = BoincUser::lookup_id((int) $argv[1]);
31
+    $user = BoincUser::lookup_id((int)$argv[1]);
32 32
     if (!$user) die("no such user\n");
33 33
     $retval = delete_account($user);
34 34
     if ($retval) {
Please login to merge, or discard this patch.
html/user/server_status.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
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 = '---';
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         $cmd = trim($cmd);
276 276
         $x = explode(" ", $cmd);
277 277
         $prog = $x[0];
278
-        $pidname = $prog . '.pid';
278
+        $pidname = $prog.'.pid';
279 279
     }
280 280
     $path = "../../pid_$host/$pidname";
281 281
     if (is_file($path)) {
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
     }
317 317
     $master_host = $u["host"];
318 318
     if ($config->www_host) {
319
-        $web_host = trim((string) $config->www_host);
319
+        $web_host = trim((string)$config->www_host);
320 320
     } else {
321 321
         $web_host = $main_host;
322 322
     }
323 323
     if ($config->sched_host) {
324
-        $sched_host = trim((string) $config->sched_host);
324
+        $sched_host = trim((string)$config->sched_host);
325 325
     } else {
326 326
         $sched_host = $main_host;
327 327
     }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
     // the upload and download servers are sort of daemons too
333 333
     //
334
-    $url = trim((string) $config->download_url);
334
+    $url = trim((string)$config->download_url);
335 335
     $u = parse_url($url);
336 336
     $h = $u["host"];
337 337
     if ($h == $master_host) {
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
     } else {
344 344
         $have_remote = true;
345 345
     }
346
-    $url = trim((string) $config->upload_url);
346
+    $url = trim((string)$config->upload_url);
347 347
     $u = parse_url($url);
348 348
     $h = $u["host"];
349 349
     if ($h == $master_host) {
350 350
         $y = new StdClass;
351 351
         $y->cmd = "Upload server";
352 352
         $y->host = $h;
353
-        $y->status = !file_exists("../../stop_upload");;
353
+        $y->status = !file_exists("../../stop_upload"); ;
354 354
         $local_daemons[] = $y;
355 355
     } else {
356 356
         $have_remote = true;
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
     $y = new StdClass;
362 362
     $y->cmd = "Scheduler";
363 363
     $y->host = $sched_host;
364
-    $y->status = !file_exists("../../stop_sched");;
364
+    $y->status = !file_exists("../../stop_sched"); ;
365 365
     $local_daemons[] = $y;
366 366
 
367 367
     foreach ($daemons->daemon as $d) {
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
             $disabled_daemons[] = $x;
375 375
             continue;
376 376
         }
377
-        $host = $d->host?(string)$d->host:$main_host;
377
+        $host = $d->host ? (string)$d->host : $main_host;
378 378
         if ($host != $web_host) {
379 379
             $have_remote = true;
380 380
             continue;
Please login to merge, or discard this patch.
html/inc/email.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 // send an email, using PHPMailer or not.
28 28
 //
29
-function send_email($user, $subject, $body, $body_html=null, $email_addr=null) {
29
+function send_email($user, $subject, $body, $body_html = null, $email_addr = null) {
30 30
     if (!$email_addr) {
31 31
         $email_addr = $user->email_addr;
32 32
     }
@@ -69,17 +69,17 @@  discard block
 block discarded – undo
69 69
             return true;
70 70
         }
71 71
     } else {
72
-        $headers ="";
72
+        $headers = "";
73 73
         if (defined('EMAIL_FROM') && defined('EMAIL_FROM_NAME')) {
74 74
             $headers = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM.">";
75 75
         } else if (defined('EMAIL_FROM')) {
76
-            $headers = "From: ". EMAIL_FROM;
76
+            $headers = "From: ".EMAIL_FROM;
77 77
         }
78 78
         if ($body_html) {
79 79
             $body = "<html><body>\n";
80 80
             $body .= $body_html;
81 81
             $body .= "\n</body></html>\n";
82
-            $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
82
+            $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
83 83
         }
84 84
         return mail($email_addr, $subject, $body, $headers);
85 85
     }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     // otherwise check both IP and email
161 161
     if ($ip && filter_var(
162 162
         $ip, FILTER_VALIDATE_IP,
163
-        FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
163
+        FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE
164 164
     )) {
165 165
         $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip."&email=".$addr);
166 166
     } else {
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     return md5($key.'oogabooga');
206 206
 }
207 207
 
208
-function opt_out_url($user, $page="opt_out.php") {
208
+function opt_out_url($user, $page = "opt_out.php") {
209 209
     return sprintf("%s%s?code=%s&userid=%d",
210 210
         secure_url_base(),
211 211
         $page,
Please login to merge, or discard this patch.
html/inc/user_util.inc 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 function check_passwd_ui($user, $passwd) {
59 59
     $passwd_hash = md5($passwd.$user->email_addr);
60
-    if(!check_passwd_hash($user, $passwd_hash)) {
60
+    if (!check_passwd_hash($user, $passwd_hash)) {
61 61
         sleep(LOGIN_FAIL_SLEEP_SEC);
62 62
         page_head("Password incorrect");
63 63
         echo "The password you entered is incorrect. Please go back and try again.\n";
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 function is_banned_email_addr($email_addr) {
70 70
     global $banned_email_domains;
71 71
     if (isset($banned_email_domains)) {
72
-        foreach($banned_email_domains as $d) {
72
+        foreach ($banned_email_domains as $d) {
73 73
             $x = strstr($email_addr, $d);
74 74
             if ($x == $d) return true;
75 75
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 //
109 109
 function make_user(
110 110
     $email_addr, $name, $passwd_hash,
111
-    $country=null, $postal_code=null, $project_prefs=null, $teamid=0
111
+    $country = null, $postal_code = null, $project_prefs = null, $teamid = 0
112 112
 ) {
113 113
     if (!is_valid_email_syntax($email_addr)) return null;
114 114
         // caller generally has already checked
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             $users = BoincUser::enum(
244 244
                 sprintf("name like '%s%%'", $new_name)
245 245
             );
246
-            foreach ($users as $u){
246
+            foreach ($users as $u) {
247 247
                 echo "<p>$u->name\n";
248 248
             }
249 249
             page_tail();
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
         show_error(tra("Passwords may only include ASCII characters."));
279 279
     }
280 280
 
281
-    if (strlen($passwd)<$min_passwd_length) {
281
+    if (strlen($passwd) < $min_passwd_length) {
282 282
         show_error(
283 283
             tra("New password is too short: minimum password length is %1 characters.", $min_passwd_length)
284 284
         );
Please login to merge, or discard this patch.