Passed
Pull Request — master (#6702)
by David
15:07 queued 05:16
created
html/inc/user.inc 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 // they've participated in
34 34
 //
35 35
 function get_other_projects($user) {
36
-    $cpid = md5($user->cross_project_id . $user->email_addr);
36
+    $cpid = md5($user->cross_project_id.$user->email_addr);
37 37
     $url = "https://api.free-dc.org/get_user.php?cpid=$cpid";
38 38
 
39 39
     // Check the cache for that URL
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     usort($user->projects, "cmp");
123 123
     if ($personal) {
124
-        $t  = tra("Projects in which you are participating");
124
+        $t = tra("Projects in which you are participating");
125 125
     } else {
126 126
         $t = tra("Projects in which %1 is participating", $user->name);
127 127
     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     }
181 181
 
182 182
     if (!NO_STATS) {
183
-        $cpid = md5($user->cross_project_id . $user->email_addr);
183
+        $cpid = md5($user->cross_project_id.$user->email_addr);
184 184
         $x = "";
185 185
         shuffle($cpid_stats_sites);
186 186
         foreach ($cpid_stats_sites as $site) {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         $u = normalize_user_url($user->url);
267 267
         row2(
268 268
             tra("URL"),
269
-            $u?sprintf('<a href="%s">%s</a>', $u, $u):tra('Invalid URL')
269
+            $u ?sprintf('<a href="%s">%s</a>', $u, $u) : tra('Invalid URL')
270 270
         );
271 271
     }
272 272
     if (USER_COUNTRY) {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 // if $badge_height is > 0, show badges
383 383
 // if $name_limit, limit name to N chars
384 384
 //
385
-function user_links($user, $badge_height=0, $name_limit=0) {
385
+function user_links($user, $badge_height = 0, $name_limit = 0) {
386 386
     if (!$user) {
387 387
         error_log("user_links(): null arg\n");
388 388
         return;
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
         $user->id,
412 412
         $name
413 413
     );
414
-    if (function_exists("project_user_links")){
414
+    if (function_exists("project_user_links")) {
415 415
         $x .= project_user_links($user);
416 416
     }
417 417
     if ($badge_height) {
418 418
         $x .= badges_string(true, $user, $badge_height);
419 419
     }
420
-    return $name_limit?"<nobr>$x</nobr>":$x;
420
+    return $name_limit ? "<nobr>$x</nobr>" : $x;
421 421
 }
422 422
 
423 423
 // show community links for the logged in user
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 
477 477
             // if there's a foundership request, notify the founder
478 478
             //
479
-            if ($user->id==$team->userid && $team->ping_user >0) {
479
+            if ($user->id == $team->userid && $team->ping_user > 0) {
480 480
                 $x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>";
481 481
             }
482 482
             row2(tra("Member of team"), $x);
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
     $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
501 501
     $x = [];
502 502
     if ($friends) {
503
-        foreach($friends as $friend) {
503
+        foreach ($friends as $friend) {
504 504
             $fuser = BoincUser::lookup_id($friend->user_dest);
505 505
             if (!$fuser) continue;
506 506
             $x[] = friend_links($fuser);
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 
551 551
 // return an object with data to show the user's community links
552 552
 //
553
-function get_community_links_object($user){
553
+function get_community_links_object($user) {
554 554
     $cache_object = new StdClass;
555 555
     $cache_object->post_count = total_posts($user);
556 556
     $cache_object->user = $user;
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     $cache_object->friends = array();
559 559
 
560 560
     $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
561
-    foreach($friends as $friend) {
561
+    foreach ($friends as $friend) {
562 562
         $fuser = BoincUser::lookup_id($friend->user_dest);
563 563
         if (!$fuser) continue;
564 564
         $cache_object->friends[] = $fuser;
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 
569 569
 // show community links of another user (described by $clo)
570 570
 //
571
-function community_links($clo, $logged_in_user){
571
+function community_links($clo, $logged_in_user) {
572 572
     $user = $clo->user;
573 573
     if (!$user) {
574 574
         error_log("community_links(): null user\n");
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
                 "<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>"
611 611
             );
612 612
         } else if ($friend) {
613
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
613
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
614 614
         } else {
615
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
615
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
616 616
         }
617 617
     }
618 618
 
619 619
     if ($friends) {
620 620
         $x = [];
621
-        foreach($friends as $friend) {
621
+        foreach ($friends as $friend) {
622 622
             $x[] = friend_links($friend);
623 623
         }
624 624
         row2(tra('Friends'), implode('<br>', $x));
Please login to merge, or discard this patch.
html/inc/util.inc 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 require_once("../inc/bootstrap.inc");
31 31
 
32 32
 function master_url() {
33
-    return parse_config(get_config() , "<master_url>");
33
+    return parse_config(get_config(), "<master_url>");
34 34
 }
35 35
 function recaptcha_public_key() {
36 36
     return parse_config(get_config(), "<recaptcha_public_key>");
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 // Set parameters to defaults if not defined in config.xml
43 43
 
44 44
 $x = parse_config(get_config(), "<user_country>");
45
-define('USER_COUNTRY', ($x===null)?1:(int)$x);
45
+define('USER_COUNTRY', ($x === null) ? 1 : (int)$x);
46 46
 
47 47
 $x = parse_config(get_config(), "<user_url>");
48
-define('USER_URL', ($x===null)?1:(int)$x);
48
+define('USER_URL', ($x === null) ? 1 : (int)$x);
49 49
 
50 50
 // Set parameters to defaults if not defined in project.inc
51 51
 
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 }
151 151
 
152 152
 function url_base() {
153
-    return is_https()?secure_url_base():URL_BASE;
153
+    return is_https() ?secure_url_base() : URL_BASE;
154 154
 }
155 155
 
156
-function send_cookie($name, $value, $permanent, $ops=false) {
156
+function send_cookie($name, $value, $permanent, $ops = false) {
157 157
     // the following allows independent login for projects on the same server
158 158
     //
159 159
     $url = parse_url(master_url());
@@ -162,28 +162,28 @@  discard block
 block discarded – undo
162 162
         $path = substr($path, 0, -1);
163 163
         $path .= "_ops/";
164 164
     }
165
-    $expire = $permanent?time()+3600*24*365:0;
165
+    $expire = $permanent ?time() + 3600*24*365 : 0;
166 166
     setcookie($name, $value, $expire, $path,
167 167
         '',
168
-        is_https(),     // if this page is secure, make cookie secure
168
+        is_https(), // if this page is secure, make cookie secure
169 169
         true            // httponly; no JS access
170 170
     );
171 171
 }
172 172
 
173
-function clear_cookie($name, $ops=false) {
173
+function clear_cookie($name, $ops = false) {
174 174
     $url = parse_url(master_url());
175 175
     $path = $url['path'];
176 176
     if ($ops) {
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 html/project/project.inc
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
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
     if ($head_extra) {
304 304
         echo "\n$head_extra\n";
305 305
     }
306
-    if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) {
306
+    if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) {
307 307
         readfile("schedulers.txt");
308 308
     }
309 309
 
310
-    $t = $title?$title:PROJECT;
310
+    $t = $title ? $title : PROJECT;
311 311
     echo "<title>$t</title>\n";
312 312
     echo '
313 313
         <meta charset="utf-8">
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     echo '<div class="container-fluid">
364 364
     ';
365 365
 
366
-    switch($title) {    //kludge
366
+    switch ($title) {    //kludge
367 367
     case tra("Log in"):
368 368
     case tra("Create an account"):
369 369
     case tra("Server status page"):
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
 
379 379
 // See the comments for page_head()
380 380
 //
381
-if (!function_exists("page_tail")){
381
+if (!function_exists("page_tail")) {
382 382
 function page_tail(
383
-    $show_date=false,
383
+    $show_date = false,
384 384
         // true for pages that are generated periodically rather than on the fly
385
-    $url_prefix="",
385
+    $url_prefix = "",
386 386
         // use for pages not at top level
387
-    $is_main=false
387
+    $is_main = false
388 388
         // passed to project_footer;
389 389
 ) {
390 390
     echo "<br>\n";
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
     exit();
416 416
 }
417 417
 
418
-function start_table_str($class="", $style="") {
419
-    $s = $style?'style="'.$style.'"':'';
418
+function start_table_str($class = "", $style = "") {
419
+    $s = $style ? 'style="'.$style.'"' : '';
420 420
     return '<div class="table">
421 421
       <table '.$s.' width="100%" class="table table-condensed '.$class.'" >
422 422
     ';
423 423
 }
424 424
 
425
-function start_table($class="", $style="") {
425
+function start_table($class = "", $style = "") {
426 426
     echo start_table_str($class, $style);
427 427
 }
428 428
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
     echo "</tr>\n";
468 468
 }
469 469
 
470
-function row1($x, $ncols=2, $class="heading") {
470
+function row1($x, $ncols = 2, $class = "heading") {
471 471
     if ($class == "heading") {
472 472
         echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n";
473 473
     } else {
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 
482 482
 // a table row with 2 columns, with the left on right-aligned
483 483
 
484
-function row2($x, $y, $show_error=false, $lwidth='40%') {
485
-    if ($x==="") $x="<br>";
486
-    if ($y==="") $y="<br>";
487
-    $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS;
484
+function row2($x, $y, $show_error = false, $lwidth = '40%') {
485
+    if ($x === "") $x = "<br>";
486
+    if ($y === "") $y = "<br>";
487
+    $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
488 488
     echo "<tr>
489 489
         <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td>
490 490
         <td $attrs >$y</td>
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 // output the first part of row2();
496 496
 // then write the content, followed by </td></tr>
497 497
 
498
-function row2_init($x, $lwidth='40%') {
498
+function row2_init($x, $lwidth = '40%') {
499 499
     echo sprintf('<tr>
500 500
         <td width="%s" %s>%s</td>
501 501
         <td %s>',
@@ -511,31 +511,31 @@  discard block
 block discarded – undo
511 511
     echo "<tr><td>$string</td></tr>";
512 512
 }
513 513
 
514
-function row_array($x, $attrs=null) {
514
+function row_array($x, $attrs = null) {
515 515
     echo "<tr>\n";
516 516
     $i = 0;
517 517
     foreach ($x as $h) {
518
-        $a = $attrs?$attrs[$i]:"";
518
+        $a = $attrs ? $attrs[$i] : "";
519 519
         echo "<td $a>$h</td>\n";
520 520
         $i++;
521 521
     }
522 522
     echo "</tr>\n";
523 523
 }
524 524
 
525
-define ('ALIGN_RIGHT', 'style="text-align:right;"');
525
+define('ALIGN_RIGHT', 'style="text-align:right;"');
526 526
 
527
-function row_heading_array($x, $attrs=null, $class='bg-primary') {
527
+function row_heading_array($x, $attrs = null, $class = 'bg-primary') {
528 528
     echo "<tr>";
529 529
     $i = 0;
530 530
     foreach ($x as $h) {
531
-        $a = $attrs?$attrs[$i]:"";
531
+        $a = $attrs ? $attrs[$i] : "";
532 532
         echo "<th $a class=\"$class\">$h</th>";
533 533
         $i++;
534 534
     }
535 535
     echo "</tr>\n";
536 536
 }
537 537
 
538
-function row_heading($x, $class='bg-primary') {
538
+function row_heading($x, $class = 'bg-primary') {
539 539
     echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr>
540 540
         ', $class, $x
541 541
     );
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 // If $ellipsis is true, then an ellipsis is added to any sentence which
596 596
 // is cut short.
597 597
 
598
-function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) {
598
+function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) {
599 599
     $words = explode($delimiter, $sentence);
600 600
     $total_chars = 0;
601 601
     $trunc = false;
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 
679 679
 // returns null if the arg is optional and missing
680 680
 //
681
-function get_int($name, $optional=false) {
682
-    $x=null;
681
+function get_int($name, $optional = false) {
682
+    $x = null;
683 683
     if (isset($_GET[$name])) $x = $_GET[$name];
684 684
     if (!is_numeric($x)) {
685 685
         if ($optional) {
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
 // returns null if the arg is optional and missing
700 700
 //
701
-function post_num($name, $optional=false) {
701
+function post_num($name, $optional = false) {
702 702
     $x = null;
703 703
     if (isset($_POST[$name])) $x = $_POST[$name];
704 704
     if (!is_numeric($x)) {
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 
714 714
 // returns null if the arg is optional and missing
715 715
 //
716
-function post_int($name, $optional=false) {
716
+function post_int($name, $optional = false) {
717 717
     $x = post_num($name, $optional);
718 718
     if (is_null($x)) return null;
719 719
     $y = (int)$x;
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
     }
732 732
 }
733 733
 
734
-function get_str($name, $optional=false) {
734
+function get_str($name, $optional = false) {
735 735
     if (isset($_GET[$name])) {
736 736
         $x = $_GET[$name];
737 737
     } else {
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
     return undo_magic_quotes($x);
744 744
 }
745 745
 
746
-function post_str($name, $optional=false) {
746
+function post_str($name, $optional = false) {
747 747
     if (isset($_POST[$name])) {
748 748
         $x = $_POST[$name];
749 749
     } else {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
     return undo_magic_quotes($x);
756 756
 }
757 757
 
758
-function post_arr($name, $optional=false) {
758
+function post_arr($name, $optional = false) {
759 759
     if (isset($_POST[$name]) && is_array($_POST[$name])) {
760 760
         $x = $_POST[$name];
761 761
     } else {
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
     // the mb_* functions are not included by default
772 772
     // return (mb_detect_encoding($passwd) -= 'ASCII');
773 773
 
774
-    for ($i=0; $i<strlen($str); $i++) {
774
+    for ($i = 0; $i < strlen($str); $i++) {
775 775
         $c = ord(substr($str, $i));
776 776
         if ($c < 32 || $c > 127) return false;
777 777
     }
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
     $number = str_replace(',', '.', $number); // replace the german decimal separator
796 796
     // if no value was entered and this is ok
797 797
     //
798
-    if ($number=='' && !$low) return true;
798
+    if ($number == '' && !$low) return true;
799 799
 
800 800
     // the supplied value contains alphabetic characters
801 801
     //
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 
813 813
 // Generate a "select" element from an array of values
814 814
 //
815
-function select_from_array($name, $array, $selection=null, $width=240) {
815
+function select_from_array($name, $array, $selection = null, $width = 240) {
816 816
     $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"';
817 817
 
818 818
     foreach ($array as $key => $value) {
@@ -837,12 +837,12 @@  discard block
 block discarded – undo
837 837
     return $str;
838 838
 }
839 839
 
840
-function strip_bbcode($string){
841
-    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string);
840
+function strip_bbcode($string) {
841
+    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string);
842 842
 }
843 843
 
844 844
 function current_url() {
845
-    $url = is_https()?'https':'http';
845
+    $url = is_https() ? 'https' : 'http';
846 846
     $url .= "://";
847 847
     $url .= $_SERVER['SERVER_NAME'];
848 848
     $url .= ":".$_SERVER['SERVER_PORT'];
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 // the colors for bootstrap's btn-success are almost illegible;
861 861
 // the green is too light.  Use a darker green.
862 862
 //
863
-function button_style($color='green', $font_size=null) {
863
+function button_style($color = 'green', $font_size = null) {
864 864
     $fs = '';
865 865
     if ($font_size) {
866 866
         $fs = sprintf('; font-size:%dpx', $font_size);
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 // class: class of the button, e.g. btn
880 880
 // extra: Additional text in href tag
881 881
 //
882
-function button_text($url, $text, $desc=null, $class=null, $extra='') {
882
+function button_text($url, $text, $desc = null, $class = null, $extra = '') {
883 883
     if (!$desc) {
884 884
         $desc = $text;
885 885
     }
@@ -894,23 +894,23 @@  discard block
 block discarded – undo
894 894
     );
895 895
 }
896 896
 
897
-function button_text_small($url, $text, $desc=null) {
897
+function button_text_small($url, $text, $desc = null) {
898 898
     return button_text($url, $text, $desc, "btn btn-xs", button_style());
899 899
 }
900 900
 
901
-function show_button($url, $text, $desc=null, $class=null, $extra=null) {
901
+function show_button($url, $text, $desc = null, $class = null, $extra = null) {
902 902
     echo button_text($url, $text, $desc, $class, $extra);
903 903
 }
904 904
 
905 905
 // for places with a bunch of buttons, like forum posts
906 906
 //
907
-function show_button_small($url, $text, $desc=null) {
907
+function show_button_small($url, $text, $desc = null) {
908 908
     echo button_text_small($url, $text, $desc);
909 909
 }
910 910
 
911 911
 // used for showing icons
912 912
 //
913
-function show_image($src, $title, $alt, $height=null) {
913
+function show_image($src, $title, $alt, $height = null) {
914 914
     $h = "";
915 915
     if ($height) {
916 916
         $h = "height=\"$height\"";
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 // tries instead to connect to <replica_db_host> if tag exists.
948 948
 // DEPRECATED - use boinc_db.inc
949 949
 //
950
-function db_init($try_replica=false) {
950
+function db_init($try_replica = false) {
951 951
     check_web_stopped();
952 952
     $retval = db_init_aux($try_replica);
953 953
     if ($retval == 1) {
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 // Check this to avoid XSS vulnerability
1024 1024
 //
1025 1025
 function sanitize_sort_by($x) {
1026
-    switch($x) {
1026
+    switch ($x) {
1027 1027
     case 'expavg_credit':
1028 1028
     case 'total_credit':
1029 1029
         return;
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 }
1042 1042
 
1043 1043
 function do_download($path) {
1044
-    $name=basename($path);
1044
+    $name = basename($path);
1045 1045
     header('Content-Description: File Transfer');
1046 1046
     header('Content-Type: application/octet-stream');
1047 1047
     header('Content-Disposition: attachment; filename='.$name);
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
     header('Expires: 0');
1050 1050
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1051 1051
     header('Pragma: public');
1052
-    header('Content-Length: ' . filesize($path));
1052
+    header('Content-Length: '.filesize($path));
1053 1053
     flush();
1054 1054
     readfile($path);
1055 1055
 }
@@ -1098,10 +1098,10 @@  discard block
 block discarded – undo
1098 1098
 // Otherwise return 0.
1099 1099
 // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)"
1100 1100
 //
1101
-function boinc_client_version(){
1101
+function boinc_client_version() {
1102 1102
     if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0;
1103 1103
     $x = $_SERVER['HTTP_USER_AGENT'];
1104
-    $e =  "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1104
+    $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1105 1105
     if (preg_match($e, $x, $matches)) {
1106 1106
         return $matches[1]*10000 + $matches[2]*100 + $matches[3];
1107 1107
     }
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
     $rem_name = $name."_remaining";
1131 1131
     return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\"
1132 1132
         onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea>
1133
-        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1133
+        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1134 1134
     ;
1135 1135
 }
1136 1136
 
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 // use the following around text with long lines,
1161 1161
 // to limit the width and make it more readable.
1162 1162
 //
1163
-function text_start($width=640) {
1163
+function text_start($width = 640) {
1164 1164
     echo sprintf("<div style=\"max-width: %dpx;\">\n", $width);
1165 1165
 }
1166 1166
 function text_end() {
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 }
1187 1187
 
1188 1188
 function cert_filename() {
1189
-    return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php";
1189
+    return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php";
1190 1190
 }
1191 1191
 
1192 1192
 // if user hasn't validated their email addr, tell them to
Please login to merge, or discard this patch.
html/inc/util_basic.inc 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
     return file_exists("$d/stop_sched");
58 58
 }
59 59
 
60
-function xml_error($num=-1, $msg=null, $file=null, $line=null) {
60
+function xml_error($num = -1, $msg = null, $file = null, $line = null) {
61 61
     global $xml_outer_tag;
62 62
     if (!$msg) {
63
-        switch($num) {
63
+        switch ($num) {
64 64
         case -112: $msg = "Invalid XML"; break;
65 65
         case -136: $msg = "Not found"; break;
66 66
         case -137: $msg = "Name or email address is not unique"; break;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 // If it's a single-tag element, and it's present, just return the tag
106 106
 //
107 107
 function parse_element($xml, $tag) {
108
-    $closetag = "</" . substr($tag,1);
108
+    $closetag = "</".substr($tag, 1);
109 109
     $x = strstr($xml, $tag);
110 110
     if ($x) {
111 111
         if (strstr($tag, "/>")) return $tag;
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 
122 122
 function parse_next_element($xml, $tag, &$cursor) {
123 123
     $element = null;
124
-    $closetag = "</" . substr($tag,1);
125
-    $pos = substr($xml,$cursor);
124
+    $closetag = "</".substr($tag, 1);
125
+    $pos = substr($xml, $cursor);
126 126
     $x = strstr($pos, $tag);
127 127
     if ($x) {
128 128
         if (strstr($tag, "/>")) return $tag;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 function time_str($x) {
206 206
     if ($x == 0) return "---";
207
-    return gmdate('j M Y, G:i:s', (int)$x) . " UTC";
207
+    return gmdate('j M Y, G:i:s', (int)$x)." UTC";
208 208
 }
209 209
 
210 210
 function local_time_str($x) {
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
 // convert time interval in seconds to a string of the form
220 220
 // 'D days h hours m min s sec'.
221 221
 
222
-function time_diff($x, $res=3) {
222
+function time_diff($x, $res = 3) {
223 223
     $x = (int)$x;
224 224
     $days    = (int)($x/86400);
225
-    $hours   = (int)(($x-$days*86400)/3600);
226
-    $minutes = (int)(($x-$days*86400-$hours*3600)/60);
227
-    $seconds = $x % 60;
225
+    $hours   = (int)(($x - $days*86400)/3600);
226
+    $minutes = (int)(($x - $days*86400 - $hours*3600)/60);
227
+    $seconds = $x%60;
228 228
 
229 229
     $s = "";
230 230
     if ($days) {
231 231
         $s .= "$days ".tra("days")." ";
232 232
     }
233
-    if ($res>0 && ($hours || strlen($s))) {
233
+    if ($res > 0 && ($hours || strlen($s))) {
234 234
         $s .= "$hours ".tra("hours")." ";
235 235
     }
236
-    if ($res>1 && ($minutes || strlen($s))) {
236
+    if ($res > 1 && ($minutes || strlen($s))) {
237 237
         $s .= "$minutes ".tra("min")." ";
238 238
     }
239
-    if ($res>2) {
239
+    if ($res > 2) {
240 240
         $s .= "$seconds ".tra("sec")." ";
241 241
     }
242 242
     return $s;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 // ALSO: allow spaces.
270 270
 //
271 271
 function is_valid_filename($x) {
272
-    if (strlen($x)>255) return false;
272
+    if (strlen($x) > 255) return false;
273 273
     // \w means A-Za-z0-9_
274 274
     return preg_match('/^[\w\-. ]+$/', $x);
275 275
 }
Please login to merge, or discard this patch.
html/ops/clean_cache.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
 set_time_limit(0);
27 27
 
28
-function main(){
28
+function main() {
29 29
     echo "------- Starting at ".time_str(time())."-------\n";
30 30
 
31 31
     echo sprintf("max cache usage: %s\n", size_string(MAX_CACHE_USAGE));
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
 set_time_limit(0);
27 27
 
28
-function main(){
28
+function main() {
29 29
     echo "------- Starting at ".time_str(time())."-------\n";
30 30
 
31 31
     echo sprintf("max cache usage: %s\n", size_string(MAX_CACHE_USAGE));
Please login to merge, or discard this patch.