Completed
Push — master ( 89cde0...6774c2 )
by Vitalii
45s queued 15s
created
html/ops/batch_accel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                         break;
63 63
                     }
64 64
                     $age = $now - $r->sent_time;
65
-                    if ($age<$batch->expire_time) {
65
+                    if ($age < $batch->expire_time) {
66 66
                         $make_another_result = false;
67 67
                         break;
68 68
                     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             if ($make_another_result) {
73 73
                 echo "creating another instance for WU $wu->id\n";
74 74
                 $query[] = sprintf(
75
-                    'target_nresults=%d', $wu->target_nresults+1
75
+                    'target_nresults=%d', $wu->target_nresults + 1
76 76
                 );
77 77
                 $query[] = sprintf(
78 78
                     'transition_time=%f', $now
Please login to merge, or discard this patch.
html/ops/batch_stats.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     BoincHost::update_aux("error_rate=0");
127 127
     $ltts = [];
128 128
     foreach ($hosts as $id=>$x) {
129
-        $avg = $x->ntt_sum / $x->ntt_n;
129
+        $avg = $x->ntt_sum/$x->ntt_n;
130 130
         if ($avg < 1) {
131 131
             $ltts[] = $id;
132 132
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             $nfast = 0;
151 151
             foreach ($hlist as $id=>$count) {
152 152
                 $x = $hosts[$id];
153
-                $avg = $x->ntt_sum / $x->ntt_n;
153
+                $avg = $x->ntt_sum/$x->ntt_n;
154 154
                 if ($avg < 1) {
155 155
                     $nfast++;
156 156
                 }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         }
166 166
 
167 167
         $app->update(
168
-            sprintf('n_size_classes=%d', $accel?1:0)
168
+            sprintf('n_size_classes=%d', $accel ? 1 : 0)
169 169
         );
170 170
     }
171 171
 }
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
     foreach ($as as $a) {
187 187
         $apps[$a->id] = [];
188 188
     }
189
-    $start = time()-30*86400;
189
+    $start = time() - 30*86400;
190 190
     $batches = BoincBatch::enum(
191 191
         sprintf(
192 192
             'create_time>%d and state in (%d, %d)',
193 193
             $start, BATCH_STATE_IN_PROGRESS, BATCH_STATE_COMPLETE
194 194
         )
195 195
     );
196
-    foreach($batches as $batch) {
196
+    foreach ($batches as $batch) {
197 197
         do_batch($batch);
198 198
     }
199 199
     update_db();
Please login to merge, or discard this patch.
html/user/submit_stats.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
     }
239 239
     $n = 100;
240 240
     $count = [];
241
-    for ($i=0; $i<$n; $i++) {
241
+    for ($i = 0; $i < $n; $i++) {
242 242
         $count[$i] = 0;
243 243
     }
244 244
     $range = $max - $min;
245 245
     foreach ($x as $f) {
246
-        $d = intval($n*($f-$min)/$range);
247
-        if ($d >= $n) $d = $n-1;
246
+        $d = intval($n*($f - $min)/$range);
247
+        if ($d >= $n) $d = $n - 1;
248 248
         $count[$d] += 1;
249 249
     }
250 250
     $data = [];
251
-    for ($i=0; $i<$n; $i++) {
252
-        $data[] = [$min+($i*$range)/$n, $count[$i]];
251
+    for ($i = 0; $i < $n; $i++) {
252
+        $data[] = [$min + ($i*$range)/$n, $count[$i]];
253 253
     }
254 254
     if ($flops) {
255 255
         graph($data, 'runtime', 'Job runtime (hours)', 'job count');
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
 $batch = BoincBatch::lookup_id(get_int('batch_id'));
316 316
 if (!$batch) error_page('no batch');
317
-switch(get_str('action')) {
317
+switch (get_str('action')) {
318 318
 case 'err_host':
319 319
     err_host($batch);
320 320
     break;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             )
218 218
         );
219 219
     } else {
220
-        page_head("Batch $batch->id turnaround times");
220
+        page_head("batch $batch->id turnaround times");
221 221
         echo "<p>Turnaround times of completed jobs.<p>";
222 222
         $results = BoincResult::enum_fields(
223 223
             '(received_time-sent_time)/3600 as val',
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 }
266 266
 
267 267
 function batch_graphs($batch) {
268
-    page_head("Batch $batch->id job times");
268
+    page_head("batch $batch->id job times");
269 269
     echo "
270 270
         <script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>
271 271
     ";
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         }
296 296
     }
297 297
     arsort($x);
298
-    page_head("Batch $batch->id: completed jobs grouped by host");
298
+    page_head("batch $batch->id: completed jobs grouped by host");
299 299
     text_start();
300 300
     start_table();
301 301
     table_header('Host', 'OS', '# jobs');
Please login to merge, or discard this patch.
html/inc/db_conn.inc 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 // Intended to be subclassed (e.g., BoincDb, BossaDb)
23 23
 //
24 24
 class DbConn {
25
-    var $db_conn;       // a mysqli object
26
-    var $db_name;       // the DB name
25
+    var $db_conn; // a mysqli object
26
+    var $db_name; // the DB name
27 27
 
28 28
     function init_conn($user, $passwd, $host, $name) {
29 29
         $x = explode(":", $host);
30
-        if (sizeof($x)>1) {
30
+        if (sizeof($x) > 1) {
31 31
             $host = $x[0];
32 32
             $port = $x[1];
33 33
         } else {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         }
36 36
         try {
37 37
             $this->db_conn = @new mysqli($host, $user, $passwd, $name, $port);
38
-        } catch(Exception $e) {
38
+        } catch (Exception $e) {
39 39
             return false;
40 40
         }
41 41
         if (mysqli_connect_error()) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         return $this->enum_general($classname, $query);
137 137
     }
138 138
 
139
-    function enum($table, $classname, $where_clause=null, $order_clause=null) {
139
+    function enum($table, $classname, $where_clause = null, $order_clause = null) {
140 140
         return self::enum_fields(
141 141
             $table, $classname, '*', $where_clause, $order_clause
142 142
         );
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         $query = "update DBNAME.$table set $clause where id=$obj->id";
147 147
         return $this->do_query($query);
148 148
     }
149
-    function update_aux($table, $clause, $where='') {
149
+    function update_aux($table, $clause, $where = '') {
150 150
         if ($where) $where = " where $where";
151 151
         $query = "update DBNAME.$table set $clause $where";
152 152
         return $this->do_query($query);
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
         if ($x) return (double)$x->$field;
183 183
         return false;
184 184
     }
185
-    function count($table, $clause="TRUE") {
185
+    function count($table, $clause = "TRUE") {
186 186
         $query = "select count(*) as total from DBNAME.$table where $clause";
187 187
         return $this->get_int($query, 'total');
188 188
     }
189
-    function sum($table, $field, $clause="") {
189
+    function sum($table, $field, $clause = "") {
190 190
         $query = "select sum($field) as total from DBNAME.$table $clause";
191 191
         return $this->get_double($query, 'total');
192 192
     }
193
-    function max($table, $field, $clause="") {
193
+    function max($table, $field, $clause = "") {
194 194
         $query = "select max($field) as total from DBNAME.$table $clause";
195 195
         return $this->get_double($query, 'total');
196 196
     }
Please login to merge, or discard this patch.
html/inc/util_basic.inc 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     return file_exists("$d/stop_sched");
57 57
 }
58 58
 
59
-function xml_error($num=-1, $msg=null, $file=null, $line=null) {
59
+function xml_error($num = -1, $msg = null, $file = null, $line = null) {
60 60
     global $xml_outer_tag;
61 61
     if (!$msg) {
62
-        switch($num) {
62
+        switch ($num) {
63 63
         case -112: $msg = "Invalid XML"; break;
64 64
         case -136: $msg = "Not found"; break;
65 65
         case -137: $msg = "Name or email address is not unique"; break;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 // If it's a single-tag element, and it's present, just return the tag
105 105
 //
106 106
 function parse_element($xml, $tag) {
107
-    $closetag = "</" . substr($tag,1);
107
+    $closetag = "</".substr($tag, 1);
108 108
     $x = strstr($xml, $tag);
109 109
     if ($x) {
110 110
         if (strstr($tag, "/>")) return $tag;
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 
121 121
 function parse_next_element($xml, $tag, &$cursor) {
122 122
     $element = null;
123
-    $closetag = "</" . substr($tag,1);
124
-    $pos = substr($xml,$cursor);
123
+    $closetag = "</".substr($tag, 1);
124
+    $pos = substr($xml, $cursor);
125 125
     $x = strstr($pos, $tag);
126 126
     if ($x) {
127 127
         if (strstr($tag, "/>")) return $tag;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 function time_str($x) {
205 205
     if ($x == 0) return "---";
206
-    return gmdate('j M Y, G:i:s', (int)$x) . " UTC";
206
+    return gmdate('j M Y, G:i:s', (int)$x)." UTC";
207 207
 }
208 208
 
209 209
 function local_time_str($x) {
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 // ALSO: allow spaces.
242 242
 //
243 243
 function is_valid_filename($x) {
244
-    if (strlen($x)>255) return false;
244
+    if (strlen($x) > 255) return false;
245 245
     // \w means A-Za-z0-9_
246 246
     return preg_match('/^[\w\-. ]+$/', $x);
247 247
 }
Please login to merge, or discard this patch.
html/inc/util.inc 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 require_once("../inc/bootstrap.inc");
31 31
 
32 32
 function master_url() {
33
-    return parse_config(get_config() , "<master_url>");
33
+    return parse_config(get_config(), "<master_url>");
34 34
 }
35 35
 function recaptcha_public_key() {
36 36
     return parse_config(get_config(), "<recaptcha_public_key>");
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 // Set parameters to defaults if not defined in config.xml
43 43
 
44 44
 $x = parse_config(get_config(), "<user_country>");
45
-define('USER_COUNTRY', ($x===null)?1:(int)$x);
45
+define('USER_COUNTRY', ($x === null) ? 1 : (int)$x);
46 46
 
47 47
 $x = parse_config(get_config(), "<user_url>");
48
-define('USER_URL', ($x===null)?1:(int)$x);
48
+define('USER_URL', ($x === null) ? 1 : (int)$x);
49 49
 
50 50
 // Set parameters to defaults if not defined in project.inc
51 51
 
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 }
156 156
 
157 157
 function url_base() {
158
-    return is_https()?secure_url_base():URL_BASE;
158
+    return is_https() ?secure_url_base() : URL_BASE;
159 159
 }
160 160
 
161
-function send_cookie($name, $value, $permanent, $ops=false) {
161
+function send_cookie($name, $value, $permanent, $ops = false) {
162 162
     // the following allows independent login for projects on the same server
163 163
     //
164 164
     $url = parse_url(master_url());
@@ -167,28 +167,28 @@  discard block
 block discarded – undo
167 167
         $path = substr($path, 0, -1);
168 168
         $path .= "_ops/";
169 169
     }
170
-    $expire = $permanent?time()+3600*24*365:0;
170
+    $expire = $permanent ?time() + 3600*24*365 : 0;
171 171
     setcookie($name, $value, $expire, $path,
172 172
         '',
173
-        is_https(),     // if this page is secure, make cookie secure
173
+        is_https(), // if this page is secure, make cookie secure
174 174
         true            // httponly; no JS access
175 175
     );
176 176
 }
177 177
 
178
-function clear_cookie($name, $ops=false) {
178
+function clear_cookie($name, $ops = false) {
179 179
     $url = parse_url(master_url());
180 180
     $path = $url['path'];
181 181
     if ($ops) {
182 182
         $path = substr($path, 0, -1);
183 183
         $path .= "_ops/";
184 184
     }
185
-    setcookie($name, '', time()-3600, $path);
185
+    setcookie($name, '', time() - 3600, $path);
186 186
 }
187 187
 
188 188
 $g_logged_in_user = null;
189 189
 $got_logged_in_user = false;
190 190
 
191
-function get_logged_in_user($must_be_logged_in=true) {
191
+function get_logged_in_user($must_be_logged_in = true) {
192 192
     global $g_logged_in_user, $got_logged_in_user;
193 193
     if ($got_logged_in_user) {
194 194
         // this could have been called earlier with $must_be_logged_in false
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             $next_url = $_SERVER['REQUEST_URI'];
215 215
             $n = strrpos($next_url, "/");
216 216
             if ($n) {
217
-                $next_url = substr($next_url, $n+1);
217
+                $next_url = substr($next_url, $n + 1);
218 218
             }
219 219
         }
220 220
         $next_url = urlencode($next_url);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     return $g_logged_in_user;
226 226
 }
227 227
 
228
-function show_login_info($prefix="") {
228
+function show_login_info($prefix = "") {
229 229
     $user = get_logged_in_user(false);
230 230
     if ($user) {
231 231
         $url_tokens = url_tokens($user->authenticator);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
     }
236 236
 }
237 237
 
238
-$cache_control_extra="";
238
+$cache_control_extra = "";
239 239
 $is_login_page = false;
240 240
 
241 241
 // Call this to start pages.
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 // with an existing web framework can more easily do so.
248 248
 // To do so, define page_head() in html/project/project.inc
249 249
 //
250
-if (!function_exists("page_head")){
250
+if (!function_exists("page_head")) {
251 251
 function page_head(
252 252
     $title,
253 253
         // page title. Put in <title>, used as title for browser tab.
254
-    $body_attrs=null,
254
+    $body_attrs = null,
255 255
         // <body XXXX>
256 256
         // e.g. Javascript to put focus in an input field
257 257
         // (onload="document.form.foo.focus()")
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
         // if set, include schedulers.txt.
261 261
         // also pass to project_banner() in case you want a different
262 262
         // header for your main page.
263
-    $url_prefix="",
263
+    $url_prefix = "",
264 264
         // prepend this to links.
265 265
         // Use for web pages not in the top directory
266
-    $head_extra=null
266
+    $head_extra = null
267 267
         // extra stuff to put in <head>. E.g.:
268 268
         // reCAPTCHA code (create_profile.php)
269 269
         // bbcode javascript (forums)
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         header("Content-type: text/html; charset=utf-8");
286 286
         header("Expires: Mon, 26 Jul 1997 05:00:00 UTC");
287 287
             // Date in the past
288
-        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC");
288
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC");
289 289
             // always modified
290 290
         header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0");
291 291
             // for HTTP/1.1
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
     if ($head_extra) {
309 309
         echo "\n$head_extra\n";
310 310
     }
311
-    if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) {
311
+    if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) {
312 312
         readfile("schedulers.txt");
313 313
     }
314 314
 
315
-    $t = $title?$title:PROJECT;
315
+    $t = $title ? $title : PROJECT;
316 316
     echo "<title>$t</title>\n";
317 317
     echo '
318 318
         <meta charset="utf-8">
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     echo '<div class="container-fluid">
369 369
     ';
370 370
 
371
-    switch($title) {    //kludge
371
+    switch ($title) {    //kludge
372 372
     case tra("Log in"):
373 373
     case tra("Create an account"):
374 374
     case tra("Server status page"):
@@ -383,13 +383,13 @@  discard block
 block discarded – undo
383 383
 
384 384
 // See the comments for page_head()
385 385
 //
386
-if (!function_exists("page_tail")){
386
+if (!function_exists("page_tail")) {
387 387
 function page_tail(
388
-    $show_date=false,
388
+    $show_date = false,
389 389
         // true for pages that are generated periodically rather than on the fly
390
-    $url_prefix="",
390
+    $url_prefix = "",
391 391
         // use for pages not at top level
392
-    $is_main=false
392
+    $is_main = false
393 393
         // passed to project_footer;
394 394
 ) {
395 395
     echo "<br>\n";
@@ -423,37 +423,37 @@  discard block
 block discarded – undo
423 423
 // convert time interval in seconds to a string of the form
424 424
 // 'D days h hours m min s sec'.
425 425
 
426
-function time_diff($x, $res=3) {
426
+function time_diff($x, $res = 3) {
427 427
     $x = (int)$x;
428 428
     $days    = (int)($x/86400);
429
-    $hours   = (int)(($x-$days*86400)/3600);
430
-    $minutes = (int)(($x-$days*86400-$hours*3600)/60);
431
-    $seconds = $x % 60;
429
+    $hours   = (int)(($x - $days*86400)/3600);
430
+    $minutes = (int)(($x - $days*86400 - $hours*3600)/60);
431
+    $seconds = $x%60;
432 432
 
433 433
     $s = "";
434 434
     if ($days) {
435 435
         $s .= "$days ".tra("days")." ";
436 436
     }
437
-    if ($res>0 && ($hours || strlen($s))) {
437
+    if ($res > 0 && ($hours || strlen($s))) {
438 438
         $s .= "$hours ".tra("hours")." ";
439 439
     }
440
-    if ($res>1 && ($minutes || strlen($s))) {
440
+    if ($res > 1 && ($minutes || strlen($s))) {
441 441
         $s .= "$minutes ".tra("min")." ";
442 442
     }
443
-    if ($res>2) {
443
+    if ($res > 2) {
444 444
         $s .= "$seconds ".tra("sec")." ";
445 445
     }
446 446
     return $s;
447 447
 }
448 448
 
449
-function start_table_str($class="", $style="") {
450
-    $s = $style?'style="'.$style.'"':'';
449
+function start_table_str($class = "", $style = "") {
450
+    $s = $style ? 'style="'.$style.'"' : '';
451 451
     return '<div class="table">
452 452
       <table '.$s.' width="100%" class="table table-condensed '.$class.'" >
453 453
     ';
454 454
 }
455 455
 
456
-function start_table($class="", $style="") {
456
+function start_table($class = "", $style = "") {
457 457
     echo start_table_str($class, $style);
458 458
 }
459 459
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     echo "</tr>\n";
499 499
 }
500 500
 
501
-function row1($x, $ncols=2, $class="heading") {
501
+function row1($x, $ncols = 2, $class = "heading") {
502 502
     if ($class == "heading") {
503 503
         echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n";
504 504
     } else {
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
 
513 513
 // a table row with 2 columns, with the left on right-aligned
514 514
 
515
-function row2($x, $y, $show_error=false, $lwidth='40%') {
516
-    if ($x==="") $x="<br>";
517
-    if ($y==="") $y="<br>";
518
-    $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS;
515
+function row2($x, $y, $show_error = false, $lwidth = '40%') {
516
+    if ($x === "") $x = "<br>";
517
+    if ($y === "") $y = "<br>";
518
+    $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
519 519
     echo "<tr>
520 520
         <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td>
521 521
         <td $attrs >$y</td>
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 // output the first part of row2();
527 527
 // then write the content, followed by </td></tr>
528 528
 
529
-function row2_init($x, $lwidth='40%') {
529
+function row2_init($x, $lwidth = '40%') {
530 530
     echo sprintf('<tr>
531 531
         <td width="%s" %s>%s</td>
532 532
         <td %s>',
@@ -542,31 +542,31 @@  discard block
 block discarded – undo
542 542
     echo "<tr><td>$string</td></tr>";
543 543
 }
544 544
 
545
-function row_array($x, $attrs=null) {
545
+function row_array($x, $attrs = null) {
546 546
     echo "<tr>\n";
547 547
     $i = 0;
548 548
     foreach ($x as $h) {
549
-        $a = $attrs?$attrs[$i]:"";
549
+        $a = $attrs ? $attrs[$i] : "";
550 550
         echo "<td $a>$h</td>\n";
551 551
         $i++;
552 552
     }
553 553
     echo "</tr>\n";
554 554
 }
555 555
 
556
-define ('ALIGN_RIGHT', 'style="text-align:right;"');
556
+define('ALIGN_RIGHT', 'style="text-align:right;"');
557 557
 
558
-function row_heading_array($x, $attrs=null, $class='bg-primary') {
558
+function row_heading_array($x, $attrs = null, $class = 'bg-primary') {
559 559
     echo "<tr>";
560 560
     $i = 0;
561 561
     foreach ($x as $h) {
562
-        $a = $attrs?$attrs[$i]:"";
562
+        $a = $attrs ? $attrs[$i] : "";
563 563
         echo "<th $a class=\"$class\">$h</th>";
564 564
         $i++;
565 565
     }
566 566
     echo "</tr>\n";
567 567
 }
568 568
 
569
-function row_heading($x, $class='bg-primary') {
569
+function row_heading($x, $class = 'bg-primary') {
570 570
     echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr>
571 571
         ', $class, $x
572 572
     );
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 // If $ellipsis is true, then an ellipsis is added to any sentence which
627 627
 // is cut short.
628 628
 
629
-function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) {
629
+function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) {
630 630
     $words = explode($delimiter, $sentence);
631 631
     $total_chars = 0;
632 632
     $trunc = false;
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 
710 710
 // returns null if the arg is optional and missing
711 711
 //
712
-function get_int($name, $optional=false) {
713
-    $x=null;
712
+function get_int($name, $optional = false) {
713
+    $x = null;
714 714
     if (isset($_GET[$name])) $x = $_GET[$name];
715 715
     if (!is_numeric($x)) {
716 716
         if ($optional) {
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 
730 730
 // returns null if the arg is optional and missing
731 731
 //
732
-function post_num($name, $optional=false) {
732
+function post_num($name, $optional = false) {
733 733
     $x = null;
734 734
     if (isset($_POST[$name])) $x = $_POST[$name];
735 735
     if (!is_numeric($x)) {
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 
745 745
 // returns null if the arg is optional and missing
746 746
 //
747
-function post_int($name, $optional=false) {
747
+function post_int($name, $optional = false) {
748 748
     $x = post_num($name, $optional);
749 749
     if (is_null($x)) return null;
750 750
     $y = (int)$x;
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
     }
763 763
 }
764 764
 
765
-function get_str($name, $optional=false) {
765
+function get_str($name, $optional = false) {
766 766
     if (isset($_GET[$name])) {
767 767
         $x = $_GET[$name];
768 768
     } else {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
     return undo_magic_quotes($x);
775 775
 }
776 776
 
777
-function post_str($name, $optional=false) {
777
+function post_str($name, $optional = false) {
778 778
     if (isset($_POST[$name])) {
779 779
         $x = $_POST[$name];
780 780
     } else {
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
     return undo_magic_quotes($x);
787 787
 }
788 788
 
789
-function post_arr($name, $optional=false) {
789
+function post_arr($name, $optional = false) {
790 790
     if (isset($_POST[$name]) && is_array($_POST[$name])) {
791 791
         $x = $_POST[$name];
792 792
     } else {
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
     // the mb_* functions are not included by default
803 803
     // return (mb_detect_encoding($passwd) -= 'ASCII');
804 804
 
805
-    for ($i=0; $i<strlen($str); $i++) {
805
+    for ($i = 0; $i < strlen($str); $i++) {
806 806
         $c = ord(substr($str, $i));
807 807
         if ($c < 32 || $c > 127) return false;
808 808
     }
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
     $number = str_replace(',', '.', $number); // replace the german decimal separator
827 827
     // if no value was entered and this is ok
828 828
     //
829
-    if ($number=='' && !$low) return true;
829
+    if ($number == '' && !$low) return true;
830 830
 
831 831
     // the supplied value contains alphabetic characters
832 832
     //
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 
844 844
 // Generate a "select" element from an array of values
845 845
 //
846
-function select_from_array($name, $array, $selection=null, $width=240) {
846
+function select_from_array($name, $array, $selection = null, $width = 240) {
847 847
     $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"';
848 848
 
849 849
     foreach ($array as $key => $value) {
@@ -868,12 +868,12 @@  discard block
 block discarded – undo
868 868
     return $str;
869 869
 }
870 870
 
871
-function strip_bbcode($string){
872
-    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string);
871
+function strip_bbcode($string) {
872
+    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string);
873 873
 }
874 874
 
875 875
 function current_url() {
876
-    $url = is_https()?'https':'http';
876
+    $url = is_https() ? 'https' : 'http';
877 877
     $url .= "://";
878 878
     $url .= $_SERVER['SERVER_NAME'];
879 879
     $url .= ":".$_SERVER['SERVER_PORT'];
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 // the colors for bootstrap's btn-success are almost illegible;
892 892
 // the green is too light.  Use a darker green.
893 893
 //
894
-function button_style($color='green', $font_size=null) {
894
+function button_style($color = 'green', $font_size = null) {
895 895
     $fs = '';
896 896
     if ($font_size) {
897 897
         $fs = sprintf('; font-size:%dpx', $font_size);
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 // class: class of the button, e.g. btn
911 911
 // extra: Additional text in href tag
912 912
 //
913
-function button_text($url, $text, $desc=null, $class=null, $extra='') {
913
+function button_text($url, $text, $desc = null, $class = null, $extra = '') {
914 914
     if (!$desc) {
915 915
         $desc = $text;
916 916
     }
@@ -925,23 +925,23 @@  discard block
 block discarded – undo
925 925
     );
926 926
 }
927 927
 
928
-function button_text_small($url, $text, $desc=null) {
928
+function button_text_small($url, $text, $desc = null) {
929 929
     return button_text($url, $text, $desc, "btn btn-xs", button_style());
930 930
 }
931 931
 
932
-function show_button($url, $text, $desc=null, $class=null, $extra=null) {
932
+function show_button($url, $text, $desc = null, $class = null, $extra = null) {
933 933
     echo button_text($url, $text, $desc, $class, $extra);
934 934
 }
935 935
 
936 936
 // for places with a bunch of buttons, like forum posts
937 937
 //
938
-function show_button_small($url, $text, $desc=null) {
938
+function show_button_small($url, $text, $desc = null) {
939 939
     echo button_text_small($url, $text, $desc);
940 940
 }
941 941
 
942 942
 // used for showing icons
943 943
 //
944
-function show_image($src, $title, $alt, $height=null) {
944
+function show_image($src, $title, $alt, $height = null) {
945 945
     $h = "";
946 946
     if ($height) {
947 947
         $h = "height=\"$height\"";
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 // tries instead to connect to <replica_db_host> if tag exists.
979 979
 // DEPRECATED - use boinc_db.inc
980 980
 //
981
-function db_init($try_replica=false) {
981
+function db_init($try_replica = false) {
982 982
     check_web_stopped();
983 983
     $retval = db_init_aux($try_replica);
984 984
     if ($retval == 1) {
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 // Check this to avoid XSS vulnerability
1055 1055
 //
1056 1056
 function sanitize_sort_by($x) {
1057
-    switch($x) {
1057
+    switch ($x) {
1058 1058
     case 'expavg_credit':
1059 1059
     case 'total_credit':
1060 1060
         return;
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 }
1073 1073
 
1074 1074
 function do_download($path) {
1075
-    $name=basename($path);
1075
+    $name = basename($path);
1076 1076
     header('Content-Description: File Transfer');
1077 1077
     header('Content-Type: application/octet-stream');
1078 1078
     header('Content-Disposition: attachment; filename='.$name);
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
     header('Expires: 0');
1081 1081
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1082 1082
     header('Pragma: public');
1083
-    header('Content-Length: ' . filesize($path));
1083
+    header('Content-Length: '.filesize($path));
1084 1084
     flush();
1085 1085
     readfile($path);
1086 1086
 }
@@ -1129,10 +1129,10 @@  discard block
 block discarded – undo
1129 1129
 // Otherwise return 0.
1130 1130
 // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)"
1131 1131
 //
1132
-function boinc_client_version(){
1132
+function boinc_client_version() {
1133 1133
     if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0;
1134 1134
     $x = $_SERVER['HTTP_USER_AGENT'];
1135
-    $e =  "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1135
+    $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
1136 1136
     if (preg_match($e, $x, $matches)) {
1137 1137
         return $matches[1]*10000 + $matches[2]*100 + $matches[3];
1138 1138
     }
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
     $rem_name = $name."_remaining";
1162 1162
     return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\"
1163 1163
         onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea>
1164
-        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1164
+        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1165 1165
     ;
1166 1166
 }
1167 1167
 
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 // use the following around text with long lines,
1192 1192
 // to limit the width and make it more readable.
1193 1193
 //
1194
-function text_start($width=640) {
1194
+function text_start($width = 640) {
1195 1195
     echo sprintf("<div style=\"max-width: %dpx;\">\n", $width);
1196 1196
 }
1197 1197
 function text_end() {
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 }
1218 1218
 
1219 1219
 function cert_filename() {
1220
-    return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php";
1220
+    return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php";
1221 1221
 }
1222 1222
 
1223 1223
 // if user hasn't validated their email addr, tell them to
Please login to merge, or discard this patch.
html/inc/boinc_db.inc 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 // close() closes the connection.
45 45
 
46 46
 class BoincDb {
47
-    static $instance;       // a DbConn object, or null
48
-    static $dbnum;          // which replica we're connected to
47
+    static $instance; // a DbConn object, or null
48
+    static $dbnum; // which replica we're connected to
49 49
 
50 50
     // connect to DB $dbnum (0, 1, ...)
51 51
     // If the requested DB doesn't exist or connection fails, connect to DB 0.
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         self::$instance = null;
57 57
         $config = get_config();
58 58
         if ($dbnum) {
59
-            $r = $dbnum==1?'':strval($dbnum);
59
+            $r = $dbnum == 1 ? '' : strval($dbnum);
60 60
             $host = parse_config($config, sprintf('<replica%s_db_host>', $r));
61 61
             $name = parse_config($config, sprintf('<replica%s_db_name>', $r));
62 62
             $user = parse_config($config, sprintf('<replica%s_db_user>', $r));
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
         $db = BoincDb::get();
205 205
         return $db->update($this, 'user', $clause);
206 206
     }
207
-    static function enum($where_clause, $order_clause=null) {
207
+    static function enum($where_clause, $order_clause = null) {
208 208
         $db = BoincDb::get();
209 209
         return $db->enum('user', 'BoincUser', $where_clause, $order_clause);
210 210
     }
211
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
211
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
212 212
         $db = BoincDb::get();
213 213
         return $db->enum_fields(
214 214
             'user', 'BoincUser', $fields, $where_clause, $order_clause
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         $db = BoincDb::get();
259 259
         return $db->update($this, 'team', $clause);
260 260
     }
261
-    static function enum($where_clause, $order_clause=null) {
261
+    static function enum($where_clause, $order_clause = null) {
262 262
         $db = BoincDb::get();
263 263
         return $db->enum('team', 'BoincTeam', $where_clause, $order_clause);
264 264
     }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         $db = BoincDb::get();
284 284
         return $db->max('team', $field);
285 285
     }
286
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
286
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
287 287
         $db = BoincDb::get();
288 288
         return $db->enum_fields(
289 289
             'team', 'BoincTeam', $fields, $where_clause, $order_clause
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
         $db = BoincDb::get();
318 318
         return $db->update($this, 'host', $clause);
319 319
     }
320
-    static function update_aux($clause, $where='') {
320
+    static function update_aux($clause, $where = '') {
321 321
         $db = BoincDb::get();
322 322
         return $db->update_aux('host', $clause, $where);
323 323
     }
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
         $db = BoincDb::get();
326 326
         return $db->delete($this, 'host');
327 327
     }
328
-    static function enum($where_clause, $order_clause=null) {
328
+    static function enum($where_clause, $order_clause = null) {
329 329
         $db = BoincDb::get();
330 330
         return $db->enum('host', 'BoincHost', $where_clause, $order_clause);
331 331
     }
332
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
332
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
333 333
         $db = BoincDb::get();
334 334
         return $db->enum_fields(
335 335
             'host', 'BoincHost', $fields, $where_clause, $order_clause
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $db = BoincDb::get();
367 367
         return $db->enum('result', 'BoincResult', $where_clause);
368 368
     }
369
-	static function enum_fields($fields, $where_clause, $order_clause=null) {
369
+	static function enum_fields($fields, $where_clause, $order_clause = null) {
370 370
         $db = BoincDb::get();
371 371
 		return $db->enum_fields(
372 372
             'result', 'BoincResult', $fields, $where_clause, $order_clause
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         $db = BoincDb::get();
377 377
         return $db->update($this, 'result', $clause);
378 378
     }
379
-    static function update_aux($clause, $where='') {
379
+    static function update_aux($clause, $where = '') {
380 380
         $db = BoincDb::get();
381 381
         return $db->update_aux('result', $clause, $where);
382 382
     }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
         $db = BoincDb::get();
416 416
         return $db->enum('workunit', 'BoincWorkunit', $where_clause);
417 417
     }
418
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
418
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
419 419
         $db = BoincDb::get();
420 420
         return $db->enum_fields('workunit', 'BoincWorkunit', $fields, $where_clause, $order_clause);
421 421
     }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         $db = BoincDb::get();
424 424
         return $db->update($this, 'workunit', $clause);
425 425
     }
426
-    static function update_aux($clause, $where='') {
426
+    static function update_aux($clause, $where = '') {
427 427
         $db = BoincDb::get();
428 428
         return $db->update_aux('workunit', $clause, $where);
429 429
     }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
         $db = BoincDb::get();
458 458
         return $db->update($this, 'app', $clause);
459 459
     }
460
-    static function sum($field, $clause=null) {
460
+    static function sum($field, $clause = null) {
461 461
         $db = BoincDb::get();
462 462
         return $db->sum('app', $field, $clause);
463 463
     }
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
         $db = BoincDb::get();
516 516
         return $db->insert('profile', $clause);
517 517
     }
518
-    static function enum($where_clause=null, $order_clause=null) {
518
+    static function enum($where_clause = null, $order_clause = null) {
519 519
         $db = BoincDb::get();
520 520
         return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause);
521 521
     }
522
-    static function enum_fields($fields, $where_clause=null, $order_clause=null) {
522
+    static function enum_fields($fields, $where_clause = null, $order_clause = null) {
523 523
         $db = BoincDb::get();
524 524
         return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause);
525 525
     }
@@ -914,12 +914,12 @@  discard block
 block discarded – undo
914 914
         return $db->enum('consent', 'BoincConsent', $where_clause);
915 915
     }
916 916
 
917
-    static function insert ($clause) {
917
+    static function insert($clause) {
918 918
         $db = BoincDb::get();
919 919
         return $db->insert('consent', $clause);
920 920
     }
921 921
 
922
-    static function update ($clause) {
922
+    static function update($clause) {
923 923
         $db = BoincDb::get();
924 924
         return $db->update_aux('consent', $clause);
925 925
     }
@@ -944,17 +944,17 @@  discard block
 block discarded – undo
944 944
         return $db->lookup('consent_type', 'BoincConsentType', $clause);
945 945
     }
946 946
 
947
-    static function enum($where_clause, $order_clause=null) {
947
+    static function enum($where_clause, $order_clause = null) {
948 948
         $db = BoincDb::get();
949 949
         return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause);
950 950
     }
951 951
 
952
-    static function insert ($clause) {
952
+    static function insert($clause) {
953 953
         $db = BoincDb::get();
954 954
         return $db->insert('consent_type', $clause);
955 955
     }
956 956
 
957
-    static function update ($clause) {
957
+    static function update($clause) {
958 958
         $db = BoincDb::get();
959 959
         return $db->update_aux('consent_type', $clause);
960 960
     }
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
         return $db->lookup('latest_consent', 'BoincLatestConsent', $clause);
981 981
     }
982 982
 
983
-    static function enum($where_clause, $order_clause=null) {
983
+    static function enum($where_clause, $order_clause = null) {
984 984
         $db = BoincDb::get();
985 985
         return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause);
986 986
     }
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 // apply this to any user-supplied strings used in queries
992 992
 //
993 993
 function boinc_real_escape_string($x) {
994
-    if (version_compare(phpversion(),"4.3.0")>=0) {
994
+    if (version_compare(phpversion(), "4.3.0") >= 0) {
995 995
         return BoincDb::escape_string($x);
996 996
     } else {
997 997
         $x = str_replace("'", "\'", $x);
Please login to merge, or discard this patch.
html/inc/host.inc 1 patch
Spacing   +21 added lines, -21 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);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         }
186 186
         if (defined('BATCH_ACCEL') && BATCH_ACCEL) {
187 187
             row2('Low turnaround time?',
188
-                $host->error_rate?'yes':'no'
188
+                $host->error_rate ? 'yes' : 'no'
189 189
             );
190 190
         }
191 191
     }
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 // Older clients may have the old-style serialnum in the DB
299 299
 // despite the server being upgraded.
300 300
 //
301
-function vbox_desc($parsed_ser){
301
+function vbox_desc($parsed_ser) {
302 302
     if (empty($parsed_ser['vbox'])) return '---';
303 303
     $f = $parsed_ser['vbox'];
304 304
     $desc = sprintf('Virtualbox (%s) %s',
305 305
         $f[1], tra("installed")
306 306
     );
307
-    if (sizeof($f)<=2){
307
+    if (sizeof($f) <= 2) {
308 308
         return $desc;
309 309
     }
310
-    if ($f[2]=="1" and $f[3]=="1") {
310
+    if ($f[2] == "1" and $f[3] == "1") {
311 311
         return $desc.tra(", CPU has hardware virtualization support and it is enabled");
312
-    } elseif ($f[2]=="1" and $f[3]=="0") {
312
+    } elseif ($f[2] == "1" and $f[3] == "0") {
313 313
         return $desc.tra(", CPU has hardware virtualization support but it is disabled");
314
-    } elseif ($f[2]=="0") {
314
+    } elseif ($f[2] == "0") {
315 315
         return $desc.tra(", CPU does not have hardware virtualization support");
316 316
     }
317 317
     return $desc;
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 
337 337
 // return a human-readable version of the GPU info
338 338
 //
339
-function gpu_desc($parsed_ser, $detail=true) {
339
+function gpu_desc($parsed_ser, $detail = true) {
340 340
     $str = "";
341 341
     foreach ($parsed_ser as $d) {
342 342
         if (!is_gpu_type($d[0])) continue;
343 343
         if (count($d) < 4) continue;
344 344
         if ($str) $str .= "<p>";
345
-        if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] ";
345
+        if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] ";
346 346
         if ($d[0] == "CUDA") {
347 347
             $str .= "NVIDIA";
348 348
         } else if ($d[0] == "CAL") {
@@ -548,14 +548,14 @@  discard block
 block discarded – undo
548 548
     if ($pos1 === false) return $x;
549 549
     $pos2 = strpos($model, ']');
550 550
     if ($pos2 === false) return $x;
551
-    $a = substr($model, $pos1+1, $pos2-$pos1-1);
551
+    $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1);
552 552
     $y = explode(" ", $a);
553 553
     if (count($y) == 0) return $x;
554 554
     if ($y[0] == "Family") {
555 555
         $x->info = $a;
556 556
     } else {
557 557
         $x->arch = $y[0];
558
-        $x->info = substr($a, strlen($y[0])+1);
558
+        $x->info = substr($a, strlen($y[0]) + 1);
559 559
     }
560 560
     return $x;
561 561
 }
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
     $avg_time = 0;
645 645
 
646 646
     $results = BoincResult::enum("hostid=$hostid order by received_time");
647
-    foreach($results as $result) {
647
+    foreach ($results as $result) {
648 648
         if ($result->granted_credit <= 0) continue;
649 649
         $total += $result->granted_credit;
650 650
 
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 
738 738
 function link_url($sort, $rev, $show_all) {
739 739
     global $userid;
740
-    $x = $userid ? "&userid=$userid":"";
740
+    $x = $userid ? "&userid=$userid" : "";
741 741
     return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x";
742 742
 }
743 743
 
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 }
812 812
 
813 813
 function show_user_hosts($userid, $private, $show_all, $sort, $rev) {
814
-    $desc = false;  // whether the sort order's default is decreasing
814
+    $desc = false; // whether the sort order's default is decreasing
815 815
     switch ($sort) {
816 816
     case "total_credit": $sort_clause = "total_credit"; $desc = true; break;
817 817
     case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
     more_or_less($sort, $rev, $show_all);
835 835
 
836 836
     $now = time();
837
-    $old_hosts=0;
837
+    $old_hosts = 0;
838 838
     $i = 1;
839 839
     $hosts = BoincHost::enum("userid=$userid order by $sort_clause limit 100");
840 840
     $any_product_name = false;
@@ -846,9 +846,9 @@  discard block
 block discarded – undo
846 846
     }
847 847
     user_host_table_start($private, $sort, $rev, $show_all, $any_product_name);
848 848
     foreach ($hosts as $host) {
849
-        $is_old=false;
849
+        $is_old = false;
850 850
         if (($now - $host->rpc_time) > 30*86400) {
851
-            $is_old=true;
851
+            $is_old = true;
852 852
             $old_hosts++;
853 853
         }
854 854
         if (!$show_all && $is_old) continue;
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
     }
858 858
     end_table();
859 859
 
860
-    if ($old_hosts>0) {
860
+    if ($old_hosts > 0) {
861 861
         more_or_less($sort, $rev, $show_all);
862 862
     }
863 863
 
Please login to merge, or discard this patch.