@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // they've participated in |
34 | 34 | // |
35 | 35 | function get_other_projects($user) { |
36 | - $cpid = md5($user->cross_project_id . $user->email_addr); |
|
36 | + $cpid = md5($user->cross_project_id.$user->email_addr); |
|
37 | 37 | $url = "http://boinc.netsoft-online.com/get_user.php?cpid=".$cpid; |
38 | 38 | |
39 | 39 | // Check the cache for that URL |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | usort($user->projects, "cmp"); |
123 | 123 | if ($personal) { |
124 | - $t = tra("Projects in which you are participating"); |
|
124 | + $t = tra("Projects in which you are participating"); |
|
125 | 125 | } else { |
126 | 126 | $t = tra("Projects in which %1 is participating", $user->name); |
127 | 127 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | if (!NO_STATS) { |
183 | - $cpid = md5($user->cross_project_id . $user->email_addr); |
|
183 | + $cpid = md5($user->cross_project_id.$user->email_addr); |
|
184 | 184 | $x = ""; |
185 | 185 | shuffle($cpid_stats_sites); |
186 | 186 | foreach ($cpid_stats_sites as $site) { |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $u = normalize_user_url($user->url); |
267 | 267 | row2( |
268 | 268 | tra("URL"), |
269 | - $u?sprintf('<a href="%s">%s</a>', $u, $u):tra('Invalid URL') |
|
269 | + $u ?sprintf('<a href="%s">%s</a>', $u, $u) : tra('Invalid URL') |
|
270 | 270 | ); |
271 | 271 | } |
272 | 272 | if (USER_COUNTRY) { |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | // if $badge_height is > 0, show badges |
378 | 378 | // if $name_limit, limit name to N chars |
379 | 379 | // |
380 | -function user_links($user, $badge_height=0, $name_limit=0) { |
|
380 | +function user_links($user, $badge_height = 0, $name_limit = 0) { |
|
381 | 381 | if (!$user) { |
382 | 382 | error_log("user_links(): null arg\n"); |
383 | 383 | return; |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | $user->id, |
410 | 410 | $name |
411 | 411 | ); |
412 | - if (function_exists("project_user_links")){ |
|
412 | + if (function_exists("project_user_links")) { |
|
413 | 413 | $x .= project_user_links($user); |
414 | 414 | } |
415 | 415 | if ($badge_height) { |
416 | 416 | $x .= badges_string(true, $user, $badge_height); |
417 | 417 | } |
418 | - return $name_limit?"<nobr>$x</nobr>":$x; |
|
418 | + return $name_limit ? "<nobr>$x</nobr>" : $x; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | function show_community_private($user) { |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | |
463 | 463 | // if there's a foundership request, notify the founder |
464 | 464 | // |
465 | - if ($user->id==$team->userid && $team->ping_user >0) { |
|
465 | + if ($user->id == $team->userid && $team->ping_user > 0) { |
|
466 | 466 | $x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>"; |
467 | 467 | } |
468 | 468 | row2(tra("Member of team"), $x); |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
487 | 487 | $x = []; |
488 | 488 | if ($friends) { |
489 | - foreach($friends as $friend) { |
|
489 | + foreach ($friends as $friend) { |
|
490 | 490 | $fuser = BoincUser::lookup_id($friend->user_dest); |
491 | 491 | if (!$fuser) continue; |
492 | 492 | $x[] = friend_links($fuser); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | |
537 | 537 | // return an object with data to show the user's community links |
538 | 538 | // |
539 | -function get_community_links_object($user){ |
|
539 | +function get_community_links_object($user) { |
|
540 | 540 | $cache_object = new StdClass; |
541 | 541 | $cache_object->post_count = total_posts($user); |
542 | 542 | $cache_object->user = $user; |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | $cache_object->friends = array(); |
545 | 545 | |
546 | 546 | $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); |
547 | - foreach($friends as $friend) { |
|
547 | + foreach ($friends as $friend) { |
|
548 | 548 | $fuser = BoincUser::lookup_id($friend->user_dest); |
549 | 549 | if (!$fuser) continue; |
550 | 550 | $cache_object->friends[] = $fuser; |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | |
555 | 555 | // show community links of another user (described by $clo) |
556 | 556 | // |
557 | -function community_links($clo, $logged_in_user){ |
|
557 | +function community_links($clo, $logged_in_user) { |
|
558 | 558 | $user = $clo->user; |
559 | 559 | if (!$user) { |
560 | 560 | error_log("community_links(): null user\n"); |
@@ -584,15 +584,15 @@ discard block |
||
584 | 584 | "<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>" |
585 | 585 | ); |
586 | 586 | } else if ($friend) { |
587 | - row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
|
587 | + row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>"); |
|
588 | 588 | } else { |
589 | - row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
|
589 | + row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>"); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
593 | 593 | if ($friends) { |
594 | 594 | $x = []; |
595 | - foreach($friends as $friend) { |
|
595 | + foreach ($friends as $friend) { |
|
596 | 596 | $x[] = friend_links($friend); |
597 | 597 | } |
598 | 598 | row2(tra('Friends'), implode('<br>', $x)); |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | function sched_log_name($x) { |
34 | 34 | if ($x == 0) return "NO_SUCH_LOG"; |
35 | - return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt"; |
|
35 | + return gmdate('Y-m-d_H/Y-m-d_H:i', $x).".txt"; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function sched_log_link($x) { |
39 | 39 | if (file_exists("sched_logs")) { |
40 | - return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>"; |
|
40 | + return "<a href=\"../sched_logs/".sched_log_name($x)."\">".time_str($x)."</a>"; |
|
41 | 41 | } else { |
42 | 42 | return time_str($x); |
43 | 43 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | function location_form($host) { |
47 | 47 | $none = "selected"; |
48 | - $h=$w=$s=$m=""; |
|
48 | + $h = $w = $s = $m = ""; |
|
49 | 49 | if ($host->venue == "home") $h = "selected"; |
50 | 50 | if ($host->venue == "work") $w = "selected"; |
51 | 51 | if ($host->venue == "school") $s = "selected"; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | row2(tra("Product name"), $host->product_name); |
100 | 100 | } |
101 | 101 | $x = $host->timezone/3600; |
102 | - if ($x >= 0) $x="+$x"; |
|
102 | + if ($x >= 0) $x = "+$x"; |
|
103 | 103 | row2(tra("Local Standard Time"), tra("UTC %1 hours", $x)); |
104 | 104 | } else { |
105 | 105 | $owner = BoincUser::lookup_id($host->userid); |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | // "[vbox|5.0.0|1|1]", where now two additional flags give information about |
260 | 260 | // hardware virtualization support. Older clients may have the old-style |
261 | 261 | // serialnum in the DB despite the server being upgraded. |
262 | -function vbox_desc($x){ |
|
263 | - if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/",$x,$matches)){ |
|
262 | +function vbox_desc($x) { |
|
263 | + if (preg_match("/\[vbox\|(.*?)(\|([01])\|([01]))?\]/", $x, $matches)) { |
|
264 | 264 | $desc = "Virtualbox (".$matches[1].") ".tra("installed"); |
265 | - if (sizeof($matches)>2){ |
|
266 | - if ($matches[3]=="1" and $matches[4]=="1") { |
|
265 | + if (sizeof($matches) > 2) { |
|
266 | + if ($matches[3] == "1" and $matches[4] == "1") { |
|
267 | 267 | return $desc.tra(", CPU has hardware virtualization support and it is enabled"); |
268 | - } elseif ($matches[3]=="1" and $matches[4]=="0") { |
|
268 | + } elseif ($matches[3] == "1" and $matches[4] == "0") { |
|
269 | 269 | return $desc.tra(", CPU has hardware virtualization support but it is disabled"); |
270 | - } elseif ($matches[3]=="0") { |
|
270 | + } elseif ($matches[3] == "0") { |
|
271 | 271 | return $desc.tra(", CPU does not have hardware virtualization support"); |
272 | 272 | } |
273 | 273 | } else { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | // Given string of the form [BOINC|vers][type|model|count|RAM|driver-vers][vbox|vers], |
282 | 282 | // return a human-readable version of the GPU info |
283 | 283 | // |
284 | -function gpu_desc($x, $detail=true) { |
|
284 | +function gpu_desc($x, $detail = true) { |
|
285 | 285 | $descs = explode("]", $x); |
286 | 286 | array_pop($descs); |
287 | 287 | $str = ""; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | if ($d[0] == "vbox") continue; |
294 | 294 | if (count($d) < 4) continue; |
295 | 295 | if ($str) $str .= "<p>"; |
296 | - if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] "; |
|
296 | + if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] "; |
|
297 | 297 | if ($d[0] == "CUDA") { |
298 | 298 | $str .= "NVIDIA"; |
299 | 299 | } else if ($d[0] == "CAL") { |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | if ($pos1 === false) return $x; |
501 | 501 | $pos2 = strpos($model, ']'); |
502 | 502 | if ($pos2 === false) return $x; |
503 | - $a = substr($model, $pos1+1, $pos2-$pos1-1); |
|
503 | + $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1); |
|
504 | 504 | $y = explode(" ", $a); |
505 | 505 | if (count($y) == 0) return $x; |
506 | 506 | if ($y[0] == "Family") { |
507 | 507 | $x->info = $a; |
508 | 508 | } else { |
509 | 509 | $x->arch = $y[0]; |
510 | - $x->info = substr($a, strlen($y[0])+1); |
|
510 | + $x->info = substr($a, strlen($y[0]) + 1); |
|
511 | 511 | } |
512 | 512 | return $x; |
513 | 513 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | $avg_time = 0; |
597 | 597 | |
598 | 598 | $results = BoincResult::enum("hostid=$hostid order by received_time"); |
599 | - foreach($results as $result) { |
|
599 | + foreach ($results as $result) { |
|
600 | 600 | if ($result->granted_credit <= 0) continue; |
601 | 601 | $total += $result->granted_credit; |
602 | 602 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | |
690 | 690 | function link_url($sort, $rev, $show_all) { |
691 | 691 | global $userid; |
692 | - $x = $userid ? "&userid=$userid":""; |
|
692 | + $x = $userid ? "&userid=$userid" : ""; |
|
693 | 693 | return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x"; |
694 | 694 | } |
695 | 695 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | } |
764 | 764 | |
765 | 765 | function show_user_hosts($userid, $private, $show_all, $sort, $rev) { |
766 | - $desc = false; // whether the sort order's default is decreasing |
|
766 | + $desc = false; // whether the sort order's default is decreasing |
|
767 | 767 | switch ($sort) { |
768 | 768 | case "total_credit": $sort_clause = "total_credit"; $desc = true; break; |
769 | 769 | case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break; |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | more_or_less($sort, $rev, $show_all); |
787 | 787 | |
788 | 788 | $now = time(); |
789 | - $old_hosts=0; |
|
789 | + $old_hosts = 0; |
|
790 | 790 | $i = 1; |
791 | 791 | $hosts = BoincHost::enum("userid=$userid order by $sort_clause"); |
792 | 792 | $any_product_name = false; |
@@ -798,9 +798,9 @@ discard block |
||
798 | 798 | } |
799 | 799 | user_host_table_start($private, $sort, $rev, $show_all, $any_product_name); |
800 | 800 | foreach ($hosts as $host) { |
801 | - $is_old=false; |
|
801 | + $is_old = false; |
|
802 | 802 | if (($now - $host->rpc_time) > 30*86400) { |
803 | - $is_old=true; |
|
803 | + $is_old = true; |
|
804 | 804 | $old_hosts++; |
805 | 805 | } |
806 | 806 | if (!$show_all && $is_old) continue; |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } |
810 | 810 | end_table(); |
811 | 811 | |
812 | - if ($old_hosts>0) { |
|
812 | + if ($old_hosts > 0) { |
|
813 | 813 | more_or_less($sort, $rev, $show_all); |
814 | 814 | } |
815 | 815 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if (!$user->has_profile) return null; |
72 | 72 | $profile = BoincProfile::lookup("userid=$user->id"); |
73 | 73 | if (!$profile->has_picture) return null; |
74 | - if (profile_screening() && $profile->verification!=1) return null; |
|
74 | + if (profile_screening() && $profile->verification != 1) return null; |
|
75 | 75 | return profile_thumb_url($user->id); |
76 | 76 | } |
77 | 77 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | return $image; |
126 | 126 | } |
127 | 127 | |
128 | - ($origWidth > $origHeight)? $scalar = ($origWidth / $targetWidth) : $scalar = ($origHeight / $targetHeight); |
|
128 | + ($origWidth > $origHeight) ? $scalar = ($origWidth/$targetWidth) : $scalar = ($origHeight/$targetHeight); |
|
129 | 129 | |
130 | 130 | if ($scalar != 0) { |
131 | - $destWidth = $origWidth / $scalar; |
|
132 | - $destHeight = $origHeight / $scalar; |
|
131 | + $destWidth = $origWidth/$scalar; |
|
132 | + $destHeight = $origHeight/$scalar; |
|
133 | 133 | } else { |
134 | 134 | $destWidth = $origWidth; |
135 | 135 | $destHeight = $origHeight; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $gd_info = gd_info(); |
139 | 139 | $v = $gd_info["GD Version"]; |
140 | 140 | $v = explode('.', $v); |
141 | - $v = (int)$v[0]; // major version |
|
141 | + $v = (int)$v[0]; // major version |
|
142 | 142 | if ($v >= 2) { |
143 | 143 | // If you are using a modern PHP/GD installation that does |
144 | 144 | // 'truecolor' images, this is what's needed. |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $options->htmlitems = false; |
182 | 182 | $temp = output_transform($profile->response1, $options); |
183 | 183 | $temp = sanitize_tags($temp); |
184 | - $description = "(\"" . sub_sentence($temp, ' ', MAX_DESC_LENGTH, true) . "\")"; |
|
184 | + $description = "(\"".sub_sentence($temp, ' ', MAX_DESC_LENGTH, true)."\")"; |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | function check_whether_to_show_profile($user, $logged_in_user) { |
193 | 193 | $min_credit = parse_config(get_config(), "<profile_min_credit>"); |
194 | - if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) { |
|
194 | + if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit) { |
|
195 | 195 | error_page( |
196 | 196 | tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit) |
197 | 197 | ); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | // |
230 | 230 | $show_picture = $profile->has_picture; |
231 | 231 | if (profile_screening()) { |
232 | - if (!$screen_mode && !$can_edit && $profile->verification!=1) { |
|
232 | + if (!$screen_mode && !$can_edit && $profile->verification != 1) { |
|
233 | 233 | $show_picture = false; |
234 | 234 | } |
235 | 235 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | // yet verified. This will tell them if other users can't view it yet, or |
246 | 246 | // if there is a problem with it and they need to replace it. |
247 | 247 | // |
248 | - if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification!=1) { |
|
248 | + if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification != 1) { |
|
249 | 249 | row1(offensive_profile_warning($profile->verification)); |
250 | 250 | } |
251 | 251 |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | require_once('../inc/sanitize_html.inc'); |
27 | 27 | |
28 | 28 | class output_options { |
29 | - var $bb2html; // BBCode as HTML? (on) |
|
30 | - var $images_as_links; // Images as hyperlinks? (off) |
|
31 | - var $link_popup; // Links in new windows? (off) |
|
32 | - var $nl2br; // Convert newlines to <br>'s? (on) |
|
33 | - var $htmlitems; // Convert special chars to HTML entities? (on) |
|
34 | - var $htmlscrub; // Scrub "bad" HTML tags? (off) |
|
35 | - var $highlight_terms;// Array of terms to be highlighted (off) |
|
29 | + var $bb2html; // BBCode as HTML? (on) |
|
30 | + var $images_as_links; // Images as hyperlinks? (off) |
|
31 | + var $link_popup; // Links in new windows? (off) |
|
32 | + var $nl2br; // Convert newlines to <br>'s? (on) |
|
33 | + var $htmlitems; // Convert special chars to HTML entities? (on) |
|
34 | + var $htmlscrub; // Scrub "bad" HTML tags? (off) |
|
35 | + var $highlight_terms; // Array of terms to be highlighted (off) |
|
36 | 36 | |
37 | 37 | // Constructor - set the defaults. |
38 | 38 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $options = new output_options; // Defaults in the class definition |
69 | 69 | } |
70 | 70 | if ($options->htmlitems) { |
71 | - $text = htmlspecialchars($text, ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE); |
|
71 | + $text = htmlspecialchars($text, ENT_COMPAT|ENT_HTML401|ENT_SUBSTITUTE); |
|
72 | 72 | } |
73 | 73 | if (is_array($options->highlight_terms)) { |
74 | 74 | $text = highlight_terms($text, $options->highlight_terms); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // If $export is true, don't use BOINC CSS |
105 | 105 | |
106 | 106 | function substr2($s, $n1, $n2) { |
107 | - return substr($s, $n1, $n2-$n1); |
|
107 | + return substr($s, $n1, $n2 - $n1); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | // process non-nestable constructs: [pre] and [code] |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)"; |
179 | 179 | // List of allowable tags |
180 | - $bbtags = array ( |
|
180 | + $bbtags = array( |
|
181 | 181 | "@\[b\](.*?)\[/b\]@is", |
182 | 182 | "@\[i\](.*?)\[/i\]@is", |
183 | 183 | "@\[u\](.*?)\[/u\]@is", |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | // What the above tags are turned in to |
208 | 208 | if ($export) { |
209 | - $htmltags = array ( |
|
209 | + $htmltags = array( |
|
210 | 210 | "<b>\\1</b>", |
211 | 211 | "<i>\\1</i>", |
212 | 212 | "<u>\\1</u>", |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | "<a href=\"https://github.com/BOINC/boinc/wiki/\\1\">\\1</a>", |
234 | 234 | ); |
235 | 235 | } else { |
236 | - $htmltags = array ( |
|
236 | + $htmltags = array( |
|
237 | 237 | "<b>\\1</b>", |
238 | 238 | "<i>\\1</i>", |
239 | 239 | "<u>\\1</u>", |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $lasttext = ""; |
266 | 266 | $i = 0; |
267 | 267 | // $i<1000 to prevent DoS |
268 | - while ($text != $lasttext && $i<1000) { |
|
268 | + while ($text != $lasttext && $i < 1000) { |
|
269 | 269 | $lasttext = $text; |
270 | 270 | $text = preg_replace($bbtags, $htmltags, $text); |
271 | 271 | $i = $i + 1; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | return $text; |
276 | 276 | } |
277 | 277 | |
278 | -function bb2html($text, $export=false) { |
|
278 | +function bb2html($text, $export = false) { |
|
279 | 279 | $text = replace_pre_code($text, $export); |
280 | 280 | return bb2html_aux($text, $export); |
281 | 281 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | // for example inside <pre> containers |
285 | 285 | // The original \n was retained after the br when it was added |
286 | 286 | // |
287 | -function remove_br($text){ |
|
287 | +function remove_br($text) { |
|
288 | 288 | return str_replace("<br />", "", $text); |
289 | 289 | } |
290 | 290 | |
@@ -292,19 +292,19 @@ discard block |
||
292 | 292 | // |
293 | 293 | function externalize_links($text) { |
294 | 294 | // TODO: Convert this to PCRE |
295 | - $i=0; |
|
296 | - $linkpos=true; |
|
295 | + $i = 0; |
|
296 | + $linkpos = true; |
|
297 | 297 | $out = ""; |
298 | - while (true){ |
|
298 | + while (true) { |
|
299 | 299 | // Find a link |
300 | 300 | // |
301 | - $linkpos=strpos($text, "<a ", $i); |
|
302 | - if ($linkpos===false) break; |
|
301 | + $linkpos = strpos($text, "<a ", $i); |
|
302 | + if ($linkpos === false) break; |
|
303 | 303 | |
304 | 304 | // Replace with target='_new' |
305 | 305 | // |
306 | - $out .= substr($text, $i, $linkpos-$i)."<a target=\"_new\" "; |
|
307 | - $i = $linkpos+3; |
|
306 | + $out .= substr($text, $i, $linkpos - $i)."<a target=\"_new\" "; |
|
307 | + $i = $linkpos + 3; |
|
308 | 308 | } |
309 | 309 | $out .= substr($text, $i); |
310 | 310 | return $out; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | // Converts image tags to links to the images. |
314 | 314 | // |
315 | -function image_as_link($text){ |
|
315 | +function image_as_link($text) { |
|
316 | 316 | $pattern = '@<img([\S\s]+?)src=([^>]+?)>@si'; |
317 | 317 | $replacement = '<a href=${2}>[Image link]</a>'; |
318 | 318 | return preg_replace($pattern, $replacement, $text); |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | return $platforms[$id]; |
54 | 54 | } |
55 | 55 | |
56 | -function anon_platform_string($result, $rsc_name=null) { |
|
56 | +function anon_platform_string($result, $rsc_name = null) { |
|
57 | 57 | $app = get_app($result->appid); |
58 | - $n = $app->user_friendly_name."<br>". tra("Anonymous platform"); |
|
58 | + $n = $app->user_friendly_name."<br>".tra("Anonymous platform"); |
|
59 | 59 | if ($rsc_name) { |
60 | 60 | $n .= " ($rsc_name)"; |
61 | 61 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return $string_to_show; |
100 | 100 | } |
101 | 101 | if ($result->server_state <> RESULT_SERVER_STATE_OVER) return "---"; |
102 | - switch($result->outcome) { |
|
102 | + switch ($result->outcome) { |
|
103 | 103 | case RESULT_OUTCOME_SUCCESS: |
104 | 104 | switch ($result->validate_state) { |
105 | 105 | case VALIDATE_STATE_INIT: |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | ) { |
215 | 215 | return tra("Not started by deadline - canceled"); |
216 | 216 | } |
217 | - switch($result->client_state) { |
|
217 | + switch ($result->client_state) { |
|
218 | 218 | case RESULT_FILES_DOWNLOADING: return tra("Error while downloading"); |
219 | 219 | case RESULT_FILES_DOWNLOADED: |
220 | 220 | case RESULT_COMPUTE_ERROR: return tra("Error while computing"); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | function result_server_state_string($result) { |
236 | - switch($result->server_state) { |
|
236 | + switch ($result->server_state) { |
|
237 | 237 | case RESULT_SERVER_STATE_INACTIVE: return tra("Inactive"); |
238 | 238 | case RESULT_SERVER_STATE_UNSENT: return tra("Unsent"); |
239 | 239 | case RESULT_SERVER_STATE_IN_PROGRESS: return tra("In progress"); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | function result_outcome_string($result) { |
246 | - switch($result->outcome) { |
|
246 | + switch ($result->outcome) { |
|
247 | 247 | case RESULT_OUTCOME_INIT: return "---"; |
248 | 248 | case RESULT_OUTCOME_SUCCESS: return tra("Success"); |
249 | 249 | case RESULT_OUTCOME_COULDNT_SEND: return tra("Couldn't send"); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | function result_client_state_string($result) { |
264 | - switch($result->client_state) { |
|
264 | + switch ($result->client_state) { |
|
265 | 265 | case RESULT_NEW: return tra("New"); |
266 | 266 | case RESULT_FILES_DOWNLOADING: return tra("Downloading"); |
267 | 267 | case RESULT_FILES_DOWNLOADED: return tra("Processing"); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | function validate_state_str($result) { |
282 | - switch($result->validate_state) { |
|
282 | + switch ($result->validate_state) { |
|
283 | 283 | case VALIDATE_STATE_INIT: return tra("Initial"); |
284 | 284 | case VALIDATE_STATE_VALID: return tra("Valid"); |
285 | 285 | case VALIDATE_STATE_INVALID: |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | function assimilate_state_str($s) { |
298 | - switch($s) { |
|
298 | + switch ($s) { |
|
299 | 299 | case ASSIMILATE_INIT: return "Initial"; |
300 | 300 | case ASSIMILATE_READY: return "Ready to assimilate"; |
301 | 301 | case ASSIMILATE_DONE: return "Assimilated"; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | function file_delete_state_str($s) { |
307 | - switch($s) { |
|
307 | + switch ($s) { |
|
308 | 308 | case FILE_DELETE_INIT: return "Initial"; |
309 | 309 | case FILE_DELETE_READY: return "Ready to delete"; |
310 | 310 | case FILE_DELETE_DONE: return "Deleted"; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | // convert WU error bitmask to str. |
317 | 317 | // If $color, add HTML red color |
318 | 318 | // |
319 | -function wu_error_mask_str($s, $color=false) { |
|
319 | +function wu_error_mask_str($s, $color = false) { |
|
320 | 320 | $x = ""; |
321 | 321 | if ($s & WU_ERROR_COULDNT_SEND_RESULT) { |
322 | 322 | $x = $x." ".tra("Couldn't send result"); |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | if ($result->received_time) { |
431 | 431 | $r = time_str($result->received_time); |
432 | 432 | } else if ($result->report_deadline) { |
433 | - if ($result->report_deadline>time()) { |
|
434 | - $r = "<font color='#33cc33'>" . time_str($result->report_deadline) . "</font>"; |
|
433 | + if ($result->report_deadline > time()) { |
|
434 | + $r = "<font color='#33cc33'>".time_str($result->report_deadline)."</font>"; |
|
435 | 435 | } else { |
436 | - $r = "<font color='#ff3333'>" . time_str($result->report_deadline) . "</font>"; |
|
436 | + $r = "<font color='#ff3333'>".time_str($result->report_deadline)."</font>"; |
|
437 | 437 | } |
438 | 438 | } else { |
439 | 439 | $r = "---"; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // @param Integer $dec A signed integer |
495 | 495 | // |
496 | 496 | function int2hex($dec) { |
497 | - return "0x".strtoupper(substr(sprintf("%08x",$dec), -8)); |
|
497 | + return "0x".strtoupper(substr(sprintf("%08x", $dec), -8)); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // Decode a windows error number into semi-human-readable, |
@@ -504,9 +504,9 @@ discard block |
||
504 | 504 | // @return String A human readable error message |
505 | 505 | // @param Integer $x An error number |
506 | 506 | // |
507 | -function windows_error_code_str($x){ |
|
508 | - $h=int2hex($x); |
|
509 | - switch($h){ |
|
507 | +function windows_error_code_str($x) { |
|
508 | + $h = int2hex($x); |
|
509 | + switch ($h) { |
|
510 | 510 | case "0xC0000005": return "STATUS_ACCESS_VIOLATION"; |
511 | 511 | case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION"; |
512 | 512 | case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO"; |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | // @return String A human readable error message |
528 | 528 | // @param Integer $x An error number |
529 | 529 | // |
530 | -function error_code_str($x){ |
|
530 | +function error_code_str($x) { |
|
531 | 531 | // severe Windows error numbers are always large negative integers |
532 | - if ($x<-400) return windows_error_code_str($x); |
|
533 | - switch($x){ |
|
532 | + if ($x < -400) return windows_error_code_str($x); |
|
533 | + switch ($x) { |
|
534 | 534 | case 0: return ""; |
535 | 535 | case 192: return "EXIT_STATEFILE_WRITE"; |
536 | 536 | case 193: return "EXIT_SIGNAL"; |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | return $x." (".int2hex($x).") ".error_code_str($x); |
692 | 692 | } |
693 | 693 | |
694 | -function show_result($result, $show_outfile_links=false) { |
|
694 | +function show_result($result, $show_outfile_links = false) { |
|
695 | 695 | start_table(); |
696 | 696 | row2(tra("Name"), $result->name); |
697 | 697 | row2(tra("Workunit"), "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>"); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | echo "<h3>".tra("Stderr output")."</h3> <pre>" |
743 | 743 | .htmlspecialchars( |
744 | 744 | $result->stderr_out, |
745 | - ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0), |
|
745 | + ENT_QUOTES|(defined('ENT_SUBSTITUTE') ?ENT_SUBSTITUTE:0), |
|
746 | 746 | 'utf-8' |
747 | 747 | ) |
748 | 748 | ."</pre>" |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | |
758 | 758 | $apps = BoincApp::enum('deprecated=0 ORDER BY user_friendly_name'); |
759 | 759 | |
760 | - for ($i=0; $i<NSTATES; $i++) { |
|
760 | + for ($i = 0; $i < NSTATES; $i++) { |
|
761 | 761 | $state_count[$i] = 0; |
762 | 762 | } |
763 | 763 | foreach ($apps as $app) { |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $x .= "<a href=$url>".tra("Next")." ".$info->results_per_page."</a>"; |
801 | 801 | } |
802 | 802 | $x .= "<br>".tra("State").": "; |
803 | - for ($i=0; $i<NSTATES; $i++) { |
|
803 | + for ($i = 0; $i < NSTATES; $i++) { |
|
804 | 804 | if ($i) $x .= " · "; |
805 | 805 | if ($info->state == $i) { |
806 | 806 | $x .= $state_name[$i]; |
@@ -27,25 +27,25 @@ |
||
27 | 27 | row_array(array("Name", "Engine", "Version", "Row Format", "Rows", "Avg Row Length (KB)", "Data Length (MB)", "Max Data Length (MB)", "Index Length (MB)", "Data free (MB)", "Create Time", "Update Time", "Check Time", "Create Options", "Comment")); |
28 | 28 | db_init(); |
29 | 29 | $result = _mysql_query("show table status"); |
30 | - while($row = _mysql_fetch_array($result)) { |
|
30 | + while ($row = _mysql_fetch_array($result)) { |
|
31 | 31 | $size += ($row["Data_length"] + $row["Index_length"]); |
32 | 32 | $engine = $row["Engine"]; |
33 | 33 | //if (!$engine) $engine = $row["Type"]; |
34 | 34 | row_array(array( |
35 | 35 | $row["Name"], |
36 | 36 | $engine, |
37 | - $row["Version"] , |
|
38 | - $row["Row_format"] , |
|
39 | - $row["Rows"] , |
|
40 | - round($row["Avg_row_length"]/1024,2) , |
|
41 | - round($row["Data_length"]/(1024*1024),2) , |
|
42 | - round($row["Max_data_length"]/(1024*1024),2) , |
|
43 | - round($row["Index_length"]/(1024*1024),2) , |
|
44 | - round($row["Data_free"]/(1024*1024),2) , |
|
45 | - $row["Create_time"] , |
|
46 | - $row["Update_time"] , |
|
47 | - $row["Check_time"] , |
|
48 | - $row["Create_options"] , |
|
37 | + $row["Version"], |
|
38 | + $row["Row_format"], |
|
39 | + $row["Rows"], |
|
40 | + round($row["Avg_row_length"]/1024, 2), |
|
41 | + round($row["Data_length"]/(1024*1024), 2), |
|
42 | + round($row["Max_data_length"]/(1024*1024), 2), |
|
43 | + round($row["Index_length"]/(1024*1024), 2), |
|
44 | + round($row["Data_free"]/(1024*1024), 2), |
|
45 | + $row["Create_time"], |
|
46 | + $row["Update_time"], |
|
47 | + $row["Check_time"], |
|
48 | + $row["Create_options"], |
|
49 | 49 | $row["Comment"] |
50 | 50 | )); |
51 | 51 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | require_once("../inc/boinc_db.inc"); |
22 | 22 | require_once("../inc/util.inc"); |
23 | 23 | |
24 | -define('CONSENT_TYPE_ENROLL','ENROLL'); |
|
24 | +define('CONSENT_TYPE_ENROLL', 'ENROLL'); |
|
25 | 25 | |
26 | 26 | function check_termsofuse() { |
27 | 27 | return defined('TERMSOFUSE_FILE') and file_exists(TERMSOFUSE_FILE); |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | $source, $ctime = 0 |
33 | 33 | ) { |
34 | 34 | $mys = BoincDb::escape_string($source); |
35 | - if ($ctime==0) { |
|
35 | + if ($ctime == 0) { |
|
36 | 36 | $mytime = $user->create_time; |
37 | 37 | } else { |
38 | 38 | $mytime = $ctime; |
39 | 39 | } |
40 | 40 | return BoincConsent::insert( |
41 | - "(userid, consent_type_id, consent_time, consent_flag, consent_not_required, source) " . |
|
41 | + "(userid, consent_type_id, consent_time, consent_flag, consent_not_required, source) ". |
|
42 | 42 | "values($user->id, $consent_type_id, $mytime, $consent_flag, $consent_not_required, '$mys')" |
43 | 43 | ); |
44 | 44 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | // The integer is the consent_type_id- the id from consent_type table. |
66 | 66 | // If the boolean is FALSE, the integer returned is -1. |
67 | 67 | // |
68 | -function check_consent_type($name, $checkenabled=TRUE) { |
|
68 | +function check_consent_type($name, $checkenabled = TRUE) { |
|
69 | 69 | $name = BoincDb::escape_string($name); |
70 | 70 | $ct = BoincConsentType::lookup("shortname = '$name'"); |
71 | - if ($ct and ( !$checkenabled or ($ct->enabled)) ) { |
|
71 | + if ($ct and (!$checkenabled or ($ct->enabled))) { |
|
72 | 72 | return array(TRUE, $ct->id); |
73 | 73 | } |
74 | 74 | return array(FALSE, -1); |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | // |
34 | 34 | $config = get_config(); |
35 | 35 | global $master_url; |
36 | -$master_url = parse_config($config , "<master_url>"); |
|
36 | +$master_url = parse_config($config, "<master_url>"); |
|
37 | 37 | $recaptcha_public_key = parse_config($config, "<recaptcha_public_key>"); |
38 | 38 | $recaptcha_private_key = parse_config($config, "<recaptcha_private_key>"); |
39 | 39 | |
40 | 40 | // Set parameters to defaults if not defined in config.xml |
41 | 41 | |
42 | 42 | $x = parse_config($config, "<user_country>"); |
43 | -define('USER_COUNTRY', ($x===null)?1:(int)$x); |
|
43 | +define('USER_COUNTRY', ($x === null) ? 1 : (int)$x); |
|
44 | 44 | |
45 | 45 | $x = parse_config($config, "<user_url>"); |
46 | -define('USER_URL', ($x===null)?1:(int)$x); |
|
46 | +define('USER_URL', ($x === null) ? 1 : (int)$x); |
|
47 | 47 | |
48 | 48 | // Set parameters to defaults if not defined in project.inc |
49 | 49 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | function url_base() { |
154 | - return is_https()?secure_url_base():URL_BASE; |
|
154 | + return is_https() ?secure_url_base() : URL_BASE; |
|
155 | 155 | } |
156 | 156 | |
157 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
157 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
158 | 158 | global $master_url; |
159 | 159 | |
160 | 160 | // the following allows independent login for projects on the same server |
@@ -165,15 +165,15 @@ discard block |
||
165 | 165 | $path = substr($path, 0, -1); |
166 | 166 | $path .= "_ops/"; |
167 | 167 | } |
168 | - $expire = $permanent?time()+3600*24*365:0; |
|
168 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
169 | 169 | setcookie($name, $value, $expire, $path, |
170 | 170 | '', |
171 | - is_https(), // if this page is secure, make cookie secure |
|
171 | + is_https(), // if this page is secure, make cookie secure |
|
172 | 172 | true // httponly; no JS access |
173 | 173 | ); |
174 | 174 | } |
175 | 175 | |
176 | -function clear_cookie($name, $ops=false) { |
|
176 | +function clear_cookie($name, $ops = false) { |
|
177 | 177 | global $master_url; |
178 | 178 | $url = parse_url($master_url); |
179 | 179 | $path = $url['path']; |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | $path = substr($path, 0, -1); |
182 | 182 | $path .= "_ops/"; |
183 | 183 | } |
184 | - setcookie($name, '', time()-3600, $path); |
|
184 | + setcookie($name, '', time() - 3600, $path); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $g_logged_in_user = null; |
188 | 188 | $got_logged_in_user = false; |
189 | 189 | |
190 | -function get_logged_in_user($must_be_logged_in=true) { |
|
190 | +function get_logged_in_user($must_be_logged_in = true) { |
|
191 | 191 | global $g_logged_in_user, $got_logged_in_user; |
192 | 192 | if ($got_logged_in_user) { |
193 | 193 | // this could have been called earlier with $must_be_logged_in false |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $next_url = $_SERVER['REQUEST_URI']; |
214 | 214 | $n = strrpos($next_url, "/"); |
215 | 215 | if ($n) { |
216 | - $next_url = substr($next_url, $n+1); |
|
216 | + $next_url = substr($next_url, $n + 1); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | $next_url = urlencode($next_url); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | return $g_logged_in_user; |
225 | 225 | } |
226 | 226 | |
227 | -function show_login_info($prefix="") { |
|
227 | +function show_login_info($prefix = "") { |
|
228 | 228 | $user = get_logged_in_user(false); |
229 | 229 | if ($user) { |
230 | 230 | $url_tokens = url_tokens($user->authenticator); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -$cache_control_extra=""; |
|
237 | +$cache_control_extra = ""; |
|
238 | 238 | $is_login_page = false; |
239 | 239 | |
240 | 240 | // Call this to start pages. |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | // with an existing web framework can more easily do so. |
247 | 247 | // To do so, define page_head() in the project include file. |
248 | 248 | // |
249 | -if (!function_exists("page_head")){ |
|
249 | +if (!function_exists("page_head")) { |
|
250 | 250 | function page_head( |
251 | 251 | $title, |
252 | 252 | // page title. Put in <title>, used as title for browser tab. |
253 | - $body_attrs=null, |
|
253 | + $body_attrs = null, |
|
254 | 254 | // <body XXXX> |
255 | 255 | // e.g. Javascript to put focus in an input field |
256 | 256 | // (onload="document.form.foo.focus()") |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | // if set, include schedulers.txt. |
260 | 260 | // also pass to project_banner() in case you want a different |
261 | 261 | // header for your main page. |
262 | - $url_prefix="", |
|
262 | + $url_prefix = "", |
|
263 | 263 | // prepend this to links. |
264 | 264 | // Use for web pages not in the top directory |
265 | - $head_extra=null |
|
265 | + $head_extra = null |
|
266 | 266 | // extra stuff to put in <head>. E.g.: |
267 | 267 | // reCAPTCHA code (create_profile.php) |
268 | 268 | // bbcode javascript (forums) |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | header("Content-type: text/html; charset=utf-8"); |
285 | 285 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
286 | 286 | // Date in the past |
287 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
287 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
288 | 288 | // always modified |
289 | 289 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
290 | 290 | // for HTTP/1.1 |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | if ($head_extra) { |
306 | 306 | echo "\n$head_extra\n"; |
307 | 307 | } |
308 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
308 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
309 | 309 | readfile("schedulers.txt"); |
310 | 310 | } |
311 | 311 | |
312 | - $t = $title?$title:PROJECT; |
|
312 | + $t = $title ? $title : PROJECT; |
|
313 | 313 | echo "<title>$t</title>\n"; |
314 | 314 | echo ' |
315 | 315 | <meta charset="utf-8"> |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | echo '<div class="container-fluid"> |
366 | 366 | '; |
367 | 367 | |
368 | - switch($title) { //kludge |
|
368 | + switch ($title) { //kludge |
|
369 | 369 | case tra("Log in"): |
370 | 370 | case tra("Create an account"): |
371 | 371 | case tra("Server status page"): |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | |
381 | 381 | // See the comments for page_head() |
382 | 382 | // |
383 | -if (!function_exists("page_tail")){ |
|
383 | +if (!function_exists("page_tail")) { |
|
384 | 384 | function page_tail( |
385 | - $show_date=false, |
|
385 | + $show_date = false, |
|
386 | 386 | // true for pages that are generated periodically rather than on the fly |
387 | - $url_prefix="", |
|
387 | + $url_prefix = "", |
|
388 | 388 | // use for pages not at top level |
389 | - $is_main=false |
|
389 | + $is_main = false |
|
390 | 390 | // passed to project_footer; |
391 | 391 | ) { |
392 | 392 | echo "<br>\n"; |
@@ -421,24 +421,24 @@ discard block |
||
421 | 421 | // convert time interval in seconds to a string of the form |
422 | 422 | // 'D days h hours m min s sec'. |
423 | 423 | |
424 | -function time_diff($x, $res=3) { |
|
424 | +function time_diff($x, $res = 3) { |
|
425 | 425 | $x = (int)$x; |
426 | 426 | $days = (int)($x/86400); |
427 | - $hours = (int)(($x-$days*86400)/3600); |
|
428 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
429 | - $seconds = $x % 60; |
|
427 | + $hours = (int)(($x - $days*86400)/3600); |
|
428 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
429 | + $seconds = $x%60; |
|
430 | 430 | |
431 | 431 | $s = ""; |
432 | 432 | if ($days) { |
433 | 433 | $s .= "$days ".tra("days")." "; |
434 | 434 | } |
435 | - if ($res>0 && ($hours || strlen($s))) { |
|
435 | + if ($res > 0 && ($hours || strlen($s))) { |
|
436 | 436 | $s .= "$hours ".tra("hours")." "; |
437 | 437 | } |
438 | - if ($res>1 && ($minutes || strlen($s))) { |
|
438 | + if ($res > 1 && ($minutes || strlen($s))) { |
|
439 | 439 | $s .= "$minutes ".tra("min")." "; |
440 | 440 | } |
441 | - if ($res>2) { |
|
441 | + if ($res > 2) { |
|
442 | 442 | $s .= "$seconds ".tra("sec")." "; |
443 | 443 | } |
444 | 444 | return $s; |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | |
453 | 453 | function time_str($x) { |
454 | 454 | if ($x == 0) return "---"; |
455 | - return gmdate('j M Y, G:i:s', (int)$x) . " UTC"; |
|
455 | + return gmdate('j M Y, G:i:s', (int)$x)." UTC"; |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | function local_time_str($x) { |
@@ -464,14 +464,14 @@ discard block |
||
464 | 464 | return time_str($x); |
465 | 465 | } |
466 | 466 | |
467 | -function start_table_str($class="", $style="") { |
|
468 | - $s = $style?'style="'.$style.'"':''; |
|
467 | +function start_table_str($class = "", $style = "") { |
|
468 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
469 | 469 | return '<div class="table"> |
470 | 470 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
471 | 471 | '; |
472 | 472 | } |
473 | 473 | |
474 | -function start_table($class="", $style="") { |
|
474 | +function start_table($class = "", $style = "") { |
|
475 | 475 | echo start_table_str($class, $style); |
476 | 476 | } |
477 | 477 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | echo "</tr>\n"; |
517 | 517 | } |
518 | 518 | |
519 | -function row1($x, $ncols=2, $class="heading") { |
|
519 | +function row1($x, $ncols = 2, $class = "heading") { |
|
520 | 520 | if ($class == "heading") { |
521 | 521 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
522 | 522 | } else { |
@@ -530,10 +530,10 @@ discard block |
||
530 | 530 | |
531 | 531 | // a table row with 2 columns, with the left on right-aligned |
532 | 532 | |
533 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
534 | - if ($x==="") $x="<br>"; |
|
535 | - if ($y==="") $y="<br>"; |
|
536 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
533 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
534 | + if ($x === "") $x = "<br>"; |
|
535 | + if ($y === "") $y = "<br>"; |
|
536 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
537 | 537 | echo "<tr> |
538 | 538 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
539 | 539 | <td $attrs >$y</td> |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | // output the first part of row2(); |
545 | 545 | // then write the content, followed by </td></tr> |
546 | 546 | |
547 | -function row2_init($x, $lwidth='40%') { |
|
547 | +function row2_init($x, $lwidth = '40%') { |
|
548 | 548 | echo sprintf('<tr> |
549 | 549 | <td width="%s" %s>%s</td> |
550 | 550 | <td %s>', |
@@ -560,31 +560,31 @@ discard block |
||
560 | 560 | echo "<tr><td>$string</td></tr>"; |
561 | 561 | } |
562 | 562 | |
563 | -function row_array($x, $attrs=null) { |
|
563 | +function row_array($x, $attrs = null) { |
|
564 | 564 | echo "<tr>\n"; |
565 | 565 | $i = 0; |
566 | 566 | foreach ($x as $h) { |
567 | - $a = $attrs?$attrs[$i]:""; |
|
567 | + $a = $attrs ? $attrs[$i] : ""; |
|
568 | 568 | echo "<td $a>$h</td>\n"; |
569 | 569 | $i++; |
570 | 570 | } |
571 | 571 | echo "</tr>\n"; |
572 | 572 | } |
573 | 573 | |
574 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
574 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
575 | 575 | |
576 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
576 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
577 | 577 | echo "<tr>"; |
578 | 578 | $i = 0; |
579 | 579 | foreach ($x as $h) { |
580 | - $a = $attrs?$attrs[$i]:""; |
|
580 | + $a = $attrs ? $attrs[$i] : ""; |
|
581 | 581 | echo "<th $a class=\"$class\">$h</th>"; |
582 | 582 | $i++; |
583 | 583 | } |
584 | 584 | echo "</tr>\n"; |
585 | 585 | } |
586 | 586 | |
587 | -function row_heading($x, $class='bg-primary') { |
|
587 | +function row_heading($x, $class = 'bg-primary') { |
|
588 | 588 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
589 | 589 | ', $class, $x |
590 | 590 | ); |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
645 | 645 | // is cut short. |
646 | 646 | |
647 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
647 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
648 | 648 | $words = explode($delimiter, $sentence); |
649 | 649 | $total_chars = 0; |
650 | 650 | $trunc = false; |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | |
728 | 728 | // returns null if the arg is optional and missing |
729 | 729 | // |
730 | -function get_int($name, $optional=false) { |
|
731 | - $x=null; |
|
730 | +function get_int($name, $optional = false) { |
|
731 | + $x = null; |
|
732 | 732 | if (isset($_GET[$name])) $x = $_GET[$name]; |
733 | 733 | if (!is_numeric($x)) { |
734 | 734 | if ($optional) { |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | |
748 | 748 | // returns null if the arg is optional and missing |
749 | 749 | // |
750 | -function post_num($name, $optional=false) { |
|
750 | +function post_num($name, $optional = false) { |
|
751 | 751 | $x = null; |
752 | 752 | if (isset($_POST[$name])) $x = $_POST[$name]; |
753 | 753 | if (!is_numeric($x)) { |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | |
763 | 763 | // returns null if the arg is optional and missing |
764 | 764 | // |
765 | -function post_int($name, $optional=false) { |
|
765 | +function post_int($name, $optional = false) { |
|
766 | 766 | $x = post_num($name, $optional); |
767 | 767 | if (is_null($x)) return null; |
768 | 768 | $y = (int)$x; |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | } |
781 | 781 | } |
782 | 782 | |
783 | -function get_str($name, $optional=false) { |
|
783 | +function get_str($name, $optional = false) { |
|
784 | 784 | if (isset($_GET[$name])) { |
785 | 785 | $x = $_GET[$name]; |
786 | 786 | } else { |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | return undo_magic_quotes($x); |
793 | 793 | } |
794 | 794 | |
795 | -function post_str($name, $optional=false) { |
|
795 | +function post_str($name, $optional = false) { |
|
796 | 796 | if (isset($_POST[$name])) { |
797 | 797 | $x = $_POST[$name]; |
798 | 798 | } else { |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | return undo_magic_quotes($x); |
805 | 805 | } |
806 | 806 | |
807 | -function post_arr($name, $optional=false) { |
|
807 | +function post_arr($name, $optional = false) { |
|
808 | 808 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
809 | 809 | $x = $_POST[$name]; |
810 | 810 | } else { |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | // the mb_* functions are not included by default |
821 | 821 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
822 | 822 | |
823 | - for ($i=0; $i<strlen($str); $i++) { |
|
823 | + for ($i = 0; $i < strlen($str); $i++) { |
|
824 | 824 | $c = ord(substr($str, $i)); |
825 | 825 | if ($c < 32 || $c > 127) return false; |
826 | 826 | } |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
845 | 845 | // if no value was entered and this is ok |
846 | 846 | // |
847 | - if ($number=='' && !$low) return true; |
|
847 | + if ($number == '' && !$low) return true; |
|
848 | 848 | |
849 | 849 | // the supplied value contains alphabetic characters |
850 | 850 | // |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | |
862 | 862 | // Generate a "select" element from an array of values |
863 | 863 | // |
864 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
864 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
865 | 865 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
866 | 866 | |
867 | 867 | foreach ($array as $key => $value) { |
@@ -886,12 +886,12 @@ discard block |
||
886 | 886 | return $str; |
887 | 887 | } |
888 | 888 | |
889 | -function strip_bbcode($string){ |
|
890 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
889 | +function strip_bbcode($string) { |
|
890 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | function current_url() { |
894 | - $url = is_https()?'https':'http'; |
|
894 | + $url = is_https() ? 'https' : 'http'; |
|
895 | 895 | $url .= "://"; |
896 | 896 | $url .= $_SERVER['SERVER_NAME']; |
897 | 897 | $url .= ":".$_SERVER['SERVER_PORT']; |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | // the colors for bootstrap's btn-success are almost illegible; |
910 | 910 | // the green is too light. Use a darker green. |
911 | 911 | // |
912 | -function button_style($color='green', $font_size=null) { |
|
912 | +function button_style($color = 'green', $font_size = null) { |
|
913 | 913 | $fs = ''; |
914 | 914 | if ($font_size) { |
915 | 915 | $fs = sprintf('; font-size:%dpx', $font_size); |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | // class: class of the button, e.g. btn |
929 | 929 | // extra: Additional text in href tag |
930 | 930 | // |
931 | -function button_text($url, $text, $desc=null, $class=null, $extra='') { |
|
931 | +function button_text($url, $text, $desc = null, $class = null, $extra = '') { |
|
932 | 932 | if (!$desc) { |
933 | 933 | $desc = $text; |
934 | 934 | } |
@@ -943,23 +943,23 @@ discard block |
||
943 | 943 | ); |
944 | 944 | } |
945 | 945 | |
946 | -function button_text_small($url, $text, $desc=null) { |
|
946 | +function button_text_small($url, $text, $desc = null) { |
|
947 | 947 | return button_text($url, $text, $desc, "btn btn-xs", button_style()); |
948 | 948 | } |
949 | 949 | |
950 | -function show_button($url, $text, $desc=null, $class=null, $extra=null) { |
|
950 | +function show_button($url, $text, $desc = null, $class = null, $extra = null) { |
|
951 | 951 | echo button_text($url, $text, $desc, $class, $extra); |
952 | 952 | } |
953 | 953 | |
954 | 954 | // for places with a bunch of buttons, like forum posts |
955 | 955 | // |
956 | -function show_button_small($url, $text, $desc=null) { |
|
956 | +function show_button_small($url, $text, $desc = null) { |
|
957 | 957 | echo button_text_small($url, $text, $desc); |
958 | 958 | } |
959 | 959 | |
960 | 960 | // used for showing icons |
961 | 961 | // |
962 | -function show_image($src, $title, $alt, $height=null) { |
|
962 | +function show_image($src, $title, $alt, $height = null) { |
|
963 | 963 | $h = ""; |
964 | 964 | if ($height) { |
965 | 965 | $h = "height=\"$height\""; |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | // tries instead to connect to <replica_db_host> if tag exists. |
997 | 997 | // DEPRECATED - use boinc_db.inc |
998 | 998 | // |
999 | -function db_init($try_replica=false) { |
|
999 | +function db_init($try_replica = false) { |
|
1000 | 1000 | check_web_stopped(); |
1001 | 1001 | $retval = db_init_aux($try_replica); |
1002 | 1002 | if ($retval == 1) { |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | // Check this to avoid XSS vulnerability |
1073 | 1073 | // |
1074 | 1074 | function sanitize_sort_by($x) { |
1075 | - switch($x) { |
|
1075 | + switch ($x) { |
|
1076 | 1076 | case 'expavg_credit': |
1077 | 1077 | case 'total_credit': |
1078 | 1078 | return; |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | function do_download($path) { |
1093 | - $name=basename($path); |
|
1093 | + $name = basename($path); |
|
1094 | 1094 | header('Content-Description: File Transfer'); |
1095 | 1095 | header('Content-Type: application/octet-stream'); |
1096 | 1096 | header('Content-Disposition: attachment; filename='.$name); |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | header('Expires: 0'); |
1099 | 1099 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1100 | 1100 | header('Pragma: public'); |
1101 | - header('Content-Length: ' . filesize($path)); |
|
1101 | + header('Content-Length: '.filesize($path)); |
|
1102 | 1102 | flush(); |
1103 | 1103 | readfile($path); |
1104 | 1104 | } |
@@ -1147,10 +1147,10 @@ discard block |
||
1147 | 1147 | // Otherwise return 0. |
1148 | 1148 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1149 | 1149 | // |
1150 | -function boinc_client_version(){ |
|
1150 | +function boinc_client_version() { |
|
1151 | 1151 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1152 | 1152 | $x = $_SERVER['HTTP_USER_AGENT']; |
1153 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1153 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1154 | 1154 | if (preg_match($e, $x, $matches)) { |
1155 | 1155 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
1156 | 1156 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | $rem_name = $name."_remaining"; |
1180 | 1180 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
1181 | 1181 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
1182 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1182 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1183 | 1183 | ; |
1184 | 1184 | } |
1185 | 1185 | |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | // use the following around text with long lines, |
1210 | 1210 | // to limit the width and make it more readable. |
1211 | 1211 | // |
1212 | -function text_start($width=640) { |
|
1212 | +function text_start($width = 640) { |
|
1213 | 1213 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
1214 | 1214 | } |
1215 | 1215 | function text_end() { |
@@ -1235,7 +1235,7 @@ discard block |
||
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | function cert_filename() { |
1238 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
1238 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | // if user hasn't validated their email addr, tell them to |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | // You should have received a copy of the GNU Lesser General Public License |
17 | 17 | // along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 | |
19 | -NOT FINISHED. DON'T USE |
|
19 | +NOT FINISHED.DON'T USE |
|
20 | 20 | |
21 | 21 | require 'openid.php'; |
22 | 22 | include_once("../inc/boinc_db.inc"); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | |
27 | 27 | function show_error($str) { |
28 | 28 | page_head("Can't create account"); |
29 | - echo "$str<br>\n"; |
|
29 | + echo "$str < br > \n"; |
|
30 | 30 | page_tail(); |
31 | 31 | exit(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | try { |
35 | 35 | $openid = new LightOpenID; |
36 | - echo "<pre>"; |
|
36 | + echo " < pre > "; |
|
37 | 37 | if(!$openid->mode) { |
38 | 38 | if(isset($_POST['openid_identifier'])) { |
39 | 39 | $openid->identity = $_POST['openid_identifier']; |