Passed
Push — dpa_submit21 ( e4087a...141260 )
by David
08:42
created
html/inc/forum.inc 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 require_once("../inc/text_transform.inc");
25 25
 
26 26
 define('THREADS_PER_PAGE', 50);
27
-define('FORUM_LH_PCT', '25%');      // width of LH column
27
+define('FORUM_LH_PCT', '25%'); // width of LH column
28 28
 
29 29
 $forum_error = "";
30 30
     // for functions that return null on error,
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 define('THREAD_SOLVED', 1);
56 56
 
57 57
 define('AVATAR_WIDTH', 100);
58
-define('AVATAR_HEIGHT',100);
58
+define('AVATAR_HEIGHT', 100);
59 59
 
60 60
 define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days
61 61
 define('ST_NEW', 'New member');
@@ -80,24 +80,24 @@  discard block
 block discarded – undo
80 80
 define('IMAGE_HIDDEN', 'img/hidden.png');
81 81
 define('IMAGE_STICKY_LOCKED', 'img/sticky_locked_post.png');
82 82
 define('IMAGE_POST', 'img/post.png');
83
-define('NEW_IMAGE_HEIGHT','15');
83
+define('NEW_IMAGE_HEIGHT', '15');
84 84
 define('EMPHASIZE_IMAGE', 'img/emphasized_post.png');
85
-define('EMPHASIZE_IMAGE_HEIGHT','15');
85
+define('EMPHASIZE_IMAGE_HEIGHT', '15');
86 86
 define('FILTER_IMAGE', 'img/filtered_post.png');
87
-define('FILTER_IMAGE_HEIGHT','15');
87
+define('FILTER_IMAGE_HEIGHT', '15');
88 88
 define('RATE_POSITIVE_IMAGE', 'img/rate_positive.png');
89
-define('RATE_POSITIVE_IMAGE_HEIGHT','9');
89
+define('RATE_POSITIVE_IMAGE_HEIGHT', '9');
90 90
 define('RATE_NEGATIVE_IMAGE', 'img/rate_negative.png');
91
-define('RATE_NEGATIVE_IMAGE_HEIGHT','9');
91
+define('RATE_NEGATIVE_IMAGE_HEIGHT', '9');
92 92
 define('REPORT_POST_IMAGE', 'img/report_post.png');
93
-define('REPORT_POST_IMAGE_HEIGHT','9');
93
+define('REPORT_POST_IMAGE_HEIGHT', '9');
94 94
 
95 95
 define('SOLUTION', tra('This answered my question'));
96 96
 define('SUFFERER', tra('I also have this question'));
97 97
 define('OFF_TOPIC', tra('Off-topic'));
98 98
 
99
-define ('DEFAULT_LOW_RATING_THRESHOLD', -25);
100
-define ('DEFAULT_HIGH_RATING_THRESHOLD', 5);
99
+define('DEFAULT_LOW_RATING_THRESHOLD', -25);
100
+define('DEFAULT_HIGH_RATING_THRESHOLD', 5);
101 101
 
102 102
 // special user attributes
103 103
 //
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
 
176 176
 // return forum/thread title, with links.
177 177
 //
178
-function forum_title($category, $forum, $thread, $link_thread=false) {
178
+function forum_title($category, $forum, $thread, $link_thread = false) {
179 179
     if ($category) {
180 180
         $is_helpdesk = $category->is_helpdesk;
181 181
     } else {
182 182
         $is_helpdesk = false;
183 183
     }
184 184
 
185
-    $where = $is_helpdesk?tra("Questions and Answers"):tra("Message boards");
186
-    $top_url = $is_helpdesk?"forum_help_desk.php":"forum_index.php";
185
+    $where = $is_helpdesk ?tra("Questions and Answers") : tra("Message boards");
186
+    $top_url = $is_helpdesk ? "forum_help_desk.php" : "forum_index.php";
187 187
 
188 188
     $x = '';
189 189
     if (!$forum && !$thread) {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     return $x;
218 218
 }
219 219
 
220
-function team_forum_title($forum, $thread=null, $link_thread=false) {
220
+function team_forum_title($forum, $thread = null, $link_thread = false) {
221 221
     $team = BoincTeam::lookup_id($forum->category);
222 222
     $x = sprintf('<a href="forum_index.php">%s</a> :',
223 223
         tra("Message boards")
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
 }
252 252
 
253 253
 function page_link($url, $page_num, $items_per_page, $text) {
254
-    return " <a href=\"$url&amp;start=" . $page_num*$items_per_page . "\">$text</a> ";
254
+    return " <a href=\"$url&amp;start=".$page_num*$items_per_page."\">$text</a> ";
255 255
 }
256 256
 
257 257
 // return a string for navigating pages
258 258
 //
259
-function page_links($url, $nitems, $items_per_page, $start){
259
+function page_links($url, $nitems, $items_per_page, $start) {
260 260
     // How many pages to potentially show before and after this one:
261 261
     $preshow = 3;
262 262
     $postshow = 3;
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
     $x = "";
265 265
 
266 266
     if ($nitems <= $items_per_page) return "";
267
-    $npages = ceil($nitems / $items_per_page);
268
-    $curpage = ceil($start / $items_per_page);
267
+    $npages = ceil($nitems/$items_per_page);
268
+    $curpage = ceil($start/$items_per_page);
269 269
 
270 270
     // If this is not the first page, display "previous"
271 271
     //
272
-    if ($curpage > 0){
272
+    if ($curpage > 0) {
273 273
         $x .= page_link(
274
-            $url, $curpage-1, $items_per_page,
274
+            $url, $curpage - 1, $items_per_page,
275 275
             tra("Previous")." &middot; "
276 276
         );
277 277
     }
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
     }
287 287
     // Display a list of pages surrounding this one
288 288
     //
289
-    for ($i=$curpage-$preshow; $i<=$curpage+$postshow; $i++){
290
-        $page_str = (string)($i+1);
289
+    for ($i = $curpage - $preshow; $i <= $curpage + $postshow; $i++) {
290
+        $page_str = (string)($i + 1);
291 291
         if ($i < 0) continue;
292 292
         if ($i >= $npages) break;
293 293
 
@@ -296,20 +296,20 @@  discard block
 block discarded – undo
296 296
         } else {
297 297
             $x .= page_link($url, $i, $items_per_page, $page_str);
298 298
         }
299
-        if ($i == $npages-1) break;
300
-        if ($i == $curpage+$postshow) break;
299
+        if ($i == $npages - 1) break;
300
+        if ($i == $curpage + $postshow) break;
301 301
         $x .= " &middot; ";
302 302
     }
303 303
 
304
-    if ($curpage + $postshow < $npages-1) {
304
+    if ($curpage + $postshow < $npages - 1) {
305 305
         $x .= " . . . ";
306
-        $x .= page_link($url, $npages-1, $items_per_page, $npages);
306
+        $x .= page_link($url, $npages - 1, $items_per_page, $npages);
307 307
     }
308 308
     // If there is a next page
309 309
     //
310
-    if ($curpage < $npages-1){
310
+    if ($curpage < $npages - 1) {
311 311
         $x .= page_link(
312
-            $url, $curpage+1, $items_per_page,
312
+            $url, $curpage + 1, $items_per_page,
313 313
             " &middot; ".tra("Next")
314 314
         );
315 315
     }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 function cleanup_title($title) {
331 331
     $x = sanitize_tags(bb2html($title));
332 332
     $x = trim($x);
333
-    if (strlen($x)==0) return "(no title)";
333
+    if (strlen($x) == 0) return "(no title)";
334 334
     else return $x;
335 335
 }
336 336
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             $i = 0;
393 393
             foreach ($posts as $post) {
394 394
                 if ($post->id == $postid) {
395
-                    $start = $i - ($i % $num_to_show);
395
+                    $start = $i - ($i%$num_to_show);
396 396
                     $jump_to_post = $post;
397 397
                     break;
398 398
                 }
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
             // if jump to post, figure out what page to show
420 420
             //
421 421
             if ($jump_to_post) {
422
-                $start = $ibest - ($ibest % $num_to_show);
422
+                $start = $ibest - ($ibest%$num_to_show);
423 423
             } else {
424 424
                 $start = $default_start;
425 425
             }
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 // Generates a table row with two cells: author and message
528 528
 //
529 529
 function show_post(
530
-    $post, $thread, $forum, $logged_in_user, $start=0,
531
-    $latest_viewed=0, $controls=FORUM_CONTROLS, $filter=true
530
+    $post, $thread, $forum, $logged_in_user, $start = 0,
531
+    $latest_viewed = 0, $controls = FORUM_CONTROLS, $filter = true
532 532
 ) {
533 533
     global $country_to_iso3166_2;
534 534
 
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 
537 537
     // If the user no longer exists, skip the post
538 538
     //
539
-    if (!$user){
539
+    if (!$user) {
540 540
         return;
541 541
     }
542 542
 
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
     // check whether the poster is on the list of people to ignore
558 558
     //
559 559
     $ignore_poster = false;
560
-    if ($logged_in_user){
560
+    if ($logged_in_user) {
561 561
         $tokens = url_tokens($logged_in_user->authenticator);
562
-        if (is_ignoring($logged_in_user, $user)){
562
+        if (is_ignoring($logged_in_user, $user)) {
563 563
             $ignore_poster = true;
564 564
         }
565 565
     }
@@ -573,8 +573,8 @@  discard block
 block discarded – undo
573 573
             if (is_moderator($logged_in_user, $forum)) {
574 574
                 $can_edit = true;
575 575
             } else if (can_reply($thread, $forum, $logged_in_user)) {
576
-                $time_limit = $post->timestamp+MAXIMUM_EDIT_TIME;
577
-                $can_edit = time()<$time_limit;
576
+                $time_limit = $post->timestamp + MAXIMUM_EDIT_TIME;
577
+                $can_edit = time() < $time_limit;
578 578
             } else {
579 579
                 $can_edit = false;
580 580
             }
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
     // Print the special user lines, if any
585 585
     //
586 586
     global $special_user_bitfield;
587
-    $fstatus="";
587
+    $fstatus = "";
588 588
     $keys = array_keys($special_user_bitfield);
589 589
     $is_posted_by_special = false;
590
-    for ($i=0; $i<sizeof($special_user_bitfield);$i++) {
590
+    for ($i = 0; $i < sizeof($special_user_bitfield); $i++) {
591 591
         if ($user->prefs && $user->prefs->privilege($keys[$i])) {
592 592
             $fstatus .= "<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>";
593 593
             $is_posted_by_special = true;
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
 
601 601
     // Highlight special users if set in prefs;
602 602
     //
603
-    if ($logged_in_user && $logged_in_user->prefs){
603
+    if ($logged_in_user && $logged_in_user->prefs) {
604 604
         $highlight = $logged_in_user->prefs->highlight_special && $is_posted_by_special;
605 605
     } else {
606 606
         $highlight = $is_posted_by_special;
607 607
     }
608
-    $class = $highlight?' style="border-left: 5px solid LightGreen" ':'';
608
+    $class = $highlight ? ' style="border-left: 5px solid LightGreen" ' : '';
609 609
 
610 610
     // row and start of author col
611 611
     //
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
 
618 618
     echo user_links($user, 0, 30);
619 619
     echo "<br>";
620
-    if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."<br>";
620
+    if ($user->create_time > time() - ST_NEW_TIME) $fstatus .= ST_NEW."<br>";
621 621
     echo "<span class=\"small\">";
622 622
     if ($fstatus) echo "$fstatus";
623 623
 
624
-    if (!$filter || !$ignore_poster){
625
-        if ($user->prefs && $user->prefs->avatar!="" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars==false))) {
624
+    if (!$filter || !$ignore_poster) {
625
+        if ($user->prefs && $user->prefs->avatar != "" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars == false))) {
626 626
             echo "<img width=\"".AVATAR_WIDTH."\" height=\"".AVATAR_HEIGHT."\" src=\"".avatar_url($user->prefs->avatar)."\" alt=\"Avatar\"><br>";
627 627
         }
628 628
     }
@@ -630,14 +630,14 @@  discard block
 block discarded – undo
630 630
 
631 631
     $url = "pm.php?action=new&amp;userid=".$user->id;
632 632
     $name = $user->name;
633
-    show_button_small($url, tra("Send message"), tra("Send %1 a private message",$name));
633
+    show_button_small($url, tra("Send message"), tra("Send %1 a private message", $name));
634 634
     echo '<br>'.tra("Joined: %1", gmdate('j M y', $user->create_time)), "<br>";
635 635
 
636 636
     if (!isset($user->nposts)) {
637 637
         $user->nposts = BoincPost::count("user=$user->id");
638 638
     }
639 639
 
640
-    if (function_exists('project_forum_user_info')){
640
+    if (function_exists('project_forum_user_info')) {
641 641
         project_forum_user_info($user);
642 642
     } else {
643 643
         echo tra("Posts: %1", $user->nposts)."<br>";
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
         //
647 647
         //echo "ID: ".$user->id."<br>";
648 648
         if (!NO_COMPUTING) {
649
-            echo tra("Credit: %1", number_format($user->total_credit)) ."<br>";
650
-            echo tra("RAC: %1",    number_format($user->expavg_credit))."<br>";
649
+            echo tra("Credit: %1", number_format($user->total_credit))."<br>";
650
+            echo tra("RAC: %1", number_format($user->expavg_credit))."<br>";
651 651
         }
652 652
 
653 653
         // to use this feature:
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         echo "<form action=\"forum_rate.php?post=", $post->id, "\" method=\"post\">";
677 677
     }
678 678
 
679
-    if ($logged_in_user && $post->timestamp > $latest_viewed){
679
+    if ($logged_in_user && $post->timestamp > $latest_viewed) {
680 680
         show_image(NEW_IMAGE, tra("You haven't read this message yet"), tra("Unread"), NEW_IMAGE_HEIGHT);
681 681
     }
682 682
 
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
     if ($post->modified) {
697 697
         echo "<br>".tra("Last modified: %1", pretty_time_Str($post->modified));
698 698
     }
699
-    if ($ignore_poster && $filter){
700
-        echo "<br>" .tra(
699
+    if ($ignore_poster && $filter) {
700
+        echo "<br>".tra(
701 701
             "This post is hidden because the sender is on your 'ignore' list.  Click %1 here %2 to view hidden posts",
702 702
             "<a href=\"?id=".$thread->id."&amp;filter=false&amp;start=$start#".$post->id."\">",
703 703
             "</a>"
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
         <p>
711 711
     ";
712 712
 
713
-    if (!$filter || !$ignore_poster){
713
+    if (!$filter || !$ignore_poster) {
714 714
         $posttext = $post->content;
715 715
 
716 716
         // If the creator of this post has a signature and
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
         // user has signatures enabled: show it
719 719
         //
720 720
         $posttext = output_transform($posttext, $options);
721
-        if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)){
721
+        if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)) {
722 722
             $sig = output_transform($user->prefs->signature, $options);
723 723
             $posttext .= "<hr>$sig\n";
724 724
         }
@@ -752,10 +752,10 @@  discard block
 block discarded – undo
752 752
         }
753 753
         if (($controls == FORUM_CONTROLS) && (can_reply($thread, $forum, $logged_in_user))) {
754 754
             echo "&nbsp;&nbsp;&nbsp;&nbsp;";
755
-            $url = "forum_reply.php?thread=" . $thread->id . "&amp;post=" . $post->id . "&amp;no_quote=1#input";
755
+            $url = "forum_reply.php?thread=".$thread->id."&amp;post=".$post->id."&amp;no_quote=1#input";
756 756
             // "Reply" is used as a verb
757 757
             show_button($url, tra("Reply"), tra("Post a reply to this message"));
758
-            $url = "forum_reply.php?thread=" . $thread->id . "&amp;post=" . $post->id . "#input";
758
+            $url = "forum_reply.php?thread=".$thread->id."&amp;post=".$post->id."#input";
759 759
             // "Quote" is used as a verb
760 760
             show_button($url, tra("Quote"), tra("Post a reply by quoting this message"));
761 761
         }
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
     $content = output_transform($post->content, $options);
778 778
     $when = time_diff_str($post->timestamp, time());
779 779
     $user = BoincUser::lookup_id($post->user);
780
-    if (!$user){
780
+    if (!$user) {
781 781
         return;
782 782
     }
783 783
 
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
     switch ($forum->parent_type) {
792 792
     case 0:
793 793
         $category = BoincCategory::lookup_id($forum->category);
794
-        $title= forum_title($category, $forum, $thread, true);
794
+        $title = forum_title($category, $forum, $thread, true);
795 795
         break;
796 796
     case 1:
797
-        $title= team_forum_title($forum);
797
+        $title = team_forum_title($forum);
798 798
         break;
799 799
     }
800 800
     row_array([
@@ -833,9 +833,9 @@  discard block
 block discarded – undo
833 833
 function post_rules() {
834 834
     if (defined('FORUM_RULES')) return FORUM_RULES;
835 835
     if (function_exists("project_forum_post_rules")) {
836
-      $project_rules=project_forum_post_rules();
836
+      $project_rules = project_forum_post_rules();
837 837
     } else {
838
-      $project_rules="";
838
+      $project_rules = "";
839 839
     }
840 840
     return sprintf("
841 841
         <ul>
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
     );
865 865
 }
866 866
 
867
-function post_warning($forum=null) {
867
+function post_warning($forum = null) {
868 868
     $x = '<p><div style="text-align:left">';
869 869
 
870 870
     // let projects add extra instructions in specific forums,
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
     $content = substr($content, 0, 64000);
951 951
     $content = BoincDb::escape_string($content);
952 952
     $now = time();
953
-    $sig = $signature?1:0;
953
+    $sig = $signature ? 1 : 0;
954 954
     $id = BoincPost::insert("(thread, user, timestamp, content, modified, parent_post, score, votes, signature, hidden) values ($thread->id, $user->id, $now, '$content', 0, $parent_id, 0, 0, $sig, 0)");
955 955
     if (!$id) {
956 956
         $forum_error = "Failed to add post to DB.";
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 //
971 971
 function update_thread_timestamp($thread) {
972 972
     $posts = BoincPost::enum("thread=$thread->id and hidden=0 order by timestamp desc limit 1");
973
-    if (count($posts)>0) {
973
+    if (count($posts) > 0) {
974 974
         $post = $posts[0];
975 975
         $thread->update("timestamp=$post->timestamp");
976 976
     }
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 
979 979
 function update_forum_timestamp($forum) {
980 980
     $threads = BoincThread::enum("forum=$forum->id and hidden=0 order by timestamp desc limit 1");
981
-    if (count($threads)>0) {
981
+    if (count($threads) > 0) {
982 982
         $thread = $threads[0];
983 983
         $forum->update("timestamp=$thread->timestamp");
984 984
     }
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
     if (is_news_forum($forum) && !$export) {
1002 1002
         $status = 1;
1003 1003
     }
1004
-    $id  = BoincThread::insert("(forum, owner, status, title, timestamp, views, replies, activity, sufferers, score, votes, create_time, hidden, sticky, locked) values ($forum->id, $user->id, $status, '$title', $now, 0, -1, 0, 0, 0, 0, $now, 0, 0, 0)");
1004
+    $id = BoincThread::insert("(forum, owner, status, title, timestamp, views, replies, activity, sufferers, score, votes, create_time, hidden, sticky, locked) values ($forum->id, $user->id, $status, '$title', $now, 0, -1, 0, 0, 0, 0, $now, 0, 0, 0)");
1005 1005
     if (!$id) {
1006 1006
         $forum_error = "Failed to add thread to DB.";
1007 1007
         return null;
@@ -1130,22 +1130,22 @@  discard block
 block discarded – undo
1130 1130
 // $sticky - bool (not directly passed to SQL)
1131 1131
 //
1132 1132
 function get_forum_threads(
1133
-    $forumID, $start=-1, $nRec=-1, $sort_style=MODIFIED_NEW,
1133
+    $forumID, $start = -1, $nRec = -1, $sort_style = MODIFIED_NEW,
1134 1134
     $show_hidden = 0, $sticky = 1
1135 1135
 ) {
1136 1136
     //if (! (is_numeric($forumID) && is_numeric($min) && is_numeric($nRec))) {
1137 1137
     //    return NULL;  // Something is wrong here.
1138 1138
     //}
1139 1139
 
1140
-    $sql = 'forum = ' . $forumID ;
1140
+    $sql = 'forum = '.$forumID;
1141 1141
     $stickysql = "";
1142
-    if ($sticky){
1142
+    if ($sticky) {
1143 1143
         $stickysql = "sticky DESC, ";
1144 1144
     }
1145 1145
     if (!$show_hidden) {
1146 1146
         $sql .= ' AND hidden = 0';
1147 1147
     }
1148
-    switch($sort_style) {
1148
+    switch ($sort_style) {
1149 1149
     case MODIFIED_NEW:
1150 1150
         $sql .= ' ORDER BY '.$stickysql.'timestamp DESC';
1151 1151
         break;
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
     if (!$show_hidden) {
1199 1199
         $sql .= ' AND hidden = 0';
1200 1200
     }
1201
-    switch($sort_style) {
1201
+    switch ($sort_style) {
1202 1202
     case CREATE_TIME_NEW:
1203 1203
         $sql .= ' ORDER BY timestamp desc';
1204 1204
         break;
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 //
1221 1221
 function show_post_moderation_links(
1222 1222
     $config, $logged_in_user, $post, $forum, $tokens
1223
-){
1223
+) {
1224 1224
     $moderators_allowed_to_ban = parse_bool($config, "moderators_allowed_to_ban");
1225 1225
     $moderators_vote_to_ban = parse_bool($config, "moderators_vote_to_ban");
1226 1226
 
@@ -1283,9 +1283,9 @@  discard block
 block discarded – undo
1283 1283
 //
1284 1284
 function user_can_create_thread($user, $forum) {
1285 1285
     if ($forum->is_dev_blog) {
1286
-        return is_admin($user)?'yes':'no';
1286
+        return is_admin($user) ? 'yes' : 'no';
1287 1287
     }
1288
-    return $user ?'yes':'login';
1288
+    return $user ? 'yes' : 'login';
1289 1289
 }
1290 1290
 
1291 1291
 function check_post_access($user, $forum) {
@@ -1311,14 +1311,14 @@  discard block
 block discarded – undo
1311 1311
     // We do not tell the (ab)user how much this is -
1312 1312
     // no need to make it easy for them to break the system.
1313 1313
     //
1314
-    if ($user->total_credit<$forum->post_min_total_credit || $user->expavg_credit<$forum->post_min_expavg_credit) {
1314
+    if ($user->total_credit < $forum->post_min_total_credit || $user->expavg_credit < $forum->post_min_expavg_credit) {
1315 1315
         error_page(tra("To create a new thread in %1 you must have a certain level of average credit. This is to protect against abuse of the system.", $forum->title));
1316 1316
     }
1317 1317
 
1318 1318
     // If the user is posting faster than forum regulations allow
1319 1319
     // Tell the user to wait a while before creating any more posts
1320 1320
     //
1321
-    if (time()-$user->prefs->last_post <$forum->post_min_interval) {
1321
+    if (time() - $user->prefs->last_post < $forum->post_min_interval) {
1322 1322
         error_page(tra("You cannot create threads right now. Please wait before trying again. This is to protect against abuse of the system."));
1323 1323
     }
1324 1324
 }
@@ -1344,10 +1344,10 @@  discard block
 block discarded – undo
1344 1344
 // - edit their posts at any time
1345 1345
 // - hide/unhide/move threads and posts
1346 1346
 
1347
-function is_moderator($user, $forum=null) {
1347
+function is_moderator($user, $forum = null) {
1348 1348
     if (!$user) return false;
1349 1349
     BoincForumPrefs::lookup($user);
1350
-    $type = $forum?$forum->parent_type:0;
1350
+    $type = $forum ? $forum->parent_type : 0;
1351 1351
     switch ($type) {
1352 1352
     case 0:
1353 1353
         if ($user->prefs->privilege(S_MODERATOR)) return true;
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
     return false;
1365 1365
 }
1366 1366
 
1367
-function thread_list_header($subscriptions=false) {
1367
+function thread_list_header($subscriptions = false) {
1368 1368
     if ($subscriptions) {
1369 1369
         $x = [
1370 1370
             tra("Thread"),
@@ -1387,13 +1387,13 @@  discard block
 block discarded – undo
1387 1387
 // show a 1-line summary of thread and its forum.
1388 1388
 // Used for search results and subscription list
1389 1389
 //
1390
-function thread_list_item($thread, $user, $subscriptions=false) {
1390
+function thread_list_item($thread, $user, $subscriptions = false) {
1391 1391
     $thread_forum = BoincForum::lookup_id($thread->forum);
1392 1392
     if (!$thread_forum) return;
1393 1393
     if (!is_forum_visible_to_user($thread_forum, $user)) return;
1394 1394
     $owner = BoincUser::lookup_id($thread->owner);
1395 1395
     if (!$owner) return;
1396
-    switch($thread_forum->parent_type) {
1396
+    switch ($thread_forum->parent_type) {
1397 1397
     case 0:
1398 1398
         $category = BoincCategory::lookup_id($thread_forum->category);
1399 1399
         $title = forum_title($category, $thread_forum, $thread, true);
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
     } else {
1415 1415
         $x = [
1416 1416
             $title,
1417
-            $thread->replies+1,
1417
+            $thread->replies + 1,
1418 1418
             user_links($owner),
1419 1419
             $thread->views,
1420 1420
             time_diff_str($thread->timestamp, time())
@@ -1451,13 +1451,13 @@  discard block
 block discarded – undo
1451 1451
 
1452 1452
 function subscribed_thread_web_line($notify) {
1453 1453
     $thread = BoincThread::lookup_id($notify->opaque);
1454
-    return tra("New posts in the thread %1","<a href=forum_thread.php?id=$thread->id>$thread->title</a>");
1454
+    return tra("New posts in the thread %1", "<a href=forum_thread.php?id=$thread->id>$thread->title</a>");
1455 1455
 }
1456 1456
 
1457 1457
 function subscribed_thread_rss($notify) {
1458 1458
     $thread = BoincThread::lookup_id($notify->opaque);
1459 1459
     $title = tra("New posts in subscribed thread");
1460
-    $msg = tra("There are new posts in the thread '%1'",$thread->title);
1460
+    $msg = tra("There are new posts in the thread '%1'", $thread->title);
1461 1461
     $url = secure_url_base()."forum_thread.php?id=$thread->id";
1462 1462
     return [$title, $msg, $url];
1463 1463
 }
@@ -1469,13 +1469,13 @@  discard block
 block discarded – undo
1469 1469
 
1470 1470
 function subscribed_forum_web_line($notify) {
1471 1471
     $forum = BoincForum::lookup_id($notify->opaque);
1472
-    return tra("New threads in the forum %1","<a href=forum_forum.php?id=$forum->id>$forum->title</a>");
1472
+    return tra("New threads in the forum %1", "<a href=forum_forum.php?id=$forum->id>$forum->title</a>");
1473 1473
 }
1474 1474
 
1475 1475
 function subscribed_forum_rss($notify) {
1476 1476
     $forum = BoincForum::lookup_id($notify->opaque);
1477 1477
     $title = tra("New posts in subscribed forum");
1478
-    $msg = tra("There are new threads in the forum '%1'",$forum->title);
1478
+    $msg = tra("There are new threads in the forum '%1'", $forum->title);
1479 1479
     $url = secure_url_base()."forum_forum.php?id=$forum->id";
1480 1480
     return [$title, $msg, $url];
1481 1481
 }
Please login to merge, or discard this patch.
html/inc/text_transform.inc 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 require_once('../inc/sanitize_html.inc');
27 27
 
28 28
 class output_options {
29
-    var $bb2html;            // BBCode as HTML? (on)
30
-    var $images_as_links;    // Images as hyperlinks? (off)
31
-    var $link_popup;        // Links in new windows? (off)
32
-    var $nl2br;                // Convert newlines to <br>'s? (on)
33
-    var $htmlitems;            // Convert special chars to HTML entities? (on)
34
-    var $htmlscrub;            // Scrub "bad" HTML tags? (off)
35
-    var $highlight_terms;// Array of terms to be highlighted (off)
29
+    var $bb2html; // BBCode as HTML? (on)
30
+    var $images_as_links; // Images as hyperlinks? (off)
31
+    var $link_popup; // Links in new windows? (off)
32
+    var $nl2br; // Convert newlines to <br>'s? (on)
33
+    var $htmlitems; // Convert special chars to HTML entities? (on)
34
+    var $htmlscrub; // Scrub "bad" HTML tags? (off)
35
+    var $highlight_terms; // Array of terms to be highlighted (off)
36 36
 
37 37
     // Constructor - set the defaults.
38 38
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $options = new output_options; // Defaults in the class definition
69 69
     }
70 70
     if ($options->htmlitems) {
71
-        $text = htmlspecialchars($text, ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE);
71
+        $text = htmlspecialchars($text, ENT_COMPAT|ENT_HTML401|ENT_SUBSTITUTE);
72 72
     }
73 73
     if (is_array($options->highlight_terms)) {
74 74
         $text = highlight_terms($text, $options->highlight_terms);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 // If $export is true, don't use BOINC CSS
105 105
 
106 106
 function substr2($s, $n1, $n2) {
107
-    return substr($s, $n1, $n2-$n1);
107
+    return substr($s, $n1, $n2 - $n1);
108 108
 }
109 109
 
110 110
 // process non-nestable constructs: [pre] and [code]
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         // but not any hacker stuff like " alert(1)
181 181
     $httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)";
182 182
     // List of allowable tags
183
-    $bbtags = array (
183
+    $bbtags = array(
184 184
         "@\[b\](.*?)\[/b\]@is",
185 185
         "@\[i\](.*?)\[/i\]@is",
186 186
         "@\[u\](.*?)\[/u\]@is",
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
     // What the above tags are turned in to
211 211
     if ($export) {
212
-        $htmltags = array (
212
+        $htmltags = array(
213 213
             "<b>\\1</b>",
214 214
             "<i>\\1</i>",
215 215
             "<u>\\1</u>",
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             "<a href=\"https://github.com/BOINC/boinc/wiki/\\1\">\\1</a>",
237 237
         );
238 238
     } else {
239
-        $htmltags = array (
239
+        $htmltags = array(
240 240
             "<b>\\1</b>",
241 241
             "<i>\\1</i>",
242 242
             "<u>\\1</u>",
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     $lasttext = "";
269 269
     $i = 0;
270 270
     // $i<1000 to prevent DoS
271
-    while ($text != $lasttext && $i<1000) {
271
+    while ($text != $lasttext && $i < 1000) {
272 272
         $lasttext = $text;
273 273
         $text = preg_replace($bbtags, $htmltags, $text);
274 274
         $i = $i + 1;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     return $text;
279 279
 }
280 280
 
281
-function bb2html($text, $export=false) {
281
+function bb2html($text, $export = false) {
282 282
     $text = replace_pre_code($text, $export);
283 283
     return bb2html_aux($text, $export);
284 284
 }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 // for example inside <pre> containers
288 288
 // The original \n was retained after the br when it was added
289 289
 //
290
-function remove_br($text){
290
+function remove_br($text) {
291 291
     return str_replace("<br />", "", $text);
292 292
 }
293 293
 
@@ -295,19 +295,19 @@  discard block
 block discarded – undo
295 295
 //
296 296
 function externalize_links($text) {
297 297
     // TODO:  Convert this to PCRE
298
-    $i=0;
299
-    $linkpos=true;
298
+    $i = 0;
299
+    $linkpos = true;
300 300
     $out = "";
301
-    while (true){
301
+    while (true) {
302 302
         // Find a link
303 303
         //
304
-        $linkpos=strpos($text, "<a ", $i);
305
-        if ($linkpos===false) break;
304
+        $linkpos = strpos($text, "<a ", $i);
305
+        if ($linkpos === false) break;
306 306
 
307 307
         // Replace with target='_new'
308 308
         //
309
-        $out .= substr($text, $i, $linkpos-$i)."<a target=\"_new\" ";
310
-        $i = $linkpos+3;
309
+        $out .= substr($text, $i, $linkpos - $i)."<a target=\"_new\" ";
310
+        $i = $linkpos + 3;
311 311
     }
312 312
     $out .= substr($text, $i);
313 313
     return $out;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 // Converts image tags to links to the images.
317 317
 //
318
-function image_as_link($text){
318
+function image_as_link($text) {
319 319
     $pattern = '@<img([\S\s]+?)src=([^>]+?)>@si';
320 320
     $replacement = '<a href=${2}>[Image link]</a>';
321 321
     return preg_replace($pattern, $replacement, $text);
Please login to merge, or discard this patch.
html/inc/db_ops.inc 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -40,22 +40,22 @@  discard block
 block discarded – undo
40 40
 // Should fix at some point.
41 41
 //
42 42
 function mysqltime_str($x) {
43
-    if(strpos($x,"-")==4) {
43
+    if (strpos($x, "-") == 4) {
44 44
         // Syntax of supplied mysql-timestamp is YYYY-MM-DD HH:MM:SS
45
-        $year = substr($x,0,4);
46
-        $month = substr($x,5,2);
47
-        $day = substr($x,8,2);
48
-        $hour = substr($x,11,2);
49
-        $minute = substr($x,14,2);
50
-        $second = substr($x,17,2);
45
+        $year = substr($x, 0, 4);
46
+        $month = substr($x, 5, 2);
47
+        $day = substr($x, 8, 2);
48
+        $hour = substr($x, 11, 2);
49
+        $minute = substr($x, 14, 2);
50
+        $second = substr($x, 17, 2);
51 51
     } else {
52 52
         // Syntax of supplied mysql-timestamp is YYYYMMDDHHMMSS
53
-        $year = substr($x,0,4);
54
-        $month = substr($x,4,2);
55
-        $day = substr($x,6,2);
56
-        $hour = substr($x,8,2);
57
-        $minute = substr($x,10,2);
58
-        $second = substr($x,12,2);
53
+        $year = substr($x, 0, 4);
54
+        $month = substr($x, 4, 2);
55
+        $day = substr($x, 6, 2);
56
+        $hour = substr($x, 8, 2);
57
+        $minute = substr($x, 10, 2);
58
+        $second = substr($x, 12, 2);
59 59
 
60 60
     }
61 61
     $time = mktime($hour, $minute, $second, $month, $day, $year);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             if (preg_match('/^MYSQLI_TYPE_(.*)/', $c, $m)) $types[$n] = $m[1];
99 99
         }
100 100
     }
101
-    return array_key_exists($type_id, $types)? strtolower($types[$type_id]) : "unknown";
101
+    return array_key_exists($type_id, $types) ? strtolower($types[$type_id]) : "unknown";
102 102
 }
103 103
 
104 104
 // print a description of $table
@@ -108,38 +108,38 @@  discard block
 block discarded – undo
108 108
     $result = $db->do_query("SELECT * from $table LIMIT 1");
109 109
     $fields = $result->field_count;
110 110
 
111
-    $avgnum=(int)($fields/$columns);
112
-    if ($avgnum*$columns<$fields) {
111
+    $avgnum = (int)($fields/$columns);
112
+    if ($avgnum*$columns < $fields) {
113 113
         $avgnum++;
114 114
     }
115 115
 
116
-    $actualcolumns=0;
117
-    while ($avgnum*$actualcolumns<$fields) {
116
+    $actualcolumns = 0;
117
+    while ($avgnum*$actualcolumns < $fields) {
118 118
         $actualcolumns++;
119 119
     }
120 120
 
121
-    if ($which>$actualcolumns) {
121
+    if ($which > $actualcolumns) {
122 122
         return 0;
123 123
     }
124 124
 
125
-    $bot=($which-1)*$avgnum;
126
-    $top=$which*$avgnum;
125
+    $bot = ($which - 1)*$avgnum;
126
+    $top = $which*$avgnum;
127 127
 
128
-    $width=100.0/$actualcolumns;
128
+    $width = 100.0/$actualcolumns;
129 129
 
130 130
     echo "<td>";
131 131
     start_table('table-striped');
132 132
     echo "<tr><th align=\"left\">NAME</th><th align=\"left\">Type</th><th align=\"left\">Bytes</th>\n";
133
-    for ($count=$bot; $count<$top; $count++) {
134
-        if ($count<$fields) {
133
+    for ($count = $bot; $count < $top; $count++) {
134
+        if ($count < $fields) {
135 135
             $x = $result->fetch_field_direct($count);
136 136
             $name = $x->name;
137 137
             $type = mysql_fieldtype_str($x->type);
138 138
             $length = $x->length;
139 139
         } else {
140
-            $name="<br/> ";
141
-            $type="<br/>";
142
-            $length="<br/>";
140
+            $name = "<br/> ";
141
+            $type = "<br/>";
142
+            $length = "<br/>";
143 143
         }
144 144
         echo "\t<tr><td><b>$name</b></td><td>$type</td><td>$length</td></tr>\n";
145 145
     }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     echo "<h2>Description of <b>$table</b> table fields:</h2>\n";
155 155
     start_table();
156 156
     echo "<tr>";
157
-    for ($i=1; $i<=$how_many_columns; $i++) {
157
+    for ($i = 1; $i <= $how_many_columns; $i++) {
158 158
         print_describe_table_onecol($table, $i, $how_many_columns);
159 159
     }
160 160
     echo "</tr>";
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 }
174 174
 
175 175
 function print_query_field() {
176
-    $currenttime=time();
177
-    $hourago=$currenttime-3600;
178
-    $dayago=$currenttime-24*3600;
179
-    $weekago=$currenttime-7*24*3600;
176
+    $currenttime = time();
177
+    $hourago = $currenttime - 3600;
178
+    $dayago = $currenttime - 24*3600;
179
+    $weekago = $currenttime - 7*24*3600;
180 180
     echo "
181 181
         <tr>
182 182
         <td align=\"right\">Additional clauses</td>
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
     }
201 201
 }
202 202
 
203
-function append_sql_query($original,$addition,$first) {
203
+function append_sql_query($original, $addition, $first) {
204 204
     if ($first == 1) {
205
-        return $original . " where " . $addition;
205
+        return $original." where ".$addition;
206 206
     } else {
207
-        return $original . " and " . $addition;
207
+        return $original." and ".$addition;
208 208
     }
209 209
 }
210 210
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
         if (isset($_GET[$name])) {
306 306
             $value = $_GET[$name];
307 307
         } else {
308
-            $value=null;
308
+            $value = null;
309 309
         }
310 310
         if (isset($_GET[$order])) {
311 311
              $order = $_GET[$order];
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
     }
347 347
 
348 348
     function get_url($base = "db_action.php") {
349
-        $s = $base . "?table=$this->table$this->urlquery";
349
+        $s = $base."?table=$this->table$this->urlquery";
350 350
         return $s;
351 351
     }
352 352
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         $this->addeq('app_version_id');
362 362
         $this->addeq('exit_status');
363 363
         if (isset($_GET['nsecs'])) {
364
-            $_GET['mod_time'] = date("YmdHis",time() - $_GET['nsecs']);
364
+            $_GET['mod_time'] = date("YmdHis", time() - $_GET['nsecs']);
365 365
         }
366 366
         $this->addgt('mod_time');
367 367
         $this->addeq_not_CHOOSE_ALL('server_state');
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
     if ($n == '0') { // intentional compare by string
383 383
         return "0";
384 384
     } else {
385
-        if(strlen($clauses)) {
385
+        if (strlen($clauses)) {
386 386
             return "<a href=\"db_action.php?table=result&query=$mq&$query&clauses=".urlencode($clauses)."&sort_by=mod_time&detail=low\">$n</a>";
387 387
         } else {
388 388
             return "<a href=\"db_action.php?table=result&query=$mq&$query&sort_by=mod_time&detail=low\">$n</a>";
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 // @return String A human readable string if error otherwise FALSE
396 396
 // @param String $stderr_out the stderr_out value to parse
397 397
 //
398
-function stderr_error_string($stderr_out){
398
+function stderr_error_string($stderr_out) {
399 399
     $y = parse_element($stderr_out, "<error_code>");
400 400
     $x = 0;
401 401
     if ($y) {
402 402
         $x = (int)$y;
403 403
     }
404
-    if (0<=$x && $x<=9) {
404
+    if (0 <= $x && $x <= 9) {
405 405
         return FALSE;
406 406
     } else {
407 407
         return "$x ".error_code_str($x);
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 }
410 410
 
411 411
 function admin_show_result_summary() {
412
-    $ntotal =0;     // TODO: how to count $result?
413
-    $nvalid = 0;    // for SUCCESS results
412
+    $ntotal = 0; // TODO: how to count $result?
413
+    $nvalid = 0; // for SUCCESS results
414 414
     $ninvalid = 0;
415 415
     $nfile_deleted = 0;
416 416
 
@@ -418,20 +418,20 @@  discard block
 block discarded – undo
418 418
     $outcome = array();
419 419
     $client_state = array();
420 420
 
421
-    for ($ss=1; $ss<6; $ss++) {
421
+    for ($ss = 1; $ss < 6; $ss++) {
422 422
         $server_state[$ss] = 0;
423 423
     }
424
-    for ($ro=0; $ro<8; $ro++) {
424
+    for ($ro = 0; $ro < 8; $ro++) {
425 425
         $outcome[$ro] = 0;
426 426
     }
427
-    for ($cs=1; $cs<7; $cs++) {
427
+    for ($cs = 1; $cs < 7; $cs++) {
428 428
         $client_state[$cs] = 0;
429 429
     }
430
-    for ($fds=0; $fds<4; $fds++) {
430
+    for ($fds = 0; $fds < 4; $fds++) {
431 431
         $delete_state[$fds] = 0;
432 432
     }
433
-    for ($vs=0; $vs<NVALIDATE_STATES; $vs++) {
434
-        $validate_state[$vs]=0;
433
+    for ($vs = 0; $vs < NVALIDATE_STATES; $vs++) {
434
+        $validate_state[$vs] = 0;
435 435
     }
436 436
 
437 437
     $_GET['table'] = 'result';
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
         //
507 507
         $delay = parse_config(get_config(), "<delete_delay_hours>");
508 508
         if ($delay) {
509
-            $start2 = $start - $delay*3600;;
509
+            $start2 = $start - $delay*3600; ;
510 510
             $main_query .= " and ((file_delete_state>1 and mod_time>FROM_UNIXTIME($start2)) or (mod_time>FROM_UNIXTIME($start)))";
511 511
         } else {
512 512
             $main_query .= " and mod_time > FROM_UNIXTIME($start)";
@@ -565,21 +565,21 @@  discard block
 block discarded – undo
565 565
 
566 566
     start_table();
567 567
     echo "<tr valign=\"top\">";
568
-    echo "<td><h2>" . link_results("$ntotal results", $urlquery, '', '') . "</h2></td>";
569
-    echo "<td><h2>" . link_results("'Over' results", $urlquery, sprintf('server_state=%d', RESULT_SERVER_STATE_OVER), '') . "</h2></td>";
570
-    echo "<td><h2>" . link_results("'Success' results", $urlquery, sprintf('outcome=%d', RESULT_OUTCOME_SUCCESS), '') . "</h2></td>";
571
-    echo "<td><h2>" . link_results("'Client error' results", $urlquery, sprintf('outcome=%d', RESULT_OUTCOME_CLIENT_ERROR), '') . "</h2></td>";
568
+    echo "<td><h2>".link_results("$ntotal results", $urlquery, '', '')."</h2></td>";
569
+    echo "<td><h2>".link_results("'Over' results", $urlquery, sprintf('server_state=%d', RESULT_SERVER_STATE_OVER), '')."</h2></td>";
570
+    echo "<td><h2>".link_results("'Success' results", $urlquery, sprintf('outcome=%d', RESULT_OUTCOME_SUCCESS), '')."</h2></td>";
571
+    echo "<td><h2>".link_results("'Client error' results", $urlquery, sprintf('outcome=%d', RESULT_OUTCOME_CLIENT_ERROR), '')."</h2></td>";
572 572
     echo "</tr>";
573 573
     echo "<tr valign=\"top\">";
574 574
     echo "<td>";
575 575
     start_table('table-striped');
576 576
     echo "<tr><th>Server state</th><th># results</th></tr>\n";
577
-    for ($ss=1; $ss<6; $ss++) {
577
+    for ($ss = 1; $ss < 6; $ss++) {
578 578
         $res = new StdClass;
579 579
         $res->server_state = $ss;
580 580
         row2(result_server_state_string($res),
581 581
             link_results(
582
-                "$server_state[$ss]",  $urlquery, "server_state=$ss", ''
582
+                "$server_state[$ss]", $urlquery, "server_state=$ss", ''
583 583
             )
584 584
         );
585 585
     }
@@ -590,12 +590,12 @@  discard block
 block discarded – undo
590 590
     start_table('table-striped');
591 591
     echo "<tr><th>Outcome</th><th># results</th></tr>\n";
592 592
 
593
-    for ($ro=0; $ro<8; $ro++) {
593
+    for ($ro = 0; $ro < 8; $ro++) {
594 594
         $res = new StdClass;
595 595
         $res->outcome = $ro;
596 596
         $res->exit_status = 0;
597 597
         c_row2(
598
-            $outcome[$ro]?outcome_color($ro):'',
598
+            $outcome[$ro] ?outcome_color($ro) : '',
599 599
             result_outcome_string($res),
600 600
             link_results("$outcome[$ro]", $urlquery, "outcome=$ro", '')
601 601
         );
@@ -606,12 +606,12 @@  discard block
 block discarded – undo
606 606
     echo "<td>";
607 607
     start_table('table-striped');
608 608
     echo "<tr><th>Validate state</th><th># results</th></tr>\n";
609
-    for ($vs=0; $vs<NVALIDATE_STATES; $vs++) {
609
+    for ($vs = 0; $vs < NVALIDATE_STATES; $vs++) {
610 610
         $res = new StdClass;
611 611
         $res->validate_state = $vs;
612 612
         $res->exit_status = 0;
613 613
         c_row2(
614
-            $validate_state[$vs]?validate_color($vs):'',
614
+            $validate_state[$vs] ?validate_color($vs) : '',
615 615
             validate_state_str($res),
616 616
             link_results(
617 617
                 "$validate_state[$vs]",
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
     start_table('table-striped');
626 626
     echo "<tr><th>File Delete state</th><th># results</th></tr>\n";
627 627
 
628
-    for ($fds=0; $fds<4; $fds++) {
628
+    for ($fds = 0; $fds < 4; $fds++) {
629 629
         row2(
630 630
             file_delete_state_str($fds),
631 631
             link_results(
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
     echo "<td>";
655 655
     start_table('table-striped');
656 656
     echo "<tr><th>Client state</th><th># results</th></tr>\n";
657
-    for ($cs=1; $cs<7; $cs++) {
657
+    for ($cs = 1; $cs < 7; $cs++) {
658 658
         $res = new StdClass;
659 659
         $res->client_state = $cs;
660 660
         $res->exit_status = 0;
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
         <select name=\"server_state\">
678 678
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
679 679
     ";
680
-    for ($i=1; $i<6; $i++) {
680
+    for ($i = 1; $i < 6; $i++) {
681 681
         $res = new StdClass;
682
-        $res->server_state=$i;
682
+        $res->server_state = $i;
683 683
         echo "<option value=\"$i\"> "."[$i]&nbsp;&nbsp;".'   '.result_server_state_string($res)."</option>\n";
684 684
     }
685 685
     echo "</select>\n";
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
         <select name=\"outcome\">
691 691
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
692 692
     ";
693
-    for ($i=0; $i<8; $i++) {
693
+    for ($i = 0; $i < 8; $i++) {
694 694
         $res = new StdClass;
695 695
         $res->outcome = $i;
696 696
         $res->exit_status = 0;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         <select name=\"validate_state\">
705 705
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
706 706
         ";
707
-    for ($vs=0; $vs<NVALIDATE_STATES; $vs++) {
707
+    for ($vs = 0; $vs < NVALIDATE_STATES; $vs++) {
708 708
         $res = new StdClass;
709 709
         $res->validate_state = $vs;
710 710
         $res->exit_status = 0;
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
         <select name=\"client_state\">
719 719
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
720 720
     ";
721
-    for ($i=0; $i<7; $i++) {
721
+    for ($i = 0; $i < 7; $i++) {
722 722
         $res = new StdClass;
723 723
         $res->client_state = $i;
724 724
         $res->exit_status = 0;
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 }
756 756
 
757 757
 function table_title($table) {
758
-    switch($table) {
758
+    switch ($table) {
759 759
     case "platform": return "Platforms";
760 760
     case "app": return "Applications";
761 761
     case "app_version": return "Application Versions";
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
     row("Created", time_str($platform->create_time));
776 776
     row("Name", $platform->name);
777 777
     row("User friendly name", $platform->user_friendly_name);
778
-    row("","<a href=\"db_action.php?table=app_version&platformid=$platform->id\">App versions for this platform</a>");
778
+    row("", "<a href=\"db_action.php?table=app_version&platformid=$platform->id\">App versions for this platform</a>");
779 779
     end_table();
780 780
 }
781 781
 
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
     row("User-friendly name", $app->user_friendly_name);
788 788
     row("Deprecated", $app->deprecated);
789 789
     row("Homogeneous redundancy", $app->homogeneous_redundancy);
790
-    row("","<a href=\"db_action.php?table=app_version&appid=$app->id\">App Versions for this application</a>");
791
-    row("","<a href=\"db_action.php?table=workunit&appid=$app->id&detail=low\">Workunits for this application</a>");
790
+    row("", "<a href=\"db_action.php?table=app_version&appid=$app->id\">App Versions for this application</a>");
791
+    row("", "<a href=\"db_action.php?table=workunit&appid=$app->id&detail=low\">Workunits for this application</a>");
792 792
     end_table();
793 793
 }
794 794
 
@@ -796,9 +796,9 @@  discard block
 block discarded – undo
796 796
     start_table();
797 797
     row("ID", $app_version->id);
798 798
     row("Created", time_str($app_version->create_time));
799
-    row("Application", "<a href=\"db_action.php?table=app&id=$app_version->appid\">" . app_name_by_id($app_version->appid) . "</a>");
799
+    row("Application", "<a href=\"db_action.php?table=app&id=$app_version->appid\">".app_name_by_id($app_version->appid)."</a>");
800 800
     row("Version num", $app_version->version_num);
801
-    row("Platform", "<a href=\"db_action.php?table=platform&id=$app_version->platformid\">" . platform_name_by_id($app_version->platformid) . "</a>" );
801
+    row("Platform", "<a href=\"db_action.php?table=platform&id=$app_version->platformid\">".platform_name_by_id($app_version->platformid)."</a>");
802 802
     row("Plan Class", $app_version->plan_class);
803 803
     row("XML doc", "<pre>".htmlspecialchars($app_version->xml_doc)."</pre>");
804 804
     row("min_core_version", $app_version->min_core_version);
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
     row("External IP address", "$host->external_ip_addr<br>");
933 933
     row("Domain name", $host->domain_name);
934 934
     $x = $host->timezone/3600;
935
-    if ($x >= 0) $x="+$x";
935
+    if ($x >= 0) $x = "+$x";
936 936
     row("Local Standard Time", "UTC $x hours");
937 937
     row("Number of CPUs", $host->p_ncpus);
938 938
     row("CPU", "$host->p_vendor $host->p_model");
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
     row("Last time modified", mysqltime_str($wu->mod_time));
988 988
     row("Name", $wu->name);
989 989
     row("XML doc", "<pre>".htmlspecialchars($wu->xml_doc)."</pre>");
990
-    row("Application", "<a href=\"db_action.php?table=app&id=$wu->appid\">" . app_name_by_id($wu->appid) . " [".$wu->appid."]</a>");
990
+    row("Application", "<a href=\"db_action.php?table=app&id=$wu->appid\">".app_name_by_id($wu->appid)." [".$wu->appid."]</a>");
991 991
     row("Application version number", $wu->app_version_num);
992 992
     row("Batch", $wu->batch);
993 993
     $x = number_format($wu->rsc_fpops_est/1e9, 2);
@@ -1000,12 +1000,12 @@  discard block
 block discarded – undo
1000 1000
     $x = $wu->rsc_disk_bound/(1024*1024);
1001 1001
     $y = number_format($x, 2);
1002 1002
     row("Max Disk Usage", "$y MB");
1003
-    row("Need validate?", ($wu->need_validate?"yes [":"no [").$wu->need_validate."]");
1003
+    row("Need validate?", ($wu->need_validate ? "yes [" : "no [").$wu->need_validate."]");
1004 1004
     row("Canonical resultid",
1005 1005
             "<a href=\"db_action.php?table=result&id=$wu->canonical_resultid\">".$wu->canonical_resultid."</a>");
1006 1006
     row("Canonical credit", $wu->canonical_credit);
1007 1007
     //row("Timeout check time", time_str($wu->timeout_check_time));
1008
-    row("Delay bound", "$wu->delay_bound" . " =  " . time_diff($wu->delay_bound) );
1008
+    row("Delay bound", "$wu->delay_bound"." =  ".time_diff($wu->delay_bound));
1009 1009
     row("Error mask", wu_error_mask_str($wu->error_mask, true));
1010 1010
     row("File delete state", file_delete_state_str($wu->file_delete_state)." [".$wu->file_delete_state."]");
1011 1011
     row("Assimilation state", assimilate_state_str($wu->assimilate_state)." [".$wu->assimilate_state."]");
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
     row("max error results", $wu->max_error_results);
1016 1016
     row("max total results", $wu->max_total_results);
1017 1017
     row("max success results", $wu->max_success_results);
1018
-    row("result template file",$wu->result_template_file);
1018
+    row("result template file", $wu->result_template_file);
1019 1019
     row("hr_class", $wu->hr_class);
1020 1020
     row("opaque", $wu->opaque);
1021 1021
     row("Priority", $wu->priority);
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 }
1094 1094
 
1095 1095
 function outcome_color($outcome) {
1096
-    switch($outcome) {
1096
+    switch ($outcome) {
1097 1097
     case 0: return '9900cc'; // "Init", purple
1098 1098
     case 1: return '33cc33'; // "Success", green
1099 1099
     case 3: return 'ff3333'; // "Client error", red
@@ -1122,16 +1122,16 @@  discard block
 block discarded – undo
1122 1122
     row("Received", time_str($result->received_time));
1123 1123
     row("Last time modified", mysqltime_str($result->mod_time));
1124 1124
     row("Name", $result->name);
1125
-    row("Workunit", "<a href=\"db_action.php?table=workunit&id=$result->workunitid\">" . wu_name_by_id($result->workunitid) . "</a> [$result->workunitid]" );
1125
+    row("Workunit", "<a href=\"db_action.php?table=workunit&id=$result->workunitid\">".wu_name_by_id($result->workunitid)."</a> [$result->workunitid]");
1126 1126
     row("Server state", result_server_state_string($result)." [$result->server_state]");
1127 1127
     row("Outcome", result_outcome_string($result)." [$result->outcome]");
1128 1128
     row("Client state", result_client_state_string($result)." [$result->client_state]");
1129 1129
     row("Exit status", exit_status_string($result->exit_status));
1130
-    row("Host ID", "<a href=\"db_action.php?table=host&id=$result->hostid\">" . host_name_by_id($result->hostid) . "</a> [$result->hostid]");
1131
-    row("User ID", "<a href=\"db_action.php?table=user&id=$result->userid\">" . user_name_by_id($result->userid) . "</a> [$result->userid]");
1130
+    row("Host ID", "<a href=\"db_action.php?table=host&id=$result->hostid\">".host_name_by_id($result->hostid)."</a> [$result->hostid]");
1131
+    row("User ID", "<a href=\"db_action.php?table=user&id=$result->userid\">".user_name_by_id($result->userid)."</a> [$result->userid]");
1132 1132
     row("CPU time", $result->cpu_time);
1133 1133
     row("Elapsed time", $result->elapsed_time);
1134
-    if($error=stderr_error_string($result->stderr_out)) {
1134
+    if ($error = stderr_error_string($result->stderr_out)) {
1135 1135
         row("error in stderr out", $error);
1136 1136
     }
1137 1137
     row("Batch", $result->batch);
@@ -1148,16 +1148,16 @@  discard block
 block discarded – undo
1148 1148
     row("App version", $x1.app_version_string($result).$x2);
1149 1149
     row("App version ID", $result->app_version_id);
1150 1150
     row("Estimated GFLOPS", number_format($result->flops_estimate/1e9, 2));
1151
-    row("Random",$result->random);
1152
-    row("Opaque",$result->opaque);
1153
-    row("Teamid",$result->teamid);
1154
-    row("Priority",$result->priority);
1151
+    row("Random", $result->random);
1152
+    row("Opaque", $result->opaque);
1153
+    row("Teamid", $result->teamid);
1154
+    row("Priority", $result->priority);
1155 1155
     row("XML doc in", "<pre>".htmlspecialchars($result->xml_doc_in)."</pre>");
1156 1156
     row("XML doc out", "<pre>".htmlspecialchars($result->xml_doc_out)."</pre>");
1157 1157
     row("stderr out", "<pre>"
1158 1158
         .htmlspecialchars(
1159 1159
             $result->stderr_out,
1160
-            ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0),
1160
+            ENT_QUOTES|(defined('ENT_SUBSTITUTE') ?ENT_SUBSTITUTE:0),
1161 1161
             'utf-8'
1162 1162
         )
1163 1163
         ."</pre>"
@@ -1205,23 +1205,23 @@  discard block
 block discarded – undo
1205 1205
     } else {
1206 1206
         // result has not been received yet, so show report deadline either
1207 1207
         // in green if in the future or in red if in the past.
1208
-        $timenow=time();
1209
-        if ($result->report_deadline==0)  {
1208
+        $timenow = time();
1209
+        if ($result->report_deadline == 0) {
1210 1210
             // not sent -- show create time in purple
1211
-            $received = "<font color=\"9900cc\">". time_str($result->create_time) . "</font>";
1212
-        } else if ($result->report_deadline>=$timenow) {
1211
+            $received = "<font color=\"9900cc\">".time_str($result->create_time)."</font>";
1212
+        } else if ($result->report_deadline >= $timenow) {
1213 1213
             // overdue -- show deadline in red
1214
-            $received = "<font color=\"#33cc33\">". time_str($result->report_deadline) . "</font>";
1214
+            $received = "<font color=\"#33cc33\">".time_str($result->report_deadline)."</font>";
1215 1215
         } else {
1216 1216
             // in progress and not overdue -- show deadline in green
1217
-            $received = "<font color=\"#ff3333\">". time_str($result->report_deadline) . "</font>";
1217
+            $received = "<font color=\"#ff3333\">".time_str($result->report_deadline)."</font>";
1218 1218
         }
1219 1219
     }
1220 1220
     $version = app_version_string($result)." (<a href=\"db_action.php?table=app_version&id=$result->app_version_id\">$result->app_version_id</a>)";
1221 1221
     $outcome_color = outcome_color($result->outcome);
1222 1222
     $validate_color = validate_color($result->validate_state);
1223 1223
     $host_user = host_user_link($result->hostid);
1224
-    $cpu_hours = sprintf("%.1f",$result->cpu_time / 3600);
1224
+    $cpu_hours = sprintf("%.1f", $result->cpu_time/3600);
1225 1225
     $granted_credit = "<a href=credit.php?wu_id=$result->workunitid>".credit_str($result->granted_credit)."</a>";
1226 1226
     $delete_state = file_delete_state_str($result->file_delete_state);
1227 1227
 
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
     row("ID", $user->id);
1250 1250
     row("Created", time_str($user->create_time));
1251 1251
     row("Name", $user->name);
1252
-    if(!in_rops()) {
1252
+    if (!in_rops()) {
1253 1253
         row("Authenticator", $user->authenticator);
1254 1254
     }
1255 1255
     row("Email address", $user->email_addr);
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
     row("Default venue", $user->venue);
1265 1265
     row("Hosts", "<a href=\"db_action.php?table=host&userid=$user->id&detail=low\">click</a>");
1266 1266
     row("Cross project ID", $user->cross_project_id);
1267
-    if(!in_rops()) {
1267
+    if (!in_rops()) {
1268 1268
         row("Password Hash", $user->passwd_hash);
1269 1269
     }
1270 1270
     row("Donated", $user->donated);
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
     echo "</table></td>";
1316 1316
     echo "<td><table border=\"2\">\n";
1317 1317
     echo "<tr><th>User</th><th># posts</th></tr>\n";
1318
-    for ($p=1; $p<=10; $p++) {
1318
+    for ($p = 1; $p <= 10; $p++) {
1319 1319
         row2_plain(user_links_ops($top10poster[$p]), $top10poster[$p]->posts);
1320 1320
     }
1321 1321
     echo "</table></td>";
@@ -1354,10 +1354,10 @@  discard block
 block discarded – undo
1354 1354
 function admin_show_team($team) {
1355 1355
     start_table();
1356 1356
     row("ID", $team->id);
1357
-    row("Team Founder", "<a href=\"db_action.php?table=user&id=$team->userid\">" . user_name_by_id($team->userid) . "</a>");
1357
+    row("Team Founder", "<a href=\"db_action.php?table=user&id=$team->userid\">".user_name_by_id($team->userid)."</a>");
1358 1358
     row("Name", $team->name);
1359
-    row("Name (HTML Formatted)", "<pre>" . htmlspecialchars($team->name_html) . "</pre>" );
1360
-    row("Url", "<a href=\"http://$team->url\">" . $team->url . "</a>");
1359
+    row("Name (HTML Formatted)", "<pre>".htmlspecialchars($team->name_html)."</pre>");
1360
+    row("Url", "<a href=\"http://$team->url\">".$team->url."</a>");
1361 1361
     row("Type", team_type_string($team->type));
1362 1362
     row("Description", $team->description);
1363 1363
     row("", "<a href=\"db_action.php?table=user&teamid=$team->id\">List All Members</a>");
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
     if (!strlen($host->domain_name) && !strlen($host->last_ip_addr)) {
1401 1401
         return "(blank)";
1402 1402
     } else {
1403
-        return $host->domain_name . " (" . $host->last_ip_addr . ")";
1403
+        return $host->domain_name." (".$host->last_ip_addr.")";
1404 1404
     }
1405 1405
 }
1406 1406
 
Please login to merge, or discard this patch.
html/inc/pm.inc 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     return $x;
52 52
 }
53 53
 
54
-function pm_team_form($user, $teamid, $error=null) {
54
+function pm_team_form($user, $teamid, $error = null) {
55 55
     global $bbcode_html, $bbcode_js;
56 56
     $team = BoincTeam::lookup_id($teamid);
57 57
     if (!$team) {
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         error_page("not admin");
62 62
     }
63 63
 
64
-    page_head(tra("Send message to team"),'','','', $bbcode_js);
64
+    page_head(tra("Send message to team"), '', '', '', $bbcode_js);
65 65
 
66 66
     $subject = post_str("subject", true);
67 67
     $content = post_str("content", true);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 function pm_form_page($replyto, $userid, $error = null) {
114 114
     global $bbcode_html, $bbcode_js;
115 115
     global $g_logged_in_user;
116
-    page_head(tra("Send private message"),'','','', $bbcode_js);
116
+    page_head(tra("Send private message"), '', '', '', $bbcode_js);
117 117
 
118 118
     if (post_str("preview", true) == tra("Preview")) {
119 119
         $content = post_str("content", true);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         if (!$user) {
138 138
             error_page("Sender no longer exists");
139 139
         }
140
-        $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")";
140
+        $writeto = UNIQUE_USER_NAME ? $user->name : $userid." (".$user->name.")";
141 141
         $subject = $message->subject;
142 142
         if (substr($subject, 0, 3) != "re:") {
143 143
             $subject = "re: ".$subject;
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
                 time_str($user->prefs->banished_until)
157 157
             );
158 158
         }
159
-        $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")";
159
+        $writeto = UNIQUE_USER_NAME ? $user->name : $userid." (".$user->name.")";
160 160
     } else {
161 161
         $writeto = sanitize_tags(post_str("to", true));
162 162
         $subject = post_str("subject", true);
163 163
         $content = post_str("content", true);
164 164
     }
165 165
 
166
-    $content = $content?htmlspecialchars($content):'';
167
-    $subject = $subject?htmlspecialchars($subject):'';
166
+    $content = $content ?htmlspecialchars($content) : '';
167
+    $subject = $subject ?htmlspecialchars($subject) : '';
168 168
 
169 169
     if ($error != null) {
170 170
         echo "<p class=\"text-danger\">".$error."</p>\n";
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 function send_pm_notification_email(
221 221
     $logged_in_user, $to_user, $subject, $content
222 222
 ) {
223
-    $message  = "
223
+    $message = "
224 224
 You have received a new private message at ".PROJECT.".
225 225
 
226 226
 From: $logged_in_user->name (ID $logged_in_user->id)
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     $pm = BoincPrivateMessage::lookup_id($notify->opaque);
251 251
     $from_user = BoincUser::lookup_id($pm->senderid);
252 252
     if (!$pm || !$from_user) return null;
253
-    return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject";
253
+    return "<a href=pm.php>".tra("Private message%1 from %2, subject:", "</a>", $from_user->name)." $pm->subject";
254 254
 }
255 255
 
256 256
 function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) {
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 
315 315
 function pm_email_remind($user) {
316 316
     if (!$user->prefs->pm_notification) {
317
-        return "<br><small>" .
317
+        return "<br><small>".
318 318
             tra(
319 319
                 "For email notification, %1 edit community prefs %2",
320 320
                 '<a href="edit_forum_preferences_form.php">', '</a>'
321
-            ) .
321
+            ).
322 322
             "</small>"
323 323
         ;
324 324
     }
Please login to merge, or discard this patch.
html/user/sandbox.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     page_tail();
85 85
 }
86 86
 
87
-function list_files($user, $notice=null) {
87
+function list_files($user, $notice = null) {
88 88
     $dir = sandbox_dir($user);
89 89
     if (!is_dir($dir)) error_page("Can't open sandbox directory");
90 90
     page_head("File sandbox");
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     $notice = "";
169 169
     $dir = sandbox_dir($user);
170 170
     $count = count($_FILES['new_file']['tmp_name']);
171
-    for ($i=0; $i<$count; $i++) {
171
+    for ($i = 0; $i < $count; $i++) {
172 172
         $tmp_name = $_FILES['new_file']['tmp_name'][$i];
173 173
         if (!is_uploaded_file($tmp_name)) {
174 174
             error_page("$tmp_name is not uploaded file");
Please login to merge, or discard this patch.
html/inc/host.inc 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 
33 33
 function sched_log_name($x) {
34 34
     if ($x == 0) return "NO_SUCH_LOG";
35
-    return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt";
35
+    return gmdate('Y-m-d_H/Y-m-d_H:i', $x).".txt";
36 36
 }
37 37
 
38 38
 function sched_log_link($x) {
39 39
     if (file_exists("sched_logs")) {
40
-        return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>";
40
+        return "<a href=\"../sched_logs/".sched_log_name($x)."\">".time_str($x)."</a>";
41 41
     } else {
42 42
         return time_str($x);
43 43
     }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 function location_form($host) {
47 47
     $none = "selected";
48
-    $h=$w=$s=$m="";
48
+    $h = $w = $s = $m = "";
49 49
     if ($host->venue == "home") $h = "selected";
50 50
     if ($host->venue == "work") $w = "selected";
51 51
     if ($host->venue == "school") $s = "selected";
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             row2(tra("Product name"), $host->product_name);
100 100
         }
101 101
         $x = $host->timezone/3600;
102
-        if ($x >= 0) $x="+$x";
102
+        if ($x >= 0) $x = "+$x";
103 103
         row2(tra("Local Standard Time"), tra("UTC %1 hours", $x));
104 104
     } else {
105 105
         $owner = BoincUser::lookup_id($host->userid);
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 // Older clients may have the old-style serialnum in the DB
294 294
 // despite the server being upgraded.
295 295
 //
296
-function vbox_desc($parsed_ser){
296
+function vbox_desc($parsed_ser) {
297 297
     if (empty($parsed_ser['vbox'])) return '---';
298 298
     $f = $parsed_ser['vbox'];
299 299
     $desc = sprintf('Virtualbox (%s) %s',
300 300
         $f[1], tra("installed")
301 301
     );
302
-    if (sizeof($f)<=2){
302
+    if (sizeof($f) <= 2) {
303 303
         return $desc;
304 304
     }
305
-    if ($f[2]=="1" and $f[3]=="1") {
305
+    if ($f[2] == "1" and $f[3] == "1") {
306 306
         return $desc.tra(", CPU has hardware virtualization support and it is enabled");
307
-    } elseif ($f[2]=="1" and $f[3]=="0") {
307
+    } elseif ($f[2] == "1" and $f[3] == "0") {
308 308
         return $desc.tra(", CPU has hardware virtualization support but it is disabled");
309
-    } elseif ($f[2]=="0") {
309
+    } elseif ($f[2] == "0") {
310 310
         return $desc.tra(", CPU does not have hardware virtualization support");
311 311
     }
312 312
     return $desc;
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 
332 332
 // return a human-readable version of the GPU info
333 333
 //
334
-function gpu_desc($parsed_ser, $detail=true) {
334
+function gpu_desc($parsed_ser, $detail = true) {
335 335
     $str = "";
336 336
     foreach ($parsed_ser as $d) {
337 337
         if (!is_gpu_type($d[0])) continue;
338 338
         if (count($d) < 4) continue;
339 339
         if ($str) $str .= "<p>";
340
-        if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] ";
340
+        if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] ";
341 341
         if ($d[0] == "CUDA") {
342 342
             $str .= "NVIDIA";
343 343
         } else if ($d[0] == "CAL") {
@@ -543,14 +543,14 @@  discard block
 block discarded – undo
543 543
     if ($pos1 === false) return $x;
544 544
     $pos2 = strpos($model, ']');
545 545
     if ($pos2 === false) return $x;
546
-    $a = substr($model, $pos1+1, $pos2-$pos1-1);
546
+    $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1);
547 547
     $y = explode(" ", $a);
548 548
     if (count($y) == 0) return $x;
549 549
     if ($y[0] == "Family") {
550 550
         $x->info = $a;
551 551
     } else {
552 552
         $x->arch = $y[0];
553
-        $x->info = substr($a, strlen($y[0])+1);
553
+        $x->info = substr($a, strlen($y[0]) + 1);
554 554
     }
555 555
     return $x;
556 556
 }
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
     $avg_time = 0;
640 640
 
641 641
     $results = BoincResult::enum("hostid=$hostid order by received_time");
642
-    foreach($results as $result) {
642
+    foreach ($results as $result) {
643 643
         if ($result->granted_credit <= 0) continue;
644 644
         $total += $result->granted_credit;
645 645
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
 function link_url($sort, $rev, $show_all) {
734 734
     global $userid;
735
-    $x = $userid ? "&userid=$userid":"";
735
+    $x = $userid ? "&userid=$userid" : "";
736 736
     return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x";
737 737
 }
738 738
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 }
807 807
 
808 808
 function show_user_hosts($userid, $private, $show_all, $sort, $rev) {
809
-    $desc = false;  // whether the sort order's default is decreasing
809
+    $desc = false; // whether the sort order's default is decreasing
810 810
     switch ($sort) {
811 811
     case "total_credit": $sort_clause = "total_credit"; $desc = true; break;
812 812
     case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break;
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
     more_or_less($sort, $rev, $show_all);
830 830
 
831 831
     $now = time();
832
-    $old_hosts=0;
832
+    $old_hosts = 0;
833 833
     $i = 1;
834 834
     $hosts = BoincHost::enum("userid=$userid order by $sort_clause");
835 835
     $any_product_name = false;
@@ -841,9 +841,9 @@  discard block
 block discarded – undo
841 841
     }
842 842
     user_host_table_start($private, $sort, $rev, $show_all, $any_product_name);
843 843
     foreach ($hosts as $host) {
844
-        $is_old=false;
844
+        $is_old = false;
845 845
         if (($now - $host->rpc_time) > 30*86400) {
846
-            $is_old=true;
846
+            $is_old = true;
847 847
             $old_hosts++;
848 848
         }
849 849
         if (!$show_all && $is_old) continue;
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
     }
853 853
     end_table();
854 854
 
855
-    if ($old_hosts>0) {
855
+    if ($old_hosts > 0) {
856 856
         more_or_less($sort, $rev, $show_all);
857 857
     }
858 858
 
Please login to merge, or discard this patch.
html/user/manage_project.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -162,11 +162,11 @@
 block discarded – undo
162 162
             }
163 163
         }
164 164
     }
165
-    $quota = (double) get_str('quota');
165
+    $quota = (double)get_str('quota');
166 166
     if ($quota != $us->quota) {
167 167
         $us->update("quota=$quota");
168 168
     }
169
-    $mj = (int) get_str('max_jobs_in_progress');
169
+    $mj = (int)get_str('max_jobs_in_progress');
170 170
     if ($mj != $us->max_jobs_in_progress) {
171 171
         $us->update("max_jobs_in_progress=$mj");
172 172
     }
Please login to merge, or discard this patch.
html/inc/util.inc 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 $config = get_config();
36 36
 
37 37
 global $master_url;
38
-$master_url = parse_config($config , "<master_url>");
38
+$master_url = parse_config($config, "<master_url>");
39 39
 
40 40
 // the above 'globals' are solely for Drupal; see
41 41
 // https://stackoverflow.com/questions/29216392/scope-of-a-global-variable-in-drupal-module
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 // Set parameters to defaults if not defined in config.xml
47 47
 
48 48
 $x = parse_config($config, "<user_country>");
49
-define('USER_COUNTRY', ($x===null)?1:(int)$x);
49
+define('USER_COUNTRY', ($x === null) ? 1 : (int)$x);
50 50
 
51 51
 $x = parse_config($config, "<user_url>");
52
-define('USER_URL', ($x===null)?1:(int)$x);
52
+define('USER_URL', ($x === null) ? 1 : (int)$x);
53 53
 
54 54
 // Set parameters to defaults if not defined in project.inc
55 55
 
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 }
160 160
 
161 161
 function url_base() {
162
-    return is_https()?secure_url_base():URL_BASE;
162
+    return is_https() ?secure_url_base() : URL_BASE;
163 163
 }
164 164
 
165
-function send_cookie($name, $value, $permanent, $ops=false) {
165
+function send_cookie($name, $value, $permanent, $ops = false) {
166 166
     global $master_url;
167 167
 
168 168
     // the following allows independent login for projects on the same server
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
         $path = substr($path, 0, -1);
174 174
         $path .= "_ops/";
175 175
     }
176
-    $expire = $permanent?time()+3600*24*365:0;
176
+    $expire = $permanent ?time() + 3600*24*365 : 0;
177 177
     setcookie($name, $value, $expire, $path,
178 178
         '',
179
-        is_https(),     // if this page is secure, make cookie secure
179
+        is_https(), // if this page is secure, make cookie secure
180 180
         true            // httponly; no JS access
181 181
     );
182 182
 }
183 183
 
184
-function clear_cookie($name, $ops=false) {
184
+function clear_cookie($name, $ops = false) {
185 185
     global $master_url;
186 186
     $url = parse_url($master_url);
187 187
     $path = $url['path'];
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
         $path = substr($path, 0, -1);
190 190
         $path .= "_ops/";
191 191
     }
192
-    setcookie($name, '', time()-3600, $path);
192
+    setcookie($name, '', time() - 3600, $path);
193 193
 }
194 194
 
195 195
 $g_logged_in_user = null;
196 196
 $got_logged_in_user = false;
197 197
 
198
-function get_logged_in_user($must_be_logged_in=true) {
198
+function get_logged_in_user($must_be_logged_in = true) {
199 199
     global $g_logged_in_user, $got_logged_in_user;
200 200
     if ($got_logged_in_user) {
201 201
         // this could have been called earlier with $must_be_logged_in false
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             $next_url = $_SERVER['REQUEST_URI'];
222 222
             $n = strrpos($next_url, "/");
223 223
             if ($n) {
224
-                $next_url = substr($next_url, $n+1);
224
+                $next_url = substr($next_url, $n + 1);
225 225
             }
226 226
         }
227 227
         $next_url = urlencode($next_url);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     return $g_logged_in_user;
233 233
 }
234 234
 
235
-function show_login_info($prefix="") {
235
+function show_login_info($prefix = "") {
236 236
     $user = get_logged_in_user(false);
237 237
     if ($user) {
238 238
         $url_tokens = url_tokens($user->authenticator);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     }
243 243
 }
244 244
 
245
-$cache_control_extra="";
245
+$cache_control_extra = "";
246 246
 $is_login_page = false;
247 247
 
248 248
 // Call this to start pages.
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 // with an existing web framework can more easily do so.
255 255
 // To do so, define page_head() in html/project/project.inc
256 256
 //
257
-if (!function_exists("page_head")){
257
+if (!function_exists("page_head")) {
258 258
 function page_head(
259 259
     $title,
260 260
         // page title. Put in <title>, used as title for browser tab.
261
-    $body_attrs=null,
261
+    $body_attrs = null,
262 262
         // <body XXXX>
263 263
         // e.g. Javascript to put focus in an input field
264 264
         // (onload="document.form.foo.focus()")
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
         // if set, include schedulers.txt.
268 268
         // also pass to project_banner() in case you want a different
269 269
         // header for your main page.
270
-    $url_prefix="",
270
+    $url_prefix = "",
271 271
         // prepend this to links.
272 272
         // Use for web pages not in the top directory
273
-    $head_extra=null
273
+    $head_extra = null
274 274
         // extra stuff to put in <head>. E.g.:
275 275
         // reCAPTCHA code (create_profile.php)
276 276
         // bbcode javascript (forums)
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
         header("Content-type: text/html; charset=utf-8");
293 293
         header("Expires: Mon, 26 Jul 1997 05:00:00 UTC");
294 294
             // Date in the past
295
-        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC");
295
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC");
296 296
             // always modified
297 297
         header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0");
298 298
             // for HTTP/1.1
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
     if ($head_extra) {
316 316
         echo "\n$head_extra\n";
317 317
     }
318
-    if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) {
318
+    if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) {
319 319
         readfile("schedulers.txt");
320 320
     }
321 321
 
322
-    $t = $title?$title:PROJECT;
322
+    $t = $title ? $title : PROJECT;
323 323
     echo "<title>$t</title>\n";
324 324
     echo '
325 325
         <meta charset="utf-8">
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
     echo '<div class="container-fluid">
376 376
     ';
377 377
 
378
-    switch($title) {    //kludge
378
+    switch ($title) {    //kludge
379 379
     case tra("Log in"):
380 380
     case tra("Create an account"):
381 381
     case tra("Server status page"):
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
 
391 391
 // See the comments for page_head()
392 392
 //
393
-if (!function_exists("page_tail")){
393
+if (!function_exists("page_tail")) {
394 394
 function page_tail(
395
-    $show_date=false,
395
+    $show_date = false,
396 396
         // true for pages that are generated periodically rather than on the fly
397
-    $url_prefix="",
397
+    $url_prefix = "",
398 398
         // use for pages not at top level
399
-    $is_main=false
399
+    $is_main = false
400 400
         // passed to project_footer;
401 401
 ) {
402 402
     echo "<br>\n";
@@ -430,24 +430,24 @@  discard block
 block discarded – undo
430 430
 // convert time interval in seconds to a string of the form
431 431
 // 'D days h hours m min s sec'.
432 432
 
433
-function time_diff($x, $res=3) {
433
+function time_diff($x, $res = 3) {
434 434
     $x = (int)$x;
435 435
     $days    = (int)($x/86400);
436
-    $hours   = (int)(($x-$days*86400)/3600);
437
-    $minutes = (int)(($x-$days*86400-$hours*3600)/60);
438
-    $seconds = $x % 60;
436
+    $hours   = (int)(($x - $days*86400)/3600);
437
+    $minutes = (int)(($x - $days*86400 - $hours*3600)/60);
438
+    $seconds = $x%60;
439 439
 
440 440
     $s = "";
441 441
     if ($days) {
442 442
         $s .= "$days ".tra("days")." ";
443 443
     }
444
-    if ($res>0 && ($hours || strlen($s))) {
444
+    if ($res > 0 && ($hours || strlen($s))) {
445 445
         $s .= "$hours ".tra("hours")." ";
446 446
     }
447
-    if ($res>1 && ($minutes || strlen($s))) {
447
+    if ($res > 1 && ($minutes || strlen($s))) {
448 448
         $s .= "$minutes ".tra("min")." ";
449 449
     }
450
-    if ($res>2) {
450
+    if ($res > 2) {
451 451
         $s .= "$seconds ".tra("sec")." ";
452 452
     }
453 453
     return $s;
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
 function time_str($x) {
463 463
     if ($x == 0) return "---";
464
-    return gmdate('j M Y, G:i:s', (int)$x) . " UTC";
464
+    return gmdate('j M Y, G:i:s', (int)$x)." UTC";
465 465
 }
466 466
 
467 467
 function local_time_str($x) {
@@ -473,14 +473,14 @@  discard block
 block discarded – undo
473 473
     return time_str($x);
474 474
 }
475 475
 
476
-function start_table_str($class="", $style="") {
477
-    $s = $style?'style="'.$style.'"':'';
476
+function start_table_str($class = "", $style = "") {
477
+    $s = $style ? 'style="'.$style.'"' : '';
478 478
     return '<div class="table">
479 479
       <table '.$s.' width="100%" class="table table-condensed '.$class.'" >
480 480
     ';
481 481
 }
482 482
 
483
-function start_table($class="", $style="") {
483
+function start_table($class = "", $style = "") {
484 484
     echo start_table_str($class, $style);
485 485
 }
486 486
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
     echo "</tr>\n";
526 526
 }
527 527
 
528
-function row1($x, $ncols=2, $class="heading") {
528
+function row1($x, $ncols = 2, $class = "heading") {
529 529
     if ($class == "heading") {
530 530
         echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n";
531 531
     } else {
@@ -539,10 +539,10 @@  discard block
 block discarded – undo
539 539
 
540 540
 // a table row with 2 columns, with the left on right-aligned
541 541
 
542
-function row2($x, $y, $show_error=false, $lwidth='40%') {
543
-    if ($x==="") $x="<br>";
544
-    if ($y==="") $y="<br>";
545
-    $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS;
542
+function row2($x, $y, $show_error = false, $lwidth = '40%') {
543
+    if ($x === "") $x = "<br>";
544
+    if ($y === "") $y = "<br>";
545
+    $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
546 546
     echo "<tr>
547 547
         <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td>
548 548
         <td $attrs >$y</td>
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 // output the first part of row2();
554 554
 // then write the content, followed by </td></tr>
555 555
 
556
-function row2_init($x, $lwidth='40%') {
556
+function row2_init($x, $lwidth = '40%') {
557 557
     echo sprintf('<tr>
558 558
         <td width="%s" %s>%s</td>
559 559
         <td %s>',
@@ -569,31 +569,31 @@  discard block
 block discarded – undo
569 569
     echo "<tr><td>$string</td></tr>";
570 570
 }
571 571
 
572
-function row_array($x, $attrs=null) {
572
+function row_array($x, $attrs = null) {
573 573
     echo "<tr>\n";
574 574
     $i = 0;
575 575
     foreach ($x as $h) {
576
-        $a = $attrs?$attrs[$i]:"";
576
+        $a = $attrs ? $attrs[$i] : "";
577 577
         echo "<td $a>$h</td>\n";
578 578
         $i++;
579 579
     }
580 580
     echo "</tr>\n";
581 581
 }
582 582
 
583
-define ('ALIGN_RIGHT', 'style="text-align:right;"');
583
+define('ALIGN_RIGHT', 'style="text-align:right;"');
584 584
 
585
-function row_heading_array($x, $attrs=null, $class='bg-primary') {
585
+function row_heading_array($x, $attrs = null, $class = 'bg-primary') {
586 586
     echo "<tr>";
587 587
     $i = 0;
588 588
     foreach ($x as $h) {
589
-        $a = $attrs?$attrs[$i]:"";
589
+        $a = $attrs ? $attrs[$i] : "";
590 590
         echo "<th $a class=\"$class\">$h</th>";
591 591
         $i++;
592 592
     }
593 593
     echo "</tr>\n";
594 594
 }
595 595
 
596
-function row_heading($x, $class='bg-primary') {
596
+function row_heading($x, $class = 'bg-primary') {
597 597
     echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr>
598 598
         ', $class, $x
599 599
     );
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 // If $ellipsis is true, then an ellipsis is added to any sentence which
654 654
 // is cut short.
655 655
 
656
-function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) {
656
+function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) {
657 657
     $words = explode($delimiter, $sentence);
658 658
     $total_chars = 0;
659 659
     $trunc = false;
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 
737 737
 // returns null if the arg is optional and missing
738 738
 //
739
-function get_int($name, $optional=false) {
740
-    $x=null;
739
+function get_int($name, $optional = false) {
740
+    $x = null;
741 741
     if (isset($_GET[$name])) $x = $_GET[$name];
742 742
     if (!is_numeric($x)) {
743 743
         if ($optional) {
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 
757 757
 // returns null if the arg is optional and missing
758 758
 //
759
-function post_num($name, $optional=false) {
759
+function post_num($name, $optional = false) {
760 760
     $x = null;
761 761
     if (isset($_POST[$name])) $x = $_POST[$name];
762 762
     if (!is_numeric($x)) {
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 
772 772
 // returns null if the arg is optional and missing
773 773
 //
774
-function post_int($name, $optional=false) {
774
+function post_int($name, $optional = false) {
775 775
     $x = post_num($name, $optional);
776 776
     if (is_null($x)) return null;
777 777
     $y = (int)$x;
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
     }
790 790
 }
791 791
 
792
-function get_str($name, $optional=false) {
792
+function get_str($name, $optional = false) {
793 793
     if (isset($_GET[$name])) {
794 794
         $x = $_GET[$name];
795 795
     } else {
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     return undo_magic_quotes($x);
802 802
 }
803 803
 
804
-function post_str($name, $optional=false) {
804
+function post_str($name, $optional = false) {
805 805
     if (isset($_POST[$name])) {
806 806
         $x = $_POST[$name];
807 807
     } else {
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
     return undo_magic_quotes($x);
814 814
 }
815 815
 
816
-function post_arr($name, $optional=false) {
816
+function post_arr($name, $optional = false) {
817 817
     if (isset($_POST[$name]) && is_array($_POST[$name])) {
818 818
         $x = $_POST[$name];
819 819
     } else {
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
     // the mb_* functions are not included by default
830 830
     // return (mb_detect_encoding($passwd) -= 'ASCII');
831 831
 
832
-    for ($i=0; $i<strlen($str); $i++) {
832
+    for ($i = 0; $i < strlen($str); $i++) {
833 833
         $c = ord(substr($str, $i));
834 834
         if ($c < 32 || $c > 127) return false;
835 835
     }
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
     $number = str_replace(',', '.', $number); // replace the german decimal separator
854 854
     // if no value was entered and this is ok
855 855
     //
856
-    if ($number=='' && !$low) return true;
856
+    if ($number == '' && !$low) return true;
857 857
 
858 858
     // the supplied value contains alphabetic characters
859 859
     //
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 
871 871
 // Generate a "select" element from an array of values
872 872
 //
873
-function select_from_array($name, $array, $selection=null, $width=240) {
873
+function select_from_array($name, $array, $selection = null, $width = 240) {
874 874
     $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"';
875 875
 
876 876
     foreach ($array as $key => $value) {
@@ -895,12 +895,12 @@  discard block
 block discarded – undo
895 895
     return $str;
896 896
 }
897 897
 
898
-function strip_bbcode($string){
899
-    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string);
898
+function strip_bbcode($string) {
899
+    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string);
900 900
 }
901 901
 
902 902
 function current_url() {
903
-    $url = is_https()?'https':'http';
903
+    $url = is_https() ? 'https' : 'http';
904 904
     $url .= "://";
905 905
     $url .= $_SERVER['SERVER_NAME'];
906 906
     $url .= ":".$_SERVER['SERVER_PORT'];
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 // the colors for bootstrap's btn-success are almost illegible;
919 919
 // the green is too light.  Use a darker green.
920 920
 //
921
-function button_style($color='green', $font_size=null) {
921
+function button_style($color = 'green', $font_size = null) {
922 922
     $fs = '';
923 923
     if ($font_size) {
924 924
         $fs = sprintf('; font-size:%dpx', $font_size);
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 // class: class of the button, e.g. btn
938 938
 // extra: Additional text in href tag
939 939
 //
940
-function button_text($url, $text, $desc=null, $class=null, $extra='') {
940
+function button_text($url, $text, $desc = null, $class = null, $extra = '') {
941 941
     if (!$desc) {
942 942
         $desc = $text;
943 943
     }
@@ -952,23 +952,23 @@  discard block
 block discarded – undo
952 952
     );
953 953
 }
954 954
 
955
-function button_text_small($url, $text, $desc=null) {
955
+function button_text_small($url, $text, $desc = null) {
956 956
     return button_text($url, $text, $desc, "btn btn-xs", button_style());
957 957
 }
958 958
 
959
-function show_button($url, $text, $desc=null, $class=null, $extra=null) {
959
+function show_button($url, $text, $desc = null, $class = null, $extra = null) {
960 960
     echo button_text($url, $text, $desc, $class, $extra);
961 961
 }
962 962
 
963 963
 // for places with a bunch of buttons, like forum posts
964 964
 //
965
-function show_button_small($url, $text, $desc=null) {
965
+function show_button_small($url, $text, $desc = null) {
966 966
     echo button_text_small($url, $text, $desc);
967 967
 }
968 968
 
969 969
 // used for showing icons
970 970
 //
971
-function show_image($src, $title, $alt, $height=null) {
971
+function show_image($src, $title, $alt, $height = null) {
972 972
     $h = "";
973 973
     if ($height) {
974 974
         $h = "height=\"$height\"";
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 // tries instead to connect to <replica_db_host> if tag exists.
1006 1006
 // DEPRECATED - use boinc_db.inc
1007 1007
 //
1008
-function db_init($try_replica=false) {
1008
+function db_init($try_replica = false) {
1009 1009
     check_web_stopped();
1010 1010
     $retval = db_init_aux($try_replica);
1011 1011
     if ($retval == 1) {
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 // Check this to avoid XSS vulnerability
1082 1082
 //
1083 1083
 function sanitize_sort_by($x) {
1084
-    switch($x) {
1084
+    switch ($x) {
1085 1085
     case 'expavg_credit':
1086 1086
     case 'total_credit':
1087 1087
         return;
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 }
1100 1100
 
1101 1101
 function do_download($path) {
1102
-    $name=basename($path);
1102
+    $name = basename($path);
1103 1103
     header('Content-Description: File Transfer');
1104 1104
     header('Content-Type: application/octet-stream');
1105 1105
     header('Content-Disposition: attachment; filename='.$name);
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
     header('Expires: 0');
1108 1108
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1109 1109
     header('Pragma: public');
1110
-    header('Content-Length: ' . filesize($path));
1110
+    header('Content-Length: '.filesize($path));
1111 1111
     flush();
1112 1112
     readfile($path);
1113 1113
 }
@@ -1156,10 +1156,10 @@  discard block
 block discarded – undo
1156 1156
 // Otherwise return 0.
1157 1157
 // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)"
1158 1158
 //
1159
-function boinc_client_version(){
1159
+function boinc_client_version() {
1160 1160
     if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0;
1161 1161
     $x = $_SERVER['HTTP_USER_AGENT'];
1162
-    $e =  "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1162
+    $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1163 1163
     if (preg_match($e, $x, $matches)) {
1164 1164
         return $matches[1]*10000 + $matches[2]*100 + $matches[3];
1165 1165
     }
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
     $rem_name = $name."_remaining";
1189 1189
     return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\"
1190 1190
         onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea>
1191
-        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1191
+        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1192 1192
     ;
1193 1193
 }
1194 1194
 
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 // use the following around text with long lines,
1219 1219
 // to limit the width and make it more readable.
1220 1220
 //
1221
-function text_start($width=640) {
1221
+function text_start($width = 640) {
1222 1222
     echo sprintf("<div style=\"max-width: %dpx;\">\n", $width);
1223 1223
 }
1224 1224
 function text_end() {
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 }
1245 1245
 
1246 1246
 function cert_filename() {
1247
-    return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php";
1247
+    return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php";
1248 1248
 }
1249 1249
 
1250 1250
 // if user hasn't validated their email addr, tell them to
Please login to merge, or discard this patch.
html/user/buda.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 // show list of BUDA apps and variants,
59 59
 // w/ buttons for adding and deleting
60 60
 //
61
-function app_list($notice=null) {
61
+function app_list($notice = null) {
62 62
     global $buda_root;
63 63
     if (!is_dir($buda_root)) {
64 64
         mkdir($buda_root);
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     //
255 255
     $x = "<input_template>\n";
256 256
     $ninfiles = 1 + count($variant_desc->input_file_names) + count($variant_desc->app_files);
257
-    for ($i=0; $i<$ninfiles; $i++) {
257
+    for ($i = 0; $i < $ninfiles; $i++) {
258 258
         $x .= "   <file_info>\n      <sticky/>\n      <no_delete/>\n      <executable/>\n   </file_info>\n";
259 259
     }
260 260
     $x .= "   <workunit>\n";
Please login to merge, or discard this patch.