@@ -7,7 +7,7 @@ |
||
7 | 7 | // add other criteria like # of countries (based on IP addr) |
8 | 8 | // consider only hosts with recent last RPC time |
9 | 9 | |
10 | -define ('MAX_HOSTS', 100); |
|
10 | +define('MAX_HOSTS', 100); |
|
11 | 11 | |
12 | 12 | require_once('../inc/boinc_db.inc'); |
13 | 13 |
@@ -24,7 +24,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | function page_link($url, $page_num, $items_per_page, $text) { |
254 | - return " <a href=\"$url&start=" . $page_num*$items_per_page . "\">$text</a> "; |
|
254 | + return " <a href=\"$url&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 |
||
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")." · " |
276 | 276 | ); |
277 | 277 | } |
@@ -286,8 +286,8 @@ discard block |
||
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 |
||
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 .= " · "; |
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 | " · ".tra("Next") |
314 | 314 | ); |
315 | 315 | } |
@@ -330,7 +330,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,24 +584,24 @@ discard block |
||
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 | - $fstatus.="<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
592 | + $fstatus .= "<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
593 | 593 | $is_posted_by_special = true; |
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | 597 | // Highlight special users if set in prefs; |
598 | 598 | // |
599 | - if ($logged_in_user && $logged_in_user->prefs){ |
|
599 | + if ($logged_in_user && $logged_in_user->prefs) { |
|
600 | 600 | $highlight = $logged_in_user->prefs->highlight_special && $is_posted_by_special; |
601 | 601 | } else { |
602 | 602 | $highlight = $is_posted_by_special; |
603 | 603 | } |
604 | - $class = $highlight?' style="border-left: 5px solid LightGreen" ':''; |
|
604 | + $class = $highlight ? ' style="border-left: 5px solid LightGreen" ' : ''; |
|
605 | 605 | |
606 | 606 | // row and start of author col |
607 | 607 | // |
@@ -613,12 +613,12 @@ discard block |
||
613 | 613 | |
614 | 614 | echo user_links($user, 0, 30); |
615 | 615 | echo "<br>"; |
616 | - if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."<br>"; |
|
616 | + if ($user->create_time > time() - ST_NEW_TIME) $fstatus .= ST_NEW."<br>"; |
|
617 | 617 | echo "<span class=\"small\">"; |
618 | 618 | if ($fstatus) echo "$fstatus"; |
619 | 619 | |
620 | - if (!$filter || !$ignore_poster){ |
|
621 | - if ($user->prefs && $user->prefs->avatar!="" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars==false))) { |
|
620 | + if (!$filter || !$ignore_poster) { |
|
621 | + if ($user->prefs && $user->prefs->avatar != "" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars == false))) { |
|
622 | 622 | echo "<img width=\"".AVATAR_WIDTH."\" height=\"".AVATAR_HEIGHT."\" src=\"".avatar_url($user->prefs->avatar)."\" alt=\"Avatar\"><br>"; |
623 | 623 | } |
624 | 624 | } |
@@ -626,14 +626,14 @@ discard block |
||
626 | 626 | |
627 | 627 | $url = "pm.php?action=new&userid=".$user->id; |
628 | 628 | $name = $user->name; |
629 | - show_button_small($url, tra("Send message"), tra("Send %1 a private message",$name)); |
|
629 | + show_button_small($url, tra("Send message"), tra("Send %1 a private message", $name)); |
|
630 | 630 | echo '<br>'.tra("Joined: %1", gmdate('j M y', $user->create_time)), "<br>"; |
631 | 631 | |
632 | 632 | if (!isset($user->nposts)) { |
633 | 633 | $user->nposts = BoincPost::count("user=$user->id"); |
634 | 634 | } |
635 | 635 | |
636 | - if (function_exists('project_forum_user_info')){ |
|
636 | + if (function_exists('project_forum_user_info')) { |
|
637 | 637 | project_forum_user_info($user); |
638 | 638 | } else { |
639 | 639 | echo tra("Posts: %1", $user->nposts)."<br>"; |
@@ -642,8 +642,8 @@ discard block |
||
642 | 642 | // |
643 | 643 | //echo "ID: ".$user->id."<br>"; |
644 | 644 | if (!NO_COMPUTING) { |
645 | - echo tra("Credit: %1", number_format($user->total_credit)) ."<br>"; |
|
646 | - echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
645 | + echo tra("Credit: %1", number_format($user->total_credit))."<br>"; |
|
646 | + echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | // to use this feature: |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | echo "<form action=\"forum_rate.php?post=", $post->id, "\" method=\"post\">"; |
673 | 673 | } |
674 | 674 | |
675 | - if ($logged_in_user && $post->timestamp > $latest_viewed){ |
|
675 | + if ($logged_in_user && $post->timestamp > $latest_viewed) { |
|
676 | 676 | show_image(NEW_IMAGE, tra("You haven't read this message yet"), tra("Unread"), NEW_IMAGE_HEIGHT); |
677 | 677 | } |
678 | 678 | |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | if ($post->modified) { |
693 | 693 | echo "<br>".tra("Last modified: %1", pretty_time_Str($post->modified)); |
694 | 694 | } |
695 | - if ($ignore_poster && $filter){ |
|
696 | - echo "<br>" .tra( |
|
695 | + if ($ignore_poster && $filter) { |
|
696 | + echo "<br>".tra( |
|
697 | 697 | "This post is hidden because the sender is on your 'ignore' list. Click %1 here %2 to view hidden posts", |
698 | 698 | "<a href=\"?id=".$thread->id."&filter=false&start=$start#".$post->id."\">", |
699 | 699 | "</a>" |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | <p> |
707 | 707 | "; |
708 | 708 | |
709 | - if (!$filter || !$ignore_poster){ |
|
709 | + if (!$filter || !$ignore_poster) { |
|
710 | 710 | $posttext = $post->content; |
711 | 711 | |
712 | 712 | // If the creator of this post has a signature and |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | // user has signatures enabled: show it |
715 | 715 | // |
716 | 716 | $posttext = output_transform($posttext, $options); |
717 | - if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)){ |
|
717 | + if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)) { |
|
718 | 718 | $sig = output_transform($user->prefs->signature, $options); |
719 | 719 | $posttext .= "<hr>$sig\n"; |
720 | 720 | } |
@@ -748,10 +748,10 @@ discard block |
||
748 | 748 | } |
749 | 749 | if (($controls == FORUM_CONTROLS) && (can_reply($thread, $forum, $logged_in_user))) { |
750 | 750 | echo " "; |
751 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "&no_quote=1#input"; |
|
751 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."&no_quote=1#input"; |
|
752 | 752 | // "Reply" is used as a verb |
753 | 753 | show_button($url, tra("Reply"), tra("Post a reply to this message")); |
754 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "#input"; |
|
754 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."#input"; |
|
755 | 755 | // "Quote" is used as a verb |
756 | 756 | show_button($url, tra("Quote"), tra("Post a reply by quoting this message")); |
757 | 757 | } |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $content = output_transform($post->content, $options); |
774 | 774 | $when = time_diff_str($post->timestamp, time()); |
775 | 775 | $user = BoincUser::lookup_id($post->user); |
776 | - if (!$user){ |
|
776 | + if (!$user) { |
|
777 | 777 | return; |
778 | 778 | } |
779 | 779 | |
@@ -787,10 +787,10 @@ discard block |
||
787 | 787 | switch ($forum->parent_type) { |
788 | 788 | case 0: |
789 | 789 | $category = BoincCategory::lookup_id($forum->category); |
790 | - $title= forum_title($category, $forum, $thread, true); |
|
790 | + $title = forum_title($category, $forum, $thread, true); |
|
791 | 791 | break; |
792 | 792 | case 1: |
793 | - $title= team_forum_title($forum); |
|
793 | + $title = team_forum_title($forum); |
|
794 | 794 | break; |
795 | 795 | } |
796 | 796 | row_array([ |
@@ -828,9 +828,9 @@ discard block |
||
828 | 828 | function post_rules() { |
829 | 829 | if (defined('FORUM_RULES')) return FORUM_RULES; |
830 | 830 | if (function_exists("project_forum_post_rules")) { |
831 | - $project_rules=project_forum_post_rules(); |
|
831 | + $project_rules = project_forum_post_rules(); |
|
832 | 832 | } else { |
833 | - $project_rules=""; |
|
833 | + $project_rules = ""; |
|
834 | 834 | } |
835 | 835 | return sprintf(" |
836 | 836 | <ul> |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | ); |
860 | 860 | } |
861 | 861 | |
862 | -function post_warning($forum=null) { |
|
862 | +function post_warning($forum = null) { |
|
863 | 863 | $x = '<p><div style="text-align:left">'; |
864 | 864 | |
865 | 865 | // let projects add extra instructions in specific forums, |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | $content = substr($content, 0, 64000); |
946 | 946 | $content = BoincDb::escape_string($content); |
947 | 947 | $now = time(); |
948 | - $sig = $signature?1:0; |
|
948 | + $sig = $signature ? 1 : 0; |
|
949 | 949 | $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)"); |
950 | 950 | if (!$id) { |
951 | 951 | $forum_error = "Failed to add post to DB."; |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | // |
966 | 966 | function update_thread_timestamp($thread) { |
967 | 967 | $posts = BoincPost::enum("thread=$thread->id and hidden=0 order by timestamp desc limit 1"); |
968 | - if (count($posts)>0) { |
|
968 | + if (count($posts) > 0) { |
|
969 | 969 | $post = $posts[0]; |
970 | 970 | $thread->update("timestamp=$post->timestamp"); |
971 | 971 | } |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | |
974 | 974 | function update_forum_timestamp($forum) { |
975 | 975 | $threads = BoincThread::enum("forum=$forum->id and hidden=0 order by timestamp desc limit 1"); |
976 | - if (count($threads)>0) { |
|
976 | + if (count($threads) > 0) { |
|
977 | 977 | $thread = $threads[0]; |
978 | 978 | $forum->update("timestamp=$thread->timestamp"); |
979 | 979 | } |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | if (is_news_forum($forum) && !$export) { |
997 | 997 | $status = 1; |
998 | 998 | } |
999 | - $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)"); |
|
999 | + $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)"); |
|
1000 | 1000 | if (!$id) { |
1001 | 1001 | $forum_error = "Failed to add thread to DB."; |
1002 | 1002 | return null; |
@@ -1125,22 +1125,22 @@ discard block |
||
1125 | 1125 | // $sticky - bool (not directly passed to SQL) |
1126 | 1126 | // |
1127 | 1127 | function get_forum_threads( |
1128 | - $forumID, $start=-1, $nRec=-1, $sort_style=MODIFIED_NEW, |
|
1128 | + $forumID, $start = -1, $nRec = -1, $sort_style = MODIFIED_NEW, |
|
1129 | 1129 | $show_hidden = 0, $sticky = 1 |
1130 | 1130 | ) { |
1131 | 1131 | //if (! (is_numeric($forumID) && is_numeric($min) && is_numeric($nRec))) { |
1132 | 1132 | // return NULL; // Something is wrong here. |
1133 | 1133 | //} |
1134 | 1134 | |
1135 | - $sql = 'forum = ' . $forumID ; |
|
1135 | + $sql = 'forum = '.$forumID; |
|
1136 | 1136 | $stickysql = ""; |
1137 | - if ($sticky){ |
|
1137 | + if ($sticky) { |
|
1138 | 1138 | $stickysql = "sticky DESC, "; |
1139 | 1139 | } |
1140 | 1140 | if (!$show_hidden) { |
1141 | 1141 | $sql .= ' AND hidden = 0'; |
1142 | 1142 | } |
1143 | - switch($sort_style) { |
|
1143 | + switch ($sort_style) { |
|
1144 | 1144 | case MODIFIED_NEW: |
1145 | 1145 | $sql .= ' ORDER BY '.$stickysql.'timestamp DESC'; |
1146 | 1146 | break; |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | if (!$show_hidden) { |
1194 | 1194 | $sql .= ' AND hidden = 0'; |
1195 | 1195 | } |
1196 | - switch($sort_style) { |
|
1196 | + switch ($sort_style) { |
|
1197 | 1197 | case CREATE_TIME_NEW: |
1198 | 1198 | $sql .= ' ORDER BY timestamp desc'; |
1199 | 1199 | break; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | // |
1216 | 1216 | function show_post_moderation_links( |
1217 | 1217 | $config, $logged_in_user, $post, $forum, $tokens |
1218 | -){ |
|
1218 | +) { |
|
1219 | 1219 | $moderators_allowed_to_ban = parse_bool($config, "moderators_allowed_to_ban"); |
1220 | 1220 | $moderators_vote_to_ban = parse_bool($config, "moderators_vote_to_ban"); |
1221 | 1221 | |
@@ -1302,14 +1302,14 @@ discard block |
||
1302 | 1302 | // We do not tell the (ab)user how much this is - |
1303 | 1303 | // no need to make it easy for them to break the system. |
1304 | 1304 | // |
1305 | - if ($user->total_credit<$forum->post_min_total_credit || $user->expavg_credit<$forum->post_min_expavg_credit) { |
|
1305 | + if ($user->total_credit < $forum->post_min_total_credit || $user->expavg_credit < $forum->post_min_expavg_credit) { |
|
1306 | 1306 | 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)); |
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | // If the user is posting faster than forum regulations allow |
1310 | 1310 | // Tell the user to wait a while before creating any more posts |
1311 | 1311 | // |
1312 | - if (time()-$user->prefs->last_post <$forum->post_min_interval) { |
|
1312 | + if (time() - $user->prefs->last_post < $forum->post_min_interval) { |
|
1313 | 1313 | error_page(tra("You cannot create threads right now. Please wait before trying again. This is to protect against abuse of the system.")); |
1314 | 1314 | } |
1315 | 1315 | } |
@@ -1335,10 +1335,10 @@ discard block |
||
1335 | 1335 | // - edit their posts at any time |
1336 | 1336 | // - hide/unhide/move threads and posts |
1337 | 1337 | |
1338 | -function is_moderator($user, $forum=null) { |
|
1338 | +function is_moderator($user, $forum = null) { |
|
1339 | 1339 | if (!$user) return false; |
1340 | 1340 | BoincForumPrefs::lookup($user); |
1341 | - $type = $forum?$forum->parent_type:0; |
|
1341 | + $type = $forum ? $forum->parent_type : 0; |
|
1342 | 1342 | switch ($type) { |
1343 | 1343 | case 0: |
1344 | 1344 | if ($user->prefs->privilege(S_MODERATOR)) return true; |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | return false; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | -function thread_list_header($subscriptions=false) { |
|
1358 | +function thread_list_header($subscriptions = false) { |
|
1359 | 1359 | if ($subscriptions) { |
1360 | 1360 | $x = [ |
1361 | 1361 | tra("Thread"), |
@@ -1378,13 +1378,13 @@ discard block |
||
1378 | 1378 | // show a 1-line summary of thread and its forum. |
1379 | 1379 | // Used for search results and subscription list |
1380 | 1380 | // |
1381 | -function thread_list_item($thread, $user, $subscriptions=false) { |
|
1381 | +function thread_list_item($thread, $user, $subscriptions = false) { |
|
1382 | 1382 | $thread_forum = BoincForum::lookup_id($thread->forum); |
1383 | 1383 | if (!$thread_forum) return; |
1384 | 1384 | if (!is_forum_visible_to_user($thread_forum, $user)) return; |
1385 | 1385 | $owner = BoincUser::lookup_id($thread->owner); |
1386 | 1386 | if (!$owner) return; |
1387 | - switch($thread_forum->parent_type) { |
|
1387 | + switch ($thread_forum->parent_type) { |
|
1388 | 1388 | case 0: |
1389 | 1389 | $category = BoincCategory::lookup_id($thread_forum->category); |
1390 | 1390 | $title = forum_title($category, $thread_forum, $thread, true); |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | } else { |
1406 | 1406 | $x = [ |
1407 | 1407 | $title, |
1408 | - $thread->replies+1, |
|
1408 | + $thread->replies + 1, |
|
1409 | 1409 | user_links($owner), |
1410 | 1410 | $thread->views, |
1411 | 1411 | time_diff_str($thread->timestamp, time()) |
@@ -1440,13 +1440,13 @@ discard block |
||
1440 | 1440 | |
1441 | 1441 | function subscribed_thread_web_line($notify) { |
1442 | 1442 | $thread = BoincThread::lookup_id($notify->opaque); |
1443 | - return tra("New posts in the thread %1","<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
1443 | + return tra("New posts in the thread %1", "<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | function subscribed_thread_rss($notify) { |
1447 | 1447 | $thread = BoincThread::lookup_id($notify->opaque); |
1448 | 1448 | $title = tra("New posts in subscribed thread"); |
1449 | - $msg = tra("There are new posts in the thread '%1'",$thread->title); |
|
1449 | + $msg = tra("There are new posts in the thread '%1'", $thread->title); |
|
1450 | 1450 | $url = secure_url_base()."forum_thread.php?id=$thread->id"; |
1451 | 1451 | return [$title, $msg, $url]; |
1452 | 1452 | } |
@@ -1458,13 +1458,13 @@ discard block |
||
1458 | 1458 | |
1459 | 1459 | function subscribed_forum_web_line($notify) { |
1460 | 1460 | $forum = BoincForum::lookup_id($notify->opaque); |
1461 | - return tra("New threads in the forum %1","<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
1461 | + return tra("New threads in the forum %1", "<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | function subscribed_forum_rss($notify) { |
1465 | 1465 | $forum = BoincForum::lookup_id($notify->opaque); |
1466 | 1466 | $title = tra("New posts in subscribed forum"); |
1467 | - $msg = tra("There are new threads in the forum '%1'",$forum->title); |
|
1467 | + $msg = tra("There are new threads in the forum '%1'", $forum->title); |
|
1468 | 1468 | $url = secure_url_base()."forum_forum.php?id=$forum->id"; |
1469 | 1469 | return [$title, $msg, $url]; |
1470 | 1470 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | // show a forum. |
27 | 27 | // $user is null if not logged in |
28 | 28 | // |
29 | -function forum_page($forum, $user, $msg=null) { |
|
29 | +function forum_page($forum, $user, $msg = null) { |
|
30 | 30 | global $forum_sort_styles; |
31 | 31 | |
32 | 32 | if (DISABLE_FORUMS) { |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | |
54 | 54 | if (!$sort_style) { |
55 | 55 | // get the sort style either from the logged in user or a cookie |
56 | - if ($user){ |
|
56 | + if ($user) { |
|
57 | 57 | $sort_style = $user->prefs->forum_sorting; |
58 | 58 | } else { |
59 | 59 | list($sort_style, $thread_style) = parse_forum_cookie(); |
60 | 60 | } |
61 | 61 | } else { |
62 | 62 | // set the sort style |
63 | - if ($user){ |
|
63 | + if ($user) { |
|
64 | 64 | $user->prefs->forum_sorting = $sort_style; |
65 | 65 | $user->prefs->update("forum_sorting=$sort_style"); |
66 | 66 | } else { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | echo "<td><a href=\"forum_thread.php?id=$thread->id\">$title</a><br></td>"; |
249 | 249 | |
250 | 250 | echo ' |
251 | - <td>'.($thread->replies+1).'</td> |
|
251 | + <td>'.($thread->replies + 1).'</td> |
|
252 | 252 | <td>'.user_links($owner, BADGE_HEIGHT_SMALL).'</td> |
253 | 253 | <td>'.$thread->views.'</td> |
254 | 254 | <td>'.time_diff_str($thread->timestamp, time()).'</td> |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | flush(); |
258 | 258 | } |
259 | 259 | end_table(); |
260 | - echo "<br>$page_nav"; // show page links |
|
260 | + echo "<br>$page_nav"; // show page links |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | $id = get_int("id"); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | if ($n === false) return ''; |
34 | 34 | $m = strpos($p, ']', $n); |
35 | 35 | if ($m === false) return ''; |
36 | - $x = substr($p, $n+5, $m-$n-5); |
|
36 | + $x = substr($p, $n + 5, $m - $n - 5); |
|
37 | 37 | |
38 | 38 | $n = strpos($x, ' '); |
39 | 39 | if ($n !== false) return substr($x, 0, $n); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if ($n === false) return ''; |
48 | 48 | $m = strpos($p, ']', $n); |
49 | 49 | if ($m === false) return ''; |
50 | - $x = substr($p, $n+5, $m-$n-5); |
|
50 | + $x = substr($p, $n + 5, $m - $n - 5); |
|
51 | 51 | $n = strpos($x, '_'); |
52 | 52 | if ($n !== false) return substr($x, 0, $n); |
53 | 53 | $n = strpos($x, 'r'); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | function main() { |
59 | 59 | global $max_days; |
60 | - $t = time()-$max_days*86400; |
|
60 | + $t = time() - $max_days*86400; |
|
61 | 61 | $hosts = BoincHost::enum("rpc_time>$t"); |
62 | 62 | $descs = []; |
63 | 63 | foreach ($hosts as $host) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | // show list of BUDA apps and variants, |
33 | 33 | // w/ buttons for adding and deleting |
34 | 34 | // |
35 | -function app_list($notice=null) { |
|
35 | +function app_list($notice = null) { |
|
36 | 36 | global $buda_root; |
37 | 37 | if (!is_dir($buda_root)) { |
38 | 38 | mkdir($buda_root); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $dir = "$buda_root/$app/$variant"; |
103 | 103 | start_table(); |
104 | 104 | table_header('name', 'size', 'md5'); |
105 | - foreach(scandir($dir) as $f) { |
|
105 | + foreach (scandir($dir) as $f) { |
|
106 | 106 | if ($f[0] == '.') continue; |
107 | 107 | [$md5, $size] = parse_info_file("$dir/.md5/$f"); |
108 | 108 | table_row( |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | // Intended to be subclassed (e.g., BoincDb, BossaDb) |
23 | 23 | // |
24 | 24 | class DbConn { |
25 | - var $db_conn; // a mysqli object |
|
26 | - var $db_name; // the DB name |
|
25 | + var $db_conn; // a mysqli object |
|
26 | + var $db_name; // the DB name |
|
27 | 27 | |
28 | 28 | function init_conn($user, $passwd, $host, $name) { |
29 | 29 | $x = explode(":", $host); |
30 | - if (sizeof($x)>1) { |
|
30 | + if (sizeof($x) > 1) { |
|
31 | 31 | $host = $x[0]; |
32 | 32 | $port = $x[1]; |
33 | 33 | } else { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | try { |
37 | 37 | $this->db_conn = @new mysqli($host, $user, $passwd, $name, $port); |
38 | - } catch(Exception $e) { |
|
38 | + } catch (Exception $e) { |
|
39 | 39 | return false; |
40 | 40 | } |
41 | 41 | if (mysqli_connect_error()) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return $this->enum_general($classname, $query); |
137 | 137 | } |
138 | 138 | |
139 | - function enum($table, $classname, $where_clause=null, $order_clause=null) { |
|
139 | + function enum($table, $classname, $where_clause = null, $order_clause = null) { |
|
140 | 140 | return self::enum_fields( |
141 | 141 | $table, $classname, '*', $where_clause, $order_clause |
142 | 142 | ); |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | if ($x) return (double)$x->$field; |
182 | 182 | return false; |
183 | 183 | } |
184 | - function count($table, $clause="TRUE") { |
|
184 | + function count($table, $clause = "TRUE") { |
|
185 | 185 | $query = "select count(*) as total from DBNAME.$table where $clause"; |
186 | 186 | return $this->get_int($query, 'total'); |
187 | 187 | } |
188 | - function sum($table, $field, $clause="") { |
|
188 | + function sum($table, $field, $clause = "") { |
|
189 | 189 | $query = "select sum($field) as total from DBNAME.$table $clause"; |
190 | 190 | return $this->get_double($query, 'total'); |
191 | 191 | } |
192 | - function max($table, $field, $clause="") { |
|
192 | + function max($table, $field, $clause = "") { |
|
193 | 193 | $query = "select max($field) as total from DBNAME.$table $clause"; |
194 | 194 | return $this->get_double($query, 'total'); |
195 | 195 | } |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | return file_exists("$d/stop_sched"); |
57 | 57 | } |
58 | 58 | |
59 | -function xml_error($num=-1, $msg=null, $file=null, $line=null) { |
|
59 | +function xml_error($num = -1, $msg = null, $file = null, $line = null) { |
|
60 | 60 | global $xml_outer_tag; |
61 | 61 | if (!$msg) { |
62 | - switch($num) { |
|
62 | + switch ($num) { |
|
63 | 63 | case -112: $msg = "Invalid XML"; break; |
64 | 64 | case -136: $msg = "Not found"; break; |
65 | 65 | case -137: $msg = "Name or email address is not unique"; break; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // If it's a single-tag element, and it's present, just return the tag |
106 | 106 | // |
107 | 107 | function parse_element($xml, $tag) { |
108 | - $closetag = "</" . substr($tag,1); |
|
108 | + $closetag = "</".substr($tag, 1); |
|
109 | 109 | $x = strstr($xml, $tag); |
110 | 110 | if ($x) { |
111 | 111 | if (strstr($tag, "/>")) return $tag; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | |
122 | 122 | function parse_next_element($xml, $tag, &$cursor) { |
123 | 123 | $element = null; |
124 | - $closetag = "</" . substr($tag,1); |
|
125 | - $pos = substr($xml,$cursor); |
|
124 | + $closetag = "</".substr($tag, 1); |
|
125 | + $pos = substr($xml, $cursor); |
|
126 | 126 | $x = strstr($pos, $tag); |
127 | 127 | if ($x) { |
128 | 128 | if (strstr($tag, "/>")) return $tag; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if ($template) { |
60 | 60 | $t = (double)$template->workunit->rsc_fpops_est; |
61 | 61 | } |
62 | - foreach($r->batch->job as $job) { |
|
62 | + foreach ($r->batch->job as $job) { |
|
63 | 63 | $y = (double)$job->rsc_fpops_est; |
64 | 64 | if ($y) { |
65 | 65 | $x += $y; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | function est_elapsed_time($r, $template) { |
86 | 86 | // crude estimate: batch FLOPs / project FLOPS |
87 | 87 | // |
88 | - return batch_flop_count($r, $template) / project_flops(); |
|
88 | + return batch_flop_count($r, $template)/project_flops(); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // if batch-level input template filename was given, read it; |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | // |
96 | 96 | function read_input_template($app, $r) { |
97 | 97 | if ((isset($r->batch)) && (isset($r->batch->workunit_template_file)) && ($r->batch->workunit_template_file)) { |
98 | - $path = project_dir() . "/templates/".$r->batch->workunit_template_file; |
|
98 | + $path = project_dir()."/templates/".$r->batch->workunit_template_file; |
|
99 | 99 | } else { |
100 | - $path = project_dir() . "/templates/$app->name"."_in"; |
|
100 | + $path = project_dir()."/templates/$app->name"."_in"; |
|
101 | 101 | } |
102 | 102 | if (file_exists($path)) { |
103 | 103 | $x = simplexml_load_file($path); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | function validate_batch($jobs, $template) { |
146 | 146 | $i = 0; |
147 | 147 | $n = count($template->file_info); |
148 | - foreach($jobs as $job) { |
|
148 | + foreach ($jobs as $job) { |
|
149 | 149 | $m = count($job->input_files); |
150 | 150 | if ($n != $m) { |
151 | 151 | log_write("wrong # of input files for job $i: need $n, got $m"); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // stage all the files |
215 | 215 | // |
216 | 216 | function stage_files(&$jobs, $user) { |
217 | - foreach($jobs as $job) { |
|
217 | + foreach ($jobs as $job) { |
|
218 | 218 | foreach ($job->input_files as $file) { |
219 | 219 | if ($file->mode != "remote") { |
220 | 220 | $file->name = stage_file($file, $user); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // |
228 | 228 | function submit_jobs( |
229 | 229 | $jobs, $job_params, $app, $batch_id, $priority, $app_version_num, |
230 | - $input_template_filename, // batch-level; can also specify per job |
|
230 | + $input_template_filename, // batch-level; can also specify per job |
|
231 | 231 | $output_template_filename, |
232 | 232 | $user |
233 | 233 | ) { |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | // one line per job |
238 | 238 | // |
239 | 239 | $x = ""; |
240 | - foreach($jobs as $job) { |
|
240 | + foreach ($jobs as $job) { |
|
241 | 241 | if ($job->name) { |
242 | 242 | $x .= " --wu_name $job->name"; |
243 | 243 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $x .= "\n"; |
273 | 273 | } |
274 | 274 | |
275 | - $cmd = "cd " . project_dir() . "; ./bin/create_work --appname $app->name --batch $batch_id"; |
|
275 | + $cmd = "cd ".project_dir()."; ./bin/create_work --appname $app->name --batch $batch_id"; |
|
276 | 276 | |
277 | 277 | if ($user->seti_id) { |
278 | 278 | $cmd .= " --target_user $user->id "; |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | // |
381 | 381 | function xml_get_jobs($r) { |
382 | 382 | $jobs = array(); |
383 | - foreach($r->batch->job as $j) { |
|
383 | + foreach ($r->batch->job as $j) { |
|
384 | 384 | $job = new StdClass; |
385 | 385 | $job->input_files = array(); |
386 | 386 | $job->command_line = (string)$j->command_line; |
@@ -431,16 +431,16 @@ discard block |
||
431 | 431 | // |
432 | 432 | function logical_end_time($r, $jobs, $user, $app) { |
433 | 433 | $total_flops = 0; |
434 | - foreach($jobs as $job) { |
|
434 | + foreach ($jobs as $job) { |
|
435 | 435 | //print_r($job); |
436 | 436 | if ($job->rsc_fpops_est) { |
437 | 437 | $total_flops += $job->rsc_fpops_est; |
438 | 438 | } else if ($job->input_template && $job->input_template->workunit->rsc_fpops_est) { |
439 | - $total_flops += (double) $job->input_template->workunit->rsc_fpops_est; |
|
439 | + $total_flops += (double)$job->input_template->workunit->rsc_fpops_est; |
|
440 | 440 | } else if ($r->batch->job_params->rsc_fpops_est) { |
441 | - $total_flops += (double) $r->batch->job_params->rsc_fpops_est; |
|
441 | + $total_flops += (double)$r->batch->job_params->rsc_fpops_est; |
|
442 | 442 | } else { |
443 | - $x = (double) $template->workunit->rsc_fpops_est; |
|
443 | + $x = (double)$template->workunit->rsc_fpops_est; |
|
444 | 444 | if ($x) { |
445 | 445 | $total_flops += $x; |
446 | 446 | } else { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | } |
449 | 449 | } |
450 | 450 | } |
451 | - $cmd = "cd " . project_dir() . "/bin; ./adjust_user_priority --user $user->id --flops $total_flops --app $app->name"; |
|
451 | + $cmd = "cd ".project_dir()."/bin; ./adjust_user_priority --user $user->id --flops $total_flops --app $app->name"; |
|
452 | 452 | $x = exec($cmd); |
453 | 453 | if (!is_numeric($x) || (double)$x == 0) { |
454 | 454 | xml_error(-1, "$cmd returned $x"); |
@@ -533,15 +533,15 @@ discard block |
||
533 | 533 | } |
534 | 534 | |
535 | 535 | $job_params = new StdClass; |
536 | - $job_params->rsc_disk_bound = (double) $r->batch->job_params->rsc_disk_bound; |
|
537 | - $job_params->rsc_fpops_est = (double) $r->batch->job_params->rsc_fpops_est; |
|
538 | - $job_params->rsc_fpops_bound = (double) $r->batch->job_params->rsc_fpops_bound; |
|
539 | - $job_params->rsc_memory_bound = (double) $r->batch->job_params->rsc_memory_bound; |
|
540 | - $job_params->delay_bound = (double) $r->batch->job_params->delay_bound; |
|
536 | + $job_params->rsc_disk_bound = (double)$r->batch->job_params->rsc_disk_bound; |
|
537 | + $job_params->rsc_fpops_est = (double)$r->batch->job_params->rsc_fpops_est; |
|
538 | + $job_params->rsc_fpops_bound = (double)$r->batch->job_params->rsc_fpops_bound; |
|
539 | + $job_params->rsc_memory_bound = (double)$r->batch->job_params->rsc_memory_bound; |
|
540 | + $job_params->delay_bound = (double)$r->batch->job_params->delay_bound; |
|
541 | 541 | // could add quorum-related stuff |
542 | 542 | |
543 | - $input_template_filename = (string) $r->batch->input_template_filename; |
|
544 | - $output_template_filename = (string) $r->batch->output_template_filename; |
|
543 | + $input_template_filename = (string)$r->batch->input_template_filename; |
|
544 | + $output_template_filename = (string)$r->batch->output_template_filename; |
|
545 | 545 | // possibly empty |
546 | 546 | |
547 | 547 | submit_jobs( |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | } |
635 | 635 | |
636 | 636 | function n_outfiles($wu) { |
637 | - $path = project_dir() . "/$wu->output_template_filename"; |
|
637 | + $path = project_dir()."/$wu->output_template_filename"; |
|
638 | 638 | $r = simplexml_load_file($path); |
639 | 639 | return count($r->file_info); |
640 | 640 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | "; |
842 | 842 | if ($result->server_state == 5) { // over? |
843 | 843 | $paths = get_outfile_paths($result); |
844 | - foreach($paths as $path) { |
|
844 | + foreach ($paths as $path) { |
|
845 | 845 | if (is_file($path)) { |
846 | 846 | $size = filesize($path); |
847 | 847 | echo " <outfile> |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | } else { |
886 | 886 | $results = BoincResult::enum("workunitid=$job_id"); |
887 | 887 | foreach ($results as $r) { |
888 | - switch($r->outcome) { |
|
888 | + switch ($r->outcome) { |
|
889 | 889 | case 1: |
890 | 890 | case 3: |
891 | 891 | case 6: |
@@ -1000,8 +1000,8 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | $user = check_remote_submit_permissions($r, $app); |
1003 | - $in = file_get_contents(project_dir() . "/templates/".$app->name."_in"); |
|
1004 | - $out = file_get_contents(project_dir() . "/templates/".$app->name."_out"); |
|
1003 | + $in = file_get_contents(project_dir()."/templates/".$app->name."_in"); |
|
1004 | + $out = file_get_contents(project_dir()."/templates/".$app->name."_out"); |
|
1005 | 1005 | if ($in === false || $out === false) { |
1006 | 1006 | log_write("template file missing"); |
1007 | 1007 | xml_error(-1, "template file missing"); |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | |
1014 | 1014 | function ping($r) { |
1015 | 1015 | xml_start_tag("ping"); |
1016 | - BoincDb::get(); // errors out if DB down or web disabled |
|
1016 | + BoincDb::get(); // errors out if DB down or web disabled |
|
1017 | 1017 | echo "<success>1</success> |
1018 | 1018 | </ping> |
1019 | 1019 | "; |
@@ -1080,9 +1080,9 @@ discard block |
||
1080 | 1080 | $request_log = parse_config(get_config(), "<remote_submit_request_log>"); |
1081 | 1081 | if ($request_log) { |
1082 | 1082 | $log_dir = parse_config(get_config(), "<log_dir>"); |
1083 | - $request_log = $log_dir . "/" . $request_log; |
|
1083 | + $request_log = $log_dir."/".$request_log; |
|
1084 | 1084 | if ($file = fopen($request_log, "a")) { |
1085 | - fwrite($file, "\n<submit_rpc_handler date=\"" . date(DATE_ATOM) . "\">\n" . $_POST['request'] . "\n</submit_rpc_handler>\n"); |
|
1085 | + fwrite($file, "\n<submit_rpc_handler date=\"".date(DATE_ATOM)."\">\n".$_POST['request']."\n</submit_rpc_handler>\n"); |
|
1086 | 1086 | fclose($file); |
1087 | 1087 | } |
1088 | 1088 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if ($user->authenticator != $auth) die('bad auth'); |
52 | 52 | } |
53 | 53 | |
54 | -function do_result_aux($result, $batch, $file_num=null) { |
|
54 | +function do_result_aux($result, $batch, $file_num = null) { |
|
55 | 55 | $phys_names = get_outfile_phys_names($result); |
56 | 56 | $log_names = get_outfile_log_names($result); |
57 | 57 | if ($file_num !== null) { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $dir_path = "submit/$batch->id/$result->name"; |
72 | 72 | system("rm -r $dir_path"); |
73 | 73 | mkdir($dir_path); |
74 | - for ($i=0; $i<count($phys_names); $i++) { |
|
74 | + for ($i = 0; $i < count($phys_names); $i++) { |
|
75 | 75 | $cmd = sprintf('ln -s %s %s/%s', |
76 | 76 | upload_path($phys_names[$i]), |
77 | 77 | $dir_path, |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | -function do_result($result_id, $auth, $file_num=null) { |
|
91 | +function do_result($result_id, $auth, $file_num = null) { |
|
92 | 92 | $result = BoincResult::lookup_id($result_id); |
93 | 93 | if (!$result) die("no result $result_id"); |
94 | 94 | $workunit = BoincWorkunit::lookup_id($result->workunitid); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | system($cmd); |
136 | 136 | } else { |
137 | 137 | mkdir(sprintf('%s/%s', $dir_path, $result->name)); |
138 | - for ($i=0; $i<count($phys_names); $i++) { |
|
138 | + for ($i = 0; $i < count($phys_names); $i++) { |
|
139 | 139 | $cmd = sprintf('ln -s %s %s/%s/%s', |
140 | 140 | upload_path($phys_names[$i]), |
141 | 141 | $dir_path, |