@@ -126,6 +126,9 @@ discard block |
||
126 | 126 | return is_https()?secure_url_base():URL_BASE; |
127 | 127 | } |
128 | 128 | |
129 | +/** |
|
130 | + * @param string $name |
|
131 | + */ |
|
129 | 132 | function send_cookie($name, $value, $permanent, $ops=false) { |
130 | 133 | global $master_url; |
131 | 134 | |
@@ -208,6 +211,9 @@ discard block |
||
208 | 211 | // To do so, define page_head() in the project include file. |
209 | 212 | // |
210 | 213 | if (!function_exists("page_head")){ |
214 | +/** |
|
215 | + * @param string $body_attrs |
|
216 | + */ |
|
211 | 217 | function page_head( |
212 | 218 | $title, |
213 | 219 | // page title. Put in <title>, used as title for browser tab. |
@@ -476,6 +482,9 @@ discard block |
||
476 | 482 | "; |
477 | 483 | } |
478 | 484 | |
485 | +/** |
|
486 | + * @param string $x |
|
487 | + */ |
|
479 | 488 | function row2_init($x, $y, $lwidth='40%') { |
480 | 489 | echo '<tr> |
481 | 490 | <td class="text-right " width="'.$lwidth.'" style="padding-right: 20px;">'.$x.'</td> |
@@ -487,6 +496,9 @@ discard block |
||
487 | 496 | echo "<tr><td>$x</td><td>$y</td></tr>\n"; |
488 | 497 | } |
489 | 498 | |
499 | +/** |
|
500 | + * @param string $string |
|
501 | + */ |
|
490 | 502 | function rowify($string) { |
491 | 503 | echo "<tr><td>$string</td></tr>"; |
492 | 504 | } |
@@ -512,6 +524,9 @@ discard block |
||
512 | 524 | echo "</tr>\n"; |
513 | 525 | } |
514 | 526 | |
527 | +/** |
|
528 | + * @param string $x |
|
529 | + */ |
|
515 | 530 | function row_heading($x, $class='bg-primary') { |
516 | 531 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
517 | 532 | ', $class, $x |
@@ -574,6 +589,11 @@ discard block |
||
574 | 589 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
575 | 590 | // is cut short. |
576 | 591 | |
592 | +/** |
|
593 | + * @param string $sentence |
|
594 | + * @param string $delimiter |
|
595 | + * @param integer $max_chars |
|
596 | + */ |
|
577 | 597 | function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
578 | 598 | $words = explode($delimiter, $sentence); |
579 | 599 | $total_chars = 0; |
@@ -624,6 +644,9 @@ discard block |
||
624 | 644 | ob_implicit_flush(0); |
625 | 645 | } |
626 | 646 | |
647 | +/** |
|
648 | + * @param string $filename |
|
649 | + */ |
|
627 | 650 | function close_output_buffer($filename) { |
628 | 651 | $fh = fopen($filename, "w"); |
629 | 652 | $page = ob_get_contents(); |
@@ -692,6 +715,9 @@ discard block |
||
692 | 715 | |
693 | 716 | // returns null if the arg is optional and missing |
694 | 717 | // |
718 | +/** |
|
719 | + * @param string $name |
|
720 | + */ |
|
695 | 721 | function post_int($name, $optional=false) { |
696 | 722 | $x = post_num($name, $optional); |
697 | 723 | if (is_null($x)) return null; |
@@ -791,6 +817,9 @@ discard block |
||
791 | 817 | |
792 | 818 | // Generate a "select" element from an array of values |
793 | 819 | // |
820 | +/** |
|
821 | + * @param string $name |
|
822 | + */ |
|
794 | 823 | function select_from_array($name, $array, $selection=null, $width=240) { |
795 | 824 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
796 | 825 | |
@@ -854,18 +883,33 @@ discard block |
||
854 | 883 | ); |
855 | 884 | } |
856 | 885 | |
886 | +/** |
|
887 | + * @param string $text |
|
888 | + * @param string $desc |
|
889 | + */ |
|
857 | 890 | function show_button($url, $text, $desc=null, $class="btn-success btn-sm") { |
858 | 891 | echo button_text($url, $text, $desc=null, $class); |
859 | 892 | } |
860 | 893 | |
861 | 894 | // for places with a bunch of buttons, like forum posts |
862 | 895 | // |
896 | +/** |
|
897 | + * @param string $url |
|
898 | + * @param string $text |
|
899 | + * @param string $desc |
|
900 | + */ |
|
863 | 901 | function show_button_small($url, $text, $desc=null) { |
864 | 902 | echo button_text($url, $text, $desc, "btn-primary btn-xs"); |
865 | 903 | } |
866 | 904 | |
867 | 905 | // used for showing icons |
868 | 906 | // |
907 | +/** |
|
908 | + * @param string $src |
|
909 | + * @param string $title |
|
910 | + * @param string $alt |
|
911 | + * @param string $height |
|
912 | + */ |
|
869 | 913 | function show_image($src, $title, $alt, $height=null) { |
870 | 914 | $h = ""; |
871 | 915 | if ($height) { |
@@ -986,6 +1030,9 @@ discard block |
||
986 | 1030 | } |
987 | 1031 | } |
988 | 1032 | |
1033 | +/** |
|
1034 | + * @param integer $f |
|
1035 | + */ |
|
989 | 1036 | function flops_to_credit($f) { |
990 | 1037 | return $f*(200/86400e9); |
991 | 1038 | } |
@@ -1020,6 +1067,9 @@ discard block |
||
1020 | 1067 | } |
1021 | 1068 | } |
1022 | 1069 | |
1070 | +/** |
|
1071 | + * @param integer $height |
|
1072 | + */ |
|
1023 | 1073 | function badges_string($is_user, $item, $height) { |
1024 | 1074 | if (DISABLE_BADGES) return null; |
1025 | 1075 | if ($is_user) { |
@@ -1036,6 +1086,9 @@ discard block |
||
1036 | 1086 | return $x; |
1037 | 1087 | } |
1038 | 1088 | |
1089 | +/** |
|
1090 | + * @param boolean $is_user |
|
1091 | + */ |
|
1039 | 1092 | function show_badges_row($is_user, $item) { |
1040 | 1093 | if (BADGE_HEIGHT_LARGE == 0) return; |
1041 | 1094 | $x = badges_string($is_user, $item, BADGE_HEIGHT_LARGE); |
@@ -1080,6 +1133,11 @@ discard block |
||
1080 | 1133 | // return HTML for a textarea with chars-remaining counter. |
1081 | 1134 | // Call text_counter_script() before using this. |
1082 | 1135 | // |
1136 | +/** |
|
1137 | + * @param string $name |
|
1138 | + * @param integer $maxlen |
|
1139 | + * @param string $text |
|
1140 | + */ |
|
1083 | 1141 | function textarea_with_counter($name, $maxlen, $text) { |
1084 | 1142 | $rem_name = $name."_remaining"; |
1085 | 1143 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | // parse some stuff from config (do it here for efficiency) |
35 | 35 | // |
36 | 36 | $config = get_config(); |
37 | -$master_url = parse_config($config , "<master_url>"); |
|
37 | +$master_url = parse_config($config, "<master_url>"); |
|
38 | 38 | $recaptcha_public_key = parse_config($config, "<recaptcha_public_key>"); |
39 | 39 | $recaptcha_private_key = parse_config($config, "<recaptcha_private_key>"); |
40 | 40 | |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | function url_base() { |
126 | - return is_https()?secure_url_base():URL_BASE; |
|
126 | + return is_https() ?secure_url_base() : URL_BASE; |
|
127 | 127 | } |
128 | 128 | |
129 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
129 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
130 | 130 | global $master_url; |
131 | 131 | |
132 | 132 | // the following allows independent login for projects on the same server |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | $path = substr($path, 0, -1); |
138 | 138 | $path .= "_ops/"; |
139 | 139 | } |
140 | - $expire = $permanent?time()+3600*24*365:0; |
|
140 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
141 | 141 | setcookie($name, $value, $expire, $path); |
142 | 142 | } |
143 | 143 | |
144 | -function clear_cookie($name, $ops=false) { |
|
144 | +function clear_cookie($name, $ops = false) { |
|
145 | 145 | global $master_url; |
146 | 146 | $url = parse_url($master_url); |
147 | 147 | $path = $url['path']; |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | $path = substr($path, 0, -1); |
150 | 150 | $path .= "_ops/"; |
151 | 151 | } |
152 | - setcookie($name, '', time()-3600, $path); |
|
152 | + setcookie($name, '', time() - 3600, $path); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | $g_logged_in_user = null; |
156 | 156 | $got_logged_in_user = false; |
157 | 157 | |
158 | -function get_logged_in_user($must_be_logged_in=true) { |
|
158 | +function get_logged_in_user($must_be_logged_in = true) { |
|
159 | 159 | global $g_logged_in_user, $got_logged_in_user; |
160 | 160 | if ($got_logged_in_user) return $g_logged_in_user; |
161 | 161 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $next_url = $_SERVER['REQUEST_URI']; |
175 | 175 | $n = strrpos($next_url, "/"); |
176 | 176 | if ($n) { |
177 | - $next_url = substr($next_url, $n+1); |
|
177 | + $next_url = substr($next_url, $n + 1); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | $next_url = urlencode($next_url); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | return $g_logged_in_user; |
186 | 186 | } |
187 | 187 | |
188 | -function show_login_info($prefix="") { |
|
188 | +function show_login_info($prefix = "") { |
|
189 | 189 | $user = get_logged_in_user(false); |
190 | 190 | if ($user) { |
191 | 191 | $url_tokens = url_tokens($user->authenticator); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | -$cache_control_extra=""; |
|
198 | +$cache_control_extra = ""; |
|
199 | 199 | $is_login_page = false; |
200 | 200 | |
201 | 201 | // Call this to start pages. |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | // with an existing web framework can more easily do so. |
208 | 208 | // To do so, define page_head() in the project include file. |
209 | 209 | // |
210 | -if (!function_exists("page_head")){ |
|
210 | +if (!function_exists("page_head")) { |
|
211 | 211 | function page_head( |
212 | 212 | $title, |
213 | 213 | // page title. Put in <title>, used as title for browser tab. |
214 | - $body_attrs=null, |
|
214 | + $body_attrs = null, |
|
215 | 215 | // <body XXXX> |
216 | 216 | // e.g. Javascript to put focus in an input field |
217 | 217 | // (onload="document.form.foo.focus()") |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | // if set, include schedulers.txt. |
221 | 221 | // also pass to project_banner() in case you want a different |
222 | 222 | // header for your main page. |
223 | - $url_prefix="", |
|
223 | + $url_prefix = "", |
|
224 | 224 | // prepend this to links. |
225 | 225 | // Use for web pages not in the top directory |
226 | - $head_extra=null |
|
226 | + $head_extra = null |
|
227 | 227 | // extra stuff to put in <head>. E.g.: |
228 | 228 | // reCAPTCHA code (create_profile.php) |
229 | 229 | // bbcode javascript (forums) |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | |
240 | 240 | if (!$caching) { |
241 | 241 | header("Content-type: text/html; charset=utf-8"); |
242 | - header ("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); // Date in the past |
|
243 | - header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); // always modified |
|
244 | - header ("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); // HTTP/1.1 |
|
245 | - header ("Pragma: no-cache"); // HTTP/1.0 |
|
242 | + header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); // Date in the past |
|
243 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); // always modified |
|
244 | + header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); // HTTP/1.1 |
|
245 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | echo '<!DOCTYPE html> |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | if ($head_extra) { |
254 | 254 | echo "\n$head_extra\n"; |
255 | 255 | } |
256 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
256 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
257 | 257 | readfile("schedulers.txt"); |
258 | 258 | } |
259 | 259 | |
260 | - $t = $title?$title:PROJECT; |
|
260 | + $t = $title ? $title : PROJECT; |
|
261 | 261 | echo "<title>$t</title>\n"; |
262 | 262 | echo ' |
263 | 263 | <meta charset="utf-8"> |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | echo '<div class="container-fluid"> |
294 | 294 | '; |
295 | 295 | |
296 | - switch($title) { //kludge |
|
296 | + switch ($title) { //kludge |
|
297 | 297 | case tra("Log in"): |
298 | 298 | case tra("Create an account"): |
299 | 299 | case tra("Server status page"): |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | |
310 | 310 | // See the comments for page_head() |
311 | 311 | // |
312 | -if (!function_exists("page_tail")){ |
|
312 | +if (!function_exists("page_tail")) { |
|
313 | 313 | function page_tail( |
314 | - $show_date=false, |
|
314 | + $show_date = false, |
|
315 | 315 | // true for pages that are generated periodically rather than on the fly |
316 | - $url_prefix="", |
|
316 | + $url_prefix = "", |
|
317 | 317 | // use for pages not at top level |
318 | - $is_main=false |
|
318 | + $is_main = false |
|
319 | 319 | // passed to project_footer; |
320 | 320 | ) { |
321 | 321 | echo "<br>\n"; |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | -function display_cvs_versions(){ |
|
333 | +function display_cvs_versions() { |
|
334 | 334 | global $cvs_version_tracker; |
335 | 335 | echo "\n<!-- SVN VERSIONS -->\n"; |
336 | - for ($i=0;$i<sizeof($cvs_version_tracker);$i++) { |
|
336 | + for ($i = 0; $i < sizeof($cvs_version_tracker); $i++) { |
|
337 | 337 | echo "<!-- ".$cvs_version_tracker[$i]." -->\n"; |
338 | 338 | } |
339 | 339 | } |
@@ -358,23 +358,23 @@ discard block |
||
358 | 358 | // takes argument in second and returns a human formatted time string |
359 | 359 | // in the form D days + h Hours + m Min + s sec. |
360 | 360 | |
361 | -function time_diff($x, $res=3) { |
|
361 | +function time_diff($x, $res = 3) { |
|
362 | 362 | $days = (int)($x/86400); |
363 | - $hours = (int)(($x-$days*86400)/3600); |
|
364 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
365 | - $seconds = (int)($x % 60); |
|
363 | + $hours = (int)(($x - $days*86400)/3600); |
|
364 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
365 | + $seconds = (int)($x%60); |
|
366 | 366 | |
367 | 367 | $datestring = ""; |
368 | 368 | if ($days) { |
369 | 369 | $datestring .= "$days ".tra("days")." "; |
370 | 370 | } |
371 | - if ($res>0 && ($hours || strlen($datestring))) { |
|
371 | + if ($res > 0 && ($hours || strlen($datestring))) { |
|
372 | 372 | $datestring .= "$hours ".tra("hours")." "; |
373 | 373 | } |
374 | - if ($res>1 && ($minutes || strlen($datestring))) { |
|
374 | + if ($res > 1 && ($minutes || strlen($datestring))) { |
|
375 | 375 | $datestring .= "$minutes ".tra("min")." "; |
376 | 376 | } |
377 | - if ($res>2 && ($seconds)) { |
|
377 | + if ($res > 2 && ($seconds)) { |
|
378 | 378 | $datestring .= "$seconds ".tra("sec")." "; |
379 | 379 | } |
380 | 380 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | function time_str($x) { |
391 | 391 | if ($x == 0) return "---"; |
392 | - return gmdate('j M Y, G:i:s', $x) . " UTC"; |
|
392 | + return gmdate('j M Y, G:i:s', $x)." UTC"; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | function local_time_str($x) { |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | return time_str($x); |
402 | 402 | } |
403 | 403 | |
404 | -function start_table_str($class="", $style="") { |
|
405 | - $s = $style?'style="'.$style.'"':''; |
|
404 | +function start_table_str($class = "", $style = "") { |
|
405 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
406 | 406 | return '<div class="table"> |
407 | 407 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
408 | 408 | '; |
409 | 409 | } |
410 | 410 | |
411 | -function start_table($class="", $style="") { |
|
411 | +function start_table($class = "", $style = "") { |
|
412 | 412 | echo start_table_str($class, $style); |
413 | 413 | } |
414 | 414 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | echo "</tr>\n"; |
454 | 454 | } |
455 | 455 | |
456 | -function row1($x, $ncols=2, $class="heading") { |
|
456 | +function row1($x, $ncols = 2, $class = "heading") { |
|
457 | 457 | if ($class == "heading") { |
458 | 458 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
459 | 459 | } else { |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | define('VALUE_ATTRS', 'style="padding-left:12px"'); |
466 | 466 | define('VALUE_ATTRS_ERR', 'class="danger" style="padding-left:12px"'); |
467 | 467 | |
468 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
469 | - if ($x==="") $x="<br>"; |
|
470 | - if ($y==="") $y="<br>"; |
|
471 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
468 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
469 | + if ($x === "") $x = "<br>"; |
|
470 | + if ($y === "") $y = "<br>"; |
|
471 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
472 | 472 | echo "<tr> |
473 | 473 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
474 | 474 | <td $attrs >$y</td> |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | "; |
477 | 477 | } |
478 | 478 | |
479 | -function row2_init($x, $y, $lwidth='40%') { |
|
479 | +function row2_init($x, $y, $lwidth = '40%') { |
|
480 | 480 | echo '<tr> |
481 | 481 | <td class="text-right " width="'.$lwidth.'" style="padding-right: 20px;">'.$x.'</td> |
482 | 482 | <td '.VALUE_ATTRS.'>'.$y.' |
@@ -499,20 +499,20 @@ discard block |
||
499 | 499 | echo "</tr>\n"; |
500 | 500 | } |
501 | 501 | |
502 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
502 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
503 | 503 | |
504 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
504 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
505 | 505 | echo "<tr>"; |
506 | 506 | $i = 0; |
507 | 507 | foreach ($x as $h) { |
508 | - $a = $attrs?$attrs[$i]:""; |
|
508 | + $a = $attrs ? $attrs[$i] : ""; |
|
509 | 509 | echo "<th $a class=\"$class\">$h</th>"; |
510 | 510 | $i++; |
511 | 511 | } |
512 | 512 | echo "</tr>\n"; |
513 | 513 | } |
514 | 514 | |
515 | -function row_heading($x, $class='bg-primary') { |
|
515 | +function row_heading($x, $class = 'bg-primary') { |
|
516 | 516 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
517 | 517 | ', $class, $x |
518 | 518 | ); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
575 | 575 | // is cut short. |
576 | 576 | |
577 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
577 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
578 | 578 | $words = explode($delimiter, $sentence); |
579 | 579 | $total_chars = 0; |
580 | 580 | $trunc = false; |
@@ -657,8 +657,8 @@ discard block |
||
657 | 657 | |
658 | 658 | // returns null if the arg is optional and missing |
659 | 659 | // |
660 | -function get_int($name, $optional=false) { |
|
661 | - $x=null; |
|
660 | +function get_int($name, $optional = false) { |
|
661 | + $x = null; |
|
662 | 662 | if (isset($_GET[$name])) $x = $_GET[$name]; |
663 | 663 | if (!is_numeric($x)) { |
664 | 664 | if ($optional) { |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | |
678 | 678 | // returns null if the arg is optional and missing |
679 | 679 | // |
680 | -function post_num($name, $optional=false) { |
|
680 | +function post_num($name, $optional = false) { |
|
681 | 681 | $x = null; |
682 | 682 | if (isset($_POST[$name])) $x = $_POST[$name]; |
683 | 683 | if (!is_numeric($x)) { |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | // returns null if the arg is optional and missing |
694 | 694 | // |
695 | -function post_int($name, $optional=false) { |
|
695 | +function post_int($name, $optional = false) { |
|
696 | 696 | $x = post_num($name, $optional); |
697 | 697 | if (is_null($x)) return null; |
698 | 698 | $y = (int)$x; |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | -function get_str($name, $optional=false) { |
|
713 | +function get_str($name, $optional = false) { |
|
714 | 714 | if (isset($_GET[$name])) { |
715 | 715 | $x = $_GET[$name]; |
716 | 716 | } else { |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | return undo_magic_quotes($x); |
723 | 723 | } |
724 | 724 | |
725 | -function post_str($name, $optional=false) { |
|
725 | +function post_str($name, $optional = false) { |
|
726 | 726 | if (isset($_POST[$name])) { |
727 | 727 | $x = $_POST[$name]; |
728 | 728 | } else { |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | return undo_magic_quotes($x); |
735 | 735 | } |
736 | 736 | |
737 | -function post_arr($name, $optional=false) { |
|
737 | +function post_arr($name, $optional = false) { |
|
738 | 738 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
739 | 739 | $x = $_POST[$name]; |
740 | 740 | } else { |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | // the mb_* functions are not included by default |
751 | 751 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
752 | 752 | |
753 | - for ($i=0; $i<strlen($str); $i++) { |
|
753 | + for ($i = 0; $i < strlen($str); $i++) { |
|
754 | 754 | $c = ord(substr($str, $i)); |
755 | 755 | if ($c < 32 || $c > 127) return false; |
756 | 756 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
775 | 775 | // if no value was entered and this is ok |
776 | 776 | // |
777 | - if ($number=='' && !$low) return true; |
|
777 | + if ($number == '' && !$low) return true; |
|
778 | 778 | |
779 | 779 | // the supplied value contains alphabetic characters |
780 | 780 | // |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | |
792 | 792 | // Generate a "select" element from an array of values |
793 | 793 | // |
794 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
794 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
795 | 795 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
796 | 796 | |
797 | 797 | foreach ($array as $key => $value) { |
@@ -816,8 +816,8 @@ discard block |
||
816 | 816 | return $str; |
817 | 817 | } |
818 | 818 | |
819 | -function strip_bbcode($string){ |
|
820 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
819 | +function strip_bbcode($string) { |
|
820 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | function current_url() { |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | // @param class The optional CSS class of the button. Defaults to a standard button |
846 | 846 | // |
847 | 847 | |
848 | -function button_text($url, $text, $desc=null, $class="btn-success btn-sm") { |
|
848 | +function button_text($url, $text, $desc = null, $class = "btn-success btn-sm") { |
|
849 | 849 | if (!$desc) { |
850 | 850 | $desc = $text; |
851 | 851 | } |
@@ -854,19 +854,19 @@ discard block |
||
854 | 854 | ); |
855 | 855 | } |
856 | 856 | |
857 | -function show_button($url, $text, $desc=null, $class="btn-success btn-sm") { |
|
858 | - echo button_text($url, $text, $desc=null, $class); |
|
857 | +function show_button($url, $text, $desc = null, $class = "btn-success btn-sm") { |
|
858 | + echo button_text($url, $text, $desc = null, $class); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | // for places with a bunch of buttons, like forum posts |
862 | 862 | // |
863 | -function show_button_small($url, $text, $desc=null) { |
|
863 | +function show_button_small($url, $text, $desc = null) { |
|
864 | 864 | echo button_text($url, $text, $desc, "btn-primary btn-xs"); |
865 | 865 | } |
866 | 866 | |
867 | 867 | // used for showing icons |
868 | 868 | // |
869 | -function show_image($src, $title, $alt, $height=null) { |
|
869 | +function show_image($src, $title, $alt, $height = null) { |
|
870 | 870 | $h = ""; |
871 | 871 | if ($height) { |
872 | 872 | $h = "height=\"$height\""; |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | // tries instead to connect to <replica_db_host> if tag exists. |
904 | 904 | // DEPRECATED - use boinc_db.inc |
905 | 905 | // |
906 | -function db_init($try_replica=false) { |
|
906 | +function db_init($try_replica = false) { |
|
907 | 907 | check_web_stopped(); |
908 | 908 | $retval = db_init_aux($try_replica); |
909 | 909 | if ($retval == 1) { |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | function sanitize_numeric($x) { |
972 | 972 | if (is_numeric($x)) { |
973 | 973 | return $x; |
974 | - } else if (trim($x) == '' ) { |
|
974 | + } else if (trim($x) == '') { |
|
975 | 975 | return ''; |
976 | 976 | } else { |
977 | 977 | return "not numeric"; |
@@ -994,9 +994,9 @@ discard block |
||
994 | 994 | return $c/(200/24); |
995 | 995 | } |
996 | 996 | |
997 | -function do_download($path,$name="") { |
|
998 | - if (strcmp($name,"") == 0) { |
|
999 | - $name=basename($path); |
|
997 | +function do_download($path, $name = "") { |
|
998 | + if (strcmp($name, "") == 0) { |
|
999 | + $name = basename($path); |
|
1000 | 1000 | } |
1001 | 1001 | header('Content-Description: File Transfer'); |
1002 | 1002 | header('Content-Type: application/octet-stream'); |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | header('Expires: 0'); |
1006 | 1006 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1007 | 1007 | header('Pragma: public'); |
1008 | - header('Content-Length: ' . filesize($path)); |
|
1008 | + header('Content-Length: '.filesize($path)); |
|
1009 | 1009 | flush(); |
1010 | 1010 | readfile($path); |
1011 | 1011 | } |
@@ -1052,10 +1052,10 @@ discard block |
||
1052 | 1052 | // Otherwise return 0. |
1053 | 1053 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1054 | 1054 | // |
1055 | -function boinc_client_version(){ |
|
1055 | +function boinc_client_version() { |
|
1056 | 1056 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1057 | 1057 | $x = $_SERVER['HTTP_USER_AGENT']; |
1058 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1058 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1059 | 1059 | if (preg_match($e, $x, $matches)) { |
1060 | 1060 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
1061 | 1061 | } |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | $rem_name = $name."_remaining"; |
1085 | 1085 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
1086 | 1086 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
1087 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1087 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1088 | 1088 | ; |
1089 | 1089 | } |
1090 | 1090 | |
@@ -1111,6 +1111,6 @@ discard block |
||
1111 | 1111 | "; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
1114 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
1115 | 1115 | |
1116 | 1116 | ?> |