Completed
Branch master (72d684)
by Christian
12:25
created
html/inc/prefs_util.inc 3 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -440,6 +440,10 @@  discard block
 block discarded – undo
440 440
     }
441 441
 }
442 442
 
443
+/**
444
+ * @param string $id
445
+ * @param string $d
446
+ */
443 447
 function hour_select($x, $name, $id, $d) {
444 448
     $s = "";
445 449
     $s .= "<select class=\"selectbox form-control input-sm\" name=$name id=$id $d>\n";
@@ -533,6 +537,9 @@  discard block
 block discarded – undo
533 537
 
534 538
 // display preference subsets as columns
535 539
 //
540
+/**
541
+ * @param string $x
542
+ */
536 543
 function row_top($x) {
537 544
     echo "<tr class=\"bg-primary\"><th width=35%>$x</th>";
538 545
     echo "<th ><b>".tra("Default")."</b></th>
@@ -545,6 +552,13 @@  discard block
 block discarded – undo
545 552
 
546 553
 // row_defs - Display a value for all 4 venues in one row
547 554
 //
555
+/**
556
+ * @param string $pre
557
+ * @param string $item
558
+ * @param string $post
559
+ * @param string $type
560
+ * @param string $tooltip
561
+ */
548 562
 function row_defs($pre, $item, $post, $type, $prefs, $tooltip=null) {
549 563
     $gen = $prefs->$item;
550 564
     $hom  = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--";
@@ -599,6 +613,9 @@  discard block
 block discarded – undo
599 613
 //
600 614
 // row_links - Display Edit/Add/Remove links for all venues in 1 row
601 615
 //
616
+/**
617
+ * @param string $subset
618
+ */
602 619
 function row_links($subset, $prefs) {
603 620
     global $g_logged_in_user;
604 621
     $tokens = url_tokens($g_logged_in_user->authenticator);
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 abstract class PREF {
43
-    public $desc;       // short description
44
-    public $tooltip;    // longer description, shown as tooltip
45
-    public $tag;        // the pref's primary XML tag
43
+    public $desc; // short description
44
+    public $tooltip; // longer description, shown as tooltip
45
+    public $tag; // the pref's primary XML tag
46 46
     function __construct($desc, $tooltip, $tag) {
47 47
         $this->desc = $desc;
48 48
         $this->tooltip = $tooltip;
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 
121 121
 class PREF_BOOL extends PREF {
122 122
     public $default;
123
-    public $invert;     // show to user in opposite sense
124
-    function __construct($desc, $tooltip, $tag, $default, $invert=false) {
123
+    public $invert; // show to user in opposite sense
124
+    function __construct($desc, $tooltip, $tag, $default, $invert = false) {
125 125
         $this->default = $default;
126 126
         $this->invert = $invert;
127 127
         parent::__construct($desc, $tooltip, $tag);
128 128
     }
129 129
     function show_value($prefs) {
130 130
         $tag = $this->tag;
131
-        $v = $this->invert?!$prefs->$tag:$prefs->$tag;
131
+        $v = $this->invert ? !$prefs->$tag : $prefs->$tag;
132 132
         echo "<td>".readonly_checkbox($v)."</td>";
133 133
     }
134 134
     function show_form($prefs, $error) {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         }
141 141
         echo "<td ".VALUE_ATTRS.">"
142 142
             ."<input type=checkbox name=$this->tag "
143
-            . ($checked?"checked":"")
143
+            . ($checked ? "checked" : "")
144 144
             ."></td>
145 145
         ";
146 146
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     function xml_string($prefs) {
154 154
         $tag = $this->tag;
155 155
         return "<$tag>"
156
-            .($prefs->$tag?"1":"0")
156
+            .($prefs->$tag ? "1" : "0")
157 157
             ."</$tag>\n";
158 158
     }
159 159
     function xml_parse(&$prefs, $name, $text) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         // this is the value if they check the box
180 180
     public $scale;
181 181
 
182
-    function __construct($suffix, $min, $max, $default, $scale=1, $default2=0) {
182
+    function __construct($suffix, $min, $max, $default, $scale = 1, $default2 = 0) {
183 183
         $this->suffix = " $suffix";
184 184
         $this->min = $min;
185 185
         $this->max = $max;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $v .= "$this->suffix ";
199 199
         return $v;
200 200
     }
201
-    function form_str($tag, $v, $had_error, $disabled=false, $id=null) {
201
+    function form_str($tag, $v, $had_error, $disabled = false, $id = null) {
202 202
         if (is_numeric($v)) {
203 203
             $v /= $this->scale;
204 204
             if (!$had_error && ($v < $this->min || $v > $this->max)) {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             }
207 207
         }
208 208
         if ($disabled) $v = "";
209
-        $i = $id?"id=\"$id\"":"";
209
+        $i = $id ? "id=\"$id\"" : "";
210 210
         return '<input type="text" size="5" class="form-control input-sm" name="'.$tag.'" value="'.$v."\" $disabled $i> &nbsp; $this->suffix ";
211 211
     }
212 212
     function form_convert($in, &$out, &$error) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     function show_form($prefs, $error) {
244 244
         $tag = $this->tag;
245 245
         $had_error = isset($error->$tag);
246
-        $attrs = $had_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
246
+        $attrs = $had_error ? VALUE_ATTRS_ERR : VALUE_ATTRS;
247 247
         echo "<td $attrs>"
248 248
             .$this->num_spec->form_str($tag, $prefs->$tag, $had_error)
249 249
             ."</td>
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
     function show_form($prefs, $error) {
325 325
         $tag = $this->tag;
326 326
         $had_error = isset($error->$tag);
327
-        $attrs = $had_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
327
+        $attrs = $had_error ? VALUE_ATTRS_ERR : VALUE_ATTRS;
328 328
         $checkbox_id = $this->tag."_cb";
329 329
         $text_id = $this->tag;
330 330
         $default = $this->num_spec->get_default();
331 331
         $val = $prefs->$tag;
332
-        $c = $val?"checked":"";
333
-        $d = $val?"":"disabled";
332
+        $c = $val ? "checked" : "";
333
+        $d = $val ? "" : "disabled";
334 334
         echo "<td $attrs>"
335 335
             ."<input type=checkbox id=$checkbox_id onClick=\"checkbox_clicked('$checkbox_id', '$text_id', $default)\" $c> &nbsp;"
336 336
             .$this->num_spec->form_str($tag, $prefs->$tag, $had_error, $d, $text_id)
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         $tag = $this->tag;
388 388
         $tag2 = $this->tag2;
389 389
         $had_error = isset($error->$tag) || isset($error->$tag2);
390
-        $attrs = $had_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
390
+        $attrs = $had_error ? VALUE_ATTRS_ERR : VALUE_ATTRS;
391 391
         $checkbox_id = $this->tag."_cb";
392 392
         $t1_id = $this->tag."_t1";
393 393
         $t2_id = $this->tag."_t2";
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 function hour_select($x, $name, $id, $d) {
444 444
     $s = "";
445 445
     $s .= "<select class=\"selectbox form-control input-sm\" name=$name id=$id $d>\n";
446
-    for ($i=0; $i<24; $i++) {
447
-        $sel = ($x == $i)?"selected":"";
446
+    for ($i = 0; $i < 24; $i++) {
447
+        $sel = ($x == $i) ? "selected" : "";
448 448
         $s .= "<option value=$i $sel> $i:00";
449 449
     }
450 450
     $s .= "</select>\n";
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
 // row_defs - Display a value for all 4 venues in one row
547 547
 //
548
-function row_defs($pre, $item, $post, $type, $prefs, $tooltip=null) {
548
+function row_defs($pre, $item, $post, $type, $prefs, $tooltip = null) {
549 549
     $gen = $prefs->$item;
550 550
     $hom  = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--";
551 551
     $schl = (isset($prefs->school) && isset($prefs->school->$item)) ? $prefs->school->$item : "--";
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
         echo "<tr>";
558 558
     }
559 559
     echo "<td ".NAME_ATTRS.">$pre</td>";
560
-    row_field($gen,  $type);
561
-    row_field($hom,  $type);
560
+    row_field($gen, $type);
561
+    row_field($hom, $type);
562 562
     row_field($schl, $type);
563
-    row_field($wrk,  $type);
563
+    row_field($wrk, $type);
564 564
     echo "<td align=left>$post</td></tr>\n";
565 565
 }
566 566
 
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
 function row_field($value, $type) {
571 571
     echo "<td>";
572 572
     $type = $value === "--" ? "--" : $type;
573
-    switch($type) {
573
+    switch ($type) {
574 574
     case "yesno":
575
-        echo $value ?tra("yes"):tra("no");
575
+        echo $value ? tra("yes") : tra("no");
576 576
         break;
577 577
     case "noyes":
578
-        echo $value ?tra("no"):tra("yes");
578
+        echo $value ? tra("no") : tra("yes");
579 579
         break;
580 580
     case "limit":
581 581
         $x = max_bytes_display_mode($value);
582
-        $y = "$x " . BYTE_ABBR;
582
+        $y = "$x ".BYTE_ABBR;
583 583
         echo $x ? "$y" : tra("no limit");
584 584
         break;
585 585
     case "minutes":
Please login to merge, or discard this patch.
Braces   +66 added lines, -22 removed lines patch added patch discarded remove patch
@@ -26,16 +26,28 @@  discard block
 block discarded – undo
26 26
 $venues = array("home", "school", "work");
27 27
 
28 28
 function check_venue($x) {
29
-    if ($x == "") return;
30
-    if ($x == "home") return;
31
-    if ($x == "work") return;
32
-    if ($x == "school") return;
29
+    if ($x == "") {
30
+        return;
31
+    }
32
+    if ($x == "home") {
33
+        return;
34
+    }
35
+    if ($x == "work") {
36
+        return;
37
+    }
38
+    if ($x == "school") {
39
+        return;
40
+    }
33 41
     error_page(tra("bad venue: %1", $x));
34 42
 }
35 43
 
36 44
 function check_subset($x) {
37
-    if ($x == "global") return;
38
-    if ($x == "project") return;
45
+    if ($x == "global") {
46
+        return;
47
+    }
48
+    if ($x == "project") {
49
+        return;
50
+    }
39 51
     error_page(tra("bad subset: %1", $x));
40 52
 }
41 53
 
@@ -147,7 +159,9 @@  discard block
 block discarded – undo
147 159
     function parse_form(&$prefs, &$error) {
148 160
         $tag = $this->tag;
149 161
         $val = array_key_exists($tag, $_GET);
150
-        if ($this->invert) $val = !$val;
162
+        if ($this->invert) {
163
+            $val = !$val;
164
+        }
151 165
         $prefs->$tag = $val;
152 166
     }
153 167
     function xml_string($prefs) {
@@ -158,7 +172,9 @@  discard block
 block discarded – undo
158 172
     }
159 173
     function xml_parse(&$prefs, $name, $text) {
160 174
         $tag = $this->tag;
161
-        if ($name != $tag) return false;
175
+        if ($name != $tag) {
176
+            return false;
177
+        }
162 178
         $val = (trim($text) != '0');
163 179
         $prefs->$tag = $val;
164 180
         return true;
@@ -205,13 +221,17 @@  discard block
 block discarded – undo
205 221
                 $v = $this->default;
206 222
             }
207 223
         }
208
-        if ($disabled) $v = "";
224
+        if ($disabled) {
225
+            $v = "";
226
+        }
209 227
         $i = $id?"id=\"$id\"":"";
210 228
         return '<input type="text" size="5" class="form-control input-sm" name="'.$tag.'" value="'.$v."\" $disabled $i> &nbsp; $this->suffix ";
211 229
     }
212 230
     function form_convert($in, &$out, &$error) {
213 231
         $error = false;
214
-        if ($in == "") $in = 0;
232
+        if ($in == "") {
233
+            $in = 0;
234
+        }
215 235
         if (!is_numeric($in)) {
216 236
             $error = true;
217 237
             $out = $in;
@@ -223,7 +243,9 @@  discard block
 block discarded – undo
223 243
         }
224 244
     }
225 245
     function get_default() {
226
-        if ($this->default) return $this->default;
246
+        if ($this->default) {
247
+            return $this->default;
248
+        }
227 249
         return $this->default2;
228 250
     }
229 251
 }
@@ -252,17 +274,23 @@  discard block
 block discarded – undo
252 274
     function parse_form(&$prefs, &$error) {
253 275
         $tag = $this->tag;
254 276
         $this->num_spec->form_convert(get_str($tag, true), $prefs->$tag, $e);
255
-        if ($e) $error->$tag = true;
277
+        if ($e) {
278
+            $error->$tag = true;
279
+        }
256 280
     }
257 281
     function xml_string($prefs) {
258 282
         $tag = $this->tag;
259 283
         $v = $prefs->$tag;
260
-        if (!$v) $v = 0;
284
+        if (!$v) {
285
+            $v = 0;
286
+        }
261 287
         return "<$tag>$v</$tag>\n";
262 288
     }
263 289
     function xml_parse(&$prefs, $name, $text) {
264 290
         $tag = $this->tag;
265
-        if ($name != $tag) return false;
291
+        if ($name != $tag) {
292
+            return false;
293
+        }
266 294
         $prefs->$tag = $text;
267 295
         return true;
268 296
     }
@@ -340,17 +368,23 @@  discard block
 block discarded – undo
340 368
     function parse_form(&$prefs, &$error) {
341 369
         $tag = $this->tag;
342 370
         $this->num_spec->form_convert(get_str($tag, true), $prefs->$tag, $e);
343
-        if ($e) $error->$tag = true;
371
+        if ($e) {
372
+            $error->$tag = true;
373
+        }
344 374
     }
345 375
     function xml_string($prefs) {
346 376
         $tag = $this->tag;
347 377
         $v = $prefs->$tag;
348
-        if (!$v) $v = 0;
378
+        if (!$v) {
379
+            $v = 0;
380
+        }
349 381
         return "<$tag>$v</$tag>\n";
350 382
     }
351 383
     function xml_parse(&$prefs, $name, $text) {
352 384
         $tag = $this->tag;
353
-        if ($name != $tag) return false;
385
+        if ($name != $tag) {
386
+            return false;
387
+        }
354 388
         $prefs->$tag = $text;
355 389
         return true;
356 390
     }
@@ -413,9 +447,13 @@  discard block
 block discarded – undo
413 447
         $tag = $this->tag;
414 448
         $tag2 = $this->tag2;
415 449
         $this->num_spec1->form_convert(get_str($tag, true), $prefs->$tag, $e);
416
-        if ($e) $error->$tag = true;
450
+        if ($e) {
451
+            $error->$tag = true;
452
+        }
417 453
         $this->num_spec2->form_convert(get_str($tag2, true), $prefs->$tag2, $e);
418
-        if ($e) $error->$tag2 = $e;
454
+        if ($e) {
455
+            $error->$tag2 = $e;
456
+        }
419 457
     }
420 458
     function xml_string($prefs) {
421 459
         $tag = $this->tag;
@@ -508,7 +546,9 @@  discard block
 block discarded – undo
508 546
         $tag2 = $this->tag2;
509 547
         $h1 = $prefs->$tag;
510 548
         $h2 = $prefs->$tag2;
511
-        if ($h1 == $h2) return "";
549
+        if ($h1 == $h2) {
550
+            return "";
551
+        }
512 552
         return "<$tag>$h1</$tag>\n<$tag2>$h2</$tag2>\n";
513 553
     }
514 554
     function xml_parse(&$prefs, $name, $text) {
@@ -637,9 +677,13 @@  discard block
 block discarded – undo
637 677
 //
638 678
 function project_has_beta() {
639 679
     $apps = BoincApp::enum("deprecated=0 and beta>0");
640
-    if (count($apps)) return true;
680
+    if (count($apps)) {
681
+        return true;
682
+    }
641 683
     $avs = BoincAppVersion::enum("deprecated=0 and beta>0");
642
-    if (count($avs)) return true;
684
+    if (count($avs)) {
685
+        return true;
686
+    }
643 687
     return false;
644 688
 }
645 689
 
Please login to merge, or discard this patch.
html/inc/profile.inc 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -114,6 +114,11 @@
 block discarded – undo
114 114
     return BoincProfile::delete_aux("userid=$user->id");
115 115
 }
116 116
 
117
+/**
118
+ * @param resource $image
119
+ * @param integer $targetWidth
120
+ * @param integer $targetHeight
121
+ */
117 122
 function scale_image(
118 123
     $image, $origWidth, $origHeight, $targetWidth, $targetHeight
119 124
 ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@
 block discarded – undo
191 191
     $min_credit = parse_config(get_config(), "<profile_min_credit>");
192 192
     if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) {
193 193
         error_page(
194
-           tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
194
+            tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
195 195
         );
196 196
     }
197 197
     if (is_banished($user)) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     if (!$user->has_profile) return null;
72 72
     $profile = BoincProfile::lookup("userid=$user->id");
73 73
     if (!$profile->has_picture) return null;
74
-    if (profile_screening() && $profile->verification!=1) return null;
74
+    if (profile_screening() && $profile->verification != 1) return null;
75 75
     return profile_thumb_url($user->id);
76 76
 }
77 77
 
@@ -125,18 +125,18 @@  discard block
 block discarded – undo
125 125
         return $image;
126 126
     }
127 127
 
128
-    ($origWidth > $origHeight)? $scalar = ($origWidth / $targetWidth) : $scalar = ($origHeight / $targetHeight);
128
+    ($origWidth > $origHeight) ? $scalar = ($origWidth/$targetWidth) : $scalar = ($origHeight/$targetHeight);
129 129
 
130 130
     if ($scalar != 0) {
131
-        $destWidth = $origWidth / $scalar;
132
-        $destHeight = $origHeight / $scalar;
131
+        $destWidth = $origWidth/$scalar;
132
+        $destHeight = $origHeight/$scalar;
133 133
     } else {
134 134
         $destWidth = $origWidth;
135 135
         $destHeight = $origHeight;
136 136
     }
137 137
 
138 138
     $gd_info = gd_info();
139
-    $newGD = (strstr($gd_info["GD Version"], "2.0")!="");
139
+    $newGD = (strstr($gd_info["GD Version"], "2.0") != "");
140 140
     if ($newGD) {
141 141
         // If you are using a modern PHP/GD installation that does
142 142
         // 'truecolor' images, this is what's needed.
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $options->htmlitems = false;
180 180
         $temp = output_transform($profile->response1, $options);
181 181
         $temp = sanitize_tags($temp);
182
-        $description = "(\"" . sub_sentence($temp, ' ', MAX_DESC_LENGTH, true) . "\")";
182
+        $description = "(\"".sub_sentence($temp, ' ', MAX_DESC_LENGTH, true)."\")";
183 183
 
184 184
     }
185 185
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
 function check_whether_to_show_profile($user, $logged_in_user) {
191 191
     $min_credit = parse_config(get_config(), "<profile_min_credit>");
192
-    if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) {
192
+    if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit) {
193 193
         error_page(
194 194
            tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
195 195
         );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     //
228 228
     $show_picture = $profile->has_picture;
229 229
     if (profile_screening()) {
230
-        if (!$screen_mode && !$can_edit && $profile->verification!=1) {
230
+        if (!$screen_mode && !$can_edit && $profile->verification != 1) {
231 231
             $show_picture = false;
232 232
         }
233 233
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     // yet verified.  This will tell them if other users can't view it yet, or
244 244
     // if there is a problem with it and they need to replace it.
245 245
     //
246
-    if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification!=1) {
246
+    if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification != 1) {
247 247
         row1(offensive_profile_warning($profile->verification));
248 248
     }
249 249
 
@@ -276,6 +276,6 @@  discard block
 block discarded – undo
276 276
     }
277 277
 }
278 278
 
279
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
279
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
280 280
 
281 281
 ?>
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,10 +68,16 @@
 block discarded – undo
68 68
 }
69 69
 
70 70
 function profile_user_thumb_url($user) {
71
-    if (!$user->has_profile) return null;
71
+    if (!$user->has_profile) {
72
+        return null;
73
+    }
72 74
     $profile = BoincProfile::lookup("userid=$user->id");
73
-    if (!$profile->has_picture) return null;
74
-    if (profile_screening() && $profile->verification!=1) return null;
75
+    if (!$profile->has_picture) {
76
+        return null;
77
+    }
78
+    if (profile_screening() && $profile->verification!=1) {
79
+        return null;
80
+    }
75 81
     return profile_thumb_url($user->id);
76 82
 }
77 83
 
Please login to merge, or discard this patch.
html/inc/result.inc 3 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -53,6 +53,9 @@  discard block
 block discarded – undo
53 53
     return $platforms[$id];
54 54
 }
55 55
 
56
+/**
57
+ * @param string $rsc_name
58
+ */
56 59
 function anon_platform_string($result, $rsc_name=null) {
57 60
     $app = get_app($result->appid);
58 61
     $n = $app->user_friendly_name."<br>".  tra("Anonymous platform");
@@ -92,6 +95,9 @@  discard block
 block discarded – undo
92 95
     return "$n v$v $c<br>$platform->name";
93 96
 }
94 97
 
98
+/**
99
+ * @param string $string_to_show
100
+ */
95 101
 function result_granted_credit_string($result, $string_to_show) {
96 102
     if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS && $result->granted_credit > 0) {
97 103
         return $string_to_show;
@@ -356,6 +362,10 @@  discard block
 block discarded – undo
356 362
     return "results.php?$c&amp;offset=$o&amp;show_names=$sn&amp;state=$st&amp;appid=$appid";
357 363
 }
358 364
 
365
+/**
366
+ * @param boolean $show_wu_link
367
+ * @param boolean $show_host_link
368
+ */
359 369
 function result_table_start($show_wu_link, $show_host_link, $info) {
360 370
     start_table('table-striped');
361 371
     $x = array();
@@ -417,6 +427,11 @@  discard block
 block discarded – undo
417 427
     return false;
418 428
 }
419 429
 
430
+/**
431
+ * @param boolean $show_wu_link
432
+ * @param boolean $show_host_link
433
+ * @param boolean $show_name
434
+ */
420 435
 function show_result_row($result, $show_wu_link, $show_host_link, $show_name) {
421 436
     $s = time_str($result->sent_time);
422 437
     // if result has been reported, show the received time,
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 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";
@@ -312,27 +312,27 @@  discard block
 block discarded – undo
312 312
 }
313 313
 function wu_error_mask_str($s) {
314 314
     $x = "";
315
-    if ($s & WU_ERROR_COULDNT_SEND_RESULT) {
315
+    if ($s&WU_ERROR_COULDNT_SEND_RESULT) {
316 316
         $x = $x." ".tra("Couldn't send result");
317 317
         $s -= WU_ERROR_COULDNT_SEND_RESULT;
318 318
     }
319
-    if ($s & WU_ERROR_TOO_MANY_ERROR_RESULTS) {
319
+    if ($s&WU_ERROR_TOO_MANY_ERROR_RESULTS) {
320 320
         $x = $x." ".tra("Too many errors (may have bug)");
321 321
         $s -= WU_ERROR_TOO_MANY_ERROR_RESULTS;
322 322
     }
323
-    if ($s & WU_ERROR_TOO_MANY_SUCCESS_RESULTS) {
323
+    if ($s&WU_ERROR_TOO_MANY_SUCCESS_RESULTS) {
324 324
         $x = $x." ".tra("Too many results (may be nondeterministic)");
325 325
         $s -= WU_ERROR_TOO_MANY_SUCCESS_RESULTS;
326 326
     }
327
-    if ($s & WU_ERROR_TOO_MANY_TOTAL_RESULTS) {
327
+    if ($s&WU_ERROR_TOO_MANY_TOTAL_RESULTS) {
328 328
         $x = $x." ".tra("Too many total results");
329 329
         $s -= WU_ERROR_TOO_MANY_TOTAL_RESULTS;
330 330
     }
331
-    if ($s & WU_ERROR_CANCELLED) {
331
+    if ($s&WU_ERROR_CANCELLED) {
332 332
         $x = $x." ".tra("WU cancelled");
333 333
         $s -= WU_ERROR_CANCELLED;
334 334
     }
335
-    if ($s & WU_ERROR_NO_CANONICAL_RESULT) {
335
+    if ($s&WU_ERROR_NO_CANONICAL_RESULT) {
336 336
         $x = $x." ".tra("Canonical result is missing");
337 337
         $s -= WU_ERROR_NO_CANONICAL_RESULT;
338 338
     }
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
         $x = $x." ".tra("Unrecognized Error: %1", $s);
341 341
     }
342 342
     if (strlen($x)) {
343
-        $x="<font color=\"#ff3333\">".$x."</font>";
343
+        $x = "<font color=\"#ff3333\">".$x."</font>";
344 344
     } else {
345
-        $x="";
345
+        $x = "";
346 346
     }
347 347
     return $x;
348 348
 }
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
     if ($result->received_time) {
427 427
         $r = time_str($result->received_time);
428 428
     } else if ($result->report_deadline) {
429
-        if ($result->report_deadline>time()) {
430
-            $r = "<font color='#33cc33'>" . time_str($result->report_deadline) . "</font>";
429
+        if ($result->report_deadline > time()) {
430
+            $r = "<font color='#33cc33'>".time_str($result->report_deadline)."</font>";
431 431
         } else {
432
-            $r = "<font color='#ff3333'>" . time_str($result->report_deadline) . "</font>";
432
+            $r = "<font color='#ff3333'>".time_str($result->report_deadline)."</font>";
433 433
         }
434 434
     } else {
435 435
         $r = "---";
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 // @param Integer $dec A signed integer
491 491
 //
492 492
 function int2hex($dec) {
493
-    return "0x".strtoupper(substr(sprintf("%08x",$dec), -8));
493
+    return "0x".strtoupper(substr(sprintf("%08x", $dec), -8));
494 494
 }
495 495
 
496 496
 // Decode a windows error number into semi-human-readable,
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 // @return String A human readable error message
501 501
 // @param Integer $x An error number
502 502
 //
503
-function windows_error_code_str($x){
504
-    $h=int2hex($x);
505
-    switch($h){
503
+function windows_error_code_str($x) {
504
+    $h = int2hex($x);
505
+    switch ($h) {
506 506
     case "0xC0000005": return "STATUS_ACCESS_VIOLATION";
507 507
     case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION";
508 508
     case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO";
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 // @return String A human readable error message
524 524
 // @param Integer $x An error number
525 525
 //
526
-function error_code_str($x){
526
+function error_code_str($x) {
527 527
     // severe Windows error numbers are always large negative integers
528
-    if ($x<-400) return windows_error_code_str($x);
529
-    switch($x){
528
+    if ($x < -400) return windows_error_code_str($x);
529
+    switch ($x) {
530 530
     case 0: return "";
531 531
     case 192: return "EXIT_STATEFILE_WRITE";
532 532
     case 193: return "EXIT_SIGNAL";
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
     return $x." (".int2hex($x).") ".error_code_str($x);
688 688
 }
689 689
 
690
-function show_result($result, $show_outfile_links=false) {
690
+function show_result($result, $show_outfile_links = false) {
691 691
     start_table();
692 692
     row2(tra("Name"), $result->name);
693 693
     row2(tra("Workunit"), "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>");
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
     echo "<h3>".tra("Stderr output")."</h3> <pre>"
737 737
         .htmlspecialchars(
738 738
             $result->stderr_out,
739
-            ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0),
739
+            ENT_QUOTES|(defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0),
740 740
             'utf-8'
741 741
         )
742 742
         ."</pre>"
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 
752 752
     $apps = BoincApp::enum('deprecated=0 ORDER BY user_friendly_name');
753 753
 
754
-    for ($i=0; $i<NSTATES; $i++) {
754
+    for ($i = 0; $i < NSTATES; $i++) {
755 755
         $state_count[$i] = 0;
756 756
     }
757 757
     foreach ($apps as $app) {
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
         $x .= "<a href=$url>".tra("Next")." ".$info->results_per_page."</a>";
794 794
     }
795 795
     $x .= "<br>".tra("State").": ";
796
-    for ($i=0; $i<NSTATES; $i++) {
796
+    for ($i = 0; $i < NSTATES; $i++) {
797 797
         if ($i) $x .= " &middot; ";
798 798
         if ($info->state == $i) {
799 799
             $x .= $state_name[$i];
@@ -838,6 +838,6 @@  discard block
 block discarded – undo
838 838
     return $x;
839 839
 }
840 840
 
841
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
841
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
842 842
 
843 843
 ?>
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -96,7 +96,9 @@  discard block
 block discarded – undo
96 96
     if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS && $result->granted_credit > 0) {
97 97
         return $string_to_show;
98 98
     }
99
-    if ($result->server_state <> RESULT_SERVER_STATE_OVER) return "---";
99
+    if ($result->server_state <> RESULT_SERVER_STATE_OVER) {
100
+        return "---";
101
+    }
100 102
     switch($result->outcome) {
101 103
     case RESULT_OUTCOME_SUCCESS:
102 104
         switch ($result->validate_state) {
@@ -145,7 +147,9 @@  discard block
 block discarded – undo
145 147
 );
146 148
 
147 149
 function state_num($result) {
148
-    if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS) return 1;
150
+    if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS) {
151
+        return 1;
152
+    }
149 153
     if ($result->server_state == RESULT_SERVER_STATE_OVER && $result->outcome == RESULT_OUTCOME_SUCCESS) {
150 154
         if ($result->validate_state == VALIDATE_STATE_INIT) {
151 155
             return STATE_PENDING;
@@ -412,8 +416,12 @@  discard block
 block discarded – undo
412 416
 // was result invalid or timed out?
413 417
 //
414 418
 function bad_result($result) {
415
-    if ($result->validate_state == 2) return true;
416
-    if (!$result->received_time && ($result->report_deadline < time())) return true;
419
+    if ($result->validate_state == 2) {
420
+        return true;
421
+    }
422
+    if (!$result->received_time && ($result->report_deadline < time())) {
423
+        return true;
424
+    }
417 425
     return false;
418 426
 }
419 427
 
@@ -525,7 +533,9 @@  discard block
 block discarded – undo
525 533
 //
526 534
 function error_code_str($x){
527 535
     // severe Windows error numbers are always large negative integers
528
-    if ($x<-400) return windows_error_code_str($x);
536
+    if ($x<-400) {
537
+        return windows_error_code_str($x);
538
+    }
529 539
     switch($x){
530 540
     case 0: return "";
531 541
     case 192: return "EXIT_STATEFILE_WRITE";
@@ -724,7 +734,9 @@  discard block
 block discarded – undo
724 734
         $i = 0;
725 735
         $x = "";
726 736
         foreach ($names as $name) {
727
-            if ($i) $x .= " &middot; ";
737
+            if ($i) {
738
+                $x .= " &middot; ";
739
+            }
728 740
             $url = dir_hier_url($name, "upload", $fanout);
729 741
             echo $name;
730 742
             $x .= " <a href=$url>$i</a> ";
@@ -794,7 +806,9 @@  discard block
 block discarded – undo
794 806
     }
795 807
     $x .= "<br>".tra("State").": ";
796 808
     for ($i=0; $i<NSTATES; $i++) {
797
-        if ($i) $x .= " &middot; ";
809
+        if ($i) {
810
+            $x .= " &middot; ";
811
+        }
798 812
         if ($info->state == $i) {
799 813
             $x .= $state_name[$i];
800 814
         } else {
Please login to merge, or discard this patch.
html/inc/sandbox.inc 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -26,6 +26,9 @@  discard block
 block discarded – undo
26 26
 // Create dir if not present.
27 27
 //
28 28
 if (!function_exists("sandbox_dir")){
29
+/**
30
+ * @return string
31
+ */
29 32
 function sandbox_dir($user) {
30 33
     $dir = parse_config(get_config(), "<sandbox_dir>");
31 34
     if (!$dir) { $dir = "../../sandbox/"; }
@@ -40,12 +43,18 @@  discard block
 block discarded – undo
40 43
 }
41 44
 }
42 45
 
46
+/**
47
+ * @param string $md5
48
+ */
43 49
 function sandbox_write_link_file($path, $size, $md5) {
44 50
     file_put_contents($path, "sb $size $md5");
45 51
 }
46 52
 
47 53
 // check if a newly update files already exists in sandbox via its md5 sum
48 54
 //
55
+/**
56
+ * @param string $md5
57
+ */
49 58
 function sandbox_lf_exist($user, $md5) {
50 59
     $exist = 0;
51 60
     $elf = "";
@@ -115,6 +124,9 @@  discard block
 block discarded – undo
115 124
 // return a <select> for files in sandbox
116 125
 //
117 126
 if (!function_exists('sandbox_file_select')) {
127
+/**
128
+ * @param string $select_name
129
+ */
118 130
 function sandbox_file_select($user, $select_name, $regexp = null, $allow_none = false) {
119 131
     if ($regexp === null) {
120 132
         $regexp = $select_name;
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 // Return path of sandbox directory for the given user.
26 26
 // Create dir if not present.
27 27
 //
28
-if (!function_exists("sandbox_dir")){
28
+if (!function_exists("sandbox_dir")) {
29 29
 function sandbox_dir($user) {
30 30
     $dir = parse_config(get_config(), "<sandbox_dir>");
31 31
     if (!$dir) { $dir = "../../sandbox/"; }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     foreach ($files as $file) {
55 55
         $path = $dir."/".$file;
56 56
         list($err, $file_size, $file_md5) = sandbox_parse_link_file($path);
57
-        if (!$err){
57
+        if (!$err) {
58 58
             if (strcmp($md5, $file_md5) == 0) {
59 59
                 //echo "this file with $md5 already exisits with another name $file";
60 60
                 $exist = 1;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     }
126 126
     $files = sandbox_file_names($user);
127 127
     foreach ($files as $f) {
128
-        if(preg_match("/$regexp/",$f)){
128
+        if (preg_match("/$regexp/", $f)) {
129 129
             $x .= "<option value=\"$f\">$f</option>\n";
130 130
         }
131 131
     }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
 //check if a file is still being used by a unfinished batch
138 138
 //
139
-function sandbox_file_in_use($user, $file){
139
+function sandbox_file_in_use($user, $file) {
140 140
     $ufiles = array();
141 141
 
142 142
     // batch status: 2(completed), 3(aborted)
@@ -144,17 +144,17 @@  discard block
 block discarded – undo
144 144
     $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3");
145 145
     if (!$pbatches) return false;
146 146
 
147
-    foreach ($pbatches as $batch){
148
-        $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" );
149
-        if ($wus == null){
147
+    foreach ($pbatches as $batch) {
148
+        $wus = BoincWorkUnit::enum("batch = $batch->id limit 1");
149
+        if ($wus == null) {
150 150
             //echo " no workunit for this batch<br/>"; 
151 151
             continue;
152 152
         }
153
-        foreach($wus as $wu){
153
+        foreach ($wus as $wu) {
154 154
             $x = "<in>".$wu->xml_doc."</in>";
155 155
             $x = simplexml_load_string($x);
156 156
             global $fanout;
157
-            foreach($x->workunit->file_ref as $fr){
157
+            foreach ($x->workunit->file_ref as $fr) {
158 158
                 $pname = (string)$fr->file_name;
159 159
                 $ufiles[] = $pname;
160 160
             }
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
     $dir = sandbox_dir($user);
166 166
     $path = $dir."/".$file;
167 167
     list($err, $size, $md5) = sandbox_parse_link_file($path);
168
-    if (!$err){
168
+    if (!$err) {
169 169
         $f = sandbox_file_name($user, $md5);
170
-        foreach($ufiles as $uf) {
171
-            if (strcmp($f,$uf) == 0){
170
+        foreach ($ufiles as $uf) {
171
+            if (strcmp($f, $uf) == 0) {
172 172
                 return true;
173 173
             }
174 174
             
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,8 +72,12 @@  discard block
 block discarded – undo
72 72
     if (!file_exists($path)) { return array(true, null, null); }
73 73
     $x = file_get_contents($path);
74 74
     $n = sscanf($x, "%s %d %s", $s, $size, $md5);
75
-    if ($n != 3) return array(true, null, null);
76
-    if ($s != 'sb') return array(true, null, null);
75
+    if ($n != 3) {
76
+        return array(true, null, null);
77
+    }
78
+    if ($s != 'sb') {
79
+        return array(true, null, null);
80
+    }
77 81
     return array(false, $size, $md5);
78 82
 }
79 83
 
@@ -103,8 +107,12 @@  discard block
 block discarded – undo
103 107
     $d = opendir(sandbox_dir($user));
104 108
     $names = array();
105 109
     while (($f = readdir($d)) !== false) {
106
-        if ($f == '.') continue;
107
-        if ($f == '..') continue;
110
+        if ($f == '.') {
111
+            continue;
112
+        }
113
+        if ($f == '..') {
114
+            continue;
115
+        }
108 116
         $names[] = $f;
109 117
     }
110 118
     natsort($names);
@@ -142,7 +150,9 @@  discard block
 block discarded – undo
142 150
     // batch status: 2(completed), 3(aborted)
143 151
     // $pbatches = BoincBatch::enum("user_id = $user->id and state != BATCH_STATE_COMPLETE and state != BATCH_STATE_ABORTED");
144 152
     $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3");
145
-    if (!$pbatches) return false;
153
+    if (!$pbatches) {
154
+        return false;
155
+    }
146 156
 
147 157
     foreach ($pbatches as $batch){
148 158
         $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" );
Please login to merge, or discard this patch.
html/inc/submit.inc 3 patches
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -145,6 +145,9 @@  discard block
 block discarded – undo
145 145
     }
146 146
 }
147 147
 
148
+/**
149
+ * @param string $op
150
+ */
148 151
 function do_batch_op($req, $op) {
149 152
     $retval = validate_request($req);
150 153
     if ($retval) return array(null, $retval);
@@ -172,6 +175,9 @@  discard block
 block discarded – undo
172 175
 
173 176
 // if RPC had a fatal error, return the message
174 177
 //
178
+/**
179
+ * @param string $outer_tag
180
+ */
175 181
 function get_error($reply, $outer_tag) {
176 182
     $name = $reply->getName();
177 183
     if ($name != $outer_tag) {
@@ -187,6 +193,9 @@  discard block
 block discarded – undo
187 193
 
188 194
 //// API functions follow
189 195
 
196
+/**
197
+ * @param stdClass $req
198
+ */
190 199
 function boinc_estimate_batch($req) {
191 200
     list($reply, $errmsg) = do_batch_op($req, "estimate_batch");
192 201
     if ($errmsg) return array(0, $errmsg);
@@ -205,6 +214,9 @@  discard block
 block discarded – undo
205 214
     return array((int)$reply->batch_id, null);
206 215
 }
207 216
 
217
+/**
218
+ * @param stdClass $req
219
+ */
208 220
 function boinc_query_batches($req) {
209 221
     $req_xml = "<query_batches>
210 222
     <authenticator>$req->authenticator</authenticator>
@@ -255,6 +267,9 @@  discard block
 block discarded – undo
255 267
     return array($r, null);
256 268
 }
257 269
 
270
+/**
271
+ * @param stdClass $req
272
+ */
258 273
 function boinc_query_job($req) {
259 274
     $req_xml = "<query_job>
260 275
     <authenticator>$req->authenticator</authenticator>
@@ -285,6 +300,9 @@  discard block
 block discarded – undo
285 300
     return array($r, null);
286 301
 }
287 302
 
303
+/**
304
+ * @return string
305
+ */
288 306
 function boinc_abort_batch($req) {
289 307
     $req_xml = "<abort_batch>
290 308
     <authenticator>$req->authenticator</authenticator>
@@ -299,6 +317,9 @@  discard block
 block discarded – undo
299 317
     return array(true, null);
300 318
 }
301 319
 
320
+/**
321
+ * @param stdClass $req
322
+ */
302 323
 function boinc_get_output_file($req) {
303 324
     $auth_str = md5($req->authenticator.$req->instance_name);
304 325
     $name = $req->instance_name;
@@ -312,6 +333,9 @@  discard block
 block discarded – undo
312 333
     return $req->project."/get_output.php?cmd=batch_files&batch_id=$batch_id&auth_str=$auth_str";
313 334
 }
314 335
 
336
+/**
337
+ * @return string
338
+ */
315 339
 function boinc_retire_batch($req) {
316 340
     $req_xml = "<retire_batch>
317 341
     <authenticator>$req->authenticator</authenticator>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     $b->create_time = (double)($batch->create_time);
159 159
     $b->est_completion_time = (double)($batch->est_completion_time);
160 160
     $b->njobs = (int)($batch->njobs);
161
-    $b->fraction_done = (double) $batch->fraction_done;
161
+    $b->fraction_done = (double)$batch->fraction_done;
162 162
     $b->nerror_jobs = (int)($batch->nerror_jobs);
163 163
     $b->state = (int)($batch->state);
164 164
     $b->completion_time = (double)($batch->completion_time);
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     </result>
387 387
 </output_template>
388 388
 ";
389
-    for ($i=0; $i<2; $i++) {
389
+    for ($i = 0; $i < 2; $i++) {
390 390
         $job->rsc_fpops_est = $i*1e9;
391 391
         $job->command_line = "--t $i";
392 392
         $job->wu_template = $it;
Please login to merge, or discard this patch.
Braces   +45 added lines, -15 removed lines patch added patch discarded remove patch
@@ -95,12 +95,24 @@  discard block
 block discarded – undo
95 95
 }
96 96
 
97 97
 function validate_request($req) {
98
-    if (!is_object($req)) return "req is not an object";
99
-    if (!array_key_exists('project', $req)) return "missing req->project";
100
-    if (!array_key_exists('authenticator', $req)) return "missing req->authenticator";
101
-    if (!array_key_exists('app_name', $req)) return "missing req->app_name";
102
-    if (!array_key_exists('jobs', $req)) return "missing req->jobs";
103
-    if (!is_array($req->jobs)) return "req->jobs is not an array";
98
+    if (!is_object($req)) {
99
+        return "req is not an object";
100
+    }
101
+    if (!array_key_exists('project', $req)) {
102
+        return "missing req->project";
103
+    }
104
+    if (!array_key_exists('authenticator', $req)) {
105
+        return "missing req->authenticator";
106
+    }
107
+    if (!array_key_exists('app_name', $req)) {
108
+        return "missing req->app_name";
109
+    }
110
+    if (!array_key_exists('jobs', $req)) {
111
+        return "missing req->jobs";
112
+    }
113
+    if (!is_array($req->jobs)) {
114
+        return "req->jobs is not an array";
115
+    }
104 116
     foreach ($req->jobs as $job) {
105 117
         // other checks
106 118
     }
@@ -132,7 +144,9 @@  discard block
 block discarded – undo
132 144
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
133 145
     $reply = curl_exec($ch);
134 146
     curl_close($ch);
135
-    if (!$reply) return array(null, "HTTP error");
147
+    if (!$reply) {
148
+        return array(null, "HTTP error");
149
+    }
136 150
     $r = @simplexml_load_string($reply);
137 151
     if (!$r) {
138 152
         return array(null, "Can't parse reply XML:\n$reply");
@@ -147,7 +161,9 @@  discard block
 block discarded – undo
147 161
 
148 162
 function do_batch_op($req, $op) {
149 163
     $retval = validate_request($req);
150
-    if ($retval) return array(null, $retval);
164
+    if ($retval) {
165
+        return array(null, $retval);
166
+    }
151 167
     $xml = req_to_xml($req, $op);
152 168
     return do_http_op($req, $xml, $op);
153 169
 }
@@ -189,7 +205,9 @@  discard block
 block discarded – undo
189 205
 
190 206
 function boinc_estimate_batch($req) {
191 207
     list($reply, $errmsg) = do_batch_op($req, "estimate_batch");
192
-    if ($errmsg) return array(0, $errmsg);
208
+    if ($errmsg) {
209
+        return array(0, $errmsg);
210
+    }
193 211
     if ($x = get_error($reply, "estimate_batch")) {
194 212
         return array(null, $x);
195 213
     }
@@ -198,7 +216,9 @@  discard block
 block discarded – undo
198 216
 
199 217
 function boinc_submit_batch($req) {
200 218
     list($reply, $errmsg) = do_batch_op($req, "submit_batch");
201
-    if ($errmsg) return array(0, $errmsg);
219
+    if ($errmsg) {
220
+        return array(0, $errmsg);
221
+    }
202 222
     if ($x = get_error($reply, "submit_batch")) {
203 223
         return array(null, $x);
204 224
     }
@@ -214,7 +234,9 @@  discard block
 block discarded – undo
214 234
     }
215 235
     $req_xml .= "</query_batches>\n";
216 236
     list($reply, $errmsg) = do_http_op($req, $req_xml, "");
217
-    if ($errmsg) return array(null, $errmsg);
237
+    if ($errmsg) {
238
+        return array(null, $errmsg);
239
+    }
218 240
     if ($x = get_error($reply, "query_batches")) {
219 241
         return array(null, $x);
220 242
     }
@@ -239,7 +261,9 @@  discard block
 block discarded – undo
239 261
     }
240 262
     echo "</query_batch>\n";
241 263
     list($reply, $errmsg) = do_http_op($req, $req_xml, "");
242
-    if ($errmsg) return array(null, $errmsg);
264
+    if ($errmsg) {
265
+        return array(null, $errmsg);
266
+    }
243 267
     if ($x = get_error($reply, "query_batch")) {
244 268
         return array(null, $x);
245 269
     }
@@ -262,7 +286,9 @@  discard block
 block discarded – undo
262 286
 </query_job>
263 287
 ";
264 288
     list($reply, $errmsg) = do_http_op($req, $req_xml, "");
265
-    if ($errmsg) return array(null, $errmsg);
289
+    if ($errmsg) {
290
+        return array(null, $errmsg);
291
+    }
266 292
     if ($x = get_error($reply, "query_job")) {
267 293
         return array(null, $x);
268 294
     }
@@ -292,7 +318,9 @@  discard block
 block discarded – undo
292 318
 </abort_batch>
293 319
 ";
294 320
     list($reply, $errmsg) = do_http_op($req, $req_xml, "");
295
-    if ($errmsg) return $errmsg;
321
+    if ($errmsg) {
322
+        return $errmsg;
323
+    }
296 324
     if ($x = get_error($reply, "abort_batch")) {
297 325
         return array(null, $x);
298 326
     }
@@ -319,7 +347,9 @@  discard block
 block discarded – undo
319 347
 </retire_batch>
320 348
 ";
321 349
     list($reply, $errmsg) = do_http_op($req, $req_xml, "");
322
-    if ($errmsg) return $errmsg;
350
+    if ($errmsg) {
351
+        return $errmsg;
352
+    }
323 353
     if ($x = get_error($reply, "retire_batch")) {
324 354
         return array(null, $x);
325 355
     }
Please login to merge, or discard this patch.
html/inc/submit_db.inc 2 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -34,6 +34,10 @@  discard block
 block discarded – undo
34 34
         $db = BoincDb::get();
35 35
         return $db->enum('batch', 'BoincBatch', $clause);
36 36
     }
37
+
38
+    /**
39
+     * @param string $clause
40
+     */
37 41
     static function insert($clause) {
38 42
         $db = BoincDb::get();
39 43
         $ret = $db->insert('batch', $clause);
@@ -44,6 +48,10 @@  discard block
 block discarded – undo
44 48
         $db = BoincDb::get();
45 49
         return $db->update($this, 'batch', $clause);
46 50
     }
51
+
52
+    /**
53
+     * @param string $clause
54
+     */
47 55
     static function update_aux($clause) {
48 56
         $db = BoincDb::get();
49 57
         return $db->update_aux('batch', $clause);
@@ -59,6 +67,10 @@  discard block
 block discarded – undo
59 67
 }
60 68
 
61 69
 class BoincUserSubmit {
70
+
71
+    /**
72
+     * @param string $clause
73
+     */
62 74
     static function enum($clause) {
63 75
         $db = BoincDb::get();
64 76
         return $db->enum('user_submit', 'BoincUserSubmit', $clause);
@@ -77,6 +89,10 @@  discard block
 block discarded – undo
77 89
         $db = BoincDb::get();
78 90
         return $db->update_aux('user_submit', "$clause where user_id=$this->user_id");
79 91
     }
92
+
93
+    /**
94
+     * @param string $clause
95
+     */
80 96
     static function update_aux($clause) {
81 97
         $db = BoincDb::get();
82 98
         return $db->update_aux('user_submit', $clause);
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@  discard block
 block discarded – undo
37 37
     static function insert($clause) {
38 38
         $db = BoincDb::get();
39 39
         $ret = $db->insert('batch', $clause);
40
-        if (!$ret) return $ret;
40
+        if (!$ret) {
41
+            return $ret;
42
+        }
41 43
         return $db->insert_id();
42 44
     }
43 45
     function update($clause) {
@@ -66,7 +68,9 @@  discard block
 block discarded – undo
66 68
     static function insert($clause) {
67 69
         $db = BoincDb::get();
68 70
         $ret = $db->insert('user_submit', $clause);
69
-        if (!$ret) return false;
71
+        if (!$ret) {
72
+            return false;
73
+        }
70 74
         return true;
71 75
     }
72 76
     static function lookup_userid($user_id) {
@@ -95,7 +99,9 @@  discard block
 block discarded – undo
95 99
     static function insert($clause) {
96 100
         $db = BoincDb::get();
97 101
         $ret = $db->insert('user_submit_app', $clause);
98
-        if (!$ret) return false;
102
+        if (!$ret) {
103
+            return false;
104
+        }
99 105
         return true;
100 106
     }
101 107
     static function delete_user($user_id) {
@@ -112,7 +118,9 @@  discard block
 block discarded – undo
112 118
     static function insert($clause) {
113 119
         $db = BoincDb::get();
114 120
         $ret = $db->insert('job_file', $clause);
115
-        if (!$ret) return false;
121
+        if (!$ret) {
122
+            return false;
123
+        }
116 124
         return $db->insert_id();
117 125
     }
118 126
     static function lookup_name($name) {
@@ -133,7 +141,9 @@  discard block
 block discarded – undo
133 141
     static function insert($clause) {
134 142
         $db = BoincDb::get();
135 143
         $ret = $db->insert('batch_file_assoc', $clause);
136
-        if (!$ret) return false;
144
+        if (!$ret) {
145
+            return false;
146
+        }
137 147
         return true;
138 148
     }
139 149
     static function lookup($clause) {
Please login to merge, or discard this patch.
html/inc/submit_util.inc 3 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -26,6 +26,9 @@  discard block
 block discarded – undo
26 26
 // we need to give a unique physical name based on its content.
27 27
 // Prepend the jf_ to make the origin of the file clear
28 28
 //
29
+/**
30
+ * @param string $md5
31
+ */
29 32
 function job_file_name($md5) {
30 33
     return "jf_$md5";
31 34
 }
@@ -179,12 +182,20 @@  discard block
 block discarded – undo
179 182
     return $batch_td_size;
180 183
 }
181 184
 
185
+/**
186
+ * @param integer $i
187
+ *
188
+ * @return double
189
+ */
182 190
 function boinc_get_output_file_url($user, $result, $i) {
183 191
     $name = $result->name;
184 192
     $auth_str = md5($user->authenticator.$name);
185 193
     return "get_output.php?cmd=result_file&result_name=$name&file_num=$i&auth_str=$auth_str";
186 194
 }
187 195
 
196
+/**
197
+ * @param null|integer $batch_id
198
+ */
188 199
 function boinc_get_output_files_url($user, $batch_id) {
189 200
     $auth_str = md5($user->authenticator.$batch_id);
190 201
     return "get_output.php?cmd=batch_files&batch_id=$batch_id&auth_str=$auth_str";
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         }
74 74
     }
75 75
     if ($fp_total) {
76
-        $batch->fraction_done = $fp_done / $fp_total;
76
+        $batch->fraction_done = $fp_done/$fp_total;
77 77
     }
78 78
     if ($completed && $batch->state == BATCH_STATE_IN_PROGRESS) {
79 79
         $batch->state = BATCH_STATE_COMPLETE;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 // get the total size of output files of a batch
160 160
 //
161 161
 function batch_output_file_size($batchid) {
162
-    $batch_td_size=0;
162
+    $batch_td_size = 0;
163 163
     $wus = BoincWorkunit::enum("batch=$batchid");
164 164
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
165 165
     $upload_dir = parse_config(get_config(), "<upload_dir>");
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
         foreach ($names as $name) {
171 171
             $path = dir_hier_path($name, $upload_dir, $fanout);
172 172
             if (is_file($path)) {
173
-                $s=stat($path);
174
-                $size=$s['size'];
175
-                $batch_td_size+=$size;
173
+                $s = stat($path);
174
+                $size = $s['size'];
175
+                $batch_td_size += $size;
176 176
             }
177 177
         }
178 178
     }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 }
192 192
 
193 193
 function boinc_get_wu_output_files_url($user, $wu_id) {
194
-    $auth_str =  md5($user->authenticator.$wu_id);
194
+    $auth_str = md5($user->authenticator.$wu_id);
195 195
     return "get_output.php?cmd=workunit_files&wu_id=$wu_id&auth_str=$auth_str";
196 196
 }
197 197
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,12 +32,18 @@  discard block
 block discarded – undo
32 32
 
33 33
 function authenticate_user($r, $app) {
34 34
     $auth = (string)$r->authenticator;
35
-    if (!$auth) xml_error(-1, "no authenticator");
35
+    if (!$auth) {
36
+        xml_error(-1, "no authenticator");
37
+    }
36 38
     $auth = BoincDb::escape_string($auth);
37 39
     $user = BoincUser::lookup("authenticator='$auth'");
38
-    if (!$user) xml_error(-1, "bad authenticator");
40
+    if (!$user) {
41
+        xml_error(-1, "bad authenticator");
42
+    }
39 43
     $user_submit = BoincUserSubmit::lookup_userid($user->id);
40
-    if (!$user_submit) xml_error(-1, "no submit access");
44
+    if (!$user_submit) {
45
+        xml_error(-1, "no submit access");
46
+    }
41 47
     if ($app && !$user_submit->submit_all) {
42 48
         $usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id");
43 49
         if (!$usa) {
@@ -89,7 +95,9 @@  discard block
 block discarded – undo
89 95
     $names = array();
90 96
     $xml = "<a>".$result->xml_doc_out."</a>";
91 97
     $r = simplexml_load_string($xml);
92
-    if (!$r) return $names;
98
+    if (!$r) {
99
+        return $names;
100
+    }
93 101
     foreach ($r->file_info as $fi) {
94 102
         $names[] = (string)($fi->name);
95 103
     }
@@ -103,7 +111,9 @@  discard block
 block discarded – undo
103 111
     $paths = array();
104 112
     $xml = "<a>".$result->xml_doc_out."</a>";
105 113
     $r = simplexml_load_string($xml);
106
-    if (!$r) return $paths;
114
+    if (!$r) {
115
+        return $paths;
116
+    }
107 117
     foreach ($r->file_info as $fi) {
108 118
         $path = dir_hier_path((string)($fi->name), $upload_dir, $fanout);
109 119
         $paths[] = $path;
@@ -164,7 +174,9 @@  discard block
 block discarded – undo
164 174
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
165 175
     $upload_dir = parse_config(get_config(), "<upload_dir>");
166 176
     foreach ($wus as $wu) {
167
-        if (!$wu->canonical_resultid) continue;
177
+        if (!$wu->canonical_resultid) {
178
+            continue;
179
+        }
168 180
         $result = BoincResult::lookup_id($wu->canonical_resultid);
169 181
         $names = get_outfile_names($result);
170 182
         foreach ($names as $name) {
Please login to merge, or discard this patch.
html/inc/team.inc 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -524,6 +524,9 @@  discard block
 block discarded – undo
524 524
 //   an active request, i.e. after the 60 days elapse X has another
525 525
 //   30 days to assume foundership before someone elase can request it
526 526
 //
527
+/**
528
+ * @param integer $now
529
+ */
527 530
 function new_transfer_request_ok($team, $now) {
528 531
     if ($team->ping_user <= 0) {
529 532
         if ($team->ping_time < $now - 60 * 86400) {
@@ -544,6 +547,9 @@  discard block
 block discarded – undo
544 547
     return $team->ping_time + 60*86400;
545 548
 }
546 549
 
550
+/**
551
+ * @param integer $now
552
+ */
547 553
 function transfer_ok($team, $now) {
548 554
     if ($now > transfer_ok_time($team)) return true;
549 555
     return false;
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     row2('<b>'.tra('Search criteria (use one or more)').'</b>', '');
41 41
     row2(
42 42
         tra('Key words').'<br><small>'.tra('Find teams with these words in their names or descriptions').'</small>',
43
-        '<input class="form-control" type="text" name="keywords" value="' . htmlspecialchars($params->keywords) . '">');
43
+        '<input class="form-control" type="text" name="keywords" value="'.htmlspecialchars($params->keywords).'">');
44 44
     row2_init(tra('Country'), '');
45 45
     echo '<select class="form-control" name="country"><option value="" selected>---</option>';
46 46
     $country = $params->country;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     echo country_select_options($country);
49 49
     echo "</select></td></tr>\n";
50 50
     row2(tra('Type of team'), team_type_select($params->type, true));
51
-    $checked = $params->active?"checked":"";
51
+    $checked = $params->active ? "checked" : "";
52 52
     row2(tra('Show only active teams'), "<input type=checkbox name=active $checked>");
53 53
     row2("", "<input class=\"btn btn-primary\" type=submit name=submit value=\"".tra('Search')."\">");
54 54
     end_table();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     row2("Created", date_str($team->create_time));
97 97
     if (defined("SHOW_NONVALIDATED_TEAMS")) {
98 98
         $founder = $team->founder;
99
-        row2("Founder email validated", $founder->email_validated?"Yes":"No (team will not be exported)");
99
+        row2("Founder email validated", $founder->email_validated ? "Yes" : "No (team will not be exported)");
100 100
     }
101 101
     if (strlen($team->url)) {;
102 102
         if (strstr($team->url, "http://")) {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     }
169 169
     row1(tra('Members'));
170 170
     row2(tra('Founder'),
171
-        $team->founder?user_links($team->founder, BADGE_HEIGHT_MEDIUM):"---"
171
+        $team->founder ? user_links($team->founder, BADGE_HEIGHT_MEDIUM) : "---"
172 172
     );
173 173
     if (count($team->admins)) {
174 174
         $first = true;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         foreach ($deltas as $delta) {
347 347
             $u = BoincUser::lookup_id($delta->userid);
348 348
             if ($u->teamid == $teamid) {
349
-                $new_members[] = $u;  // they might have later quit
349
+                $new_members[] = $u; // they might have later quit
350 350
             }
351 351
         }
352 352
     }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
     if (!$user->teamid) return;
418 418
     $user->update("teamid=0");
419 419
     $team = BoincTeam::lookup_id($user->teamid);
420
-    if ($team && $team->ping_user=$user->id) {
420
+    if ($team && $team->ping_user = $user->id) {
421 421
         $team->update("ping_user=-ping_user");
422 422
     }
423 423
     BoincTeamAdmin::delete("teamid=$user->teamid and userid=$user->id");
@@ -443,34 +443,34 @@  discard block
 block discarded – undo
443 443
     start_table();
444 444
     row2(tra('Team name, text version').'
445 445
         <br><p class=\"text-muted\">'.tra('Don\'t use HTML tags.').'</p>',
446
-        '<input class="form-control" name="name" type="text" size="50" value="'.($team?$team->name:"").'">'
446
+        '<input class="form-control" name="name" type="text" size="50" value="'.($team ? $team->name : "").'">'
447 447
     );
448 448
     row2(tra('Team name, HTML version').'
449 449
         <br><p class=\"text-muted\">
450 450
         '.tra('You may use %1limited HTML tags%2.', '<a href="html.php" target="_new">', '</a>').'
451 451
         '.tra('If you don\'t know HTML, leave this box blank.').'</p>',
452
-        '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"',"'",($team?$team->name_html:"")).'">'
452
+        '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"', "'", ($team ? $team->name_html : "")).'">'
453 453
     );
454 454
     row2(tra('URL of team web page, if any').':<br><font size=-2>('.tra('without "http://"').')
455 455
         '.tra('This URL will be linked to from the team\'s page on this site.'),
456
-        '<input class="form-control" type="text" name="url" size="60" value="'.($team?$team->url:"").'">'
456
+        '<input class="form-control" type="text" name="url" size="60" value="'.($team ? $team->url : "").'">'
457 457
     );
458 458
     row2(tra('Description of team').':
459 459
         <br><p class=\"text-muted\">
460 460
         '.tra('You may use %1limited HTML tags%2.', '<a href="html.php" target="_new">', '</a>').'
461 461
         </p>',
462
-        '<textarea class="form-control" name="description" rows=10>'.($team?$team->description:"").'</textarea>'
462
+        '<textarea class="form-control" name="description" rows=10>'.($team ? $team->description : "").'</textarea>'
463 463
     );
464 464
 
465
-    row2(tra('Type of team').':', team_type_select($team?$team->type:null));
465
+    row2(tra('Type of team').':', team_type_select($team ? $team->type : null));
466 466
 
467 467
     row2_init(tra('Country'),
468 468
         '<select class="form-control" name="country">'
469 469
     );
470
-    echo country_select_options($team?$team->country:null);
470
+    echo country_select_options($team ? $team->country : null);
471 471
 
472 472
     echo "</select></td></tr>\n";
473
-    $x = (!$team || $team->joinable)?"checked":"";
473
+    $x = (!$team || $team->joinable) ? "checked" : "";
474 474
     row2(tra("Accept new members?"), "<input type=checkbox name=joinable $x>");
475 475
     row2("",
476 476
         "<input class=\"btn btn-primary\" type=submit name=new value='$label'>"
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
 //
527 527
 function new_transfer_request_ok($team, $now) {
528 528
     if ($team->ping_user <= 0) {
529
-        if ($team->ping_time < $now - 60 * 86400) {
529
+        if ($team->ping_time < $now - 60*86400) {
530 530
             return true;
531 531
         }
532 532
         return false;
533 533
     }
534
-    if ($team->ping_time < $now - 90 * 86400) {
534
+    if ($team->ping_time < $now - 90*86400) {
535 535
         return true;
536 536
     }
537 537
     return false;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
     if (!is_valid_country($country)) {
567 567
         $country = tra('None');
568 568
     }
569
-    $country = BoincDb::escape_string($country);  // for Cote d'Ivoire
569
+    $country = BoincDb::escape_string($country); // for Cote d'Ivoire
570 570
 
571 571
     $clause = sprintf(
572 572
         "(userid, create_time, name, name_lc, url, type, name_html, description, country, nusers, expavg_time) values(%d, %d, '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, unix_timestamp())",
@@ -589,6 +589,6 @@  discard block
 block discarded – undo
589 589
     }
590 590
 }
591 591
 
592
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
592
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
593 593
 
594 594
 ?>
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@  discard block
 block discarded – undo
44 44
     row2_init(tra('Country'), '');
45 45
     echo '<select class="form-control" name="country"><option value="" selected>---</option>';
46 46
     $country = $params->country;
47
-    if (!$country || $country == 'None') $country = "XXX";
47
+    if (!$country || $country == 'None') {
48
+        $country = "XXX";
49
+    }
48 50
     echo country_select_options($country);
49 51
     echo "</select></td></tr>\n";
50 52
     row2(tra('Type of team'), team_type_select($params->type, true));
@@ -315,10 +317,16 @@  discard block
 block discarded – undo
315 317
 }
316 318
 
317 319
 function is_team_admin($user, $team) {
318
-    if (!$user) return false;
319
-    if ($user->id == $team->userid) return true;
320
+    if (!$user) {
321
+        return false;
322
+    }
323
+    if ($user->id == $team->userid) {
324
+        return true;
325
+    }
320 326
     $admin = BoincTeamAdmin::lookup($team->id, $user->id);
321
-    if ($admin) return true;
327
+    if ($admin) {
328
+        return true;
329
+    }
322 330
     return false;
323 331
 }
324 332
 
@@ -327,7 +335,9 @@  discard block
 block discarded – undo
327 335
 //
328 336
 function is_team_admin_aux($user, $admins) {
329 337
     foreach ($admins as $a) {
330
-        if ($a->userid == $user->id) return true;
338
+        if ($a->userid == $user->id) {
339
+            return true;
340
+        }
331 341
     }
332 342
     return false;
333 343
 }
@@ -414,7 +424,9 @@  discard block
 block discarded – undo
414 424
 }
415 425
 
416 426
 function user_quit_team($user) {
417
-    if (!$user->teamid) return;
427
+    if (!$user->teamid) {
428
+        return;
429
+    }
418 430
     $user->update("teamid=0");
419 431
     $team = BoincTeam::lookup_id($user->teamid);
420 432
     if ($team && $team->ping_user=$user->id) {
@@ -545,7 +557,9 @@  discard block
 block discarded – undo
545 557
 }
546 558
 
547 559
 function transfer_ok($team, $now) {
548
-    if ($now > transfer_ok_time($team)) return true;
560
+    if ($now > transfer_ok_time($team)) {
561
+        return true;
562
+    }
549 563
     return false;
550 564
 }
551 565
 
@@ -555,7 +569,9 @@  discard block
 block discarded – undo
555 569
     $userid, $name, $url, $type, $name_html, $description, $country
556 570
 ) {
557 571
     $name = BoincDb::escape_string(sanitize_tags($name));
558
-    if (strlen($name) == 0) return null;
572
+    if (strlen($name) == 0) {
573
+        return null;
574
+    }
559 575
     $name_lc = strtolower($name);
560 576
     $url = BoincDb::escape_string(sanitize_tags($url));
561 577
     if (strstr($url, "http://")) {
Please login to merge, or discard this patch.
html/inc/text_transform.inc 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -105,6 +105,9 @@  discard block
 block discarded – undo
105 105
 
106 106
 // handle [pre] and [code] separately because we need to remove <br />s
107 107
 //
108
+/**
109
+ * @param boolean $export
110
+ */
108 111
 function replace_pre_code($text, $export) {
109 112
     if ($export) {
110 113
         $text = preg_replace_callback(
@@ -272,6 +275,11 @@  discard block
 block discarded – undo
272 275
 // for example inside <pre> containers
273 276
 // The original \n was retained after the br when it was added
274 277
 //
278
+/**
279
+ * @param string $text
280
+ *
281
+ * @return string
282
+ */
275 283
 function remove_br($text){
276 284
     return str_replace("<br />", "", $text);
277 285
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 require_once('../inc/sanitize_html.inc');
27 27
 
28 28
 class output_options {
29
-    var $bb2html;            // BBCode as HTML? (on)
30
-    var $images_as_links;    // Images as hyperlinks? (off)
31
-    var $link_popup;        // Links in new windows? (off)
32
-    var $nl2br;                // Convert newlines to <br>'s? (on)
33
-    var $htmlitems;            // Convert special chars to HTML entities? (on)
34
-    var $htmlscrub;            // Scrub "bad" HTML tags? (off)
35
-    var $highlight_terms;// Array of terms to be highlighted (off)    
29
+    var $bb2html; // BBCode as HTML? (on)
30
+    var $images_as_links; // Images as hyperlinks? (off)
31
+    var $link_popup; // Links in new windows? (off)
32
+    var $nl2br; // Convert newlines to <br>'s? (on)
33
+    var $htmlitems; // Convert special chars to HTML entities? (on)
34
+    var $htmlscrub; // Scrub "bad" HTML tags? (off)
35
+    var $highlight_terms; // Array of terms to be highlighted (off)    
36 36
 
37 37
     // Constructor - set the defaults.
38 38
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     if ($export) {
110 110
         $text = preg_replace_callback(
111 111
             "@\[pre\](.*?)\[/pre\]@is",
112
-            function ($matches) {
112
+            function($matches) {
113 113
                 $x = remove_br(substr($matches[0], 5, -6));
114 114
                 $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false);
115 115
                 $x = str_replace("[", "&#91;", $x);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         );
120 120
         return preg_replace_callback(
121 121
             "@\[code\](.*?)\[/code\]@is",
122
-            function ($matches) {
122
+            function($matches) {
123 123
                 $x = remove_br(substr($matches[0], 6, -7));
124 124
                 $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false);
125 125
                 $x = str_replace("[", "&#91;", $x);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     } else {
131 131
         $text = preg_replace_callback(
132 132
             "@\[pre\](.*?)\[/pre\]@is",
133
-            function ($matches) {
133
+            function($matches) {
134 134
                 $x = remove_br(substr($matches[0], 5, -6));
135 135
                 $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false);
136 136
                 $x = str_replace("[", "&#91;", $x);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         );
141 141
         return preg_replace_callback(
142 142
             "@\[code\](.*?)\[/code\]@is",
143
-            function ($matches) {
143
+            function($matches) {
144 144
                 $x = remove_br(substr($matches[0], 6, -7));
145 145
                 $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false);
146 146
                 $x = str_replace("[", "&#91;", $x);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     }
152 152
 }
153 153
 
154
-function bb2html($text, $export=false) {
154
+function bb2html($text, $export = false) {
155 155
     $urlregex = "(?:\"?)(?:(http\:\/\/)?)([^\[\"<\ ]+)(?:\"?)";
156 156
     // NOTE:
157 157
     // This matches https:// too; I don't understand why.
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
     $httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)";
173 173
     // List of allowable tags
174
-    $bbtags = array (
174
+    $bbtags = array(
175 175
         "@\[b\](.*?)\[/b\]@is",
176 176
         "@\[i\](.*?)\[/i\]@is",
177 177
         "@\[u\](.*?)\[/u\]@is",
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     
201 201
     // What the above tags are turned in to
202 202
     if ($export) {
203
-        $htmltags = array (
203
+        $htmltags = array(
204 204
             "<b>\\1</b>",
205 205
             "<i>\\1</i>",
206 206
             "<u>\\1</u>",
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
             "<a href=\"https://github.com/BOINC/boinc-dev-doc/wiki/\\1\">\\1</a>",
228 228
         );
229 229
     } else {
230
-        $htmltags = array (
230
+        $htmltags = array(
231 231
             "<b>\\1</b>",
232 232
             "<i>\\1</i>",
233 233
             "<u>\\1</u>",
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
     $lasttext = "";
260 260
     $i = 0;
261 261
     // $i<1000 to prevent DoS
262
-    while ($text != $lasttext && $i<1000) {
262
+    while ($text != $lasttext && $i < 1000) {
263 263
         $lasttext = $text;
264 264
         $text = replace_pre_code($text, $export);
265 265
         $text = preg_replace($bbtags, $htmltags, $text);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 // for example inside <pre> containers
273 273
 // The original \n was retained after the br when it was added
274 274
 //
275
-function remove_br($text){
275
+function remove_br($text) {
276 276
     return str_replace("<br />", "", $text);
277 277
 }
278 278
 
@@ -280,19 +280,19 @@  discard block
 block discarded – undo
280 280
 //
281 281
 function externalize_links($text) {
282 282
     // TODO:  Convert this to PCRE
283
-    $i=0;
284
-    $linkpos=true;
283
+    $i = 0;
284
+    $linkpos = true;
285 285
     $out = "";
286
-    while (true){
286
+    while (true) {
287 287
         //Find a link
288 288
         //
289
-        $linkpos=strpos($text, "<a ", $i);
290
-        if ($linkpos===false) break;
289
+        $linkpos = strpos($text, "<a ", $i);
290
+        if ($linkpos === false) break;
291 291
 
292 292
         //Replace with target='_new'
293 293
         //
294
-        $out .= substr($text, $i, $linkpos-$i)."<a target=\"_new\" ";
295
-        $i = $linkpos+3;
294
+        $out .= substr($text, $i, $linkpos - $i)."<a target=\"_new\" ";
295
+        $i = $linkpos + 3;
296 296
     }
297 297
     $out .= substr($text, $i);
298 298
     return $out;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
 // Converts image tags to links to the images.
302 302
 
303
-function image_as_link($text){
303
+function image_as_link($text) {
304 304
     /* This function depends on sanitized HTML */
305 305
     // Build some regex (should be a *lot* faster)
306 306
     $pattern = '@<img([\S\s]+?)src=([^>]+?)>@si';
@@ -325,5 +325,5 @@  discard block
 block discarded – undo
325 325
     }
326 326
 }
327 327
 
328
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
328
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
329 329
 ?>
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -94,8 +94,12 @@  discard block
 block discarded – undo
94 94
 function get_output_options($user) {
95 95
     $options = new output_options();
96 96
     if ($user) {
97
-        if ($user->prefs->images_as_links) $options->images_as_links = 1;
98
-        if ($user->prefs->link_popup) $options->link_popup = 1;
97
+        if ($user->prefs->images_as_links) {
98
+            $options->images_as_links = 1;
99
+        }
100
+        if ($user->prefs->link_popup) {
101
+            $options->link_popup = 1;
102
+        }
99 103
     }
100 104
     return $options;
101 105
 }
@@ -287,7 +291,9 @@  discard block
 block discarded – undo
287 291
         //Find a link
288 292
         //
289 293
         $linkpos=strpos($text, "<a ", $i);
290
-        if ($linkpos===false) break;
294
+        if ($linkpos===false) {
295
+            break;
296
+        }
291 297
 
292 298
         //Replace with target='_new'
293 299
         //
Please login to merge, or discard this patch.