@@ -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 | } |
@@ -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 |
@@ -27,74 +27,74 @@ |
||
27 | 27 | define('BATCH_STATE_RETIRED', 4); |
28 | 28 | |
29 | 29 | define('ANON_PLATFORM_UNKNOWN', -1); |
30 | -define('ANON_PLATFORM_CPU', -2); |
|
31 | -define('ANON_PLATFORM_NVIDIA', -3); |
|
32 | -define('ANON_PLATFORM_ATI', -4); |
|
33 | -define('ANON_PLATFORM_INTEL_GPU', -5); |
|
34 | -define('ANON_PLATFORM_APPLE_GPU', -6); |
|
30 | +define('ANON_PLATFORM_CPU', -2); |
|
31 | +define('ANON_PLATFORM_NVIDIA', -3); |
|
32 | +define('ANON_PLATFORM_ATI', -4); |
|
33 | +define('ANON_PLATFORM_INTEL_GPU', -5); |
|
34 | +define('ANON_PLATFORM_APPLE_GPU', -6); |
|
35 | 35 | |
36 | -define('RESULT_SERVER_STATE_INACTIVE', 1); |
|
37 | -define('RESULT_SERVER_STATE_UNSENT', 2); |
|
38 | -define('RESULT_SERVER_STATE_IN_PROGRESS', 4); |
|
39 | -define('RESULT_SERVER_STATE_OVER', 5); |
|
36 | +define('RESULT_SERVER_STATE_INACTIVE', 1); |
|
37 | +define('RESULT_SERVER_STATE_UNSENT', 2); |
|
38 | +define('RESULT_SERVER_STATE_IN_PROGRESS', 4); |
|
39 | +define('RESULT_SERVER_STATE_OVER', 5); |
|
40 | 40 | |
41 | -define('RESULT_OUTCOME_INIT', 0); |
|
42 | -define('RESULT_OUTCOME_SUCCESS', 1); |
|
43 | -define('RESULT_OUTCOME_COULDNT_SEND', 2); |
|
44 | -define('RESULT_OUTCOME_CLIENT_ERROR', 3); |
|
45 | -define('RESULT_OUTCOME_NO_REPLY', 4); |
|
46 | -define('RESULT_OUTCOME_DIDNT_NEED', 5); |
|
47 | -define('RESULT_OUTCOME_VALIDATE_ERROR', 6); |
|
48 | -define('RESULT_OUTCOME_CLIENT_DETACHED', 7); |
|
41 | +define('RESULT_OUTCOME_INIT', 0); |
|
42 | +define('RESULT_OUTCOME_SUCCESS', 1); |
|
43 | +define('RESULT_OUTCOME_COULDNT_SEND', 2); |
|
44 | +define('RESULT_OUTCOME_CLIENT_ERROR', 3); |
|
45 | +define('RESULT_OUTCOME_NO_REPLY', 4); |
|
46 | +define('RESULT_OUTCOME_DIDNT_NEED', 5); |
|
47 | +define('RESULT_OUTCOME_VALIDATE_ERROR', 6); |
|
48 | +define('RESULT_OUTCOME_CLIENT_DETACHED', 7); |
|
49 | 49 | |
50 | -define('VALIDATE_STATE_INIT', 0); |
|
51 | -define('VALIDATE_STATE_VALID', 1); |
|
52 | -define('VALIDATE_STATE_INVALID', 2); |
|
53 | -define('VALIDATE_STATE_NO_CHECK', 3); |
|
54 | -define('VALIDATE_STATE_INCONCLUSIVE',4); |
|
55 | -define('VALIDATE_STATE_TOO_LATE', 5); |
|
50 | +define('VALIDATE_STATE_INIT', 0); |
|
51 | +define('VALIDATE_STATE_VALID', 1); |
|
52 | +define('VALIDATE_STATE_INVALID', 2); |
|
53 | +define('VALIDATE_STATE_NO_CHECK', 3); |
|
54 | +define('VALIDATE_STATE_INCONCLUSIVE', 4); |
|
55 | +define('VALIDATE_STATE_TOO_LATE', 5); |
|
56 | 56 | |
57 | -define('WU_ERROR_COULDNT_SEND_RESULT', 1); |
|
58 | -define('WU_ERROR_TOO_MANY_ERROR_RESULTS', 2); |
|
59 | -define('WU_ERROR_TOO_MANY_SUCCESS_RESULTS', 4); |
|
60 | -define('WU_ERROR_TOO_MANY_TOTAL_RESULTS', 8); |
|
61 | -define('WU_ERROR_CANCELLED', 16); |
|
62 | -define('WU_ERROR_NO_CANONICAL_RESULT', 32); |
|
57 | +define('WU_ERROR_COULDNT_SEND_RESULT', 1); |
|
58 | +define('WU_ERROR_TOO_MANY_ERROR_RESULTS', 2); |
|
59 | +define('WU_ERROR_TOO_MANY_SUCCESS_RESULTS', 4); |
|
60 | +define('WU_ERROR_TOO_MANY_TOTAL_RESULTS', 8); |
|
61 | +define('WU_ERROR_CANCELLED', 16); |
|
62 | +define('WU_ERROR_NO_CANONICAL_RESULT', 32); |
|
63 | 63 | |
64 | -define('FILE_DELETE_INIT', 0); |
|
65 | -define('FILE_DELETE_READY', 1); |
|
66 | -define('FILE_DELETE_DONE', 2); |
|
67 | -define('FILE_DELETE_ERROR', 3); |
|
64 | +define('FILE_DELETE_INIT', 0); |
|
65 | +define('FILE_DELETE_READY', 1); |
|
66 | +define('FILE_DELETE_DONE', 2); |
|
67 | +define('FILE_DELETE_ERROR', 3); |
|
68 | 68 | |
69 | -define('ASSIMILATE_INIT', 0); |
|
70 | -define('ASSIMILATE_READY', 1); |
|
71 | -define('ASSIMILATE_DONE', 2); |
|
69 | +define('ASSIMILATE_INIT', 0); |
|
70 | +define('ASSIMILATE_READY', 1); |
|
71 | +define('ASSIMILATE_DONE', 2); |
|
72 | 72 | |
73 | 73 | // from lib/common_defs.h |
74 | 74 | // |
75 | -define('RESULT_NEW', 0); |
|
76 | -define('RESULT_FILES_DOWNLOADING', 1); |
|
77 | -define('RESULT_FILES_DOWNLOADED', 2); |
|
78 | -define('RESULT_COMPUTE_ERROR', 3); |
|
79 | -define('RESULT_FILES_UPLOADING', 4); |
|
80 | -define('RESULT_FILES_UPLOADED', 5); |
|
81 | -define('RESULT_ABORTED', 6); |
|
82 | -define('RESULT_UPLOAD_FAILED', 7); |
|
75 | +define('RESULT_NEW', 0); |
|
76 | +define('RESULT_FILES_DOWNLOADING', 1); |
|
77 | +define('RESULT_FILES_DOWNLOADED', 2); |
|
78 | +define('RESULT_COMPUTE_ERROR', 3); |
|
79 | +define('RESULT_FILES_UPLOADING', 4); |
|
80 | +define('RESULT_FILES_UPLOADED', 5); |
|
81 | +define('RESULT_ABORTED', 6); |
|
82 | +define('RESULT_UPLOAD_FAILED', 7); |
|
83 | 83 | |
84 | 84 | // from lib/error_numbers.h |
85 | 85 | // returned by some web RPCs |
86 | 86 | // |
87 | -define('ERR_XML_PARSE', -112); |
|
88 | -define('ERR_DB_NOT_FOUND', -136); |
|
89 | -define('ERR_DB_NOT_UNIQUE', -137); |
|
90 | -define('ERR_DB_CANT_CONNECT', -138); |
|
91 | -define('ERR_PROJECT_DOWN', -183); |
|
92 | -define('ERR_BAD_USER_NAME', -188); |
|
93 | -define('ERR_NO_OPTION', -191); |
|
94 | -define('ERR_BAD_EMAIL_ADDR', -205); |
|
95 | -define('ERR_BAD_PASSWD', -206); |
|
96 | -define('ERR_ACCT_CREATION_DISABLED', -208); |
|
97 | -define('ERR_ATTACH_FAIL_INIT', -209); |
|
98 | -define('ERR_ATTACH_FAIL_DOWNLOAD', -210); |
|
99 | -define('ERR_ACCT_REQUIRE_CONSENT', -242); |
|
87 | +define('ERR_XML_PARSE', -112); |
|
88 | +define('ERR_DB_NOT_FOUND', -136); |
|
89 | +define('ERR_DB_NOT_UNIQUE', -137); |
|
90 | +define('ERR_DB_CANT_CONNECT', -138); |
|
91 | +define('ERR_PROJECT_DOWN', -183); |
|
92 | +define('ERR_BAD_USER_NAME', -188); |
|
93 | +define('ERR_NO_OPTION', -191); |
|
94 | +define('ERR_BAD_EMAIL_ADDR', -205); |
|
95 | +define('ERR_BAD_PASSWD', -206); |
|
96 | +define('ERR_ACCT_CREATION_DISABLED', -208); |
|
97 | +define('ERR_ATTACH_FAIL_INIT', -209); |
|
98 | +define('ERR_ATTACH_FAIL_DOWNLOAD', -210); |
|
99 | +define('ERR_ACCT_REQUIRE_CONSENT', -242); |
|
100 | 100 | ?> |
@@ -34,26 +34,26 @@ |
||
34 | 34 | $intel_gpu_credit_sum = 0; |
35 | 35 | $apple_gpu_scale_sum = 0; |
36 | 36 | $apple_gpu_credit_sum = 0; |
37 | -$total_credit_sum= 0; |
|
37 | +$total_credit_sum = 0; |
|
38 | 38 | |
39 | 39 | $apps = BoincApp::enum("deprecated=0"); |
40 | 40 | foreach ($apps as $app) { |
41 | 41 | $avs = BoincAppVersion::enum("appid=$app->id and deprecated=0"); |
42 | 42 | foreach ($avs as $av) { |
43 | 43 | if (strstr($av->plan_class, "ati")) { |
44 | - $ati_scale_sum += $av->pfc_scale * $av->expavg_credit; |
|
44 | + $ati_scale_sum += $av->pfc_scale*$av->expavg_credit; |
|
45 | 45 | $ati_credit_sum += $av->expavg_credit; |
46 | 46 | } else if (strstr($av->plan_class, "nvidia") || strstr($av->plan_class, "cuda")) { |
47 | - $nvidia_scale_sum += $av->pfc_scale * $av->expavg_credit; |
|
47 | + $nvidia_scale_sum += $av->pfc_scale*$av->expavg_credit; |
|
48 | 48 | $nvidia_credit_sum += $av->expavg_credit; |
49 | 49 | } else if (strstr($av->plan_class, "intel_gpu")) { |
50 | - $intel_gpu_scale_sum += $av->pfc_scale * $av->expavg_credit; |
|
50 | + $intel_gpu_scale_sum += $av->pfc_scale*$av->expavg_credit; |
|
51 | 51 | $intel_gpu_credit_sum += $av->expavg_credit; |
52 | 52 | } else if (strstr($av->plan_class, "apple_gpu")) { |
53 | - $apple_gpu_scale_sum += $av->pfc_scale * $av->expavg_credit; |
|
53 | + $apple_gpu_scale_sum += $av->pfc_scale*$av->expavg_credit; |
|
54 | 54 | $apple_gpu_credit_sum += $av->expavg_credit; |
55 | 55 | } else { |
56 | - $cpu_scale_sum += $av->pfc_scale * $av->expavg_credit; |
|
56 | + $cpu_scale_sum += $av->pfc_scale*$av->expavg_credit; |
|
57 | 57 | $cpu_credit_sum += $av->expavg_credit; |
58 | 58 | } |
59 | 59 | $total_credit_sum += $av->expavg_credit; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | } |
30 | 30 | BoincForumPrefs::lookup($user); |
31 | 31 | |
32 | -if (post_str("action", true)=="reset_confirm"){ |
|
32 | +if (post_str("action", true) == "reset_confirm") { |
|
33 | 33 | page_head(tra("Confirm reset")); |
34 | 34 | echo tra("This action will erase any changes you have made in your community preferences. To cancel, click your browser's Back button.")." |
35 | 35 | <p> |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | // If the user has requested a reset of preferences; |
46 | 46 | // preserve a few fields. |
47 | 47 | // |
48 | -if (post_str("action", true)=="reset"){ |
|
48 | +if (post_str("action", true) == "reset") { |
|
49 | 49 | $posts = $user->prefs->posts; |
50 | 50 | $last_post = $user->prefs->last_post; |
51 | 51 | $rated_posts = $user->prefs->rated_posts; |
@@ -67,30 +67,30 @@ discard block |
||
67 | 67 | if (!DISABLE_FORUMS) { |
68 | 68 | |
69 | 69 | $avatar_type = post_int("avatar_select"); |
70 | -$newfile=IMAGE_PATH.$user->id."_avatar.jpg"; |
|
70 | +$newfile = IMAGE_PATH.$user->id."_avatar.jpg"; |
|
71 | 71 | |
72 | 72 | // Update the user avatar |
73 | -if ($avatar_type<0 or $avatar_type>3) $avatar_type=0; |
|
74 | -if ($avatar_type==0){ |
|
75 | - if (file_exists($newfile)){ |
|
73 | +if ($avatar_type < 0 or $avatar_type > 3) $avatar_type = 0; |
|
74 | +if ($avatar_type == 0) { |
|
75 | + if (file_exists($newfile)) { |
|
76 | 76 | // Delete the file on the server if the user |
77 | 77 | // decides not to use an avatar |
78 | 78 | // |
79 | 79 | unlink($newfile); |
80 | 80 | } |
81 | - $avatar_url=""; |
|
81 | + $avatar_url = ""; |
|
82 | 82 | } elseif ($avatar_type == 1) { |
83 | 83 | $avatar_url = "//www.gravatar.com/avatar/".md5($user->email_addr)."?s=100&d=identicon"; |
84 | -} elseif ($avatar_type==2){ |
|
85 | - if (($rpc && (post_str("avatar_url", true) != null)) || ($_FILES['picture']['tmp_name']!="")) { |
|
86 | - if ($_FILES['picture']['tmp_name']!="") { |
|
84 | +} elseif ($avatar_type == 2) { |
|
85 | + if (($rpc && (post_str("avatar_url", true) != null)) || ($_FILES['picture']['tmp_name'] != "")) { |
|
86 | + if ($_FILES['picture']['tmp_name'] != "") { |
|
87 | 87 | $file = $_FILES['picture']['tmp_name']; |
88 | 88 | } else { |
89 | 89 | // Remote image. Download and store locally |
90 | 90 | $file = post_str("avatar_url"); |
91 | 91 | } |
92 | 92 | $size = getImageSize($file); |
93 | - if ($size[2]!=2 and $size[2]!=3){ |
|
93 | + if ($size[2] != 2 and $size[2] != 3) { |
|
94 | 94 | //Not the right kind of file |
95 | 95 | error_page(tra("Error: Not the right kind of file, only PNG and JPEG are supported.")); |
96 | 96 | } |
@@ -99,30 +99,30 @@ discard block |
||
99 | 99 | $image2 = intelligently_scale_image($file, 100, 100); |
100 | 100 | ImageJPEG($image2, $newfile); |
101 | 101 | } |
102 | - if (file_exists($newfile)){ |
|
103 | - $avatar_url=IMAGE_URL.$user->id."_avatar.jpg"; //$newfile; |
|
102 | + if (file_exists($newfile)) { |
|
103 | + $avatar_url = IMAGE_URL.$user->id."_avatar.jpg"; //$newfile; |
|
104 | 104 | } else { |
105 | 105 | //User didn't upload a compatible file or it went lost on the server |
106 | - $avatar_url=""; |
|
106 | + $avatar_url = ""; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | -$images_as_links = (isset($_POST["forum_images_as_links"]) && $_POST["forum_images_as_links"]!="")?1:0; |
|
111 | -$link_popup = (isset($_POST["forum_link_popup"]) && $_POST["forum_link_popup"]!="")?1:0; |
|
112 | -$hide_avatars = (isset($_POST["forum_hide_avatars"]) && $_POST["forum_hide_avatars"]!="")?1:0; |
|
113 | -$hide_signatures = (isset($_POST["forum_hide_signatures"]) && $_POST["forum_hide_signatures"]!="")?1:0; |
|
114 | -$highlight_special = (isset($_POST["forum_highlight_special"]) && $_POST["forum_highlight_special"]!="")?1:0; |
|
115 | -$jump_to_unread = (isset($_POST["forum_jump_to_unread"]) && $_POST["forum_jump_to_unread"]!="")?1:0; |
|
116 | -$ignore_sticky_posts = (isset($_POST["forum_ignore_sticky_posts"]) && $_POST["forum_ignore_sticky_posts"]!="")?1:0; |
|
117 | -$no_signature_by_default = (isset($_POST["signature_by_default"]) && $_POST["signature_by_default"]!="")?0:1; |
|
110 | +$images_as_links = (isset($_POST["forum_images_as_links"]) && $_POST["forum_images_as_links"] != "") ? 1 : 0; |
|
111 | +$link_popup = (isset($_POST["forum_link_popup"]) && $_POST["forum_link_popup"] != "") ? 1 : 0; |
|
112 | +$hide_avatars = (isset($_POST["forum_hide_avatars"]) && $_POST["forum_hide_avatars"] != "") ? 1 : 0; |
|
113 | +$hide_signatures = (isset($_POST["forum_hide_signatures"]) && $_POST["forum_hide_signatures"] != "") ? 1 : 0; |
|
114 | +$highlight_special = (isset($_POST["forum_highlight_special"]) && $_POST["forum_highlight_special"] != "") ? 1 : 0; |
|
115 | +$jump_to_unread = (isset($_POST["forum_jump_to_unread"]) && $_POST["forum_jump_to_unread"] != "") ? 1 : 0; |
|
116 | +$ignore_sticky_posts = (isset($_POST["forum_ignore_sticky_posts"]) && $_POST["forum_ignore_sticky_posts"] != "") ? 1 : 0; |
|
117 | +$no_signature_by_default = (isset($_POST["signature_by_default"]) && $_POST["signature_by_default"] != "") ? 0 : 1; |
|
118 | 118 | $signature = post_str("signature", true); |
119 | -if (strlen($signature)>250) { |
|
119 | +if (strlen($signature) > 250) { |
|
120 | 120 | error_page(tra("Your signature was too long, please keep it less than 250 characters.")); |
121 | 121 | } |
122 | 122 | $forum_sort = post_int("forum_sort"); |
123 | 123 | $thread_sort = post_int("thread_sort"); |
124 | 124 | $display_wrap_postcount = post_int("forum_display_wrap_postcount"); |
125 | -if ($display_wrap_postcount<1) $display_wrap_postcount=1; |
|
125 | +if ($display_wrap_postcount < 1) $display_wrap_postcount = 1; |
|
126 | 126 | |
127 | 127 | $signature = BoincDb::escape_string($signature); |
128 | 128 | |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | } |
142 | 142 | } else { |
143 | 143 | // todo: clean up the following |
144 | - $add_user_to_filter = (isset($_POST["add_user_to_filter"]) && $_POST["add_user_to_filter"]!=""); |
|
145 | - if ($add_user_to_filter){ |
|
144 | + $add_user_to_filter = (isset($_POST["add_user_to_filter"]) && $_POST["add_user_to_filter"] != ""); |
|
145 | + if ($add_user_to_filter) { |
|
146 | 146 | $user_to_add = trim($_POST["forum_filter_user"]); |
147 | - if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){ |
|
147 | + if ($user_to_add != "" and $user_to_add == strval(intval($user_to_add))) { |
|
148 | 148 | $other_user = BoincUser::lookup_id($user_to_add); |
149 | 149 | if (!$other_user) { |
150 | 150 | echo tra("No such user:")." ".$user_to_add; |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | // |
160 | 160 | $ignored_users = get_ignored_list($user); |
161 | 161 | // todo: use foreach |
162 | -for ($i=0;$i<sizeof($ignored_users);$i++){ |
|
162 | +for ($i = 0; $i < sizeof($ignored_users); $i++) { |
|
163 | 163 | $remove = "remove".trim($ignored_users[$i]); |
164 | - if (isset($_POST[$remove]) && $_POST[$remove]!=""){ |
|
164 | + if (isset($_POST[$remove]) && $_POST[$remove] != "") { |
|
165 | 165 | $other_user = BoincUser::lookup_id($ignored_users[$i]); |
166 | 166 | if (!$other_user) { |
167 | 167 | echo tra("No such user:")." ".$ignored_users[$j]; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | define('UNIQUE_USER_NAME', true); |
51 | 51 | define("FORUM_QA_MERGED_MODE", true); |
52 | 52 | // Set to true to merge Message boards and Q&A section |
53 | -define ("DISABLE_PROFILES", true); |
|
53 | +define("DISABLE_PROFILES", true); |
|
54 | 54 | // enable profiles only after enabling reCAPTCHA |
55 | 55 | // https://github.com/BOINC/boinc/wiki/ProtectionFromSpam |
56 | 56 | define("USE_STOPFORUMSPAM", true); |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | </ol>", PROJECT); |
192 | 192 | } |
193 | 193 | |
194 | -function project_workunit($wu){ |
|
194 | +function project_workunit($wu) { |
|
195 | 195 | // shown in the workunit page |
196 | 196 | } |
197 | 197 | |
198 | -function project_user_summary($user){ |
|
198 | +function project_user_summary($user) { |
|
199 | 199 | // shown in the user summary page |
200 | 200 | } |
201 | 201 | |
202 | -function project_user_page_private($user){ |
|
202 | +function project_user_page_private($user) { |
|
203 | 203 | // shown in the private account page |
204 | 204 | } |
205 | 205 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | array("name" => "Uppercase", "short_name" => "UC", "appids" => array(1, 25)), |
283 | 283 | ); |
284 | 284 | |
285 | -function project_user_credit($user){ |
|
285 | +function project_user_credit($user) { |
|
286 | 286 | global $sub_projects; |
287 | 287 | foreach ($sub_projects as $sp) { |
288 | 288 | show_app_credit_user($user, $sp["name"], $sp["appids"]); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | if ($notify) { |
39 | 39 | page_head(tra("Request pending")); |
40 | 40 | $t = date_str($friend->create_time); |
41 | - echo tra("You requested friendship with %1 on %2.", $destuser->name,$t) . " |
|
41 | + echo tra("You requested friendship with %1 on %2.", $destuser->name, $t)." |
|
42 | 42 | <p>" . |
43 | 43 | tra("This request is still pending confirmation."); |
44 | 44 | page_tail(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | function check_ignoring($srcuser, $destuser) { |
52 | 52 | BoincForumPrefs::lookup($destuser); |
53 | 53 | if (is_ignoring($destuser, $srcuser)) { |
54 | - error_page(tra("%1 is not accepting friendship requests from you",$destuser->name)); |
|
54 | + error_page(tra("%1 is not accepting friendship requests from you", $destuser->name)); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | echo " |
73 | 73 | <form method=post action=friend.php> |
74 | 74 | <input type=hidden name=userid value=$destid> |
75 | - <input type=hidden name=action value=add_confirm>" . |
|
75 | + <input type=hidden name=action value=add_confirm>". |
|
76 | 76 | tra("You have asked to add %1 as a friend. We will notify %1 and will ask him/her to confirm that you are friends.", |
77 | - "<b>".$destuser->name."</b>") ." |
|
77 | + "<b>".$destuser->name."</b>")." |
|
78 | 78 | <p>" . |
79 | - tra("Add an optional message here:") ." |
|
79 | + tra("Add an optional message here:")." |
|
80 | 80 | <br> |
81 | 81 | ".textarea_with_counter("message", 250, "")." |
82 | 82 | <p> |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | send_friend_request_email($user, $destuser, $msg); |
116 | 116 | } |
117 | 117 | page_head(tra("Friend request sent")); |
118 | - echo tra("We have notified %1 of your request.","<b>".$destuser->name."</b>"); |
|
118 | + echo tra("We have notified %1 of your request.", "<b>".$destuser->name."</b>"); |
|
119 | 119 | page_tail(); |
120 | 120 | } |
121 | 121 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | |
198 | 198 | page_head(tra("Friendship confirmed")); |
199 | - echo tra("Your friendship with %1 has been confirmed.","<b>" . $srcuser->name ."</b>"); |
|
199 | + echo tra("Your friendship with %1 has been confirmed.", "<b>".$srcuser->name."</b>"); |
|
200 | 200 | page_tail(); |
201 | 201 | } |
202 | 202 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $notify->delete(); |
216 | 216 | } |
217 | 217 | page_head(tra("Friendship declined")); |
218 | - echo tra("You have declined friendship with %1","<b>".$srcuser->name."</b>"); |
|
218 | + echo tra("You have declined friendship with %1", "<b>".$srcuser->name."</b>"); |
|
219 | 219 | page_tail(); |
220 | 220 | } |
221 | 221 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | echo tra("Notification not found"); |
234 | 234 | } |
235 | 235 | page_head(tra("Friend confirmed")); |
236 | - echo tra("You are now friends with %1.",$destuser->name); |
|
236 | + echo tra("You are now friends with %1.", $destuser->name); |
|
237 | 237 | page_tail(); |
238 | 238 | } |
239 | 239 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | echo |
246 | 246 | tra("Are you sure you want to cancel your friendship with %1?", |
247 | 247 | $destuser->name |
248 | - ) ."<p>\n" |
|
248 | + )."<p>\n" |
|
249 | 249 | ; |
250 | 250 | show_button("friend.php?action=cancel&userid=$destid", tra("Yes"), tra("Cancel friendship")); |
251 | 251 | show_button(HOME_PAGE, tra("No"), tra("Stay friends")); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | if (!$destuser) error_page("No such user"); |
260 | 260 | BoincFriend::delete($user->id, $destid); |
261 | 261 | page_head(tra("Friendship cancelled")); |
262 | - echo tra("Your friendship with %1 has been cancelled.",$destuser->name); |
|
262 | + echo tra("Your friendship with %1 has been cancelled.", $destuser->name); |
|
263 | 263 | page_tail(); |
264 | 264 | } |
265 | 265 |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | mkdir("../cache", 0770); |
33 | 33 | chmod("../cache", 0770); |
34 | 34 | } |
35 | - for ($i=0;$i<256;$i++) { |
|
36 | - $j=sprintf("%02x",$i); |
|
35 | + for ($i = 0; $i < 256; $i++) { |
|
36 | + $j = sprintf("%02x", $i); |
|
37 | 37 | if (!@filemtime("../cache/$j")) { |
38 | 38 | mkdir("../cache/$j", 0770); |
39 | 39 | chmod("../cache/$j", 0770); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | -function get_path($params, $phpfile=null) { |
|
44 | +function get_path($params, $phpfile = null) { |
|
45 | 45 | if (!@filemtime("../cache/00")) make_cache_dirs(); |
46 | 46 | if ($phpfile) { |
47 | 47 | $z = $phpfile; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | // add a layer of subdirectories for reducing file lookup time |
54 | - $sz = substr(md5($z."_".urlencode($params)),1,2); |
|
54 | + $sz = substr(md5($z."_".urlencode($params)), 1, 2); |
|
55 | 55 | $path = "../cache/".$sz."/".$z; |
56 | 56 | if ($params) { |
57 | 57 | $path = $path."_".urlencode($params); |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | function disk_usage($dir) { |
63 | - $usage=0; |
|
64 | - if ($handle=@opendir($dir)) { |
|
65 | - while ($file=readdir($handle)) { |
|
63 | + $usage = 0; |
|
64 | + if ($handle = @opendir($dir)) { |
|
65 | + while ($file = readdir($handle)) { |
|
66 | 66 | if (($file != ".") && ($file != "..")) { |
67 | 67 | if (@is_dir($dir."/".$file)) { |
68 | - $usage+=disk_usage($dir."/".$file); |
|
68 | + $usage += disk_usage($dir."/".$file); |
|
69 | 69 | } else { |
70 | - $usage+=@filesize($dir."/".$file); |
|
70 | + $usage += @filesize($dir."/".$file); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | if (!chdir($dir)) { |
82 | 82 | return; |
83 | 83 | } |
84 | - if ($handle=@opendir(".")) { |
|
85 | - while ($file=readdir($handle)) { |
|
84 | + if ($handle = @opendir(".")) { |
|
85 | + while ($file = readdir($handle)) { |
|
86 | 86 | if ($file == ".") continue; |
87 | 87 | if ($file == "..") continue; |
88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | if (@is_dir($file)) { |
94 | 94 | clean_cache($max_age, $file); |
95 | 95 | } else { |
96 | - if ((time()-@filemtime($file))>$max_age) { |
|
96 | + if ((time() - @filemtime($file)) > $max_age) { |
|
97 | 97 | //echo "unlinking ".getcwd()."/$file\n"; |
98 | 98 | @unlink($file); |
99 | 99 | } |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | // check cache size every once in a while, purge if too big |
109 | 109 | // |
110 | -function cache_check_diskspace(){ |
|
111 | - if ((rand() % CACHE_SIZE_CHECK_FREQ)) return; |
|
110 | +function cache_check_diskspace() { |
|
111 | + if ((rand()%CACHE_SIZE_CHECK_FREQ)) return; |
|
112 | 112 | if (disk_usage("../cache") < MAX_CACHE_USAGE) return; |
113 | 113 | $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL, |
114 | 114 | USER_PROFILE_TTL, TOP_PAGES_TTL, INDEX_PAGE_TTL |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | clean_cache($x, "../cache"); |
117 | 117 | } |
118 | 118 | |
119 | -function cache_need_to_regenerate($path, $max_age){ |
|
119 | +function cache_need_to_regenerate($path, $max_age) { |
|
120 | 120 | $regenerate = false; |
121 | 121 | $request = apache_request_headers(); |
122 | 122 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | // and touch the cached copy so other processes |
129 | 129 | // don't regenerate at the same time |
130 | 130 | // |
131 | - if ($lastmodified<time()-$max_age) { |
|
131 | + if ($lastmodified < time() - $max_age) { |
|
132 | 132 | $regenerate = true; |
133 | 133 | @touch($path); |
134 | 134 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | // Returns cached data or false if nothing was found |
142 | -function get_cached_data($max_age, $params=""){ |
|
142 | +function get_cached_data($max_age, $params = "") { |
|
143 | 143 | global $no_cache; |
144 | 144 | |
145 | 145 | if ($no_cache) return; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | } else { |
157 | 157 | cache_check_diskspace(); |
158 | - $regenerate=cache_need_to_regenerate($path, $max_age); |
|
158 | + $regenerate = cache_need_to_regenerate($path, $max_age); |
|
159 | 159 | if (!$regenerate) { |
160 | 160 | return file_get_contents($path); |
161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // DEPRECATED |
168 | -function start_cache($max_age, $params=""){ |
|
168 | +function start_cache($max_age, $params = "") { |
|
169 | 169 | global $no_cache, $caching, $memcache; |
170 | 170 | |
171 | 171 | if ($no_cache) return; |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | $regenerate = cache_need_to_regenerate($path, $max_age); |
189 | 189 | } |
190 | 190 | //Is the stored version too old, do we need to regenerate it? |
191 | - if ($regenerate){ |
|
191 | + if ($regenerate) { |
|
192 | 192 | // If cached version is too old (or non-existent) |
193 | 193 | // generate the page and write to cache |
194 | 194 | // |
195 | 195 | ob_start(); |
196 | 196 | ob_implicit_flush(0); |
197 | - Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
198 | - Header("Expires: " . gmdate("D, d M Y H:i:s",time()+$max_age) . " GMT"); |
|
199 | - Header("Cache-Control: public, max-age=" . $max_age); |
|
197 | + Header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
198 | + Header("Expires: ".gmdate("D, d M Y H:i:s", time() + $max_age)." GMT"); |
|
199 | + Header("Cache-Control: public, max-age=".$max_age); |
|
200 | 200 | |
201 | 201 | // allow the calling page to see cache period |
202 | 202 | // |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | if (strstr($params, "format=xml")) { |
209 | 209 | header('Content-type: text/xml'); |
210 | 210 | } |
211 | - Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT"); |
|
212 | - Header("Expires: " . gmdate("D, d M Y H:i:s",$lastmodified+$max_age) . " GMT"); |
|
213 | - Header("Cache-Control: public, max-age=" . $max_age ); |
|
211 | + Header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastmodified)." GMT"); |
|
212 | + Header("Expires: ".gmdate("D, d M Y H:i:s", $lastmodified + $max_age)." GMT"); |
|
213 | + Header("Cache-Control: public, max-age=".$max_age); |
|
214 | 214 | if ($cache && $cache->content) { |
215 | 215 | echo $cache->content; |
216 | 216 | exit; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | // write output buffer both to client and to cache |
230 | 230 | // DEPRECATED |
231 | -function end_cache($max_age,$params=""){ |
|
231 | +function end_cache($max_age, $params = "") { |
|
232 | 232 | global $no_cache; |
233 | 233 | if ($no_cache) return; |
234 | 234 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | -function set_cached_data($max_age, $data, $params=""){ |
|
256 | +function set_cached_data($max_age, $data, $params = "") { |
|
257 | 257 | // for the benefit of hackers |
258 | 258 | if (strstr($params, "..")) { |
259 | 259 | return "bad params"; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | $server_arr = array(); |
297 | 297 | $servers = explode('|', MEMCACHE_SERVERS); |
298 | - foreach($servers as &$server) { |
|
298 | + foreach ($servers as &$server) { |
|
299 | 299 | list($ip, $port, $weight) = explode(':', $server); |
300 | 300 | if (!$port) { $port = 11211; } |
301 | 301 | $server_arr[] = array($ip, $port, $weight); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | require_once("../inc/submit_util.inc"); |
80 | 80 | |
81 | 81 | function upload_error_description($errno) { |
82 | - switch($errno) { |
|
82 | + switch ($errno) { |
|
83 | 83 | case UPLOAD_ERR_INI_SIZE: |
84 | 84 | return "The uploaded file exceeds upload_max_filesize of php.ini."; break; |
85 | 85 | case UPLOAD_ERR_FORM_SIZE: |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | $delete_time = (int)$r->delete_time; |
106 | 106 | $batch_id = (int)$r->batch_id; |
107 | 107 | $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); |
108 | - $phys_names= array(); |
|
109 | - foreach($r->phys_name as $f) { |
|
108 | + $phys_names = array(); |
|
109 | + foreach ($r->phys_name as $f) { |
|
110 | 110 | $phys_names[] = (string)$f; |
111 | 111 | } |
112 | 112 | $i = 0; |
113 | - foreach($phys_names as $fname) { |
|
114 | - $path = dir_hier_path($fname, project_dir() . "/download", $fanout); |
|
113 | + foreach ($phys_names as $fname) { |
|
114 | + $path = dir_hier_path($fname, project_dir()."/download", $fanout); |
|
115 | 115 | |
116 | 116 | // if the job_file record is there, |
117 | 117 | // update the delete time first to avoid race condition |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | foreach ($_FILES as $f) { |
219 | 219 | $tmp_name = $f['tmp_name']; |
220 | 220 | $fname = $phys_names[$i]; |
221 | - $path = dir_hier_path($fname, project_dir() . "/download", $fanout); |
|
221 | + $path = dir_hier_path($fname, project_dir()."/download", $fanout); |
|
222 | 222 | |
223 | 223 | // see if file is in download hierarchy |
224 | 224 | // |
225 | - switch(check_download_file($tmp_name, $path)) { |
|
225 | + switch (check_download_file($tmp_name, $path)) { |
|
226 | 226 | case 0: |
227 | 227 | // file is already there |
228 | 228 | // note: check_download_file() generates .md5 in cases 1 and 2 |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | if ($request_log) { |
278 | 278 | $request_log_dir = parse_config(get_config(), "<log_dir>"); |
279 | 279 | if ($request_log_dir) { |
280 | - $request_log = $request_log_dir . "/" . $request_log; |
|
280 | + $request_log = $request_log_dir."/".$request_log; |
|
281 | 281 | } |
282 | 282 | if ($file = fopen($request_log, "a+")) { |
283 | - fwrite($file, "\n<job_file date=\"" . date(DATE_ATOM) . "\">\n" . $_POST['request'] . "\n</job_file>\n"); |
|
283 | + fwrite($file, "\n<job_file date=\"".date(DATE_ATOM)."\">\n".$_POST['request']."\n</job_file>\n"); |
|
284 | 284 | fclose($file); |
285 | 285 | } |
286 | 286 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | xml_error(-1, "can't parse request message: $req", __FILE__, __LINE__); |
293 | 293 | } |
294 | 294 | |
295 | -switch($r->getName()) { |
|
295 | +switch ($r->getName()) { |
|
296 | 296 | case 'query_files': |
297 | 297 | query_files($r); |
298 | 298 | break; |