@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | // only do files ending in .po |
71 | - if (substr($file,-3) != ".po"){ |
|
71 | + if (substr($file,-3) != ".po") { |
|
72 | 72 | //debug("File $file with unknown extension found in $info_dir"); |
73 | 73 | continue; |
74 | 74 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | "-------------Compiling $transdir$file------------", 0 |
77 | 77 | ); |
78 | 78 | $language = parse_po_file($langdir.$transdir.$file); |
79 | - if (!$language){ |
|
79 | + if (!$language) { |
|
80 | 80 | language_log( |
81 | 81 | "WARNING: Could not parse language ".$file |
82 | 82 | ); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ); |
96 | 96 | exit; |
97 | 97 | } |
98 | - foreach ($language as $key => $value){ |
|
98 | + foreach ($language as $key => $value) { |
|
99 | 99 | if ($value !== "") { |
100 | 100 | // Skip if the msgstr is empty |
101 | 101 | fwrite($fh, "\$language_lookup_array[\"".str_replace("\"", "\\\"", substr($file,0,-3))."\"][\"".$key."\"] = \"".$value."\";\n"); |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | $parsing_text = false; |
122 | 122 | $size = sizeof($translation_file); |
123 | 123 | $output = array(); |
124 | - for ($i=0; $i<$size; $i++){ |
|
124 | + for ($i=0; $i<$size; $i++) { |
|
125 | 125 | $entry = trim($translation_file[$i]); |
126 | 126 | //echo "line $i: $entry\n"; |
127 | 127 | if (substr($entry, 0, 1)=="#") { |
128 | 128 | continue; |
129 | 129 | } elseif (strpos($entry, "msgid") !== false) { |
130 | - if (!$first_entry){ |
|
130 | + if (!$first_entry) { |
|
131 | 131 | //If this is not the first, save the previous entry |
132 | 132 | $output[$current_token]=$current_token_text; |
133 | 133 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | // Get the last token |
151 | 151 | // |
152 | - if ($current_token && $current_token_text){ |
|
152 | + if ($current_token && $current_token_text) { |
|
153 | 153 | $output[$current_token] = $current_token_text; |
154 | 154 | } |
155 | 155 | return $output; |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | |
181 | 181 | // Find the string in the user's language |
182 | 182 | // |
183 | - foreach ($languages_in_use as $language){ |
|
183 | + foreach ($languages_in_use as $language) { |
|
184 | 184 | if (isset($language_lookup_array[$language][$text])) { |
185 | 185 | $text = $language_lookup_array[$language][$text]; |
186 | 186 | break; |
187 | - } else if ($language=="en"){ |
|
187 | + } else if ($language=="en") { |
|
188 | 188 | // This language is defined in the code and is always available |
189 | 189 | break; |
190 | 190 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // Replace relevant substrings with given arguments. |
194 | 194 | // Use strtr to avoid problems if an argument contains %n. |
195 | 195 | $replacements = array(); |
196 | - for ($i=1; $i<func_num_args(); $i++){ |
|
196 | + for ($i=1; $i<func_num_args(); $i++) { |
|
197 | 197 | $replacements["%".$i] = func_get_arg($i); |
198 | 198 | } |
199 | 199 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if ($loglevel==1) $msg = "[ Warning ]"; |
218 | 218 | if ($loglevel==2) $msg = "[ CRITICAL ]"; |
219 | 219 | |
220 | - if ($loglevel >= $lang_log_level){ |
|
220 | + if ($loglevel >= $lang_log_level) { |
|
221 | 221 | echo gmdate("Y-m-d H:i:s", time())." ".$msg." ".$message."\n"; |
222 | 222 | } |
223 | 223 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | // (by looking at cookies and browser settings) |
227 | 227 | // cookies have highest priority. |
228 | 228 | |
229 | -if (isset($_COOKIE['lang'])){ |
|
229 | +if (isset($_COOKIE['lang'])) { |
|
230 | 230 | $language_string = $_COOKIE['lang'].","; |
231 | 231 | } else { |
232 | 232 | $language_string = ''; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | for ($i=0; $i<$size; $i++) { |
261 | 261 | if ((strlen($client_languages[$i])>2) |
262 | 262 | && (substr($client_languages[$i], 2, 1) == "_" || substr($client_languages[$i], 2, 1) == "-") |
263 | - ){ |
|
263 | + ) { |
|
264 | 264 | // If this is defined as primary-secondary, represent it as xx_YY |
265 | 265 | // |
266 | 266 | $language = substr( |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | // |
288 | 288 | $file_name = $lang_language_dir.$lang_compiled_dir.$language.".po.inc"; |
289 | 289 | if (file_exists($file_name)) { |
290 | - if (!in_array($language, $languages_in_use)){ |
|
290 | + if (!in_array($language, $languages_in_use)) { |
|
291 | 291 | require_once($file_name); |
292 | 292 | $languages_in_use[] = $language; |
293 | 293 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | if ($language2) { |
296 | 296 | $file_name = $lang_language_dir.$lang_compiled_dir.$language2.".po.inc"; |
297 | 297 | if (file_exists($file_name)) { |
298 | - if (!in_array($language2, $languages_in_use)){ |
|
298 | + if (!in_array($language2, $languages_in_use)) { |
|
299 | 299 | require_once($file_name); |
300 | 300 | $languages_in_use[] = $language2; |
301 | 301 | } |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | $dh = opendir($langdir.$transdir); |
65 | 65 | if (!$dh) die("can't open translation dir"); |
66 | 66 | while (($file = readdir($dh)) !== false) { |
67 | - if ($file==".." || $file==".") { |
|
67 | + if ($file == ".." || $file == ".") { |
|
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | // only do files ending in .po |
71 | - if (substr($file,-3) != ".po"){ |
|
71 | + if (substr($file, -3) != ".po") { |
|
72 | 72 | //debug("File $file with unknown extension found in $info_dir"); |
73 | 73 | continue; |
74 | 74 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | "-------------Compiling $transdir$file------------", 0 |
77 | 77 | ); |
78 | 78 | $language = parse_po_file($langdir.$transdir.$file); |
79 | - if (!$language){ |
|
79 | + if (!$language) { |
|
80 | 80 | language_log( |
81 | 81 | "WARNING: Could not parse language ".$file |
82 | 82 | ); |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | ); |
96 | 96 | exit; |
97 | 97 | } |
98 | - foreach ($language as $key => $value){ |
|
98 | + foreach ($language as $key => $value) { |
|
99 | 99 | if ($value !== "") { |
100 | 100 | // Skip if the msgstr is empty |
101 | - fwrite($fh, "\$language_lookup_array[\"".str_replace("\"", "\\\"", substr($file,0,-3))."\"][\"".$key."\"] = \"".$value."\";\n"); |
|
101 | + fwrite($fh, "\$language_lookup_array[\"".str_replace("\"", "\\\"", substr($file, 0, -3))."\"][\"".$key."\"] = \"".$value."\";\n"); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | // don't write \?\> - may append |
@@ -115,27 +115,27 @@ discard block |
||
115 | 115 | function parse_po_file($file) { |
116 | 116 | $translation_file = file($file); |
117 | 117 | $first_entry = true; |
118 | - $current_token_text=""; |
|
119 | - $current_token =""; |
|
118 | + $current_token_text = ""; |
|
119 | + $current_token = ""; |
|
120 | 120 | $parsing_token = false; |
121 | 121 | $parsing_text = false; |
122 | 122 | $size = sizeof($translation_file); |
123 | 123 | $output = array(); |
124 | - for ($i=0; $i<$size; $i++){ |
|
124 | + for ($i = 0; $i < $size; $i++) { |
|
125 | 125 | $entry = trim($translation_file[$i]); |
126 | 126 | //echo "line $i: $entry\n"; |
127 | - if (substr($entry, 0, 1)=="#") { |
|
127 | + if (substr($entry, 0, 1) == "#") { |
|
128 | 128 | continue; |
129 | 129 | } elseif (strpos($entry, "msgid") !== false) { |
130 | - if (!$first_entry){ |
|
130 | + if (!$first_entry) { |
|
131 | 131 | //If this is not the first, save the previous entry |
132 | - $output[$current_token]=$current_token_text; |
|
132 | + $output[$current_token] = $current_token_text; |
|
133 | 133 | } |
134 | 134 | $current_token = get_po_line($entry, $file); |
135 | - $current_token_text=""; |
|
135 | + $current_token_text = ""; |
|
136 | 136 | $parsing_token = true; |
137 | 137 | $parsing_text = false; |
138 | - $first_entry=false; |
|
138 | + $first_entry = false; |
|
139 | 139 | } elseif (strpos($entry, "msgstr") !== false) { |
140 | 140 | $current_token_text = get_po_line($entry, $file); |
141 | 141 | $parsing_token = false; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | // Get the last token |
151 | 151 | // |
152 | - if ($current_token && $current_token_text){ |
|
152 | + if ($current_token && $current_token_text) { |
|
153 | 153 | $output[$current_token] = $current_token_text; |
154 | 154 | } |
155 | 155 | return $output; |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | // Returns the contents of a line (ie removes "" from start and end) |
160 | 160 | // |
161 | 161 | function get_po_line($line, $file) { |
162 | - $start = strpos($line, '"')+1; |
|
162 | + $start = strpos($line, '"') + 1; |
|
163 | 163 | $stop = strrpos($line, '"'); |
164 | - $x = substr($line, $start, $stop-$start); |
|
164 | + $x = substr($line, $start, $stop - $start); |
|
165 | 165 | $n = preg_match("/[^\\\\]\"/", $x); |
166 | 166 | if ($n) { |
167 | 167 | echo "ERROR - MISMATCHED QUOTES IN $file: $line\n"; |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | |
181 | 181 | // Find the string in the user's language |
182 | 182 | // |
183 | - foreach ($languages_in_use as $language){ |
|
183 | + foreach ($languages_in_use as $language) { |
|
184 | 184 | if (isset($language_lookup_array[$language][$text])) { |
185 | 185 | $text = $language_lookup_array[$language][$text]; |
186 | 186 | break; |
187 | - } else if ($language=="en"){ |
|
187 | + } else if ($language == "en") { |
|
188 | 188 | // This language is defined in the code and is always available |
189 | 189 | break; |
190 | 190 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // Replace relevant substrings with given arguments. |
194 | 194 | // Use strtr to avoid problems if an argument contains %n. |
195 | 195 | $replacements = array(); |
196 | - for ($i=1; $i<func_num_args(); $i++){ |
|
196 | + for ($i = 1; $i < func_num_args(); $i++) { |
|
197 | 197 | $replacements["%".$i] = func_get_arg($i); |
198 | 198 | } |
199 | 199 | |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | return $text; |
211 | 211 | } |
212 | 212 | |
213 | -function language_log($message, $loglevel=0) { |
|
213 | +function language_log($message, $loglevel = 0) { |
|
214 | 214 | global $lang_log_level; |
215 | 215 | $msg = ""; |
216 | - if ($loglevel==0) $msg = "[ Debug ]"; |
|
217 | - if ($loglevel==1) $msg = "[ Warning ]"; |
|
218 | - if ($loglevel==2) $msg = "[ CRITICAL ]"; |
|
216 | + if ($loglevel == 0) $msg = "[ Debug ]"; |
|
217 | + if ($loglevel == 1) $msg = "[ Warning ]"; |
|
218 | + if ($loglevel == 2) $msg = "[ CRITICAL ]"; |
|
219 | 219 | |
220 | - if ($loglevel >= $lang_log_level){ |
|
220 | + if ($loglevel >= $lang_log_level) { |
|
221 | 221 | echo gmdate("Y-m-d H:i:s", time())." ".$msg." ".$message."\n"; |
222 | 222 | } |
223 | 223 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | // (by looking at cookies and browser settings) |
227 | 227 | // cookies have highest priority. |
228 | 228 | |
229 | -if (isset($_COOKIE['lang'])){ |
|
229 | +if (isset($_COOKIE['lang'])) { |
|
230 | 230 | $language_string = $_COOKIE['lang'].","; |
231 | 231 | } else { |
232 | 232 | $language_string = ''; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | // Loop over languages that the client requests |
258 | 258 | // |
259 | 259 | $size = sizeof($client_languages); |
260 | -for ($i=0; $i<$size; $i++) { |
|
261 | - if ((strlen($client_languages[$i])>2) |
|
260 | +for ($i = 0; $i < $size; $i++) { |
|
261 | + if ((strlen($client_languages[$i]) > 2) |
|
262 | 262 | && (substr($client_languages[$i], 2, 1) == "_" || substr($client_languages[$i], 2, 1) == "-") |
263 | - ){ |
|
263 | + ) { |
|
264 | 264 | // If this is defined as primary-secondary, represent it as xx_YY |
265 | 265 | // |
266 | 266 | $language = substr( |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | // if main language is english, look no further |
281 | 281 | // |
282 | - if ((count($languages_in_use)==0) && ($language == 'en' || $language2 == 'en')) { |
|
282 | + if ((count($languages_in_use) == 0) && ($language == 'en' || $language2 == 'en')) { |
|
283 | 283 | break; |
284 | 284 | } |
285 | 285 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | // |
288 | 288 | $file_name = $lang_language_dir.$lang_compiled_dir.$language.".po.inc"; |
289 | 289 | if (file_exists($file_name)) { |
290 | - if (!in_array($language, $languages_in_use)){ |
|
290 | + if (!in_array($language, $languages_in_use)) { |
|
291 | 291 | require_once($file_name); |
292 | 292 | $languages_in_use[] = $language; |
293 | 293 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | if ($language2) { |
296 | 296 | $file_name = $lang_language_dir.$lang_compiled_dir.$language2.".po.inc"; |
297 | 297 | if (file_exists($file_name)) { |
298 | - if (!in_array($language2, $languages_in_use)){ |
|
298 | + if (!in_array($language2, $languages_in_use)) { |
|
299 | 299 | require_once($file_name); |
300 | 300 | $languages_in_use[] = $language2; |
301 | 301 | } |
@@ -303,6 +303,6 @@ discard block |
||
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | -$GLOBALS['languages_in_use'] = $languages_in_use; // for Drupal |
|
306 | +$GLOBALS['languages_in_use'] = $languages_in_use; // for Drupal |
|
307 | 307 | |
308 | 308 | ?> |
@@ -259,10 +259,10 @@ |
||
259 | 259 | // "[vbox|5.0.0|1|1]", where now two additional flags give information about |
260 | 260 | // hardware virtualization support. Older clients may have the old-style |
261 | 261 | // serialnum in the DB despite the server being upgraded. |
262 | -function vbox_desc($x){ |
|
263 | - if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/",$x,$matches)){ |
|
262 | +function vbox_desc($x) { |
|
263 | + if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/",$x,$matches)) { |
|
264 | 264 | $desc = "Virtualbox (".$matches[1].") ".tra("installed"); |
265 | - if (sizeof($matches)>2){ |
|
265 | + if (sizeof($matches)>2) { |
|
266 | 266 | if ($matches[3]=="1" and $matches[4]=="1") { |
267 | 267 | return $desc.tra(", CPU has hardware virtualization support and it is enabled"); |
268 | 268 | } elseif ($matches[3]=="1" and $matches[4]=="0") { |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | function sched_log_name($x) { |
34 | 34 | if ($x == 0) return "NO_SUCH_LOG"; |
35 | - return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt"; |
|
35 | + return gmdate('Y-m-d_H/Y-m-d_H:i', $x).".txt"; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function sched_log_link($x) { |
39 | 39 | if (file_exists("sched_logs")) { |
40 | - return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>"; |
|
40 | + return "<a href=\"../sched_logs/".sched_log_name($x)."\">".time_str($x)."</a>"; |
|
41 | 41 | } else { |
42 | 42 | return time_str($x); |
43 | 43 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | function location_form($host) { |
47 | 47 | $none = "selected"; |
48 | - $h=$w=$s=$m=""; |
|
48 | + $h = $w = $s = $m = ""; |
|
49 | 49 | if ($host->venue == "home") $h = "selected"; |
50 | 50 | if ($host->venue == "work") $w = "selected"; |
51 | 51 | if ($host->venue == "school") $s = "selected"; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | row2(tra("Product name"), $host->product_name); |
100 | 100 | } |
101 | 101 | $x = $host->timezone/3600; |
102 | - if ($x >= 0) $x="+$x"; |
|
102 | + if ($x >= 0) $x = "+$x"; |
|
103 | 103 | row2(tra("Local Standard Time"), tra("UTC %1 hours", $x)); |
104 | 104 | } else { |
105 | 105 | $owner = BoincUser::lookup_id($host->userid); |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | // "[vbox|5.0.0|1|1]", where now two additional flags give information about |
260 | 260 | // hardware virtualization support. Older clients may have the old-style |
261 | 261 | // serialnum in the DB despite the server being upgraded. |
262 | -function vbox_desc($x){ |
|
263 | - if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/",$x,$matches)){ |
|
262 | +function vbox_desc($x) { |
|
263 | + if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/", $x, $matches)) { |
|
264 | 264 | $desc = "Virtualbox (".$matches[1].") ".tra("installed"); |
265 | - if (sizeof($matches)>2){ |
|
266 | - if ($matches[3]=="1" and $matches[4]=="1") { |
|
265 | + if (sizeof($matches) > 2) { |
|
266 | + if ($matches[3] == "1" and $matches[4] == "1") { |
|
267 | 267 | return $desc.tra(", CPU has hardware virtualization support and it is enabled"); |
268 | - } elseif ($matches[3]=="1" and $matches[4]=="0") { |
|
268 | + } elseif ($matches[3] == "1" and $matches[4] == "0") { |
|
269 | 269 | return $desc.tra(", CPU has hardware virtualization support but it is disabled"); |
270 | - } elseif ($matches[3]=="0") { |
|
270 | + } elseif ($matches[3] == "0") { |
|
271 | 271 | return $desc.tra(", CPU does not have hardware virtualization support"); |
272 | 272 | } |
273 | 273 | } else { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | // Given string of the form [BOINC|vers][type|model|count|RAM|driver-vers][vbox|vers], |
282 | 282 | // return a human-readable version of the GPU info |
283 | 283 | // |
284 | -function gpu_desc($x, $detail=true) { |
|
284 | +function gpu_desc($x, $detail = true) { |
|
285 | 285 | $descs = explode("]", $x); |
286 | 286 | array_pop($descs); |
287 | 287 | $str = ""; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | if ($d[0] == "vbox") continue; |
294 | 294 | if (count($d) < 4) continue; |
295 | 295 | if ($str) $str .= "<p>"; |
296 | - if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] "; |
|
296 | + if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] "; |
|
297 | 297 | if ($d[0] == "CUDA") { |
298 | 298 | $str .= "NVIDIA"; |
299 | 299 | } else if ($d[0] == "CAL") { |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | if ($pos1 === false) return $x; |
501 | 501 | $pos2 = strpos($model, ']'); |
502 | 502 | if ($pos2 === false) return $x; |
503 | - $a = substr($model, $pos1+1, $pos2-$pos1-1); |
|
503 | + $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1); |
|
504 | 504 | $y = explode(" ", $a); |
505 | 505 | if (count($y) == 0) return $x; |
506 | 506 | if ($y[0] == "Family") { |
507 | 507 | $x->info = $a; |
508 | 508 | } else { |
509 | 509 | $x->arch = $y[0]; |
510 | - $x->info = substr($a, strlen($y[0])+1); |
|
510 | + $x->info = substr($a, strlen($y[0]) + 1); |
|
511 | 511 | } |
512 | 512 | return $x; |
513 | 513 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | $avg_time = 0; |
597 | 597 | |
598 | 598 | $results = BoincResult::enum("hostid=$hostid order by received_time"); |
599 | - foreach($results as $result) { |
|
599 | + foreach ($results as $result) { |
|
600 | 600 | if ($result->granted_credit <= 0) continue; |
601 | 601 | $total += $result->granted_credit; |
602 | 602 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | |
690 | 690 | function link_url($sort, $rev, $show_all) { |
691 | 691 | global $userid; |
692 | - $x = $userid ? "&userid=$userid":""; |
|
692 | + $x = $userid ? "&userid=$userid" : ""; |
|
693 | 693 | return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x"; |
694 | 694 | } |
695 | 695 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | } |
764 | 764 | |
765 | 765 | function show_user_hosts($userid, $private, $show_all, $sort, $rev) { |
766 | - $desc = false; // whether the sort order's default is decreasing |
|
766 | + $desc = false; // whether the sort order's default is decreasing |
|
767 | 767 | switch ($sort) { |
768 | 768 | case "total_credit": $sort_clause = "total_credit"; $desc = true; break; |
769 | 769 | case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break; |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | more_or_less($sort, $rev, $show_all); |
787 | 787 | |
788 | 788 | $now = time(); |
789 | - $old_hosts=0; |
|
789 | + $old_hosts = 0; |
|
790 | 790 | $i = 1; |
791 | 791 | $hosts = BoincHost::enum("userid=$userid order by $sort_clause"); |
792 | 792 | $any_product_name = false; |
@@ -798,9 +798,9 @@ discard block |
||
798 | 798 | } |
799 | 799 | user_host_table_start($private, $sort, $rev, $show_all, $any_product_name); |
800 | 800 | foreach ($hosts as $host) { |
801 | - $is_old=false; |
|
801 | + $is_old = false; |
|
802 | 802 | if (($now - $host->rpc_time) > 30*86400) { |
803 | - $is_old=true; |
|
803 | + $is_old = true; |
|
804 | 804 | $old_hosts++; |
805 | 805 | } |
806 | 806 | if (!$show_all && $is_old) continue; |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } |
810 | 810 | end_table(); |
811 | 811 | |
812 | - if ($old_hosts>0) { |
|
812 | + if ($old_hosts > 0) { |
|
813 | 813 | more_or_less($sort, $rev, $show_all); |
814 | 814 | } |
815 | 815 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | db_init(); |
27 | 27 | |
28 | 28 | function current_tally($voteid) { |
29 | - $query="select sum(yes) as ayes,count(id)-sum(yes) as nays from banishment_votes where voteid=".$voteid; |
|
29 | + $query = "select sum(yes) as ayes,count(id)-sum(yes) as nays from banishment_votes where voteid=".$voteid; |
|
30 | 30 | $result = _mysql_query($query); |
31 | 31 | $foobar = _mysql_fetch_object($result); |
32 | 32 | echo "<b>Current Tally</b> Ayes: ".$foobar->ayes." Nays: ".$foobar->nays."<p>"; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | function vote_is_in_progress($userid) { |
37 | 37 | // check whether a vote is already ongoing |
38 | - $now=time(); |
|
39 | - $query="select count(id) as count from banishment_vote where userid=".$userid." and end_time>".$now; |
|
38 | + $now = time(); |
|
39 | + $query = "select count(id) as count from banishment_vote where userid=".$userid." and end_time>".$now; |
|
40 | 40 | $result = _mysql_query($query); |
41 | 41 | if (!$result) { |
42 | 42 | echo "Database error attempting to read banishment_vote table 1.<p>"; |
@@ -51,56 +51,56 @@ discard block |
||
51 | 51 | return $foobar->count; |
52 | 52 | } |
53 | 53 | |
54 | -function start_vote($config,$logged_in_user,$user,$category,$reason) { |
|
55 | - $now=time(); |
|
56 | - $fin=$now+21600; |
|
54 | +function start_vote($config, $logged_in_user, $user, $category, $reason) { |
|
55 | + $now = time(); |
|
56 | + $fin = $now + 21600; |
|
57 | 57 | |
58 | 58 | |
59 | - if ( vote_is_in_progress($user->id) !=0 ) { |
|
59 | + if (vote_is_in_progress($user->id) != 0) { |
|
60 | 60 | echo "A banishment vote is already underway for this user.<p>"; |
61 | 61 | return 0; |
62 | 62 | } |
63 | - $query="insert into banishment_vote (userid,modid,start_time,end_time) values (".$user->id.",".$logged_in_user->id.",".$now.",".$fin.")"; |
|
63 | + $query = "insert into banishment_vote (userid,modid,start_time,end_time) values (".$user->id.",".$logged_in_user->id.",".$now.",".$fin.")"; |
|
64 | 64 | $result = _mysql_query($query); |
65 | 65 | if (!$result) { |
66 | 66 | echo "Database error attempting to insert to banishment_vote table.<p>"; |
67 | 67 | return 0; |
68 | 68 | } |
69 | 69 | |
70 | - $voteid=_mysql_insert_id(); |
|
71 | - $query="insert into banishment_votes (voteid,modid,time,yes) values (". $voteid .",". $logged_in_user->id .",". $now .",1)"; |
|
70 | + $voteid = _mysql_insert_id(); |
|
71 | + $query = "insert into banishment_votes (voteid,modid,time,yes) values (".$voteid.",".$logged_in_user->id.",".$now.",1)"; |
|
72 | 72 | $result = _mysql_query($query); |
73 | 73 | if (!$result) { |
74 | 74 | echo "Database error attempting to insert to banishment_votes table.<p>"; |
75 | 75 | return 0; |
76 | 76 | } |
77 | 77 | |
78 | - $query="update forum_preferences set banished_until=".$fin." where userid=".$user->id; |
|
78 | + $query = "update forum_preferences set banished_until=".$fin." where userid=".$user->id; |
|
79 | 79 | $result = _mysql_query($query); |
80 | 80 | |
81 | 81 | echo "Banishment vote started.<p><p>"; |
82 | 82 | current_tally($voteid); |
83 | - return send_banish_vote_email($user, 86400*14, $reason, $now+21600); |
|
83 | + return send_banish_vote_email($user, 86400*14, $reason, $now + 21600); |
|
84 | 84 | } |
85 | 85 | |
86 | -function vote_yes($config,$logged_in_user,$user) { |
|
87 | - $now=time(); |
|
86 | +function vote_yes($config, $logged_in_user, $user) { |
|
87 | + $now = time(); |
|
88 | 88 | // Check that a vote is underway. |
89 | - if (vote_is_in_progress($user->id)<1) { |
|
89 | + if (vote_is_in_progress($user->id) < 1) { |
|
90 | 90 | echo "No banishment vote is underway for this user.<p><p>"; |
91 | 91 | return 0; |
92 | 92 | } |
93 | 93 | // Find the voteid |
94 | - $query="select id as voteid from banishment_vote where userid=".$user->id." and end_time>".$now; |
|
94 | + $query = "select id as voteid from banishment_vote where userid=".$user->id." and end_time>".$now; |
|
95 | 95 | $result = _mysql_query($query); |
96 | 96 | $foobar = _mysql_fetch_object($result); |
97 | 97 | if (!$foobar) { |
98 | 98 | echo "Database error attempting to read banishment_vote table.<p>"; |
99 | 99 | return 0; |
100 | 100 | } |
101 | - $voteid=$foobar->voteid; |
|
101 | + $voteid = $foobar->voteid; |
|
102 | 102 | // Check whether mod has voted already. |
103 | - $query="select count(id) as count from banishment_votes where voteid=".$voteid." and modid=".$logged_in_user->id; |
|
103 | + $query = "select count(id) as count from banishment_votes where voteid=".$voteid." and modid=".$logged_in_user->id; |
|
104 | 104 | $result = _mysql_query($query); |
105 | 105 | $foobar = _mysql_fetch_object($result); |
106 | 106 | if (!$foobar) { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | return 0; |
114 | 114 | } |
115 | 115 | // insert the vote |
116 | - $query="insert into banishment_votes (voteid,modid,time,yes) values (" . $voteid .",". $logged_in_user->id .",". $now .",1)"; |
|
116 | + $query = "insert into banishment_votes (voteid,modid,time,yes) values (".$voteid.",".$logged_in_user->id.",".$now.",1)"; |
|
117 | 117 | $result = _mysql_query($query); |
118 | 118 | if (!$result) { |
119 | 119 | echo "Database error attempting to insert to banishment_votes table.<p>"; |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | return 1; |
125 | 125 | } |
126 | 126 | |
127 | -function vote_no($config,$logged_in_user,$user) { |
|
127 | +function vote_no($config, $logged_in_user, $user) { |
|
128 | 128 | // Check that a vote is underway. |
129 | - $now=time(); |
|
130 | - if (vote_is_in_progress($user->id)<1) { |
|
129 | + $now = time(); |
|
130 | + if (vote_is_in_progress($user->id) < 1) { |
|
131 | 131 | echo "No banishment vote is underway for this user.<p>"; |
132 | 132 | return 0; |
133 | 133 | } |
134 | 134 | // Find the voteid |
135 | - $query="select id as voteid from banishment_vote where userid=".$user->id." and end_time>".$now; |
|
135 | + $query = "select id as voteid from banishment_vote where userid=".$user->id." and end_time>".$now; |
|
136 | 136 | $result = _mysql_query($query); |
137 | 137 | $foobar = _mysql_fetch_object($result); |
138 | 138 | if (!$foobar) { |
139 | 139 | echo "Database error attempting to read banishment_vote table.<p>"; |
140 | 140 | return 0; |
141 | 141 | } |
142 | - $voteid=$foobar->voteid; |
|
142 | + $voteid = $foobar->voteid; |
|
143 | 143 | // Check whether mod has voted already. |
144 | - $query="select count(id) as count from banishment_votes where voteid=".$voteid ." and modid=".$logged_in_user->id; |
|
144 | + $query = "select count(id) as count from banishment_votes where voteid=".$voteid." and modid=".$logged_in_user->id; |
|
145 | 145 | $result = _mysql_query($query); |
146 | 146 | $foobar = _mysql_fetch_object($result); |
147 | 147 | if (!$foobar) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | return 0; |
155 | 155 | } |
156 | 156 | // insert the vote |
157 | - $query="insert into banishment_votes (voteid,modid,time,yes) values (" . $voteid .",". $logged_in_user->id .",". $now .",0)"; |
|
157 | + $query = "insert into banishment_votes (voteid,modid,time,yes) values (".$voteid.",".$logged_in_user->id.",".$now.",0)"; |
|
158 | 158 | $result = _mysql_query($query); |
159 | 159 | if (!$result) { |
160 | 160 | echo "Database error attempting to insert to banishment_votes table.<p>"; |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | global $app_name,$log; |
32 | 32 | |
33 | 33 | $timestamp = date("Y-m-d H:i",time()); |
34 | - // read the list of template filenames |
|
35 | - // |
|
36 | - $files = file("../../tree_threader_template_files"); |
|
37 | - if ($files === false) { |
|
34 | + // read the list of template filenames |
|
35 | + // |
|
36 | + $files = file("../../tree_threader_template_files"); |
|
37 | + if ($files === false) { |
|
38 | 38 | fwrite($log,"$timestamp\ttemplate file tree_threader_template_files\n"); |
39 | 39 | error("no templates file"); |
40 | 40 | |
41 | 41 | } |
42 | - $njobs = sizeof($files); |
|
43 | - $now = time(); |
|
42 | + $njobs = sizeof($files); |
|
43 | + $now = time(); |
|
44 | 44 | $batch_id = BoincBatch::insert( |
45 | - "(user_id, create_time, njobs, name, app_id, state) values ($user->id, $now, $njobs, 'tree_threader batch', $app->id, ".BATCH_STATE_IN_PROGRESS.")" |
|
45 | + "(user_id, create_time, njobs, name, app_id, state) values ($user->id, $now, $njobs, 'tree_threader batch', $app->id, ".BATCH_STATE_IN_PROGRESS.")" |
|
46 | 46 | ); |
47 | 47 | if (!$batch_id) { |
48 | 48 | $log_msg = "$timestamp\tfailed to create batch for user $user->id\n"; |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | $i = 1; |
71 | - foreach ($files as $file) { |
|
71 | + foreach ($files as $file) { |
|
72 | 72 | $file = trim($file); |
73 | 73 | $wu_name = "ICT_".$batch_id."_$i"; |
74 | 74 | |
75 | - $cmd = "cd ../..; ./bin/create_work --appname $app_name --batch $batch_id --wu_name $wu_name --wu_template templates/ICT_in --result_template templates/ICT_out $seq_fname $file"; |
|
75 | + $cmd = "cd ../..; ./bin/create_work --appname $app_name --batch $batch_id --wu_name $wu_name --wu_template templates/ICT_in --result_template templates/ICT_out $seq_fname $file"; |
|
76 | 76 | fwrite($log, "$timestamp\t$cmd\n"); |
77 | 77 | system($cmd, $ret); |
78 | - if ($ret != 0) { |
|
78 | + if ($ret != 0) { |
|
79 | 79 | fwrite($log, "can not creat job $wu_name\n"); |
80 | - error("can't create job"); |
|
80 | + error("can't create job"); |
|
81 | 81 | } |
82 | 82 | $i++; |
83 | - } |
|
84 | - echo "<tt_reply>\n<batch_id>$batch_id</batch_id>\n</tt_reply>\n"; |
|
83 | + } |
|
84 | + echo "<tt_reply>\n<batch_id>$batch_id</batch_id>\n</tt_reply>\n"; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Enumerate all the successfully completed WUs for this batch. |
@@ -93,51 +93,51 @@ discard block |
||
93 | 93 | function handle_get_output($r, $batch) { |
94 | 94 | global $log; |
95 | 95 | $timestamp = date("Y-m-d H:i",time()); |
96 | - $wus = BoincWorkUnit::enum("batch=$batch->id"); |
|
97 | - $outdir = "/tmp/treeThreader_result_".$batch->id; |
|
96 | + $wus = BoincWorkUnit::enum("batch=$batch->id"); |
|
97 | + $outdir = "/tmp/treeThreader_result_".$batch->id; |
|
98 | 98 | @mkdir($outdir); |
99 | - foreach ($wus as $wu) { |
|
100 | - if (!$wu->canonical_resultid) continue; |
|
101 | - $result = BoincResult::lookup_id($wu->canonical_resultid); |
|
102 | - if (!$result) continue; |
|
103 | - $paths = get_outfile_paths($result); |
|
104 | - if (sizeof($paths) < 1) continue; |
|
105 | - |
|
106 | - // there's only one output file |
|
107 | - // |
|
108 | - $path = $paths[0]; |
|
109 | - |
|
110 | - // unzip it into a directory in /tmp |
|
111 | - // |
|
112 | - $dir = "/tmp/$wu->name"; |
|
99 | + foreach ($wus as $wu) { |
|
100 | + if (!$wu->canonical_resultid) continue; |
|
101 | + $result = BoincResult::lookup_id($wu->canonical_resultid); |
|
102 | + if (!$result) continue; |
|
103 | + $paths = get_outfile_paths($result); |
|
104 | + if (sizeof($paths) < 1) continue; |
|
105 | + |
|
106 | + // there's only one output file |
|
107 | + // |
|
108 | + $path = $paths[0]; |
|
109 | + |
|
110 | + // unzip it into a directory in /tmp |
|
111 | + // |
|
112 | + $dir = "/tmp/$wu->name"; |
|
113 | 113 | @mkdir($dir); |
114 | - $cmd = "cd $dir; unzip -q $path"; |
|
115 | - system($cmd, $ret); |
|
116 | - if ($ret != 0) { |
|
117 | - error("can't unzip output file"); |
|
118 | - } |
|
119 | - $cmd = "cp $dir/Aln/* $outdir"; |
|
120 | - system($cmd, $ret); |
|
121 | - if ($ret != 0) { |
|
122 | - error("can't copy output files"); |
|
123 | - } |
|
114 | + $cmd = "cd $dir; unzip -q $path"; |
|
115 | + system($cmd, $ret); |
|
116 | + if ($ret != 0) { |
|
117 | + error("can't unzip output file"); |
|
118 | + } |
|
119 | + $cmd = "cp $dir/Aln/* $outdir"; |
|
120 | + system($cmd, $ret); |
|
121 | + if ($ret != 0) { |
|
122 | + error("can't copy output files"); |
|
123 | + } |
|
124 | 124 | |
125 | 125 | system("rm -rf $dir"); |
126 | - } |
|
127 | - |
|
128 | - $cmd = "zip -r -q $outdir $outdir"; |
|
129 | - system($cmd, $ret); |
|
130 | - if ($ret != $ret) { |
|
131 | - error("can't zip output files"); |
|
132 | - } |
|
133 | - $fname = "treeThreader_result_".$batch->id.".zip"; |
|
126 | + } |
|
127 | + |
|
128 | + $cmd = "zip -r -q $outdir $outdir"; |
|
129 | + system($cmd, $ret); |
|
130 | + if ($ret != $ret) { |
|
131 | + error("can't zip output files"); |
|
132 | + } |
|
133 | + $fname = "treeThreader_result_".$batch->id.".zip"; |
|
134 | 134 | $treeThreader_dir="treeThreaderResult"; |
135 | 135 | if(!is_dir("../../download/$treeThreader_dir"))mkdir("../../download/$treeThreader_dir"); |
136 | - @symlink("/tmp/$fname", "../../download/$treeThreader_dir/$fname"); |
|
136 | + @symlink("/tmp/$fname", "../../download/$treeThreader_dir/$fname"); |
|
137 | 137 | system("rm -fr $outdir"); |
138 | 138 | $config = simplexml_load_string(file_get_contents("../../config.xml")); |
139 | 139 | $download_url = trim((string)$config->config->download_url); |
140 | - echo "<tt_reply>\n<url>$download_url/$treeThreader_dir/$fname</url>\n</tt_reply>\n"; |
|
140 | + echo "<tt_reply>\n<url>$download_url/$treeThreader_dir/$fname</url>\n</tt_reply>\n"; |
|
141 | 141 | $log_msg="$timestamp\tuser $batch->user_id downloads results for batch $batch->id : $download_url/$treeThreader_dir/$fname\n"; |
142 | 142 | fwrite($log, $log_msg); |
143 | 143 | } |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | handle_submit($r, $user, $app); |
178 | 178 | break; |
179 | 179 | case 'get_output': |
180 | - $batch_id = (int)$r->batch_id; |
|
181 | - $batch = BoincBatch::lookup_id($batch_id); |
|
182 | - if (!$batch) error("no such batch"); |
|
183 | - if ($batch->user_id != $user->id) error("not owner of batch"); |
|
184 | - handle_get_output($r, $batch); |
|
185 | - break; |
|
180 | + $batch_id = (int)$r->batch_id; |
|
181 | + $batch = BoincBatch::lookup_id($batch_id); |
|
182 | + if (!$batch) error("no such batch"); |
|
183 | + if ($batch->user_id != $user->id) error("not owner of batch"); |
|
184 | + handle_get_output($r, $batch); |
|
185 | + break; |
|
186 | 186 | default: error("bad command"); |
187 | 187 | } |
188 | 188 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | display_errors(); |
19 | 19 | |
20 | 20 | $app_name = "treeThreader"; |
21 | -$log = fopen("/tmp/tt_job.log","a+"); |
|
21 | +$log = fopen("/tmp/tt_job.log", "a+"); |
|
22 | 22 | |
23 | 23 | function error($s) { |
24 | 24 | echo "<error>\n<message>$s</message>\n</error>\n"; |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | function handle_submit($r, $user, $app) { |
29 | - global $app_name,$log; |
|
29 | + global $app_name, $log; |
|
30 | 30 | |
31 | - $timestamp = date("Y-m-d H:i",time()); |
|
31 | + $timestamp = date("Y-m-d H:i", time()); |
|
32 | 32 | // read the list of template filenames |
33 | 33 | // |
34 | 34 | $files = file("../../tree_threader_template_files"); |
35 | 35 | if ($files === false) { |
36 | - fwrite($log,"$timestamp\ttemplate file tree_threader_template_files\n"); |
|
36 | + fwrite($log, "$timestamp\ttemplate file tree_threader_template_files\n"); |
|
37 | 37 | error("no templates file"); |
38 | 38 | |
39 | 39 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // |
91 | 91 | function handle_get_output($r, $batch) { |
92 | 92 | global $log; |
93 | - $timestamp = date("Y-m-d H:i",time()); |
|
93 | + $timestamp = date("Y-m-d H:i", time()); |
|
94 | 94 | $wus = BoincWorkUnit::enum("batch=$batch->id"); |
95 | 95 | $outdir = "/tmp/treeThreader_result_".$batch->id; |
96 | 96 | @mkdir($outdir); |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | error("can't zip output files"); |
130 | 130 | } |
131 | 131 | $fname = "treeThreader_result_".$batch->id.".zip"; |
132 | - $treeThreader_dir="treeThreaderResult"; |
|
133 | - if(!is_dir("../../download/$treeThreader_dir"))mkdir("../../download/$treeThreader_dir"); |
|
132 | + $treeThreader_dir = "treeThreaderResult"; |
|
133 | + if (!is_dir("../../download/$treeThreader_dir"))mkdir("../../download/$treeThreader_dir"); |
|
134 | 134 | @symlink("/tmp/$fname", "../../download/$treeThreader_dir/$fname"); |
135 | 135 | system("rm -fr $outdir"); |
136 | 136 | $config = simplexml_load_string(file_get_contents("../../config.xml")); |
137 | 137 | $download_url = trim((string)$config->config->download_url); |
138 | 138 | echo "<tt_reply>\n<url>$download_url/$treeThreader_dir/$fname</url>\n</tt_reply>\n"; |
139 | - $log_msg="$timestamp\tuser $batch->user_id downloads results for batch $batch->id : $download_url/$treeThreader_dir/$fname\n"; |
|
139 | + $log_msg = "$timestamp\tuser $batch->user_id downloads results for batch $batch->id : $download_url/$treeThreader_dir/$fname\n"; |
|
140 | 140 | fwrite($log, $log_msg); |
141 | 141 | } |
142 | 142 |
@@ -25,17 +25,17 @@ |
||
25 | 25 | page_head(tra("Download BOINC add-on software")); |
26 | 26 | echo " |
27 | 27 | <p>" . |
28 | - tra("You can download applications in several categories.") ." |
|
28 | + tra("You can download applications in several categories.")." |
|
29 | 29 | <ul> |
30 | 30 | <li>". |
31 | - tra("These applications are not endorsed by %1 and you use them at your own risk.", PROJECT) ." |
|
31 | + tra("These applications are not endorsed by %1 and you use them at your own risk.", PROJECT)." |
|
32 | 32 | <li>" . |
33 | 33 | tra("We do not provide instructions for installing these applications. |
34 | 34 | However, the author may have provided some help on installing or uninstalling the application. |
35 | 35 | If this is not enough you should contact the author."). |
36 | 36 | tra("Instructions for installing and running BOINC are %1 here %2.", "<a href=https://boinc.berkeley.edu/download.php>", "</a>") |
37 | - . "<li>" . |
|
38 | - tra("This list is managed centrally at %1 the BOINC website %2.", "<a href=\"https://boinc.berkeley.edu/addons.php\">", "</a>") ." |
|
37 | + . "<li>". |
|
38 | + tra("This list is managed centrally at %1 the BOINC website %2.", "<a href=\"https://boinc.berkeley.edu/addons.php\">", "</a>")." |
|
39 | 39 | </ul> |
40 | 40 | "; |
41 | 41 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | // where team includes a field "refcnt". |
32 | 32 | // |
33 | 33 | function merge_lists($list1, &$list2, $weight) { |
34 | - foreach($list1 as $team) { |
|
34 | + foreach ($list1 as $team) { |
|
35 | 35 | $id = $team->id; |
36 | 36 | if (array_key_exists($id, $list2)) { |
37 | 37 | $list2[$id]->refcnt += $weight; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | if (defined("SHOW_NONVALIDATED_TEAMS")) { |
98 | 98 | $user = BoincUser::lookup_id($team->userid); |
99 | 99 | echo "<td>"; |
100 | - echo $user->email_validated?"Yes":"No"; |
|
100 | + echo $user->email_validated ? "Yes" : "No"; |
|
101 | 101 | echo "</td>\n"; |
102 | 102 | } |
103 | 103 | echo " |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | xml_header(); |
138 | 138 | echo "<teams>\n"; |
139 | 139 | sort_list($list); |
140 | - foreach($list as $team) { |
|
140 | + foreach ($list as $team) { |
|
141 | 141 | show_team_xml($team); |
142 | 142 | } |
143 | 143 | echo "</teams>\n"; |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | merge_lists($list2, $list, 3); |
165 | 165 | $tried = true; |
166 | 166 | } |
167 | - if (strlen($params->country) && $params->country!='None') { |
|
167 | + if (strlen($params->country) && $params->country != 'None') { |
|
168 | 168 | $country = BoincDb::escape_string($params->country); |
169 | 169 | $list2 = get_teams("country = '$country'", $params->active); |
170 | 170 | //echo "<br>country matches: ",sizeof($list2); |
171 | 171 | merge_lists($list2, $list, 1); |
172 | 172 | $tried = true; |
173 | 173 | } |
174 | - if ($params->type and $params->type>1) { |
|
174 | + if ($params->type and $params->type > 1) { |
|
175 | 175 | $list2 = get_teams("type=$params->type", $params->active); |
176 | 176 | //echo "<br>type matches: ",sizeof($list2); |
177 | 177 | merge_lists($list2, $list, 2); |
@@ -35,14 +35,14 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | $owner = BoincUser::lookup_id($thread->owner); |
38 | -if ($logged_in_user->id == $owner->id){ |
|
38 | +if ($logged_in_user->id == $owner->id) { |
|
39 | 39 | $action = get_str("action"); |
40 | 40 | if ($action == "set") { |
41 | 41 | $ret = $thread->update("status=1"); |
42 | 42 | } else { |
43 | 43 | $ret = $thread->update("status=0"); |
44 | 44 | } |
45 | - if (!$ret){ |
|
45 | + if (!$ret) { |
|
46 | 46 | error_page("Could not update the status of the thread: ".$thread->id); |
47 | 47 | } |
48 | 48 | } else { |
@@ -35,14 +35,14 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | $owner = BoincUser::lookup_id($thread->owner); |
38 | -if ($logged_in_user->id == $owner->id){ |
|
38 | +if ($logged_in_user->id == $owner->id) { |
|
39 | 39 | $action = get_str("action"); |
40 | 40 | if ($action == "set") { |
41 | 41 | $ret = $thread->update("status=1"); |
42 | 42 | } else { |
43 | 43 | $ret = $thread->update("status=0"); |
44 | 44 | } |
45 | - if (!$ret){ |
|
45 | + if (!$ret) { |
|
46 | 46 | error_page("Could not update the status of the thread: ".$thread->id); |
47 | 47 | } |
48 | 48 | } else { |
@@ -35,7 +35,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -38,8 +38,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -430,7 +430,7 @@ |
||
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'); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | display_errors(); |
19 | 19 | |
20 | -$debug=0; |
|
20 | +$debug = 0; |
|
21 | 21 | |
22 | 22 | // test a LAMMPS job |
23 | 23 | // |
@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | // output: success flag, CPU time per step, est. disk usage per job |
31 | 31 | // |
32 | 32 | function terminate_job($p) { |
33 | - $pstatus=proc_get_status($p); |
|
34 | - $ppid=$pstatus['pid']; |
|
35 | - $ret=`ps -o pid --no-heading --ppid $ppid`; |
|
33 | + $pstatus = proc_get_status($p); |
|
34 | + $ppid = $pstatus['pid']; |
|
35 | + $ret = `ps -o pid --no-heading --ppid $ppid`; |
|
36 | 36 | //echo "parent pid is $ppid\nterninate it\n"; |
37 | 37 | proc_terminate($p); |
38 | 38 | // echo "child process is $ret\n"; |
39 | - $pids=preg_split('/\s+/',$ret); |
|
40 | - foreach($pids as $pid){ |
|
41 | - if(is_numeric($pid)){ |
|
42 | - if($GLOBALS["debug"])echo "killing child process $pid\n"; |
|
43 | - posix_kill($pid,9); |
|
39 | + $pids = preg_split('/\s+/', $ret); |
|
40 | + foreach ($pids as $pid) { |
|
41 | + if (is_numeric($pid)) { |
|
42 | + if ($GLOBALS["debug"])echo "killing child process $pid\n"; |
|
43 | + posix_kill($pid, 9); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
@@ -51,23 +51,23 @@ discard block |
||
51 | 51 | $descs = array(); |
52 | 52 | $pipes = array(); |
53 | 53 | $options = file("cmd_variables"); |
54 | - $options[0] = chop($options[0],"\n"); |
|
54 | + $options[0] = chop($options[0], "\n"); |
|
55 | 55 | $cmd = "../lmp_linux ".$options[0]."&>output"; |
56 | 56 | if ($GLOBALS["debug"]) echo $cmd."<br>"; |
57 | 57 | system("unzip pot_files >/dev/null"); |
58 | 58 | $stime = time(); |
59 | 59 | $p = proc_open("$cmd", $descs, $pipes); |
60 | 60 | while (1) { |
61 | - $ctime=time(); |
|
62 | - if($ctime-$stime >=2 and ! file_exists("log.1")){ |
|
63 | - if($GLOBALS["debug"]) echo "time out "."<br>"; |
|
61 | + $ctime = time(); |
|
62 | + if ($ctime - $stime >= 2 and !file_exists("log.1")) { |
|
63 | + if ($GLOBALS["debug"]) echo "time out "."<br>"; |
|
64 | 64 | terminate_job($p); |
65 | 65 | break; |
66 | 66 | } |
67 | 67 | if (file_exists("log.1")) { |
68 | 68 | list($avg_cpu, $test_steps) = calc_step_cpu("log.1"); |
69 | 69 | if ($avg_cpu != 0) { |
70 | - if($GLOBALS["debug"])echo "avg_cpu is ".$avg_cpu."<br>"; |
|
70 | + if ($GLOBALS["debug"])echo "avg_cpu is ".$avg_cpu."<br>"; |
|
71 | 71 | terminate_job($p); |
72 | 72 | $test_result = 1; |
73 | 73 | break; |
@@ -86,32 +86,32 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | function get_total_steps($cmd_file) { |
89 | - $fd = fopen($cmd_file,"r"); |
|
89 | + $fd = fopen($cmd_file, "r"); |
|
90 | 90 | if (!$fd) { |
91 | 91 | echo "can not open file $cmd_file\n"; |
92 | 92 | exit(-1); |
93 | 93 | } |
94 | 94 | $this_loopno = 1; |
95 | 95 | $this_looprun = 1; |
96 | - $total_steps=1; |
|
96 | + $total_steps = 1; |
|
97 | 97 | while (!feof($fd)) { |
98 | - $line = fgets($fd,4096); |
|
98 | + $line = fgets($fd, 4096); |
|
99 | 99 | if (preg_match("/loopnumber\s+\d+/", $line, $matches) |
100 | 100 | && preg_match("/\d+/", $matches[0], $no) |
101 | 101 | ) { |
102 | - $this_loopno=$no[0]; |
|
102 | + $this_loopno = $no[0]; |
|
103 | 103 | } |
104 | 104 | if (preg_match("/looprun\s+\d+/", $line, $matches) |
105 | 105 | and preg_match("/\d+/", $matches[0], $no) |
106 | 106 | ) { |
107 | - $this_looprun=$no[0]; |
|
108 | - if($this_loopno*$this_looprun>$total_steps)$total_steps=$this_loopno*$this_looprun; |
|
107 | + $this_looprun = $no[0]; |
|
108 | + if ($this_loopno*$this_looprun > $total_steps)$total_steps = $this_loopno*$this_looprun; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } |
112 | 112 | fclose($fd); |
113 | 113 | //$total_steps = $loopno*$looprun; |
114 | - if($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>"; |
|
114 | + if ($GLOBALS["debug"])print "total_steps = ".$total_steps."<br>"; |
|
115 | 115 | return $total_steps; |
116 | 116 | } |
117 | 117 | |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | } |
130 | 130 | $count = 0; |
131 | 131 | while (!feof($fd)) { |
132 | - $line = fgets($fd,4096); |
|
133 | - if (preg_match('/^Step\s+CPU/',$line)) { |
|
132 | + $line = fgets($fd, 4096); |
|
133 | + if (preg_match('/^Step\s+CPU/', $line)) { |
|
134 | 134 | //echo $line."\n"; |
135 | 135 | $start = 1; |
136 | 136 | continue; |
@@ -139,24 +139,24 @@ discard block |
||
139 | 139 | $arr = preg_split("/\s+/", $line); |
140 | 140 | //print_r($arr); |
141 | 141 | |
142 | - if (count($arr) <=6 || !is_numeric($arr[1])) { |
|
142 | + if (count($arr) <= 6 || !is_numeric($arr[1])) { |
|
143 | 143 | continue; |
144 | 144 | } |
145 | 145 | $step = (int)$arr[1]; |
146 | 146 | $cpu = (float)$arr[2]; |
147 | 147 | //echo "step=".$step." cpu=".$cpu."\n"; |
148 | - if ($cpu==0) { |
|
149 | - $count=0; |
|
148 | + if ($cpu == 0) { |
|
149 | + $count = 0; |
|
150 | 150 | $start_step = $step; |
151 | 151 | } else { |
152 | - $count+=1; |
|
153 | - if($GLOBALS["debug"])echo "step=".$step." cpu=".$cpu."count=".$count."<br>"; |
|
154 | - if($count >= 10) { |
|
152 | + $count += 1; |
|
153 | + if ($GLOBALS["debug"])echo "step=".$step." cpu=".$cpu."count=".$count."<br>"; |
|
154 | + if ($count >= 10) { |
|
155 | 155 | $end_step = $step; |
156 | - $steps = $end_step-$start_step; |
|
156 | + $steps = $end_step - $start_step; |
|
157 | 157 | $avg_cpu = $cpu/$steps; |
158 | 158 | #$avg_cpu = $cpu/$count; |
159 | - if ($GLOBALS["debug"]){ |
|
159 | + if ($GLOBALS["debug"]) { |
|
160 | 160 | echo "test steps is ".$steps."<br>"; |
161 | 161 | echo "avg_cpu is ".$avg_cpu."<br>"; |
162 | 162 | } |
@@ -165,56 +165,56 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
168 | - return array($avg_cpu,$test_steps); |
|
168 | + return array($avg_cpu, $test_steps); |
|
169 | 169 | } |
170 | 170 | |
171 | -function calc_est_size($lammps_script, $structure_file, $cmd_file,$test_steps){ |
|
171 | +function calc_est_size($lammps_script, $structure_file, $cmd_file, $test_steps) { |
|
172 | 172 | $dump_types = 0; |
173 | - $fd = fopen($lammps_script,"r"); |
|
174 | - if (!$fd){ |
|
173 | + $fd = fopen($lammps_script, "r"); |
|
174 | + if (!$fd) { |
|
175 | 175 | echo "can not open file $lammps_script\n"; |
176 | 176 | exit(-1); |
177 | 177 | } |
178 | - while (!feof($fd)){ |
|
178 | + while (!feof($fd)) { |
|
179 | 179 | $line = fgets($fd, 4096); |
180 | 180 | //if (preg_match("/^\s*dump/", $line) |
181 | 181 | // and preg_match_all("/dump\S+\.\w{3}/", $line, $matches, PREG_PATTERN_ORDER)) |
182 | 182 | |
183 | - if(preg_match("/^\s*dump\s+(\d)\s+/", $line,$matches)) |
|
183 | + if (preg_match("/^\s*dump\s+(\d)\s+/", $line, $matches)) |
|
184 | 184 | { |
185 | - if($GLOBALS["debug"]){print "matches=";print_r($matches);} |
|
185 | + if ($GLOBALS["debug"]) {print "matches="; print_r($matches); } |
|
186 | 186 | |
187 | - $dump_types=(int)$matches[1]; |
|
187 | + $dump_types = (int)$matches[1]; |
|
188 | 188 | break; |
189 | 189 | } |
190 | 190 | } |
191 | 191 | fclose($fd); |
192 | - if($GLOBALS["debug"])print "dump_types= ".$dump_types."<br>"; |
|
192 | + if ($GLOBALS["debug"])print "dump_types= ".$dump_types."<br>"; |
|
193 | 193 | |
194 | 194 | $structure_file_size = filesize($structure_file); |
195 | - $fd = fopen($cmd_file,"r"); |
|
196 | - if (!$fd){ |
|
195 | + $fd = fopen($cmd_file, "r"); |
|
196 | + if (!$fd) { |
|
197 | 197 | echo "can not open file $cmd_file\n"; |
198 | 198 | exit(-1); |
199 | 199 | } |
200 | - if($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>"; |
|
201 | - |
|
202 | - $loopno=1; |
|
203 | - $looprun=1; |
|
204 | - while (!feof($fd)){ |
|
205 | - $line = fgets($fd,4096); |
|
206 | - if(preg_match("/loopnumber\s+\d+/", $line, $matches)){ |
|
207 | - if(preg_match("/\d+/", $matches[0], $no)){ |
|
200 | + if ($GLOBALS["debug"]) print "structure_file_size=".$structure_file_size."<br>"; |
|
201 | + |
|
202 | + $loopno = 1; |
|
203 | + $looprun = 1; |
|
204 | + while (!feof($fd)) { |
|
205 | + $line = fgets($fd, 4096); |
|
206 | + if (preg_match("/loopnumber\s+\d+/", $line, $matches)) { |
|
207 | + if (preg_match("/\d+/", $matches[0], $no)) { |
|
208 | 208 | //$loopno=$no[0]; |
209 | - if($no[0]>$loopno)$loopno=$no[0]; |
|
209 | + if ($no[0] > $loopno)$loopno = $no[0]; |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | if (preg_match("/looprun\s+\d+/", $line, $matches) and preg_match("/\d+/", $matches[0], $no)) { |
213 | - if($no[0]>$looprun)$looprun=$no[0]; |
|
213 | + if ($no[0] > $looprun)$looprun = $no[0]; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | fclose($fd); |
217 | - if($GLOBALS["debug"]){ |
|
217 | + if ($GLOBALS["debug"]) { |
|
218 | 218 | print "max loopno(number of loops to run)=".$loopno."<br>"; |
219 | 219 | print "max looprun(steps for each loop)=".$looprun."<br>"; |
220 | 220 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | $dump_files = glob("dump1*"); |
226 | 226 | $test_dump_file = $dump_files[0]; |
227 | 227 | $test_dump_size = filesize($test_dump_file); |
228 | - $dump_size1 = $test_dump_size+0.5*$test_dump_size*ceil(($looprun-$test_steps)/$test_steps); |
|
228 | + $dump_size1 = $test_dump_size + 0.5*$test_dump_size*ceil(($looprun - $test_steps)/$test_steps); |
|
229 | 229 | $dump_size = $loopno*$dump_size1*$dump_types; |
230 | 230 | $app_fixed_size = 5e7; |
231 | - $est_size = $log_size+$dump_size+$app_fixed_size; |
|
231 | + $est_size = $log_size + $dump_size + $app_fixed_size; |
|
232 | 232 | |
233 | - if($GLOBALS["debug"]){ |
|
233 | + if ($GLOBALS["debug"]) { |
|
234 | 234 | print "test_steps=".$test_steps."<br>"; |
235 | 235 | print "test_log_size=".$test_log_size."<br>"; |
236 | 236 | print "log_size1=".$log_size1."<br>"; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | if ($njobs < $nhosts) { |
322 | 322 | return $flops_per_job/$median_flops; |
323 | 323 | } else { |
324 | - $k = (int)(($njobs+$nhosts-1)/$nhosts); |
|
324 | + $k = (int)(($njobs + $nhosts - 1)/$nhosts); |
|
325 | 325 | return $k*$flops_per_job/$median_flops; |
326 | 326 | } |
327 | 327 | } |
@@ -361,27 +361,27 @@ discard block |
||
361 | 361 | if ($GLOBALS["debug"]) { |
362 | 362 | print "est_cpu_time is ".$est_cpu_time."<br>"; |
363 | 363 | } |
364 | - if ($error==0) { |
|
365 | - $err_msgs=file("output"); |
|
366 | - $err="Your test job <strong>failed</strong> |
|
364 | + if ($error == 0) { |
|
365 | + $err_msgs = file("output"); |
|
366 | + $err = "Your test job <strong>failed</strong> |
|
367 | 367 | <br>Please refer to the following Error Message:<br><p> |
368 | 368 | "; |
369 | - foreach($err_msgs as $line){ |
|
370 | - $err=$err.$line."<br>"; |
|
369 | + foreach ($err_msgs as $line) { |
|
370 | + $err = $err.$line."<br>"; |
|
371 | 371 | } |
372 | - $err=$err." <p> |
|
372 | + $err = $err." <p> |
|
373 | 373 | <a href=sandbox.php><strong> File_Sandbox </strong></a> |
374 | 374 | "; |
375 | 375 | error_page($err); |
376 | 376 | } |
377 | 377 | |
378 | 378 | system("rm *"); |
379 | - $info->rsc_fpops_est = $est_cpu_time * 1.5e9; |
|
380 | - $info->rsc_fpops_bound = $info->rsc_fpops_est * 20; |
|
379 | + $info->rsc_fpops_est = $est_cpu_time*1.5e9; |
|
380 | + $info->rsc_fpops_bound = $info->rsc_fpops_est*20; |
|
381 | 381 | |
382 | - if ($disk==0){ |
|
383 | - $info->rsc_disk_bound=1000000; |
|
384 | - } else{ |
|
382 | + if ($disk == 0) { |
|
383 | + $info->rsc_disk_bound = 1000000; |
|
384 | + } else { |
|
385 | 385 | $info->rsc_disk_bound = $disk; |
386 | 386 | } |
387 | 387 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | // |
393 | 393 | $njobs = count(file($cmdline_file_path)); |
394 | 394 | $secs_est = estimated_makespan($njobs, $info->rsc_fpops_est); |
395 | - if($GLOBALS["debug"])echo "secs_est is $secs_est\n"; |
|
395 | + if ($GLOBALS["debug"])echo "secs_est is $secs_est\n"; |
|
396 | 396 | //assume the server's flops is 1.5G and the average client's flops is 1G |
397 | 397 | $hrs_est = number_format($secs_est*1.5/60, 2); |
398 | 398 | //$hrs_est = number_format($secs_est, 2); |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | function submit_job($app, $batch_id, $info, $cmdline, $i) { |
419 | - $client_disk=$info->rsc_disk_bound*2; |
|
420 | - if($client_disk<500000000) $client_disk=500000000; |
|
419 | + $client_disk = $info->rsc_disk_bound*2; |
|
420 | + if ($client_disk < 500000000) $client_disk = 500000000; |
|
421 | 421 | $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"; |
422 | 422 | if ($cmdline) { |
423 | 423 | $cmd .= " --command_line \"$cmdline\""; |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | $x = file_get_contents("$tmpfile"); |
442 | 442 | $info = unserialize($x); |
443 | 443 | |
444 | - $njobs=0; |
|
444 | + $njobs = 0; |
|
445 | 445 | $cmdlines = file($info->cmdline_file_path); |
446 | - foreach ($cmdlines as $cmdline){ |
|
446 | + foreach ($cmdlines as $cmdline) { |
|
447 | 447 | if (preg_match("/^\s*-var/", $cmdline)) { |
448 | 448 | $njobs++; |
449 | 449 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | |
460 | 460 | $i = 0; |
461 | 461 | foreach ($cmdlines as $cmdline) { |
462 | - if (preg_match("/^\s*-var/", $cmdline)){ |
|
462 | + if (preg_match("/^\s*-var/", $cmdline)) { |
|
463 | 463 | submit_job($app, $batch_id, $info, $cmdline, $i); |
464 | 464 | $i++; |
465 | 465 | } |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | } |
40 | 40 | $format = get_str("format", true); |
41 | 41 | |
42 | -if ($format=="xml"){ |
|
42 | +if ($format=="xml") { |
|
43 | 43 | // don't do caching for XML |
44 | 44 | xml_header(); |
45 | 45 | $retval = db_init_xml(); |
46 | 46 | if ($retval) xml_error($retval); |
47 | - if ($auth){ |
|
47 | + if ($auth) { |
|
48 | 48 | $user = BoincUser::lookup_auth($auth); |
49 | 49 | $show_hosts = true; |
50 | 50 | } else { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | // |
61 | 61 | $cache_args="userid=".$id; |
62 | 62 | $cached_data = get_cached_data(USER_PAGE_TTL, $cache_args); |
63 | - if ($cached_data){ |
|
63 | + if ($cached_data) { |
|
64 | 64 | // We found some old but non-stale data, let's use it |
65 | 65 | $data = unserialize($cached_data); |
66 | 66 | $user = $data->user; |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | } |
39 | 39 | $format = get_str("format", true); |
40 | 40 | |
41 | -if ($format=="xml"){ |
|
41 | +if ($format == "xml") { |
|
42 | 42 | // don't do caching for XML |
43 | 43 | xml_header(); |
44 | 44 | $retval = db_init_xml(); |
45 | 45 | if ($retval) xml_error($retval); |
46 | - if ($auth){ |
|
46 | + if ($auth) { |
|
47 | 47 | $user = BoincUser::lookup_auth($auth); |
48 | 48 | $show_hosts = true; |
49 | 49 | } else { |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | // The page may be presented in many different languages, |
58 | 58 | // so here we cache the data instead |
59 | 59 | // |
60 | - $cache_args="userid=".$id; |
|
60 | + $cache_args = "userid=".$id; |
|
61 | 61 | $cached_data = get_cached_data(USER_PAGE_TTL, $cache_args); |
62 | - if ($cached_data){ |
|
62 | + if ($cached_data) { |
|
63 | 63 | // We found some old but non-stale data, let's use it |
64 | 64 | $data = unserialize($cached_data); |
65 | 65 | $user = $data->user; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | BoincForumPrefs::lookup($user); |
77 | 77 | $user = @get_other_projects($user); |
78 | - $community_links = get_community_links_object($user); |
|
78 | + $community_links = get_community_links_object($user); |
|
79 | 79 | |
80 | 80 | $data = new StdClass; |
81 | 81 | $data->user = $user; |