@@ -162,11 +162,11 @@ |
||
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
165 | - $quota = (double) get_str('quota'); |
|
165 | + $quota = (double)get_str('quota'); |
|
166 | 166 | if ($quota != $us->quota) { |
167 | 167 | $us->update("quota=$quota"); |
168 | 168 | } |
169 | - $mj = (int) get_str('max_jobs_in_progress'); |
|
169 | + $mj = (int)get_str('max_jobs_in_progress'); |
|
170 | 170 | if ($mj != $us->max_jobs_in_progress) { |
171 | 171 | $us->update("max_jobs_in_progress=$mj"); |
172 | 172 | } |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | // prefix for links; needed for pages not in top dir |
142 | 142 | $user, |
143 | 143 | // logged-in user, if any |
144 | - $fixed=false, |
|
144 | + $fixed = false, |
|
145 | 145 | // if true, navbar is fixed at top of page. |
146 | 146 | // NOTE: if you do this, you must set a global var $fixed_navbar |
147 | 147 | // to true at compile time |
148 | 148 | // (it needs to be set when page_head() is called). |
149 | - $inverse=false |
|
149 | + $inverse = false |
|
150 | 150 | // white on black? |
151 | 151 | ) { |
152 | 152 | global $master_url; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | // output a panel. |
216 | 216 | // $content_func is a function that generates the panel contents |
217 | 217 | // |
218 | -function panel($title, $content_func, $class="panel-primary", $body_class="") { |
|
218 | +function panel($title, $content_func, $class = "panel-primary", $body_class = "") { |
|
219 | 219 | echo sprintf('<div class="panel %s"> |
220 | 220 | ', $class |
221 | 221 | ); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | // $left_width is the width of left column in 1/12 units. |
243 | 243 | // $arg is passed to the functions. |
244 | 244 | // |
245 | -function grid($top_func, $left_func, $right_func, $left_width=6, $arg=null) { |
|
245 | +function grid($top_func, $left_func, $right_func, $left_width = 6, $arg = null) { |
|
246 | 246 | echo ' |
247 | 247 | <div class="container-fluid"> |
248 | 248 | '; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | </div> |
258 | 258 | '; |
259 | 259 | } |
260 | - $right_width = 12-$left_width; |
|
260 | + $right_width = 12 - $left_width; |
|
261 | 261 | echo ' |
262 | 262 | <div class="row"> |
263 | 263 | <div class="col-sm-'.$left_width.'"> |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | // use extra = "name=x" |
282 | 282 | // call forum_focus(x, foo) after defining the field |
283 | 283 | // |
284 | -function form_start($action, $method='get', $extra='') { |
|
284 | +function form_start($action, $method = 'get', $extra = '') { |
|
285 | 285 | echo sprintf( |
286 | 286 | '<div class="container-fluid"> |
287 | 287 | <form class="form-horizontal" method="%s" action="%s" %s>' |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | // just the input field |
314 | 314 | // |
315 | 315 | function form_input_text_field( |
316 | - $name, $value='', $type='text', $attrs='', $extra='' |
|
316 | + $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
317 | 317 | ) { |
318 | 318 | return sprintf( |
319 | 319 | '<input %s type="%s" class="form-control" name="%s" value="%s">%s', |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | // the whole row |
325 | 325 | // |
326 | 326 | function form_input_text( |
327 | - $label, $name, $value='', $type='text', $attrs='', $extra='' |
|
327 | + $label, $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
328 | 328 | ) { |
329 | 329 | echo sprintf(' |
330 | 330 | <div class="form-group"> |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | ); |
353 | 353 | } |
354 | 354 | |
355 | -function form_input_textarea($label, $name, $value='', $nrows=4) { |
|
355 | +function form_input_textarea($label, $name, $value = '', $nrows = 4) { |
|
356 | 356 | echo sprintf(' |
357 | 357 | <div class="form-group"> |
358 | 358 | <label align=right class="%s" for="%s">%s</label> |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | // $items is either a string of <option> elements, or an array |
370 | 370 | // |
371 | -function form_select($label, $name, $items, $selected=null) { |
|
371 | +function form_select($label, $name, $items, $selected = null) { |
|
372 | 372 | echo sprintf(' |
373 | 373 | <div class="form-group"> |
374 | 374 | <label align=right class="%s" for="%s">%s</label> |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | foreach ($items as $i) { |
382 | 382 | echo sprintf( |
383 | 383 | '<option %s value=%s>%s</option>', |
384 | - ($i[0]==$selected)?'selected':'', |
|
384 | + ($i[0] == $selected) ? 'selected' : '', |
|
385 | 385 | $i[0], $i[1] |
386 | 386 | ); |
387 | 387 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | // same, for multiple select. |
395 | 395 | // $selected, if non-null, is a list of selected values |
396 | 396 | // |
397 | -function form_select_multiple($label, $name, $items, $selected=null, $size=0) { |
|
397 | +function form_select_multiple($label, $name, $items, $selected = null, $size = 0) { |
|
398 | 398 | echo sprintf(' |
399 | 399 | <div class="form-group"> |
400 | 400 | <label align=right class="%s" for="%s">%s</label> |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | foreach ($items as $i) { |
407 | 407 | echo sprintf( |
408 | 408 | '<option %s value=%s>%s</option>', |
409 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
409 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
410 | 410 | $i[0], $i[1] |
411 | 411 | ); |
412 | 412 | } |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | |
416 | 416 | // return a list of strings for checkbox items |
417 | 417 | // |
418 | -function checkbox_item_strings($items, $attrs='') { |
|
418 | +function checkbox_item_strings($items, $attrs = '') { |
|
419 | 419 | $x = []; |
420 | 420 | foreach ($items as $i) { |
421 | 421 | $x[] = sprintf('<input %s type="checkbox" name="%s" %s> %s |
422 | 422 | ', |
423 | - $attrs, $i[0], $i[2]?"checked":"", $i[1] |
|
423 | + $attrs, $i[0], $i[2] ? "checked" : "", $i[1] |
|
424 | 424 | ); |
425 | 425 | } |
426 | 426 | return $x; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | // $items is list of (name, label, checked) |
430 | 430 | // |
431 | -function form_checkboxes($label, $items, $attrs='') { |
|
431 | +function form_checkboxes($label, $items, $attrs = '') { |
|
432 | 432 | echo sprintf(' |
433 | 433 | <div class="form-group"> |
434 | 434 | <label align=right class="%s">%s</label> |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | // |
448 | 448 | function form_radio_buttons( |
449 | 449 | $label, $name, $items, $selected, |
450 | - $assign_ids=false // assign IDs to buttons based on names |
|
450 | + $assign_ids = false // assign IDs to buttons based on names |
|
451 | 451 | ) { |
452 | 452 | echo sprintf(' |
453 | 453 | <div class="form-group"> |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS |
458 | 458 | ); |
459 | 459 | foreach ($items as $i) { |
460 | - $checked = ($selected == $i[0])?"checked":""; |
|
460 | + $checked = ($selected == $i[0]) ? "checked" : ""; |
|
461 | 461 | if ($assign_ids) { |
462 | 462 | $id = sprintf('id="%s_%s"', $name, $i[0]); |
463 | 463 | } else { |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | '; |
496 | 496 | } |
497 | 497 | |
498 | -function form_submit($text, $attrs='') { |
|
498 | +function form_submit($text, $attrs = '') { |
|
499 | 499 | form_general( |
500 | 500 | "", |
501 | 501 | sprintf( |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | ); |
506 | 506 | } |
507 | 507 | |
508 | -function form_checkbox($label, $name, $checked=false) { |
|
508 | +function form_checkbox($label, $name, $checked = false) { |
|
509 | 509 | echo sprintf(' |
510 | 510 | <div class="form-group"> |
511 | 511 | <label align=right class="%s">%s</label> |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | echo sprintf(' |
517 | 517 | <input type="checkbox" name="%s" %s> |
518 | 518 | </div> |
519 | - ', $name, $checked?"checked":"" |
|
519 | + ', $name, $checked ? "checked" : "" |
|
520 | 520 | ); |
521 | 521 | } |
522 | 522 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | // $selected is the list of selected values. |
545 | 545 | // $extra is e.g. id=foo |
546 | 546 | // |
547 | -function form_select2_multi($label, $name, $items, $selected=null, $extra='') { |
|
547 | +function form_select2_multi($label, $name, $items, $selected = null, $extra = '') { |
|
548 | 548 | echo sprintf(' |
549 | 549 | <div class="form-group"> |
550 | 550 | <label align=right class="%s" for="%s">%s</label> |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | foreach ($items as $i) { |
557 | 557 | echo sprintf( |
558 | 558 | '<option %s value=%s>%s</option>', |
559 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
559 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
560 | 560 | $i[0], $i[1] |
561 | 561 | ); |
562 | 562 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $config = get_config(); |
36 | 36 | |
37 | 37 | global $master_url; |
38 | -$master_url = parse_config($config , "<master_url>"); |
|
38 | +$master_url = parse_config($config, "<master_url>"); |
|
39 | 39 | |
40 | 40 | // the above 'globals' are solely for Drupal; see |
41 | 41 | // https://stackoverflow.com/questions/29216392/scope-of-a-global-variable-in-drupal-module |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | // Set parameters to defaults if not defined in config.xml |
47 | 47 | |
48 | 48 | $x = parse_config($config, "<user_country>"); |
49 | -define('USER_COUNTRY', ($x===null)?1:(int)$x); |
|
49 | +define('USER_COUNTRY', ($x === null) ? 1 : (int)$x); |
|
50 | 50 | |
51 | 51 | $x = parse_config($config, "<user_url>"); |
52 | -define('USER_URL', ($x===null)?1:(int)$x); |
|
52 | +define('USER_URL', ($x === null) ? 1 : (int)$x); |
|
53 | 53 | |
54 | 54 | // Set parameters to defaults if not defined in project.inc |
55 | 55 | |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | function url_base() { |
162 | - return is_https()?secure_url_base():URL_BASE; |
|
162 | + return is_https() ?secure_url_base() : URL_BASE; |
|
163 | 163 | } |
164 | 164 | |
165 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
165 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
166 | 166 | global $master_url; |
167 | 167 | |
168 | 168 | // the following allows independent login for projects on the same server |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | $path = substr($path, 0, -1); |
174 | 174 | $path .= "_ops/"; |
175 | 175 | } |
176 | - $expire = $permanent?time()+3600*24*365:0; |
|
176 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
177 | 177 | setcookie($name, $value, $expire, $path, |
178 | 178 | '', |
179 | - is_https(), // if this page is secure, make cookie secure |
|
179 | + is_https(), // if this page is secure, make cookie secure |
|
180 | 180 | true // httponly; no JS access |
181 | 181 | ); |
182 | 182 | } |
183 | 183 | |
184 | -function clear_cookie($name, $ops=false) { |
|
184 | +function clear_cookie($name, $ops = false) { |
|
185 | 185 | global $master_url; |
186 | 186 | $url = parse_url($master_url); |
187 | 187 | $path = $url['path']; |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | $path = substr($path, 0, -1); |
190 | 190 | $path .= "_ops/"; |
191 | 191 | } |
192 | - setcookie($name, '', time()-3600, $path); |
|
192 | + setcookie($name, '', time() - 3600, $path); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | $g_logged_in_user = null; |
196 | 196 | $got_logged_in_user = false; |
197 | 197 | |
198 | -function get_logged_in_user($must_be_logged_in=true) { |
|
198 | +function get_logged_in_user($must_be_logged_in = true) { |
|
199 | 199 | global $g_logged_in_user, $got_logged_in_user; |
200 | 200 | if ($got_logged_in_user) { |
201 | 201 | // this could have been called earlier with $must_be_logged_in false |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $next_url = $_SERVER['REQUEST_URI']; |
222 | 222 | $n = strrpos($next_url, "/"); |
223 | 223 | if ($n) { |
224 | - $next_url = substr($next_url, $n+1); |
|
224 | + $next_url = substr($next_url, $n + 1); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | $next_url = urlencode($next_url); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | return $g_logged_in_user; |
233 | 233 | } |
234 | 234 | |
235 | -function show_login_info($prefix="") { |
|
235 | +function show_login_info($prefix = "") { |
|
236 | 236 | $user = get_logged_in_user(false); |
237 | 237 | if ($user) { |
238 | 238 | $url_tokens = url_tokens($user->authenticator); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | -$cache_control_extra=""; |
|
245 | +$cache_control_extra = ""; |
|
246 | 246 | $is_login_page = false; |
247 | 247 | |
248 | 248 | // Call this to start pages. |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | // with an existing web framework can more easily do so. |
255 | 255 | // To do so, define page_head() in html/project/project.inc |
256 | 256 | // |
257 | -if (!function_exists("page_head")){ |
|
257 | +if (!function_exists("page_head")) { |
|
258 | 258 | function page_head( |
259 | 259 | $title, |
260 | 260 | // page title. Put in <title>, used as title for browser tab. |
261 | - $body_attrs=null, |
|
261 | + $body_attrs = null, |
|
262 | 262 | // <body XXXX> |
263 | 263 | // e.g. Javascript to put focus in an input field |
264 | 264 | // (onload="document.form.foo.focus()") |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | // if set, include schedulers.txt. |
268 | 268 | // also pass to project_banner() in case you want a different |
269 | 269 | // header for your main page. |
270 | - $url_prefix="", |
|
270 | + $url_prefix = "", |
|
271 | 271 | // prepend this to links. |
272 | 272 | // Use for web pages not in the top directory |
273 | - $head_extra=null |
|
273 | + $head_extra = null |
|
274 | 274 | // extra stuff to put in <head>. E.g.: |
275 | 275 | // reCAPTCHA code (create_profile.php) |
276 | 276 | // bbcode javascript (forums) |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | header("Content-type: text/html; charset=utf-8"); |
293 | 293 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
294 | 294 | // Date in the past |
295 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
295 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
296 | 296 | // always modified |
297 | 297 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
298 | 298 | // for HTTP/1.1 |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | if ($head_extra) { |
316 | 316 | echo "\n$head_extra\n"; |
317 | 317 | } |
318 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
318 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
319 | 319 | readfile("schedulers.txt"); |
320 | 320 | } |
321 | 321 | |
322 | - $t = $title?$title:PROJECT; |
|
322 | + $t = $title ? $title : PROJECT; |
|
323 | 323 | echo "<title>$t</title>\n"; |
324 | 324 | echo ' |
325 | 325 | <meta charset="utf-8"> |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | echo '<div class="container-fluid"> |
376 | 376 | '; |
377 | 377 | |
378 | - switch($title) { //kludge |
|
378 | + switch ($title) { //kludge |
|
379 | 379 | case tra("Log in"): |
380 | 380 | case tra("Create an account"): |
381 | 381 | case tra("Server status page"): |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | |
391 | 391 | // See the comments for page_head() |
392 | 392 | // |
393 | -if (!function_exists("page_tail")){ |
|
393 | +if (!function_exists("page_tail")) { |
|
394 | 394 | function page_tail( |
395 | - $show_date=false, |
|
395 | + $show_date = false, |
|
396 | 396 | // true for pages that are generated periodically rather than on the fly |
397 | - $url_prefix="", |
|
397 | + $url_prefix = "", |
|
398 | 398 | // use for pages not at top level |
399 | - $is_main=false |
|
399 | + $is_main = false |
|
400 | 400 | // passed to project_footer; |
401 | 401 | ) { |
402 | 402 | echo "<br>\n"; |
@@ -430,24 +430,24 @@ discard block |
||
430 | 430 | // convert time interval in seconds to a string of the form |
431 | 431 | // 'D days h hours m min s sec'. |
432 | 432 | |
433 | -function time_diff($x, $res=3) { |
|
433 | +function time_diff($x, $res = 3) { |
|
434 | 434 | $x = (int)$x; |
435 | 435 | $days = (int)($x/86400); |
436 | - $hours = (int)(($x-$days*86400)/3600); |
|
437 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
438 | - $seconds = $x % 60; |
|
436 | + $hours = (int)(($x - $days*86400)/3600); |
|
437 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
438 | + $seconds = $x%60; |
|
439 | 439 | |
440 | 440 | $s = ""; |
441 | 441 | if ($days) { |
442 | 442 | $s .= "$days ".tra("days")." "; |
443 | 443 | } |
444 | - if ($res>0 && ($hours || strlen($s))) { |
|
444 | + if ($res > 0 && ($hours || strlen($s))) { |
|
445 | 445 | $s .= "$hours ".tra("hours")." "; |
446 | 446 | } |
447 | - if ($res>1 && ($minutes || strlen($s))) { |
|
447 | + if ($res > 1 && ($minutes || strlen($s))) { |
|
448 | 448 | $s .= "$minutes ".tra("min")." "; |
449 | 449 | } |
450 | - if ($res>2) { |
|
450 | + if ($res > 2) { |
|
451 | 451 | $s .= "$seconds ".tra("sec")." "; |
452 | 452 | } |
453 | 453 | return $s; |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | function time_str($x) { |
463 | 463 | if ($x == 0) return "---"; |
464 | - return gmdate('j M Y, G:i:s', (int)$x) . " UTC"; |
|
464 | + return gmdate('j M Y, G:i:s', (int)$x)." UTC"; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | function local_time_str($x) { |
@@ -473,14 +473,14 @@ discard block |
||
473 | 473 | return time_str($x); |
474 | 474 | } |
475 | 475 | |
476 | -function start_table_str($class="", $style="") { |
|
477 | - $s = $style?'style="'.$style.'"':''; |
|
476 | +function start_table_str($class = "", $style = "") { |
|
477 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
478 | 478 | return '<div class="table"> |
479 | 479 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
480 | 480 | '; |
481 | 481 | } |
482 | 482 | |
483 | -function start_table($class="", $style="") { |
|
483 | +function start_table($class = "", $style = "") { |
|
484 | 484 | echo start_table_str($class, $style); |
485 | 485 | } |
486 | 486 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | echo "</tr>\n"; |
526 | 526 | } |
527 | 527 | |
528 | -function row1($x, $ncols=2, $class="heading") { |
|
528 | +function row1($x, $ncols = 2, $class = "heading") { |
|
529 | 529 | if ($class == "heading") { |
530 | 530 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
531 | 531 | } else { |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | |
540 | 540 | // a table row with 2 columns, with the left on right-aligned |
541 | 541 | |
542 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
543 | - if ($x==="") $x="<br>"; |
|
544 | - if ($y==="") $y="<br>"; |
|
545 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
542 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
543 | + if ($x === "") $x = "<br>"; |
|
544 | + if ($y === "") $y = "<br>"; |
|
545 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
546 | 546 | echo "<tr> |
547 | 547 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
548 | 548 | <td $attrs >$y</td> |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | // output the first part of row2(); |
554 | 554 | // then write the content, followed by </td></tr> |
555 | 555 | |
556 | -function row2_init($x, $lwidth='40%') { |
|
556 | +function row2_init($x, $lwidth = '40%') { |
|
557 | 557 | echo sprintf('<tr> |
558 | 558 | <td width="%s" %s>%s</td> |
559 | 559 | <td %s>', |
@@ -569,31 +569,31 @@ discard block |
||
569 | 569 | echo "<tr><td>$string</td></tr>"; |
570 | 570 | } |
571 | 571 | |
572 | -function row_array($x, $attrs=null) { |
|
572 | +function row_array($x, $attrs = null) { |
|
573 | 573 | echo "<tr>\n"; |
574 | 574 | $i = 0; |
575 | 575 | foreach ($x as $h) { |
576 | - $a = $attrs?$attrs[$i]:""; |
|
576 | + $a = $attrs ? $attrs[$i] : ""; |
|
577 | 577 | echo "<td $a>$h</td>\n"; |
578 | 578 | $i++; |
579 | 579 | } |
580 | 580 | echo "</tr>\n"; |
581 | 581 | } |
582 | 582 | |
583 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
583 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
584 | 584 | |
585 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
585 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
586 | 586 | echo "<tr>"; |
587 | 587 | $i = 0; |
588 | 588 | foreach ($x as $h) { |
589 | - $a = $attrs?$attrs[$i]:""; |
|
589 | + $a = $attrs ? $attrs[$i] : ""; |
|
590 | 590 | echo "<th $a class=\"$class\">$h</th>"; |
591 | 591 | $i++; |
592 | 592 | } |
593 | 593 | echo "</tr>\n"; |
594 | 594 | } |
595 | 595 | |
596 | -function row_heading($x, $class='bg-primary') { |
|
596 | +function row_heading($x, $class = 'bg-primary') { |
|
597 | 597 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
598 | 598 | ', $class, $x |
599 | 599 | ); |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
654 | 654 | // is cut short. |
655 | 655 | |
656 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
656 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
657 | 657 | $words = explode($delimiter, $sentence); |
658 | 658 | $total_chars = 0; |
659 | 659 | $trunc = false; |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | |
737 | 737 | // returns null if the arg is optional and missing |
738 | 738 | // |
739 | -function get_int($name, $optional=false) { |
|
740 | - $x=null; |
|
739 | +function get_int($name, $optional = false) { |
|
740 | + $x = null; |
|
741 | 741 | if (isset($_GET[$name])) $x = $_GET[$name]; |
742 | 742 | if (!is_numeric($x)) { |
743 | 743 | if ($optional) { |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | |
757 | 757 | // returns null if the arg is optional and missing |
758 | 758 | // |
759 | -function post_num($name, $optional=false) { |
|
759 | +function post_num($name, $optional = false) { |
|
760 | 760 | $x = null; |
761 | 761 | if (isset($_POST[$name])) $x = $_POST[$name]; |
762 | 762 | if (!is_numeric($x)) { |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | |
772 | 772 | // returns null if the arg is optional and missing |
773 | 773 | // |
774 | -function post_int($name, $optional=false) { |
|
774 | +function post_int($name, $optional = false) { |
|
775 | 775 | $x = post_num($name, $optional); |
776 | 776 | if (is_null($x)) return null; |
777 | 777 | $y = (int)$x; |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | -function get_str($name, $optional=false) { |
|
792 | +function get_str($name, $optional = false) { |
|
793 | 793 | if (isset($_GET[$name])) { |
794 | 794 | $x = $_GET[$name]; |
795 | 795 | } else { |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | return undo_magic_quotes($x); |
802 | 802 | } |
803 | 803 | |
804 | -function post_str($name, $optional=false) { |
|
804 | +function post_str($name, $optional = false) { |
|
805 | 805 | if (isset($_POST[$name])) { |
806 | 806 | $x = $_POST[$name]; |
807 | 807 | } else { |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | return undo_magic_quotes($x); |
814 | 814 | } |
815 | 815 | |
816 | -function post_arr($name, $optional=false) { |
|
816 | +function post_arr($name, $optional = false) { |
|
817 | 817 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
818 | 818 | $x = $_POST[$name]; |
819 | 819 | } else { |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | // the mb_* functions are not included by default |
830 | 830 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
831 | 831 | |
832 | - for ($i=0; $i<strlen($str); $i++) { |
|
832 | + for ($i = 0; $i < strlen($str); $i++) { |
|
833 | 833 | $c = ord(substr($str, $i)); |
834 | 834 | if ($c < 32 || $c > 127) return false; |
835 | 835 | } |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
854 | 854 | // if no value was entered and this is ok |
855 | 855 | // |
856 | - if ($number=='' && !$low) return true; |
|
856 | + if ($number == '' && !$low) return true; |
|
857 | 857 | |
858 | 858 | // the supplied value contains alphabetic characters |
859 | 859 | // |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | |
871 | 871 | // Generate a "select" element from an array of values |
872 | 872 | // |
873 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
873 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
874 | 874 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
875 | 875 | |
876 | 876 | foreach ($array as $key => $value) { |
@@ -895,12 +895,12 @@ discard block |
||
895 | 895 | return $str; |
896 | 896 | } |
897 | 897 | |
898 | -function strip_bbcode($string){ |
|
899 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
898 | +function strip_bbcode($string) { |
|
899 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | function current_url() { |
903 | - $url = is_https()?'https':'http'; |
|
903 | + $url = is_https() ? 'https' : 'http'; |
|
904 | 904 | $url .= "://"; |
905 | 905 | $url .= $_SERVER['SERVER_NAME']; |
906 | 906 | $url .= ":".$_SERVER['SERVER_PORT']; |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | // the colors for bootstrap's btn-success are almost illegible; |
919 | 919 | // the green is too light. Use a darker green. |
920 | 920 | // |
921 | -function button_style($color='green', $font_size=null) { |
|
921 | +function button_style($color = 'green', $font_size = null) { |
|
922 | 922 | $fs = ''; |
923 | 923 | if ($font_size) { |
924 | 924 | $fs = sprintf('; font-size:%dpx', $font_size); |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | // class: class of the button, e.g. btn |
938 | 938 | // extra: Additional text in href tag |
939 | 939 | // |
940 | -function button_text($url, $text, $desc=null, $class=null, $extra='') { |
|
940 | +function button_text($url, $text, $desc = null, $class = null, $extra = '') { |
|
941 | 941 | if (!$desc) { |
942 | 942 | $desc = $text; |
943 | 943 | } |
@@ -952,23 +952,23 @@ discard block |
||
952 | 952 | ); |
953 | 953 | } |
954 | 954 | |
955 | -function button_text_small($url, $text, $desc=null) { |
|
955 | +function button_text_small($url, $text, $desc = null) { |
|
956 | 956 | return button_text($url, $text, $desc, "btn btn-xs", button_style()); |
957 | 957 | } |
958 | 958 | |
959 | -function show_button($url, $text, $desc=null, $class=null, $extra=null) { |
|
959 | +function show_button($url, $text, $desc = null, $class = null, $extra = null) { |
|
960 | 960 | echo button_text($url, $text, $desc, $class, $extra); |
961 | 961 | } |
962 | 962 | |
963 | 963 | // for places with a bunch of buttons, like forum posts |
964 | 964 | // |
965 | -function show_button_small($url, $text, $desc=null) { |
|
965 | +function show_button_small($url, $text, $desc = null) { |
|
966 | 966 | echo button_text_small($url, $text, $desc); |
967 | 967 | } |
968 | 968 | |
969 | 969 | // used for showing icons |
970 | 970 | // |
971 | -function show_image($src, $title, $alt, $height=null) { |
|
971 | +function show_image($src, $title, $alt, $height = null) { |
|
972 | 972 | $h = ""; |
973 | 973 | if ($height) { |
974 | 974 | $h = "height=\"$height\""; |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | // tries instead to connect to <replica_db_host> if tag exists. |
1006 | 1006 | // DEPRECATED - use boinc_db.inc |
1007 | 1007 | // |
1008 | -function db_init($try_replica=false) { |
|
1008 | +function db_init($try_replica = false) { |
|
1009 | 1009 | check_web_stopped(); |
1010 | 1010 | $retval = db_init_aux($try_replica); |
1011 | 1011 | if ($retval == 1) { |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | // Check this to avoid XSS vulnerability |
1082 | 1082 | // |
1083 | 1083 | function sanitize_sort_by($x) { |
1084 | - switch($x) { |
|
1084 | + switch ($x) { |
|
1085 | 1085 | case 'expavg_credit': |
1086 | 1086 | case 'total_credit': |
1087 | 1087 | return; |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | function do_download($path) { |
1102 | - $name=basename($path); |
|
1102 | + $name = basename($path); |
|
1103 | 1103 | header('Content-Description: File Transfer'); |
1104 | 1104 | header('Content-Type: application/octet-stream'); |
1105 | 1105 | header('Content-Disposition: attachment; filename='.$name); |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | header('Expires: 0'); |
1108 | 1108 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1109 | 1109 | header('Pragma: public'); |
1110 | - header('Content-Length: ' . filesize($path)); |
|
1110 | + header('Content-Length: '.filesize($path)); |
|
1111 | 1111 | flush(); |
1112 | 1112 | readfile($path); |
1113 | 1113 | } |
@@ -1156,10 +1156,10 @@ discard block |
||
1156 | 1156 | // Otherwise return 0. |
1157 | 1157 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1158 | 1158 | // |
1159 | -function boinc_client_version(){ |
|
1159 | +function boinc_client_version() { |
|
1160 | 1160 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1161 | 1161 | $x = $_SERVER['HTTP_USER_AGENT']; |
1162 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1162 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1163 | 1163 | if (preg_match($e, $x, $matches)) { |
1164 | 1164 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
1165 | 1165 | } |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | $rem_name = $name."_remaining"; |
1189 | 1189 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
1190 | 1190 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
1191 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1191 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1192 | 1192 | ; |
1193 | 1193 | } |
1194 | 1194 | |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | // use the following around text with long lines, |
1219 | 1219 | // to limit the width and make it more readable. |
1220 | 1220 | // |
1221 | -function text_start($width=640) { |
|
1221 | +function text_start($width = 640) { |
|
1222 | 1222 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
1223 | 1223 | } |
1224 | 1224 | function text_end() { |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | function cert_filename() { |
1247 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
1247 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | // if user hasn't validated their email addr, tell them to |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | // with an existing web framework can more easily do so. |
255 | 255 | // To do so, define page_head() in html/project/project.inc |
256 | 256 | // |
257 | -if (!function_exists("page_head")){ |
|
257 | +if (!function_exists("page_head")) { |
|
258 | 258 | function page_head( |
259 | 259 | $title, |
260 | 260 | // page title. Put in <title>, used as title for browser tab. |
@@ -375,7 +375,8 @@ discard block |
||
375 | 375 | echo '<div class="container-fluid"> |
376 | 376 | '; |
377 | 377 | |
378 | - switch($title) { //kludge |
|
378 | + switch($title) { |
|
379 | +//kludge |
|
379 | 380 | case tra("Log in"): |
380 | 381 | case tra("Create an account"): |
381 | 382 | case tra("Server status page"): |
@@ -390,7 +391,7 @@ discard block |
||
390 | 391 | |
391 | 392 | // See the comments for page_head() |
392 | 393 | // |
393 | -if (!function_exists("page_tail")){ |
|
394 | +if (!function_exists("page_tail")) { |
|
394 | 395 | function page_tail( |
395 | 396 | $show_date=false, |
396 | 397 | // true for pages that are generated periodically rather than on the fly |
@@ -895,7 +896,7 @@ discard block |
||
895 | 896 | return $str; |
896 | 897 | } |
897 | 898 | |
898 | -function strip_bbcode($string){ |
|
899 | +function strip_bbcode($string) { |
|
899 | 900 | return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
900 | 901 | } |
901 | 902 | |
@@ -1156,7 +1157,7 @@ discard block |
||
1156 | 1157 | // Otherwise return 0. |
1157 | 1158 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1158 | 1159 | // |
1159 | -function boinc_client_version(){ |
|
1160 | +function boinc_client_version() { |
|
1160 | 1161 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1161 | 1162 | $x = $_SERVER['HTTP_USER_AGENT']; |
1162 | 1163 | $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |