Passed
Pull Request — master (#5599)
by Vitalii
21:21 queued 10:05
created
html/inc/host.inc 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 
33 33
 function sched_log_name($x) {
34 34
     if ($x == 0) return "NO_SUCH_LOG";
35
-    return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt";
35
+    return gmdate('Y-m-d_H/Y-m-d_H:i', $x).".txt";
36 36
 }
37 37
 
38 38
 function sched_log_link($x) {
39 39
     if (file_exists("sched_logs")) {
40
-        return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>";
40
+        return "<a href=\"../sched_logs/".sched_log_name($x)."\">".time_str($x)."</a>";
41 41
     } else {
42 42
         return time_str($x);
43 43
     }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 function location_form($host) {
47 47
     $none = "selected";
48
-    $h=$w=$s=$m="";
48
+    $h = $w = $s = $m = "";
49 49
     if ($host->venue == "home") $h = "selected";
50 50
     if ($host->venue == "work") $w = "selected";
51 51
     if ($host->venue == "school") $s = "selected";
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             row2(tra("Product name"), $host->product_name);
100 100
         }
101 101
         $x = $host->timezone/3600;
102
-        if ($x >= 0) $x="+$x";
102
+        if ($x >= 0) $x = "+$x";
103 103
         row2(tra("Local Standard Time"), tra("UTC %1 hours", $x));
104 104
     } else {
105 105
         $owner = BoincUser::lookup_id($host->userid);
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
 // "[vbox|5.0.0|1|1]", where now two additional flags give information about
260 260
 // hardware virtualization support. Older clients may have the old-style
261 261
 // serialnum in the DB despite the server being upgraded.
262
-function vbox_desc($x){
263
-    if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/",$x,$matches)){
262
+function vbox_desc($x) {
263
+    if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/", $x, $matches)) {
264 264
         $desc = "Virtualbox (".$matches[1].") ".tra("installed");
265
-        if (sizeof($matches)>2){
266
-            if ($matches[3]=="1" and $matches[4]=="1") {
265
+        if (sizeof($matches) > 2) {
266
+            if ($matches[3] == "1" and $matches[4] == "1") {
267 267
                 return $desc.tra(", CPU has hardware virtualization support and it is enabled");
268
-            } elseif ($matches[3]=="1" and $matches[4]=="0") {
268
+            } elseif ($matches[3] == "1" and $matches[4] == "0") {
269 269
                 return $desc.tra(", CPU has hardware virtualization support but it is disabled");
270
-            } elseif ($matches[3]=="0") {
270
+            } elseif ($matches[3] == "0") {
271 271
                 return $desc.tra(", CPU does not have hardware virtualization support");
272 272
             }
273 273
         } else {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 // Given string of the form [BOINC|vers][type|model|count|RAM|driver-vers][vbox|vers],
282 282
 // return a human-readable version of the GPU info
283 283
 //
284
-function gpu_desc($x, $detail=true) {
284
+function gpu_desc($x, $detail = true) {
285 285
     $descs = explode("]", $x);
286 286
     array_pop($descs);
287 287
     $str = "";
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         if ($d[0] == "vbox") continue;
294 294
         if (count($d) < 5) continue;
295 295
         if ($str) $str .= "<p>";
296
-        if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] ";
296
+        if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] ";
297 297
         if ($d[0] == "CUDA") {
298 298
             $str .= "NVIDIA";
299 299
         } else if ($d[0] == "CAL") {
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
     if ($pos1 === false) return $x;
501 501
     $pos2 = strpos($model, ']');
502 502
     if ($pos2 === false) return $x;
503
-    $a = substr($model, $pos1+1, $pos2-$pos1-1);
503
+    $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1);
504 504
     $y = explode(" ", $a);
505 505
     if (count($y) == 0) return $x;
506 506
     if ($y[0] == "Family") {
507 507
         $x->info = $a;
508 508
     } else {
509 509
         $x->arch = $y[0];
510
-        $x->info = substr($a, strlen($y[0])+1);
510
+        $x->info = substr($a, strlen($y[0]) + 1);
511 511
     }
512 512
     return $x;
513 513
 }
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     $avg_time = 0;
597 597
 
598 598
     $results = BoincResult::enum("hostid=$hostid order by received_time");
599
-    foreach($results as $result) {
599
+    foreach ($results as $result) {
600 600
         if ($result->granted_credit <= 0) continue;
601 601
         $total += $result->granted_credit;
602 602
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 
690 690
 function link_url($sort, $rev, $show_all) {
691 691
     global $userid;
692
-    $x = $userid ? "&userid=$userid":"";
692
+    $x = $userid ? "&userid=$userid" : "";
693 693
     return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x";
694 694
 }
695 695
 
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 }
764 764
 
765 765
 function show_user_hosts($userid, $private, $show_all, $sort, $rev) {
766
-    $desc = false;  // whether the sort order's default is decreasing
766
+    $desc = false; // whether the sort order's default is decreasing
767 767
     switch ($sort) {
768 768
     case "total_credit": $sort_clause = "total_credit"; $desc = true; break;
769 769
     case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
     more_or_less($sort, $rev, $show_all);
787 787
 
788 788
     $now = time();
789
-    $old_hosts=0;
789
+    $old_hosts = 0;
790 790
     $i = 1;
791 791
     $hosts = BoincHost::enum("userid=$userid order by $sort_clause");
792 792
     $any_product_name = false;
@@ -798,9 +798,9 @@  discard block
 block discarded – undo
798 798
     }
799 799
     user_host_table_start($private, $sort, $rev, $show_all, $any_product_name);
800 800
     foreach ($hosts as $host) {
801
-        $is_old=false;
801
+        $is_old = false;
802 802
         if (($now - $host->rpc_time) > 30*86400) {
803
-            $is_old=true;
803
+            $is_old = true;
804 804
             $old_hosts++;
805 805
         }
806 806
         if (!$show_all && $is_old) continue;
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
     }
810 810
     end_table();
811 811
 
812
-    if ($old_hosts>0) {
812
+    if ($old_hosts > 0) {
813 813
         more_or_less($sort, $rev, $show_all);
814 814
     }
815 815
 
@@ -829,6 +829,6 @@  discard block
 block discarded – undo
829 829
     }
830 830
 }
831 831
 
832
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
832
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
833 833
 
834 834
 ?>
Please login to merge, or discard this patch.
html/inc/db_ops.inc 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -42,27 +42,27 @@  discard block
 block discarded – undo
42 42
 // @return String A user readable DateTime-String in UTC
43 43
 // @param Integer $x The mysql-Timestamp to convert
44 44
 function mysqltime_str($x) {
45
-    if(strpos($x,"-")==4) {
45
+    if (strpos($x, "-") == 4) {
46 46
         // Syntax of supplied mysql-timestamp is YYYY-MM-DD HH:MM:SS
47
-        $year = substr($x,0,4);
48
-        $month = substr($x,5,2);
49
-        $day = substr($x,8,2);
50
-        $hour = substr($x,11,2);
51
-        $minute = substr($x,14,2);
52
-        $second = substr($x,17,2);
47
+        $year = substr($x, 0, 4);
48
+        $month = substr($x, 5, 2);
49
+        $day = substr($x, 8, 2);
50
+        $hour = substr($x, 11, 2);
51
+        $minute = substr($x, 14, 2);
52
+        $second = substr($x, 17, 2);
53 53
     } else {
54 54
         // Syntax of supplied mysql-timestamp is YYYYMMDDHHMMSS
55
-        $year = substr($x,0,4);
56
-        $month = substr($x,4,2);
57
-        $day = substr($x,6,2);
58
-        $hour = substr($x,8,2);
59
-        $minute = substr($x,10,2);
60
-        $second = substr($x,12,2);
55
+        $year = substr($x, 0, 4);
56
+        $month = substr($x, 4, 2);
57
+        $day = substr($x, 6, 2);
58
+        $hour = substr($x, 8, 2);
59
+        $minute = substr($x, 10, 2);
60
+        $second = substr($x, 12, 2);
61 61
 
62 62
     }
63 63
     //make a Unix-Timestamp
64 64
     // echo "Time string is " . "$x";
65
-    $time = mktime($hour,$minute,$second,$month,$day,$year);
65
+    $time = mktime($hour, $minute, $second, $month, $day, $year);
66 66
     return time_str($time);
67 67
 }
68 68
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $constants = get_defined_constants(true);
101 101
         foreach ($constants['mysqli'] as $c => $n) if (preg_match('/^MYSQLI_TYPE_(.*)/', $c, $m)) $types[$n] = $m[1];
102 102
     }
103
-    return array_key_exists($type_id, $types)? strtolower($types[$type_id]) : "unknown";
103
+    return array_key_exists($type_id, $types) ? strtolower($types[$type_id]) : "unknown";
104 104
 }
105 105
 
106 106
 // Function prints a description of $table
@@ -110,38 +110,38 @@  discard block
 block discarded – undo
110 110
     $result = $db->do_query("SELECT * from $table LIMIT 1");
111 111
     $fields = $result->field_count;
112 112
 
113
-    $avgnum=(int)($fields/$columns);
114
-    if ($avgnum*$columns<$fields) {
113
+    $avgnum = (int)($fields/$columns);
114
+    if ($avgnum*$columns < $fields) {
115 115
         $avgnum++;
116 116
     }
117 117
 
118
-    $actualcolumns=0;
119
-    while ($avgnum*$actualcolumns<$fields) {
118
+    $actualcolumns = 0;
119
+    while ($avgnum*$actualcolumns < $fields) {
120 120
         $actualcolumns++;
121 121
     }
122 122
 
123
-    if ($which>$actualcolumns) {
123
+    if ($which > $actualcolumns) {
124 124
         return 0;
125 125
     }
126 126
 
127
-    $bot=($which-1)*$avgnum;
128
-    $top=$which*$avgnum;
127
+    $bot = ($which - 1)*$avgnum;
128
+    $top = $which*$avgnum;
129 129
 
130
-    $width=100.0/$actualcolumns;
130
+    $width = 100.0/$actualcolumns;
131 131
 
132 132
     echo "<td>";
133 133
     start_table('table-striped');
134 134
     echo "<tr><th align=\"left\">NAME</th><th align=\"left\">Type</th><th align=\"left\">Bytes</th>\n";
135
-    for ($count=$bot; $count<$top; $count++) {
136
-        if ($count<$fields) {
135
+    for ($count = $bot; $count < $top; $count++) {
136
+        if ($count < $fields) {
137 137
             $x = $result->fetch_field_direct($count);
138 138
             $name = $x->name;
139 139
             $type = mysql_fieldtype_str($x->type);
140 140
             $length = $x->length;
141 141
         } else {
142
-            $name="<br/> ";
143
-            $type="<br/>";
144
-            $length="<br/>";
142
+            $name = "<br/> ";
143
+            $type = "<br/>";
144
+            $length = "<br/>";
145 145
         }
146 146
         echo "\t<tr><td><b>$name</b></td><td>$type</td><td>$length</td></tr>\n";
147 147
     }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     echo "<h2>Description of <b>$table</b> table fields:</h2>\n";
157 157
     start_table();
158 158
     echo "<tr>";
159
-    for ($i=1; $i<=$how_many_columns; $i++) {
159
+    for ($i = 1; $i <= $how_many_columns; $i++) {
160 160
         print_describe_table_onecol($table, $i, $how_many_columns);
161 161
     }
162 162
     echo "</tr>";
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 }
176 176
 
177 177
 function print_query_field() {
178
-    $currenttime=time();
179
-    $hourago=$currenttime-3600;
180
-    $dayago=$currenttime-24*3600;
181
-    $weekago=$currenttime-7*24*3600;
178
+    $currenttime = time();
179
+    $hourago = $currenttime - 3600;
180
+    $dayago = $currenttime - 24*3600;
181
+    $weekago = $currenttime - 7*24*3600;
182 182
     echo "
183 183
         <tr>
184 184
         <td align=\"right\">Additional clauses</td>
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
     }
203 203
 }
204 204
 
205
-function append_sql_query($original,$addition,$first) {
205
+function append_sql_query($original, $addition, $first) {
206 206
     if ($first == 1) {
207
-        return $original . " where " . $addition;
207
+        return $original." where ".$addition;
208 208
     } else {
209
-        return $original . " and " . $addition;
209
+        return $original." and ".$addition;
210 210
     }
211 211
 }
212 212
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         if (isset($_GET[$name])) {
308 308
             $value = $_GET[$name];
309 309
         } else {
310
-            $value=null;
310
+            $value = null;
311 311
         }
312 312
         if (isset($_GET[$order])) {
313 313
              $order = $_GET[$order];
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     }
349 349
 
350 350
     function get_url($base = "db_action.php") {
351
-        $s = $base . "?table=$this->table$this->urlquery";
351
+        $s = $base."?table=$this->table$this->urlquery";
352 352
         return $s;
353 353
     }
354 354
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         $this->addeq('app_version_id');
364 364
         $this->addeq('exit_status');
365 365
         if (isset($_GET['nsecs'])) {
366
-            $_GET['mod_time'] = date("YmdHis",time() - $_GET['nsecs']);
366
+            $_GET['mod_time'] = date("YmdHis", time() - $_GET['nsecs']);
367 367
         }
368 368
         $this->addgt('mod_time');
369 369
         $this->addeq_not_CHOOSE_ALL('server_state');
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     if ($n == '0') { // intentional compare by string
385 385
         return "0";
386 386
     } else {
387
-        if(strlen($clauses)) {
387
+        if (strlen($clauses)) {
388 388
             return "<a href=\"db_action.php?table=result&query=$mq&$query&clauses=".urlencode($clauses)."&sort_by=mod_time&detail=low\">$n</a>";
389 389
         }
390 390
         else {
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 // Determines if in stderr_out is an error reported and prints as human readable String
398 398
 // @return String A human readable string if error otherwise FALSE
399 399
 // @param String $stderr_out the stderr_out value to parse
400
-function stderr_error_string($stderr_out){
400
+function stderr_error_string($stderr_out) {
401 401
     $y = parse_element($stderr_out, "<error_code>");
402 402
     $x = 0;
403 403
     if ($y) {
404 404
         $x = (int)$y;
405 405
     }
406
-    if (0<=$x && $x<=9) {
406
+    if (0 <= $x && $x <= 9) {
407 407
         return FALSE;
408 408
     } else {
409 409
         return "$x ".error_code_str($x);
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 }
412 412
 
413 413
 function admin_show_result_summary() {
414
-    $ntotal =0;     // TODO: how to count $result?
415
-    $nvalid = 0;    // for SUCCESS results
414
+    $ntotal = 0; // TODO: how to count $result?
415
+    $nvalid = 0; // for SUCCESS results
416 416
     $ninvalid = 0;
417 417
     $nfile_deleted = 0;
418 418
 
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
     $outcome = array();
421 421
     $client_state = array();
422 422
 
423
-    for ($ss=1; $ss<6; $ss++) {
423
+    for ($ss = 1; $ss < 6; $ss++) {
424 424
         $server_state[$ss] = 0;
425 425
     }
426
-    for ($ro=0; $ro<8; $ro++) {
426
+    for ($ro = 0; $ro < 8; $ro++) {
427 427
         $outcome[$ro] = 0;
428 428
     }
429
-    for ($cs=1; $cs<7; $cs++) {
429
+    for ($cs = 1; $cs < 7; $cs++) {
430 430
         $client_state[$cs] = 0;
431 431
     }
432
-    for ($fds=0; $fds<4; $fds++) {
432
+    for ($fds = 0; $fds < 4; $fds++) {
433 433
         $delete_state[$fds] = 0;
434 434
     }
435
-    for ($vs=0; $vs<NVALIDATE_STATES; $vs++) {
436
-        $validate_state[$vs]=0;
435
+    for ($vs = 0; $vs < NVALIDATE_STATES; $vs++) {
436
+        $validate_state[$vs] = 0;
437 437
     }
438 438
 
439 439
     $_GET['table'] = 'result';
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
         //
509 509
         $delay = parse_config(get_config(), "<delete_delay_hours>");
510 510
         if ($delay) {
511
-            $start2 = $start - $delay*3600;;
511
+            $start2 = $start - $delay*3600; ;
512 512
             $main_query .= " and ((file_delete_state>1 and mod_time>FROM_UNIXTIME($start2)) or (mod_time>FROM_UNIXTIME($start)))";
513 513
         } else {
514 514
             $main_query .= " and mod_time > FROM_UNIXTIME($start)";
@@ -567,20 +567,20 @@  discard block
 block discarded – undo
567 567
 
568 568
     start_table();
569 569
     echo "<tr valign=\"top\">";
570
-    echo "<td><h2>" . link_results("$ntotal results", $urlquery, '', '') . "</h2></td>";
571
-    echo "<td><h2>" . link_results("'Over' results", $urlquery, "server_state=5", '') . "</h2></td>";
572
-    echo "<td><h2>" . link_results("'Success' results", $urlquery, "outcome=1", '') . "</h2></td>";
573
-    echo "<td><h2>" . link_results("'Client error' results", $urlquery, "outcome=3", '') . "</h2></td>";
570
+    echo "<td><h2>".link_results("$ntotal results", $urlquery, '', '')."</h2></td>";
571
+    echo "<td><h2>".link_results("'Over' results", $urlquery, "server_state=5", '')."</h2></td>";
572
+    echo "<td><h2>".link_results("'Success' results", $urlquery, "outcome=1", '')."</h2></td>";
573
+    echo "<td><h2>".link_results("'Client error' results", $urlquery, "outcome=3", '')."</h2></td>";
574 574
     echo "</tr>";
575 575
     echo "<tr valign=\"top\">";
576 576
     echo "<td>";
577 577
     start_table('table-striped');
578 578
     echo "<tr><th>Server state</th><th># results</th></tr>\n";
579
-    for ($ss=1; $ss<6; $ss++) {
579
+    for ($ss = 1; $ss < 6; $ss++) {
580 580
         $res = new StdClass;
581 581
         $res->server_state = $ss;
582 582
         row2(result_server_state_string($res),
583
-             link_results("$server_state[$ss]",  $urlquery,"server_state=$ss", '')
583
+             link_results("$server_state[$ss]", $urlquery, "server_state=$ss", '')
584 584
         );
585 585
     }
586 586
     end_table();
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
     start_table('table-striped');
591 591
     echo "<tr><th>Outcome</th><th># results</th></tr>\n";
592 592
 
593
-    for ($ro=0; $ro<8; $ro++) {
593
+    for ($ro = 0; $ro < 8; $ro++) {
594 594
         $res = new StdClass;
595 595
         $res->outcome = $ro;
596 596
         $res->exit_status = 0;
597
-        c_row2($outcome[$ro]?outcome_color($ro):'', result_outcome_string($res),
597
+        c_row2($outcome[$ro] ?outcome_color($ro) : '', result_outcome_string($res),
598 598
             link_results("$outcome[$ro]", $urlquery, "outcome=$ro", '')
599 599
         );
600 600
     }
@@ -604,18 +604,18 @@  discard block
 block discarded – undo
604 604
     echo "<td>";
605 605
     start_table('table-striped');
606 606
     echo "<tr><th>Validate state</th><th># results</th></tr>\n";
607
-    for ($vs=0; $vs<NVALIDATE_STATES; $vs++) {
607
+    for ($vs = 0; $vs < NVALIDATE_STATES; $vs++) {
608 608
         $res = new StdClass;
609 609
         $res->validate_state = $vs;
610 610
         $res->exit_status = 0;
611
-        c_row2($validate_state[$vs]?validate_color($vs):'', validate_state_str($res),
611
+        c_row2($validate_state[$vs] ?validate_color($vs) : '', validate_state_str($res),
612 612
         link_results("$validate_state[$vs]", $urlquery, "validate_state=$vs", "outcome=1"));
613 613
     }
614 614
     end_table();
615 615
     start_table('table-striped');
616 616
     echo "<tr><th>File Delete state</th><th># results</th></tr>\n";
617 617
 
618
-    for ($fds=0; $fds<4; $fds++) {
618
+    for ($fds = 0; $fds < 4; $fds++) {
619 619
         row2(file_delete_state_str($fds),
620 620
         link_results("$file_delete[$fds]", $urlquery, "outcome=1", "file_delete_state=$fds"));
621 621
     }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
     echo "<td>";
628 628
     start_table('table-striped');
629 629
     echo "<tr><th>Client state</th><th># results</th></tr>\n";
630
-    for ($cs=1; $cs<7; $cs++) {
630
+    for ($cs = 1; $cs < 7; $cs++) {
631 631
         $res = new StdClass;
632 632
         $res->client_state = $cs;
633 633
         $res->exit_status = 0;
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
         <select name=\"server_state\">
647 647
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
648 648
     ";
649
-    for ($i=1; $i<6; $i++) {
649
+    for ($i = 1; $i < 6; $i++) {
650 650
         $res = new StdClass;
651
-        $res->server_state=$i;
651
+        $res->server_state = $i;
652 652
         echo "<option value=\"$i\"> "."[$i]&nbsp;&nbsp;".'   '.result_server_state_string($res)."</option>\n";
653 653
     }
654 654
     echo "</select>\n";
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
         <select name=\"outcome\">
660 660
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
661 661
     ";
662
-    for ($i=0; $i<8; $i++) {
662
+    for ($i = 0; $i < 8; $i++) {
663 663
         $res = new StdClass;
664 664
         $res->outcome = $i;
665 665
         $res->exit_status = 0;
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
         <select name=\"validate_state\">
674 674
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
675 675
         ";
676
-    for ($vs=0; $vs<NVALIDATE_STATES; $vs++) {
676
+    for ($vs = 0; $vs < NVALIDATE_STATES; $vs++) {
677 677
         $res = new StdClass;
678 678
         $res->validate_state = $vs;
679 679
         $res->exit_status = 0;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
         <select name=\"client_state\">
688 688
         <option value=\"CHOOSE_ALL\" selected=\"selected\"> Any </option>
689 689
     ";
690
-    for ($i=0; $i<7; $i++) {
690
+    for ($i = 0; $i < 7; $i++) {
691 691
         $res = new StdClass;
692 692
         $res->client_state = $i;
693 693
         $res->exit_status = 0;
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 }
725 725
 
726 726
 function table_title($table) {
727
-    switch($table) {
727
+    switch ($table) {
728 728
     case "platform": return "Platforms";
729 729
     case "app": return "Applications";
730 730
     case "app_version": return "Application Versions";
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
     row("Created", time_str($platform->create_time));
745 745
     row("Name", $platform->name);
746 746
     row("User friendly name", $platform->user_friendly_name);
747
-    row("","<a href=\"db_action.php?table=app_version&platformid=$platform->id\">App versions for this platform</a>");
747
+    row("", "<a href=\"db_action.php?table=app_version&platformid=$platform->id\">App versions for this platform</a>");
748 748
     end_table();
749 749
 }
750 750
 
@@ -756,8 +756,8 @@  discard block
 block discarded – undo
756 756
     row("User-friendly name", $app->user_friendly_name);
757 757
     row("Deprecated", $app->deprecated);
758 758
     row("Homogeneous redundancy", $app->homogeneous_redundancy);
759
-    row("","<a href=\"db_action.php?table=app_version&appid=$app->id\">App Versions for this application</a>");
760
-    row("","<a href=\"db_action.php?table=workunit&appid=$app->id&detail=low\">Workunits for this application</a>");
759
+    row("", "<a href=\"db_action.php?table=app_version&appid=$app->id\">App Versions for this application</a>");
760
+    row("", "<a href=\"db_action.php?table=workunit&appid=$app->id&detail=low\">Workunits for this application</a>");
761 761
     end_table();
762 762
 }
763 763
 
@@ -765,9 +765,9 @@  discard block
 block discarded – undo
765 765
     start_table();
766 766
     row("ID", $app_version->id);
767 767
     row("Created", time_str($app_version->create_time));
768
-    row("Application", "<a href=\"db_action.php?table=app&id=$app_version->appid\">" . app_name_by_id($app_version->appid) . "</a>");
768
+    row("Application", "<a href=\"db_action.php?table=app&id=$app_version->appid\">".app_name_by_id($app_version->appid)."</a>");
769 769
     row("Version num", $app_version->version_num);
770
-    row("Platform", "<a href=\"db_action.php?table=platform&id=$app_version->platformid\">" . platform_name_by_id($app_version->platformid) . "</a>" );
770
+    row("Platform", "<a href=\"db_action.php?table=platform&id=$app_version->platformid\">".platform_name_by_id($app_version->platformid)."</a>");
771 771
     row("Plan Class", $app_version->plan_class);
772 772
     row("XML doc", "<pre>".htmlspecialchars($app_version->xml_doc)."</pre>");
773 773
     row("min_core_version", $app_version->min_core_version);
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
     row("External IP address", "$host->external_ip_addr<br>");
902 902
     row("Domain name", $host->domain_name);
903 903
     $x = $host->timezone/3600;
904
-    if ($x >= 0) $x="+$x";
904
+    if ($x >= 0) $x = "+$x";
905 905
     row("Local Standard Time", "UTC $x hours");
906 906
     row("Number of CPUs", $host->p_ncpus);
907 907
     row("CPU", "$host->p_vendor $host->p_model");
@@ -953,10 +953,10 @@  discard block
 block discarded – undo
953 953
     start_table();
954 954
     row("Created", time_str($wu->create_time));
955 955
     row("Transition Time", time_str($wu->transition_time));
956
-    row("Last time modified",mysqltime_str($wu->mod_time));
956
+    row("Last time modified", mysqltime_str($wu->mod_time));
957 957
     row("Name", $wu->name);
958 958
     row("XML doc", "<pre>".htmlspecialchars($wu->xml_doc)."</pre>");
959
-    row("Application", "<a href=\"db_action.php?table=app&id=$wu->appid\">" . app_name_by_id($wu->appid) . " [".$wu->appid."]</a>");
959
+    row("Application", "<a href=\"db_action.php?table=app&id=$wu->appid\">".app_name_by_id($wu->appid)." [".$wu->appid."]</a>");
960 960
     row("Application version number", $wu->app_version_num);
961 961
     row("Batch", $wu->batch);
962 962
     $x = number_format($wu->rsc_fpops_est/1e9, 2);
@@ -969,12 +969,12 @@  discard block
 block discarded – undo
969 969
     $x = $wu->rsc_disk_bound/(1024*1024);
970 970
     $y = number_format($x, 2);
971 971
     row("Max Disk Usage", "$y MB");
972
-    row("Need validate?", ($wu->need_validate?"yes [":"no [").$wu->need_validate."]");
972
+    row("Need validate?", ($wu->need_validate ? "yes [" : "no [").$wu->need_validate."]");
973 973
     row("Canonical resultid",
974 974
             "<a href=\"db_action.php?table=result&id=$wu->canonical_resultid\">".$wu->canonical_resultid."</a>");
975 975
     row("Canonical credit", $wu->canonical_credit);
976 976
     //row("Timeout check time", time_str($wu->timeout_check_time));
977
-    row("Delay bound", "$wu->delay_bound" . " =  " . time_diff($wu->delay_bound) );
977
+    row("Delay bound", "$wu->delay_bound"." =  ".time_diff($wu->delay_bound));
978 978
     row("Error mask", wu_error_mask_str($wu->error_mask, true));
979 979
     row("File delete state", file_delete_state_str($wu->file_delete_state)." [".$wu->file_delete_state."]");
980 980
     row("Assimilation state", assimilate_state_str($wu->assimilate_state)." [".$wu->assimilate_state."]");
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
     row("max error results", $wu->max_error_results);
985 985
     row("max total results", $wu->max_total_results);
986 986
     row("max success results", $wu->max_success_results);
987
-    row("result template file",$wu->result_template_file);
987
+    row("result template file", $wu->result_template_file);
988 988
     row("hr_class", $wu->hr_class);
989 989
     row("opaque", $wu->opaque);
990 990
     row("Priority", $wu->priority);
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 }
1063 1063
 
1064 1064
 function outcome_color($outcome) {
1065
-    switch($outcome) {
1065
+    switch ($outcome) {
1066 1066
     case 0: return '9900cc'; // "Init", purple
1067 1067
     case 1: return '33cc33'; // "Success", green
1068 1068
     case 3: return 'ff3333'; // "Client error", red
@@ -1089,18 +1089,18 @@  discard block
 block discarded – undo
1089 1089
     row("Sent", time_str($result->sent_time));
1090 1090
     row("Report deadline", time_str($result->report_deadline));
1091 1091
     row("Received", time_str($result->received_time));
1092
-    row("Last time modified",mysqltime_str($result->mod_time));
1092
+    row("Last time modified", mysqltime_str($result->mod_time));
1093 1093
     row("Name", $result->name);
1094
-    row("Workunit", "<a href=\"db_action.php?table=workunit&id=$result->workunitid\">" . wu_name_by_id($result->workunitid) . "</a> [$result->workunitid]" );
1094
+    row("Workunit", "<a href=\"db_action.php?table=workunit&id=$result->workunitid\">".wu_name_by_id($result->workunitid)."</a> [$result->workunitid]");
1095 1095
     row("Server state", result_server_state_string($result)." [$result->server_state]");
1096 1096
     row("Outcome", result_outcome_string($result)." [$result->outcome]");
1097 1097
     row("Client state", result_client_state_string($result)." [$result->client_state]");
1098 1098
     row("Exit status", exit_status_string($result->exit_status));
1099
-    row("Host ID", "<a href=\"db_action.php?table=host&id=$result->hostid\">" . host_name_by_id($result->hostid) . "</a> [$result->hostid]");
1100
-    row("User ID", "<a href=\"db_action.php?table=user&id=$result->userid\">" . user_name_by_id($result->userid) . "</a> [$result->userid]");
1099
+    row("Host ID", "<a href=\"db_action.php?table=host&id=$result->hostid\">".host_name_by_id($result->hostid)."</a> [$result->hostid]");
1100
+    row("User ID", "<a href=\"db_action.php?table=user&id=$result->userid\">".user_name_by_id($result->userid)."</a> [$result->userid]");
1101 1101
     row("CPU time", $result->cpu_time);
1102 1102
     row("Elapsed time", $result->elapsed_time);
1103
-    if($error=stderr_error_string($result->stderr_out)) {
1103
+    if ($error = stderr_error_string($result->stderr_out)) {
1104 1104
         row("error in stderr out", $error);
1105 1105
     }
1106 1106
     row("Batch", $result->batch);
@@ -1117,16 +1117,16 @@  discard block
 block discarded – undo
1117 1117
     row("App version", $x1.app_version_string($result).$x2);
1118 1118
     row("App version ID", $result->app_version_id);
1119 1119
     row("Estimated GFLOPS", number_format($result->flops_estimate/1e9, 2));
1120
-    row("Random",$result->random);
1121
-    row("Opaque",$result->opaque);
1122
-    row("Teamid",$result->teamid);
1123
-    row("Priority",$result->priority);
1120
+    row("Random", $result->random);
1121
+    row("Opaque", $result->opaque);
1122
+    row("Teamid", $result->teamid);
1123
+    row("Priority", $result->priority);
1124 1124
     row("XML doc in", "<pre>".htmlspecialchars($result->xml_doc_in)."</pre>");
1125 1125
     row("XML doc out", "<pre>".htmlspecialchars($result->xml_doc_out)."</pre>");
1126 1126
     row("stderr out", "<pre>"
1127 1127
         .htmlspecialchars(
1128 1128
             $result->stderr_out,
1129
-            ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0),
1129
+            ENT_QUOTES|(defined('ENT_SUBSTITUTE') ?ENT_SUBSTITUTE:0),
1130 1130
             'utf-8'
1131 1131
         )
1132 1132
         ."</pre>"
@@ -1174,23 +1174,23 @@  discard block
 block discarded – undo
1174 1174
     } else {
1175 1175
         // result has not been received yet, so show report deadline either
1176 1176
         // in green if in the future or in red if in the past.
1177
-        $timenow=time();
1178
-        if ($result->report_deadline==0)  {
1177
+        $timenow = time();
1178
+        if ($result->report_deadline == 0) {
1179 1179
             // not sent -- show create time in purple
1180
-            $received = "<font color=\"9900cc\">". time_str($result->create_time) . "</font>";
1181
-        } else if ($result->report_deadline>=$timenow) {
1180
+            $received = "<font color=\"9900cc\">".time_str($result->create_time)."</font>";
1181
+        } else if ($result->report_deadline >= $timenow) {
1182 1182
             // overdue -- show deadline in red
1183
-            $received = "<font color=\"#33cc33\">". time_str($result->report_deadline) . "</font>";
1183
+            $received = "<font color=\"#33cc33\">".time_str($result->report_deadline)."</font>";
1184 1184
         } else {
1185 1185
             // in progress and not overdue -- show deadline in green
1186
-            $received = "<font color=\"#ff3333\">". time_str($result->report_deadline) . "</font>";
1186
+            $received = "<font color=\"#ff3333\">".time_str($result->report_deadline)."</font>";
1187 1187
         }
1188 1188
     }
1189 1189
     $version = app_version_string($result)." (<a href=\"db_action.php?table=app_version&id=$result->app_version_id\">$result->app_version_id</a>)";
1190 1190
     $outcome_color = outcome_color($result->outcome);
1191 1191
     $validate_color = validate_color($result->validate_state);
1192 1192
     $host_user = host_user_link($result->hostid);
1193
-    $cpu_hours = sprintf("%.1f",$result->cpu_time / 3600);
1193
+    $cpu_hours = sprintf("%.1f", $result->cpu_time/3600);
1194 1194
     $granted_credit = "<a href=credit.php?wu_id=$result->workunitid>".credit_str($result->granted_credit)."</a>";
1195 1195
     $delete_state = file_delete_state_str($result->file_delete_state);
1196 1196
 
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
     row("ID", $user->id);
1219 1219
     row("Created", time_str($user->create_time));
1220 1220
     row("Name", $user->name);
1221
-    if(!in_rops()) {
1221
+    if (!in_rops()) {
1222 1222
         row("Authenticator", $user->authenticator);
1223 1223
     }
1224 1224
     row("Email address", $user->email_addr);
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
     row("Default venue", $user->venue);
1234 1234
     row("Hosts", "<a href=\"db_action.php?table=host&userid=$user->id&detail=low\">click</a>");
1235 1235
     row("Cross project ID", $user->cross_project_id);
1236
-    if(!in_rops()) {
1236
+    if (!in_rops()) {
1237 1237
         row("Password Hash", $user->passwd_hash);
1238 1238
     }
1239 1239
     row("Donated", $user->donated);
@@ -1284,7 +1284,7 @@  discard block
 block discarded – undo
1284 1284
     echo "</table></td>";
1285 1285
     echo "<td><table border=\"2\">\n";
1286 1286
     echo "<tr><th>User</th><th># posts</th></tr>\n";
1287
-    for ($p=1; $p<=10; $p++) {
1287
+    for ($p = 1; $p <= 10; $p++) {
1288 1288
         row2_plain(user_links_ops($top10poster[$p]), $top10poster[$p]->posts);
1289 1289
     }
1290 1290
     echo "</table></td>";
@@ -1323,10 +1323,10 @@  discard block
 block discarded – undo
1323 1323
 function admin_show_team($team) {
1324 1324
     start_table();
1325 1325
     row("ID", $team->id);
1326
-    row("Team Founder", "<a href=\"db_action.php?table=user&id=$team->userid\">" . user_name_by_id($team->userid) . "</a>");
1326
+    row("Team Founder", "<a href=\"db_action.php?table=user&id=$team->userid\">".user_name_by_id($team->userid)."</a>");
1327 1327
     row("Name", $team->name);
1328
-    row("Name (HTML Formatted)", "<pre>" . htmlspecialchars($team->name_html) . "</pre>" );
1329
-    row("Url", "<a href=\"http://$team->url\">" . $team->url . "</a>");
1328
+    row("Name (HTML Formatted)", "<pre>".htmlspecialchars($team->name_html)."</pre>");
1329
+    row("Url", "<a href=\"http://$team->url\">".$team->url."</a>");
1330 1330
     row("Type", team_type_string($team->type));
1331 1331
     row("Description", $team->description);
1332 1332
     row("", "<a href=\"db_action.php?table=user&teamid=$team->id\">List All Members</a>");
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
     if (!strlen($host->domain_name) && !strlen($host->last_ip_addr)) {
1370 1370
         return "(blank)";
1371 1371
     } else {
1372
-        return $host->domain_name . " (" . $host->last_ip_addr . ")";
1372
+        return $host->domain_name." (".$host->last_ip_addr.")";
1373 1373
     }
1374 1374
 }
1375 1375
 
Please login to merge, or discard this patch.
html/inc/result.inc 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
     return $platforms[$id];
54 54
 }
55 55
 
56
-function anon_platform_string($result, $rsc_name=null) {
56
+function anon_platform_string($result, $rsc_name = null) {
57 57
     $app = get_app($result->appid);
58
-    $n = $app->user_friendly_name."<br>".  tra("Anonymous platform");
58
+    $n = $app->user_friendly_name."<br>".tra("Anonymous platform");
59 59
     if ($rsc_name) {
60 60
         $n .= " ($rsc_name)";
61 61
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         return $string_to_show;
98 98
     }
99 99
     if ($result->server_state <> RESULT_SERVER_STATE_OVER) return "---";
100
-    switch($result->outcome) {
100
+    switch ($result->outcome) {
101 101
     case RESULT_OUTCOME_SUCCESS:
102 102
         switch ($result->validate_state) {
103 103
         case VALIDATE_STATE_INIT:
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             ) {
213 213
                 return tra("Not started by deadline - canceled");
214 214
             }
215
-            switch($result->client_state) {
215
+            switch ($result->client_state) {
216 216
             case RESULT_FILES_DOWNLOADING: return tra("Error while downloading");
217 217
             case RESULT_FILES_DOWNLOADED:
218 218
             case RESULT_COMPUTE_ERROR: return tra("Error while computing");
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 }
232 232
 
233 233
 function result_server_state_string($result) {
234
-    switch($result->server_state) {
234
+    switch ($result->server_state) {
235 235
     case RESULT_SERVER_STATE_INACTIVE: return tra("Inactive");
236 236
     case RESULT_SERVER_STATE_UNSENT: return tra("Unsent");
237 237
     case RESULT_SERVER_STATE_IN_PROGRESS: return tra("In progress");
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 }
242 242
 
243 243
 function result_outcome_string($result) {
244
-    switch($result->outcome) {
244
+    switch ($result->outcome) {
245 245
     case RESULT_OUTCOME_INIT: return "---";
246 246
     case RESULT_OUTCOME_SUCCESS: return tra("Success");
247 247
     case RESULT_OUTCOME_COULDNT_SEND: return tra("Couldn't send");
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 }
260 260
 
261 261
 function result_client_state_string($result) {
262
-    switch($result->client_state) {
262
+    switch ($result->client_state) {
263 263
     case RESULT_NEW: return tra("New");
264 264
     case RESULT_FILES_DOWNLOADING: return tra("Downloading");
265 265
     case RESULT_FILES_DOWNLOADED: return tra("Processing");
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 }
278 278
 
279 279
 function validate_state_str($result) {
280
-    switch($result->validate_state) {
280
+    switch ($result->validate_state) {
281 281
     case VALIDATE_STATE_INIT: return tra("Initial");
282 282
     case VALIDATE_STATE_VALID: return tra("Valid");
283 283
     case VALIDATE_STATE_INVALID:
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 }
294 294
 
295 295
 function assimilate_state_str($s) {
296
-    switch($s) {
296
+    switch ($s) {
297 297
     case ASSIMILATE_INIT: return "Initial";
298 298
     case ASSIMILATE_READY: return "Ready to assimilate";
299 299
     case ASSIMILATE_DONE: return "Assimilated";
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 }
303 303
 
304 304
 function file_delete_state_str($s) {
305
-    switch($s) {
305
+    switch ($s) {
306 306
     case FILE_DELETE_INIT: return "Initial";
307 307
     case FILE_DELETE_READY: return "Ready to delete";
308 308
     case FILE_DELETE_DONE: return "Deleted";
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 // convert WU error bitmask to str.
315 315
 // If $color, add HTML red color
316 316
 //
317
-function wu_error_mask_str($s, $color=false) {
317
+function wu_error_mask_str($s, $color = false) {
318 318
     $x = "";
319 319
     if ($s & WU_ERROR_COULDNT_SEND_RESULT) {
320 320
         $x = $x." ".tra("Couldn't send result");
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
     if ($result->received_time) {
429 429
         $r = time_str($result->received_time);
430 430
     } else if ($result->report_deadline) {
431
-        if ($result->report_deadline>time()) {
432
-            $r = "<font color='#33cc33'>" . time_str($result->report_deadline) . "</font>";
431
+        if ($result->report_deadline > time()) {
432
+            $r = "<font color='#33cc33'>".time_str($result->report_deadline)."</font>";
433 433
         } else {
434
-            $r = "<font color='#ff3333'>" . time_str($result->report_deadline) . "</font>";
434
+            $r = "<font color='#ff3333'>".time_str($result->report_deadline)."</font>";
435 435
         }
436 436
     } else {
437 437
         $r = "---";
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 // @param Integer $dec A signed integer
493 493
 //
494 494
 function int2hex($dec) {
495
-    return "0x".strtoupper(substr(sprintf("%08x",$dec), -8));
495
+    return "0x".strtoupper(substr(sprintf("%08x", $dec), -8));
496 496
 }
497 497
 
498 498
 // Decode a windows error number into semi-human-readable,
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 // @return String A human readable error message
503 503
 // @param Integer $x An error number
504 504
 //
505
-function windows_error_code_str($x){
506
-    $h=int2hex($x);
507
-    switch($h){
505
+function windows_error_code_str($x) {
506
+    $h = int2hex($x);
507
+    switch ($h) {
508 508
     case "0xC0000005": return "STATUS_ACCESS_VIOLATION";
509 509
     case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION";
510 510
     case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO";
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 // @return String A human readable error message
526 526
 // @param Integer $x An error number
527 527
 //
528
-function error_code_str($x){
528
+function error_code_str($x) {
529 529
     // severe Windows error numbers are always large negative integers
530
-    if ($x<-400) return windows_error_code_str($x);
531
-    switch($x){
530
+    if ($x < -400) return windows_error_code_str($x);
531
+    switch ($x) {
532 532
     case 0: return "";
533 533
     case 192: return "EXIT_STATEFILE_WRITE";
534 534
     case 193: return "EXIT_SIGNAL";
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
     return $x." (".int2hex($x).") ".error_code_str($x);
690 690
 }
691 691
 
692
-function show_result($result, $show_outfile_links=false) {
692
+function show_result($result, $show_outfile_links = false) {
693 693
     start_table();
694 694
     row2(tra("Name"), $result->name);
695 695
     row2(tra("Workunit"), "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>");
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
     echo "<h3>".tra("Stderr output")."</h3> <pre>"
741 741
         .htmlspecialchars(
742 742
             $result->stderr_out,
743
-            ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0),
743
+            ENT_QUOTES|(defined('ENT_SUBSTITUTE') ?ENT_SUBSTITUTE:0),
744 744
             'utf-8'
745 745
         )
746 746
         ."</pre>"
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 
756 756
     $apps = BoincApp::enum('deprecated=0 ORDER BY user_friendly_name');
757 757
 
758
-    for ($i=0; $i<NSTATES; $i++) {
758
+    for ($i = 0; $i < NSTATES; $i++) {
759 759
         $state_count[$i] = 0;
760 760
     }
761 761
     foreach ($apps as $app) {
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
         $x .= "<a href=$url>".tra("Next")." ".$info->results_per_page."</a>";
799 799
     }
800 800
     $x .= "<br>".tra("State").": ";
801
-    for ($i=0; $i<NSTATES; $i++) {
801
+    for ($i = 0; $i < NSTATES; $i++) {
802 802
         if ($i) $x .= " &middot; ";
803 803
         if ($info->state == $i) {
804 804
             $x .= $state_name[$i];
@@ -843,6 +843,6 @@  discard block
 block discarded – undo
843 843
     return $x;
844 844
 }
845 845
 
846
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
846
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
847 847
 
848 848
 ?>
Please login to merge, or discard this patch.
html/inc/prefs_util.inc 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 }
43 43
 
44 44
 abstract class PREF {
45
-    public $desc;       // short description
46
-    public $tooltip;    // longer description, shown as tooltip
47
-    public $tag;        // the pref's primary XML tag
45
+    public $desc; // short description
46
+    public $tooltip; // longer description, shown as tooltip
47
+    public $tag; // the pref's primary XML tag
48 48
     function __construct($desc, $tooltip, $tag) {
49 49
         $this->desc = $desc;
50 50
         $this->tooltip = $tooltip;
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 
123 123
 class PREF_BOOL extends PREF {
124 124
     public $default;
125
-    public $invert;     // show to user in opposite sense
126
-    function __construct($desc, $tooltip, $tag, $default, $invert=false) {
125
+    public $invert; // show to user in opposite sense
126
+    function __construct($desc, $tooltip, $tag, $default, $invert = false) {
127 127
         $this->default = $default;
128 128
         $this->invert = $invert;
129 129
         parent::__construct($desc, $tooltip, $tag);
130 130
     }
131 131
     function show_value($prefs) {
132 132
         $tag = $this->tag;
133
-        $v = $this->invert?!$prefs->$tag:$prefs->$tag;
133
+        $v = $this->invert ? !$prefs->$tag : $prefs->$tag;
134 134
         echo "<td>".readonly_checkbox($v)."</td>";
135 135
     }
136 136
     function show_form($prefs, $error) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         }
143 143
         echo "<td ".VALUE_ATTRS.">"
144 144
             ."<input type=checkbox name=$this->tag "
145
-            . ($checked?"checked":"")
145
+            . ($checked ? "checked" : "")
146 146
             ."></td>
147 147
         ";
148 148
     }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     function xml_string($prefs) {
156 156
         $tag = $this->tag;
157 157
         return "<$tag>"
158
-            .($prefs->$tag?"1":"0")
158
+            .($prefs->$tag ? "1" : "0")
159 159
             ."</$tag>\n";
160 160
     }
161 161
     function xml_parse(&$prefs, $name, $text) {
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
     public $consent_type_id; // the consent_type_id from the consent_type table
176 176
     public $consent_name; // the consent_name to configure
177 177
     public $default;
178
-    public $invert;     // show to user in opposite sense
178
+    public $invert; // show to user in opposite sense
179 179
 
180
-    function __construct($desc, $tooltip, $tag, $consent_type_id, $consent_name, $default, $invert=false) {
180
+    function __construct($desc, $tooltip, $tag, $consent_type_id, $consent_name, $default, $invert = false) {
181 181
         $this->consent_type_id = $consent_type_id;
182 182
         $this->consent_name = $consent_name;
183 183
         $this->default = $default;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         } else {
241 241
             $value = false;
242 242
         }
243
-        echo "<td>" . readonly_checkbox($value) . "</td>";
243
+        echo "<td>".readonly_checkbox($value)."</td>";
244 244
     }
245 245
     function show_form($user, $error) {
246 246
         $consent_type_id = $this->consent_type_id;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         }
258 258
         echo "<td ".VALUE_ATTRS.">"
259 259
             ."<input type=checkbox name=$this->tag "
260
-            . ($checked?"checked":"")
260
+            . ($checked ? "checked" : "")
261 261
             ."></td>
262 262
         ";
263 263
     }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             "userid=$user->id AND consent_type_id='$consent_type_id$'"
277 277
         );
278 278
 
279
-        if ((($cr) and ($cr->consent_flag!=$flag)) or (!$cr)) {
279
+        if ((($cr) and ($cr->consent_flag != $flag)) or (!$cr)) {
280 280
             $rc = consent_to_a_policy(
281 281
                 $user, $consent_type_id, $flag, 0, 'Webform', time()
282 282
             );
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         // this is the value if they check the box
317 317
     public $scale;
318 318
 
319
-    function __construct($suffix, $min, $max, $default, $scale=1, $default2=0) {
319
+    function __construct($suffix, $min, $max, $default, $scale = 1, $default2 = 0) {
320 320
         $this->suffix = " $suffix";
321 321
         $this->min = $min;
322 322
         $this->max = $max;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         $v .= "$this->suffix ";
336 336
         return $v;
337 337
     }
338
-    function form_str($tag, $v, $had_error, $disabled=false, $id=null) {
338
+    function form_str($tag, $v, $had_error, $disabled = false, $id = null) {
339 339
         if (is_numeric($v)) {
340 340
             $v /= $this->scale;
341 341
             if (!$had_error && ($v < $this->min || $v > $this->max)) {
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             }
344 344
         }
345 345
         if ($disabled) $v = "";
346
-        $i = $id?"id=\"$id\"":"";
346
+        $i = $id ? "id=\"$id\"" : "";
347 347
         return '<input type="text" size="5" class="form-control input-sm" name="'.$tag.'" value="'.$v."\" $disabled $i> &nbsp; $this->suffix ";
348 348
     }
349 349
     function form_convert($in, &$out, &$error) {
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
         $text_id = $this->tag;
467 467
         $default = $this->num_spec->get_default();
468 468
         $val = $prefs->$tag;
469
-        $c = $val?"checked":"";
470
-        $d = $val?"":"disabled";
469
+        $c = $val ? "checked" : "";
470
+        $d = $val ? "" : "disabled";
471 471
         echo "<td $attrs>"
472 472
             ."<input type=checkbox id=$checkbox_id onClick=\"checkbox_clicked('$checkbox_id', '$text_id', $default)\" $c> &nbsp;"
473 473
             .$this->num_spec->form_str($tag, $prefs->$tag, $had_error, $d, $text_id)
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 function hour_select($x, $name, $id, $d) {
581 581
     $s = "";
582 582
     $s .= "<select class=\"selectbox form-control input-sm\" name=$name id=$id $d>\n";
583
-    for ($i=0; $i<24; $i++) {
584
-        $sel = ($x == $i)?"selected":"";
583
+    for ($i = 0; $i < 24; $i++) {
584
+        $sel = ($x == $i) ? "selected" : "";
585 585
         $s .= "<option value=$i $sel> $i:00";
586 586
     }
587 587
     $s .= "</select>\n";
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 
683 683
 // row_defs - Display a value for all 4 venues in one row
684 684
 //
685
-function row_defs($pre, $item, $post, $type, $prefs, $tooltip=null) {
685
+function row_defs($pre, $item, $post, $type, $prefs, $tooltip = null) {
686 686
     $gen = $prefs->$item;
687 687
     $hom  = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--";
688 688
     $schl = (isset($prefs->school) && isset($prefs->school->$item)) ? $prefs->school->$item : "--";
@@ -694,10 +694,10 @@  discard block
 block discarded – undo
694 694
         echo "<tr>";
695 695
     }
696 696
     echo "<td ".NAME_ATTRS.">$pre</td>";
697
-    row_field($gen,  $type);
698
-    row_field($hom,  $type);
697
+    row_field($gen, $type);
698
+    row_field($hom, $type);
699 699
     row_field($schl, $type);
700
-    row_field($wrk,  $type);
700
+    row_field($wrk, $type);
701 701
     echo "<td align=left>$post</td></tr>\n";
702 702
 }
703 703
 
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
 function row_field($value, $type) {
708 708
     echo "<td>";
709 709
     $type = $value === "--" ? "--" : $type;
710
-    switch($type) {
710
+    switch ($type) {
711 711
     case "yesno":
712
-        echo $value ?tra("yes"):tra("no");
712
+        echo $value ?tra("yes") : tra("no");
713 713
         break;
714 714
     case "noyes":
715
-        echo $value ?tra("no"):tra("yes");
715
+        echo $value ?tra("no") : tra("yes");
716 716
         break;
717 717
     case "limit":
718 718
         $x = max_bytes_display_mode($value);
719
-        $y = "$x " . BYTE_ABBR;
719
+        $y = "$x ".BYTE_ABBR;
720 720
         echo $x ? "$y" : tra("no limit");
721 721
         break;
722 722
     case "minutes":
Please login to merge, or discard this patch.
html/ops/dbinfo.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 
43 43
 // returns formatted data size
44
-function size_format($size){
44
+function size_format($size) {
45 45
 	$retval = 0;
46 46
 
47 47
 	$KB = 1024;
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
     if ($size < $KB) {
53 53
 	    $retval = $size;
54 54
     } elseif (($size > $KB) && ($size < $MB)) {
55
-		$retval = sprintf("%.0fK", ($size / $KB));
56
-    } elseif ( ($size >= $MB) && ($size < $GB)) {
57
-		$retval = sprintf("%.2fMB", ($size / $MB));
58
-    } elseif ( ($size >= $GB) && ($size < $TB)) {
59
-		$retval = sprintf("%.2fGB", ($size / $GB));
60
-	} elseif ( $size >= $TB ) {
61
-		$retval = sprintf("%.2fTB", ($size / $TB));
55
+		$retval = sprintf("%.0fK", ($size/$KB));
56
+    } elseif (($size >= $MB) && ($size < $GB)) {
57
+		$retval = sprintf("%.2fMB", ($size/$MB));
58
+    } elseif (($size >= $GB) && ($size < $TB)) {
59
+		$retval = sprintf("%.2fGB", ($size/$GB));
60
+	} elseif ($size >= $TB) {
61
+		$retval = sprintf("%.2fTB", ($size/$TB));
62 62
 	}
63 63
 	return $retval;
64 64
 }
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
         if ($myarr['Comment'] == 'VIEW') continue;
90 90
 
91 91
 		// sum grand totals
92
-		$total  =  $myarr["Data_length"] + $myarr["Index_length"];
92
+		$total = $myarr["Data_length"] + $myarr["Index_length"];
93 93
 		$gindex += $myarr["Index_length"];
94
-        $gdata  += $myarr["Data_length"];
94
+        $gdata += $myarr["Data_length"];
95 95
 		$grows  += $myarr["Rows"];
96 96
 		$gtotal += $total;
97 97
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         );
106 106
 		$i++;
107 107
 	}
108
-    $db_rec[$i] = new DB_REC ("Total", $gdata, $gindex, $gtotal, $grows, "" );
108
+    $db_rec[$i] = new DB_REC("Total", $gdata, $gindex, $gtotal, $grows, "");
109 109
 	return $db_rec;
110 110
 }
111 111
 
@@ -126,25 +126,25 @@  discard block
 block discarded – undo
126 126
 	echo "<th>Avg. Size per Row</th>";
127 127
 	echo "</tr>";
128 128
 
129
-	for ($i = 0; $i < sizeof($db_rec)-1; $i++){
129
+	for ($i = 0; $i < sizeof($db_rec) - 1; $i++) {
130 130
 		echo "<tr>";
131
-		echo "<td align=left valign=top class=fieldname>" . $db_rec[$i]->name . "</td>";
132
-		echo "<td align=left valign=top class=fieldname>" . size_format($db_rec[$i]->data_size)  . "</td>";
133
-		echo "<td align=left valign=top class=fieldname>" . size_format($db_rec[$i]->index_size) . "</td>";
134
-		echo "<td align=left valign=top class=fieldname>" . size_format($db_rec[$i]->total_size) . "</td>";
135
-        echo "<td align=left valign=top class=fieldname>" . number_format($db_rec[$i]->rows)     . "</td>";
136
-        echo "<td align=left valign=top class=fieldname>" . size_format($db_rec[$i]->size_per_row) . "</td>";
131
+		echo "<td align=left valign=top class=fieldname>".$db_rec[$i]->name."</td>";
132
+		echo "<td align=left valign=top class=fieldname>".size_format($db_rec[$i]->data_size)."</td>";
133
+		echo "<td align=left valign=top class=fieldname>".size_format($db_rec[$i]->index_size)."</td>";
134
+		echo "<td align=left valign=top class=fieldname>".size_format($db_rec[$i]->total_size)."</td>";
135
+        echo "<td align=left valign=top class=fieldname>".number_format($db_rec[$i]->rows)."</td>";
136
+        echo "<td align=left valign=top class=fieldname>".size_format($db_rec[$i]->size_per_row)."</td>";
137 137
 		echo "</tr>";
138 138
 	}
139 139
 
140 140
 	// Last record is just a summary
141
-	$i = sizeof($db_rec)-1;
141
+	$i = sizeof($db_rec) - 1;
142 142
 	echo "<tr>";
143
-    echo "<th align=left>" . $db_rec[$i]->name . "</th>";
144
-    echo "<th align=left>" . size_format($db_rec[$i]->data_size)  . "</th>";
145
-    echo "<th align=left>" . size_format($db_rec[$i]->index_size) . "</th>";
146
-    echo "<th align=left>" . size_format($db_rec[$i]->total_size) . "</th>";
147
-    echo "<th align=left>" . number_format($db_rec[$i]->rows)     . "</th>";
143
+    echo "<th align=left>".$db_rec[$i]->name."</th>";
144
+    echo "<th align=left>".size_format($db_rec[$i]->data_size)."</th>";
145
+    echo "<th align=left>".size_format($db_rec[$i]->index_size)."</th>";
146
+    echo "<th align=left>".size_format($db_rec[$i]->total_size)."</th>";
147
+    echo "<th align=left>".number_format($db_rec[$i]->rows)."</th>";
148 148
     echo "<th align=left></th>";
149 149
 	echo "</tr>";
150 150
     echo "</table>";
@@ -156,28 +156,28 @@  discard block
 block discarded – undo
156 156
 	$file_list = array();
157 157
     $file_sort = array();
158 158
 
159
-	$sort =  get_str("sort", true);
159
+	$sort = get_str("sort", true);
160 160
 	$r = get_str("r", true);
161 161
 
162 162
 	if (empty($sort)) $sort = "name";
163 163
 	// check for allowed keys
164
-	if ((strcmp($sort, "name")!=0) &&
165
-		(strcmp($sort, "data_size")!=0) &&
166
-		(strcmp($sort, "index_size")!=0) &&
167
-		(strcmp($sort, "total_size")!=0)  &&
168
-		(strcmp($sort, "rows")!=0) &&
169
-		(strcmp($sort, "size_per_row")!=0)
164
+	if ((strcmp($sort, "name") != 0) &&
165
+		(strcmp($sort, "data_size") != 0) &&
166
+		(strcmp($sort, "index_size") != 0) &&
167
+		(strcmp($sort, "total_size") != 0) &&
168
+		(strcmp($sort, "rows") != 0) &&
169
+		(strcmp($sort, "size_per_row") != 0)
170 170
     ) {
171 171
 		$sort = "name";
172 172
     }
173
-	if (empty($r)) $r=0;
173
+	if (empty($r)) $r = 0;
174 174
 
175
-	for ($i=0; $i < sizeof($db_rec)-1; $i++){
175
+	for ($i = 0; $i < sizeof($db_rec) - 1; $i++) {
176 176
 		$file_details["name"]         = $db_rec[$i]->name;
177 177
 		$file_details["data_size"]    = $db_rec[$i]->data_size;
178 178
 		$file_details["index_size"]   = $db_rec[$i]->index_size;
179 179
 		$file_details["total_size"]   = $db_rec[$i]->total_size;
180
-	    $file_details["rows"]         = $db_rec[$i]->rows;
180
+	    $file_details["rows"] = $db_rec[$i]->rows;
181 181
 		$file_details["size_per_row"] = $db_rec[$i]->size_per_row;
182 182
 
183 183
 		$file_list[$i] = $file_details;
@@ -197,35 +197,35 @@  discard block
 block discarded – undo
197 197
 	echo "</tr>";
198 198
 
199 199
 	echo "<tr>";
200
-	echo "<th><a href='dbinfo.php?sort=name&r=" . (!$r) . "'>Table </a></th>";
201
-	echo "<th><a href='dbinfo.php?sort=data_size&r=" . (!$r) . "'>Data Size</a></th>";
202
-	echo "<th><a href='dbinfo.php?sort=index_size&r=" . (!$r) . "'>Index Size</a></th>";
203
-	echo "<th><a href='dbinfo.php?sort=total_size&r=" . (!$r) . "'>Total Size</a></th>";
204
-	echo "<th><a href='dbinfo.php?sort=rows&r=" . (!$r) . "'>Total Rows</a></th>";
205
-	echo "<th><a href='dbinfo.php?sort=size_per_row&r=" . (!$r) . "'>Avg. Size per Row</a></th>";
200
+	echo "<th><a href='dbinfo.php?sort=name&r=".(!$r)."'>Table </a></th>";
201
+	echo "<th><a href='dbinfo.php?sort=data_size&r=".(!$r)."'>Data Size</a></th>";
202
+	echo "<th><a href='dbinfo.php?sort=index_size&r=".(!$r)."'>Index Size</a></th>";
203
+	echo "<th><a href='dbinfo.php?sort=total_size&r=".(!$r)."'>Total Size</a></th>";
204
+	echo "<th><a href='dbinfo.php?sort=rows&r=".(!$r)."'>Total Rows</a></th>";
205
+	echo "<th><a href='dbinfo.php?sort=size_per_row&r=".(!$r)."'>Avg. Size per Row</a></th>";
206 206
 	echo "</tr>";
207 207
 
208 208
     foreach ($file_sort as $key=>$value) {
209 209
 		$value = $file_list[$key];
210 210
 
211 211
 		echo "<tr>";
212
-		echo "<td align=left valign=top class=fieldname>" . $value["name"] . "</td>";
213
-		echo "<td align=left valign=top class=fieldname>" . size_format($value["data_size"])  . "</td>";
214
-		echo "<td align=left valign=top class=fieldname>" . size_format($value["index_size"]) . "</td>";
215
-		echo "<td align=left valign=top class=fieldname>" . size_format($value["total_size"]) . "</td>";
216
-        echo "<td align=left valign=top class=fieldname>" . number_format($value["rows"])     . "</td>";
217
-        echo "<td align=left valign=top class=fieldname>" . size_format($value["size_per_row"]) . "</td>";
212
+		echo "<td align=left valign=top class=fieldname>".$value["name"]."</td>";
213
+		echo "<td align=left valign=top class=fieldname>".size_format($value["data_size"])."</td>";
214
+		echo "<td align=left valign=top class=fieldname>".size_format($value["index_size"])."</td>";
215
+		echo "<td align=left valign=top class=fieldname>".size_format($value["total_size"])."</td>";
216
+        echo "<td align=left valign=top class=fieldname>".number_format($value["rows"])."</td>";
217
+        echo "<td align=left valign=top class=fieldname>".size_format($value["size_per_row"])."</td>";
218 218
 		echo "</tr>";
219 219
 	}
220 220
 
221 221
 	// Last record is a summary
222
-	$i = sizeof($db_rec)-1;
222
+	$i = sizeof($db_rec) - 1;
223 223
 	echo "<tr>";
224
-    echo "<th align=left>" . $db_rec[$i]->name . "</th>";
225
-    echo "<th align=left>" . size_format($db_rec[$i]->data_size)  . "</th>";
226
-    echo "<th align=left>" . size_format($db_rec[$i]->index_size) . "</th>";
227
-    echo "<th align=left>" . size_format($db_rec[$i]->total_size) . "</th>";
228
-    echo "<th align=left>" . number_format($db_rec[$i]->rows)     . "</th>";
224
+    echo "<th align=left>".$db_rec[$i]->name."</th>";
225
+    echo "<th align=left>".size_format($db_rec[$i]->data_size)."</th>";
226
+    echo "<th align=left>".size_format($db_rec[$i]->index_size)."</th>";
227
+    echo "<th align=left>".size_format($db_rec[$i]->total_size)."</th>";
228
+    echo "<th align=left>".number_format($db_rec[$i]->rows)."</th>";
229 229
     echo "<th align=left></th>";
230 230
 	echo "</tr>";
231 231
 
Please login to merge, or discard this patch.
html/inc/email.inc 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 // send an email, using PHPMailer or not.
28 28
 //
29
-function send_email($user, $subject, $body, $body_html=null, $email_addr=null) {
29
+function send_email($user, $subject, $body, $body_html = null, $email_addr = null) {
30 30
     if (!$email_addr) {
31 31
         $email_addr = $user->email_addr;
32 32
     }
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
             return true;
64 64
         }
65 65
     } else {
66
-        $headers ="";
66
+        $headers = "";
67 67
         if (defined('EMAIL_FROM') && defined('EMAIL_FROM_NAME')) {
68 68
             $headers = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM.">";
69 69
         } else if (defined('EMAIL_FROM')) {
70
-            $headers = "From: ". EMAIL_FROM;
70
+            $headers = "From: ".EMAIL_FROM;
71 71
         }
72 72
         if ($body_html) {
73 73
             $body = "<html><body>\n";
74 74
             $body .= $body_html;
75 75
             $body .= "\n</body></html>\n";
76
-            $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
76
+            $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
77 77
         }
78 78
         return mail($email_addr, $subject, $body, $headers);
79 79
     }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     if (defined("USE_STOPFORUMSPAM") && USE_STOPFORUMSPAM && array_key_exists('REMOTE_ADDR', $_SERVER)) {
149 149
         $ip = $_SERVER['REMOTE_ADDR'];
150 150
         // For obviously private IPs check just the email against SFS, otherwise check both IP and email
151
-        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
151
+        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE)) {
152 152
             $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip."&email=".$addr);
153 153
         } else {
154 154
             $x = @file_get_contents("https://www.stopforumspam.com/api?email=".$addr);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     }
160 160
     $pattern = '/^([^@]+)@([^@\.]+)\.([^@]{2,})$/';
161 161
     $match = preg_match($pattern, $addr);
162
-    return (bool) $match;
162
+    return (bool)$match;
163 163
 }
164 164
 
165 165
 function send_confirm_delete_email($user) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     return md5($key.'oogabooga');
188 188
 }
189 189
 
190
-function opt_out_url($user, $page="opt_out.php") {
190
+function opt_out_url($user, $page = "opt_out.php") {
191 191
     return sprintf("%s%s?code=%s&userid=%d",
192 192
         secure_url_base(),
193 193
         $page,
Please login to merge, or discard this patch.
html/user/submit.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
 function progress_bar($batch, $wus, $width) {
366 366
     $w_success = $width*$batch->fraction_done;
367 367
     $w_fail = $width*$batch->nerror_jobs/$batch->njobs;
368
-    $nsuccess = $batch->njobs * $batch->fraction_done;
368
+    $nsuccess = $batch->njobs*$batch->fraction_done;
369 369
     $nsent = wus_nsent($wus);
370 370
     $nprog = $nsent - $nsuccess - $batch->nerror_jobs;
371 371
     $w_prog = $width*$nprog/$batch->njobs;
372
-    $nunsent = $batch->njobs-$nsent;
372
+    $nunsent = $batch->njobs - $nsent;
373 373
     $w_unsent = $width*$nunsent/$batch->njobs;
374 374
     $x = '<table height=20><tr>';
375 375
     if ($w_fail) {
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     page_head("Batch $batch_id");
408 408
     start_table();
409 409
     row2("name", $batch->name);
410
-    row2("application", $app?$app->name:'---');
410
+    row2("application", $app ? $app->name : '---');
411 411
     row2("state", batch_state_string($batch->state));
412 412
     //row2("# jobs", $batch->njobs);
413 413
     //row2("# error jobs", $batch->nerror_jobs);
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
         "Canonical instance<br><small>click to see result page on BOINC server</smallp>",
455 455
         "Download Results"
456 456
     );
457
-    foreach($wus as $wu) {
457
+    foreach ($wus as $wu) {
458 458
         $resultid = $wu->canonical_resultid;
459 459
         if ($resultid) {
460 460
             $x = "<a href=result.php?resultid=$resultid>$resultid</a>";
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
             $text = "---";
466 466
             if ($batch->state == BATCH_STATE_COMPLETE) {
467 467
                 $y = '<font color="red">failed</font>';
468
-            }   else {
468
+            } else {
469 469
                 $y = "in progress";
470 470
             }
471 471
         }
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
     $results = BoincResult::enum("workunitid=$wuid");
531 531
     $upload_dir = parse_config(get_config(), "<upload_dir>");
532 532
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
533
-    foreach($results as $result) {
533
+    foreach ($results as $result) {
534 534
         echo "<tr>
535 535
             <td><a href=result.php?resultid=$result->id>$result->id &middot; $result->name </a></td>
536 536
             <td>".state_string($result)."</td>
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
         if ($result->server_state == 5) {
541 541
             $phys_names = get_outfile_names($result);
542 542
             $log_names = get_outfile_log_names($result);
543
-            for ($i=0; $i<count($phys_names); $i++) {
543
+            for ($i = 0; $i < count($phys_names); $i++) {
544 544
                 $url = sprintf(
545 545
                     'get_output2.php?cmd=result&result_id=%d&file_num=%d',
546 546
                     $result->id, $i
Please login to merge, or discard this patch.
html/user/lammps.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 display_errors();
19 19
 
20
-$debug=0;
20
+$debug = 0;
21 21
 
22 22
 // test a LAMMPS job
23 23
 //
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
 // output: success flag, CPU time per step, est. disk usage per job
31 31
 //
32 32
 function terminate_job($p) {
33
-    $pstatus=proc_get_status($p);
34
-    $ppid=$pstatus['pid'];
35
-    $ret=`ps -o pid --no-heading --ppid $ppid`;
33
+    $pstatus = proc_get_status($p);
34
+    $ppid = $pstatus['pid'];
35
+    $ret = `ps -o pid --no-heading --ppid $ppid`;
36 36
     //echo "parent pid is $ppid\nterninate it\n";
37 37
      proc_terminate($p);
38 38
     // echo "child process is $ret\n";
39
-    $pids=preg_split('/\s+/',$ret);
40
-    foreach($pids as $pid){
41
-        if(is_numeric($pid)){
42
-            if($GLOBALS["debug"])echo "killing child process $pid\n";
43
-            posix_kill($pid,9);
39
+    $pids = preg_split('/\s+/', $ret);
40
+    foreach ($pids as $pid) {
41
+        if (is_numeric($pid)) {
42
+            if ($GLOBALS["debug"])echo "killing child process $pid\n";
43
+            posix_kill($pid, 9);
44 44
         }
45 45
     }
46 46
 }
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
     $descs = array();
52 52
     $pipes = array();
53 53
     $options = file("cmd_variables");
54
-    $options[0] = chop($options[0],"\n");
54
+    $options[0] = chop($options[0], "\n");
55 55
     $cmd = "../lmp_linux ".$options[0]."&>output";
56 56
     if ($GLOBALS["debug"]) echo $cmd."<br>";
57 57
     system("unzip pot_files >/dev/null");
58 58
     $stime = time();
59 59
     $p = proc_open("$cmd", $descs, $pipes);
60 60
     while (1) {
61
-        $ctime=time();
62
-        if($ctime-$stime >=2 and ! file_exists("log.1")){
63
-           if($GLOBALS["debug"]) echo "time out "."<br>";
61
+        $ctime = time();
62
+        if ($ctime - $stime >= 2 and !file_exists("log.1")) {
63
+           if ($GLOBALS["debug"]) echo "time out "."<br>";
64 64
            terminate_job($p);
65 65
            break;
66 66
         }
67 67
         if (file_exists("log.1")) {
68 68
             list($avg_cpu, $test_steps) = calc_step_cpu("log.1");
69 69
             if ($avg_cpu != 0) {
70
-                if($GLOBALS["debug"])echo "avg_cpu is ".$avg_cpu."<br>";
70
+                if ($GLOBALS["debug"])echo "avg_cpu is ".$avg_cpu."<br>";
71 71
                 terminate_job($p);
72 72
                 $test_result = 1;
73 73
                 break;
@@ -86,32 +86,32 @@  discard block
 block discarded – undo
86 86
 }
87 87
 
88 88
 function get_total_steps($cmd_file) {
89
-    $fd = fopen($cmd_file,"r");
89
+    $fd = fopen($cmd_file, "r");
90 90
     if (!$fd) {
91 91
         echo "can not open file $cmd_file\n";
92 92
         exit(-1);
93 93
     }
94 94
     $this_loopno = 1;
95 95
     $this_looprun = 1;
96
-    $total_steps=1;
96
+    $total_steps = 1;
97 97
     while (!feof($fd)) {
98
-        $line = fgets($fd,4096);
98
+        $line = fgets($fd, 4096);
99 99
         if (preg_match("/loopnumber\s+\d+/", $line, $matches)
100 100
             && preg_match("/\d+/", $matches[0], $no)
101 101
         ) {
102
-            $this_loopno=$no[0];
102
+            $this_loopno = $no[0];
103 103
         }
104 104
         if (preg_match("/looprun\s+\d+/", $line, $matches)
105 105
             and preg_match("/\d+/", $matches[0], $no)
106 106
         ) {
107
-            $this_looprun=$no[0];
108
-            if($this_loopno*$this_looprun>$total_steps)$total_steps=$this_loopno*$this_looprun;
107
+            $this_looprun = $no[0];
108
+            if ($this_loopno*$this_looprun > $total_steps)$total_steps = $this_loopno*$this_looprun;
109 109
         }
110 110
 
111 111
     }
112 112
     fclose($fd);
113 113
     //$total_steps = $loopno*$looprun;
114
-     if($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>";
114
+     if ($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>";
115 115
     return $total_steps;
116 116
 }
117 117
 
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
     }
130 130
     $count = 0;
131 131
     while (!feof($fd)) {
132
-        $line = fgets($fd,4096);
133
-        if (preg_match('/^Step\s+CPU/',$line)) {
132
+        $line = fgets($fd, 4096);
133
+        if (preg_match('/^Step\s+CPU/', $line)) {
134 134
             //echo $line."\n";
135 135
             $start = 1;
136 136
             continue;
@@ -139,24 +139,24 @@  discard block
 block discarded – undo
139 139
         $arr = preg_split("/\s+/", $line);
140 140
         //print_r($arr);
141 141
 
142
-        if (count($arr) <=6 || !is_numeric($arr[1])) {
142
+        if (count($arr) <= 6 || !is_numeric($arr[1])) {
143 143
             continue;
144 144
         }
145 145
         $step = (int)$arr[1];
146 146
         $cpu = (float)$arr[2];
147 147
         //echo "step=".$step." cpu=".$cpu."\n";
148
-        if ($cpu==0) {
149
-           $count=0;
148
+        if ($cpu == 0) {
149
+           $count = 0;
150 150
            $start_step = $step;
151 151
         } else {
152
-            $count+=1;
153
-            if($GLOBALS["debug"])echo "step=".$step." cpu=".$cpu."count=".$count."<br>";
154
-           if($count >= 10) {
152
+            $count += 1;
153
+            if ($GLOBALS["debug"])echo "step=".$step." cpu=".$cpu."count=".$count."<br>";
154
+           if ($count >= 10) {
155 155
                 $end_step = $step;
156
-                $steps = $end_step-$start_step;
156
+                $steps = $end_step - $start_step;
157 157
                 $avg_cpu = $cpu/$steps;
158 158
                 #$avg_cpu = $cpu/$count;
159
-                if ($GLOBALS["debug"]){
159
+                if ($GLOBALS["debug"]) {
160 160
                     echo "test steps is ".$steps."<br>";
161 161
                     echo "avg_cpu is ".$avg_cpu."<br>";
162 162
                 }
@@ -165,56 +165,56 @@  discard block
 block discarded – undo
165 165
             }
166 166
         }
167 167
     }
168
-    return array($avg_cpu,$test_steps);
168
+    return array($avg_cpu, $test_steps);
169 169
 }
170 170
 
171
-function calc_est_size($lammps_script, $structure_file, $cmd_file,$test_steps){
171
+function calc_est_size($lammps_script, $structure_file, $cmd_file, $test_steps) {
172 172
     $dump_types = 0;
173
-    $fd = fopen($lammps_script,"r");
174
-    if (!$fd){
173
+    $fd = fopen($lammps_script, "r");
174
+    if (!$fd) {
175 175
         echo "can not open file $lammps_script\n";
176 176
         exit(-1);
177 177
     }
178
-    while (!feof($fd)){
178
+    while (!feof($fd)) {
179 179
         $line = fgets($fd, 4096);
180 180
         //if (preg_match("/^\s*dump/", $line)
181 181
         //    and preg_match_all("/dump\S+\.\w{3}/", $line, $matches, PREG_PATTERN_ORDER))
182 182
 
183
-        if(preg_match("/^\s*dump\s+(\d)\s+/", $line,$matches))
183
+        if (preg_match("/^\s*dump\s+(\d)\s+/", $line, $matches))
184 184
         {
185
-             if($GLOBALS["debug"]){print "matches=";print_r($matches);}
185
+             if ($GLOBALS["debug"]) {print "matches="; print_r($matches); }
186 186
 
187
-            $dump_types=(int)$matches[1];
187
+            $dump_types = (int)$matches[1];
188 188
             break;
189 189
         }
190 190
     }
191 191
     fclose($fd);
192
-    if($GLOBALS["debug"])print "dump_types= ".$dump_types."<br>";
192
+    if ($GLOBALS["debug"])print "dump_types= ".$dump_types."<br>";
193 193
 
194 194
     $structure_file_size = filesize($structure_file);
195
-    $fd = fopen($cmd_file,"r");
196
-    if (!$fd){
195
+    $fd = fopen($cmd_file, "r");
196
+    if (!$fd) {
197 197
         echo "can not open file $cmd_file\n";
198 198
         exit(-1);
199 199
     }
200
-     if($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>";
201
-
202
-    $loopno=1;
203
-    $looprun=1;
204
-    while (!feof($fd)){
205
-        $line = fgets($fd,4096);
206
-        if(preg_match("/loopnumber\s+\d+/", $line, $matches)){
207
-            if(preg_match("/\d+/", $matches[0], $no)){
200
+     if ($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>";
201
+
202
+    $loopno = 1;
203
+    $looprun = 1;
204
+    while (!feof($fd)) {
205
+        $line = fgets($fd, 4096);
206
+        if (preg_match("/loopnumber\s+\d+/", $line, $matches)) {
207
+            if (preg_match("/\d+/", $matches[0], $no)) {
208 208
                 //$loopno=$no[0];
209
-                if($no[0]>$loopno)$loopno=$no[0];
209
+                if ($no[0] > $loopno)$loopno = $no[0];
210 210
             }
211 211
         }
212 212
         if (preg_match("/looprun\s+\d+/", $line, $matches) and preg_match("/\d+/", $matches[0], $no)) {
213
-            if($no[0]>$looprun)$looprun=$no[0];
213
+            if ($no[0] > $looprun)$looprun = $no[0];
214 214
         }
215 215
     }
216 216
     fclose($fd);
217
-    if($GLOBALS["debug"]){
217
+    if ($GLOBALS["debug"]) {
218 218
          print "max loopno(number of loops to run)=".$loopno."<br>";
219 219
          print "max looprun(steps for each loop)=".$looprun."<br>";
220 220
     }
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
     $dump_files = glob("dump1*");
226 226
     $test_dump_file = $dump_files[0];
227 227
     $test_dump_size = filesize($test_dump_file);
228
-    $dump_size1 = $test_dump_size+0.5*$test_dump_size*ceil(($looprun-$test_steps)/$test_steps);
228
+    $dump_size1 = $test_dump_size + 0.5*$test_dump_size*ceil(($looprun - $test_steps)/$test_steps);
229 229
     $dump_size = $loopno*$dump_size1*$dump_types;
230 230
     $app_fixed_size = 5e7;
231
-    $est_size = $log_size+$dump_size+$app_fixed_size;
231
+    $est_size = $log_size + $dump_size + $app_fixed_size;
232 232
 
233
-    if($GLOBALS["debug"]){
233
+    if ($GLOBALS["debug"]) {
234 234
         print "test_steps=".$test_steps."<br>";
235 235
         print "test_log_size=".$test_log_size."<br>";
236 236
         print "log_size1=".$log_size1."<br>";
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     if ($njobs < $nhosts) {
322 322
         return $flops_per_job/$median_flops;
323 323
     } else {
324
-        $k = (int)(($njobs+$nhosts-1)/$nhosts);
324
+        $k = (int)(($njobs + $nhosts - 1)/$nhosts);
325 325
         return $k*$flops_per_job/$median_flops;
326 326
     }
327 327
 }
@@ -361,27 +361,27 @@  discard block
 block discarded – undo
361 361
     if ($GLOBALS["debug"]) {
362 362
         print "est_cpu_time is ".$est_cpu_time."<br>";
363 363
     }
364
-    if ($error==0) {
365
-        $err_msgs=file("output");
366
-        $err="Your test job <strong>failed</strong>
364
+    if ($error == 0) {
365
+        $err_msgs = file("output");
366
+        $err = "Your test job <strong>failed</strong>
367 367
             <br>Please refer to the following Error Message:<br><p>
368 368
         ";
369
-        foreach($err_msgs as $line){
370
-             $err=$err.$line."<br>";
369
+        foreach ($err_msgs as $line) {
370
+             $err = $err.$line."<br>";
371 371
         }
372
-        $err=$err." <p>
372
+        $err = $err." <p>
373 373
             <a href=sandbox.php><strong> File_Sandbox </strong></a>
374 374
         ";
375 375
         error_page($err);
376 376
     }
377 377
 
378 378
     system("rm *");
379
-    $info->rsc_fpops_est = $est_cpu_time * 1.5e9;
380
-    $info->rsc_fpops_bound = $info->rsc_fpops_est * 20;
379
+    $info->rsc_fpops_est = $est_cpu_time*1.5e9;
380
+    $info->rsc_fpops_bound = $info->rsc_fpops_est*20;
381 381
 
382
-    if ($disk==0){
383
-        $info->rsc_disk_bound=1000000;
384
-    } else{
382
+    if ($disk == 0) {
383
+        $info->rsc_disk_bound = 1000000;
384
+    } else {
385 385
         $info->rsc_disk_bound = $disk;
386 386
     }
387 387
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
     //
393 393
     $njobs = count(file($cmdline_file_path));
394 394
     $secs_est = estimated_makespan($njobs, $info->rsc_fpops_est);
395
-     if($GLOBALS["debug"])echo "secs_est is $secs_est\n";
395
+     if ($GLOBALS["debug"])echo "secs_est is $secs_est\n";
396 396
     //assume the server's flops is 1.5G and the average client's flops is 1G
397 397
     $hrs_est = number_format($secs_est*1.5/60, 2);
398 398
     //$hrs_est = number_format($secs_est, 2);
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 }
417 417
 
418 418
 function submit_job($app, $batch_id, $info, $cmdline, $i) {
419
-    $client_disk=$info->rsc_disk_bound*2;
420
-    if($client_disk<500000000) $client_disk=500000000;
419
+    $client_disk = $info->rsc_disk_bound*2;
420
+    if ($client_disk < 500000000) $client_disk = 500000000;
421 421
     $cmd = "cd ../..; ./bin/create_work --appname $app->name --batch $batch_id --rsc_fpops_est $info->rsc_fpops_est --rsc_fpops_bound $info->rsc_fpops_bound --rsc_disk_bound $client_disk";
422 422
     if ($cmdline) {
423 423
         $cmd .= " --command_line \"$cmdline\"";
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
     $x = file_get_contents("$tmpfile");
442 442
     $info = unserialize($x);
443 443
 
444
-    $njobs=0;
444
+    $njobs = 0;
445 445
     $cmdlines = file($info->cmdline_file_path);
446
-    foreach ($cmdlines as $cmdline){
446
+    foreach ($cmdlines as $cmdline) {
447 447
         if (preg_match("/^\s*-var/", $cmdline)) {
448 448
             $njobs++;
449 449
         }
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
     $i = 0;
461 461
     foreach ($cmdlines as $cmdline) {
462
-        if (preg_match("/^\s*-var/", $cmdline)){
462
+        if (preg_match("/^\s*-var/", $cmdline)) {
463 463
             submit_job($app, $batch_id, $info, $cmdline, $i);
464 464
             $i++;
465 465
         }
Please login to merge, or discard this patch.
html/user/tree_threader.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 display_errors();
19 19
 
20 20
 $app_name = "treeThreader";
21
-$log = fopen("/tmp/tt_job.log","a+");
21
+$log = fopen("/tmp/tt_job.log", "a+");
22 22
 
23 23
 function error($s) {
24 24
     echo "<error>\n<message>$s</message>\n</error>\n";
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
 }
27 27
 
28 28
 function handle_submit($r, $user, $app) {
29
-    global $app_name,$log;
29
+    global $app_name, $log;
30 30
 
31
-    $timestamp = date("Y-m-d H:i",time());
31
+    $timestamp = date("Y-m-d H:i", time());
32 32
 	// read the list of template filenames
33 33
 	//
34 34
 	$files = file("../../tree_threader_template_files");
35 35
 	if ($files === false) {
36
-        fwrite($log,"$timestamp\ttemplate file tree_threader_template_files\n");
36
+        fwrite($log, "$timestamp\ttemplate file tree_threader_template_files\n");
37 37
         error("no templates file");
38 38
 
39 39
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 //
91 91
 function handle_get_output($r, $batch) {
92 92
     global $log;
93
-    $timestamp = date("Y-m-d H:i",time());
93
+    $timestamp = date("Y-m-d H:i", time());
94 94
 	$wus = BoincWorkUnit::enum("batch=$batch->id");
95 95
 	$outdir = "/tmp/treeThreader_result_".$batch->id;
96 96
     @mkdir($outdir);
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 		error("can't zip output files");
130 130
 	}
131 131
 	$fname = "treeThreader_result_".$batch->id.".zip";
132
-    $treeThreader_dir="treeThreaderResult";
133
-    if(!is_dir("../../download/$treeThreader_dir"))mkdir("../../download/$treeThreader_dir");
132
+    $treeThreader_dir = "treeThreaderResult";
133
+    if (!is_dir("../../download/$treeThreader_dir"))mkdir("../../download/$treeThreader_dir");
134 134
 	@symlink("/tmp/$fname", "../../download/$treeThreader_dir/$fname");
135 135
     system("rm -fr $outdir");
136 136
     $config = simplexml_load_string(file_get_contents("../../config.xml"));
137 137
     $download_url = trim((string)$config->config->download_url);
138 138
 	echo "<tt_reply>\n<url>$download_url/$treeThreader_dir/$fname</url>\n</tt_reply>\n";
139
-    $log_msg="$timestamp\tuser $batch->user_id downloads results for batch $batch->id : $download_url/$treeThreader_dir/$fname\n";
139
+    $log_msg = "$timestamp\tuser $batch->user_id downloads results for batch $batch->id : $download_url/$treeThreader_dir/$fname\n";
140 140
     fwrite($log, $log_msg);
141 141
 }
142 142
 
Please login to merge, or discard this patch.