@@ -30,6 +30,9 @@ discard block |
||
30 | 30 | // |
31 | 31 | // output: success flag, CPU time per step, est. disk usage per job |
32 | 32 | // |
33 | +/** |
|
34 | + * @param resource $p |
|
35 | + */ |
|
33 | 36 | function terminate_job($p) { |
34 | 37 | $pstatus=proc_get_status($p); |
35 | 38 | $ppid=$pstatus['pid']; |
@@ -86,6 +89,9 @@ discard block |
||
86 | 89 | return array($test_result, $total_cpu, $disk_space); |
87 | 90 | } |
88 | 91 | |
92 | +/** |
|
93 | + * @param string $cmd_file |
|
94 | + */ |
|
89 | 95 | function get_total_steps($cmd_file) { |
90 | 96 | $fd = fopen($cmd_file,"r"); |
91 | 97 | if (!$fd) { |
@@ -116,6 +122,9 @@ discard block |
||
116 | 122 | return $total_steps; |
117 | 123 | } |
118 | 124 | |
125 | +/** |
|
126 | + * @param string $filename |
|
127 | + */ |
|
119 | 128 | function calc_step_cpu($filename) { |
120 | 129 | $fd = fopen("$filename", "r"); |
121 | 130 | $start_line = "Step CPU "; |
@@ -169,6 +178,11 @@ discard block |
||
169 | 178 | return array($avg_cpu,$test_steps); |
170 | 179 | } |
171 | 180 | |
181 | +/** |
|
182 | + * @param string $lammps_script |
|
183 | + * @param string $structure_file |
|
184 | + * @param string $cmd_file |
|
185 | + */ |
|
172 | 186 | function calc_est_size($lammps_script, $structure_file, $cmd_file,$test_steps){ |
173 | 187 | $dump_types = 0; |
174 | 188 | $fd = fopen($lammps_script,"r"); |
@@ -280,6 +294,11 @@ discard block |
||
280 | 294 | |
281 | 295 | // verify that an input file exists in sandbox, and return its physical path |
282 | 296 | // |
297 | +/** |
|
298 | + * @param string $name |
|
299 | + * |
|
300 | + * @return string |
|
301 | + */ |
|
283 | 302 | function get_file_path($user, $name) { |
284 | 303 | $fname = get_str($name); |
285 | 304 | |
@@ -308,6 +327,10 @@ discard block |
||
308 | 327 | // |
309 | 328 | // Note: these are both extremely optimistic estimates |
310 | 329 | // |
330 | +/** |
|
331 | + * @param integer $njobs |
|
332 | + * @param double $flops_per_job |
|
333 | + */ |
|
311 | 334 | function estimated_makespan($njobs, $flops_per_job) { |
312 | 335 | $nhosts = BoincHost::count("expavg_credit > 1"); |
313 | 336 | if ($nhosts < 10) { |
@@ -416,6 +439,9 @@ discard block |
||
416 | 439 | page_tail(); |
417 | 440 | } |
418 | 441 | |
442 | +/** |
|
443 | + * @param integer $i |
|
444 | + */ |
|
419 | 445 | function submit_job($app, $batch_id, $info, $cmdline, $i) { |
420 | 446 | $client_disk=$info->rsc_disk_bound*2; |
421 | 447 | if($client_disk<500000000) $client_disk=500000000; |
@@ -315,6 +315,11 @@ discard block |
||
315 | 315 | /** |
316 | 316 | * Helper function used to scan for <meta>/<link> tags and extract information |
317 | 317 | * from them |
318 | + * @param string $tag |
|
319 | + * @param string $attrName |
|
320 | + * @param string $attrValue |
|
321 | + * @param string $valueName |
|
322 | + * @return string |
|
318 | 323 | */ |
319 | 324 | protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName) |
320 | 325 | { |
@@ -531,6 +536,9 @@ discard block |
||
531 | 536 | return $params; |
532 | 537 | } |
533 | 538 | |
539 | + /** |
|
540 | + * @param boolean $immediate |
|
541 | + */ |
|
534 | 542 | protected function authUrl_v1($immediate) |
535 | 543 | { |
536 | 544 | $returnUrl = $this->returnUrl; |
@@ -552,6 +560,9 @@ discard block |
||
552 | 560 | , array('query' => http_build_query($params, '', '&'))); |
553 | 561 | } |
554 | 562 | |
563 | + /** |
|
564 | + * @param boolean $immediate |
|
565 | + */ |
|
555 | 566 | protected function authUrl_v2($immediate) |
556 | 567 | { |
557 | 568 | $params = array( |
@@ -587,7 +598,6 @@ discard block |
||
587 | 598 | /** |
588 | 599 | * Returns authentication url. Usually, you want to redirect your user to it. |
589 | 600 | * @return String The authentication url. |
590 | - * @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1. |
|
591 | 601 | * @throws ErrorException |
592 | 602 | */ |
593 | 603 | function authUrl($immediate = false) |
@@ -88,17 +88,26 @@ discard block |
||
88 | 88 | "; |
89 | 89 | } |
90 | 90 | |
91 | +/** |
|
92 | + * @param string $name |
|
93 | + */ |
|
91 | 94 | function item_xml($name, $val) { |
92 | 95 | if (!$val) $val = 0; |
93 | 96 | echo " <$name>$val</$name>\n"; |
94 | 97 | } |
95 | 98 | |
99 | +/** |
|
100 | + * @param string $name |
|
101 | + */ |
|
96 | 102 | function item_html($name, $val) { |
97 | 103 | $name = tra($name); |
98 | 104 | echo "<tr><td>$name</td><td>$val</td></tr>\n"; |
99 | 105 | //echo "<tr><td align=right>$name</td><td align=right>$val</td></tr>\n"; |
100 | 106 | } |
101 | 107 | |
108 | +/** |
|
109 | + * @param stdClass $x |
|
110 | + */ |
|
102 | 111 | function show_status_html($x) { |
103 | 112 | page_head(tra("Project status")); |
104 | 113 | $j = $x->jobs; |
@@ -190,6 +199,9 @@ discard block |
||
190 | 199 | page_tail(); |
191 | 200 | } |
192 | 201 | |
202 | +/** |
|
203 | + * @param stdClass $x |
|
204 | + */ |
|
193 | 205 | function show_status_xml($x) { |
194 | 206 | xml_header(); |
195 | 207 | echo "<server_status>\n<daemon_status>\n"; |
@@ -239,6 +251,11 @@ discard block |
||
239 | 251 | "; |
240 | 252 | } |
241 | 253 | |
254 | +/** |
|
255 | + * @param string $cmd |
|
256 | + * @param string $pidname |
|
257 | + * @param string $host |
|
258 | + */ |
|
242 | 259 | function local_daemon_running($cmd, $pidname, $host) { |
243 | 260 | if (!$pidname) { |
244 | 261 | $cmd = trim($cmd); |
@@ -25,6 +25,9 @@ |
||
25 | 25 | |
26 | 26 | check_get_args(array("mode")); |
27 | 27 | |
28 | +/** |
|
29 | + * @param string $mode |
|
30 | + */ |
|
28 | 31 | function filename($mode) { |
29 | 32 | switch ($mode) { |
30 | 33 | case 'host': return "cuda_hosts.dat"; |
@@ -37,6 +37,9 @@ discard block |
||
37 | 37 | return $n; |
38 | 38 | } |
39 | 39 | |
40 | +/** |
|
41 | + * @param integer $state |
|
42 | + */ |
|
40 | 43 | function show_all_link($batches, $state, $limit, $user, $app) { |
41 | 44 | $n = state_count($batches, $state); |
42 | 45 | if ($n > $limit) { |
@@ -269,6 +272,9 @@ discard block |
||
269 | 272 | page_tail(); |
270 | 273 | } |
271 | 274 | |
275 | +/** |
|
276 | + * @param null|integer $app_id |
|
277 | + */ |
|
272 | 278 | function check_admin_access($user, $app_id) { |
273 | 279 | $user_submit = BoincUserSubmit::lookup_userid($user->id); |
274 | 280 | if (!$user_submit) error_page("no access"); |
@@ -523,6 +529,9 @@ discard block |
||
523 | 529 | page_tail(); |
524 | 530 | } |
525 | 531 | |
532 | +/** |
|
533 | + * @param null|integer $state |
|
534 | + */ |
|
526 | 535 | function show_batches_in_state($batches, $state) { |
527 | 536 | switch ($state) { |
528 | 537 | case BATCH_STATE_IN_PROGRESS: |
@@ -30,6 +30,9 @@ discard block |
||
30 | 30 | ini_set('display_errors', true); |
31 | 31 | ini_set('display_startup_errors', true); |
32 | 32 | |
33 | +/** |
|
34 | + * @param string $name |
|
35 | + */ |
|
33 | 36 | function get_wu($name) { |
34 | 37 | $name = BoincDb::escape_string($name); |
35 | 38 | $wu = BoincWorkunit::lookup("name='$name'"); |
@@ -37,6 +40,9 @@ discard block |
||
37 | 40 | return $wu; |
38 | 41 | } |
39 | 42 | |
43 | +/** |
|
44 | + * @param string $name |
|
45 | + */ |
|
40 | 46 | function get_submit_app($name) { |
41 | 47 | $name = BoincDb::escape_string($name); |
42 | 48 | $app = BoincApp::lookup("name='$name'"); |
@@ -76,6 +82,9 @@ discard block |
||
76 | 82 | return $y; |
77 | 83 | } |
78 | 84 | |
85 | +/** |
|
86 | + * @param SimpleXMLElement|null $template |
|
87 | + */ |
|
79 | 88 | function est_elapsed_time($r, $template) { |
80 | 89 | // crude estimate: batch FLOPs / project FLOPS |
81 | 90 | // |
@@ -122,6 +131,9 @@ discard block |
||
122 | 131 | "; |
123 | 132 | } |
124 | 133 | |
134 | +/** |
|
135 | + * @param SimpleXMLElement $template |
|
136 | + */ |
|
125 | 137 | function validate_batch($jobs, $template) { |
126 | 138 | $i = 0; |
127 | 139 | $n = count($template->file_info); |
@@ -191,6 +203,10 @@ discard block |
||
191 | 203 | |
192 | 204 | // submit a list of jobs with a single create_work command. |
193 | 205 | // |
206 | +/** |
|
207 | + * @param SimpleXMLElement|null $template |
|
208 | + * @param double $priority |
|
209 | + */ |
|
194 | 210 | function submit_jobs( |
195 | 211 | $jobs, $template, $app, $batch_id, $priority, |
196 | 212 | $result_template_file, // batch-level; can also specify per job |
@@ -267,6 +283,9 @@ discard block |
||
267 | 283 | // Check whether the template is already in our map. |
268 | 284 | // If not, write it to a temp file. |
269 | 285 | // |
286 | +/** |
|
287 | + * @param stdClass $job |
|
288 | + */ |
|
270 | 289 | function make_wu_template($job) { |
271 | 290 | global $wu_templates; |
272 | 291 | if (!array_key_exists($job->wu_template, $wu_templates)) { |
@@ -283,6 +302,9 @@ discard block |
||
283 | 302 | // A little different because these have to exist for life of job. |
284 | 303 | // Store them in templates/tmp/, with content-based filenames |
285 | 304 | // |
305 | +/** |
|
306 | + * @param stdClass $job |
|
307 | + */ |
|
286 | 308 | function make_result_template($job) { |
287 | 309 | global $result_templates; |
288 | 310 | if (!array_key_exists($job->result_template, $result_templates)) { |
@@ -468,6 +490,9 @@ discard block |
||
468 | 490 | "; |
469 | 491 | } |
470 | 492 | |
493 | +/** |
|
494 | + * @param integer $get_cpu_time |
|
495 | + */ |
|
471 | 496 | function print_batch_params($batch, $get_cpu_time) { |
472 | 497 | $app = BoincApp::lookup_id($batch->app_id); |
473 | 498 | if (!$app) $app->name = "none"; |
@@ -57,6 +57,9 @@ |
||
57 | 57 | edit_form($user, $team, $forum, true); |
58 | 58 | } |
59 | 59 | |
60 | +/** |
|
61 | + * @param boolean $first |
|
62 | + */ |
|
60 | 63 | function edit_form($user, $team, $forum, $first) { |
61 | 64 | page_head(tra("Team Message Board")); |
62 | 65 | echo " |
@@ -30,6 +30,9 @@ |
||
30 | 30 | // list entries are of the form id => team, |
31 | 31 | // where team includes a field "refcnt". |
32 | 32 | // |
33 | +/** |
|
34 | + * @param integer $weight |
|
35 | + */ |
|
33 | 36 | function merge_lists($list1, &$list2, $weight) { |
34 | 37 | foreach($list1 as $team) { |
35 | 38 | $id = $team->id; |
@@ -106,6 +106,9 @@ discard block |
||
106 | 106 | return secure_url_base(); |
107 | 107 | } |
108 | 108 | |
109 | +/** |
|
110 | + * @param string $name |
|
111 | + */ |
|
109 | 112 | function send_cookie($name, $value, $permanent, $ops=false) { |
110 | 113 | global $master_url; |
111 | 114 | |
@@ -188,6 +191,9 @@ discard block |
||
188 | 191 | // To do so, define page_head() in the project include file. |
189 | 192 | // |
190 | 193 | if (!function_exists("page_head")){ |
194 | +/** |
|
195 | + * @param string $body_attrs |
|
196 | + */ |
|
191 | 197 | function page_head( |
192 | 198 | $title, |
193 | 199 | // page title. Put in <title>, used as title for browser tab. |
@@ -455,6 +461,9 @@ discard block |
||
455 | 461 | "; |
456 | 462 | } |
457 | 463 | |
464 | +/** |
|
465 | + * @param string $x |
|
466 | + */ |
|
458 | 467 | function row2_init($x, $y, $lwidth='40%') { |
459 | 468 | echo '<tr> |
460 | 469 | <td class="text-right " width="'.$lwidth.'" style="padding-right: 20px;">'.$x.'</td> |
@@ -466,6 +475,9 @@ discard block |
||
466 | 475 | echo "<tr><td>$x</td><td>$y</td></tr>\n"; |
467 | 476 | } |
468 | 477 | |
478 | +/** |
|
479 | + * @param string $string |
|
480 | + */ |
|
469 | 481 | function rowify($string) { |
470 | 482 | echo "<tr><td>$string</td></tr>"; |
471 | 483 | } |
@@ -491,6 +503,9 @@ discard block |
||
491 | 503 | echo "</tr>\n"; |
492 | 504 | } |
493 | 505 | |
506 | +/** |
|
507 | + * @param string $x |
|
508 | + */ |
|
494 | 509 | function row_heading($x) { |
495 | 510 | echo '<tr><th class="bg-primary" colspan=99>'.$x.'</th></tr> |
496 | 511 | '; |
@@ -555,6 +570,11 @@ discard block |
||
555 | 570 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
556 | 571 | // is cut short. |
557 | 572 | |
573 | +/** |
|
574 | + * @param string $sentence |
|
575 | + * @param string $delimiter |
|
576 | + * @param integer $max_chars |
|
577 | + */ |
|
558 | 578 | function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
559 | 579 | $words = explode($delimiter, $sentence); |
560 | 580 | $total_chars = 0; |
@@ -605,6 +625,9 @@ discard block |
||
605 | 625 | ob_implicit_flush(0); |
606 | 626 | } |
607 | 627 | |
628 | +/** |
|
629 | + * @param string $filename |
|
630 | + */ |
|
608 | 631 | function close_output_buffer($filename) { |
609 | 632 | $fh = fopen($filename, "w"); |
610 | 633 | $page = ob_get_contents(); |
@@ -673,6 +696,9 @@ discard block |
||
673 | 696 | |
674 | 697 | // returns null if the arg is optional and missing |
675 | 698 | // |
699 | +/** |
|
700 | + * @param string $name |
|
701 | + */ |
|
676 | 702 | function post_int($name, $optional=false) { |
677 | 703 | $x = post_num($name, $optional); |
678 | 704 | if (is_null($x)) return null; |
@@ -772,6 +798,9 @@ discard block |
||
772 | 798 | |
773 | 799 | // Generate a "select" element from an array of values |
774 | 800 | // |
801 | +/** |
|
802 | + * @param string $name |
|
803 | + */ |
|
775 | 804 | function select_from_array($name, $array, $selection=null, $width=240) { |
776 | 805 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
777 | 806 | |
@@ -833,6 +862,9 @@ discard block |
||
833 | 862 | "; |
834 | 863 | } |
835 | 864 | |
865 | +/** |
|
866 | + * @param string $text |
|
867 | + */ |
|
836 | 868 | function button_text($url, $text, $desc=null, $class="btn btn-default") { |
837 | 869 | if (!$desc) $desc = $text; |
838 | 870 | return "<a href=\"".$url."\" title=\"$desc\" class=\"".$class."\">".$text."</a> |
@@ -854,6 +886,12 @@ discard block |
||
854 | 886 | |
855 | 887 | // used for showing icons |
856 | 888 | // |
889 | +/** |
|
890 | + * @param string $src |
|
891 | + * @param string $title |
|
892 | + * @param string $alt |
|
893 | + * @param string $height |
|
894 | + */ |
|
857 | 895 | function show_image($src, $title, $alt, $height=null) { |
858 | 896 | $h = ""; |
859 | 897 | if ($height) { |
@@ -969,6 +1007,9 @@ discard block |
||
969 | 1007 | } |
970 | 1008 | } |
971 | 1009 | |
1010 | +/** |
|
1011 | + * @param integer $f |
|
1012 | + */ |
|
972 | 1013 | function flops_to_credit($f) { |
973 | 1014 | return $f*(200/86400e9); |
974 | 1015 | } |
@@ -1004,6 +1045,9 @@ discard block |
||
1004 | 1045 | } |
1005 | 1046 | } |
1006 | 1047 | |
1048 | +/** |
|
1049 | + * @param integer $height |
|
1050 | + */ |
|
1007 | 1051 | function badges_string($is_user, $item, $height) { |
1008 | 1052 | if (DISABLE_BADGES) return null; |
1009 | 1053 | if ($is_user) { |
@@ -1020,6 +1064,9 @@ discard block |
||
1020 | 1064 | return $x; |
1021 | 1065 | } |
1022 | 1066 | |
1067 | +/** |
|
1068 | + * @param boolean $is_user |
|
1069 | + */ |
|
1023 | 1070 | function show_badges_row($is_user, $item) { |
1024 | 1071 | if (BADGE_HEIGHT_LARGE == 0) return; |
1025 | 1072 | $x = badges_string($is_user, $item, BADGE_HEIGHT_LARGE); |
@@ -1064,6 +1111,11 @@ discard block |
||
1064 | 1111 | // return HTML for a textarea with chars-remaining counter. |
1065 | 1112 | // Call text_counter_script() before using this. |
1066 | 1113 | // |
1114 | +/** |
|
1115 | + * @param string $name |
|
1116 | + * @param integer $maxlen |
|
1117 | + * @param string $text |
|
1118 | + */ |
|
1067 | 1119 | function textarea_with_counter($name, $maxlen, $text) { |
1068 | 1120 | $rem_name = $name."_remaining"; |
1069 | 1121 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |