@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | // |
34 | 34 | $config = get_config(); |
35 | 35 | global $master_url; |
36 | -$master_url = parse_config($config , "<master_url>"); |
|
36 | +$master_url = parse_config($config, "<master_url>"); |
|
37 | 37 | $recaptcha_public_key = parse_config($config, "<recaptcha_public_key>"); |
38 | 38 | $recaptcha_private_key = parse_config($config, "<recaptcha_private_key>"); |
39 | 39 | |
40 | 40 | // Set parameters to defaults if not defined in config.xml |
41 | 41 | |
42 | 42 | $x = parse_config($config, "<user_country>"); |
43 | -define('USER_COUNTRY', ($x===null)?1:(int)$x); |
|
43 | +define('USER_COUNTRY', ($x === null) ? 1 : (int)$x); |
|
44 | 44 | |
45 | 45 | $x = parse_config($config, "<user_url>"); |
46 | -define('USER_URL', ($x===null)?1:(int)$x); |
|
46 | +define('USER_URL', ($x === null) ? 1 : (int)$x); |
|
47 | 47 | |
48 | 48 | // Set parameters to defaults if not defined in project.inc |
49 | 49 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | function url_base() { |
154 | - return is_https()?secure_url_base():URL_BASE; |
|
154 | + return is_https() ?secure_url_base() : URL_BASE; |
|
155 | 155 | } |
156 | 156 | |
157 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
157 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
158 | 158 | global $master_url; |
159 | 159 | |
160 | 160 | // the following allows independent login for projects on the same server |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | $path = substr($path, 0, -1); |
166 | 166 | $path .= "_ops/"; |
167 | 167 | } |
168 | - $expire = $permanent?time()+3600*24*365:0; |
|
168 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
169 | 169 | setcookie($name, $value, $expire, $path); |
170 | 170 | } |
171 | 171 | |
172 | -function clear_cookie($name, $ops=false) { |
|
172 | +function clear_cookie($name, $ops = false) { |
|
173 | 173 | global $master_url; |
174 | 174 | $url = parse_url($master_url); |
175 | 175 | $path = $url['path']; |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | $path = substr($path, 0, -1); |
178 | 178 | $path .= "_ops/"; |
179 | 179 | } |
180 | - setcookie($name, '', time()-3600, $path); |
|
180 | + setcookie($name, '', time() - 3600, $path); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $g_logged_in_user = null; |
184 | 184 | $got_logged_in_user = false; |
185 | 185 | |
186 | -function get_logged_in_user($must_be_logged_in=true) { |
|
186 | +function get_logged_in_user($must_be_logged_in = true) { |
|
187 | 187 | global $g_logged_in_user, $got_logged_in_user; |
188 | 188 | if ($got_logged_in_user) { |
189 | 189 | // this could have been called earlier with $must_be_logged_in false |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $next_url = $_SERVER['REQUEST_URI']; |
210 | 210 | $n = strrpos($next_url, "/"); |
211 | 211 | if ($n) { |
212 | - $next_url = substr($next_url, $n+1); |
|
212 | + $next_url = substr($next_url, $n + 1); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | $next_url = urlencode($next_url); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | return $g_logged_in_user; |
221 | 221 | } |
222 | 222 | |
223 | -function show_login_info($prefix="") { |
|
223 | +function show_login_info($prefix = "") { |
|
224 | 224 | $user = get_logged_in_user(false); |
225 | 225 | if ($user) { |
226 | 226 | $url_tokens = url_tokens($user->authenticator); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | -$cache_control_extra=""; |
|
233 | +$cache_control_extra = ""; |
|
234 | 234 | $is_login_page = false; |
235 | 235 | |
236 | 236 | // Call this to start pages. |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | // with an existing web framework can more easily do so. |
243 | 243 | // To do so, define page_head() in the project include file. |
244 | 244 | // |
245 | -if (!function_exists("page_head")){ |
|
245 | +if (!function_exists("page_head")) { |
|
246 | 246 | function page_head( |
247 | 247 | $title, |
248 | 248 | // page title. Put in <title>, used as title for browser tab. |
249 | - $body_attrs=null, |
|
249 | + $body_attrs = null, |
|
250 | 250 | // <body XXXX> |
251 | 251 | // e.g. Javascript to put focus in an input field |
252 | 252 | // (onload="document.form.foo.focus()") |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | // if set, include schedulers.txt. |
256 | 256 | // also pass to project_banner() in case you want a different |
257 | 257 | // header for your main page. |
258 | - $url_prefix="", |
|
258 | + $url_prefix = "", |
|
259 | 259 | // prepend this to links. |
260 | 260 | // Use for web pages not in the top directory |
261 | - $head_extra=null |
|
261 | + $head_extra = null |
|
262 | 262 | // extra stuff to put in <head>. E.g.: |
263 | 263 | // reCAPTCHA code (create_profile.php) |
264 | 264 | // bbcode javascript (forums) |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | header("Content-type: text/html; charset=utf-8"); |
281 | 281 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
282 | 282 | // Date in the past |
283 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
283 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
284 | 284 | // always modified |
285 | 285 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
286 | 286 | // for HTTP/1.1 |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | if ($head_extra) { |
302 | 302 | echo "\n$head_extra\n"; |
303 | 303 | } |
304 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
304 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
305 | 305 | readfile("schedulers.txt"); |
306 | 306 | } |
307 | 307 | |
308 | - $t = $title?$title:PROJECT; |
|
308 | + $t = $title ? $title : PROJECT; |
|
309 | 309 | echo "<title>$t</title>\n"; |
310 | 310 | echo ' |
311 | 311 | <meta charset="utf-8"> |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | echo '<div class="container-fluid"> |
363 | 363 | '; |
364 | 364 | |
365 | - switch($title) { //kludge |
|
365 | + switch ($title) { //kludge |
|
366 | 366 | case tra("Log in"): |
367 | 367 | case tra("Create an account"): |
368 | 368 | case tra("Server status page"): |
@@ -377,13 +377,13 @@ discard block |
||
377 | 377 | |
378 | 378 | // See the comments for page_head() |
379 | 379 | // |
380 | -if (!function_exists("page_tail")){ |
|
380 | +if (!function_exists("page_tail")) { |
|
381 | 381 | function page_tail( |
382 | - $show_date=false, |
|
382 | + $show_date = false, |
|
383 | 383 | // true for pages that are generated periodically rather than on the fly |
384 | - $url_prefix="", |
|
384 | + $url_prefix = "", |
|
385 | 385 | // use for pages not at top level |
386 | - $is_main=false |
|
386 | + $is_main = false |
|
387 | 387 | // passed to project_footer; |
388 | 388 | ) { |
389 | 389 | echo "<br>\n"; |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | -function display_cvs_versions(){ |
|
401 | +function display_cvs_versions() { |
|
402 | 402 | global $cvs_version_tracker; |
403 | 403 | echo "\n<!-- SVN VERSIONS -->\n"; |
404 | - for ($i=0;$i<sizeof($cvs_version_tracker);$i++) { |
|
404 | + for ($i = 0; $i < sizeof($cvs_version_tracker); $i++) { |
|
405 | 405 | echo "<!-- ".$cvs_version_tracker[$i]." -->\n"; |
406 | 406 | } |
407 | 407 | } |
@@ -426,24 +426,24 @@ discard block |
||
426 | 426 | // convert time interval in seconds to a string of the form |
427 | 427 | // 'D days h hours m min s sec'. |
428 | 428 | |
429 | -function time_diff($x, $res=3) { |
|
429 | +function time_diff($x, $res = 3) { |
|
430 | 430 | $x = (int)$x; |
431 | 431 | $days = (int)($x/86400); |
432 | - $hours = (int)(($x-$days*86400)/3600); |
|
433 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
434 | - $seconds = $x % 60; |
|
432 | + $hours = (int)(($x - $days*86400)/3600); |
|
433 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
434 | + $seconds = $x%60; |
|
435 | 435 | |
436 | 436 | $s = ""; |
437 | 437 | if ($days) { |
438 | 438 | $s .= "$days ".tra("days")." "; |
439 | 439 | } |
440 | - if ($res>0 && ($hours || strlen($s))) { |
|
440 | + if ($res > 0 && ($hours || strlen($s))) { |
|
441 | 441 | $s .= "$hours ".tra("hours")." "; |
442 | 442 | } |
443 | - if ($res>1 && ($minutes || strlen($s))) { |
|
443 | + if ($res > 1 && ($minutes || strlen($s))) { |
|
444 | 444 | $s .= "$minutes ".tra("min")." "; |
445 | 445 | } |
446 | - if ($res>2) { |
|
446 | + if ($res > 2) { |
|
447 | 447 | $s .= "$seconds ".tra("sec")." "; |
448 | 448 | } |
449 | 449 | return $s; |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | |
458 | 458 | function time_str($x) { |
459 | 459 | if ($x == 0) return "---"; |
460 | - return gmdate('j M Y, G:i:s', (int)$x) . " UTC"; |
|
460 | + return gmdate('j M Y, G:i:s', (int)$x)." UTC"; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | function local_time_str($x) { |
@@ -469,14 +469,14 @@ discard block |
||
469 | 469 | return time_str($x); |
470 | 470 | } |
471 | 471 | |
472 | -function start_table_str($class="", $style="") { |
|
473 | - $s = $style?'style="'.$style.'"':''; |
|
472 | +function start_table_str($class = "", $style = "") { |
|
473 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
474 | 474 | return '<div class="table"> |
475 | 475 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
476 | 476 | '; |
477 | 477 | } |
478 | 478 | |
479 | -function start_table($class="", $style="") { |
|
479 | +function start_table($class = "", $style = "") { |
|
480 | 480 | echo start_table_str($class, $style); |
481 | 481 | } |
482 | 482 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | echo "</tr>\n"; |
522 | 522 | } |
523 | 523 | |
524 | -function row1($x, $ncols=2, $class="heading") { |
|
524 | +function row1($x, $ncols = 2, $class = "heading") { |
|
525 | 525 | if ($class == "heading") { |
526 | 526 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
527 | 527 | } else { |
@@ -535,10 +535,10 @@ discard block |
||
535 | 535 | |
536 | 536 | // a table row with 2 columns, with the left on right-aligned |
537 | 537 | |
538 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
539 | - if ($x==="") $x="<br>"; |
|
540 | - if ($y==="") $y="<br>"; |
|
541 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
538 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
539 | + if ($x === "") $x = "<br>"; |
|
540 | + if ($y === "") $y = "<br>"; |
|
541 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
542 | 542 | echo "<tr> |
543 | 543 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
544 | 544 | <td $attrs >$y</td> |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | // output the first part of row2(); |
550 | 550 | // then write the content, followed by </td></tr> |
551 | 551 | |
552 | -function row2_init($x, $lwidth='40%') { |
|
552 | +function row2_init($x, $lwidth = '40%') { |
|
553 | 553 | echo sprintf('<tr> |
554 | 554 | <td width="%s" %s>%s</td> |
555 | 555 | <td %s>', |
@@ -565,31 +565,31 @@ discard block |
||
565 | 565 | echo "<tr><td>$string</td></tr>"; |
566 | 566 | } |
567 | 567 | |
568 | -function row_array($x, $attrs=null) { |
|
568 | +function row_array($x, $attrs = null) { |
|
569 | 569 | echo "<tr>\n"; |
570 | 570 | $i = 0; |
571 | 571 | foreach ($x as $h) { |
572 | - $a = $attrs?$attrs[$i]:""; |
|
572 | + $a = $attrs ? $attrs[$i] : ""; |
|
573 | 573 | echo "<td $a>$h</td>\n"; |
574 | 574 | $i++; |
575 | 575 | } |
576 | 576 | echo "</tr>\n"; |
577 | 577 | } |
578 | 578 | |
579 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
579 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
580 | 580 | |
581 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
581 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
582 | 582 | echo "<tr>"; |
583 | 583 | $i = 0; |
584 | 584 | foreach ($x as $h) { |
585 | - $a = $attrs?$attrs[$i]:""; |
|
585 | + $a = $attrs ? $attrs[$i] : ""; |
|
586 | 586 | echo "<th $a class=\"$class\">$h</th>"; |
587 | 587 | $i++; |
588 | 588 | } |
589 | 589 | echo "</tr>\n"; |
590 | 590 | } |
591 | 591 | |
592 | -function row_heading($x, $class='bg-primary') { |
|
592 | +function row_heading($x, $class = 'bg-primary') { |
|
593 | 593 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
594 | 594 | ', $class, $x |
595 | 595 | ); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
650 | 650 | // is cut short. |
651 | 651 | |
652 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
652 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
653 | 653 | $words = explode($delimiter, $sentence); |
654 | 654 | $total_chars = 0; |
655 | 655 | $trunc = false; |
@@ -732,8 +732,8 @@ discard block |
||
732 | 732 | |
733 | 733 | // returns null if the arg is optional and missing |
734 | 734 | // |
735 | -function get_int($name, $optional=false) { |
|
736 | - $x=null; |
|
735 | +function get_int($name, $optional = false) { |
|
736 | + $x = null; |
|
737 | 737 | if (isset($_GET[$name])) $x = $_GET[$name]; |
738 | 738 | if (!is_numeric($x)) { |
739 | 739 | if ($optional) { |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | |
753 | 753 | // returns null if the arg is optional and missing |
754 | 754 | // |
755 | -function post_num($name, $optional=false) { |
|
755 | +function post_num($name, $optional = false) { |
|
756 | 756 | $x = null; |
757 | 757 | if (isset($_POST[$name])) $x = $_POST[$name]; |
758 | 758 | if (!is_numeric($x)) { |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | |
768 | 768 | // returns null if the arg is optional and missing |
769 | 769 | // |
770 | -function post_int($name, $optional=false) { |
|
770 | +function post_int($name, $optional = false) { |
|
771 | 771 | $x = post_num($name, $optional); |
772 | 772 | if (is_null($x)) return null; |
773 | 773 | $y = (int)$x; |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | -function get_str($name, $optional=false) { |
|
788 | +function get_str($name, $optional = false) { |
|
789 | 789 | if (isset($_GET[$name])) { |
790 | 790 | $x = $_GET[$name]; |
791 | 791 | } else { |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | return undo_magic_quotes($x); |
798 | 798 | } |
799 | 799 | |
800 | -function post_str($name, $optional=false) { |
|
800 | +function post_str($name, $optional = false) { |
|
801 | 801 | if (isset($_POST[$name])) { |
802 | 802 | $x = $_POST[$name]; |
803 | 803 | } else { |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | return undo_magic_quotes($x); |
810 | 810 | } |
811 | 811 | |
812 | -function post_arr($name, $optional=false) { |
|
812 | +function post_arr($name, $optional = false) { |
|
813 | 813 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
814 | 814 | $x = $_POST[$name]; |
815 | 815 | } else { |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | // the mb_* functions are not included by default |
826 | 826 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
827 | 827 | |
828 | - for ($i=0; $i<strlen($str); $i++) { |
|
828 | + for ($i = 0; $i < strlen($str); $i++) { |
|
829 | 829 | $c = ord(substr($str, $i)); |
830 | 830 | if ($c < 32 || $c > 127) return false; |
831 | 831 | } |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
850 | 850 | // if no value was entered and this is ok |
851 | 851 | // |
852 | - if ($number=='' && !$low) return true; |
|
852 | + if ($number == '' && !$low) return true; |
|
853 | 853 | |
854 | 854 | // the supplied value contains alphabetic characters |
855 | 855 | // |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | |
867 | 867 | // Generate a "select" element from an array of values |
868 | 868 | // |
869 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
869 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
870 | 870 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
871 | 871 | |
872 | 872 | foreach ($array as $key => $value) { |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | return $str; |
892 | 892 | } |
893 | 893 | |
894 | -function strip_bbcode($string){ |
|
895 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
894 | +function strip_bbcode($string) { |
|
895 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | function current_url() { |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | // the colors for bootstrap' btn-success are almost illegible; |
918 | 918 | // the green is too light. Use a darker green. |
919 | 919 | // |
920 | -function button_style($color='green', $font_size=null) { |
|
920 | +function button_style($color = 'green', $font_size = null) { |
|
921 | 921 | $fs = ''; |
922 | 922 | if ($font_size) { |
923 | 923 | $fs = sprintf('; font-size:%dpx', $font_size); |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | // class: class of the button, e.g. btn |
937 | 937 | // extra: Additional text in href tag |
938 | 938 | // |
939 | -function button_text($url, $text, $desc=null, $class=null, $extra='') { |
|
939 | +function button_text($url, $text, $desc = null, $class = null, $extra = '') { |
|
940 | 940 | if (!$desc) { |
941 | 941 | $desc = $text; |
942 | 942 | } |
@@ -951,19 +951,19 @@ discard block |
||
951 | 951 | ); |
952 | 952 | } |
953 | 953 | |
954 | -function show_button($url, $text, $desc=null, $class=null, $extra=null) { |
|
954 | +function show_button($url, $text, $desc = null, $class = null, $extra = null) { |
|
955 | 955 | echo button_text($url, $text, $desc, $class, $extra); |
956 | 956 | } |
957 | 957 | |
958 | 958 | // for places with a bunch of buttons, like forum posts |
959 | 959 | // |
960 | -function show_button_small($url, $text, $desc=null) { |
|
960 | +function show_button_small($url, $text, $desc = null) { |
|
961 | 961 | echo button_text($url, $text, $desc, "btn btn-xs", button_style()); |
962 | 962 | } |
963 | 963 | |
964 | 964 | // used for showing icons |
965 | 965 | // |
966 | -function show_image($src, $title, $alt, $height=null) { |
|
966 | +function show_image($src, $title, $alt, $height = null) { |
|
967 | 967 | $h = ""; |
968 | 968 | if ($height) { |
969 | 969 | $h = "height=\"$height\""; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | // tries instead to connect to <replica_db_host> if tag exists. |
1001 | 1001 | // DEPRECATED - use boinc_db.inc |
1002 | 1002 | // |
1003 | -function db_init($try_replica=false) { |
|
1003 | +function db_init($try_replica = false) { |
|
1004 | 1004 | check_web_stopped(); |
1005 | 1005 | $retval = db_init_aux($try_replica); |
1006 | 1006 | if ($retval == 1) { |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | // Check this to avoid XSS vulnerability |
1117 | 1117 | // |
1118 | 1118 | function sanitize_sort_by($x) { |
1119 | - switch($x) { |
|
1119 | + switch ($x) { |
|
1120 | 1120 | case 'expavg_credit': |
1121 | 1121 | case 'total_credit': |
1122 | 1122 | return; |
@@ -1133,9 +1133,9 @@ discard block |
||
1133 | 1133 | return $c/(200/24); |
1134 | 1134 | } |
1135 | 1135 | |
1136 | -function do_download($path,$name="") { |
|
1137 | - if (strcmp($name,"") == 0) { |
|
1138 | - $name=basename($path); |
|
1136 | +function do_download($path, $name = "") { |
|
1137 | + if (strcmp($name, "") == 0) { |
|
1138 | + $name = basename($path); |
|
1139 | 1139 | } |
1140 | 1140 | header('Content-Description: File Transfer'); |
1141 | 1141 | header('Content-Type: application/octet-stream'); |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | header('Expires: 0'); |
1145 | 1145 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1146 | 1146 | header('Pragma: public'); |
1147 | - header('Content-Length: ' . filesize($path)); |
|
1147 | + header('Content-Length: '.filesize($path)); |
|
1148 | 1148 | flush(); |
1149 | 1149 | readfile($path); |
1150 | 1150 | } |
@@ -1193,10 +1193,10 @@ discard block |
||
1193 | 1193 | // Otherwise return 0. |
1194 | 1194 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1195 | 1195 | // |
1196 | -function boinc_client_version(){ |
|
1196 | +function boinc_client_version() { |
|
1197 | 1197 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1198 | 1198 | $x = $_SERVER['HTTP_USER_AGENT']; |
1199 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1199 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1200 | 1200 | if (preg_match($e, $x, $matches)) { |
1201 | 1201 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
1202 | 1202 | } |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | $rem_name = $name."_remaining"; |
1226 | 1226 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
1227 | 1227 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
1228 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1228 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1229 | 1229 | ; |
1230 | 1230 | } |
1231 | 1231 | |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | // use the following around text with long lines, |
1256 | 1256 | // to limit the width and make it more readable. |
1257 | 1257 | // |
1258 | -function text_start($width=640) { |
|
1258 | +function text_start($width = 640) { |
|
1259 | 1259 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
1260 | 1260 | } |
1261 | 1261 | function text_end() { |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | function cert_filename() { |
1284 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
1284 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | // if user hasn't validated their email addr, tell them to |
@@ -1298,6 +1298,6 @@ discard block |
||
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | |
1301 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
1301 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
1302 | 1302 | |
1303 | 1303 | ?> |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | define('THREAD_SOLVED', 1); |
55 | 55 | |
56 | 56 | define('AVATAR_WIDTH', 100); |
57 | -define('AVATAR_HEIGHT',100); |
|
57 | +define('AVATAR_HEIGHT', 100); |
|
58 | 58 | |
59 | 59 | define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days |
60 | 60 | define('ST_NEW', 'New member'); |
61 | 61 | |
62 | -define('MAXIMUM_EDIT_TIME',3600); |
|
62 | +define('MAXIMUM_EDIT_TIME', 3600); |
|
63 | 63 | // allow edits of forums posts up till one hour after posting. |
64 | 64 | |
65 | 65 | define('MAX_FORUM_LOGGING_TIME', 2419200); //3600*24*28 - 28 days |
@@ -77,24 +77,24 @@ discard block |
||
77 | 77 | define('IMAGE_HIDDEN', 'img/hidden.png'); |
78 | 78 | define('IMAGE_STICKY_LOCKED', 'img/sticky_locked_post.png'); |
79 | 79 | define('IMAGE_POST', 'img/post.png'); |
80 | -define('NEW_IMAGE_HEIGHT','15'); |
|
80 | +define('NEW_IMAGE_HEIGHT', '15'); |
|
81 | 81 | define('EMPHASIZE_IMAGE', 'img/emphasized_post.png'); |
82 | -define('EMPHASIZE_IMAGE_HEIGHT','15'); |
|
82 | +define('EMPHASIZE_IMAGE_HEIGHT', '15'); |
|
83 | 83 | define('FILTER_IMAGE', 'img/filtered_post.png'); |
84 | -define('FILTER_IMAGE_HEIGHT','15'); |
|
84 | +define('FILTER_IMAGE_HEIGHT', '15'); |
|
85 | 85 | define('RATE_POSITIVE_IMAGE', 'img/rate_positive.png'); |
86 | -define('RATE_POSITIVE_IMAGE_HEIGHT','9'); |
|
86 | +define('RATE_POSITIVE_IMAGE_HEIGHT', '9'); |
|
87 | 87 | define('RATE_NEGATIVE_IMAGE', 'img/rate_negative.png'); |
88 | -define('RATE_NEGATIVE_IMAGE_HEIGHT','9'); |
|
88 | +define('RATE_NEGATIVE_IMAGE_HEIGHT', '9'); |
|
89 | 89 | define('REPORT_POST_IMAGE', 'img/report_post.png'); |
90 | -define('REPORT_POST_IMAGE_HEIGHT','9'); |
|
90 | +define('REPORT_POST_IMAGE_HEIGHT', '9'); |
|
91 | 91 | |
92 | 92 | define('SOLUTION', tra('This answered my question')); |
93 | 93 | define('SUFFERER', tra('I also have this question')); |
94 | 94 | define('OFF_TOPIC', tra('Off-topic')); |
95 | 95 | |
96 | -define ('DEFAULT_LOW_RATING_THRESHOLD', -25); |
|
97 | -define ('DEFAULT_HIGH_RATING_THRESHOLD', 5); |
|
96 | +define('DEFAULT_LOW_RATING_THRESHOLD', -25); |
|
97 | +define('DEFAULT_HIGH_RATING_THRESHOLD', 5); |
|
98 | 98 | |
99 | 99 | // special user attributes |
100 | 100 | // |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | |
173 | 173 | // Output the forum/thread title. |
174 | 174 | // |
175 | -function show_forum_title($category, $forum, $thread, $link_thread=false) { |
|
175 | +function show_forum_title($category, $forum, $thread, $link_thread = false) { |
|
176 | 176 | if ($category) { |
177 | 177 | $is_helpdesk = $category->is_helpdesk; |
178 | 178 | } else { |
179 | 179 | $is_helpdesk = false; |
180 | 180 | } |
181 | 181 | |
182 | - $where = $is_helpdesk?tra("Questions and Answers"):tra("Message boards"); |
|
183 | - $top_url = $is_helpdesk?"forum_help_desk.php":"forum_index.php"; |
|
182 | + $where = $is_helpdesk ?tra("Questions and Answers") : tra("Message boards"); |
|
183 | + $top_url = $is_helpdesk ? "forum_help_desk.php" : "forum_index.php"; |
|
184 | 184 | |
185 | 185 | if (!$forum && !$thread) { |
186 | 186 | echo "<span class=\"title\">$where</span>\n"; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | -function show_team_forum_title($forum, $thread=null, $link_thread=false) { |
|
211 | +function show_team_forum_title($forum, $thread = null, $link_thread = false) { |
|
212 | 212 | $team = BoincTeam::lookup_id($forum->category); |
213 | 213 | echo "<span class=title> |
214 | 214 | <a href=\"forum_index.php\">".tra("Message boards")."</a> : |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | function page_link($url, $page_num, $items_per_page, $text) { |
244 | - return " <a href=\"$url&start=" . $page_num*$items_per_page . "\">$text</a> "; |
|
244 | + return " <a href=\"$url&start=".$page_num*$items_per_page."\">$text</a> "; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // return a string for navigating pages |
248 | 248 | // |
249 | -function page_links($url, $nitems, $items_per_page, $start){ |
|
249 | +function page_links($url, $nitems, $items_per_page, $start) { |
|
250 | 250 | // How many pages to potentially show before and after this one: |
251 | 251 | $preshow = 3; |
252 | 252 | $postshow = 3; |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | $x = ""; |
255 | 255 | |
256 | 256 | if ($nitems <= $items_per_page) return ""; |
257 | - $npages = ceil($nitems / $items_per_page); |
|
258 | - $curpage = ceil($start / $items_per_page); |
|
257 | + $npages = ceil($nitems/$items_per_page); |
|
258 | + $curpage = ceil($start/$items_per_page); |
|
259 | 259 | |
260 | 260 | // If this is not the first page, display "previous" |
261 | 261 | // |
262 | - if ($curpage > 0){ |
|
262 | + if ($curpage > 0) { |
|
263 | 263 | $x .= page_link( |
264 | - $url, $curpage-1, $items_per_page, |
|
264 | + $url, $curpage - 1, $items_per_page, |
|
265 | 265 | tra("Previous")." · " |
266 | 266 | ); |
267 | 267 | } |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | } |
277 | 277 | // Display a list of pages surrounding this one |
278 | 278 | // |
279 | - for ($i=$curpage-$preshow; $i<=$curpage+$postshow; $i++){ |
|
280 | - $page_str = (string)($i+1); |
|
279 | + for ($i = $curpage - $preshow; $i <= $curpage + $postshow; $i++) { |
|
280 | + $page_str = (string)($i + 1); |
|
281 | 281 | if ($i < 0) continue; |
282 | 282 | if ($i >= $npages) break; |
283 | 283 | |
@@ -286,20 +286,20 @@ discard block |
||
286 | 286 | } else { |
287 | 287 | $x .= page_link($url, $i, $items_per_page, $page_str); |
288 | 288 | } |
289 | - if ($i == $npages-1) break; |
|
290 | - if ($i == $curpage+$postshow) break; |
|
289 | + if ($i == $npages - 1) break; |
|
290 | + if ($i == $curpage + $postshow) break; |
|
291 | 291 | $x .= " · "; |
292 | 292 | } |
293 | 293 | |
294 | - if ($curpage + $postshow < $npages-1) { |
|
294 | + if ($curpage + $postshow < $npages - 1) { |
|
295 | 295 | $x .= " . . . "; |
296 | - $x .= page_link($url, $npages-1, $items_per_page, $npages); |
|
296 | + $x .= page_link($url, $npages - 1, $items_per_page, $npages); |
|
297 | 297 | } |
298 | 298 | // If there is a next page |
299 | 299 | // |
300 | - if ($curpage < $npages-1){ |
|
300 | + if ($curpage < $npages - 1) { |
|
301 | 301 | $x .= page_link( |
302 | - $url, $curpage+1, $items_per_page, |
|
302 | + $url, $curpage + 1, $items_per_page, |
|
303 | 303 | " · ".tra("Next") |
304 | 304 | ); |
305 | 305 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | function cleanup_title($title) { |
321 | 321 | $x = sanitize_tags(bb2html($title)); |
322 | 322 | $x = trim($x); |
323 | - if (strlen($x)==0) return "(no title)"; |
|
323 | + if (strlen($x) == 0) return "(no title)"; |
|
324 | 324 | else return $x; |
325 | 325 | } |
326 | 326 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $i = 0; |
383 | 383 | foreach ($posts as $post) { |
384 | 384 | if ($post->id == $postid) { |
385 | - $start = $i - ($i % $num_to_show); |
|
385 | + $start = $i - ($i%$num_to_show); |
|
386 | 386 | $jump_to_post = $post; |
387 | 387 | break; |
388 | 388 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | // if jump to post, figure out what page to show |
410 | 410 | // |
411 | 411 | if ($jump_to_post) { |
412 | - $start = $ibest - ($ibest % $num_to_show); |
|
412 | + $start = $ibest - ($ibest%$num_to_show); |
|
413 | 413 | } else { |
414 | 414 | $start = $default_start; |
415 | 415 | } |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | // Generates a table row with two cells: author and message |
518 | 518 | // |
519 | 519 | function show_post( |
520 | - $post, $thread, $forum, $logged_in_user, $start=0, |
|
521 | - $latest_viewed=0, $controls=FORUM_CONTROLS, $filter=true |
|
520 | + $post, $thread, $forum, $logged_in_user, $start = 0, |
|
521 | + $latest_viewed = 0, $controls = FORUM_CONTROLS, $filter = true |
|
522 | 522 | ) { |
523 | 523 | global $country_to_iso3166_2; |
524 | 524 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | // If the user no longer exists, skip the post |
528 | 528 | // |
529 | - if (!$user){ |
|
529 | + if (!$user) { |
|
530 | 530 | return; |
531 | 531 | } |
532 | 532 | |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | // check whether the poster is on the list of people to ignore |
548 | 548 | // |
549 | 549 | $ignore_poster = false; |
550 | - if ($logged_in_user){ |
|
550 | + if ($logged_in_user) { |
|
551 | 551 | $tokens = url_tokens($logged_in_user->authenticator); |
552 | - if (is_ignoring($logged_in_user, $user)){ |
|
552 | + if (is_ignoring($logged_in_user, $user)) { |
|
553 | 553 | $ignore_poster = true; |
554 | 554 | } |
555 | 555 | } |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | if (is_moderator($logged_in_user, $forum)) { |
564 | 564 | $can_edit = true; |
565 | 565 | } else if (can_reply($thread, $forum, $logged_in_user)) { |
566 | - $time_limit = $post->timestamp+MAXIMUM_EDIT_TIME; |
|
567 | - $can_edit = time()<$time_limit; |
|
566 | + $time_limit = $post->timestamp + MAXIMUM_EDIT_TIME; |
|
567 | + $can_edit = time() < $time_limit; |
|
568 | 568 | } else { |
569 | 569 | $can_edit = false; |
570 | 570 | } |
@@ -574,24 +574,24 @@ discard block |
||
574 | 574 | // Print the special user lines, if any |
575 | 575 | // |
576 | 576 | global $special_user_bitfield; |
577 | - $fstatus=""; |
|
577 | + $fstatus = ""; |
|
578 | 578 | $keys = array_keys($special_user_bitfield); |
579 | 579 | $is_posted_by_special = false; |
580 | - for ($i=0; $i<sizeof($special_user_bitfield);$i++) { |
|
580 | + for ($i = 0; $i < sizeof($special_user_bitfield); $i++) { |
|
581 | 581 | if ($user->prefs && $user->prefs->privilege($keys[$i])) { |
582 | - $fstatus.="<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
582 | + $fstatus .= "<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
583 | 583 | $is_posted_by_special = true; |
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | 587 | // Highlight special users if set in prefs; |
588 | 588 | // |
589 | - if ($logged_in_user && $logged_in_user->prefs){ |
|
589 | + if ($logged_in_user && $logged_in_user->prefs) { |
|
590 | 590 | $highlight = $logged_in_user->prefs->highlight_special && $is_posted_by_special; |
591 | 591 | } else { |
592 | 592 | $highlight = $is_posted_by_special; |
593 | 593 | } |
594 | - $class = $highlight?' style="border-left: 5px solid LightGreen" ':''; |
|
594 | + $class = $highlight ? ' style="border-left: 5px solid LightGreen" ' : ''; |
|
595 | 595 | |
596 | 596 | // row and start of author col |
597 | 597 | // |
@@ -603,12 +603,12 @@ discard block |
||
603 | 603 | |
604 | 604 | echo user_links($user, 0, 30); |
605 | 605 | echo "<br>"; |
606 | - if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."<br>"; |
|
606 | + if ($user->create_time > time() - ST_NEW_TIME) $fstatus .= ST_NEW."<br>"; |
|
607 | 607 | echo "<span class=\"small\">"; |
608 | 608 | if ($fstatus) echo "$fstatus"; |
609 | 609 | |
610 | - if (!$filter || !$ignore_poster){ |
|
611 | - if ($user->prefs && $user->prefs->avatar!="" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars==false))) { |
|
610 | + if (!$filter || !$ignore_poster) { |
|
611 | + if ($user->prefs && $user->prefs->avatar != "" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars == false))) { |
|
612 | 612 | echo "<img width=\"".AVATAR_WIDTH."\" height=\"".AVATAR_HEIGHT."\" src=\"".avatar_url($user->prefs->avatar)."\" alt=\"Avatar\"><br>"; |
613 | 613 | } |
614 | 614 | } |
@@ -616,14 +616,14 @@ discard block |
||
616 | 616 | |
617 | 617 | $url = "pm.php?action=new&userid=".$user->id; |
618 | 618 | $name = $user->name; |
619 | - show_button_small($url, tra("Send message"), tra("Send %1 a private message",$name)); |
|
619 | + show_button_small($url, tra("Send message"), tra("Send %1 a private message", $name)); |
|
620 | 620 | echo '<br>'.tra("Joined: %1", gmdate('j M y', $user->create_time)), "<br>"; |
621 | 621 | |
622 | 622 | if (!isset($user->nposts)) { |
623 | 623 | $user->nposts = BoincPost::count("user=$user->id"); |
624 | 624 | } |
625 | 625 | |
626 | - if (function_exists('project_forum_user_info')){ |
|
626 | + if (function_exists('project_forum_user_info')) { |
|
627 | 627 | project_forum_user_info($user); |
628 | 628 | } else { |
629 | 629 | echo tra("Posts: %1", $user->nposts)."<br>"; |
@@ -632,8 +632,8 @@ discard block |
||
632 | 632 | // |
633 | 633 | //echo "ID: ".$user->id."<br>"; |
634 | 634 | if (!NO_COMPUTING) { |
635 | - echo tra("Credit: %1", number_format($user->total_credit)) ."<br>"; |
|
636 | - echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
635 | + echo tra("Credit: %1", number_format($user->total_credit))."<br>"; |
|
636 | + echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | // to use this feature: |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | echo "<form action=\"forum_rate.php?post=", $post->id, "\" method=\"post\">"; |
663 | 663 | } |
664 | 664 | |
665 | - if ($logged_in_user && $post->timestamp > $latest_viewed){ |
|
665 | + if ($logged_in_user && $post->timestamp > $latest_viewed) { |
|
666 | 666 | show_image(NEW_IMAGE, tra("You haven't read this message yet"), tra("Unread"), NEW_IMAGE_HEIGHT); |
667 | 667 | } |
668 | 668 | |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | if ($post->modified) { |
683 | 683 | echo "<br>".tra("Last modified: %1", pretty_time_Str($post->modified)); |
684 | 684 | } |
685 | - if ($ignore_poster && $filter){ |
|
686 | - echo "<br>" .tra( |
|
685 | + if ($ignore_poster && $filter) { |
|
686 | + echo "<br>".tra( |
|
687 | 687 | "This post is hidden because the sender is on your 'ignore' list. Click %1 here %2 to view hidden posts", |
688 | 688 | "<a href=\"?id=".$thread->id."&filter=false&start=$start#".$post->id."\">", |
689 | 689 | "</a>" |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | <p> |
697 | 697 | "; |
698 | 698 | |
699 | - if (!$filter || !$ignore_poster){ |
|
699 | + if (!$filter || !$ignore_poster) { |
|
700 | 700 | $posttext = $post->content; |
701 | 701 | |
702 | 702 | // If the creator of this post has a signature and |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | // user has signatures enabled: show it |
705 | 705 | // |
706 | 706 | $posttext = output_transform($posttext, $options); |
707 | - if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)){ |
|
707 | + if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)) { |
|
708 | 708 | $sig = output_transform($user->prefs->signature, $options); |
709 | 709 | $posttext .= "<hr>$sig\n"; |
710 | 710 | } |
@@ -738,10 +738,10 @@ discard block |
||
738 | 738 | } |
739 | 739 | if (($controls == FORUM_CONTROLS) && (can_reply($thread, $forum, $logged_in_user))) { |
740 | 740 | echo " "; |
741 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "&no_quote=1#input"; |
|
741 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."&no_quote=1#input"; |
|
742 | 742 | // "Reply" is used as a verb |
743 | 743 | show_button($url, tra("Reply"), tra("Post a reply to this message")); |
744 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "#input"; |
|
744 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."#input"; |
|
745 | 745 | // "Quote" is used as a verb |
746 | 746 | show_button($url, tra("Quote"), tra("Post a reply by quoting this message")); |
747 | 747 | } |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | $content = output_transform($post->content, $options); |
764 | 764 | $when = time_diff_str($post->timestamp, time()); |
765 | 765 | $user = BoincUser::lookup_id($post->user); |
766 | - if (!$user){ |
|
766 | + if (!$user) { |
|
767 | 767 | return; |
768 | 768 | } |
769 | 769 | |
@@ -819,9 +819,9 @@ discard block |
||
819 | 819 | function post_rules() { |
820 | 820 | if (defined('FORUM_RULES')) return FORUM_RULES; |
821 | 821 | if (function_exists("project_forum_post_rules")) { |
822 | - $project_rules=project_forum_post_rules(); |
|
822 | + $project_rules = project_forum_post_rules(); |
|
823 | 823 | } else { |
824 | - $project_rules=""; |
|
824 | + $project_rules = ""; |
|
825 | 825 | } |
826 | 826 | return sprintf(" |
827 | 827 | <ul> |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | ); |
851 | 851 | } |
852 | 852 | |
853 | -function post_warning($forum=null) { |
|
853 | +function post_warning($forum = null) { |
|
854 | 854 | $x = "<br><br> |
855 | 855 | <table><tr><td align=left> |
856 | 856 | "; |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | $content = substr($content, 0, 64000); |
939 | 939 | $content = BoincDb::escape_string($content); |
940 | 940 | $now = time(); |
941 | - $sig = $signature?1:0; |
|
941 | + $sig = $signature ? 1 : 0; |
|
942 | 942 | $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)"); |
943 | 943 | if (!$id) { |
944 | 944 | $forum_error = "Failed to add post to DB."; |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | // |
959 | 959 | function update_thread_timestamp($thread) { |
960 | 960 | $posts = BoincPost::enum("thread=$thread->id and hidden=0 order by timestamp desc limit 1"); |
961 | - if (count($posts)>0) { |
|
961 | + if (count($posts) > 0) { |
|
962 | 962 | $post = $posts[0]; |
963 | 963 | $thread->update("timestamp=$post->timestamp"); |
964 | 964 | } |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | function update_forum_timestamp($forum) { |
968 | 968 | $threads = BoincThread::enum("forum=$forum->id and hidden=0 order by timestamp desc limit 1"); |
969 | - if (count($threads)>0) { |
|
969 | + if (count($threads) > 0) { |
|
970 | 970 | $thread = $threads[0]; |
971 | 971 | $forum->update("timestamp=$thread->timestamp"); |
972 | 972 | } |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | if (is_news_forum($forum) && !$export) { |
990 | 990 | $status = 1; |
991 | 991 | } |
992 | - $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)"); |
|
992 | + $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)"); |
|
993 | 993 | if (!$id) { |
994 | 994 | $forum_error = "Failed to add thread to DB."; |
995 | 995 | return null; |
@@ -1119,22 +1119,22 @@ discard block |
||
1119 | 1119 | // $sticky - bool (not directly passed to SQL) |
1120 | 1120 | // |
1121 | 1121 | function get_forum_threads( |
1122 | - $forumID, $start=-1, $nRec=-1, $sort_style=MODIFIED_NEW, |
|
1122 | + $forumID, $start = -1, $nRec = -1, $sort_style = MODIFIED_NEW, |
|
1123 | 1123 | $show_hidden = 0, $sticky = 1 |
1124 | 1124 | ) { |
1125 | 1125 | //if (! (is_numeric($forumID) && is_numeric($min) && is_numeric($nRec))) { |
1126 | 1126 | // return NULL; // Something is wrong here. |
1127 | 1127 | //} |
1128 | 1128 | |
1129 | - $sql = 'forum = ' . $forumID ; |
|
1129 | + $sql = 'forum = '.$forumID; |
|
1130 | 1130 | $stickysql = ""; |
1131 | - if ($sticky){ |
|
1131 | + if ($sticky) { |
|
1132 | 1132 | $stickysql = "sticky DESC, "; |
1133 | 1133 | } |
1134 | 1134 | if (!$show_hidden) { |
1135 | 1135 | $sql .= ' AND hidden = 0'; |
1136 | 1136 | } |
1137 | - switch($sort_style) { |
|
1137 | + switch ($sort_style) { |
|
1138 | 1138 | case MODIFIED_NEW: |
1139 | 1139 | $sql .= ' ORDER BY '.$stickysql.'timestamp DESC'; |
1140 | 1140 | break; |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | if (!$show_hidden) { |
1188 | 1188 | $sql .= ' AND hidden = 0'; |
1189 | 1189 | } |
1190 | - switch($sort_style) { |
|
1190 | + switch ($sort_style) { |
|
1191 | 1191 | case CREATE_TIME_NEW: |
1192 | 1192 | $sql .= ' ORDER BY timestamp desc'; |
1193 | 1193 | break; |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | // |
1210 | 1210 | function show_post_moderation_links( |
1211 | 1211 | $config, $logged_in_user, $post, $forum, $tokens |
1212 | -){ |
|
1212 | +) { |
|
1213 | 1213 | $moderators_allowed_to_ban = parse_bool($config, "moderators_allowed_to_ban"); |
1214 | 1214 | $moderators_vote_to_ban = parse_bool($config, "moderators_vote_to_ban"); |
1215 | 1215 | |
@@ -1296,14 +1296,14 @@ discard block |
||
1296 | 1296 | // We do not tell the (ab)user how much this is - |
1297 | 1297 | // no need to make it easy for them to break the system. |
1298 | 1298 | // |
1299 | - if ($user->total_credit<$forum->post_min_total_credit || $user->expavg_credit<$forum->post_min_expavg_credit) { |
|
1299 | + if ($user->total_credit < $forum->post_min_total_credit || $user->expavg_credit < $forum->post_min_expavg_credit) { |
|
1300 | 1300 | 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)); |
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | // If the user is posting faster than forum regulations allow |
1304 | 1304 | // Tell the user to wait a while before creating any more posts |
1305 | 1305 | // |
1306 | - if (time()-$user->prefs->last_post <$forum->post_min_interval) { |
|
1306 | + if (time() - $user->prefs->last_post < $forum->post_min_interval) { |
|
1307 | 1307 | error_page(tra("You cannot create threads right now. Please wait before trying again. This is to protect against abuse of the system.")); |
1308 | 1308 | } |
1309 | 1309 | } |
@@ -1329,10 +1329,10 @@ discard block |
||
1329 | 1329 | // - edit their posts at any time |
1330 | 1330 | // - hide/unhide/move threads and posts |
1331 | 1331 | |
1332 | -function is_moderator($user, $forum=null) { |
|
1332 | +function is_moderator($user, $forum = null) { |
|
1333 | 1333 | if (!$user) return false; |
1334 | 1334 | BoincForumPrefs::lookup($user); |
1335 | - $type = $forum?$forum->parent_type:0; |
|
1335 | + $type = $forum ? $forum->parent_type : 0; |
|
1336 | 1336 | switch ($type) { |
1337 | 1337 | case 0: |
1338 | 1338 | if ($user->prefs->privilege(S_MODERATOR)) return true; |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | $owner = BoincUser::lookup_id($thread->owner); |
1371 | 1371 | if (!$owner) return; |
1372 | 1372 | echo "<tr><td>\n"; |
1373 | - switch($thread_forum->parent_type) { |
|
1373 | + switch ($thread_forum->parent_type) { |
|
1374 | 1374 | case 0: |
1375 | 1375 | $category = BoincCategory::lookup_id($thread_forum->category); |
1376 | 1376 | show_forum_title($category, $thread_forum, $thread, true); |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | break; |
1381 | 1381 | } |
1382 | 1382 | echo ' |
1383 | - </td><td class="numbers">'.($thread->replies+1).'</td> |
|
1383 | + </td><td class="numbers">'.($thread->replies + 1).'</td> |
|
1384 | 1384 | <td>'.user_links($owner).'</td> |
1385 | 1385 | <td class="numbers">'.$thread->views.'</td> |
1386 | 1386 | <td class="lastpost">'.time_diff_str($thread->timestamp, time()).'</td> |
@@ -1414,13 +1414,13 @@ discard block |
||
1414 | 1414 | |
1415 | 1415 | function subscribed_thread_web_line($notify) { |
1416 | 1416 | $thread = BoincThread::lookup_id($notify->opaque); |
1417 | - return tra("New posts in the thread %1","<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
1417 | + return tra("New posts in the thread %1", "<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | function subscribed_thread_rss($notify) { |
1421 | 1421 | $thread = BoincThread::lookup_id($notify->opaque); |
1422 | 1422 | $title = tra("New posts in subscribed thread"); |
1423 | - $msg = tra("There are new posts in the thread '%1'",$thread->title); |
|
1423 | + $msg = tra("There are new posts in the thread '%1'", $thread->title); |
|
1424 | 1424 | $url = secure_url_base()."forum_thread.php?id=$thread->id"; |
1425 | 1425 | return [$title, $msg, $url]; |
1426 | 1426 | } |
@@ -1432,13 +1432,13 @@ discard block |
||
1432 | 1432 | |
1433 | 1433 | function subscribed_forum_web_line($notify) { |
1434 | 1434 | $forum = BoincForum::lookup_id($notify->opaque); |
1435 | - return tra("New threads in the forum %1","<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
1435 | + return tra("New threads in the forum %1", "<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | function subscribed_forum_rss($notify) { |
1439 | 1439 | $forum = BoincForum::lookup_id($notify->opaque); |
1440 | 1440 | $title = tra("New posts in subscribed forum"); |
1441 | - $msg = tra("There are new threads in the forum '%1'",$forum->title); |
|
1441 | + $msg = tra("There are new threads in the forum '%1'", $forum->title); |
|
1442 | 1442 | $url = secure_url_base()."forum_forum.php?id=$forum->id"; |
1443 | 1443 | return [$title, $msg, $url]; |
1444 | 1444 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $db = BoincDb::get(); |
28 | 28 | return $db->lookup('category', 'BoincCategory', $clause); |
29 | 29 | } |
30 | - static function enum($clause=null) { |
|
30 | + static function enum($clause = null) { |
|
31 | 31 | $db = BoincDb::get(); |
32 | 32 | return $db->enum('category', 'BoincCategory', $clause); |
33 | 33 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $db = BoincDb::get(); |
79 | 79 | return $db->update($this, 'thread', $clause); |
80 | 80 | } |
81 | - static function enum($clause="") { |
|
81 | + static function enum($clause = "") { |
|
82 | 82 | $db = BoincDb::get(); |
83 | 83 | return $db->enum('thread', 'BoincThread', $clause); |
84 | 84 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $db = BoincDb::get(); |
143 | 143 | $ret = $db->insert('forum_preferences', $clause); |
144 | 144 | } |
145 | - static function lookup(&$user, $nocache=false) { |
|
145 | + static function lookup(&$user, $nocache = false) { |
|
146 | 146 | if (!$user) return; |
147 | 147 | if (isset($user->prefs)) return; |
148 | 148 | if (!$nocache && isset(self::$cache[$user->id])) { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $user->prefs = $prefs; |
165 | 165 | } |
166 | 166 | function privilege($specialbit) { |
167 | - return (substr($this->special_user, $specialbit,1)==1); |
|
167 | + return (substr($this->special_user, $specialbit, 1) == 1); |
|
168 | 168 | } |
169 | 169 | function update($clause) { |
170 | 170 | $db = BoincDb::get(); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $db = BoincDb::get(); |
176 | 176 | return $db->delete_aux('forum_preferences', "userid=$this->userid"); |
177 | 177 | } |
178 | - static function enum($clause=null) { |
|
178 | + static function enum($clause = null) { |
|
179 | 179 | $db = BoincDb::get(); |
180 | 180 | return $db->enum('forum_preferences', 'BoincForumPrefs', $clause); |
181 | 181 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | // |
216 | 216 | $fl = BoincForumLogging::lookup(0, 0); |
217 | 217 | if ($fl) { |
218 | - if ($fl->timestamp<time()-MAX_FORUM_LOGGING_TIME){ |
|
219 | - BoincForumLogging::delete_aux("timestamp<'".(time()-MAX_FORUM_LOGGING_TIME)."' and userid != 0"); |
|
218 | + if ($fl->timestamp < time() - MAX_FORUM_LOGGING_TIME) { |
|
219 | + BoincForumLogging::delete_aux("timestamp<'".(time() - MAX_FORUM_LOGGING_TIME)."' and userid != 0"); |
|
220 | 220 | BoincForumLogging::replace(0, 0, time()); |
221 | 221 | } |
222 | 222 | } else { |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | -define ('NOTIFY_FRIEND_REQ', 1); |
|
330 | -define ('NOTIFY_FRIEND_ACCEPT', 2); |
|
331 | -define ('NOTIFY_PM', 3); |
|
332 | -define ('NOTIFY_SUBSCRIBED_THREAD', 4); |
|
333 | -define ('NOTIFY_SUBSCRIBED_FORUM', 5); |
|
329 | +define('NOTIFY_FRIEND_REQ', 1); |
|
330 | +define('NOTIFY_FRIEND_ACCEPT', 2); |
|
331 | +define('NOTIFY_PM', 3); |
|
332 | +define('NOTIFY_SUBSCRIBED_THREAD', 4); |
|
333 | +define('NOTIFY_SUBSCRIBED_FORUM', 5); |
|
334 | 334 | |
335 | 335 | ?> |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | // - project forums: everyone in POST_REPORT_EMAILS |
25 | 25 | // - team message board: team founder and admins |
26 | 26 | // |
27 | -function mail_report_list($forum, $subject, $body, $must_send=false) { |
|
27 | +function mail_report_list($forum, $subject, $body, $must_send = false) { |
|
28 | 28 | $success = true; |
29 | 29 | switch ($forum->parent_type) { |
30 | 30 | case 0: |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | function send_moderation_email($forum, $post, $thread, $explanation, $action) { |
66 | 66 | global $master_url; |
67 | 67 | |
68 | - $moderator=get_logged_in_user(); |
|
68 | + $moderator = get_logged_in_user(); |
|
69 | 69 | $body = ""; |
70 | 70 | $user = BoincUser::lookup_id($post->user); |
71 | 71 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | // There's a new post in the thread, which the user is subscribed to. |
127 | 127 | // send them an email notifying them. |
128 | 128 | // |
129 | -function send_thread_notification_email($thread, $user){ |
|
130 | - $title = PROJECT . ": there is a new post in '". $thread->title ."'"; |
|
131 | - $link = secure_url_base() . "forum_thread.php?id=" . $thread->id; |
|
132 | - $body = "A " . PROJECT . " user has posted to the thread |
|
133 | -\"" . $thread->title . "\".\n" |
|
129 | +function send_thread_notification_email($thread, $user) { |
|
130 | + $title = PROJECT.": there is a new post in '".$thread->title."'"; |
|
131 | + $link = secure_url_base()."forum_thread.php?id=".$thread->id; |
|
132 | + $body = "A ".PROJECT." user has posted to the thread |
|
133 | +\"" . $thread->title."\".\n" |
|
134 | 134 | ."To view the updated thread, visit:\n$link |
135 | 135 | |
136 | 136 | -------------------------- |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | // There's a new thread in the forum, which the user is subscribed to. |
145 | 145 | // send them an email notifying them. |
146 | 146 | // |
147 | -function send_forum_notification_email($forum, $user){ |
|
148 | - $title = PROJECT . ": there is a new thread in '". $forum->title ."'"; |
|
149 | - $link = secure_url_base() . "forum_forum.php?id=" . $forum->id; |
|
150 | - $body = "A " . PROJECT . " user has added a thread to the forum |
|
151 | -\"" . $thread->title . "\".\n" |
|
147 | +function send_forum_notification_email($forum, $user) { |
|
148 | + $title = PROJECT.": there is a new thread in '".$forum->title."'"; |
|
149 | + $link = secure_url_base()."forum_forum.php?id=".$forum->id; |
|
150 | + $body = "A ".PROJECT." user has added a thread to the forum |
|
151 | +\"" . $thread->title."\".\n" |
|
152 | 152 | ."To view the updated forum, visit:\n$link |
153 | 153 | |
154 | 154 | -------------------------- |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | //////////////////// a user clicks the red "x" to report a post /////////// |
163 | 163 | // |
164 | -function send_report_post_email($user, $forum, $thread, $post, $message) { |
|
164 | +function send_report_post_email($user, $forum, $thread, $post, $message) { |
|
165 | 165 | global $master_url; |
166 | 166 | |
167 | 167 | $body = ""; |
@@ -219,16 +219,16 @@ discard block |
||
219 | 219 | // |
220 | 220 | function send_banish_vote_email($user, $duration, $reason, $end_time) { |
221 | 221 | global $master_url; |
222 | - $now=time(); |
|
222 | + $now = time(); |
|
223 | 223 | $subject = PROJECT." banishment vote underway"; |
224 | 224 | $vote_url = $master_url."forum_banishment_vote.php"; |
225 | 225 | $body = " |
226 | 226 | A vote has been started to banish you |
227 | 227 | from the ".PROJECT." message boards until ".date('M j, |
228 | -Y G:i', $duration+$now).", |
|
228 | +Y G:i', $duration + $now).", |
|
229 | 229 | because your postings have not followed our guidelines. |
230 | 230 | |
231 | -This vote will last until ".date('M j, Y G:i',$end_time)." or until a majority |
|
231 | +This vote will last until ".date('M j, Y G:i', $end_time)." or until a majority |
|
232 | 232 | decision has been reached. If the vote does not result in banishment, you will be |
233 | 233 | able to resume posting at that time. |
234 | 234 | "; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | require_once('../inc/forum.inc'); |
24 | 24 | require_once('../inc/pm.inc'); |
25 | 25 | |
26 | -function forum_page($forum, $user, $msg=null) { |
|
26 | +function forum_page($forum, $user, $msg = null) { |
|
27 | 27 | global $forum_sort_styles; |
28 | 28 | $sort_style = get_int("sort", true); |
29 | 29 | $start = get_int("start", true); |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | |
47 | 47 | if (!$sort_style) { |
48 | 48 | // get the sort style either from the logged in user or a cookie |
49 | - if ($user){ |
|
49 | + if ($user) { |
|
50 | 50 | $sort_style = $user->prefs->forum_sorting; |
51 | 51 | } else { |
52 | 52 | list($sort_style, $thread_style) = parse_forum_cookie(); |
53 | 53 | } |
54 | 54 | } else { |
55 | 55 | // set the sort style |
56 | - if ($user){ |
|
56 | + if ($user) { |
|
57 | 57 | $user->prefs->forum_sorting = $sort_style; |
58 | 58 | $user->prefs->update("forum_sorting=$sort_style"); |
59 | 59 | } else { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | echo "<td><a href=\"forum_thread.php?id=$thread->id\">$title</a><br></td>"; |
243 | 243 | |
244 | 244 | echo ' |
245 | - <td>'.($thread->replies+1).'</td> |
|
245 | + <td>'.($thread->replies + 1).'</td> |
|
246 | 246 | <td>'.user_links($owner, BADGE_HEIGHT_SMALL).'</td> |
247 | 247 | <td>'.$thread->views.'</td> |
248 | 248 | <td>'.time_diff_str($thread->timestamp, time()).'</td> |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | flush(); |
252 | 252 | } |
253 | 253 | end_table(); |
254 | - echo "<br>$page_nav"; // show page links |
|
254 | + echo "<br>$page_nav"; // show page links |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | $id = get_int("id"); |