@@ -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 |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | // ------------ Notification ----------- |
39 | 39 | |
40 | 40 | row1(tra("Notifications")); |
41 | -$ch0 = $user->prefs->pm_notification==0?"checked":""; |
|
42 | -$ch1 = $user->prefs->pm_notification==1?"checked":""; |
|
43 | -$ch2 = $user->prefs->pm_notification==2?"checked":""; |
|
41 | +$ch0 = $user->prefs->pm_notification == 0 ? "checked" : ""; |
|
42 | +$ch1 = $user->prefs->pm_notification == 1 ? "checked" : ""; |
|
43 | +$ch2 = $user->prefs->pm_notification == 2 ? "checked" : ""; |
|
44 | 44 | row2( |
45 | 45 | tra("How should we notify you of new private messages, friend requests, posts in subscribed threads, and other events?"), |
46 | 46 | "<input type=radio name=pm_notification value=0 $ch0> ".tra("On my Account page (no email)")." |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | // ------------ Forum identity ----------- |
54 | 54 | |
55 | 55 | $select_0 = $select_1 = $select_2 = ""; |
56 | -if (strlen($user->prefs->avatar)){ |
|
57 | - if (substr($user->prefs->avatar, 0, 23) == 'http://www.gravatar.com' || substr($user->prefs->avatar, 0, 18)=="//www.gravatar.com") { // Gravatar |
|
56 | +if (strlen($user->prefs->avatar)) { |
|
57 | + if (substr($user->prefs->avatar, 0, 23) == 'http://www.gravatar.com' || substr($user->prefs->avatar, 0, 18) == "//www.gravatar.com") { // Gravatar |
|
58 | 58 | $select_1 = "checked=\"true\""; |
59 | 59 | } else { |
60 | 60 | $select_2 = "checked=\"true\""; |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | <input type=\"radio\" id=\"avatar_select_2\" name=\"avatar_select\" value=\"2\" ".$select_2."> |
74 | 74 | <label for=\"avatar_select_2\">".tra("Use this uploaded avatar:")."</label> <input type=\"file\" name=\"picture\">" |
75 | 75 | ); |
76 | -if (strlen($user->prefs->avatar)){ |
|
76 | +if (strlen($user->prefs->avatar)) { |
|
77 | 77 | row2(tra("Avatar preview")."<br><p class=\"text-muted\">".tra("This is how your avatar will look")."</p>", |
78 | 78 | "<img src=\"".$user->prefs->avatar."\" width=\"100\" height=\"100\">"); |
79 | 79 | } |
80 | 80 | |
81 | -$signature_by_default = $user->prefs->no_signature_by_default==false?"checked=\"checked\"":""; |
|
81 | +$signature_by_default = $user->prefs->no_signature_by_default == false ? "checked=\"checked\"" : ""; |
|
82 | 82 | |
83 | -$signature=$user->prefs->signature; |
|
84 | -$maxlen=250; |
|
83 | +$signature = $user->prefs->signature; |
|
84 | +$maxlen = 250; |
|
85 | 85 | $x = ''; |
86 | 86 | if (!NO_COMPUTING) { |
87 | 87 | $x = tra( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | tra("Attach signature by default") |
104 | 104 | ) |
105 | 105 | ); |
106 | -if ($user->prefs->signature!=""){ |
|
106 | +if ($user->prefs->signature != "") { |
|
107 | 107 | row2(tra("Signature preview"). |
108 | 108 | "<br><p class=\"text-muted\">".tra("This is how your signature will look in the forums")."</p>", |
109 | 109 | output_transform($user->prefs->signature) |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | |
113 | 113 | // ------------ Message display ----------- |
114 | 114 | |
115 | -$forum_hide_avatars = $user->prefs->hide_avatars?"checked=\"checked\"":""; |
|
116 | -$forum_hide_signatures = $user->prefs->hide_signatures?"checked=\"checked\"":""; |
|
117 | -$forum_link_popup = $user->prefs->link_popup?"checked=\"checked\"":""; |
|
118 | -$forum_image_as_link = $user->prefs->images_as_links?"checked=\"checked\"":""; |
|
119 | -$forum_jump_to_unread = $user->prefs->jump_to_unread?"checked=\"checked\"":""; |
|
120 | -$forum_ignore_sticky_posts = $user->prefs->ignore_sticky_posts?"checked=\"checked\"":""; |
|
121 | -$forum_highlight_special = $user->prefs->highlight_special?"checked=\"checked\"":""; |
|
115 | +$forum_hide_avatars = $user->prefs->hide_avatars ? "checked=\"checked\"" : ""; |
|
116 | +$forum_hide_signatures = $user->prefs->hide_signatures ? "checked=\"checked\"" : ""; |
|
117 | +$forum_link_popup = $user->prefs->link_popup ? "checked=\"checked\"" : ""; |
|
118 | +$forum_image_as_link = $user->prefs->images_as_links ? "checked=\"checked\"" : ""; |
|
119 | +$forum_jump_to_unread = $user->prefs->jump_to_unread ? "checked=\"checked\"" : ""; |
|
120 | +$forum_ignore_sticky_posts = $user->prefs->ignore_sticky_posts ? "checked=\"checked\"" : ""; |
|
121 | +$forum_highlight_special = $user->prefs->highlight_special ? "checked=\"checked\"" : ""; |
|
122 | 122 | |
123 | 123 | $forum_minimum_wrap_postcount = intval($user->prefs->minimum_wrap_postcount); |
124 | 124 | $forum_display_wrap_postcount = intval($user->prefs->display_wrap_postcount); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | <input class="btn btn-default" type="submit" name="remove%d" value="%s"> |
165 | 165 | <br> |
166 | 166 | ', |
167 | - UNIQUE_USER_NAME?'':"$blocked_user->id -", |
|
167 | + UNIQUE_USER_NAME ? '' : "$blocked_user->id -", |
|
168 | 168 | user_links($blocked_user), |
169 | 169 | $blocked_user->id, |
170 | 170 | tra("Unblock") |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | tra("Blocked users"), |
179 | 179 | tra('Ignore message board posts and private messages from these users.') |
180 | 180 | ), |
181 | - $blocked_str?$blocked_str:'---' |
|
181 | + $blocked_str ? $blocked_str : '---' |
|
182 | 182 | ); |
183 | 183 | row2( |
184 | 184 | tra('Block user'), |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | <input type="text" name="forum_filter_user" size=12> |
189 | 189 | <input class="btn btn-default" type="submit" name="add_user_to_filter" value="%s"> |
190 | 190 | ', |
191 | - UNIQUE_USER_NAME?tra('User name'):tra('User ID (For instance: 123456789)'), |
|
191 | + UNIQUE_USER_NAME ?tra('User name') : tra('User ID (For instance: 123456789)'), |
|
192 | 192 | tra("Block") |
193 | 193 | ) |
194 | 194 | ); |
@@ -206,5 +206,5 @@ discard block |
||
206 | 206 | end_table(); |
207 | 207 | page_tail(); |
208 | 208 | |
209 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
209 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
210 | 210 | ?> |
@@ -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); |
@@ -84,20 +84,20 @@ discard block |
||
84 | 84 | if ($offset === false) $offset = 0; |
85 | 85 | if ($offset >= $nmsgs) $offset = 0; |
86 | 86 | echo sprintf('Showing messages %d to %d of %d', |
87 | - $offset+1, |
|
88 | - min($offset+$nshow, $nmsgs), |
|
87 | + $offset + 1, |
|
88 | + min($offset + $nshow, $nmsgs), |
|
89 | 89 | $nmsgs |
90 | 90 | ); |
91 | 91 | if ($offset) { |
92 | 92 | echo sprintf( |
93 | 93 | ' · <a href=pm.php?action=inbox&offset=%d>Previous %d</a>', |
94 | - max(0, $offset-$nshow), $nshow |
|
94 | + max(0, $offset - $nshow), $nshow |
|
95 | 95 | ); |
96 | 96 | } |
97 | - if ($offset+$nshow < $nmsgs) { |
|
97 | + if ($offset + $nshow < $nmsgs) { |
|
98 | 98 | echo sprintf( |
99 | 99 | ' · <a href=pm.php?action=inbox&offset=%d>Next %d</a>', |
100 | - $offset+$nshow, $nshow |
|
100 | + $offset + $nshow, $nshow |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | array('style="width: 12em;"', 'style="width: 10em;"', "") |
113 | 113 | ); |
114 | 114 | $i = 0; |
115 | - foreach($msgs as $msg) { |
|
116 | - if ($i<$offset) { |
|
115 | + foreach ($msgs as $msg) { |
|
116 | + if ($i < $offset) { |
|
117 | 117 | $i++; |
118 | 118 | continue; |
119 | 119 | } |
120 | - if ($i>=$offset+$nshow) break; |
|
120 | + if ($i >= $offset + $nshow) break; |
|
121 | 121 | $i++; |
122 | 122 | $sender = BoincUser::lookup_id($msg->senderid); |
123 | 123 | if (!$sender) { |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $msgs = BoincPrivateMessage::enum( |
366 | 366 | "userid=$logged_in_user->id" |
367 | 367 | ); |
368 | - foreach($msgs as $msg) { |
|
368 | + foreach ($msgs as $msg) { |
|
369 | 369 | $x = "pm_select_$msg->id"; |
370 | 370 | if (post_str($x, true)) { |
371 | 371 | $msg = BoincPrivateMessage::lookup_id($msg->id); |
@@ -420,5 +420,5 @@ discard block |
||
420 | 420 | error_page(tra("Unknown action")); |
421 | 421 | } |
422 | 422 | |
423 | -$cvs_version_tracker[]="\$Id: pm.php 14077 2007-11-03 04:26:47Z davea $"; |
|
423 | +$cvs_version_tracker[] = "\$Id: pm.php 14077 2007-11-03 04:26:47Z davea $"; |
|
424 | 424 | ?> |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | foreach ($files as $file) { |
62 | 62 | $path = "$dir/$file"; |
63 | 63 | [$err, $file_size, $file_md5] = sandbox_parse_link_file($path); |
64 | - if (!$err){ |
|
64 | + if (!$err) { |
|
65 | 65 | if (strcmp($md5, $file_md5) == 0) { |
66 | 66 | $exist = true; |
67 | 67 | $elf = $file; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | $files = sandbox_file_names($user); |
126 | 126 | foreach ($files as $f) { |
127 | - if ($regexp && !preg_match("/$regexp/",$f)) continue; |
|
127 | + if ($regexp && !preg_match("/$regexp/", $f)) continue; |
|
128 | 128 | $x .= "<option value=\"$f\">$f</option>\n"; |
129 | 129 | } |
130 | 130 | $x .= "</select>\n"; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | // TODO: this is a kludge. |
155 | 155 | // Should we use the job_file and batch_file_assoc tables instead? |
156 | 156 | // |
157 | -function sandbox_file_in_use($user, $file){ |
|
157 | +function sandbox_file_in_use($user, $file) { |
|
158 | 158 | $ufiles = array(); |
159 | 159 | |
160 | 160 | $pbatches = BoincBatch::enum( |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | ); |
165 | 165 | if (!$pbatches) return false; |
166 | 166 | |
167 | - foreach ($pbatches as $batch){ |
|
168 | - $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" ); |
|
169 | - if ($wus == null){ |
|
167 | + foreach ($pbatches as $batch) { |
|
168 | + $wus = BoincWorkUnit::enum("batch = $batch->id limit 1"); |
|
169 | + if ($wus == null) { |
|
170 | 170 | continue; |
171 | 171 | } |
172 | - foreach($wus as $wu){ |
|
172 | + foreach ($wus as $wu) { |
|
173 | 173 | $x = "<in>".$wu->xml_doc."</in>"; |
174 | 174 | $x = simplexml_load_string($x); |
175 | 175 | global $fanout; |
176 | - foreach($x->workunit->file_ref as $fr){ |
|
176 | + foreach ($x->workunit->file_ref as $fr) { |
|
177 | 177 | $pname = (string)$fr->file_name; |
178 | 178 | $ufiles[] = $pname; |
179 | 179 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | $dir = sandbox_dir($user); |
183 | 183 | $path = $dir."/".$file; |
184 | 184 | list($err, $size, $md5) = sandbox_parse_link_file($path); |
185 | - if (!$err){ |
|
185 | + if (!$err) { |
|
186 | 186 | $f = sandbox_file_name($user, $md5); |
187 | - foreach($ufiles as $uf) { |
|
188 | - if (strcmp($f,$uf) == 0){ |
|
187 | + foreach ($ufiles as $uf) { |
|
188 | + if (strcmp($f, $uf) == 0) { |
|
189 | 189 | return true; |
190 | 190 | } |
191 | 191 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if ($template) { |
60 | 60 | $t = (double)$template->workunit->rsc_fpops_est; |
61 | 61 | } |
62 | - foreach($r->batch->job as $job) { |
|
62 | + foreach ($r->batch->job as $job) { |
|
63 | 63 | $y = (double)$job->rsc_fpops_est; |
64 | 64 | if ($y) { |
65 | 65 | $x += $y; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | function est_elapsed_time($r, $template) { |
86 | 86 | // crude estimate: batch FLOPs / project FLOPS |
87 | 87 | // |
88 | - return batch_flop_count($r, $template) / project_flops(); |
|
88 | + return batch_flop_count($r, $template)/project_flops(); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // if batch-level input template filename was given, read it; |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | // |
96 | 96 | function read_input_template($app, $r) { |
97 | 97 | if ((isset($r->batch)) && (isset($r->batch->workunit_template_file)) && ($r->batch->workunit_template_file)) { |
98 | - $path = project_dir() . "/templates/".$r->batch->workunit_template_file; |
|
98 | + $path = project_dir()."/templates/".$r->batch->workunit_template_file; |
|
99 | 99 | } else { |
100 | - $path = project_dir() . "/templates/$app->name"."_in"; |
|
100 | + $path = project_dir()."/templates/$app->name"."_in"; |
|
101 | 101 | } |
102 | 102 | if (file_exists($path)) { |
103 | 103 | $x = simplexml_load_file($path); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | function validate_batch($jobs, $template) { |
143 | 143 | $i = 0; |
144 | 144 | $n = count($template->file_info); |
145 | - foreach($jobs as $job) { |
|
145 | + foreach ($jobs as $job) { |
|
146 | 146 | $m = count($job->input_files); |
147 | 147 | if ($n != $m) { |
148 | 148 | log_write("wrong # of input files for job $i: need $n, got $m"); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // stage all the files |
212 | 212 | // |
213 | 213 | function stage_files(&$jobs, $user) { |
214 | - foreach($jobs as $job) { |
|
214 | + foreach ($jobs as $job) { |
|
215 | 215 | foreach ($job->input_files as $file) { |
216 | 216 | if ($file->mode != "remote") { |
217 | 217 | $file->name = stage_file($file, $user); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // |
225 | 225 | function submit_jobs( |
226 | 226 | $jobs, $job_params, $app, $batch_id, $priority, $app_version_num, |
227 | - $input_template_filename, // batch-level; can also specify per job |
|
227 | + $input_template_filename, // batch-level; can also specify per job |
|
228 | 228 | $output_template_filename, |
229 | 229 | $user |
230 | 230 | ) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | // one line per job |
235 | 235 | // |
236 | 236 | $x = ""; |
237 | - foreach($jobs as $job) { |
|
237 | + foreach ($jobs as $job) { |
|
238 | 238 | if ($job->name) { |
239 | 239 | $x .= " --wu_name $job->name"; |
240 | 240 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $x .= "\n"; |
270 | 270 | } |
271 | 271 | |
272 | - $cmd = "cd " . project_dir() . "; ./bin/create_work --appname $app->name --batch $batch_id"; |
|
272 | + $cmd = "cd ".project_dir()."; ./bin/create_work --appname $app->name --batch $batch_id"; |
|
273 | 273 | |
274 | 274 | if ($user->seti_id) { |
275 | 275 | $cmd .= " --target_user $user->id "; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | // |
378 | 378 | function xml_get_jobs($r) { |
379 | 379 | $jobs = array(); |
380 | - foreach($r->batch->job as $j) { |
|
380 | + foreach ($r->batch->job as $j) { |
|
381 | 381 | $job = new StdClass; |
382 | 382 | $job->input_files = array(); |
383 | 383 | $job->command_line = (string)$j->command_line; |
@@ -428,16 +428,16 @@ discard block |
||
428 | 428 | // |
429 | 429 | function logical_end_time($r, $jobs, $user, $app) { |
430 | 430 | $total_flops = 0; |
431 | - foreach($jobs as $job) { |
|
431 | + foreach ($jobs as $job) { |
|
432 | 432 | //print_r($job); |
433 | 433 | if ($job->rsc_fpops_est) { |
434 | 434 | $total_flops += $job->rsc_fpops_est; |
435 | 435 | } else if ($job->input_template && $job->input_template->workunit->rsc_fpops_est) { |
436 | - $total_flops += (double) $job->input_template->workunit->rsc_fpops_est; |
|
436 | + $total_flops += (double)$job->input_template->workunit->rsc_fpops_est; |
|
437 | 437 | } else if ($r->batch->job_params->rsc_fpops_est) { |
438 | - $total_flops += (double) $r->batch->job_params->rsc_fpops_est; |
|
438 | + $total_flops += (double)$r->batch->job_params->rsc_fpops_est; |
|
439 | 439 | } else { |
440 | - $x = (double) $template->workunit->rsc_fpops_est; |
|
440 | + $x = (double)$template->workunit->rsc_fpops_est; |
|
441 | 441 | if ($x) { |
442 | 442 | $total_flops += $x; |
443 | 443 | } else { |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | } |
446 | 446 | } |
447 | 447 | } |
448 | - $cmd = "cd " . project_dir() . "/bin; ./adjust_user_priority --user $user->id --flops $total_flops --app $app->name"; |
|
448 | + $cmd = "cd ".project_dir()."/bin; ./adjust_user_priority --user $user->id --flops $total_flops --app $app->name"; |
|
449 | 449 | $x = exec($cmd); |
450 | 450 | if (!is_numeric($x) || (double)$x == 0) { |
451 | 451 | xml_error(-1, "$cmd returned $x"); |
@@ -530,15 +530,15 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | $job_params = new StdClass; |
533 | - $job_params->rsc_disk_bound = (double) $r->batch->job_params->rsc_disk_bound; |
|
534 | - $job_params->rsc_fpops_est = (double) $r->batch->job_params->rsc_fpops_est; |
|
535 | - $job_params->rsc_fpops_bound = (double) $r->batch->job_params->rsc_fpops_bound; |
|
536 | - $job_params->rsc_memory_bound = (double) $r->batch->job_params->rsc_memory_bound; |
|
537 | - $job_params->delay_bound = (double) $r->batch->job_params->delay_bound; |
|
533 | + $job_params->rsc_disk_bound = (double)$r->batch->job_params->rsc_disk_bound; |
|
534 | + $job_params->rsc_fpops_est = (double)$r->batch->job_params->rsc_fpops_est; |
|
535 | + $job_params->rsc_fpops_bound = (double)$r->batch->job_params->rsc_fpops_bound; |
|
536 | + $job_params->rsc_memory_bound = (double)$r->batch->job_params->rsc_memory_bound; |
|
537 | + $job_params->delay_bound = (double)$r->batch->job_params->delay_bound; |
|
538 | 538 | // could add quorum-related stuff |
539 | 539 | |
540 | - $input_template_filename = (string) $r->batch->input_template_filename; |
|
541 | - $output_template_filename = (string) $r->batch->output_template_filename; |
|
540 | + $input_template_filename = (string)$r->batch->input_template_filename; |
|
541 | + $output_template_filename = (string)$r->batch->output_template_filename; |
|
542 | 542 | // possibly empty |
543 | 543 | |
544 | 544 | submit_jobs( |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | } |
632 | 632 | |
633 | 633 | function n_outfiles($wu) { |
634 | - $path = project_dir() . "/$wu->output_template_filename"; |
|
634 | + $path = project_dir()."/$wu->output_template_filename"; |
|
635 | 635 | $r = simplexml_load_file($path); |
636 | 636 | return count($r->file_info); |
637 | 637 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | "; |
839 | 839 | if ($result->server_state == 5) { // over? |
840 | 840 | $paths = get_outfile_paths($result); |
841 | - foreach($paths as $path) { |
|
841 | + foreach ($paths as $path) { |
|
842 | 842 | if (is_file($path)) { |
843 | 843 | $size = filesize($path); |
844 | 844 | echo " <outfile> |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | } else { |
883 | 883 | $results = BoincResult::enum("workunitid=$job_id"); |
884 | 884 | foreach ($results as $r) { |
885 | - switch($r->outcome) { |
|
885 | + switch ($r->outcome) { |
|
886 | 886 | case 1: |
887 | 887 | case 3: |
888 | 888 | case 6: |
@@ -997,8 +997,8 @@ discard block |
||
997 | 997 | } |
998 | 998 | |
999 | 999 | list($user, $user_submit) = check_remote_submit_permissions($r, $app); |
1000 | - $in = file_get_contents(project_dir() . "/templates/".$app->name."_in"); |
|
1001 | - $out = file_get_contents(project_dir() . "/templates/".$app->name."_out"); |
|
1000 | + $in = file_get_contents(project_dir()."/templates/".$app->name."_in"); |
|
1001 | + $out = file_get_contents(project_dir()."/templates/".$app->name."_out"); |
|
1002 | 1002 | if ($in === false || $out === false) { |
1003 | 1003 | log_write("template file missing"); |
1004 | 1004 | xml_error(-1, "template file missing"); |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | |
1011 | 1011 | function ping($r) { |
1012 | 1012 | xml_start_tag("ping"); |
1013 | - BoincDb::get(); // errors out if DB down or web disabled |
|
1013 | + BoincDb::get(); // errors out if DB down or web disabled |
|
1014 | 1014 | echo "<success>1</success> |
1015 | 1015 | </ping> |
1016 | 1016 | "; |
@@ -1077,9 +1077,9 @@ discard block |
||
1077 | 1077 | $request_log = parse_config(get_config(), "<remote_submit_request_log>"); |
1078 | 1078 | if ($request_log) { |
1079 | 1079 | $log_dir = parse_config(get_config(), "<log_dir>"); |
1080 | - $request_log = $log_dir . "/" . $request_log; |
|
1080 | + $request_log = $log_dir."/".$request_log; |
|
1081 | 1081 | if ($file = fopen($request_log, "a")) { |
1082 | - fwrite($file, "\n<submit_rpc_handler date=\"" . date(DATE_ATOM) . "\">\n" . $_POST['request'] . "\n</submit_rpc_handler>\n"); |
|
1082 | + fwrite($file, "\n<submit_rpc_handler date=\"".date(DATE_ATOM)."\">\n".$_POST['request']."\n</submit_rpc_handler>\n"); |
|
1083 | 1083 | fclose($file); |
1084 | 1084 | } |
1085 | 1085 | } |
@@ -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; |