Passed
Pull Request — master (#5918)
by David
13:04
created
html/user/buda_submit.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 //
55 55
 function unzip_batch_file($user, $batch_file) {
56 56
     @mkdir("../../buda_batches");
57
-    for ($i=0; $i<1000; $i++) {
57
+    for ($i = 0; $i < 1000; $i++) {
58 58
         $batch_dir = "../../buda_batches/$i";
59 59
         $batch_dir_name = $i;
60 60
         $ret = @mkdir($batch_dir);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         }
105 105
         $job_files = [];
106 106
         $cmdline = '';
107
-        foreach(scandir("$batch_dir/$fname") as $f2) {
107
+        foreach (scandir("$batch_dir/$fname") as $f2) {
108 108
             if ($f2[0] == '.') continue;
109 109
             if ($f2 == 'cmdline') {
110 110
                 $cmdline = file_get_contents("$batch_dir/$f2");
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 function stage_input_files($batch_dir, $batch_desc, $batch_id) {
153 153
     $n = count($batch_desc->shared_files);
154 154
     $batch_desc->shared_files_phys_names = [];
155
-    for ($i=0; $i<$n; $i++) {
155
+    for ($i = 0; $i < $n; $i++) {
156 156
         $path = sprintf('%s/%s', $batch_dir, $batch_desc->shared_files[$i]);
157 157
         [$md5, $size] = $batch_desc->shared_file_infos[$i];
158 158
         $phys_name = sprintf('batch_%d_%s', $batch_id, $md5);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     foreach ($batch_desc->jobs as $job) {
163 163
         $n = count($batch_desc->unshared_files);
164 164
         $job->phys_names = [];
165
-        for ($i=0; $i<$n; $i++) {
165
+        for ($i = 0; $i < $n; $i++) {
166 166
             $path = sprintf('%s/%s/%s',
167 167
                 $batch_dir, $job->dir, $batch_desc->unshared_files[$i]
168 168
             );
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     //
265 265
     $x = "<input_template>\n";
266 266
     $ninfiles = 1 + count($variant_desc->input_file_names) + count($variant_desc->app_files);
267
-    for ($i=0; $i<$ninfiles; $i++) {
267
+    for ($i = 0; $i < $ninfiles; $i++) {
268 268
         $x .= "   <file_info>\n      <no_delete/>\n   </file_info>\n";
269 269
     }
270 270
     $x .= "   <workunit>\n";
Please login to merge, or discard this patch.
html/user/submit.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 function progress_bar($batch, $wus, $width) {
409 409
     $w_success = $width*$batch->fraction_done;
410 410
     $w_fail = $width*$batch->nerror_jobs/$batch->njobs;
411
-    $nsuccess = $batch->njobs * $batch->fraction_done;
411
+    $nsuccess = $batch->njobs*$batch->fraction_done;
412 412
     $nsent = wus_nsent($wus);
413 413
     $nprog = $nsent - $nsuccess - $batch->nerror_jobs;
414 414
     $w_prog = $width*$nprog/$batch->njobs;
415
-    $nunsent = $batch->njobs-$nsent;
415
+    $nunsent = $batch->njobs - $nsent;
416 416
     $w_unsent = $width*$nunsent/$batch->njobs;
417 417
     $x = '<table height=20><tr>';
418 418
     if ($w_fail) {
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
     if ($owner) {
467 467
         row2('submitter', $owner->name);
468 468
     }
469
-    row2("application", $app?$app->name:'---');
469
+    row2("application", $app ? $app->name : '---');
470 470
     row2("state", batch_state_string($batch->state));
471 471
     //row2("# jobs", $batch->njobs);
472 472
     //row2("# error jobs", $batch->nerror_jobs);
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
         $x[] = "Download Results";
522 522
     }
523 523
     row_heading_array($x);
524
-    foreach($wus as $wu) {
524
+    foreach ($wus as $wu) {
525 525
         $resultid = $wu->canonical_resultid;
526 526
         if ($resultid) {
527 527
             $y = '<font color="green">completed</font>';
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
             $text = "---";
531 531
             if ($batch->state == BATCH_STATE_COMPLETE) {
532 532
                 $y = '<font color="red">failed</font>';
533
-            }   else {
533
+            } else {
534 534
                 $y = "in progress";
535 535
             }
536 536
         }
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     $results = BoincResult::enum("workunitid=$wuid");
581 581
     $upload_dir = parse_config(get_config(), "<upload_dir>");
582 582
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
583
-    foreach($results as $result) {
583
+    foreach ($results as $result) {
584 584
         $x = [
585 585
             "<a href=result.php?resultid=$result->id>$result->id</a>",
586 586
             state_string($result)
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         if ($result->server_state == RESULT_SERVER_STATE_OVER) {
590 590
             $phys_names = get_outfile_names($result);
591 591
             $log_names = get_outfile_log_names($result);
592
-            for ($i=0; $i<count($phys_names); $i++) {
592
+            for ($i = 0; $i < count($phys_names); $i++) {
593 593
                 if ($web_app->assim_move) {
594 594
                     // file is in
595 595
                     // project/results/<batchid>/<wu_name>__file_<log_name>
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 
457 457
     $web_app = $web_apps[$app->name];
458 458
 
459
-    page_head("Batch $batch_id");
459
+    page_head("batch $batch_id");
460 460
     text_start();
461 461
     start_table();
462 462
     row2("name", $batch->name);
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     $app = BoincApp::lookup_id($wu->appid);
562 562
     $web_app = $web_apps[$app->name];
563 563
 
564
-    page_head("Job $wu->name");
564
+    page_head("job $wu->name");
565 565
     text_start();
566 566
 
567 567
     echo "
Please login to merge, or discard this patch.
html/user/sandbox.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     } else {
78 78
         sort($files);
79 79
         start_table();
80
-        table_header("Name<br><p class=\"text-muted\">(click to view text files)</p>", "Modified", "Size (bytes)", "MD5", "Delete","Download");
80
+        table_header("Name<br><p class=\"text-muted\">(click to view text files)</p>", "Modified", "Size (bytes)", "MD5", "Delete", "Download");
81 81
         foreach ($files as $f) {
82 82
             [$md5, $size] = sandbox_parse_info_file($user, $f);
83 83
             $path = "$dir/$f";
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     $notice = "";
109 109
     $dir = sandbox_dir($user);
110 110
     $count = count($_FILES['new_file']['tmp_name']);
111
-    for ($i=0; $i<$count; $i++) {
111
+    for ($i = 0; $i < $count; $i++) {
112 112
         $tmp_name = $_FILES['new_file']['tmp_name'][$i];
113 113
         if (!is_uploaded_file($tmp_name)) {
114 114
             error_page("$tmp_name is not uploaded file");
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 if (!$action) $action = post_str('action', true);
187 187
 
188 188
 switch ($action) {
189
-case '': list_files($user,""); break;
189
+case '': list_files($user, ""); break;
190 190
 case 'upload_file': upload_file($user); break;
191 191
 case 'add_file': add_file($user); break;
192 192
 case 'delete_file': delete_file($user); break;
Please login to merge, or discard this patch.
html/user/buda.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 // show list of BUDA apps and variants,
33 33
 // w/ buttons for adding and deleting
34 34
 //
35
-function app_list($notice=null) {
35
+function app_list($notice = null) {
36 36
     global $buda_root;
37 37
     if (!is_dir($buda_root)) {
38 38
         mkdir($buda_root);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     $dir = "$buda_root/$app/$variant";
103 103
     start_table();
104 104
     table_header('name', 'size', 'md5');
105
-    foreach(scandir($dir) as $f) {
105
+    foreach (scandir($dir) as $f) {
106 106
         if ($f[0] == '.') continue;
107 107
         [$md5, $size] = parse_info_file("$dir/.md5/$f");
108 108
         table_row(
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     global $buda_root;
99 99
     $app = get_str('app');
100 100
     $variant = get_str('variant');
101
-    page_head("App $app variant $variant");
101
+    page_head("app $app variant $variant");
102 102
     $dir = "$buda_root/$app/$variant";
103 103
     start_table();
104 104
     table_header('name', 'size', 'md5');
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     // Note: we don't currently allow indirect file access.
205 205
     // If we did, we'd need to create job.toml to mount project dir
206 206
 
207
-    app_list("Variant $variant added for app $app.");
207
+    app_list("variant $variant added for app $app.");
208 208
 }
209 209
 
210 210
 function variant_delete() {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         if ($ret) {
229 229
             error_page("delete failed");
230 230
         }
231
-        $notice = "Variant $variant of app $app removed.";
231
+        $notice = "variant $variant of app $app removed.";
232 232
         app_list($notice);
233 233
     } else {
234 234
         page_head("Confirm");
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     $name = get_str('name');
258 258
     $dir = "$buda_root/$name";
259 259
     if (file_exists($dir)) {
260
-        error_page("App $name already exists.");
260
+        error_page("app $name already exists.");
261 261
     }
262 262
     mkdir($dir);
263 263
     header("Location: buda.php");
Please login to merge, or discard this patch.
html/inc/util.inc 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -33,17 +33,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 }
1135 1135
 
1136 1136
 function do_download($path) {
1137
-    $name=basename($path);
1137
+    $name = basename($path);
1138 1138
     header('Content-Description: File Transfer');
1139 1139
     header('Content-Type: application/octet-stream');
1140 1140
     header('Content-Disposition: attachment; filename='.$name);
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
     header('Expires: 0');
1143 1143
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1144 1144
     header('Pragma: public');
1145
-    header('Content-Length: ' . filesize($path));
1145
+    header('Content-Length: '.filesize($path));
1146 1146
     flush();
1147 1147
     readfile($path);
1148 1148
 }
@@ -1191,10 +1191,10 @@  discard block
 block discarded – undo
1191 1191
 // Otherwise return 0.
1192 1192
 // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)"
1193 1193
 //
1194
-function boinc_client_version(){
1194
+function boinc_client_version() {
1195 1195
     if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0;
1196 1196
     $x = $_SERVER['HTTP_USER_AGENT'];
1197
-    $e =  "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1197
+    $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1198 1198
     if (preg_match($e, $x, $matches)) {
1199 1199
         return $matches[1]*10000 + $matches[2]*100 + $matches[3];
1200 1200
     }
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
     $rem_name = $name."_remaining";
1224 1224
     return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\"
1225 1225
         onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea>
1226
-        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1226
+        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1227 1227
     ;
1228 1228
 }
1229 1229
 
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 // use the following around text with long lines,
1254 1254
 // to limit the width and make it more readable.
1255 1255
 //
1256
-function text_start($width=640) {
1256
+function text_start($width = 640) {
1257 1257
     echo sprintf("<div style=\"max-width: %dpx;\">\n", $width);
1258 1258
 }
1259 1259
 function text_end() {
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 }
1280 1280
 
1281 1281
 function cert_filename() {
1282
-    return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php";
1282
+    return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php";
1283 1283
 }
1284 1284
 
1285 1285
 // if user hasn't validated their email addr, tell them to
@@ -1296,6 +1296,6 @@  discard block
 block discarded – undo
1296 1296
     }
1297 1297
 }
1298 1298
 
1299
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
1299
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
1300 1300
 
1301 1301
 ?>
Please login to merge, or discard this patch.
html/inc/sandbox.inc 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 // return list of files matching given pattern,
91 91
 // in the format used for form_select() and form_select_multiple()
92 92
 //
93
-function sandbox_select_items($user, $pattern=null) {
93
+function sandbox_select_items($user, $pattern = null) {
94 94
     $sbfiles = sandbox_file_names($user);
95 95
     $sbitems = [];
96 96
     foreach ($sbfiles as $f) {
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     }
112 112
     $files = sandbox_file_names($user);
113 113
     foreach ($files as $f) {
114
-        if ($regexp && !preg_match("/$regexp/",$f)) continue;
114
+        if ($regexp && !preg_match("/$regexp/", $f)) continue;
115 115
         $x .= "<option value=\"$f\">$f</option>\n";
116 116
     }
117 117
     $x .= "</select>\n";
Please login to merge, or discard this patch.
html/inc/submit_util.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         }
137 137
     }
138 138
     if ($fp_total) {
139
-        $batch->fraction_done = $fp_done / $fp_total;
139
+        $batch->fraction_done = $fp_done/$fp_total;
140 140
     }
141 141
     if ($completed && $batch->state == BATCH_STATE_IN_PROGRESS) {
142 142
         $batch->state = BATCH_STATE_COMPLETE;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 // get the total size of output files of a batch
257 257
 //
258 258
 function batch_output_file_size($batchid) {
259
-    $batch_td_size=0;
259
+    $batch_td_size = 0;
260 260
     $wus = BoincWorkunit::enum("batch=$batchid");
261 261
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
262 262
     $upload_dir = parse_config(get_config(), "<upload_dir>");
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 }
287 287
 
288 288
 function boinc_get_wu_output_files_url($user, $wu_id) {
289
-    $auth_str =  md5($user->authenticator.$wu_id);
289
+    $auth_str = md5($user->authenticator.$wu_id);
290 290
     return "get_output.php?cmd=workunit_files&wu_id=$wu_id&auth_str=$auth_str";
291 291
 }
292 292
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
     if (!file_exists($path)) return null;
321 321
     $x = file_get_contents($path);
322 322
     $n = sscanf($x, "%s %d", $md5, $size);
323
-    if ($n != 2 || strlen($md5)!=32) {
323
+    if ($n != 2 || strlen($md5) != 32) {
324 324
         return null;
325 325
     }
326 326
     return [$md5, $size];
Please login to merge, or discard this patch.
html/inc/db_conn.inc 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 // Intended to be subclassed (e.g., BoincDb, BossaDb)
23 23
 //
24 24
 class DbConn {
25
-    var $db_conn;       // a mysqli object
26
-    var $db_name;       // the DB name
25
+    var $db_conn; // a mysqli object
26
+    var $db_name; // the DB name
27 27
 
28 28
     function init_conn($user, $passwd, $host, $name) {
29 29
         $x = explode(":", $host);
30
-        if (sizeof($x)>1) {
30
+        if (sizeof($x) > 1) {
31 31
             $host = $x[0];
32 32
             $port = $x[1];
33 33
         } else {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         }
36 36
         try {
37 37
             $this->db_conn = @new mysqli($host, $user, $passwd, $name, $port);
38
-        } catch(Exception $e) {
38
+        } catch (Exception $e) {
39 39
             return false;
40 40
         }
41 41
         if (mysqli_connect_error()) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         return $this->enum_general($classname, $query);
137 137
     }
138 138
 
139
-    function enum($table, $classname, $where_clause=null, $order_clause=null) {
139
+    function enum($table, $classname, $where_clause = null, $order_clause = null) {
140 140
         return self::enum_fields(
141 141
             $table, $classname, '*', $where_clause, $order_clause
142 142
         );
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
         if ($x) return (double)$x->$field;
182 182
         return false;
183 183
     }
184
-    function count($table, $clause="TRUE") {
184
+    function count($table, $clause = "TRUE") {
185 185
         $query = "select count(*) as total from DBNAME.$table where $clause";
186 186
         return $this->get_int($query, 'total');
187 187
     }
188
-    function sum($table, $field, $clause="") {
188
+    function sum($table, $field, $clause = "") {
189 189
         $query = "select sum($field) as total from DBNAME.$table $clause";
190 190
         return $this->get_double($query, 'total');
191 191
     }
192
-    function max($table, $field, $clause="") {
192
+    function max($table, $field, $clause = "") {
193 193
         $query = "select max($field) as total from DBNAME.$table $clause";
194 194
         return $this->get_double($query, 'total');
195 195
     }
Please login to merge, or discard this patch.