@@ -65,6 +65,10 @@ |
||
65 | 65 | return $forum->parent_type == 0 && ($forum->title === $forum_name); |
66 | 66 | } |
67 | 67 | |
68 | +/** |
|
69 | + * @param integer $start |
|
70 | + * @param integer $count |
|
71 | + */ |
|
68 | 72 | function show_news($start, $count) { |
69 | 73 | $forum = news_forum(); |
70 | 74 | if (!$forum) { |
@@ -118,5 +118,5 @@ |
||
118 | 118 | "; |
119 | 119 | } |
120 | 120 | |
121 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
121 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
122 | 122 | ?> |
@@ -27,6 +27,10 @@ discard block |
||
27 | 27 | echo "</div>\n"; |
28 | 28 | } |
29 | 29 | |
30 | +/** |
|
31 | + * @param null|integer $teamid |
|
32 | + * @param string $error |
|
33 | + */ |
|
30 | 34 | function pm_team_form($user, $teamid, $error=null) { |
31 | 35 | global $bbcode_html, $bbcode_js; |
32 | 36 | $team = BoincTeam::lookup_id($teamid); |
@@ -78,6 +82,9 @@ discard block |
||
78 | 82 | page_tail(); |
79 | 83 | } |
80 | 84 | |
85 | +/** |
|
86 | + * @param string $error |
|
87 | + */ |
|
81 | 88 | function pm_form($replyto, $userid, $error = null) { |
82 | 89 | global $bbcode_html, $bbcode_js; |
83 | 90 | global $g_logged_in_user; |
@@ -196,6 +203,9 @@ discard block |
||
196 | 203 | return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject"; |
197 | 204 | } |
198 | 205 | |
206 | +/** |
|
207 | + * @param boolean $send_email |
|
208 | + */ |
|
199 | 209 | function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) { |
200 | 210 | $sql_subject = BoincDb::escape_string(sanitize_tags($subject)); |
201 | 211 | $sql_content = BoincDb::escape_string($content); |
@@ -224,6 +234,9 @@ discard block |
||
224 | 234 | BoincNotify::insert("(userid, create_time, type, opaque) values ($to_user->id, ".time().", ".NOTIFY_PM.", $mid)"); |
225 | 235 | } |
226 | 236 | |
237 | +/** |
|
238 | + * @param integer $duration |
|
239 | + */ |
|
227 | 240 | function pm_count($userid, $duration) { |
228 | 241 | $time = time() - $duration; |
229 | 242 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | echo "</div>\n"; |
28 | 28 | } |
29 | 29 | |
30 | -function pm_team_form($user, $teamid, $error=null) { |
|
30 | +function pm_team_form($user, $teamid, $error = null) { |
|
31 | 31 | global $bbcode_html, $bbcode_js; |
32 | 32 | $team = BoincTeam::lookup_id($teamid); |
33 | 33 | if (!$team) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | error_page("not admin"); |
38 | 38 | } |
39 | 39 | |
40 | - page_head(tra("Send message to team"),'','','', $bbcode_js); |
|
40 | + page_head(tra("Send message to team"), '', '', '', $bbcode_js); |
|
41 | 41 | |
42 | 42 | $subject = post_str("subject", true); |
43 | 43 | $content = post_str("content", true); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | function pm_form($replyto, $userid, $error = null) { |
82 | 82 | global $bbcode_html, $bbcode_js; |
83 | 83 | global $g_logged_in_user; |
84 | - page_head(tra("Send private message"),'','','', $bbcode_js); |
|
84 | + page_head(tra("Send private message"), '', '', '', $bbcode_js); |
|
85 | 85 | |
86 | 86 | if (post_str("preview", true) == tra("Preview")) { |
87 | 87 | $content = post_str("content", true); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | function send_pm_notification_email( |
164 | 164 | $logged_in_user, $to_user, $subject, $content |
165 | 165 | ) { |
166 | - $message = " |
|
166 | + $message = " |
|
167 | 167 | You have received a new private message at ".PROJECT.". |
168 | 168 | |
169 | 169 | From: $logged_in_user->name (ID $logged_in_user->id) |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $pm = BoincPrivateMessage::lookup_id($notify->opaque); |
194 | 194 | $from_user = BoincUser::lookup_id($pm->senderid); |
195 | 195 | if (!$pm || !$from_user) return null; |
196 | - return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject"; |
|
196 | + return "<a href=pm.php>".tra("Private message%1 from %2, subject:", "</a>", $from_user->name)." $pm->subject"; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) { |
@@ -257,11 +257,11 @@ discard block |
||
257 | 257 | |
258 | 258 | function pm_email_remind($user) { |
259 | 259 | if (!$user->prefs->pm_notification) { |
260 | - return "<br><small>" . |
|
260 | + return "<br><small>". |
|
261 | 261 | tra( |
262 | 262 | "For email notification, %1edit community prefs%2", |
263 | 263 | '<a href="edit_forum_preferences_form.php">', '</a>' |
264 | - ) . |
|
264 | + ). |
|
265 | 265 | "</small>" |
266 | 266 | ; |
267 | 267 | } |
@@ -287,5 +287,5 @@ discard block |
||
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | -$cvs_version_tracker[]="\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $"; |
|
290 | +$cvs_version_tracker[] = "\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $"; |
|
291 | 291 | ?> |
@@ -291,6 +291,9 @@ discard block |
||
291 | 291 | return $dp; |
292 | 292 | } |
293 | 293 | |
294 | +/** |
|
295 | + * @param string $t |
|
296 | + */ |
|
294 | 297 | function group_header($t) { |
295 | 298 | echo "<tr><th class=\"bg-info\">$t</th><td class=\"bg-info\" colspan=4><br></td></tr>\n"; |
296 | 299 | } |
@@ -413,6 +416,9 @@ discard block |
||
413 | 416 | |
414 | 417 | // Display all venues as columns next to descriptions |
415 | 418 | // |
419 | +/** |
|
420 | + * @param stdClass $prefs |
|
421 | + */ |
|
416 | 422 | function prefs_show_columns_global($prefs) { |
417 | 423 | global $cpu_prefs; |
418 | 424 | global $disk_prefs; |
@@ -483,6 +489,11 @@ discard block |
||
483 | 489 | return PROJECT; |
484 | 490 | } |
485 | 491 | |
492 | +/** |
|
493 | + * @param stdClass $prefs |
|
494 | + * @param string $venue |
|
495 | + * @param string $subset |
|
496 | + */ |
|
486 | 497 | function prefs_display_venue($prefs, $venue, $subset) { |
487 | 498 | global $g_logged_in_user; |
488 | 499 | $tokens = url_tokens($g_logged_in_user->authenticator); |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | $dp->disk_max_used_pct = parse_config($config, "<default_disk_max_used_pct>"); |
277 | 277 | $dp->disk_min_free_gb = parse_config($config, "<default_disk_min_free_gb>"); |
278 | 278 | // set some defaults if not found |
279 | - if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0; // no limit |
|
279 | + if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0; // no limit |
|
280 | 280 | if (!$dp->disk_max_used_pct) $dp->disk_max_used_pct = 90; // 90 percent |
281 | - if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb = 1; // 1 GB |
|
281 | + if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb = 1; // 1 GB |
|
282 | 282 | // set mininimum free space scheduler allows |
283 | 283 | // - depends on which scheduler is running |
284 | 284 | $dp->new_sched_flag = 1; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | global $text; |
305 | 305 | global $venue_name; |
306 | 306 | |
307 | - switch($name) { |
|
307 | + switch ($name) { |
|
308 | 308 | case "venue": |
309 | 309 | if (array_key_exists("name", $attrs)) { |
310 | 310 | $venue_name = $attrs["name"]; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | return; |
351 | 351 | } |
352 | 352 | } |
353 | - switch($name) { |
|
353 | + switch ($name) { |
|
354 | 354 | case "venue": |
355 | 355 | $top_parse_result->$venue_name = $parse_result; |
356 | 356 | $parse_result = $top_parse_result; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | } |
511 | 511 | |
512 | -function print_prefs_display_global($user, $columns=false) { |
|
512 | +function print_prefs_display_global($user, $columns = false) { |
|
513 | 513 | $global_prefs = prefs_parse_global($user->global_prefs); |
514 | 514 | |
515 | 515 | echo tra("These settings apply to all computers using this account except") |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | .tra("Android devices") |
520 | 520 | ."</ul> |
521 | 521 | "; |
522 | - $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=global&cols=". (int)!$columns .">".tra("(Switch view)")."</a></font>"; |
|
522 | + $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=global&cols=".(int)!$columns.">".tra("(Switch view)")."</a></font>"; |
|
523 | 523 | if ($columns) { |
524 | 524 | echo "<h3>".tra("Combined preferences").$switch_link."</h3>"; |
525 | 525 | start_table(); |
@@ -554,9 +554,9 @@ discard block |
||
554 | 554 | // otherwise false |
555 | 555 | // |
556 | 556 | function print_prefs_form( |
557 | - $action, $subset, $venue, $user, $prefs, $cols, $error=false, |
|
558 | - $project_error=false |
|
559 | -){ |
|
557 | + $action, $subset, $venue, $user, $prefs, $cols, $error = false, |
|
558 | + $project_error = false |
|
559 | +) { |
|
560 | 560 | if ($action == "add") { |
561 | 561 | $script = "add_venue.php"; |
562 | 562 | $submit_value = tra("Add preferences"); |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | // |
596 | 596 | // Functions to display preference subsets as forms |
597 | 597 | // |
598 | -function prefs_form_global($user, $prefs, $error=false) { |
|
598 | +function prefs_form_global($user, $prefs, $error = false) { |
|
599 | 599 | global $cpu_prefs; |
600 | 600 | global $disk_prefs; |
601 | 601 | global $mem_prefs; |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | // |
636 | 636 | function prefs_form_radio_buttons($name, $yesno) { |
637 | 637 | $rb = tra("yes")." <input type=radio name=$name value=yes " |
638 | - .($yesno?"checked":"") |
|
638 | + .($yesno ? "checked" : "") |
|
639 | 639 | ."> ".tra("no")." <input type=radio name=$name value=no " |
640 | - .($yesno?"":"checked") |
|
640 | + .($yesno ? "" : "checked") |
|
641 | 641 | .">\n"; |
642 | 642 | return $rb; |
643 | 643 | } |
@@ -656,12 +656,12 @@ discard block |
||
656 | 656 | } |
657 | 657 | function venue_show($user) { |
658 | 658 | $venue = $user->venue; |
659 | - if ($venue =='') $venue = '---'; |
|
659 | + if ($venue == '') $venue = '---'; |
|
660 | 660 | tooltip_row2(VENUE_TOOLTIP, VENUE_DESC, $venue); |
661 | 661 | } |
662 | 662 | |
663 | 663 | function venue_form($user) { |
664 | - $n=$h=$w=$s=$m=''; |
|
664 | + $n = $h = $w = $s = $m = ''; |
|
665 | 665 | if ($user->venue == '') $n = 'selected'; |
666 | 666 | if ($user->venue == 'home') $h = 'selected'; |
667 | 667 | if ($user->venue == 'work') $w = 'selected'; |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | // |
718 | 718 | // convert prefs from structure to XML |
719 | 719 | // |
720 | -function global_prefs_make_xml($prefs, $primary=true) { |
|
720 | +function global_prefs_make_xml($prefs, $primary = true) { |
|
721 | 721 | global $cpu_prefs; |
722 | 722 | global $disk_prefs; |
723 | 723 | global $mem_prefs; |
@@ -556,7 +556,7 @@ |
||
556 | 556 | function print_prefs_form( |
557 | 557 | $action, $subset, $venue, $user, $prefs, $cols, $error=false, |
558 | 558 | $project_error=false |
559 | -){ |
|
559 | +) { |
|
560 | 560 | if ($action == "add") { |
561 | 561 | $script = "add_venue.php"; |
562 | 562 | $submit_value = tra("Add preferences"); |
@@ -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; |