Passed
Pull Request — master (#5252)
by David
09:18
created
html/inc/sandbox.inc 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 // Return path of sandbox directory for the given user.
33 33
 // Create dir if not present.
34 34
 //
35
-if (!function_exists("sandbox_dir")){
35
+if (!function_exists("sandbox_dir")) {
36 36
 function sandbox_dir($user) {
37 37
     $dir = parse_config(get_config(), "<sandbox_dir>");
38 38
     if (!$dir) {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     foreach ($files as $file) {
64 64
         $path = "$dir/$file";
65 65
         [$err, $file_size, $file_md5] = sandbox_parse_link_file($path);
66
-        if (!$err){
66
+        if (!$err) {
67 67
             if (strcmp($md5, $file_md5) == 0) {
68 68
                 $exist = true;
69 69
                 $elf = $file;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     }
131 131
     $files = sandbox_file_names($user);
132 132
     foreach ($files as $f) {
133
-        if ($regexp && !preg_match("/$regexp/",$f)) continue;
133
+        if ($regexp && !preg_match("/$regexp/", $f)) continue;
134 134
         $x .= "<option value=\"$f\">$f</option>\n";
135 135
     }
136 136
     $x .= "</select>\n";
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
 //check if a file is still being used by a unfinished batch
142 142
 //
143
-function sandbox_file_in_use($user, $file){
143
+function sandbox_file_in_use($user, $file) {
144 144
     $ufiles = array();
145 145
 
146 146
     // batch status: 2(completed), 3(aborted)
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
     $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3");
149 149
     if (!$pbatches) return false;
150 150
 
151
-    foreach ($pbatches as $batch){
152
-        $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" );
153
-        if ($wus == null){
151
+    foreach ($pbatches as $batch) {
152
+        $wus = BoincWorkUnit::enum("batch = $batch->id limit 1");
153
+        if ($wus == null) {
154 154
             //echo " no workunit for this batch<br/>";
155 155
             continue;
156 156
         }
157
-        foreach($wus as $wu){
157
+        foreach ($wus as $wu) {
158 158
             $x = "<in>".$wu->xml_doc."</in>";
159 159
             $x = simplexml_load_string($x);
160 160
             global $fanout;
161
-            foreach($x->workunit->file_ref as $fr){
161
+            foreach ($x->workunit->file_ref as $fr) {
162 162
                 $pname = (string)$fr->file_name;
163 163
                 $ufiles[] = $pname;
164 164
             }
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
     $dir = sandbox_dir($user);
170 170
     $path = $dir."/".$file;
171 171
     list($err, $size, $md5) = sandbox_parse_link_file($path);
172
-    if (!$err){
172
+    if (!$err) {
173 173
         $f = sandbox_file_name($user, $md5);
174
-        foreach($ufiles as $uf) {
175
-            if (strcmp($f,$uf) == 0){
174
+        foreach ($ufiles as $uf) {
175
+            if (strcmp($f, $uf) == 0) {
176 176
                 return true;
177 177
             }
178 178
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 // Return path of sandbox directory for the given user.
33 33
 // Create dir if not present.
34 34
 //
35
-if (!function_exists("sandbox_dir")){
35
+if (!function_exists("sandbox_dir")) {
36 36
 function sandbox_dir($user) {
37 37
     $dir = parse_config(get_config(), "<sandbox_dir>");
38 38
     if (!$dir) {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     foreach ($files as $file) {
64 64
         $path = "$dir/$file";
65 65
         [$err, $file_size, $file_md5] = sandbox_parse_link_file($path);
66
-        if (!$err){
66
+        if (!$err) {
67 67
             if (strcmp($md5, $file_md5) == 0) {
68 68
                 $exist = true;
69 69
                 $elf = $file;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
 //check if a file is still being used by a unfinished batch
142 142
 //
143
-function sandbox_file_in_use($user, $file){
143
+function sandbox_file_in_use($user, $file) {
144 144
     $ufiles = array();
145 145
 
146 146
     // batch status: 2(completed), 3(aborted)
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
     $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3");
149 149
     if (!$pbatches) return false;
150 150
 
151
-    foreach ($pbatches as $batch){
151
+    foreach ($pbatches as $batch) {
152 152
         $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" );
153
-        if ($wus == null){
153
+        if ($wus == null) {
154 154
             //echo " no workunit for this batch<br/>";
155 155
             continue;
156 156
         }
157
-        foreach($wus as $wu){
157
+        foreach($wus as $wu) {
158 158
             $x = "<in>".$wu->xml_doc."</in>";
159 159
             $x = simplexml_load_string($x);
160 160
             global $fanout;
161
-            foreach($x->workunit->file_ref as $fr){
161
+            foreach($x->workunit->file_ref as $fr) {
162 162
                 $pname = (string)$fr->file_name;
163 163
                 $ufiles[] = $pname;
164 164
             }
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
     $dir = sandbox_dir($user);
170 170
     $path = $dir."/".$file;
171 171
     list($err, $size, $md5) = sandbox_parse_link_file($path);
172
-    if (!$err){
172
+    if (!$err) {
173 173
         $f = sandbox_file_name($user, $md5);
174 174
         foreach($ufiles as $uf) {
175
-            if (strcmp($f,$uf) == 0){
175
+            if (strcmp($f,$uf) == 0) {
176 176
                 return true;
177 177
             }
178 178
 
Please login to merge, or discard this patch.
html/inc/bootstrap.inc 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
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;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 // output a panel.
215 215
 // $content_func is a function that generates the panel contents
216 216
 //
217
-function panel($title, $content_func, $class="panel-primary", $body_class="") {
217
+function panel($title, $content_func, $class = "panel-primary", $body_class = "") {
218 218
     echo sprintf('<div class="panel %s">
219 219
         ', $class
220 220
     );
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 // are functions that generate the top, left, and right content
241 241
 // $left_width is the width of left column in 1/12 units.
242 242
 //
243
-function grid($top_func, $left_func, $right_func, $left_width=6) {
243
+function grid($top_func, $left_func, $right_func, $left_width = 6) {
244 244
     echo '
245 245
         <div class="container-fluid">
246 246
     ';
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             </div>
256 256
         ';
257 257
     }
258
-    $right_width = 12-$left_width;
258
+    $right_width = 12 - $left_width;
259 259
     echo '
260 260
         <div class="row">
261 261
         <div class="col-sm-'.$left_width.'">
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 //      use extra = "name=x"
280 280
 //      call forum_focus(x, foo) after defining the field
281 281
 //
282
-function form_start($action, $method='get', $extra='') {
282
+function form_start($action, $method = 'get', $extra = '') {
283 283
     echo sprintf(
284 284
         '<div class="container-fluid">
285 285
         <form class="form-horizontal" method="%s" action="%s" %s>'
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 // just the input field
312 312
 //
313 313
 function form_input_text_field(
314
-    $name, $value='', $type='text', $attrs='', $extra=''
314
+    $name, $value = '', $type = 'text', $attrs = '', $extra = ''
315 315
 ) {
316 316
     return sprintf(
317 317
         '<input %s type="%s" class="form-control" name="%s" value="%s">%s',
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 // the whole row
323 323
 //
324 324
 function form_input_text(
325
-    $label, $name, $value='', $type='text', $attrs='', $extra=''
325
+    $label, $name, $value = '', $type = 'text', $attrs = '', $extra = ''
326 326
 ) {
327 327
     echo sprintf('
328 328
         <div class="form-group">
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     );
351 351
 }
352 352
 
353
-function form_input_textarea($label, $name, $value='', $nrows=4) {
353
+function form_input_textarea($label, $name, $value = '', $nrows = 4) {
354 354
     echo sprintf('
355 355
         <div class="form-group">
356 356
             <label align=right class="%s" for="%s">%s</label>
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 // same, for multiple select.
390 390
 // flags, if non-null, says which ones are selected
391 391
 //
392
-function form_select_multiple($label, $name, $items, $flags=null) {
392
+function form_select_multiple($label, $name, $items, $flags = null) {
393 393
     echo sprintf('
394 394
         <div class="form-group">
395 395
             <label align=right class="%s" for="%s">%s</label>
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     );
401 401
     $n = 0;
402 402
     foreach ($items as $i) {
403
-        $s = ($flags && $flags[$n])?'selected':'';
403
+        $s = ($flags && $flags[$n]) ? 'selected' : '';
404 404
         echo '<option '.$s.' value="'.$i[0].'">'.$i[1].'</option>
405 405
         ';
406 406
         $n++;
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 
411 411
 // return a list of string for checkbox items
412 412
 //
413
-function checkbox_item_strings($items, $attrs='') {
413
+function checkbox_item_strings($items, $attrs = '') {
414 414
     $x = [];
415 415
     foreach ($items as $i) {
416 416
         $x[] = sprintf('<input %s type="checkbox" name="%s" %s> %s
417 417
             ',
418
-            $attrs, $i[0], $i[2]?"checked":"", $i[1]
418
+            $attrs, $i[0], $i[2] ? "checked" : "", $i[1]
419 419
         );
420 420
     }
421 421
     return $x;
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 
424 424
 // $items is list of (name, label, checked)
425 425
 //
426
-function form_checkboxes($label, $items, $attrs='') {
426
+function form_checkboxes($label, $items, $attrs = '') {
427 427
     echo sprintf('
428 428
         <div class="form-group">
429 429
             <label align=right class="%s">%s</label>
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
         FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS
450 450
     );
451 451
     foreach ($items as $i) {
452
-        $checked = ($selected == $i[0])?"checked":"";
452
+        $checked = ($selected == $i[0]) ? "checked" : "";
453 453
         echo sprintf('<input type="radio" name="%s" value="%s" %s> %s <br>
454 454
             ',
455 455
             $name, $i[0], $checked, $i[1]
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 ';
483 483
 }
484 484
 
485
-function form_submit($text, $attrs='') {
485
+function form_submit($text, $attrs = '') {
486 486
     form_general(
487 487
         "",
488 488
         sprintf('<button %s type="submit" class="btn btn-success">%s</button>',
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
     );
492 492
 }
493 493
 
494
-function form_checkbox($label, $name, $checked=false) {
494
+function form_checkbox($label, $name, $checked = false) {
495 495
     echo sprintf('
496 496
         <div class="form-group">
497 497
             <input type="checkbox" name="%s" %s> &nbsp; <span class="lead">%s</span>
498 498
         </div>
499
-        ', $name, $checked?"checked":"", $label
499
+        ', $name, $checked ? "checked" : "", $label
500 500
     );
501 501
 }
Please login to merge, or discard this patch.
html/user/sandbox.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     } else {
68 68
         sort($files);
69 69
         start_table();
70
-        table_header("Name<br><p class=\"text-muted\">(click to view)</p>", "Modified", "Size (bytes)", "MD5", "Delete","Download");
70
+        table_header("Name<br><p class=\"text-muted\">(click to view)</p>", "Modified", "Size (bytes)", "MD5", "Delete", "Download");
71 71
         foreach ($files as $f) {
72 72
             $path = "$dir/$f";
73 73
             list($error, $size, $md5) = sandbox_parse_link_file($path);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $s = stat($tmp_name);
118 118
         $size = $s['size'];
119 119
         [$exists, $elf] = sandbox_lf_exists($user, $md5);
120
-        if (!$exists){
120
+        if (!$exists) {
121 121
             // move file to download dir
122 122
             //
123 123
             $phys_path = sandbox_physical_path($user, $md5);
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
         error_page("physical file is missing");
151 151
     }
152 152
     $bused = sandbox_file_in_use($user, $name);
153
-    if ($bused){
153
+    if ($bused) {
154 154
         $notice = "<strong>$name</strong> is being used by batch(es), you can not delete it now!<br/>";
155
-    } else{
155
+    } else {
156 156
         unlink("$dir/$name");
157 157
         $notice = "<strong>$name</strong> was deleted from your sandbox<br/>";
158 158
         [$exists, $elf] = sandbox_lf_exists($user, $md5);
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 if (!$action) $action = post_str('action', true);
197 197
 
198 198
 switch ($action) {
199
-case '': list_files($user,""); break;
199
+case '': list_files($user, ""); break;
200 200
 case 'upload_file': upload_file($user); break;
201 201
 case 'delete_file': delete_file($user); break;
202 202
 case 'download_file': download_file($user); break;
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $s = stat($tmp_name);
118 118
         $size = $s['size'];
119 119
         [$exists, $elf] = sandbox_lf_exists($user, $md5);
120
-        if (!$exists){
120
+        if (!$exists) {
121 121
             // move file to download dir
122 122
             //
123 123
             $phys_path = sandbox_physical_path($user, $md5);
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
         error_page("physical file is missing");
151 151
     }
152 152
     $bused = sandbox_file_in_use($user, $name);
153
-    if ($bused){
153
+    if ($bused) {
154 154
         $notice = "<strong>$name</strong> is being used by batch(es), you can not delete it now!<br/>";
155
-    } else{
155
+    } else {
156 156
         unlink("$dir/$name");
157 157
         $notice = "<strong>$name</strong> was deleted from your sandbox<br/>";
158 158
         [$exists, $elf] = sandbox_lf_exists($user, $md5);
Please login to merge, or discard this patch.