@@ -99,7 +99,7 @@ |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | - @closedir($handle); |
|
102 | + @closedir($handle); |
|
103 | 103 | } |
104 | 104 | chdir($start_dir); |
105 | 105 | } |
@@ -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 false; |
@@ -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); |
@@ -107,7 +107,7 @@ 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(){ |
|
110 | +function cache_check_diskspace() { |
|
111 | 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, |
@@ -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 | |
@@ -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 false; |
@@ -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,7 +188,7 @@ 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 | // |
@@ -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"; |
@@ -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; |
@@ -39,7 +39,7 @@ |
||
39 | 39 | } else { |
40 | 40 | $last_mod_time = time(); |
41 | 41 | } |
42 | -$create_date = gmdate('D, d M Y H:i:s', $last_mod_time) . ' GMT'; |
|
42 | +$create_date = gmdate('D, d M Y H:i:s', $last_mod_time).' GMT'; |
|
43 | 43 | |
44 | 44 | header("Expires: ".gmdate('D, d M Y H:i:s', time())." GMT"); |
45 | 45 | header("Last-Modified: ".$create_date); |