@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | return file_exists("$d/stop_sched"); |
57 | 57 | } |
58 | 58 | |
59 | -function xml_error($num=-1, $msg=null, $file=null, $line=null) { |
|
59 | +function xml_error($num = -1, $msg = null, $file = null, $line = null) { |
|
60 | 60 | global $xml_outer_tag; |
61 | 61 | if (!$msg) { |
62 | - switch($num) { |
|
62 | + switch ($num) { |
|
63 | 63 | case -112: $msg = "Invalid XML"; break; |
64 | 64 | case -136: $msg = "Not found"; break; |
65 | 65 | case -137: $msg = "Name or email address is not unique"; break; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // If it's a single-tag element, and it's present, just return the tag |
106 | 106 | // |
107 | 107 | function parse_element($xml, $tag) { |
108 | - $closetag = "</" . substr($tag,1); |
|
108 | + $closetag = "</".substr($tag, 1); |
|
109 | 109 | $x = strstr($xml, $tag); |
110 | 110 | if ($x) { |
111 | 111 | if (strstr($tag, "/>")) return $tag; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | |
122 | 122 | function parse_next_element($xml, $tag, &$cursor) { |
123 | 123 | $element = null; |
124 | - $closetag = "</" . substr($tag,1); |
|
125 | - $pos = substr($xml,$cursor); |
|
124 | + $closetag = "</".substr($tag, 1); |
|
125 | + $pos = substr($xml, $cursor); |
|
126 | 126 | $x = strstr($pos, $tag); |
127 | 127 | if ($x) { |
128 | 128 | if (strstr($tag, "/>")) return $tag; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | // whose OSs may have such restrictions. |
223 | 223 | // |
224 | 224 | function is_valid_filename($x) { |
225 | - if (strlen($x)>255) return false; |
|
225 | + if (strlen($x) > 255) return false; |
|
226 | 226 | // \w means A-Za-z0-9_ |
227 | 227 | return preg_match('/^[\w\-.]+$/', $x); |
228 | 228 | } |
@@ -30,6 +30,6 @@ |
||
30 | 30 | if (!$thread) error_page('No such thread'); |
31 | 31 | $logged_in_user = get_logged_in_user(); |
32 | 32 | |
33 | -$posts = get_thread_posts($threadid, 0,true); |
|
33 | +$posts = get_thread_posts($threadid, 0, true); |
|
34 | 34 | header("Location: forum_rate.php?choice=p&post=".$posts[0]->id); |
35 | 35 | ?> |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | start_table(); |
51 | 51 | |
52 | 52 | $get_reason = true; |
53 | -if (get_str('action')=="hide") { |
|
53 | +if (get_str('action') == "hide") { |
|
54 | 54 | //display input that selects reason |
55 | 55 | echo "<input type=hidden name=action value=hide>"; |
56 | 56 | row1(tra("Hide post")); |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | ) |
68 | 68 | ) |
69 | 69 | ); |
70 | -} elseif (get_str('action')=="move") { |
|
70 | +} elseif (get_str('action') == "move") { |
|
71 | 71 | row1(tra("Move post")); |
72 | 72 | echo "<input type=hidden name=action value=move>"; |
73 | 73 | row2(tra("Destination thread ID:"), "<input name=\"threadid\">"); |
74 | 74 | // TODO: display where to move the post as a dropdown instead of having to get ID |
75 | -} elseif (get_str('action')=="banish_user") { |
|
75 | +} elseif (get_str('action') == "banish_user") { |
|
76 | 76 | $userid = get_int('userid'); |
77 | 77 | $user = BoincUser::lookup_id($userid); |
78 | 78 | if (!$user) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | BoincForumPrefs::lookup($user); |
82 | 82 | $x = $user->prefs->banished_until; |
83 | - if ($x>time()) { |
|
83 | + if ($x > time()) { |
|
84 | 84 | error_page(tra("User is already banished")); |
85 | 85 | } |
86 | 86 | row1(tra("Banish user")); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | echo "<input type=\"hidden\" name=\"id\" value=\"".$postid."\">\n"; |
99 | 99 | echo "<input type=\"hidden\" name=\"userid\" value=\"".$userid."\">\n"; |
100 | 100 | echo "<input type=\"hidden\" name=\"confirmed\" value=\"yes\">\n"; |
101 | -} elseif (get_str('action')=="delete") { |
|
101 | +} elseif (get_str('action') == "delete") { |
|
102 | 102 | echo "<input type=hidden name=action value=delete>"; |
103 | 103 | row2( |
104 | 104 | "Are you sure want to delete this post? This cannot be undone.", |
@@ -80,20 +80,20 @@ |
||
80 | 80 | |
81 | 81 | function upload_error_description($errno) { |
82 | 82 | switch ($errno) { |
83 | - case UPLOAD_ERR_INI_SIZE: |
|
84 | - return "The uploaded file exceeds upload_max_filesize of php.ini."; break; |
|
85 | - case UPLOAD_ERR_FORM_SIZE: |
|
86 | - return "The uploaded file exceeds the MAX_FILE_SIZE specified in the HTML form."; break; |
|
87 | - case UPLOAD_ERR_PARTIAL: |
|
88 | - return "The uploaded file was only partially uploaded."; break; |
|
89 | - case UPLOAD_ERR_NO_FILE: |
|
90 | - return "No file was uploaded."; break; |
|
91 | - case UPLOAD_ERR_NO_TMP_DIR: |
|
92 | - return "Missing a temporary folder."; break; |
|
93 | - case UPLOAD_ERR_CANT_WRITE: |
|
94 | - return "Failed to write file to disk."; break; |
|
95 | - case UPLOAD_ERR_EXTENSION: |
|
96 | - return "A PHP extension stopped the file upload."; break; |
|
83 | + case UPLOAD_ERR_INI_SIZE: |
|
84 | + return "The uploaded file exceeds upload_max_filesize of php.ini."; break; |
|
85 | + case UPLOAD_ERR_FORM_SIZE: |
|
86 | + return "The uploaded file exceeds the MAX_FILE_SIZE specified in the HTML form."; break; |
|
87 | + case UPLOAD_ERR_PARTIAL: |
|
88 | + return "The uploaded file was only partially uploaded."; break; |
|
89 | + case UPLOAD_ERR_NO_FILE: |
|
90 | + return "No file was uploaded."; break; |
|
91 | + case UPLOAD_ERR_NO_TMP_DIR: |
|
92 | + return "Missing a temporary folder."; break; |
|
93 | + case UPLOAD_ERR_CANT_WRITE: |
|
94 | + return "Failed to write file to disk."; break; |
|
95 | + case UPLOAD_ERR_EXTENSION: |
|
96 | + return "A PHP extension stopped the file upload."; break; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return $x; |
52 | 52 | } |
53 | 53 | |
54 | -function pm_team_form($user, $teamid, $error=null) { |
|
54 | +function pm_team_form($user, $teamid, $error = null) { |
|
55 | 55 | global $bbcode_html, $bbcode_js; |
56 | 56 | $team = BoincTeam::lookup_id($teamid); |
57 | 57 | if (!$team) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | error_page("not admin"); |
62 | 62 | } |
63 | 63 | |
64 | - page_head(tra("Send message to team"),'','','', $bbcode_js); |
|
64 | + page_head(tra("Send message to team"), '', '', '', $bbcode_js); |
|
65 | 65 | |
66 | 66 | $subject = post_str("subject", true); |
67 | 67 | $content = post_str("content", true); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | function pm_form_page($replyto, $userid, $error = null) { |
114 | 114 | global $bbcode_html, $bbcode_js; |
115 | 115 | global $g_logged_in_user; |
116 | - page_head(tra("Send private message"),'','','', $bbcode_js); |
|
116 | + page_head(tra("Send private message"), '', '', '', $bbcode_js); |
|
117 | 117 | |
118 | 118 | if (post_str("preview", true) == tra("Preview")) { |
119 | 119 | $content = post_str("content", true); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | if (!$user) { |
138 | 138 | error_page("Sender no longer exists"); |
139 | 139 | } |
140 | - $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")"; |
|
140 | + $writeto = UNIQUE_USER_NAME ? $user->name : $userid." (".$user->name.")"; |
|
141 | 141 | $subject = $message->subject; |
142 | 142 | if (substr($subject, 0, 3) != "re:") { |
143 | 143 | $subject = "re: ".$subject; |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | time_str($user->prefs->banished_until) |
157 | 157 | ); |
158 | 158 | } |
159 | - $writeto = UNIQUE_USER_NAME?$user->name:$userid." (".$user->name.")"; |
|
159 | + $writeto = UNIQUE_USER_NAME ? $user->name : $userid." (".$user->name.")"; |
|
160 | 160 | } else { |
161 | 161 | $writeto = sanitize_tags(post_str("to", true)); |
162 | 162 | $subject = post_str("subject", true); |
163 | 163 | $content = post_str("content", true); |
164 | 164 | } |
165 | 165 | |
166 | - $content = $content?htmlspecialchars($content):''; |
|
167 | - $subject = $subject?htmlspecialchars($subject):''; |
|
166 | + $content = $content ?htmlspecialchars($content) : ''; |
|
167 | + $subject = $subject ?htmlspecialchars($subject) : ''; |
|
168 | 168 | |
169 | 169 | if ($error != null) { |
170 | 170 | echo "<p class=\"text-danger\">".$error."</p>\n"; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | function send_pm_notification_email( |
221 | 221 | $logged_in_user, $to_user, $subject, $content |
222 | 222 | ) { |
223 | - $message = " |
|
223 | + $message = " |
|
224 | 224 | You have received a new private message at ".PROJECT.". |
225 | 225 | |
226 | 226 | From: $logged_in_user->name (ID $logged_in_user->id) |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $pm = BoincPrivateMessage::lookup_id($notify->opaque); |
251 | 251 | $from_user = BoincUser::lookup_id($pm->senderid); |
252 | 252 | if (!$pm || !$from_user) return null; |
253 | - return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject"; |
|
253 | + return "<a href=pm.php>".tra("Private message%1 from %2, subject:", "</a>", $from_user->name)." $pm->subject"; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) { |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | |
315 | 315 | function pm_email_remind($user) { |
316 | 316 | if (!$user->prefs->pm_notification) { |
317 | - return "<br><small>" . |
|
317 | + return "<br><small>". |
|
318 | 318 | tra( |
319 | 319 | "For email notification, %1 edit community prefs %2", |
320 | 320 | '<a href="edit_forum_preferences_form.php">', '</a>' |
321 | - ) . |
|
321 | + ). |
|
322 | 322 | "</small>" |
323 | 323 | ; |
324 | 324 | } |
@@ -293,13 +293,13 @@ |
||
293 | 293 | // Older clients may have the old-style serialnum in the DB |
294 | 294 | // despite the server being upgraded. |
295 | 295 | // |
296 | -function vbox_desc($parsed_ser){ |
|
296 | +function vbox_desc($parsed_ser) { |
|
297 | 297 | if (empty($parsed_ser['vbox'])) return '---'; |
298 | 298 | $f = $parsed_ser['vbox']; |
299 | 299 | $desc = sprintf('Virtualbox (%s) %s', |
300 | 300 | $f[1], tra("installed") |
301 | 301 | ); |
302 | - if (sizeof($f)<=2){ |
|
302 | + if (sizeof($f)<=2) { |
|
303 | 303 | return $desc; |
304 | 304 | } |
305 | 305 | if ($f[2]=="1" and $f[3]=="1") { |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | function sched_log_name($x) { |
34 | 34 | if ($x == 0) return "NO_SUCH_LOG"; |
35 | - return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt"; |
|
35 | + return gmdate('Y-m-d_H/Y-m-d_H:i', $x).".txt"; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function sched_log_link($x) { |
39 | 39 | if (file_exists("sched_logs")) { |
40 | - return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>"; |
|
40 | + return "<a href=\"../sched_logs/".sched_log_name($x)."\">".time_str($x)."</a>"; |
|
41 | 41 | } else { |
42 | 42 | return time_str($x); |
43 | 43 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | function location_form($host) { |
47 | 47 | $none = "selected"; |
48 | - $h=$w=$s=$m=""; |
|
48 | + $h = $w = $s = $m = ""; |
|
49 | 49 | if ($host->venue == "home") $h = "selected"; |
50 | 50 | if ($host->venue == "work") $w = "selected"; |
51 | 51 | if ($host->venue == "school") $s = "selected"; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | row2(tra("Product name"), $host->product_name); |
100 | 100 | } |
101 | 101 | $x = $host->timezone/3600; |
102 | - if ($x >= 0) $x="+$x"; |
|
102 | + if ($x >= 0) $x = "+$x"; |
|
103 | 103 | row2(tra("Local Standard Time"), tra("UTC %1 hours", $x)); |
104 | 104 | } else { |
105 | 105 | $owner = BoincUser::lookup_id($host->userid); |
@@ -293,20 +293,20 @@ discard block |
||
293 | 293 | // Older clients may have the old-style serialnum in the DB |
294 | 294 | // despite the server being upgraded. |
295 | 295 | // |
296 | -function vbox_desc($parsed_ser){ |
|
296 | +function vbox_desc($parsed_ser) { |
|
297 | 297 | if (empty($parsed_ser['vbox'])) return '---'; |
298 | 298 | $f = $parsed_ser['vbox']; |
299 | 299 | $desc = sprintf('Virtualbox (%s) %s', |
300 | 300 | $f[1], tra("installed") |
301 | 301 | ); |
302 | - if (sizeof($f)<=2){ |
|
302 | + if (sizeof($f) <= 2) { |
|
303 | 303 | return $desc; |
304 | 304 | } |
305 | - if ($f[2]=="1" and $f[3]=="1") { |
|
305 | + if ($f[2] == "1" and $f[3] == "1") { |
|
306 | 306 | return $desc.tra(", CPU has hardware virtualization support and it is enabled"); |
307 | - } elseif ($f[2]=="1" and $f[3]=="0") { |
|
307 | + } elseif ($f[2] == "1" and $f[3] == "0") { |
|
308 | 308 | return $desc.tra(", CPU has hardware virtualization support but it is disabled"); |
309 | - } elseif ($f[2]=="0") { |
|
309 | + } elseif ($f[2] == "0") { |
|
310 | 310 | return $desc.tra(", CPU does not have hardware virtualization support"); |
311 | 311 | } |
312 | 312 | return $desc; |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | |
332 | 332 | // return a human-readable version of the GPU info |
333 | 333 | // |
334 | -function gpu_desc($parsed_ser, $detail=true) { |
|
334 | +function gpu_desc($parsed_ser, $detail = true) { |
|
335 | 335 | $str = ""; |
336 | 336 | foreach ($parsed_ser as $d) { |
337 | 337 | if (!is_gpu_type($d[0])) continue; |
338 | 338 | if (count($d) < 4) continue; |
339 | 339 | if ($str) $str .= "<p>"; |
340 | - if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] "; |
|
340 | + if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] "; |
|
341 | 341 | if ($d[0] == "CUDA") { |
342 | 342 | $str .= "NVIDIA"; |
343 | 343 | } else if ($d[0] == "CAL") { |
@@ -543,14 +543,14 @@ discard block |
||
543 | 543 | if ($pos1 === false) return $x; |
544 | 544 | $pos2 = strpos($model, ']'); |
545 | 545 | if ($pos2 === false) return $x; |
546 | - $a = substr($model, $pos1+1, $pos2-$pos1-1); |
|
546 | + $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1); |
|
547 | 547 | $y = explode(" ", $a); |
548 | 548 | if (count($y) == 0) return $x; |
549 | 549 | if ($y[0] == "Family") { |
550 | 550 | $x->info = $a; |
551 | 551 | } else { |
552 | 552 | $x->arch = $y[0]; |
553 | - $x->info = substr($a, strlen($y[0])+1); |
|
553 | + $x->info = substr($a, strlen($y[0]) + 1); |
|
554 | 554 | } |
555 | 555 | return $x; |
556 | 556 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | $avg_time = 0; |
640 | 640 | |
641 | 641 | $results = BoincResult::enum("hostid=$hostid order by received_time"); |
642 | - foreach($results as $result) { |
|
642 | + foreach ($results as $result) { |
|
643 | 643 | if ($result->granted_credit <= 0) continue; |
644 | 644 | $total += $result->granted_credit; |
645 | 645 | |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | |
733 | 733 | function link_url($sort, $rev, $show_all) { |
734 | 734 | global $userid; |
735 | - $x = $userid ? "&userid=$userid":""; |
|
735 | + $x = $userid ? "&userid=$userid" : ""; |
|
736 | 736 | return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x"; |
737 | 737 | } |
738 | 738 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | } |
807 | 807 | |
808 | 808 | function show_user_hosts($userid, $private, $show_all, $sort, $rev) { |
809 | - $desc = false; // whether the sort order's default is decreasing |
|
809 | + $desc = false; // whether the sort order's default is decreasing |
|
810 | 810 | switch ($sort) { |
811 | 811 | case "total_credit": $sort_clause = "total_credit"; $desc = true; break; |
812 | 812 | case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break; |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | more_or_less($sort, $rev, $show_all); |
830 | 830 | |
831 | 831 | $now = time(); |
832 | - $old_hosts=0; |
|
832 | + $old_hosts = 0; |
|
833 | 833 | $i = 1; |
834 | 834 | $hosts = BoincHost::enum("userid=$userid order by $sort_clause limit 100"); |
835 | 835 | $any_product_name = false; |
@@ -841,9 +841,9 @@ discard block |
||
841 | 841 | } |
842 | 842 | user_host_table_start($private, $sort, $rev, $show_all, $any_product_name); |
843 | 843 | foreach ($hosts as $host) { |
844 | - $is_old=false; |
|
844 | + $is_old = false; |
|
845 | 845 | if (($now - $host->rpc_time) > 30*86400) { |
846 | - $is_old=true; |
|
846 | + $is_old = true; |
|
847 | 847 | $old_hosts++; |
848 | 848 | } |
849 | 849 | if (!$show_all && $is_old) continue; |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | } |
853 | 853 | end_table(); |
854 | 854 | |
855 | - if ($old_hosts>0) { |
|
855 | + if ($old_hosts > 0) { |
|
856 | 856 | more_or_less($sort, $rev, $show_all); |
857 | 857 | } |
858 | 858 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | $desc->long_name, |
38 | 38 | $desc->description, |
39 | 39 | kw_array_to_str($desc->sci_kw), |
40 | - empty($desc->url)?'':"<a href=$desc->url>View</a>", |
|
40 | + empty($desc->url) ? '' : "<a href=$desc->url>View</a>", |
|
41 | 41 | 'Yes' |
42 | 42 | ); |
43 | 43 | } |
@@ -210,7 +210,7 @@ |
||
210 | 210 | ]; |
211 | 211 | } else { |
212 | 212 | $x[] = [ |
213 | - "Manage $app->name", |
|
213 | + "manage $app->name", |
|
214 | 214 | "manage_project.php" |
215 | 215 | ]; |
216 | 216 | } |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | // prefix for links; needed for pages not in top dir |
142 | 142 | $user, |
143 | 143 | // logged-in user, if any |
144 | - $fixed=false, |
|
144 | + $fixed = false, |
|
145 | 145 | // if true, navbar is fixed at top of page. |
146 | 146 | // NOTE: if you do this, you must set a global var $fixed_navbar |
147 | 147 | // to true at compile time |
148 | 148 | // (it needs to be set when page_head() is called). |
149 | - $inverse=false |
|
149 | + $inverse = false |
|
150 | 150 | // white on black? |
151 | 151 | ) { |
152 | 152 | $master_url = master_url(); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | // output a panel. |
247 | 247 | // $content_func is a function that generates the panel contents |
248 | 248 | // |
249 | -function panel($title, $content_func, $class="panel-primary", $body_class="") { |
|
249 | +function panel($title, $content_func, $class = "panel-primary", $body_class = "") { |
|
250 | 250 | echo sprintf('<div class="panel %s"> |
251 | 251 | ', $class |
252 | 252 | ); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | // $left_width is the width of left column in 1/12 units. |
274 | 274 | // $arg is passed to the functions. |
275 | 275 | // |
276 | -function grid($top_func, $left_func, $right_func, $left_width=6, $arg=null) { |
|
276 | +function grid($top_func, $left_func, $right_func, $left_width = 6, $arg = null) { |
|
277 | 277 | echo ' |
278 | 278 | <div class="container-fluid"> |
279 | 279 | '; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | </div> |
289 | 289 | '; |
290 | 290 | } |
291 | - $right_width = 12-$left_width; |
|
291 | + $right_width = 12 - $left_width; |
|
292 | 292 | echo ' |
293 | 293 | <div class="row"> |
294 | 294 | <div class="col-sm-'.$left_width.'"> |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | // use extra = "name=x" |
313 | 313 | // call forum_focus(x, foo) after defining the field |
314 | 314 | // |
315 | -function form_start($action, $method='get', $extra='') { |
|
315 | +function form_start($action, $method = 'get', $extra = '') { |
|
316 | 316 | echo sprintf( |
317 | 317 | '<div class="container-fluid"> |
318 | 318 | <form class="form-horizontal" method="%s" action="%s" %s>' |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | // just the input field |
345 | 345 | // |
346 | 346 | function form_input_text_field( |
347 | - $name, $value='', $type='text', $attrs='', $extra='' |
|
347 | + $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
348 | 348 | ) { |
349 | 349 | return sprintf( |
350 | 350 | '<input %s type="%s" class="form-control" name="%s" value="%s">%s', |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | // the whole row |
356 | 356 | // |
357 | 357 | function form_input_text( |
358 | - $label, $name, $value='', $type='text', $attrs='', $extra='' |
|
358 | + $label, $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
359 | 359 | ) { |
360 | 360 | echo sprintf(' |
361 | 361 | <div class="form-group"> |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | ); |
384 | 384 | } |
385 | 385 | |
386 | -function form_input_textarea($label, $name, $value='', $nrows=4) { |
|
386 | +function form_input_textarea($label, $name, $value = '', $nrows = 4) { |
|
387 | 387 | echo sprintf(' |
388 | 388 | <div class="form-group"> |
389 | 389 | <label align=right class="%s" for="%s">%s</label> |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | // $items is either a string of <option> elements, |
401 | 401 | // or an array of [value, name] pairs |
402 | 402 | // |
403 | -function form_select($label, $name, $items, $selected=null) { |
|
403 | +function form_select($label, $name, $items, $selected = null) { |
|
404 | 404 | echo sprintf(' |
405 | 405 | <div class="form-group"> |
406 | 406 | <label align=right class="%s" for="%s">%s</label> |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | foreach ($items as $i) { |
414 | 414 | echo sprintf( |
415 | 415 | '<option %s value=%s>%s</option>', |
416 | - ($i[0]==$selected)?'selected':'', |
|
416 | + ($i[0] == $selected) ? 'selected' : '', |
|
417 | 417 | $i[0], $i[1] |
418 | 418 | ); |
419 | 419 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | // same, for multiple select. |
427 | 427 | // $selected, if non-null, is a list of selected values |
428 | 428 | // |
429 | -function form_select_multiple($label, $name, $items, $selected=null, $size=0) { |
|
429 | +function form_select_multiple($label, $name, $items, $selected = null, $size = 0) { |
|
430 | 430 | echo sprintf(' |
431 | 431 | <div class="form-group"> |
432 | 432 | <label align=right class="%s" for="%s">%s</label> |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | foreach ($items as $i) { |
439 | 439 | echo sprintf( |
440 | 440 | '<option %s value=%s>%s</option>', |
441 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
441 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
442 | 442 | $i[0], $i[1] |
443 | 443 | ); |
444 | 444 | } |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | |
448 | 448 | // return a list of strings for checkbox items |
449 | 449 | // |
450 | -function checkbox_item_strings($items, $attrs='') { |
|
450 | +function checkbox_item_strings($items, $attrs = '') { |
|
451 | 451 | $x = []; |
452 | 452 | foreach ($items as $i) { |
453 | 453 | $x[] = sprintf('<input %s type="checkbox" name="%s" %s> %s |
454 | 454 | ', |
455 | - $attrs, $i[0], $i[2]?"checked":"", $i[1] |
|
455 | + $attrs, $i[0], $i[2] ? "checked" : "", $i[1] |
|
456 | 456 | ); |
457 | 457 | } |
458 | 458 | return $x; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | |
461 | 461 | // $items is list of (name, label, checked) |
462 | 462 | // |
463 | -function form_checkboxes($label, $items, $attrs='') { |
|
463 | +function form_checkboxes($label, $items, $attrs = '') { |
|
464 | 464 | echo sprintf(' |
465 | 465 | <div class="form-group"> |
466 | 466 | <label align=right class="%s">%s</label> |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | // |
480 | 480 | function form_radio_buttons( |
481 | 481 | $label, $name, $items, $selected, |
482 | - $assign_ids=false // assign IDs to buttons based on names |
|
482 | + $assign_ids = false // assign IDs to buttons based on names |
|
483 | 483 | ) { |
484 | 484 | echo sprintf(' |
485 | 485 | <div class="form-group"> |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS |
490 | 490 | ); |
491 | 491 | foreach ($items as $i) { |
492 | - $checked = ($selected == $i[0])?"checked":""; |
|
492 | + $checked = ($selected == $i[0]) ? "checked" : ""; |
|
493 | 493 | if ($assign_ids) { |
494 | 494 | $id = sprintf('id="%s_%s"', $name, $i[0]); |
495 | 495 | } else { |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | '; |
528 | 528 | } |
529 | 529 | |
530 | -function form_submit($text, $attrs='') { |
|
530 | +function form_submit($text, $attrs = '') { |
|
531 | 531 | form_general( |
532 | 532 | "", |
533 | 533 | sprintf( |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | ); |
538 | 538 | } |
539 | 539 | |
540 | -function form_checkbox($label, $name, $checked=false) { |
|
540 | +function form_checkbox($label, $name, $checked = false) { |
|
541 | 541 | echo sprintf(' |
542 | 542 | <div class="form-group"> |
543 | 543 | <label align=right class="%s">%s</label> |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | <input type="checkbox" name="%s" %s> |
550 | 550 | </div> |
551 | 551 | </div> |
552 | - ', $name, $checked?"checked":"" |
|
552 | + ', $name, $checked ? "checked" : "" |
|
553 | 553 | ); |
554 | 554 | } |
555 | 555 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | // $selected is the list of selected values. |
578 | 578 | // $extra is e.g. id=foo |
579 | 579 | // |
580 | -function form_select2_multi($label, $name, $items, $selected=null, $extra='') { |
|
580 | +function form_select2_multi($label, $name, $items, $selected = null, $extra = '') { |
|
581 | 581 | echo sprintf(' |
582 | 582 | <div class="form-group"> |
583 | 583 | <label align=right class="%s" for="%s">%s</label> |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | foreach ($items as $i) { |
590 | 590 | echo sprintf( |
591 | 591 | '<option %s value=%s>%s</option>', |
592 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
592 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
593 | 593 | $i[0], $i[1] |
594 | 594 | ); |
595 | 595 | } |
@@ -362,12 +362,12 @@ |
||
362 | 362 | $db = BoincDb::get(); |
363 | 363 | return $db->enum('result', 'BoincResult', $where_clause); |
364 | 364 | } |
365 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
365 | + static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
366 | 366 | $db = BoincDb::get(); |
367 | - return $db->enum_fields( |
|
367 | + return $db->enum_fields( |
|
368 | 368 | 'result', 'BoincResult', $fields, $where_clause, $order_clause |
369 | 369 | ); |
370 | - } |
|
370 | + } |
|
371 | 371 | function update($clause) { |
372 | 372 | $db = BoincDb::get(); |
373 | 373 | return $db->update($this, 'result', $clause); |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | // close() closes the connection. |
45 | 45 | |
46 | 46 | class BoincDb { |
47 | - static $instance; // a DbConn object, or null |
|
48 | - static $dbnum; // which replica we're connected to |
|
47 | + static $instance; // a DbConn object, or null |
|
48 | + static $dbnum; // which replica we're connected to |
|
49 | 49 | |
50 | 50 | // connect to DB $dbnum (0, 1, ...) |
51 | 51 | // If the requested DB doesn't exist or connection fails, connect to DB 0. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | self::$instance = null; |
57 | 57 | $config = get_config(); |
58 | 58 | if ($dbnum) { |
59 | - $r = $dbnum==1?'':strval($dbnum); |
|
59 | + $r = $dbnum == 1 ? '' : strval($dbnum); |
|
60 | 60 | $host = parse_config($config, sprintf('<replica%s_db_host>', $r)); |
61 | 61 | $name = parse_config($config, sprintf('<replica%s_db_name>', $r)); |
62 | 62 | $user = parse_config($config, sprintf('<replica%s_db_user>', $r)); |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | $db = BoincDb::get(); |
205 | 205 | return $db->update($this, 'user', $clause); |
206 | 206 | } |
207 | - static function enum($where_clause, $order_clause=null) { |
|
207 | + static function enum($where_clause, $order_clause = null) { |
|
208 | 208 | $db = BoincDb::get(); |
209 | 209 | return $db->enum('user', 'BoincUser', $where_clause, $order_clause); |
210 | 210 | } |
211 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
211 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
212 | 212 | $db = BoincDb::get(); |
213 | 213 | return $db->enum_fields( |
214 | 214 | 'user', 'BoincUser', $fields, $where_clause, $order_clause |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $db = BoincDb::get(); |
259 | 259 | return $db->update($this, 'team', $clause); |
260 | 260 | } |
261 | - static function enum($where_clause, $order_clause=null) { |
|
261 | + static function enum($where_clause, $order_clause = null) { |
|
262 | 262 | $db = BoincDb::get(); |
263 | 263 | return $db->enum('team', 'BoincTeam', $where_clause, $order_clause); |
264 | 264 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $db = BoincDb::get(); |
284 | 284 | return $db->max('team', $field); |
285 | 285 | } |
286 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
286 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
287 | 287 | $db = BoincDb::get(); |
288 | 288 | return $db->enum_fields( |
289 | 289 | 'team', 'BoincTeam', $fields, $where_clause, $order_clause |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | $db = BoincDb::get(); |
322 | 322 | return $db->delete($this, 'host'); |
323 | 323 | } |
324 | - static function enum($where_clause, $order_clause=null) { |
|
324 | + static function enum($where_clause, $order_clause = null) { |
|
325 | 325 | $db = BoincDb::get(); |
326 | 326 | return $db->enum('host', 'BoincHost', $where_clause, $order_clause); |
327 | 327 | } |
328 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
328 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
329 | 329 | $db = BoincDb::get(); |
330 | 330 | return $db->enum_fields( |
331 | 331 | 'host', 'BoincHost', $fields, $where_clause, $order_clause |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $db = BoincDb::get(); |
363 | 363 | return $db->enum('result', 'BoincResult', $where_clause); |
364 | 364 | } |
365 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
365 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
366 | 366 | $db = BoincDb::get(); |
367 | 367 | return $db->enum_fields( |
368 | 368 | 'result', 'BoincResult', $fields, $where_clause, $order_clause |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $db = BoincDb::get(); |
412 | 412 | return $db->enum('workunit', 'BoincWorkunit', $where_clause); |
413 | 413 | } |
414 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
414 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
415 | 415 | $db = BoincDb::get(); |
416 | 416 | return $db->enum_fields('workunit', 'BoincWorkunit', $fields, $where_clause, $order_clause); |
417 | 417 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | $db = BoincDb::get(); |
454 | 454 | return $db->update($this, 'app', $clause); |
455 | 455 | } |
456 | - static function sum($field, $clause=null) { |
|
456 | + static function sum($field, $clause = null) { |
|
457 | 457 | $db = BoincDb::get(); |
458 | 458 | return $db->sum('app', $field, $clause); |
459 | 459 | } |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | $db = BoincDb::get(); |
512 | 512 | return $db->insert('profile', $clause); |
513 | 513 | } |
514 | - static function enum($where_clause=null, $order_clause=null) { |
|
514 | + static function enum($where_clause = null, $order_clause = null) { |
|
515 | 515 | $db = BoincDb::get(); |
516 | 516 | return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause); |
517 | 517 | } |
518 | - static function enum_fields($fields, $where_clause=null, $order_clause=null) { |
|
518 | + static function enum_fields($fields, $where_clause = null, $order_clause = null) { |
|
519 | 519 | $db = BoincDb::get(); |
520 | 520 | return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause); |
521 | 521 | } |
@@ -910,12 +910,12 @@ discard block |
||
910 | 910 | return $db->enum('consent', 'BoincConsent', $where_clause); |
911 | 911 | } |
912 | 912 | |
913 | - static function insert ($clause) { |
|
913 | + static function insert($clause) { |
|
914 | 914 | $db = BoincDb::get(); |
915 | 915 | return $db->insert('consent', $clause); |
916 | 916 | } |
917 | 917 | |
918 | - static function update ($clause) { |
|
918 | + static function update($clause) { |
|
919 | 919 | $db = BoincDb::get(); |
920 | 920 | return $db->update_aux('consent', $clause); |
921 | 921 | } |
@@ -940,17 +940,17 @@ discard block |
||
940 | 940 | return $db->lookup('consent_type', 'BoincConsentType', $clause); |
941 | 941 | } |
942 | 942 | |
943 | - static function enum($where_clause, $order_clause=null) { |
|
943 | + static function enum($where_clause, $order_clause = null) { |
|
944 | 944 | $db = BoincDb::get(); |
945 | 945 | return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause); |
946 | 946 | } |
947 | 947 | |
948 | - static function insert ($clause) { |
|
948 | + static function insert($clause) { |
|
949 | 949 | $db = BoincDb::get(); |
950 | 950 | return $db->insert('consent_type', $clause); |
951 | 951 | } |
952 | 952 | |
953 | - static function update ($clause) { |
|
953 | + static function update($clause) { |
|
954 | 954 | $db = BoincDb::get(); |
955 | 955 | return $db->update_aux('consent_type', $clause); |
956 | 956 | } |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | return $db->lookup('latest_consent', 'BoincLatestConsent', $clause); |
977 | 977 | } |
978 | 978 | |
979 | - static function enum($where_clause, $order_clause=null) { |
|
979 | + static function enum($where_clause, $order_clause = null) { |
|
980 | 980 | $db = BoincDb::get(); |
981 | 981 | return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause); |
982 | 982 | } |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | // apply this to any user-supplied strings used in queries |
988 | 988 | // |
989 | 989 | function boinc_real_escape_string($x) { |
990 | - if (version_compare(phpversion(),"4.3.0")>=0) { |
|
990 | + if (version_compare(phpversion(), "4.3.0") >= 0) { |
|
991 | 991 | return BoincDb::escape_string($x); |
992 | 992 | } else { |
993 | 993 | $x = str_replace("'", "\'", $x); |