@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | row2('<b>'.tra('Search criteria (use one or more)').'</b>', ''); |
41 | 41 | row2( |
42 | 42 | tra('Key words').'<br><small>'.tra('Find teams with these words in their names or descriptions').'</small>', |
43 | - '<input class="form-control" type="text" name="keywords" value="' . htmlspecialchars($params->keywords) . '">'); |
|
43 | + '<input class="form-control" type="text" name="keywords" value="'.htmlspecialchars($params->keywords).'">'); |
|
44 | 44 | row2_init(tra('Country')); |
45 | 45 | echo '<select class="form-control" name="country"><option value="" selected>---</option>'; |
46 | 46 | $country = $params->country; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | echo country_select_options($country); |
49 | 49 | echo "</select></td></tr>\n"; |
50 | 50 | row2(tra('Type of team'), team_type_select($params->type, true)); |
51 | - $checked = $params->active?"checked":""; |
|
51 | + $checked = $params->active ? "checked" : ""; |
|
52 | 52 | row2(tra('Show only active teams'), "<input type=checkbox name=active $checked>"); |
53 | 53 | row2("", "<input class=\"btn btn-primary\" type=submit name=submit value=\"".tra('Search')."\">"); |
54 | 54 | end_table(); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | row2("Created", date_str($team->create_time)); |
96 | 96 | if (defined("SHOW_NONVALIDATED_TEAMS")) { |
97 | 97 | $founder = $team->founder; |
98 | - row2("Founder email validated", $founder->email_validated?"Yes":"No (team will not be exported)"); |
|
98 | + row2("Founder email validated", $founder->email_validated ? "Yes" : "No (team will not be exported)"); |
|
99 | 99 | } |
100 | 100 | if (strlen($team->url)) {; |
101 | 101 | if (strstr($team->url, "http://")) { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | row1(tra('Members')); |
170 | 170 | row2(tra('Founder'), |
171 | - $team->founder?user_links($team->founder, BADGE_HEIGHT_MEDIUM):"---" |
|
171 | + $team->founder ?user_links($team->founder, BADGE_HEIGHT_MEDIUM) : "---" |
|
172 | 172 | ); |
173 | 173 | if (count($team->admins)) { |
174 | 174 | $first = true; |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | foreach ($deltas as $delta) { |
356 | 356 | $u = BoincUser::lookup_id($delta->userid); |
357 | 357 | if ($u->teamid == $teamid) { |
358 | - $new_members[] = $u->id; // they might have later quit |
|
358 | + $new_members[] = $u->id; // they might have later quit |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | return array_unique($new_members); |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | if (!$user->teamid) return; |
439 | 439 | $user->update("teamid=0"); |
440 | 440 | $team = BoincTeam::lookup_id($user->teamid); |
441 | - if ($team && $team->ping_user==$user->id) { |
|
441 | + if ($team && $team->ping_user == $user->id) { |
|
442 | 442 | $team->update("ping_user=-ping_user"); |
443 | 443 | } |
444 | 444 | BoincTeamAdmin::delete("teamid=$user->teamid and userid=$user->id"); |
@@ -477,33 +477,33 @@ discard block |
||
477 | 477 | start_table(); |
478 | 478 | row2(tra('Team name, text version').' |
479 | 479 | <br><p class=\"text-muted\">'.tra('Don\'t use HTML tags.').'</p>', |
480 | - '<input class="form-control" name="name" type="text" size="50" value="'.($team?$team->name:"").'">' |
|
480 | + '<input class="form-control" name="name" type="text" size="50" value="'.($team ? $team->name : "").'">' |
|
481 | 481 | ); |
482 | 482 | row2(tra('Team name, HTML version').' |
483 | 483 | <br><p class=\"text-muted\"> |
484 | 484 | '.tra('You may use %1 limited HTML tags %2.', '<a href="html.php" target="_new">', '</a>').' |
485 | 485 | '.tra('If you don\'t know HTML, leave this box blank.').'</p>', |
486 | - '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"',"'",($team?$team->name_html:"")).'">' |
|
486 | + '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"', "'", ($team ? $team->name_html : "")).'">' |
|
487 | 487 | ); |
488 | 488 | row2(tra('URL of team web page, if any').':<br><font size=-2>('.tra('without "http://"').') |
489 | 489 | '.tra('This URL will be linked to from the team\'s page on this site.'), |
490 | - '<input class="form-control" type="text" name="url" size="60" value="'.($team?$team->url:"").'">' |
|
490 | + '<input class="form-control" type="text" name="url" size="60" value="'.($team ? $team->url : "").'">' |
|
491 | 491 | ); |
492 | 492 | row2(tra('Description of team').': |
493 | 493 | <br><p class=\"text-muted\"> |
494 | 494 | '.tra('You may use %1 limited HTML tags %2.', '<a href="html.php" target="_new">', '</a>').' |
495 | 495 | </p>', |
496 | - '<textarea class="form-control" name="description" rows=10>'.($team?$team->description:"").'</textarea>' |
|
496 | + '<textarea class="form-control" name="description" rows=10>'.($team ? $team->description : "").'</textarea>' |
|
497 | 497 | ); |
498 | 498 | |
499 | - row2(tra('Type of team').':', team_type_select($team?$team->type:null)); |
|
499 | + row2(tra('Type of team').':', team_type_select($team ? $team->type : null)); |
|
500 | 500 | |
501 | 501 | row2_init(tra('Country')); |
502 | 502 | echo '<select class="form-control" name="country">'; |
503 | - echo country_select_options($team?$team->country:null); |
|
503 | + echo country_select_options($team ? $team->country : null); |
|
504 | 504 | echo "</select></td></tr>\n"; |
505 | 505 | |
506 | - $x = (!$team || $team->joinable)?"checked":""; |
|
506 | + $x = (!$team || $team->joinable) ? "checked" : ""; |
|
507 | 507 | row2(tra("Accept new members?"), "<input type=checkbox name=joinable $x>"); |
508 | 508 | // Check if we're using reCaptcha to prevent spam accounts |
509 | 509 | // |
@@ -571,12 +571,12 @@ discard block |
||
571 | 571 | // |
572 | 572 | function new_transfer_request_ok($team, $now) { |
573 | 573 | if ($team->ping_user <= 0) { |
574 | - if ($team->ping_time < $now - 60 * 86400) { |
|
574 | + if ($team->ping_time < $now - 60*86400) { |
|
575 | 575 | return true; |
576 | 576 | } |
577 | 577 | return false; |
578 | 578 | } |
579 | - if ($team->ping_time < $now - 90 * 86400) { |
|
579 | + if ($team->ping_time < $now - 90*86400) { |
|
580 | 580 | return true; |
581 | 581 | } |
582 | 582 | return false; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | if (!is_valid_country($country)) { |
612 | 612 | $country = tra('None'); |
613 | 613 | } |
614 | - $country = BoincDb::escape_string($country); // for Cote d'Ivoire |
|
614 | + $country = BoincDb::escape_string($country); // for Cote d'Ivoire |
|
615 | 615 | |
616 | 616 | $clause = sprintf( |
617 | 617 | "(userid, create_time, name, name_lc, url, type, name_html, description, country, nusers, expavg_time) values(%d, %d, '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, unix_timestamp())", |
@@ -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 |
@@ -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,11 +165,11 @@ 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 | 171 | |
172 | -function clear_cookie($name, $ops=false) { |
|
172 | +function clear_cookie($name, $ops = false) { |
|
173 | 173 | global $master_url; |
174 | 174 | $url = parse_url($master_url); |
175 | 175 | $path = $url['path']; |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | $path = substr($path, 0, -1); |
178 | 178 | $path .= "_ops/"; |
179 | 179 | } |
180 | - setcookie($name, '', time()-3600, $path); |
|
180 | + setcookie($name, '', time() - 3600, $path); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $g_logged_in_user = null; |
184 | 184 | $got_logged_in_user = false; |
185 | 185 | |
186 | -function get_logged_in_user($must_be_logged_in=true) { |
|
186 | +function get_logged_in_user($must_be_logged_in = true) { |
|
187 | 187 | global $g_logged_in_user, $got_logged_in_user; |
188 | 188 | if ($got_logged_in_user) { |
189 | 189 | // this could have been called earlier with $must_be_logged_in false |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $next_url = $_SERVER['REQUEST_URI']; |
210 | 210 | $n = strrpos($next_url, "/"); |
211 | 211 | if ($n) { |
212 | - $next_url = substr($next_url, $n+1); |
|
212 | + $next_url = substr($next_url, $n + 1); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | $next_url = urlencode($next_url); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | return $g_logged_in_user; |
221 | 221 | } |
222 | 222 | |
223 | -function show_login_info($prefix="") { |
|
223 | +function show_login_info($prefix = "") { |
|
224 | 224 | $user = get_logged_in_user(false); |
225 | 225 | if ($user) { |
226 | 226 | $url_tokens = url_tokens($user->authenticator); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | -$cache_control_extra=""; |
|
233 | +$cache_control_extra = ""; |
|
234 | 234 | $is_login_page = false; |
235 | 235 | |
236 | 236 | // Call this to start pages. |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | // with an existing web framework can more easily do so. |
243 | 243 | // To do so, define page_head() in the project include file. |
244 | 244 | // |
245 | -if (!function_exists("page_head")){ |
|
245 | +if (!function_exists("page_head")) { |
|
246 | 246 | function page_head( |
247 | 247 | $title, |
248 | 248 | // page title. Put in <title>, used as title for browser tab. |
249 | - $body_attrs=null, |
|
249 | + $body_attrs = null, |
|
250 | 250 | // <body XXXX> |
251 | 251 | // e.g. Javascript to put focus in an input field |
252 | 252 | // (onload="document.form.foo.focus()") |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | // if set, include schedulers.txt. |
256 | 256 | // also pass to project_banner() in case you want a different |
257 | 257 | // header for your main page. |
258 | - $url_prefix="", |
|
258 | + $url_prefix = "", |
|
259 | 259 | // prepend this to links. |
260 | 260 | // Use for web pages not in the top directory |
261 | - $head_extra=null |
|
261 | + $head_extra = null |
|
262 | 262 | // extra stuff to put in <head>. E.g.: |
263 | 263 | // reCAPTCHA code (create_profile.php) |
264 | 264 | // bbcode javascript (forums) |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | header("Content-type: text/html; charset=utf-8"); |
281 | 281 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
282 | 282 | // Date in the past |
283 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
283 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
284 | 284 | // always modified |
285 | 285 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
286 | 286 | // for HTTP/1.1 |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | if ($head_extra) { |
302 | 302 | echo "\n$head_extra\n"; |
303 | 303 | } |
304 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
304 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
305 | 305 | readfile("schedulers.txt"); |
306 | 306 | } |
307 | 307 | |
308 | - $t = $title?$title:PROJECT; |
|
308 | + $t = $title ? $title : PROJECT; |
|
309 | 309 | echo "<title>$t</title>\n"; |
310 | 310 | echo ' |
311 | 311 | <meta charset="utf-8"> |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | echo '<div class="container-fluid"> |
362 | 362 | '; |
363 | 363 | |
364 | - switch($title) { //kludge |
|
364 | + switch ($title) { //kludge |
|
365 | 365 | case tra("Log in"): |
366 | 366 | case tra("Create an account"): |
367 | 367 | case tra("Server status page"): |
@@ -376,13 +376,13 @@ discard block |
||
376 | 376 | |
377 | 377 | // See the comments for page_head() |
378 | 378 | // |
379 | -if (!function_exists("page_tail")){ |
|
379 | +if (!function_exists("page_tail")) { |
|
380 | 380 | function page_tail( |
381 | - $show_date=false, |
|
381 | + $show_date = false, |
|
382 | 382 | // true for pages that are generated periodically rather than on the fly |
383 | - $url_prefix="", |
|
383 | + $url_prefix = "", |
|
384 | 384 | // use for pages not at top level |
385 | - $is_main=false |
|
385 | + $is_main = false |
|
386 | 386 | // passed to project_footer; |
387 | 387 | ) { |
388 | 388 | echo "<br>\n"; |
@@ -417,24 +417,24 @@ discard block |
||
417 | 417 | // convert time interval in seconds to a string of the form |
418 | 418 | // 'D days h hours m min s sec'. |
419 | 419 | |
420 | -function time_diff($x, $res=3) { |
|
420 | +function time_diff($x, $res = 3) { |
|
421 | 421 | $x = (int)$x; |
422 | 422 | $days = (int)($x/86400); |
423 | - $hours = (int)(($x-$days*86400)/3600); |
|
424 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
425 | - $seconds = $x % 60; |
|
423 | + $hours = (int)(($x - $days*86400)/3600); |
|
424 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
425 | + $seconds = $x%60; |
|
426 | 426 | |
427 | 427 | $s = ""; |
428 | 428 | if ($days) { |
429 | 429 | $s .= "$days ".tra("days")." "; |
430 | 430 | } |
431 | - if ($res>0 && ($hours || strlen($s))) { |
|
431 | + if ($res > 0 && ($hours || strlen($s))) { |
|
432 | 432 | $s .= "$hours ".tra("hours")." "; |
433 | 433 | } |
434 | - if ($res>1 && ($minutes || strlen($s))) { |
|
434 | + if ($res > 1 && ($minutes || strlen($s))) { |
|
435 | 435 | $s .= "$minutes ".tra("min")." "; |
436 | 436 | } |
437 | - if ($res>2) { |
|
437 | + if ($res > 2) { |
|
438 | 438 | $s .= "$seconds ".tra("sec")." "; |
439 | 439 | } |
440 | 440 | return $s; |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | |
449 | 449 | function time_str($x) { |
450 | 450 | if ($x == 0) return "---"; |
451 | - return gmdate('j M Y, G:i:s', (int)$x) . " UTC"; |
|
451 | + return gmdate('j M Y, G:i:s', (int)$x)." UTC"; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | function local_time_str($x) { |
@@ -460,14 +460,14 @@ discard block |
||
460 | 460 | return time_str($x); |
461 | 461 | } |
462 | 462 | |
463 | -function start_table_str($class="", $style="") { |
|
464 | - $s = $style?'style="'.$style.'"':''; |
|
463 | +function start_table_str($class = "", $style = "") { |
|
464 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
465 | 465 | return '<div class="table"> |
466 | 466 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
467 | 467 | '; |
468 | 468 | } |
469 | 469 | |
470 | -function start_table($class="", $style="") { |
|
470 | +function start_table($class = "", $style = "") { |
|
471 | 471 | echo start_table_str($class, $style); |
472 | 472 | } |
473 | 473 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | echo "</tr>\n"; |
513 | 513 | } |
514 | 514 | |
515 | -function row1($x, $ncols=2, $class="heading") { |
|
515 | +function row1($x, $ncols = 2, $class = "heading") { |
|
516 | 516 | if ($class == "heading") { |
517 | 517 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
518 | 518 | } else { |
@@ -526,10 +526,10 @@ discard block |
||
526 | 526 | |
527 | 527 | // a table row with 2 columns, with the left on right-aligned |
528 | 528 | |
529 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
530 | - if ($x==="") $x="<br>"; |
|
531 | - if ($y==="") $y="<br>"; |
|
532 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
529 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
530 | + if ($x === "") $x = "<br>"; |
|
531 | + if ($y === "") $y = "<br>"; |
|
532 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
533 | 533 | echo "<tr> |
534 | 534 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
535 | 535 | <td $attrs >$y</td> |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | // output the first part of row2(); |
541 | 541 | // then write the content, followed by </td></tr> |
542 | 542 | |
543 | -function row2_init($x, $lwidth='40%') { |
|
543 | +function row2_init($x, $lwidth = '40%') { |
|
544 | 544 | echo sprintf('<tr> |
545 | 545 | <td width="%s" %s>%s</td> |
546 | 546 | <td %s>', |
@@ -556,31 +556,31 @@ discard block |
||
556 | 556 | echo "<tr><td>$string</td></tr>"; |
557 | 557 | } |
558 | 558 | |
559 | -function row_array($x, $attrs=null) { |
|
559 | +function row_array($x, $attrs = null) { |
|
560 | 560 | echo "<tr>\n"; |
561 | 561 | $i = 0; |
562 | 562 | foreach ($x as $h) { |
563 | - $a = $attrs?$attrs[$i]:""; |
|
563 | + $a = $attrs ? $attrs[$i] : ""; |
|
564 | 564 | echo "<td $a>$h</td>\n"; |
565 | 565 | $i++; |
566 | 566 | } |
567 | 567 | echo "</tr>\n"; |
568 | 568 | } |
569 | 569 | |
570 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
570 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
571 | 571 | |
572 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
572 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
573 | 573 | echo "<tr>"; |
574 | 574 | $i = 0; |
575 | 575 | foreach ($x as $h) { |
576 | - $a = $attrs?$attrs[$i]:""; |
|
576 | + $a = $attrs ? $attrs[$i] : ""; |
|
577 | 577 | echo "<th $a class=\"$class\">$h</th>"; |
578 | 578 | $i++; |
579 | 579 | } |
580 | 580 | echo "</tr>\n"; |
581 | 581 | } |
582 | 582 | |
583 | -function row_heading($x, $class='bg-primary') { |
|
583 | +function row_heading($x, $class = 'bg-primary') { |
|
584 | 584 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
585 | 585 | ', $class, $x |
586 | 586 | ); |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
641 | 641 | // is cut short. |
642 | 642 | |
643 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
643 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
644 | 644 | $words = explode($delimiter, $sentence); |
645 | 645 | $total_chars = 0; |
646 | 646 | $trunc = false; |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | |
724 | 724 | // returns null if the arg is optional and missing |
725 | 725 | // |
726 | -function get_int($name, $optional=false) { |
|
727 | - $x=null; |
|
726 | +function get_int($name, $optional = false) { |
|
727 | + $x = null; |
|
728 | 728 | if (isset($_GET[$name])) $x = $_GET[$name]; |
729 | 729 | if (!is_numeric($x)) { |
730 | 730 | if ($optional) { |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | |
744 | 744 | // returns null if the arg is optional and missing |
745 | 745 | // |
746 | -function post_num($name, $optional=false) { |
|
746 | +function post_num($name, $optional = false) { |
|
747 | 747 | $x = null; |
748 | 748 | if (isset($_POST[$name])) $x = $_POST[$name]; |
749 | 749 | if (!is_numeric($x)) { |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | |
759 | 759 | // returns null if the arg is optional and missing |
760 | 760 | // |
761 | -function post_int($name, $optional=false) { |
|
761 | +function post_int($name, $optional = false) { |
|
762 | 762 | $x = post_num($name, $optional); |
763 | 763 | if (is_null($x)) return null; |
764 | 764 | $y = (int)$x; |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
779 | -function get_str($name, $optional=false) { |
|
779 | +function get_str($name, $optional = false) { |
|
780 | 780 | if (isset($_GET[$name])) { |
781 | 781 | $x = $_GET[$name]; |
782 | 782 | } else { |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | return undo_magic_quotes($x); |
789 | 789 | } |
790 | 790 | |
791 | -function post_str($name, $optional=false) { |
|
791 | +function post_str($name, $optional = false) { |
|
792 | 792 | if (isset($_POST[$name])) { |
793 | 793 | $x = $_POST[$name]; |
794 | 794 | } else { |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | return undo_magic_quotes($x); |
801 | 801 | } |
802 | 802 | |
803 | -function post_arr($name, $optional=false) { |
|
803 | +function post_arr($name, $optional = false) { |
|
804 | 804 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
805 | 805 | $x = $_POST[$name]; |
806 | 806 | } else { |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | // the mb_* functions are not included by default |
817 | 817 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
818 | 818 | |
819 | - for ($i=0; $i<strlen($str); $i++) { |
|
819 | + for ($i = 0; $i < strlen($str); $i++) { |
|
820 | 820 | $c = ord(substr($str, $i)); |
821 | 821 | if ($c < 32 || $c > 127) return false; |
822 | 822 | } |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
841 | 841 | // if no value was entered and this is ok |
842 | 842 | // |
843 | - if ($number=='' && !$low) return true; |
|
843 | + if ($number == '' && !$low) return true; |
|
844 | 844 | |
845 | 845 | // the supplied value contains alphabetic characters |
846 | 846 | // |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | |
858 | 858 | // Generate a "select" element from an array of values |
859 | 859 | // |
860 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
860 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
861 | 861 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
862 | 862 | |
863 | 863 | foreach ($array as $key => $value) { |
@@ -882,8 +882,8 @@ discard block |
||
882 | 882 | return $str; |
883 | 883 | } |
884 | 884 | |
885 | -function strip_bbcode($string){ |
|
886 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
885 | +function strip_bbcode($string) { |
|
886 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | function current_url() { |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | // the colors for bootstrap's btn-success are almost illegible; |
909 | 909 | // the green is too light. Use a darker green. |
910 | 910 | // |
911 | -function button_style($color='green', $font_size=null) { |
|
911 | +function button_style($color = 'green', $font_size = null) { |
|
912 | 912 | $fs = ''; |
913 | 913 | if ($font_size) { |
914 | 914 | $fs = sprintf('; font-size:%dpx', $font_size); |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | // class: class of the button, e.g. btn |
928 | 928 | // extra: Additional text in href tag |
929 | 929 | // |
930 | -function button_text($url, $text, $desc=null, $class=null, $extra='') { |
|
930 | +function button_text($url, $text, $desc = null, $class = null, $extra = '') { |
|
931 | 931 | if (!$desc) { |
932 | 932 | $desc = $text; |
933 | 933 | } |
@@ -942,23 +942,23 @@ discard block |
||
942 | 942 | ); |
943 | 943 | } |
944 | 944 | |
945 | -function button_text_small($url, $text, $desc=null) { |
|
945 | +function button_text_small($url, $text, $desc = null) { |
|
946 | 946 | return button_text($url, $text, $desc, "btn btn-xs", button_style()); |
947 | 947 | } |
948 | 948 | |
949 | -function show_button($url, $text, $desc=null, $class=null, $extra=null) { |
|
949 | +function show_button($url, $text, $desc = null, $class = null, $extra = null) { |
|
950 | 950 | echo button_text($url, $text, $desc, $class, $extra); |
951 | 951 | } |
952 | 952 | |
953 | 953 | // for places with a bunch of buttons, like forum posts |
954 | 954 | // |
955 | -function show_button_small($url, $text, $desc=null) { |
|
955 | +function show_button_small($url, $text, $desc = null) { |
|
956 | 956 | echo button_text_small($url, $text, $desc); |
957 | 957 | } |
958 | 958 | |
959 | 959 | // used for showing icons |
960 | 960 | // |
961 | -function show_image($src, $title, $alt, $height=null) { |
|
961 | +function show_image($src, $title, $alt, $height = null) { |
|
962 | 962 | $h = ""; |
963 | 963 | if ($height) { |
964 | 964 | $h = "height=\"$height\""; |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | // tries instead to connect to <replica_db_host> if tag exists. |
996 | 996 | // DEPRECATED - use boinc_db.inc |
997 | 997 | // |
998 | -function db_init($try_replica=false) { |
|
998 | +function db_init($try_replica = false) { |
|
999 | 999 | check_web_stopped(); |
1000 | 1000 | $retval = db_init_aux($try_replica); |
1001 | 1001 | if ($retval == 1) { |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | // Check this to avoid XSS vulnerability |
1112 | 1112 | // |
1113 | 1113 | function sanitize_sort_by($x) { |
1114 | - switch($x) { |
|
1114 | + switch ($x) { |
|
1115 | 1115 | case 'expavg_credit': |
1116 | 1116 | case 'total_credit': |
1117 | 1117 | return; |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | function do_download($path) { |
1132 | - $name=basename($path); |
|
1132 | + $name = basename($path); |
|
1133 | 1133 | header('Content-Description: File Transfer'); |
1134 | 1134 | header('Content-Type: application/octet-stream'); |
1135 | 1135 | header('Content-Disposition: attachment; filename='.$name); |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | header('Expires: 0'); |
1138 | 1138 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
1139 | 1139 | header('Pragma: public'); |
1140 | - header('Content-Length: ' . filesize($path)); |
|
1140 | + header('Content-Length: '.filesize($path)); |
|
1141 | 1141 | flush(); |
1142 | 1142 | readfile($path); |
1143 | 1143 | } |
@@ -1186,10 +1186,10 @@ discard block |
||
1186 | 1186 | // Otherwise return 0. |
1187 | 1187 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1188 | 1188 | // |
1189 | -function boinc_client_version(){ |
|
1189 | +function boinc_client_version() { |
|
1190 | 1190 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1191 | 1191 | $x = $_SERVER['HTTP_USER_AGENT']; |
1192 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1192 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
1193 | 1193 | if (preg_match($e, $x, $matches)) { |
1194 | 1194 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
1195 | 1195 | } |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | $rem_name = $name."_remaining"; |
1219 | 1219 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
1220 | 1220 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
1221 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1221 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
1222 | 1222 | ; |
1223 | 1223 | } |
1224 | 1224 | |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | // use the following around text with long lines, |
1249 | 1249 | // to limit the width and make it more readable. |
1250 | 1250 | // |
1251 | -function text_start($width=640) { |
|
1251 | +function text_start($width = 640) { |
|
1252 | 1252 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
1253 | 1253 | } |
1254 | 1254 | function text_end() { |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | function cert_filename() { |
1277 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
1277 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | // if user hasn't validated their email addr, tell them to |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | // with an existing web framework can more easily do so. |
243 | 243 | // To do so, define page_head() in the project include file. |
244 | 244 | // |
245 | -if (!function_exists("page_head")){ |
|
245 | +if (!function_exists("page_head")) { |
|
246 | 246 | function page_head( |
247 | 247 | $title, |
248 | 248 | // page title. Put in <title>, used as title for browser tab. |
@@ -361,7 +361,8 @@ discard block |
||
361 | 361 | echo '<div class="container-fluid"> |
362 | 362 | '; |
363 | 363 | |
364 | - switch($title) { //kludge |
|
364 | + switch($title) { |
|
365 | +//kludge |
|
365 | 366 | case tra("Log in"): |
366 | 367 | case tra("Create an account"): |
367 | 368 | case tra("Server status page"): |
@@ -376,7 +377,7 @@ discard block |
||
376 | 377 | |
377 | 378 | // See the comments for page_head() |
378 | 379 | // |
379 | -if (!function_exists("page_tail")){ |
|
380 | +if (!function_exists("page_tail")) { |
|
380 | 381 | function page_tail( |
381 | 382 | $show_date=false, |
382 | 383 | // true for pages that are generated periodically rather than on the fly |
@@ -882,7 +883,7 @@ discard block |
||
882 | 883 | return $str; |
883 | 884 | } |
884 | 885 | |
885 | -function strip_bbcode($string){ |
|
886 | +function strip_bbcode($string) { |
|
886 | 887 | return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
887 | 888 | } |
888 | 889 | |
@@ -1186,7 +1187,7 @@ discard block |
||
1186 | 1187 | // Otherwise return 0. |
1187 | 1188 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
1188 | 1189 | // |
1189 | -function boinc_client_version(){ |
|
1190 | +function boinc_client_version() { |
|
1190 | 1191 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
1191 | 1192 | $x = $_SERVER['HTTP_USER_AGENT']; |
1192 | 1193 | $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
@@ -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]; |