Passed
Pull Request — master (#6441)
by
unknown
09:23
created
html/user/forum_moderate_post.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 start_table();
51 51
 
52 52
 $get_reason = true;
53
-if (get_str('action')=="hide") {
53
+if (get_str('action') == "hide") {
54 54
     //display input that selects reason
55 55
     echo "<input type=hidden name=action value=hide>";
56 56
     row1(tra("Hide post"));
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
             )
68 68
         )
69 69
     );
70
-} elseif (get_str('action')=="move") {
70
+} elseif (get_str('action') == "move") {
71 71
     row1(tra("Move post"));
72 72
     echo "<input type=hidden name=action value=move>";
73 73
     row2(tra("Destination thread ID:"), "<input name=\"threadid\">");
74 74
     // TODO: display where to move the post as a dropdown instead of having to get ID
75
-} elseif (get_str('action')=="banish_user") {
75
+} elseif (get_str('action') == "banish_user") {
76 76
     $userid = get_int('userid');
77 77
     $user = BoincUser::lookup_id($userid);
78 78
     if (!$user) {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     }
81 81
     BoincForumPrefs::lookup($user);
82 82
     $x = $user->prefs->banished_until;
83
-    if ($x>time()) {
83
+    if ($x > time()) {
84 84
         error_page(tra("User is already banished"));
85 85
     }
86 86
     row1(tra("Banish user"));
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     echo "<input type=\"hidden\" name=\"id\" value=\"".$postid."\">\n";
99 99
     echo "<input type=\"hidden\" name=\"userid\" value=\"".$userid."\">\n";
100 100
     echo "<input type=\"hidden\" name=\"confirmed\" value=\"yes\">\n";
101
-} elseif (get_str('action')=="delete") {
101
+} elseif (get_str('action') == "delete") {
102 102
     echo "<input type=hidden name=action value=delete>";
103 103
     row2(
104 104
         "Are you sure want to delete this post?  This cannot be undone.",
Please login to merge, or discard this patch.
html/user/forum_search_action.php 1 patch
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.
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.
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/project.sample/project.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 //define("STYLESHEET", "aaa.css");
46 46
 //define("STYLESHEET2", "bbb.css");
47 47
 //define("SHORTCUT_ICON", "f.gif");     // browser tab icon
48
-define('DARK_MODE', true);      // enable dark mode if selected by user
48
+define('DARK_MODE', true); // enable dark mode if selected by user
49 49
 
50 50
 //-------------- enable/disable web features
51 51
 
52 52
 define('UNIQUE_USER_NAME', true);
53 53
 define("FORUM_QA_MERGED_MODE", true);
54 54
     // Set to true to merge Message boards and Q&A section
55
-define ("DISABLE_PROFILES", true);
55
+define("DISABLE_PROFILES", true);
56 56
     // enable profiles only after enabling reCAPTCHA
57 57
     // https://github.com/BOINC/boinc/wiki/ProtectionFromSpam
58 58
 define("USE_STOPFORUMSPAM", true);
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
     </ol>", PROJECT);
194 194
 }
195 195
 
196
-function project_workunit($wu){
196
+function project_workunit($wu) {
197 197
     // shown in the workunit page
198 198
 }
199 199
 
200
-function project_user_summary($user){
200
+function project_user_summary($user) {
201 201
     // shown in the user summary page
202 202
 }
203 203
 
204
-function project_user_page_private($user){
204
+function project_user_page_private($user) {
205 205
     // shown in the private account page
206 206
 }
207 207
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     array("name" => "Uppercase", "short_name" => "UC", "appids" => array(1, 25)),
285 285
 );
286 286
 
287
-function project_user_credit($user){
287
+function project_user_credit($user) {
288 288
     global $sub_projects;
289 289
     foreach ($sub_projects as $sp) {
290 290
         show_app_credit_user($user, $sp["name"], $sp["appids"]);
Please login to merge, or discard this patch.