Completed
Push — master ( ccde79...76a055 )
by Kevin
43s
created
html/user/create_profile.php 2 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -31,6 +31,10 @@  discard block
 block discarded – undo
31 31
 // If $selection is provided, and if it matches one of the entries in the file,
32 32
 // it will be selected by default.
33 33
 //
34
+/**
35
+ * @param string $name
36
+ * @param string $filename
37
+ */
34 38
 function show_combo_box($name, $filename, $selection=null) {
35 39
     echo "<select name=\"$name\" class=\"form-control\">\n";
36 40
 
@@ -185,6 +189,9 @@  discard block
 block discarded – undo
185 189
     show_language_selection($profile);
186 190
 }
187 191
 
192
+/**
193
+ * @param string $name
194
+ */
188 195
 function show_textarea($name, $text) {
189 196
     rowify("<textarea name=\"$name\" class=\"form-control\" rows=\"10\">" . $text . "</textarea>");
190 197
 }
@@ -311,6 +318,9 @@  discard block
 block discarded – undo
311 318
     page_tail();
312 319
 }
313 320
 
321
+/**
322
+ * @param string $warning
323
+ */
314 324
 function show_profile_form($profile, $warning=null) {
315 325
     if ($profile) {
316 326
         page_head(tra("Edit your profile"), null, null, null, boinc_recaptcha_get_head_extra());
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 // If $selection is provided, and if it matches one of the entries in the file,
32 32
 // it will be selected by default.
33 33
 //
34
-function show_combo_box($name, $filename, $selection=null) {
34
+function show_combo_box($name, $filename, $selection = null) {
35 35
     echo "<select name=\"$name\" class=\"form-control\">\n";
36 36
 
37 37
     $file = fopen($filename, "r");
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 <tr><td colspan=2>
63 63
 <table border=0 cellpadding=5
64 64
 <tr>
65
-<td valign=top><a href=\"" . IMAGE_URL . $profile->userid . '.jpg' . "\"><img src=\"" . IMAGE_URL . $profile->userid . '_sm.jpg' . "\"></a>
65
+<td valign=top><a href=\"" . IMAGE_URL.$profile->userid.'.jpg'."\"><img src=\"".IMAGE_URL.$profile->userid.'_sm.jpg'."\"></a>
66 66
 </td>
67
-<td valign=top>" .tra("%1 Your profile picture is shown to the left.",  $warning) ."
67
+<td valign=top>" .tra("%1 Your profile picture is shown to the left.", $warning)."
68 68
 <p>".
69
-tra("To replace it, click the \"Browse\" button and select a JPEG or PNG file (%1 or less).", "50KB") ."<br />
69
+tra("To replace it, click the \"Browse\" button and select a JPEG or PNG file (%1 or less).", "50KB")."<br />
70 70
 <input name=picture type=file><br>
71 71
 <p>".
72
-tra("To remove it from your profile, check this box:") . "
72
+tra("To remove it from your profile, check this box:")."
73 73
 <input type=checkbox name=delete_pic>
74 74
 <p>
75 75
 </td></tr>";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         end_table();
78 78
         echo "</td></tr>";
79 79
     } else {
80
-        rowify(tra("If you would like include a picture with your profile, click the \"Browse\" button and select a JPEG or PNG file. Please select images of %1 or less.", "50KB") . "
80
+        rowify(tra("If you would like include a picture with your profile, click the \"Browse\" button and select a JPEG or PNG file. Please select images of %1 or less.", "50KB")."
81 81
 <p>
82 82
 <input name=picture type=file>
83 83
         ");
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     row1(tra("Language"));
93 93
     echo "<tr><td>
94 94
         <p>" .
95
-        tra("Select the language in which your profile is written:") . "
95
+        tra("Select the language in which your profile is written:")."
96 96
         <p>
97 97
     ";
98 98
     if (isset($profile->language)) {
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     if ($publickey) {
111 111
         table_row(boinc_recaptcha_get_html($publickey));
112 112
     }
113
-    table_row("<p><input class=\"btn btn-success\" type=\"submit\" value=\"".tra("Create/edit profile") ."\" name=\"submit\">");
113
+    table_row("<p><input class=\"btn btn-success\" type=\"submit\" value=\"".tra("Create/edit profile")."\" name=\"submit\">");
114 114
 }
115 115
 
116 116
 // Returns an array containing:
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
     // Determine if the filetype uploaded is supported.
126 126
     // TODO: Change these to constants.
127
-    switch($size[2]) {
127
+    switch ($size[2]) {
128 128
     case '2':    // JPEG
129 129
         $image = imageCreateFromJPEG($fileName);
130 130
         break;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
 function show_description() {
163 163
     echo "
164
-        <p>" .tra("Your %1 profile %2 lets you share your opinions and background with the %3 community.", "<b>", "</b>", PROJECT) . "
164
+        <p>" .tra("Your %1 profile %2 lets you share your opinions and background with the %3 community.", "<b>", "</b>", PROJECT)."
165 165
         <p>
166 166
     ";
167 167
 }
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
     row1(show_profile_heading1());
180 180
     rowify(show_profile_question1().bbcode_info());
181 181
     show_textarea("response1", $response1);
182
-    row1( show_profile_heading2());
183
-    rowify( show_profile_question2().bbcode_info());
182
+    row1(show_profile_heading2());
183
+    rowify(show_profile_question2().bbcode_info());
184 184
     show_textarea("response2", $response2);
185 185
     show_language_selection($profile);
186 186
 }
187 187
 
188 188
 function show_textarea($name, $text) {
189
-    rowify("<textarea name=\"$name\" class=\"form-control\" rows=\"10\">" . $text . "</textarea>");
189
+    rowify("<textarea name=\"$name\" class=\"form-control\" rows=\"10\">".$text."</textarea>");
190 190
 }
191 191
 
192 192
 // $profile is null if user doesn't already have a profile.
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
         $delete_pic = "off";
234 234
     }
235 235
 
236
-    if (strlen($response1)==0 &&
237
-        strlen($response2)==0 &&
236
+    if (strlen($response1) == 0 &&
237
+        strlen($response2) == 0 &&
238 238
         $delete_pic != "on" &&
239 239
         !is_uploaded_file($_FILES['picture']['tmp_name'])
240 240
     ) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         $profile->verification = 0;
249 249
     }
250 250
 
251
-    $profile ? $has_picture = $profile->has_picture: $has_picture = false;
251
+    $profile ? $has_picture = $profile->has_picture : $has_picture = false;
252 252
 
253 253
     if (is_uploaded_file($_FILES['picture']['tmp_name'])) {
254 254
         $has_picture = true;
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
 
264 264
         // Write the original image file to disk.
265 265
         // TODO: define a constant for image quality.
266
-        ImageJPEG($images[0], IMAGE_PATH . $user->id . '.jpg');
267
-        ImageJPEG($images[1], IMAGE_PATH . $user->id . '_sm.jpg');
266
+        ImageJPEG($images[0], IMAGE_PATH.$user->id.'.jpg');
267
+        ImageJPEG($images[1], IMAGE_PATH.$user->id.'_sm.jpg');
268 268
     }
269 269
     $response1 = sanitize_html($response1);
270 270
     $response2 = sanitize_html($response2);
271 271
 
272
-    $has_picture = $has_picture?1:0;
272
+    $has_picture = $has_picture ? 1 : 0;
273 273
     if ($profile) {
274 274
         $query = " response1 = '".BoincDb::escape_string($response1)."',"
275 275
             ." response2 = '".BoincDb::escape_string($response2)."',"
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
     page_tail();
312 312
 }
313 313
 
314
-function show_profile_form($profile, $warning=null) {
314
+function show_profile_form($profile, $warning = null) {
315 315
     if ($profile) {
316 316
         page_head(tra("Edit your profile"), null, null, null, boinc_recaptcha_get_head_extra());
317 317
     } else {
Please login to merge, or discard this patch.
html/user/forum_reply.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -178,6 +178,9 @@
 block discarded – undo
178 178
     row2($x1, $x2, false, "20%");
179 179
 }
180 180
 
181
+/**
182
+ * @param string $text
183
+ */
181 184
 function quote_text($text) {
182 185
     $text = "[quote]" . $text . "[/quote]";
183 186
     return $text;
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     $parent_post_id = 0;
51 51
 }
52 52
 
53
-if ($filter != "false"){
53
+if ($filter != "false") {
54 54
     $filter = true;
55 55
 } else {
56 56
     $filter = false;
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 }
66 66
 
67 67
 $warning = null;
68
-if ($content && (!$preview)){
69
-    if (post_str('add_signature',true)=="add_it"){
68
+if ($content && (!$preview)) {
69
+    if (post_str('add_signature',true)=="add_it") {
70 70
         $add_signature=true;    // set a flag and concatenate later
71
-    }  else {
71
+    } else {
72 72
         $add_signature=false;
73 73
     }
74 74
     check_tokens($logged_in_user->authenticator);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     $parent_post_id = 0;
51 51
 }
52 52
 
53
-if ($filter != "false"){
53
+if ($filter != "false") {
54 54
     $filter = true;
55 55
 } else {
56 56
     $filter = false;
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 }
66 66
 
67 67
 $warning = null;
68
-if ($content && (!$preview)){
69
-    if (post_str('add_signature',true)=="add_it"){
70
-        $add_signature=true;    // set a flag and concatenate later
71
-    }  else {
72
-        $add_signature=false;
68
+if ($content && (!$preview)) {
69
+    if (post_str('add_signature', true) == "add_it") {
70
+        $add_signature = true; // set a flag and concatenate later
71
+    } else {
72
+        $add_signature = false;
73 73
     }
74 74
     check_tokens($logged_in_user->authenticator);
75 75
     if (!akismet_check($logged_in_user, $content)) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     }
89 89
 }
90 90
 
91
-page_head(tra("Post to thread"),'','','', $bbcode_js);
91
+page_head(tra("Post to thread"), '', '', '', $bbcode_js);
92 92
 
93 93
 show_forum_header($logged_in_user);
94 94
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     $x1 = tra("Message:").bbcode_info().post_warning();
143 143
     $x2 = "";
144 144
     if ($parent_post) {
145
-        $x2 .=" ".tra("reply to %1 Message ID %2:", "<a href=#".$parent_post->id.">", " ".$parent_post->id."</a>");
145
+        $x2 .= " ".tra("reply to %1 Message ID %2:", "<a href=#".$parent_post->id.">", " ".$parent_post->id."</a>");
146 146
     }
147 147
     $x2 .= "<form action=forum_reply.php?thread=".$thread->id;
148 148
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     $x2 .= " method=\"post\" name=\"post\" onsubmit=\"return checkForm(this)\">\n";
154 154
     $x2 .= form_tokens($logged_in_user->authenticator);
155 155
     $x2 .= start_table_str().$bbcode_html.end_table_str()."<textarea class=\"form-control\" name=\"content\" rows=\"18\">";
156
-    $no_quote = get_int("no_quote", true)==1;
156
+    $no_quote = get_int("no_quote", true) == 1;
157 157
     if ($preview) {
158 158
         $x2 .= htmlspecialchars($content);
159 159
     } else if (!$no_quote) {
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
         }
163 163
     }
164 164
     if (!$logged_in_user->prefs->no_signature_by_default) {
165
-        $enable_signature="checked=\"true\"";
165
+        $enable_signature = "checked=\"true\"";
166 166
     } else {
167
-        $enable_signature="";
167
+        $enable_signature = "";
168 168
     }
169 169
     $x2 .= "</textarea><p> </p>
170 170
         <input class=\"btn btn-primary btn-sm \" type=\"submit\" name=\"preview\" value=\"".tra("Preview")."\">
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 }
180 180
 
181 181
 function quote_text($text) {
182
-    $text = "[quote]" . $text . "[/quote]";
182
+    $text = "[quote]".$text."[/quote]";
183 183
     return $text;
184 184
 }
185 185
 
186
-$cvs_version_tracker[]="\$Id$";
186
+$cvs_version_tracker[] = "\$Id$";
187 187
 ?>
Please login to merge, or discard this patch.
html/user/gpu_list.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -29,6 +29,9 @@  discard block
 block discarded – undo
29 29
 // take a host.serialnum field (which may encode several GPUs)
30 30
 // and extract the model name for the given vendor
31 31
 //
32
+/**
33
+ * @param string $vendor
34
+ */
32 35
 function get_gpu_model($x, $vendor) {
33 36
     $descs = explode("]", $x);
34 37
     array_pop($descs);
@@ -60,6 +63,10 @@  discard block
 block discarded – undo
60 63
 // $x->linux
61 64
 // $x->mac
62 65
 //
66
+/**
67
+ * @param string $vendor
68
+ * @param string $alt_vendor
69
+ */
63 70
 function get_gpu_list($vendor, $alt_vendor=null) {
64 71
     $clause = "plan_class like '%$vendor%'";
65 72
     if ($alt_vendor) {
@@ -144,6 +151,9 @@  discard block
 block discarded – undo
144 151
     return $x1->avg_time > $x2->avg_time;
145 152
 }
146 153
 
154
+/**
155
+ * @param string $name
156
+ */
147 157
 function show_list($models, $name) {
148 158
     echo "<td><h2>$name</h2>\n";
149 159
     if (!count($models)) {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 // $x->linux
61 61
 // $x->mac
62 62
 //
63
-function get_gpu_list($vendor, $alt_vendor=null) {
63
+function get_gpu_list($vendor, $alt_vendor = null) {
64 64
     $clause = "plan_class like '%$vendor%'";
65 65
     if ($alt_vendor) {
66 66
         $clause .= " or plan_class like '%$alt_vendor%'";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     }
74 74
 
75 75
     $av_ids = "";
76
-    foreach($avs as $av) {
76
+    foreach ($avs as $av) {
77 77
         $av_ids .= "$av->id, ";
78 78
     }
79 79
     if ($vendor == "cuda") {
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
         echo tra("No GPU tasks reported");
177 177
         return;
178 178
     }
179
-    $have_win = count($x->win)>0;
180
-    $have_mac = count($x->mac)>0;
181
-    $have_linux = count($x->linux)>0;
179
+    $have_win = count($x->win) > 0;
180
+    $have_mac = count($x->mac) > 0;
181
+    $have_linux = count($x->linux) > 0;
182 182
     $n = 0;
183 183
     if ($have_win) $n++;
184 184
     if ($have_mac) $n++;
185 185
     if ($have_linux) $n++;
186
-    $show_total = $n>1;
186
+    $show_total = $n > 1;
187 187
     start_table();
188 188
     echo "<tr>";
189 189
     if ($show_total) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@
 block discarded – undo
196 196
 }
197 197
 
198 198
 $d = get_cached_data(86400);
199
-$data = FALSE;
199
+$data = false;
200 200
 if ($d) {
201 201
     $data = unserialize($d);
202 202
 }
Please login to merge, or discard this patch.
html/user/host_app_versions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -18,6 +18,9 @@
 block discarded – undo
18 18
 
19 19
 require_once("../inc/util.inc");
20 20
 
21
+/**
22
+ * @param integer $t
23
+ */
21 24
 function rsc_name($t) {
22 25
     switch ($t) {
23 26
     case 2: return tra("CPU");
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         if (!$show_dep && $app->deprecated) {
41 41
             return null;
42 42
         }
43
-        $rsc_type = $gavid % 1000000;
43
+        $rsc_type = $gavid%1000000;
44 44
         $r = rsc_name($rsc_type);
45 45
         return "$app->user_friendly_name (".tra("anonymous platform").", $r)";
46 46
     } else {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         }
61 61
         $platform = BoincPlatform::lookup_id($av->platformid);
62 62
         if (!$platform) return tra("Missing platform");
63
-        $pc = (strlen($av->plan_class))?"($av->plan_class)":"";
63
+        $pc = (strlen($av->plan_class)) ? "($av->plan_class)" : "";
64 64
         $v = number_format($av->version_num/100, 2);
65 65
         return "$app->user_friendly_name $v $platform->name $pc";
66 66
     }
Please login to merge, or discard this patch.
html/user/host_edit_action.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -20,6 +20,9 @@
 block discarded – undo
20 20
 require_once("../inc/util.inc");
21 21
 require_once("../inc/host.inc");
22 22
 
23
+/**
24
+ * @param string $msg
25
+ */
23 26
 function fail($msg) {
24 27
     echo "Error: $msg";
25 28
     page_tail();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 $nhosts = get_int("nhosts");
42 42
 $hostid = get_int("id_0");
43 43
 $latest_host = get_host($hostid, $user);
44
-for ($i=1; $i<$nhosts; $i++) {
44
+for ($i = 1; $i < $nhosts; $i++) {
45 45
     $var = "id_$i";
46 46
     $hostid = get_int($var, true);
47 47
     if (!$hostid) continue;
Please login to merge, or discard this patch.
html/user/lammps.php 5 patches
Doc Comments   +26 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     $ppid=$pstatus['pid'];
36 36
     $ret=`ps -o pid --no-heading --ppid $ppid`;
37 37
     //echo "parent pid is $ppid\nterninate it\n";
38
-     proc_terminate($p);
38
+        proc_terminate($p);
39 39
     // echo "child process is $ret\n";
40 40
     $pids=preg_split('/\s+/',$ret);
41 41
     foreach($pids as $pid){
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
     while (1) {
62 62
         $ctime=time();
63 63
         if($ctime-$stime >=2 and ! file_exists("log.1")){
64
-           if($GLOBALS["debug"]) echo "time out "."<br>";
65
-           terminate_job($p);
66
-           break;
64
+            if($GLOBALS["debug"]) echo "time out "."<br>";
65
+            terminate_job($p);
66
+            break;
67 67
         } 
68 68
         if (file_exists("log.1")) {
69 69
             list($avg_cpu, $test_steps) = calc_step_cpu("log.1");
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     }
113 113
     fclose($fd);
114 114
     //$total_steps = $loopno*$looprun;
115
-     if($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>";
115
+        if($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>";
116 116
     return $total_steps;
117 117
 }
118 118
 
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
         $cpu = (float)$arr[2];
148 148
         //echo "step=".$step." cpu=".$cpu."\n";
149 149
         if ($cpu==0) {
150
-           $count=0;
151
-           $start_step = $step;
150
+            $count=0;
151
+            $start_step = $step;
152 152
         } else {
153 153
             $count+=1;
154 154
             if($GLOBALS["debug"])echo "step=".$step." cpu=".$cpu."count=".$count."<br>";
155
-           if($count >= 10) {
155
+            if($count >= 10) {
156 156
                 $end_step = $step;
157 157
                 $steps = $end_step-$start_step;
158 158
                 $avg_cpu = $cpu/$steps;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         
184 184
         if(preg_match("/^\s*dump\s+(\d)\s+/", $line,$matches))
185 185
         {        
186
-             if($GLOBALS["debug"]){print "matches=";print_r($matches);}
186
+                if($GLOBALS["debug"]){print "matches=";print_r($matches);}
187 187
 
188 188
             $dump_types=(int)$matches[1];
189 189
             break;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         echo "can not open file $cmd_file\n";
199 199
         exit(-1);
200 200
     }
201
-     if($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>";
201
+        if($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>";
202 202
    
203 203
     $loopno=1;
204 204
     $looprun=1;
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
     }
217 217
     fclose($fd);
218 218
     if($GLOBALS["debug"]){
219
-         print "max loopno(number of loops to run)=".$loopno."<br>";
220
-         print "max looprun(steps for each loop)=".$looprun."<br>";
219
+            print "max loopno(number of loops to run)=".$loopno."<br>";
220
+            print "max looprun(steps for each loop)=".$looprun."<br>";
221 221
     }
222 222
     //$est_size = $loopno*$structure_file_size*0.8*$dump_types;
223 223
     $test_log_size = filesize("log.1");
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             <br>Please refer to the following Error Message:<br><p>
369 369
         ";
370 370
         foreach($err_msgs as $line){
371
-             $err=$err.$line."<br>";
371
+                $err=$err.$line."<br>";
372 372
         }
373 373
         $err=$err." <p>
374 374
             <a href=sandbox.php><strong> File_Sandbox </strong></a>
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     //
394 394
     $njobs = count(file($cmdline_file_path));
395 395
     $secs_est = estimated_makespan($njobs, $info->rsc_fpops_est);
396
-     if($GLOBALS["debug"])echo "secs_est is $secs_est\n";
396
+        if($GLOBALS["debug"])echo "secs_est is $secs_est\n";
397 397
     //assume the server's flops is 1.5G and the average client's flops is 1G
398 398
     $hrs_est = number_format($secs_est*1.5/60, 2);
399 399
     //$hrs_est = number_format($secs_est, 2);
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 require_once("../inc/util.inc");
19 19
 require_once("../inc/submit_db.inc");
20 20
 require_once("../inc/sandbox.inc");
21
-$debug=0;
21
+$debug = 0;
22 22
 
23 23
 // test a LAMMPS job
24 24
 //
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
31 31
 // output: success flag, CPU time per step, est. disk usage per job
32 32
 //
33 33
 function terminate_job($p) {
34
-    $pstatus=proc_get_status($p);
35
-    $ppid=$pstatus['pid'];
36
-    $ret=`ps -o pid --no-heading --ppid $ppid`;
34
+    $pstatus = proc_get_status($p);
35
+    $ppid = $pstatus['pid'];
36
+    $ret = `ps -o pid --no-heading --ppid $ppid`;
37 37
     //echo "parent pid is $ppid\nterninate it\n";
38 38
      proc_terminate($p);
39 39
     // echo "child process is $ret\n";
40
-    $pids=preg_split('/\s+/',$ret);
41
-    foreach($pids as $pid){
42
-        if(is_numeric($pid)){
43
-            if($GLOBALS["debug"])echo "killing child process $pid\n";
44
-            posix_kill($pid,9);
40
+    $pids = preg_split('/\s+/', $ret);
41
+    foreach ($pids as $pid) {
42
+        if (is_numeric($pid)) {
43
+            if ($GLOBALS["debug"])echo "killing child process $pid\n";
44
+            posix_kill($pid, 9);
45 45
         }
46 46
     }
47 47
 }
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
     $descs = array();
53 53
     $pipes = array();
54 54
     $options = file("cmd_variables");
55
-    $options[0] = chop($options[0],"\n");
55
+    $options[0] = chop($options[0], "\n");
56 56
     $cmd = "../lmp_linux ".$options[0]."&>output";
57 57
     if ($GLOBALS["debug"]) echo $cmd."<br>";
58 58
     system("unzip pot_files >/dev/null");
59 59
     $stime = time();
60 60
     $p = proc_open("$cmd", $descs, $pipes);
61 61
     while (1) {
62
-        $ctime=time();
63
-        if($ctime-$stime >=2 and ! file_exists("log.1")){
64
-           if($GLOBALS["debug"]) echo "time out "."<br>";
62
+        $ctime = time();
63
+        if ($ctime - $stime >= 2 and !file_exists("log.1")) {
64
+           if ($GLOBALS["debug"]) echo "time out "."<br>";
65 65
            terminate_job($p);
66 66
            break;
67 67
         } 
68 68
         if (file_exists("log.1")) {
69 69
             list($avg_cpu, $test_steps) = calc_step_cpu("log.1");
70 70
             if ($avg_cpu != 0) {
71
-                if($GLOBALS["debug"])echo "avg_cpu is ".$avg_cpu."<br>";
71
+                if ($GLOBALS["debug"])echo "avg_cpu is ".$avg_cpu."<br>";
72 72
                 terminate_job($p);
73 73
                 $test_result = 1;
74 74
                 break;
@@ -87,32 +87,32 @@  discard block
 block discarded – undo
87 87
 }
88 88
 
89 89
 function get_total_steps($cmd_file) {
90
-    $fd = fopen($cmd_file,"r");
90
+    $fd = fopen($cmd_file, "r");
91 91
     if (!$fd) {
92 92
         echo "can not open file $cmd_file\n";
93 93
         exit(-1);
94 94
     }
95 95
     $this_loopno = 1;
96 96
     $this_looprun = 1;
97
-    $total_steps=1;
97
+    $total_steps = 1;
98 98
     while (!feof($fd)) {
99
-        $line = fgets($fd,4096);
99
+        $line = fgets($fd, 4096);
100 100
         if (preg_match("/loopnumber\s+\d+/", $line, $matches)
101 101
             && preg_match("/\d+/", $matches[0], $no)
102 102
         ) {
103
-            $this_loopno=$no[0];
103
+            $this_loopno = $no[0];
104 104
         }
105 105
         if (preg_match("/looprun\s+\d+/", $line, $matches)
106 106
             and preg_match("/\d+/", $matches[0], $no)
107 107
         ) {
108
-            $this_looprun=$no[0];
109
-            if($this_loopno*$this_looprun>$total_steps)$total_steps=$this_loopno*$this_looprun;
108
+            $this_looprun = $no[0];
109
+            if ($this_loopno*$this_looprun > $total_steps)$total_steps = $this_loopno*$this_looprun;
110 110
         }
111 111
 
112 112
     }
113 113
     fclose($fd);
114 114
     //$total_steps = $loopno*$looprun;
115
-     if($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>";
115
+     if ($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>";
116 116
     return $total_steps;
117 117
 }
118 118
 
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
     }
131 131
     $count = 0;
132 132
     while (!feof($fd)) {
133
-        $line = fgets($fd,4096);
134
-        if (preg_match('/^Step\s+CPU/',$line)) {
133
+        $line = fgets($fd, 4096);
134
+        if (preg_match('/^Step\s+CPU/', $line)) {
135 135
             //echo $line."\n";
136 136
             $start = 1;
137 137
             continue;
@@ -140,24 +140,24 @@  discard block
 block discarded – undo
140 140
         $arr = preg_split("/\s+/", $line);
141 141
         //print_r($arr);
142 142
 
143
-        if (count($arr) <=6 || !is_numeric($arr[1])) {
143
+        if (count($arr) <= 6 || !is_numeric($arr[1])) {
144 144
             continue;
145 145
         }
146 146
         $step = (int)$arr[1];
147 147
         $cpu = (float)$arr[2];
148 148
         //echo "step=".$step." cpu=".$cpu."\n";
149
-        if ($cpu==0) {
150
-           $count=0;
149
+        if ($cpu == 0) {
150
+           $count = 0;
151 151
            $start_step = $step;
152 152
         } else {
153
-            $count+=1;
154
-            if($GLOBALS["debug"])echo "step=".$step." cpu=".$cpu."count=".$count."<br>";
155
-           if($count >= 10) {
153
+            $count += 1;
154
+            if ($GLOBALS["debug"])echo "step=".$step." cpu=".$cpu."count=".$count."<br>";
155
+           if ($count >= 10) {
156 156
                 $end_step = $step;
157
-                $steps = $end_step-$start_step;
157
+                $steps = $end_step - $start_step;
158 158
                 $avg_cpu = $cpu/$steps;
159 159
                 #$avg_cpu = $cpu/$count;
160
-                if ($GLOBALS["debug"]){
160
+                if ($GLOBALS["debug"]) {
161 161
                     echo "test steps is ".$steps."<br>";
162 162
                     echo "avg_cpu is ".$avg_cpu."<br>";
163 163
                 }
@@ -166,56 +166,56 @@  discard block
 block discarded – undo
166 166
             }
167 167
         }
168 168
     }
169
-    return array($avg_cpu,$test_steps);
169
+    return array($avg_cpu, $test_steps);
170 170
 }
171 171
 
172
-function calc_est_size($lammps_script, $structure_file, $cmd_file,$test_steps){
172
+function calc_est_size($lammps_script, $structure_file, $cmd_file, $test_steps) {
173 173
     $dump_types = 0;
174
-    $fd = fopen($lammps_script,"r");
175
-    if (!$fd){
174
+    $fd = fopen($lammps_script, "r");
175
+    if (!$fd) {
176 176
         echo "can not open file $lammps_script\n";
177 177
         exit(-1);
178 178
     }
179
-    while (!feof($fd)){
179
+    while (!feof($fd)) {
180 180
         $line = fgets($fd, 4096);
181 181
         //if (preg_match("/^\s*dump/", $line)
182 182
         //    and preg_match_all("/dump\S+\.\w{3}/", $line, $matches, PREG_PATTERN_ORDER))
183 183
         
184
-        if(preg_match("/^\s*dump\s+(\d)\s+/", $line,$matches))
184
+        if (preg_match("/^\s*dump\s+(\d)\s+/", $line, $matches))
185 185
         {        
186
-             if($GLOBALS["debug"]){print "matches=";print_r($matches);}
186
+             if ($GLOBALS["debug"]) {print "matches="; print_r($matches); }
187 187
 
188
-            $dump_types=(int)$matches[1];
188
+            $dump_types = (int)$matches[1];
189 189
             break;
190 190
         }
191 191
     }
192 192
     fclose($fd);
193
-    if($GLOBALS["debug"])print "dump_types= ".$dump_types."<br>";
193
+    if ($GLOBALS["debug"])print "dump_types= ".$dump_types."<br>";
194 194
 
195 195
     $structure_file_size = filesize($structure_file);
196
-    $fd = fopen($cmd_file,"r");
197
-    if (!$fd){
196
+    $fd = fopen($cmd_file, "r");
197
+    if (!$fd) {
198 198
         echo "can not open file $cmd_file\n";
199 199
         exit(-1);
200 200
     }
201
-     if($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>";
201
+     if ($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>";
202 202
    
203
-    $loopno=1;
204
-    $looprun=1;
205
-    while (!feof($fd)){
206
-        $line = fgets($fd,4096);
207
-        if(preg_match("/loopnumber\s+\d+/", $line, $matches)){
208
-            if(preg_match("/\d+/", $matches[0], $no)){
203
+    $loopno = 1;
204
+    $looprun = 1;
205
+    while (!feof($fd)) {
206
+        $line = fgets($fd, 4096);
207
+        if (preg_match("/loopnumber\s+\d+/", $line, $matches)) {
208
+            if (preg_match("/\d+/", $matches[0], $no)) {
209 209
                 //$loopno=$no[0];
210
-                if($no[0]>$loopno)$loopno=$no[0];
210
+                if ($no[0] > $loopno)$loopno = $no[0];
211 211
             }
212 212
         }
213 213
         if (preg_match("/looprun\s+\d+/", $line, $matches) and preg_match("/\d+/", $matches[0], $no)) {
214
-            if($no[0]>$looprun)$looprun=$no[0];
214
+            if ($no[0] > $looprun)$looprun = $no[0];
215 215
         }
216 216
     }
217 217
     fclose($fd);
218
-    if($GLOBALS["debug"]){
218
+    if ($GLOBALS["debug"]) {
219 219
          print "max loopno(number of loops to run)=".$loopno."<br>";
220 220
          print "max looprun(steps for each loop)=".$looprun."<br>";
221 221
     }
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
     $dump_files = glob("dump1*");
227 227
     $test_dump_file = $dump_files[0];
228 228
     $test_dump_size = filesize($test_dump_file);
229
-    $dump_size1 = $test_dump_size+0.5*$test_dump_size*ceil(($looprun-$test_steps)/$test_steps);
229
+    $dump_size1 = $test_dump_size + 0.5*$test_dump_size*ceil(($looprun - $test_steps)/$test_steps);
230 230
     $dump_size = $loopno*$dump_size1*$dump_types;
231 231
     $app_fixed_size = 5e7;
232
-    $est_size = $log_size+$dump_size+$app_fixed_size;
232
+    $est_size = $log_size + $dump_size + $app_fixed_size;
233 233
     
234
-    if($GLOBALS["debug"]){
234
+    if ($GLOBALS["debug"]) {
235 235
         print "test_steps=".$test_steps."<br>";
236 236
         print "test_log_size=".$test_log_size."<br>";
237 237
         print "log_size1=".$log_size1."<br>";
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
     if ($njobs < $nhosts) {
323 323
         return $flops_per_job/$median_flops;
324 324
     } else {
325
-        $k = (int)(($njobs+$nhosts-1)/$nhosts);
325
+        $k = (int)(($njobs + $nhosts - 1)/$nhosts);
326 326
         return $k*$flops_per_job/$median_flops;
327 327
     }
328 328
 }
@@ -362,27 +362,27 @@  discard block
 block discarded – undo
362 362
     if ($GLOBALS["debug"]) {
363 363
         print "est_cpu_time is ".$est_cpu_time."<br>";
364 364
     }
365
-    if ($error==0) {
366
-        $err_msgs=file("output");
367
-        $err="Your test job <strong>failed</strong>
365
+    if ($error == 0) {
366
+        $err_msgs = file("output");
367
+        $err = "Your test job <strong>failed</strong>
368 368
             <br>Please refer to the following Error Message:<br><p>
369 369
         ";
370
-        foreach($err_msgs as $line){
371
-             $err=$err.$line."<br>";
370
+        foreach ($err_msgs as $line) {
371
+             $err = $err.$line."<br>";
372 372
         }
373
-        $err=$err." <p>
373
+        $err = $err." <p>
374 374
             <a href=sandbox.php><strong> File_Sandbox </strong></a>
375 375
         ";
376 376
         error_page($err);
377 377
     }
378 378
 
379 379
     system("rm *");
380
-    $info->rsc_fpops_est = $est_cpu_time * 1.5e9;
381
-    $info->rsc_fpops_bound = $info->rsc_fpops_est * 20;
380
+    $info->rsc_fpops_est = $est_cpu_time*1.5e9;
381
+    $info->rsc_fpops_bound = $info->rsc_fpops_est*20;
382 382
     
383
-    if ($disk==0){
384
-        $info->rsc_disk_bound=1000000;
385
-    } else{
383
+    if ($disk == 0) {
384
+        $info->rsc_disk_bound = 1000000;
385
+    } else {
386 386
         $info->rsc_disk_bound = $disk;
387 387
     }
388 388
 
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     //
394 394
     $njobs = count(file($cmdline_file_path));
395 395
     $secs_est = estimated_makespan($njobs, $info->rsc_fpops_est);
396
-     if($GLOBALS["debug"])echo "secs_est is $secs_est\n";
396
+     if ($GLOBALS["debug"])echo "secs_est is $secs_est\n";
397 397
     //assume the server's flops is 1.5G and the average client's flops is 1G
398 398
     $hrs_est = number_format($secs_est*1.5/60, 2);
399 399
     //$hrs_est = number_format($secs_est, 2);
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 }
418 418
 
419 419
 function submit_job($app, $batch_id, $info, $cmdline, $i) {
420
-    $client_disk=$info->rsc_disk_bound*2;
421
-    if($client_disk<500000000) $client_disk=500000000;
420
+    $client_disk = $info->rsc_disk_bound*2;
421
+    if ($client_disk < 500000000) $client_disk = 500000000;
422 422
     $cmd = "cd ../..; ./bin/create_work --appname $app->name --batch $batch_id --rsc_fpops_est $info->rsc_fpops_est --rsc_fpops_bound $info->rsc_fpops_bound --rsc_disk_bound $client_disk";
423 423
     if ($cmdline) {
424 424
         $cmd .= " --command_line \"$cmdline\"";
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
     $x = file_get_contents("$tmpfile");
443 443
     $info = unserialize($x);
444 444
 
445
-    $njobs=0;
445
+    $njobs = 0;
446 446
     $cmdlines = file($info->cmdline_file_path);
447
-    foreach ($cmdlines as $cmdline){
447
+    foreach ($cmdlines as $cmdline) {
448 448
         if (preg_match("/^\s*-var/", $cmdline)) {
449 449
             $njobs++;
450 450
         }
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 
461 461
     $i = 0;
462 462
     foreach ($cmdlines as $cmdline) {
463
-        if (preg_match("/^\s*-var/", $cmdline)){
463
+        if (preg_match("/^\s*-var/", $cmdline)) {
464 464
             submit_job($app, $batch_id, $info, $cmdline, $i);
465 465
             $i++;
466 466
         }
Please login to merge, or discard this patch.
Braces   +19 added lines, -20 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
      proc_terminate($p);
39 39
     // echo "child process is $ret\n";
40 40
     $pids=preg_split('/\s+/',$ret);
41
-    foreach($pids as $pid){
42
-        if(is_numeric($pid)){
41
+    foreach($pids as $pid) {
42
+        if(is_numeric($pid)) {
43 43
             if($GLOBALS["debug"])echo "killing child process $pid\n";
44 44
             posix_kill($pid,9);
45 45
         }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     $p = proc_open("$cmd", $descs, $pipes);
61 61
     while (1) {
62 62
         $ctime=time();
63
-        if($ctime-$stime >=2 and ! file_exists("log.1")){
63
+        if($ctime-$stime >=2 and ! file_exists("log.1")) {
64 64
            if($GLOBALS["debug"]) echo "time out "."<br>";
65 65
            terminate_job($p);
66 66
            break;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                 $steps = $end_step-$start_step;
158 158
                 $avg_cpu = $cpu/$steps;
159 159
                 #$avg_cpu = $cpu/$count;
160
-                if ($GLOBALS["debug"]){
160
+                if ($GLOBALS["debug"]) {
161 161
                     echo "test steps is ".$steps."<br>";
162 162
                     echo "avg_cpu is ".$avg_cpu."<br>";
163 163
                 }
@@ -169,20 +169,19 @@  discard block
 block discarded – undo
169 169
     return array($avg_cpu,$test_steps);
170 170
 }
171 171
 
172
-function calc_est_size($lammps_script, $structure_file, $cmd_file,$test_steps){
172
+function calc_est_size($lammps_script, $structure_file, $cmd_file,$test_steps) {
173 173
     $dump_types = 0;
174 174
     $fd = fopen($lammps_script,"r");
175
-    if (!$fd){
175
+    if (!$fd) {
176 176
         echo "can not open file $lammps_script\n";
177 177
         exit(-1);
178 178
     }
179
-    while (!feof($fd)){
179
+    while (!feof($fd)) {
180 180
         $line = fgets($fd, 4096);
181 181
         //if (preg_match("/^\s*dump/", $line)
182 182
         //    and preg_match_all("/dump\S+\.\w{3}/", $line, $matches, PREG_PATTERN_ORDER))
183 183
         
184
-        if(preg_match("/^\s*dump\s+(\d)\s+/", $line,$matches))
185
-        {        
184
+        if(preg_match("/^\s*dump\s+(\d)\s+/", $line,$matches)) {
186 185
              if($GLOBALS["debug"]){print "matches=";print_r($matches);}
187 186
 
188 187
             $dump_types=(int)$matches[1];
@@ -194,7 +193,7 @@  discard block
 block discarded – undo
194 193
 
195 194
     $structure_file_size = filesize($structure_file);
196 195
     $fd = fopen($cmd_file,"r");
197
-    if (!$fd){
196
+    if (!$fd) {
198 197
         echo "can not open file $cmd_file\n";
199 198
         exit(-1);
200 199
     }
@@ -202,10 +201,10 @@  discard block
 block discarded – undo
202 201
    
203 202
     $loopno=1;
204 203
     $looprun=1;
205
-    while (!feof($fd)){
204
+    while (!feof($fd)) {
206 205
         $line = fgets($fd,4096);
207
-        if(preg_match("/loopnumber\s+\d+/", $line, $matches)){
208
-            if(preg_match("/\d+/", $matches[0], $no)){
206
+        if(preg_match("/loopnumber\s+\d+/", $line, $matches)) {
207
+            if(preg_match("/\d+/", $matches[0], $no)) {
209 208
                 //$loopno=$no[0];
210 209
                 if($no[0]>$loopno)$loopno=$no[0];
211 210
             }
@@ -215,7 +214,7 @@  discard block
 block discarded – undo
215 214
         }
216 215
     }
217 216
     fclose($fd);
218
-    if($GLOBALS["debug"]){
217
+    if($GLOBALS["debug"]) {
219 218
          print "max loopno(number of loops to run)=".$loopno."<br>";
220 219
          print "max looprun(steps for each loop)=".$looprun."<br>";
221 220
     }
@@ -231,7 +230,7 @@  discard block
 block discarded – undo
231 230
     $app_fixed_size = 5e7;
232 231
     $est_size = $log_size+$dump_size+$app_fixed_size;
233 232
     
234
-    if($GLOBALS["debug"]){
233
+    if($GLOBALS["debug"]) {
235 234
         print "test_steps=".$test_steps."<br>";
236 235
         print "test_log_size=".$test_log_size."<br>";
237 236
         print "log_size1=".$log_size1."<br>";
@@ -367,7 +366,7 @@  discard block
 block discarded – undo
367 366
         $err="Your test job <strong>failed</strong>
368 367
             <br>Please refer to the following Error Message:<br><p>
369 368
         ";
370
-        foreach($err_msgs as $line){
369
+        foreach($err_msgs as $line) {
371 370
              $err=$err.$line."<br>";
372 371
         }
373 372
         $err=$err." <p>
@@ -380,9 +379,9 @@  discard block
 block discarded – undo
380 379
     $info->rsc_fpops_est = $est_cpu_time * 1.5e9;
381 380
     $info->rsc_fpops_bound = $info->rsc_fpops_est * 20;
382 381
     
383
-    if ($disk==0){
382
+    if ($disk==0) {
384 383
         $info->rsc_disk_bound=1000000;
385
-    } else{
384
+    } else {
386 385
         $info->rsc_disk_bound = $disk;
387 386
     }
388 387
 
@@ -444,7 +443,7 @@  discard block
 block discarded – undo
444 443
 
445 444
     $njobs=0;
446 445
     $cmdlines = file($info->cmdline_file_path);
447
-    foreach ($cmdlines as $cmdline){
446
+    foreach ($cmdlines as $cmdline) {
448 447
         if (preg_match("/^\s*-var/", $cmdline)) {
449 448
             $njobs++;
450 449
         }
@@ -460,7 +459,7 @@  discard block
 block discarded – undo
460 459
 
461 460
     $i = 0;
462 461
     foreach ($cmdlines as $cmdline) {
463
-        if (preg_match("/^\s*-var/", $cmdline)){
462
+        if (preg_match("/^\s*-var/", $cmdline)) {
464 463
             submit_job($app, $batch_id, $info, $cmdline, $i);
465 464
             $i++;
466 465
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -430,7 +430,7 @@
 block discarded – undo
430 430
     //echo "<br> $cmd\n"; 
431 431
 
432 432
     system($cmd, $ret);
433
-    if ($ret === FALSE) {
433
+    if ($ret === false) {
434 434
         error_page("can't create job");
435 435
     } else {
436 436
         header('Location: submit.php');
Please login to merge, or discard this patch.
html/user/openid.php 4 patches
Doc Comments   +11 added lines, -1 removed lines patch added patch discarded remove patch
@@ -315,6 +315,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 class LightOpenID
48 48
 {
49 49
     public $returnUrl
50
-         , $required = array()
51
-         , $optional = array()
52
-         , $verify_peer = null
53
-         , $capath = null
54
-         , $cainfo = null;
50
+            , $required = array()
51
+            , $optional = array()
52
+            , $verify_peer = null
53
+            , $capath = null
54
+            , $cainfo = null;
55 55
     private $identity, $claimed_id;
56 56
     protected $server, $version, $trustRoot, $aliases, $identifier_select = false
57 57
             , $ax = false, $sreg = false, $data, $setup_url = null;
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
                         $parsed_url = parse_url($this->claimed_id);
262 262
                         $this->identity =
263 263
                         $this->claimed_id = $parsed_url['scheme'] . '://'
264
-                                          . $parsed_url['host']
265
-                                          . $headers[$name];
264
+                                            . $parsed_url['host']
265
+                                            . $headers[$name];
266 266
                     }
267 267
                 }
268 268
             }
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 
302 302
         $url = $parts + $url;
303 303
         $url = $url['scheme'] . '://'
304
-             . (empty($url['username'])?''
304
+                . (empty($url['username'])?''
305 305
                  :(empty($url['password'])? "{$url['username']}@"
306 306
                  :"{$url['username']}:{$url['password']}@"))
307
-             . $url['host']
308
-             . (empty($url['port'])?'':":{$url['port']}")
309
-             . (empty($url['path'])?'':$url['path'])
310
-             . (empty($url['query'])?'':"?{$url['query']}")
311
-             . (empty($url['fragment'])?'':"#{$url['fragment']}");
307
+                . $url['host']
308
+                . (empty($url['port'])?'':":{$url['port']}")
309
+                . (empty($url['path'])?'':$url['path'])
310
+                . (empty($url['query'])?'':"?{$url['query']}")
311
+                . (empty($url['fragment'])?'':"#{$url['fragment']}");
312 312
         return $url;
313 313
     }
314 314
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
     protected function authUrl_v1($immediate)
535 535
     {
536
-	$returnUrl = $this->returnUrl;
536
+    $returnUrl = $this->returnUrl;
537 537
         # If we have an openid.delegate that is different from our claimed id,
538 538
         # we need to somehow preserve the claimed id between requests.
539 539
         # The simplest way is to just send it along with the return_to url.
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
             ) + $this->sregParams();
550 550
 
551 551
         return $this->build_url(parse_url($this->server)
552
-                               , array('query' => http_build_query($params, '', '&')));
552
+                                , array('query' => http_build_query($params, '', '&')));
553 553
     }
554 554
 
555 555
     protected function authUrl_v2($immediate)
@@ -574,14 +574,14 @@  discard block
 block discarded – undo
574 574
 
575 575
         if ($this->identifier_select) {
576 576
             $params['openid.identity'] = $params['openid.claimed_id']
577
-                 = 'http://specs.openid.net/auth/2.0/identifier_select';
577
+                    = 'http://specs.openid.net/auth/2.0/identifier_select';
578 578
         } else {
579 579
             $params['openid.identity'] = $this->identity;
580 580
             $params['openid.claimed_id'] = $this->claimed_id;
581 581
         }
582 582
 
583 583
         return $this->build_url(parse_url($this->server)
584
-                               , array('query' => http_build_query($params, '', '&')));
584
+                                , array('query' => http_build_query($params, '', '&')));
585 585
     }
586 586
 
587 587
     /**
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
             # If it's an OpenID 1 provider, and we've got claimed_id,
639 639
             # we have to append it to the returnUrl, like authUrl_v1 does.
640 640
             $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
641
-                             .  'openid.claimed_id=' . $this->claimed_id;
641
+                                .  'openid.claimed_id=' . $this->claimed_id;
642 642
         }
643 643
 
644 644
         if ($this->data['openid_return_to'] != $this->returnUrl) {
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
                 continue;
708 708
             }
709 709
             $key = substr($this->data['openid_' . $alias . '_type_' . $key],
710
-                          strlen('http://axschema.org/'));
710
+                            strlen('http://axschema.org/'));
711 711
             $attributes[$key] = $value;
712 712
         }
713 713
         return $attributes;
Please login to merge, or discard this patch.
Braces   +24 added lines, -42 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@  discard block
 block discarded – undo
44 44
  * @copyright Copyright (c) 2010, Mewp
45 45
  * @license http://www.opensource.org/licenses/mit-license.php MIT
46 46
  */
47
-class LightOpenID
48
-{
47
+class LightOpenID {
49 48
     public $returnUrl
50 49
          , $required = array()
51 50
          , $optional = array()
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
         'pref/timezone'           => 'timezone',
68 67
         );
69 68
 
70
-    function __construct()
71
-    {
69
+    function __construct() {
72 70
         $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
73 71
         $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
74 72
         $this->returnUrl = $this->trustRoot . $uri;
@@ -80,8 +78,7 @@  discard block
 block discarded – undo
80 78
         }
81 79
     }
82 80
 
83
-    function __set($name, $value)
84
-    {
81
+    function __set($name, $value) {
85 82
         switch ($name) {
86 83
         case 'identity':
87 84
             if (strlen($value = trim((String) $value))) {
@@ -102,8 +99,7 @@  discard block
 block discarded – undo
102 99
         }
103 100
     }
104 101
 
105
-    function __get($name)
106
-    {
102
+    function __get($name) {
107 103
         switch ($name) {
108 104
         case 'identity':
109 105
             # We return claimed_id instead of identity,
@@ -124,8 +120,7 @@  discard block
 block discarded – undo
124 120
      * @param $url url to check
125 121
      * @return true, if the server exists; false otherwise
126 122
      */
127
-    function hostExists($url)
128
-    {
123
+    function hostExists($url) {
129 124
         if (strpos($url, '/') === false) {
130 125
             $server = $url;
131 126
         } else {
@@ -139,8 +134,7 @@  discard block
 block discarded – undo
139 134
         return !!gethostbynamel($server);
140 135
     }
141 136
 
142
-    protected function request_curl($url, $method='GET', $params=array())
143
-    {
137
+    protected function request_curl($url, $method='GET', $params=array()) {
144 138
         $params = http_build_query($params, '', '&');
145 139
         $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
146 140
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
@@ -195,8 +189,7 @@  discard block
 block discarded – undo
195 189
         return $response;
196 190
     }
197 191
 
198
-    protected function request_streams($url, $method='GET', $params=array())
199
-    {
192
+    protected function request_streams($url, $method='GET', $params=array()) {
200 193
         if(!$this->hostExists($url)) {
201 194
             throw new ErrorException('Invalid request.');
202 195
         }
@@ -285,16 +278,14 @@  discard block
 block discarded – undo
285 278
         return file_get_contents($url, false, $context);
286 279
     }
287 280
 
288
-    protected function request($url, $method='GET', $params=array())
289
-    {
281
+    protected function request($url, $method='GET', $params=array()) {
290 282
         if(function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
291 283
             return $this->request_curl($url, $method, $params);
292 284
         }
293 285
         return $this->request_streams($url, $method, $params);
294 286
     }
295 287
 
296
-    protected function build_url($url, $parts)
297
-    {
288
+    protected function build_url($url, $parts) {
298 289
         if (isset($url['query'], $parts['query'])) {
299 290
             $parts['query'] = $url['query'] . '&' . $parts['query'];
300 291
         }
@@ -316,8 +307,7 @@  discard block
 block discarded – undo
316 307
      * Helper function used to scan for <meta>/<link> tags and extract information
317 308
      * from them
318 309
      */
319
-    protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
320
-    {
310
+    protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName) {
321 311
         preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1);
322 312
         preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
323 313
 
@@ -331,8 +321,7 @@  discard block
 block discarded – undo
331 321
      * @return String OP Endpoint (i.e. OpenID provider address).
332 322
      * @throws ErrorException
333 323
      */
334
-    function discover($url)
335
-    {
324
+    function discover($url) {
336 325
         if (!$url) throw new ErrorException('No identity supplied.');
337 326
         # Use xri.net proxy to resolve i-name identities
338 327
         if (!preg_match('#^https?:#', $url)) {
@@ -465,8 +454,7 @@  discard block
 block discarded – undo
465 454
         throw new ErrorException('Endless redirection!');
466 455
     }
467 456
 
468
-    protected function sregParams()
469
-    {
457
+    protected function sregParams() {
470 458
         $params = array();
471 459
         # We always use SREG 1.1, even if the server is advertising only support for 1.0.
472 460
         # That's because it's fully backwards compatibile with 1.0, and some providers
@@ -492,8 +480,7 @@  discard block
 block discarded – undo
492 480
         return $params;
493 481
     }
494 482
 
495
-    protected function axParams()
496
-    {
483
+    protected function axParams() {
497 484
         $params = array();
498 485
         if ($this->required || $this->optional) {
499 486
             $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
@@ -531,8 +518,7 @@  discard block
 block discarded – undo
531 518
         return $params;
532 519
     }
533 520
 
534
-    protected function authUrl_v1($immediate)
535
-    {
521
+    protected function authUrl_v1($immediate) {
536 522
 	$returnUrl = $this->returnUrl;
537 523
         # If we have an openid.delegate that is different from our claimed id,
538 524
         # we need to somehow preserve the claimed id between requests.
@@ -552,8 +538,7 @@  discard block
 block discarded – undo
552 538
                                , array('query' => http_build_query($params, '', '&')));
553 539
     }
554 540
 
555
-    protected function authUrl_v2($immediate)
556
-    {
541
+    protected function authUrl_v2($immediate) {
557 542
         $params = array(
558 543
             'openid.ns'          => 'http://specs.openid.net/auth/2.0',
559 544
             'openid.mode'        => $immediate ? 'checkid_immediate' : 'checkid_setup',
@@ -590,8 +575,7 @@  discard block
 block discarded – undo
590 575
      * @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
591 576
      * @throws ErrorException
592 577
      */
593
-    function authUrl($immediate = false)
594
-    {
578
+    function authUrl($immediate = false) {
595 579
         if ($this->setup_url && !$immediate) return $this->setup_url;
596 580
         if (!$this->server) $this->discover($this->identity);
597 581
 
@@ -606,8 +590,7 @@  discard block
 block discarded – undo
606 590
      * @return Bool Whether the verification was successful.
607 591
      * @throws ErrorException
608 592
      */
609
-    function validate()
610
-    {
593
+    function validate() {
611 594
         # If the request was using immediate mode, a failure may be reported
612 595
         # by presenting user_setup_url (for 1.1) or reporting
613 596
         # mode 'setup_needed' (for 2.0). Also catching all modes other than
@@ -668,12 +651,12 @@  discard block
 block discarded – undo
668 651
         return preg_match('/is_valid\s*:\s*true/i', $response);
669 652
     }
670 653
 
671
-    protected function getAxAttributes()
672
-    {
654
+    protected function getAxAttributes() {
673 655
         $alias = null;
674 656
         if (isset($this->data['openid_ns_ax'])
675 657
             && $this->data['openid_ns_ax'] != 'http://openid.net/srv/ax/1.0'
676
-        ) { # It's the most likely case, so we'll check it before
658
+        ) {
659
+# It's the most likely case, so we'll check it before
677 660
             $alias = 'ax';
678 661
         } else {
679 662
             # 'ax' prefix is either undefined, or points to another extension,
@@ -713,8 +696,7 @@  discard block
 block discarded – undo
713 696
         return $attributes;
714 697
     }
715 698
 
716
-    protected function getSregAttributes()
717
-    {
699
+    protected function getSregAttributes() {
718 700
         $attributes = array();
719 701
         $sreg_to_ax = array_flip(self::$ax_to_sreg);
720 702
         foreach ($this->data as $key => $value) {
@@ -741,11 +723,11 @@  discard block
 block discarded – undo
741 723
      *     * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email'
742 724
      * @see http://www.axschema.org/types/
743 725
      */
744
-    function getAttributes()
745
-    {
726
+    function getAttributes() {
746 727
         if (isset($this->data['openid_ns'])
747 728
             && $this->data['openid_ns'] == 'http://specs.openid.net/auth/2.0'
748
-        ) { # OpenID 2.0
729
+        ) {
730
+# OpenID 2.0
749 731
             # We search for both AX and SREG attributes, with AX taking precedence.
750 732
             return $this->getAxAttributes() + $this->getSregAttributes();
751 733
         }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 
70 70
     function __construct()
71 71
     {
72
-        $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
72
+        $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'];
73 73
         $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
74
-        $this->returnUrl = $this->trustRoot . $uri;
74
+        $this->returnUrl = $this->trustRoot.$uri;
75 75
 
76 76
         $this->data = $_POST + $_GET; # OPs may send data as POST or GET.
77 77
 
78
-        if(!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
78
+        if (!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
79 79
             throw new ErrorException('You must have either https wrappers or curl enabled.');
80 80
         }
81 81
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         switch ($name) {
86 86
         case 'identity':
87
-            if (strlen($value = trim((String) $value))) {
87
+            if (strlen($value = trim((String)$value))) {
88 88
                 if (preg_match('#^xri:/*#i', $value, $m)) {
89 89
                     $value = substr($value, strlen($m[0]));
90 90
                 } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) {
@@ -139,23 +139,23 @@  discard block
 block discarded – undo
139 139
         return !!gethostbynamel($server);
140 140
     }
141 141
 
142
-    protected function request_curl($url, $method='GET', $params=array())
142
+    protected function request_curl($url, $method = 'GET', $params = array())
143 143
     {
144 144
         $params = http_build_query($params, '', '&');
145
-        $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
145
+        $curl = curl_init($url.($method == 'GET' && $params ? '?'.$params : ''));
146 146
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
147 147
         curl_setopt($curl, CURLOPT_HEADER, false);
148 148
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
149 149
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
150 150
         curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
151 151
 
152
-        if($this->verify_peer !== null) {
152
+        if ($this->verify_peer !== null) {
153 153
             curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
154
-            if($this->capath) {
154
+            if ($this->capath) {
155 155
                 curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
156 156
             }
157 157
 
158
-            if($this->cainfo) {
158
+            if ($this->cainfo) {
159 159
                 curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
160 160
             }
161 161
         }
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
         }
172 172
         $response = curl_exec($curl);
173 173
 
174
-        if($method == 'HEAD') {
174
+        if ($method == 'HEAD') {
175 175
             $headers = array();
176
-            foreach(explode("\n", $response) as $header) {
177
-                $pos = strpos($header,':');
176
+            foreach (explode("\n", $response) as $header) {
177
+                $pos = strpos($header, ':');
178 178
                 $name = strtolower(trim(substr($header, 0, $pos)));
179
-                $headers[$name] = trim(substr($header, $pos+1));
179
+                $headers[$name] = trim(substr($header, $pos + 1));
180 180
             }
181 181
 
182 182
             # Updating claimed_id in case of redirections.
183 183
             $effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
184
-            if($effective_url != $url) {
184
+            if ($effective_url != $url) {
185 185
                 $this->identity = $this->claimed_id = $effective_url;
186 186
             }
187 187
 
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         return $response;
196 196
     }
197 197
 
198
-    protected function request_streams($url, $method='GET', $params=array())
198
+    protected function request_streams($url, $method = 'GET', $params = array())
199 199
     {
200
-        if(!$this->hostExists($url)) {
200
+        if (!$this->hostExists($url)) {
201 201
             throw new ErrorException('Invalid request.');
202 202
         }
203 203
 
204 204
         $params = http_build_query($params, '', '&');
205
-        switch($method) {
205
+        switch ($method) {
206 206
         case 'GET':
207 207
             $opts = array(
208 208
                 'http' => array(
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                     'ignore_errors' => true,
212 212
                 )
213 213
             );
214
-            $url = $url . ($params ? '?' . $params : '');
214
+            $url = $url.($params ? '?'.$params : '');
215 215
             break;
216 216
         case 'POST':
217 217
             $opts = array(
@@ -236,31 +236,31 @@  discard block
 block discarded – undo
236 236
                 ))
237 237
             );
238 238
 
239
-            $url = $url . ($params ? '?' . $params : '');
240
-            $headers_tmp = get_headers ($url);
241
-            if(!$headers_tmp) {
239
+            $url = $url.($params ? '?'.$params : '');
240
+            $headers_tmp = get_headers($url);
241
+            if (!$headers_tmp) {
242 242
                 return array();
243 243
             }
244 244
 
245 245
             # Parsing headers.
246 246
             $headers = array();
247
-            foreach($headers_tmp as $header) {
248
-                $pos = strpos($header,':');
247
+            foreach ($headers_tmp as $header) {
248
+                $pos = strpos($header, ':');
249 249
                 $name = strtolower(trim(substr($header, 0, $pos)));
250
-                $headers[$name] = trim(substr($header, $pos+1));
250
+                $headers[$name] = trim(substr($header, $pos + 1));
251 251
 
252 252
                 # Following possible redirections. The point is just to have
253 253
                 # claimed_id change with them, because get_headers() will
254 254
                 # follow redirections automatically.
255 255
                 # We ignore redirections with relative paths.
256 256
                 # If any known provider uses them, file a bug report.
257
-                if($name == 'location') {
258
-                    if(strpos($headers[$name], 'http') === 0) {
257
+                if ($name == 'location') {
258
+                    if (strpos($headers[$name], 'http') === 0) {
259 259
                         $this->identity = $this->claimed_id = $headers[$name];
260
-                    } elseif($headers[$name][0] == '/') {
260
+                    } elseif ($headers[$name][0] == '/') {
261 261
                         $parsed_url = parse_url($this->claimed_id);
262 262
                         $this->identity =
263
-                        $this->claimed_id = $parsed_url['scheme'] . '://'
263
+                        $this->claimed_id = $parsed_url['scheme'].'://'
264 264
                                           . $parsed_url['host']
265 265
                                           . $headers[$name];
266 266
                     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             return $headers;
273 273
         }
274 274
 
275
-        if($this->verify_peer) {
275
+        if ($this->verify_peer) {
276 276
             $opts += array('ssl' => array(
277 277
                 'verify_peer' => true,
278 278
                 'capath'      => $this->capath,
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
             ));
281 281
         }
282 282
 
283
-        $context = stream_context_create ($opts);
283
+        $context = stream_context_create($opts);
284 284
 
285 285
         return file_get_contents($url, false, $context);
286 286
     }
287 287
 
288
-    protected function request($url, $method='GET', $params=array())
288
+    protected function request($url, $method = 'GET', $params = array())
289 289
     {
290
-        if(function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
290
+        if (function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
291 291
             return $this->request_curl($url, $method, $params);
292 292
         }
293 293
         return $this->request_streams($url, $method, $params);
@@ -296,19 +296,19 @@  discard block
 block discarded – undo
296 296
     protected function build_url($url, $parts)
297 297
     {
298 298
         if (isset($url['query'], $parts['query'])) {
299
-            $parts['query'] = $url['query'] . '&' . $parts['query'];
299
+            $parts['query'] = $url['query'].'&'.$parts['query'];
300 300
         }
301 301
 
302 302
         $url = $parts + $url;
303
-        $url = $url['scheme'] . '://'
304
-             . (empty($url['username'])?''
305
-                 :(empty($url['password'])? "{$url['username']}@"
303
+        $url = $url['scheme'].'://'
304
+             . (empty($url['username']) ? ''
305
+                 :(empty($url['password']) ? "{$url['username']}@"
306 306
                  :"{$url['username']}:{$url['password']}@"))
307 307
              . $url['host']
308
-             . (empty($url['port'])?'':":{$url['port']}")
309
-             . (empty($url['path'])?'':$url['path'])
310
-             . (empty($url['query'])?'':"?{$url['query']}")
311
-             . (empty($url['fragment'])?'':"#{$url['fragment']}");
308
+             . (empty($url['port']) ? '' : ":{$url['port']}")
309
+             . (empty($url['path']) ? '' : $url['path'])
310
+             . (empty($url['query']) ? '' : "?{$url['query']}")
311
+             . (empty($url['fragment']) ? '' : "#{$url['fragment']}");
312 312
         return $url;
313 313
     }
314 314
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
323 323
 
324 324
         $result = array_merge($matches1[1], $matches2[1]);
325
-        return empty($result)?false:$result[0];
325
+        return empty($result) ?false:$result[0];
326 326
     }
327 327
 
328 328
     /**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         $yadis = true;
349 349
 
350 350
         # We'll jump a maximum of 5 times, to avoid endless redirections.
351
-        for ($i = 0; $i < 5; $i ++) {
351
+        for ($i = 0; $i < 5; $i++) {
352 352
             if ($yadis) {
353 353
                 $headers = $this->request($url, 'HEAD');
354 354
 
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
                     $content = $this->request($url, 'GET');
371 371
 
372 372
                     preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
373
-                    foreach($m[1] as $content) {
374
-                        $content = ' ' . $content; # The space is added, so that strpos doesn't return 0.
373
+                    foreach ($m[1] as $content) {
374
+                        $content = ' '.$content; # The space is added, so that strpos doesn't return 0.
375 375
 
376 376
                         # OpenID 2
377 377
                         $ns = preg_quote('http://specs.openid.net/auth/2.0/');
378
-                        if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
378
+                        if (preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
379 379
                             if ($type[1] == 'server') $this->identifier_select = true;
380 380
 
381 381
                             preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
                                 return false;
385 385
                             }
386 386
                             # Does the server advertise support for either AX or SREG?
387
-                            $this->ax   = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
387
+                            $this->ax   = (bool)strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
388 388
                             $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
389 389
                                        || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
390 390
 
@@ -498,33 +498,33 @@  discard block
 block discarded – undo
498 498
         if ($this->required || $this->optional) {
499 499
             $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
500 500
             $params['openid.ax.mode'] = 'fetch_request';
501
-            $this->aliases  = array();
501
+            $this->aliases = array();
502 502
             $counts   = array();
503 503
             $required = array();
504 504
             $optional = array();
505
-            foreach (array('required','optional') as $type) {
505
+            foreach (array('required', 'optional') as $type) {
506 506
                 foreach ($this->$type as $alias => $field) {
507 507
                     if (is_int($alias)) $alias = strtr($field, '/', '_');
508
-                    $this->aliases[$alias] = 'http://axschema.org/' . $field;
508
+                    $this->aliases[$alias] = 'http://axschema.org/'.$field;
509 509
                     if (empty($counts[$alias])) $counts[$alias] = 0;
510 510
                     $counts[$alias] += 1;
511 511
                     ${$type}[] = $alias;
512 512
                 }
513 513
             }
514 514
             foreach ($this->aliases as $alias => $ns) {
515
-                $params['openid.ax.type.' . $alias] = $ns;
515
+                $params['openid.ax.type.'.$alias] = $ns;
516 516
             }
517 517
             foreach ($counts as $alias => $count) {
518 518
                 if ($count == 1) continue;
519
-                $params['openid.ax.count.' . $alias] = $count;
519
+                $params['openid.ax.count.'.$alias] = $count;
520 520
             }
521 521
 
522 522
             # Don't send empty ax.requied and ax.if_available.
523 523
             # Google and possibly other providers refuse to support ax when one of these is empty.
524
-            if($required) {
524
+            if ($required) {
525 525
                 $params['openid.ax.required'] = implode(',', $required);
526 526
             }
527
-            if($optional) {
527
+            if ($optional) {
528 528
                 $params['openid.ax.if_available'] = implode(',', $optional);
529 529
             }
530 530
         }
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
         # If we have an openid.delegate that is different from our claimed id,
538 538
         # we need to somehow preserve the claimed id between requests.
539 539
         # The simplest way is to just send it along with the return_to url.
540
-        if($this->identity != $this->claimed_id) {
541
-            $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id;
540
+        if ($this->identity != $this->claimed_id) {
541
+            $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?').'openid.claimed_id='.$this->claimed_id;
542 542
         }
543 543
 
544 544
         $params = array(
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
         # by presenting user_setup_url (for 1.1) or reporting
613 613
         # mode 'setup_needed' (for 2.0). Also catching all modes other than
614 614
         # id_res, in order to avoid throwing errors.
615
-        if(isset($this->data['openid_user_setup_url'])) {
615
+        if (isset($this->data['openid_user_setup_url'])) {
616 616
             $this->setup_url = $this->data['openid_user_setup_url'];
617 617
             return false;
618 618
         }
619
-        if($this->mode != 'id_res') {
619
+        if ($this->mode != 'id_res') {
620 620
             return false;
621 621
         }
622 622
 
623
-        $this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity'];
623
+        $this->claimed_id = isset($this->data['openid_claimed_id']) ? $this->data['openid_claimed_id'] : $this->data['openid_identity'];
624 624
         $params = array(
625 625
             'openid.assoc_handle' => $this->data['openid_assoc_handle'],
626 626
             'openid.signed'       => $this->data['openid_signed'],
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
             # If it's an OpenID 1 provider, and we've got claimed_id,
639 639
             # we have to append it to the returnUrl, like authUrl_v1 does.
640 640
             $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
641
-                             .  'openid.claimed_id=' . $this->claimed_id;
641
+                             .  'openid.claimed_id='.$this->claimed_id;
642 642
         }
643 643
 
644 644
         if ($this->data['openid_return_to'] != $this->returnUrl) {
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
             # In such case, validation would fail, since we'd send different data than OP
657 657
             # wants to verify. stripslashes() should solve that problem, but we can't
658 658
             # use it when magic_quotes is off.
659
-            $value = $this->data['openid_' . str_replace('.','_',$item)];
660
-            $params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
659
+            $value = $this->data['openid_'.str_replace('.', '_', $item)];
660
+            $params['openid.'.$item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
661 661
 
662 662
         }
663 663
 
@@ -695,18 +695,18 @@  discard block
 block discarded – undo
695 695
 
696 696
         $attributes = array();
697 697
         foreach ($this->data as $key => $value) {
698
-            $keyMatch = 'openid_' . $alias . '_value_';
698
+            $keyMatch = 'openid_'.$alias.'_value_';
699 699
             if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
700 700
                 continue;
701 701
             }
702 702
             $key = substr($key, strlen($keyMatch));
703
-            if (!isset($this->data['openid_' . $alias . '_type_' . $key])) {
703
+            if (!isset($this->data['openid_'.$alias.'_type_'.$key])) {
704 704
                 # OP is breaking the spec by returning a field without
705 705
                 # associated ns. This shouldn't happen, but it's better
706 706
                 # to check, than cause an E_NOTICE.
707 707
                 continue;
708 708
             }
709
-            $key = substr($this->data['openid_' . $alias . '_type_' . $key],
709
+            $key = substr($this->data['openid_'.$alias.'_type_'.$key],
710 710
                           strlen('http://axschema.org/'));
711 711
             $attributes[$key] = $value;
712 712
         }
Please login to merge, or discard this patch.
html/user/server_status.php 3 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -88,17 +88,26 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         $avg = round($app->info->avg, 2);
172 172
         $min = round($app->info->min, 2);
173 173
         $max = round($app->info->max, 2);
174
-        $x = $max?"$avg ($min - $max)":"---";
174
+        $x = $max ? "$avg ($min - $max)" : "---";
175 175
         $u = $app->info->users;
176 176
         echo "<tr>
177 177
             <td>$app->user_friendly_name</td>
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         $cmd = trim($cmd);
245 245
         $x = explode(" ", $cmd);
246 246
         $prog = $x[0];
247
-        $pidname = $prog . '.pid';
247
+        $pidname = $prog.'.pid';
248 248
     }
249 249
     $path = "../../pid_$host/$pidname";
250 250
     if (is_file($path)) {
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
     }
286 286
     $master_host = $u["host"];
287 287
     if ($config->www_host) {
288
-        $web_host = trim((string) $config->www_host);
288
+        $web_host = trim((string)$config->www_host);
289 289
     } else {
290 290
         $web_host = $main_host;
291 291
     }
292 292
     if ($config->sched_host) {
293
-        $sched_host = trim((string) $config->sched_host);
293
+        $sched_host = trim((string)$config->sched_host);
294 294
     } else {
295 295
         $sched_host = $main_host;
296 296
     }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
     // the upload and download servers are sort of daemons too
302 302
     //
303
-    $url = trim((string) $config->download_url);
303
+    $url = trim((string)$config->download_url);
304 304
     $u = parse_url($url);
305 305
     $h = $u["host"];
306 306
     if ($h == $master_host) {
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
     } else {
313 313
         $have_remote = true;
314 314
     }
315
-    $url = trim((string) $config->upload_url);
315
+    $url = trim((string)$config->upload_url);
316 316
     $u = parse_url($url);
317 317
     $h = $u["host"];
318 318
     if ($h == $master_host) {
319 319
         $y = new StdClass;
320 320
         $y->cmd = "Upload server";
321 321
         $y->host = $h;
322
-        $y->status = !file_exists("../../stop_upload");;
322
+        $y->status = !file_exists("../../stop_upload"); ;
323 323
         $local_daemons[] = $y;
324 324
     } else {
325 325
         $have_remote = true;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         $y = new StdClass;
332 332
         $y->cmd = "Scheduler";
333 333
         $y->host = $sched_host;
334
-        $y->status = !file_exists("../../stop_sched");;
334
+        $y->status = !file_exists("../../stop_sched"); ;
335 335
         $local_daemons[] = $y;
336 336
     } else {
337 337
         $have_remote = true;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
             $disabled_daemons[] = $x;
348 348
             continue;
349 349
         }
350
-        $host = $d->host?(string)$d->host:$main_host;
350
+        $host = $d->host ? (string)$d->host : $main_host;
351 351
         if ($host != $web_host) {
352 352
             $have_remote = true;
353 353
             continue;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
         $pid = file_get_contents($path);
252 252
         if ($pid) {
253 253
             $pid = trim($pid);
254
-            $out = Array();
254
+            $out = array();
255 255
             exec("ps -ww $pid", $out);
256 256
             foreach ($out as $y) {
257 257
                 if (strstr($y, (string)$pid)) return 1;
Please login to merge, or discard this patch.
html/user/show_coproc.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -25,6 +25,9 @@
 block discarded – undo
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";
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
         echo $x;
93 93
         break;
94 94
     }
95
-    echo "</td><td align=right>".format_credit_large($y->credit),"</td><td align=right>$y->nresults</td></tr>\n";
95
+    echo "</td><td align=right>".format_credit_large($y->credit), "</td><td align=right>$y->nresults</td></tr>\n";
96 96
 }
97 97
 
98 98
 $mode = get_str('mode', true);
Please login to merge, or discard this patch.