Passed
Pull Request — master (#6115)
by David
16:09 queued 08:15
created
html/user/forum_search_action.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 // Optionally filters by forum, user, time, or hidden if specified.
32 32
 //
33 33
 function search_thread_titles(
34
-    $keyword_list, $forum="", $user="", $time="", $limit=200,
35
-    $sort_style=CREATE_TIME_NEW, $show_hidden = false
36
-){
37
-    $search_string="%";
34
+    $keyword_list, $forum = "", $user = "", $time = "", $limit = 200,
35
+    $sort_style = CREATE_TIME_NEW, $show_hidden = false
36
+) {
37
+    $search_string = "%";
38 38
     foreach ($keyword_list as $key => $word) {
39 39
         $search_string .= BoincDb::escape_string($word)."%";
40 40
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     if (!$show_hidden) {
52 52
         $query .= " and thread.hidden = 0";
53 53
     }
54
-    switch($sort_style) {
54
+    switch ($sort_style) {
55 55
     case MODIFIED_NEW:
56 56
         $query .= ' ORDER BY timestamp DESC';
57 57
         break;
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 //
85 85
 function search_post_content(
86 86
     $keyword_list, $forum, $user, $time, $limit, $sort_style, $show_hidden
87
-){
87
+) {
88 88
     $db = BoincDb::get();
89 89
 
90
-    $search_string="%";
91
-    foreach ($keyword_list as $key => $word){
90
+    $search_string = "%";
91
+    foreach ($keyword_list as $key => $word) {
92 92
         $search_string .= BoincDb::escape_string($word)."%";
93 93
     }
94 94
     $optional_join = "";
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
     }
101 101
     $query = "select post.* from ".$db->db_name.".post".$optional_join." where content like '".$search_string."'";
102 102
     if ($forum) {
103
-        $query.=" and forum = $forum->id";
103
+        $query .= " and forum = $forum->id";
104 104
     }
105 105
     if ($user) {
106
-        $query.=" and post.user = $user->id ";
106
+        $query .= " and post.user = $user->id ";
107 107
     }
108 108
     if ($time) {
109
-        $query.=" and post.timestamp > $time";
109
+        $query .= " and post.timestamp > $time";
110 110
     }
111 111
     if (!$show_hidden) {
112 112
         $query .= " AND post.hidden = 0";
113 113
     }
114
-    switch($sort_style) {
114
+    switch ($sort_style) {
115 115
     case VIEWS_MOST:
116
-        $query.= ' ORDER BY views DESC';
116
+        $query .= ' ORDER BY views DESC';
117 117
         break;
118 118
     case CREATE_TIME_NEW:
119 119
         $query .= ' ORDER by post.timestamp desc';
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
         $query .= ' ORDER BY post.timestamp DESC';
129 129
         break;
130 130
     }
131
-    $query.= " limit $limit";
131
+    $query .= " limit $limit";
132 132
     return BoincPost::enum_general($query);
133 133
 }
134 134
 
135 135
 $logged_in_user = get_logged_in_user(false);
136 136
 BoincForumPrefs::lookup($logged_in_user);
137
-if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)){
137
+if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)) {
138 138
     $show_hidden_posts = true;
139 139
 } else {
140 140
     $show_hidden_posts = false;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 $search_max_time = post_int("search_max_time");
148 148
 $search_forum = post_int("search_forum");
149 149
 $search_sort = post_int("search_sort");
150
-$search_list = explode(" ",$search_keywords);
150
+$search_list = explode(" ", $search_keywords);
151 151
 if ($search_max_time) {
152 152
     $min_timestamp = time() - ($search_max_time*3600*24);
153 153
 } else {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 $limit = 100;
158 158
 
159
-if ($search_forum==-1){
159
+if ($search_forum == -1) {
160 160
     $forum = null;
161 161
 } else if ($search_forum) {
162 162
     $forum = BoincForum::lookup_id($search_forum);
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 
177 177
 // Display the threads
178 178
 //
179
-if (count($threads)){
180
-    echo "<h3>" . tra("Thread titles matching your query:") . "</h3>";
179
+if (count($threads)) {
180
+    echo "<h3>".tra("Thread titles matching your query:")."</h3>";
181 181
     start_table('table-striped');
182 182
     thread_list_header();
183
-    foreach ($threads as $thread){
183
+    foreach ($threads as $thread) {
184 184
         if (!$show_hidden_posts) {
185 185
             $u = BoincUser::lookup_id($thread->owner);
186 186
             if ($u && is_banished($u)) continue;
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
     $show_hidden_posts
201 201
 );
202 202
 
203
-if (count($posts)){
204
-    echo "<h3>" . tra("Messages matching your query:") . "</h3>";
203
+if (count($posts)) {
204
+    echo "<h3>".tra("Messages matching your query:")."</h3>";
205 205
     start_table('table-striped');
206 206
     row_heading_array(['Info', 'Post'], ['', 'width=70%']);
207 207
     $n = 1;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     end_table();
229 229
 }
230 230
 
231
-if (!count($threads) && !count($posts)){
231
+if (!count($threads) && !count($posts)) {
232 232
     echo "<p>".tra("Sorry, couldn't find anything matching your search query. You can try to broaden your search by using less words (or less specific words).")."</p>
233 233
     <p>"
234 234
     .tra("You can also %1 try the same search on Google. %2",
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 function search_thread_titles(
34 34
     $keyword_list, $forum="", $user="", $time="", $limit=200,
35 35
     $sort_style=CREATE_TIME_NEW, $show_hidden = false
36
-){
36
+) {
37 37
     $search_string="%";
38 38
     foreach ($keyword_list as $key => $word) {
39 39
         $search_string .= BoincDb::escape_string($word)."%";
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 //
85 85
 function search_post_content(
86 86
     $keyword_list, $forum, $user, $time, $limit, $sort_style, $show_hidden
87
-){
87
+) {
88 88
     $db = BoincDb::get();
89 89
 
90 90
     $search_string="%";
91
-    foreach ($keyword_list as $key => $word){
91
+    foreach ($keyword_list as $key => $word) {
92 92
         $search_string .= BoincDb::escape_string($word)."%";
93 93
     }
94 94
     $optional_join = "";
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 $logged_in_user = get_logged_in_user(false);
136 136
 BoincForumPrefs::lookup($logged_in_user);
137
-if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)){
137
+if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)) {
138 138
     $show_hidden_posts = true;
139 139
 } else {
140 140
     $show_hidden_posts = false;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 $limit = 100;
158 158
 
159
-if ($search_forum==-1){
159
+if ($search_forum==-1) {
160 160
     $forum = null;
161 161
 } else if ($search_forum) {
162 162
     $forum = BoincForum::lookup_id($search_forum);
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 
177 177
 // Display the threads
178 178
 //
179
-if (count($threads)){
179
+if (count($threads)) {
180 180
     echo "<h3>" . tra("Thread titles matching your query:") . "</h3>";
181 181
     start_table('table-striped');
182 182
     thread_list_header();
183
-    foreach ($threads as $thread){
183
+    foreach ($threads as $thread) {
184 184
         if (!$show_hidden_posts) {
185 185
             $u = BoincUser::lookup_id($thread->owner);
186 186
             if ($u && is_banished($u)) continue;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     $show_hidden_posts
201 201
 );
202 202
 
203
-if (count($posts)){
203
+if (count($posts)) {
204 204
     echo "<h3>" . tra("Messages matching your query:") . "</h3>";
205 205
     start_table('table-striped');
206 206
     row_heading_array(['Info', 'Post'], ['', 'width=70%']);
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     end_table();
229 229
 }
230 230
 
231
-if (!count($threads) && !count($posts)){
231
+if (!count($threads) && !count($posts)) {
232 232
     echo "<p>".tra("Sorry, couldn't find anything matching your search query. You can try to broaden your search by using less words (or less specific words).")."</p>
233 233
     <p>"
234 234
     .tra("You can also %1 try the same search on Google. %2",
Please login to merge, or discard this patch.
html/inc/profile.inc 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@
 block discarded – undo
193 193
     $min_credit = parse_config(get_config(), "<profile_min_credit>");
194 194
     if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) {
195 195
         error_page(
196
-           tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
196
+            tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
197 197
         );
198 198
     }
199 199
 }
Please login to merge, or discard this patch.
html/inc/user.inc 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 // they've participated in
34 34
 //
35 35
 function get_other_projects($user) {
36
-    $cpid = md5($user->cross_project_id . $user->email_addr);
36
+    $cpid = md5($user->cross_project_id.$user->email_addr);
37 37
     $url = "http://boinc.netsoft-online.com/get_user.php?cpid=".$cpid;
38 38
 
39 39
     // Check the cache for that URL
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     usort($user->projects, "cmp");
123 123
     if ($personal) {
124
-        $t  = tra("Projects in which you are participating");
124
+        $t = tra("Projects in which you are participating");
125 125
     } else {
126 126
         $t = tra("Projects in which %1 is participating", $user->name);
127 127
     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     }
181 181
 
182 182
     if (!NO_STATS) {
183
-        $cpid = md5($user->cross_project_id . $user->email_addr);
183
+        $cpid = md5($user->cross_project_id.$user->email_addr);
184 184
         $x = "";
185 185
         shuffle($cpid_stats_sites);
186 186
         foreach ($cpid_stats_sites as $site) {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         $u = normalize_user_url($user->url);
267 267
         row2(
268 268
             tra("URL"),
269
-            $u?sprintf('<a href="%s">%s</a>', $u, $u):tra('Invalid URL')
269
+            $u ?sprintf('<a href="%s">%s</a>', $u, $u) : tra('Invalid URL')
270 270
         );
271 271
     }
272 272
     if (USER_COUNTRY) {
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 // if $badge_height is > 0, show badges
375 375
 // if $name_limit, limit name to N chars
376 376
 //
377
-function user_links($user, $badge_height=0, $name_limit=0) {
377
+function user_links($user, $badge_height = 0, $name_limit = 0) {
378 378
     if (!$user) {
379 379
         error_log("user_links(): null arg\n");
380 380
         return;
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
         $user->id,
404 404
         $name
405 405
     );
406
-    if (function_exists("project_user_links")){
406
+    if (function_exists("project_user_links")) {
407 407
         $x .= project_user_links($user);
408 408
     }
409 409
     if ($badge_height) {
410 410
         $x .= badges_string(true, $user, $badge_height);
411 411
     }
412
-    return $name_limit?"<nobr>$x</nobr>":$x;
412
+    return $name_limit ? "<nobr>$x</nobr>" : $x;
413 413
 }
414 414
 
415 415
 // show community links for the logged in user
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 
469 469
             // if there's a foundership request, notify the founder
470 470
             //
471
-            if ($user->id==$team->userid && $team->ping_user >0) {
471
+            if ($user->id == $team->userid && $team->ping_user > 0) {
472 472
                 $x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>";
473 473
             }
474 474
             row2(tra("Member of team"), $x);
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
     $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
493 493
     $x = [];
494 494
     if ($friends) {
495
-        foreach($friends as $friend) {
495
+        foreach ($friends as $friend) {
496 496
             $fuser = BoincUser::lookup_id($friend->user_dest);
497 497
             if (!$fuser) continue;
498 498
             $x[] = friend_links($fuser);
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 
543 543
 // return an object with data to show the user's community links
544 544
 //
545
-function get_community_links_object($user){
545
+function get_community_links_object($user) {
546 546
     $cache_object = new StdClass;
547 547
     $cache_object->post_count = total_posts($user);
548 548
     $cache_object->user = $user;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     $cache_object->friends = array();
551 551
 
552 552
     $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
553
-    foreach($friends as $friend) {
553
+    foreach ($friends as $friend) {
554 554
         $fuser = BoincUser::lookup_id($friend->user_dest);
555 555
         if (!$fuser) continue;
556 556
         $cache_object->friends[] = $fuser;
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 
561 561
 // show community links of another user (described by $clo)
562 562
 //
563
-function community_links($clo, $logged_in_user){
563
+function community_links($clo, $logged_in_user) {
564 564
     $user = $clo->user;
565 565
     if (!$user) {
566 566
         error_log("community_links(): null user\n");
@@ -602,15 +602,15 @@  discard block
 block discarded – undo
602 602
                 "<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>"
603 603
             );
604 604
         } else if ($friend) {
605
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
605
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
606 606
         } else {
607
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
607
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
608 608
         }
609 609
     }
610 610
 
611 611
     if ($friends) {
612 612
         $x = [];
613
-        foreach($friends as $friend) {
613
+        foreach ($friends as $friend) {
614 614
             $x[] = friend_links($friend);
615 615
         }
616 616
         row2(tra('Friends'), implode('<br>', $x));
Please login to merge, or discard this patch.
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.