@@ -241,6 +241,9 @@ |
||
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | +/** |
|
245 | + * @param boolean $columns |
|
246 | + */ |
|
244 | 247 | function prefs_show_privacy($user, $columns) { |
245 | 248 | global $privacy_pref_descs; |
246 | 249 | if ($columns) { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | if ($app_types->cpu) { |
71 | - $project_pref_descs[] = new PREF_BOOL ( |
|
71 | + $project_pref_descs[] = new PREF_BOOL( |
|
72 | 72 | tra("Use CPU"), |
73 | 73 | "Request CPU-only tasks from this project.", |
74 | 74 | "no_cpu", |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ); |
78 | 78 | } |
79 | 79 | if ($app_types->ati) { |
80 | - $project_pref_descs[] = new PREF_BOOL ( |
|
80 | + $project_pref_descs[] = new PREF_BOOL( |
|
81 | 81 | tra("Use ATI GPU"), |
82 | 82 | "Request ATI GPU tasks from this project.", |
83 | 83 | "no_ati", |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | ); |
87 | 87 | } |
88 | 88 | if ($app_types->cuda) { |
89 | - $project_pref_descs[] = new PREF_BOOL ( |
|
89 | + $project_pref_descs[] = new PREF_BOOL( |
|
90 | 90 | tra("Use NVIDIA GPU"), |
91 | 91 | "Request NVIDIA GPU tasks from this project.", |
92 | 92 | "no_cuda", |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ); |
96 | 96 | } |
97 | 97 | if ($app_types->intel_gpu) { |
98 | - $project_pref_descs[] = new PREF_BOOL ( |
|
98 | + $project_pref_descs[] = new PREF_BOOL( |
|
99 | 99 | tra("Use Intel GPU"), |
100 | 100 | "Request Intel GPU tasks from this project.", |
101 | 101 | "no_intel_gpu", |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $x = ""; |
121 | 121 | } |
122 | 122 | |
123 | -$privacy_pref_descs = array ( |
|
123 | +$privacy_pref_descs = array( |
|
124 | 124 | new PREF_BOOL( |
125 | 125 | tra("Is it OK for %1 and your team (if any) to email you?", PROJECT).$x, |
126 | 126 | "", |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | global $in_project_specific; |
153 | 153 | global $venue_name; |
154 | 154 | |
155 | - switch($name) { |
|
155 | + switch ($name) { |
|
156 | 156 | case "venue": |
157 | 157 | $venue_name = $attrs["name"]; |
158 | 158 | $top_parse_result = $parse_result; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | break; |
165 | 165 | default: |
166 | 166 | if ($in_project_specific) { |
167 | - $text= $text."<$name>"; |
|
167 | + $text = $text."<$name>"; |
|
168 | 168 | } else { |
169 | 169 | $text = ""; |
170 | 170 | } |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | global $venue_name; |
180 | 180 | global $project_pref_descs; |
181 | 181 | |
182 | - foreach($project_pref_descs as $p) { |
|
182 | + foreach ($project_pref_descs as $p) { |
|
183 | 183 | if ($p->xml_parse($parse_result, $name, $text)) { |
184 | 184 | return; |
185 | 185 | } |
186 | 186 | } |
187 | - switch($name) { |
|
187 | + switch ($name) { |
|
188 | 188 | case "venue": |
189 | 189 | $top_parse_result->$venue_name = $parse_result; |
190 | 190 | $parse_result = $top_parse_result; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | return $parse_result; |
229 | 229 | } |
230 | 230 | |
231 | -function prefs_show_project($prefs, $columns=false) { |
|
231 | +function prefs_show_project($prefs, $columns = false) { |
|
232 | 232 | global $project_pref_descs; |
233 | 233 | if ($columns) { |
234 | 234 | foreach ($project_pref_descs as $p) { |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | -function prefs_show_project_specific($prefs, $columns=false) { |
|
257 | +function prefs_show_project_specific($prefs, $columns = false) { |
|
258 | 258 | if ($columns) { |
259 | 259 | $project_specific_prefs = project_specific_prefs_parse($prefs->project_specific); |
260 | 260 | $project_specific_prefs->home = isset($prefs->home) ? project_specific_prefs_parse($prefs->home->project_specific) : ""; |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | project_specific_prefs_show($project_specific_prefs, $columns); |
267 | 267 | } |
268 | 268 | |
269 | -function print_prefs_display_project($user, $columns=false) { |
|
269 | +function print_prefs_display_project($user, $columns = false) { |
|
270 | 270 | $project_prefs = prefs_parse_project($user->project_prefs); |
271 | 271 | |
272 | - $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=project&cols=". (int)!$columns .">".tra("(Switch View)")."</a></font>"; |
|
272 | + $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=project&cols=".(int)!$columns.">".tra("(Switch View)")."</a></font>"; |
|
273 | 273 | if ($columns) { |
274 | 274 | start_table(); |
275 | 275 | row_heading(tra("Combined preferences").$switch_link); |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | -function prefs_form_project($prefs, $error=false) { |
|
314 | +function prefs_form_project($prefs, $error = false) { |
|
315 | 315 | global $project_pref_descs; |
316 | 316 | foreach ($project_pref_descs as $p) { |
317 | 317 | $p->show_form_row($prefs, $error); |
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | -function prefs_form_project_specific($prefs_xml, $error=false) { |
|
321 | +function prefs_form_project_specific($prefs_xml, $error = false) { |
|
322 | 322 | $prefs = project_specific_prefs_parse($prefs_xml); |
323 | 323 | project_specific_prefs_edit($prefs, $error); |
324 | 324 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | |
358 | 358 | // given a prefs structure, return the corresponding XML string |
359 | 359 | // |
360 | -function project_prefs_make_xml($prefs, $primary=true) { |
|
360 | +function project_prefs_make_xml($prefs, $primary = true) { |
|
361 | 361 | global $project_pref_descs; |
362 | 362 | $xml = ""; |
363 | 363 | if ($primary) { |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | // |
393 | 393 | function project_prefs_update(&$user, $prefs) { |
394 | 394 | $prefs_xml = BoincDb::escape_string(project_prefs_make_xml($prefs)); |
395 | - $send_email = $user->send_email?1:0; |
|
396 | - $show_hosts = $user->show_hosts?1:0; |
|
395 | + $send_email = $user->send_email ? 1 : 0; |
|
396 | + $show_hosts = $user->show_hosts ? 1 : 0; |
|
397 | 397 | $retval = $user->update("project_prefs='$prefs_xml', send_email=$send_email, show_hosts=$show_hosts"); |
398 | 398 | if (!$retval) { |
399 | 399 | return 1; |
@@ -440,6 +440,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -40,9 +40,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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> $this->suffix "; |
211 | 211 | } |
212 | 212 | function form_convert($in, &$out, &$error) { |
@@ -243,7 +243,7 @@ discard block |
||
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 |
||
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> " |
336 | 336 | .$this->num_spec->form_str($tag, $prefs->$tag, $had_error, $d, $text_id) |
@@ -387,7 +387,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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": |
@@ -114,6 +114,11 @@ |
||
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 | ) { |
@@ -191,7 +191,7 @@ |
||
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)) { |
@@ -71,7 +71,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | ?> |
@@ -53,6 +53,9 @@ discard block |
||
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 |
||
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 |
||
356 | 362 | return "results.php?$c&offset=$o&show_names=$sn&state=$st&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 |
||
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, |
@@ -53,9 +53,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 .= " · "; |
798 | 798 | if ($info->state == $i) { |
799 | 799 | $x .= $state_name[$i]; |
@@ -838,6 +838,6 @@ discard block |
||
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 | ?> |
@@ -500,9 +500,9 @@ discard block |
||
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){ |
|
503 | +function windows_error_code_str($x) { |
|
504 | 504 | $h=int2hex($x); |
505 | - switch($h){ |
|
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 |
||
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 | 528 | if ($x<-400) return windows_error_code_str($x); |
529 | - switch($x){ |
|
529 | + switch($x) { |
|
530 | 530 | case 0: return ""; |
531 | 531 | case 192: return "EXIT_STATEFILE_WRITE"; |
532 | 532 | case 193: return "EXIT_SIGNAL"; |
@@ -26,6 +26,9 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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){ |
|
147 | + foreach ($pbatches as $batch) { |
|
148 | 148 | $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" ); |
149 | - if ($wus == null){ |
|
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 |
||
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 | 170 | foreach($ufiles as $uf) { |
171 | - if (strcmp($f,$uf) == 0){ |
|
171 | + if (strcmp($f,$uf) == 0) { |
|
172 | 172 | return true; |
173 | 173 | } |
174 | 174 |
@@ -145,6 +145,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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> |
@@ -158,7 +158,7 @@ discard block |
||
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 |
||
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; |
@@ -34,6 +34,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -26,6 +26,9 @@ discard block |
||
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 |
||
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"; |
@@ -73,7 +73,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -524,6 +524,9 @@ discard block |
||
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 |
||
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; |
@@ -40,7 +40,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | // Check if we're using reCaptcha to prevent spam accounts |
476 | 476 | // |
@@ -534,12 +534,12 @@ discard block |
||
534 | 534 | // |
535 | 535 | function new_transfer_request_ok($team, $now) { |
536 | 536 | if ($team->ping_user <= 0) { |
537 | - if ($team->ping_time < $now - 60 * 86400) { |
|
537 | + if ($team->ping_time < $now - 60*86400) { |
|
538 | 538 | return true; |
539 | 539 | } |
540 | 540 | return false; |
541 | 541 | } |
542 | - if ($team->ping_time < $now - 90 * 86400) { |
|
542 | + if ($team->ping_time < $now - 90*86400) { |
|
543 | 543 | return true; |
544 | 544 | } |
545 | 545 | return false; |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | if (!is_valid_country($country)) { |
575 | 575 | $country = tra('None'); |
576 | 576 | } |
577 | - $country = BoincDb::escape_string($country); // for Cote d'Ivoire |
|
577 | + $country = BoincDb::escape_string($country); // for Cote d'Ivoire |
|
578 | 578 | |
579 | 579 | $clause = sprintf( |
580 | 580 | "(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())", |
@@ -597,6 +597,6 @@ discard block |
||
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
600 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
601 | 601 | |
602 | 602 | ?> |