@@ -28,7 +28,7 @@ |
||
| 28 | 28 | die("Delete this line first\n"); |
| 29 | 29 | |
| 30 | 30 | if (is_numeric($argv[1])) { |
| 31 | - $user = BoincUser::lookup_id((int) $argv[1]); |
|
| 31 | + $user = BoincUser::lookup_id((int)$argv[1]); |
|
| 32 | 32 | if (!$user) die("no such user\n"); |
| 33 | 33 | $retval = delete_account($user); |
| 34 | 34 | if ($retval) { |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | // close() closes the connection. |
| 45 | 45 | |
| 46 | 46 | class BoincDb { |
| 47 | - static $instance; // a DbConn object, or null |
|
| 48 | - static $dbnum; // which replica we're connected to |
|
| 47 | + static $instance; // a DbConn object, or null |
|
| 48 | + static $dbnum; // which replica we're connected to |
|
| 49 | 49 | |
| 50 | 50 | // connect to DB $dbnum (0, 1, ...) |
| 51 | 51 | // If the requested DB doesn't exist or connection fails, connect to DB 0. |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | self::$instance = null; |
| 57 | 57 | $config = get_config(); |
| 58 | 58 | if ($dbnum) { |
| 59 | - $r = $dbnum==1?'':strval($dbnum); |
|
| 59 | + $r = $dbnum == 1 ? '' : strval($dbnum); |
|
| 60 | 60 | $host = parse_config($config, sprintf('<replica%s_db_host>', $r)); |
| 61 | 61 | $name = parse_config($config, sprintf('<replica%s_db_name>', $r)); |
| 62 | 62 | $user = parse_config($config, sprintf('<replica%s_db_user>', $r)); |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | $db = BoincDb::get(); |
| 202 | 202 | return $db->update($this, 'user', $clause); |
| 203 | 203 | } |
| 204 | - static function enum($where_clause, $order_clause=null) { |
|
| 204 | + static function enum($where_clause, $order_clause = null) { |
|
| 205 | 205 | $db = BoincDb::get(); |
| 206 | 206 | return $db->enum('user', 'BoincUser', $where_clause, $order_clause); |
| 207 | 207 | } |
| 208 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
| 208 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
| 209 | 209 | $db = BoincDb::get(); |
| 210 | 210 | return $db->enum_fields( |
| 211 | 211 | 'user', 'BoincUser', $fields, $where_clause, $order_clause |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | $db = BoincDb::get(); |
| 256 | 256 | return $db->update($this, 'team', $clause); |
| 257 | 257 | } |
| 258 | - static function enum($where_clause, $order_clause=null) { |
|
| 258 | + static function enum($where_clause, $order_clause = null) { |
|
| 259 | 259 | $db = BoincDb::get(); |
| 260 | 260 | return $db->enum('team', 'BoincTeam', $where_clause, $order_clause); |
| 261 | 261 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $db = BoincDb::get(); |
| 281 | 281 | return $db->max('team', $field); |
| 282 | 282 | } |
| 283 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
| 283 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
| 284 | 284 | $db = BoincDb::get(); |
| 285 | 285 | return $db->enum_fields( |
| 286 | 286 | 'team', 'BoincTeam', $fields, $where_clause, $order_clause |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | $db = BoincDb::get(); |
| 319 | 319 | return $db->delete($this, 'host'); |
| 320 | 320 | } |
| 321 | - static function enum($where_clause, $order_clause=null) { |
|
| 321 | + static function enum($where_clause, $order_clause = null) { |
|
| 322 | 322 | $db = BoincDb::get(); |
| 323 | 323 | return $db->enum('host', 'BoincHost', $where_clause, $order_clause); |
| 324 | 324 | } |
| 325 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
| 325 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
| 326 | 326 | $db = BoincDb::get(); |
| 327 | 327 | return $db->enum_fields( |
| 328 | 328 | 'host', 'BoincHost', $fields, $where_clause, $order_clause |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | $db = BoincDb::get(); |
| 445 | 445 | return $db->update($this, 'app', $clause); |
| 446 | 446 | } |
| 447 | - static function sum($field, $clause=null) { |
|
| 447 | + static function sum($field, $clause = null) { |
|
| 448 | 448 | $db = BoincDb::get(); |
| 449 | 449 | return $db->sum('app', $field, $clause); |
| 450 | 450 | } |
@@ -502,11 +502,11 @@ discard block |
||
| 502 | 502 | $db = BoincDb::get(); |
| 503 | 503 | return $db->insert('profile', $clause); |
| 504 | 504 | } |
| 505 | - static function enum($where_clause=null, $order_clause=null) { |
|
| 505 | + static function enum($where_clause = null, $order_clause = null) { |
|
| 506 | 506 | $db = BoincDb::get(); |
| 507 | 507 | return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause); |
| 508 | 508 | } |
| 509 | - static function enum_fields($fields, $where_clause=null, $order_clause=null) { |
|
| 509 | + static function enum_fields($fields, $where_clause = null, $order_clause = null) { |
|
| 510 | 510 | $db = BoincDb::get(); |
| 511 | 511 | return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause); |
| 512 | 512 | } |
@@ -901,12 +901,12 @@ discard block |
||
| 901 | 901 | return $db->enum('consent', 'BoincConsent', $where_clause); |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - static function insert ($clause) { |
|
| 904 | + static function insert($clause) { |
|
| 905 | 905 | $db = BoincDb::get(); |
| 906 | 906 | return $db->insert('consent', $clause); |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - static function update ($clause) { |
|
| 909 | + static function update($clause) { |
|
| 910 | 910 | $db = BoincDb::get(); |
| 911 | 911 | return $db->update_aux('consent', $clause); |
| 912 | 912 | } |
@@ -931,17 +931,17 @@ discard block |
||
| 931 | 931 | return $db->lookup('consent_type', 'BoincConsentType', $clause); |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - static function enum($where_clause, $order_clause=null) { |
|
| 934 | + static function enum($where_clause, $order_clause = null) { |
|
| 935 | 935 | $db = BoincDb::get(); |
| 936 | 936 | return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause); |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - static function insert ($clause) { |
|
| 939 | + static function insert($clause) { |
|
| 940 | 940 | $db = BoincDb::get(); |
| 941 | 941 | return $db->insert('consent_type', $clause); |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | - static function update ($clause) { |
|
| 944 | + static function update($clause) { |
|
| 945 | 945 | $db = BoincDb::get(); |
| 946 | 946 | return $db->update_aux('consent_type', $clause); |
| 947 | 947 | } |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | return $db->lookup('latest_consent', 'BoincLatestConsent', $clause); |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | - static function enum($where_clause, $order_clause=null) { |
|
| 970 | + static function enum($where_clause, $order_clause = null) { |
|
| 971 | 971 | $db = BoincDb::get(); |
| 972 | 972 | return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause); |
| 973 | 973 | } |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | // apply this to any user-supplied strings used in queries |
| 979 | 979 | // |
| 980 | 980 | function boinc_real_escape_string($x) { |
| 981 | - if (version_compare(phpversion(),"4.3.0")>=0) { |
|
| 981 | + if (version_compare(phpversion(), "4.3.0") >= 0) { |
|
| 982 | 982 | return BoincDb::escape_string($x); |
| 983 | 983 | } else { |
| 984 | 984 | $x = str_replace("'", "\'", $x); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $avg = round($app->info->avg, 2); |
| 181 | 181 | $min = round($app->info->min, 2); |
| 182 | 182 | $max = round($app->info->max, 2); |
| 183 | - $x = $max?"$avg ($min - $max)":"---"; |
|
| 183 | + $x = $max ? "$avg ($min - $max)" : "---"; |
|
| 184 | 184 | $u = $app->info->users; |
| 185 | 185 | } else { |
| 186 | 186 | $x = '---'; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $cmd = trim($cmd); |
| 276 | 276 | $x = explode(" ", $cmd); |
| 277 | 277 | $prog = $x[0]; |
| 278 | - $pidname = $prog . '.pid'; |
|
| 278 | + $pidname = $prog.'.pid'; |
|
| 279 | 279 | } |
| 280 | 280 | $path = "../../pid_$host/$pidname"; |
| 281 | 281 | if (is_file($path)) { |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | $master_host = $u["host"]; |
| 318 | 318 | if ($config->www_host) { |
| 319 | - $web_host = trim((string) $config->www_host); |
|
| 319 | + $web_host = trim((string)$config->www_host); |
|
| 320 | 320 | } else { |
| 321 | 321 | $web_host = $main_host; |
| 322 | 322 | } |
| 323 | 323 | if ($config->sched_host) { |
| 324 | - $sched_host = trim((string) $config->sched_host); |
|
| 324 | + $sched_host = trim((string)$config->sched_host); |
|
| 325 | 325 | } else { |
| 326 | 326 | $sched_host = $main_host; |
| 327 | 327 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | // the upload and download servers are sort of daemons too |
| 333 | 333 | // |
| 334 | - $url = trim((string) $config->download_url); |
|
| 334 | + $url = trim((string)$config->download_url); |
|
| 335 | 335 | $u = parse_url($url); |
| 336 | 336 | $h = $u["host"]; |
| 337 | 337 | if ($h == $master_host) { |
@@ -343,14 +343,14 @@ discard block |
||
| 343 | 343 | } else { |
| 344 | 344 | $have_remote = true; |
| 345 | 345 | } |
| 346 | - $url = trim((string) $config->upload_url); |
|
| 346 | + $url = trim((string)$config->upload_url); |
|
| 347 | 347 | $u = parse_url($url); |
| 348 | 348 | $h = $u["host"]; |
| 349 | 349 | if ($h == $master_host) { |
| 350 | 350 | $y = new StdClass; |
| 351 | 351 | $y->cmd = "Upload server"; |
| 352 | 352 | $y->host = $h; |
| 353 | - $y->status = !file_exists("../../stop_upload");; |
|
| 353 | + $y->status = !file_exists("../../stop_upload"); ; |
|
| 354 | 354 | $local_daemons[] = $y; |
| 355 | 355 | } else { |
| 356 | 356 | $have_remote = true; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | $y = new StdClass; |
| 362 | 362 | $y->cmd = "Scheduler"; |
| 363 | 363 | $y->host = $sched_host; |
| 364 | - $y->status = !file_exists("../../stop_sched");; |
|
| 364 | + $y->status = !file_exists("../../stop_sched"); ; |
|
| 365 | 365 | $local_daemons[] = $y; |
| 366 | 366 | |
| 367 | 367 | foreach ($daemons->daemon as $d) { |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $disabled_daemons[] = $x; |
| 375 | 375 | continue; |
| 376 | 376 | } |
| 377 | - $host = $d->host?(string)$d->host:$main_host; |
|
| 377 | + $host = $d->host ? (string)$d->host : $main_host; |
|
| 378 | 378 | if ($host != $web_host) { |
| 379 | 379 | $have_remote = true; |
| 380 | 380 | continue; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | // send an email, using PHPMailer or not. |
| 28 | 28 | // |
| 29 | -function send_email($user, $subject, $body, $body_html=null, $email_addr=null) { |
|
| 29 | +function send_email($user, $subject, $body, $body_html = null, $email_addr = null) { |
|
| 30 | 30 | if (!$email_addr) { |
| 31 | 31 | $email_addr = $user->email_addr; |
| 32 | 32 | } |
@@ -69,17 +69,17 @@ discard block |
||
| 69 | 69 | return true; |
| 70 | 70 | } |
| 71 | 71 | } else { |
| 72 | - $headers =""; |
|
| 72 | + $headers = ""; |
|
| 73 | 73 | if (defined('EMAIL_FROM') && defined('EMAIL_FROM_NAME')) { |
| 74 | 74 | $headers = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM.">"; |
| 75 | 75 | } else if (defined('EMAIL_FROM')) { |
| 76 | - $headers = "From: ". EMAIL_FROM; |
|
| 76 | + $headers = "From: ".EMAIL_FROM; |
|
| 77 | 77 | } |
| 78 | 78 | if ($body_html) { |
| 79 | 79 | $body = "<html><body>\n"; |
| 80 | 80 | $body .= $body_html; |
| 81 | 81 | $body .= "\n</body></html>\n"; |
| 82 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 82 | + $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n"; |
|
| 83 | 83 | } |
| 84 | 84 | return mail($email_addr, $subject, $body, $headers); |
| 85 | 85 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | // otherwise check both IP and email |
| 161 | 161 | if ($ip && filter_var( |
| 162 | 162 | $ip, FILTER_VALIDATE_IP, |
| 163 | - FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE |
|
| 163 | + FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE |
|
| 164 | 164 | )) { |
| 165 | 165 | $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip."&email=".$addr); |
| 166 | 166 | } else { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | return md5($key.'oogabooga'); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | -function opt_out_url($user, $page="opt_out.php") { |
|
| 208 | +function opt_out_url($user, $page = "opt_out.php") { |
|
| 209 | 209 | return sprintf("%s%s?code=%s&userid=%d", |
| 210 | 210 | secure_url_base(), |
| 211 | 211 | $page, |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | function check_passwd_ui($user, $passwd) { |
| 59 | 59 | $passwd_hash = md5($passwd.$user->email_addr); |
| 60 | - if(!check_passwd_hash($user, $passwd_hash)) { |
|
| 60 | + if (!check_passwd_hash($user, $passwd_hash)) { |
|
| 61 | 61 | sleep(LOGIN_FAIL_SLEEP_SEC); |
| 62 | 62 | page_head("Password incorrect"); |
| 63 | 63 | echo "The password you entered is incorrect. Please go back and try again.\n"; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | function is_banned_email_addr($email_addr) { |
| 70 | 70 | global $banned_email_domains; |
| 71 | 71 | if (isset($banned_email_domains)) { |
| 72 | - foreach($banned_email_domains as $d) { |
|
| 72 | + foreach ($banned_email_domains as $d) { |
|
| 73 | 73 | $x = strstr($email_addr, $d); |
| 74 | 74 | if ($x == $d) return true; |
| 75 | 75 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | // |
| 109 | 109 | function make_user( |
| 110 | 110 | $email_addr, $name, $passwd_hash, |
| 111 | - $country=null, $postal_code=null, $project_prefs=null, $teamid=0 |
|
| 111 | + $country = null, $postal_code = null, $project_prefs = null, $teamid = 0 |
|
| 112 | 112 | ) { |
| 113 | 113 | if (!is_valid_email_syntax($email_addr)) return null; |
| 114 | 114 | // caller generally has already checked |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $users = BoincUser::enum( |
| 244 | 244 | sprintf("name like '%s%%'", $new_name) |
| 245 | 245 | ); |
| 246 | - foreach ($users as $u){ |
|
| 246 | + foreach ($users as $u) { |
|
| 247 | 247 | echo "<p>$u->name\n"; |
| 248 | 248 | } |
| 249 | 249 | page_tail(); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | show_error(tra("Passwords may only include ASCII characters.")); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if (strlen($passwd)<$min_passwd_length) { |
|
| 281 | + if (strlen($passwd) < $min_passwd_length) { |
|
| 282 | 282 | show_error( |
| 283 | 283 | tra("New password is too short: minimum password length is %1 characters.", $min_passwd_length) |
| 284 | 284 | ); |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | // add other criteria like # of countries (based on IP addr) |
| 8 | 8 | // consider only hosts with recent last RPC time |
| 9 | 9 | |
| 10 | -define ('MAX_HOSTS', 100); |
|
| 10 | +define('MAX_HOSTS', 100); |
|
| 11 | 11 | |
| 12 | 12 | require_once('../inc/boinc_db.inc'); |
| 13 | 13 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | require_once("../inc/text_transform.inc"); |
| 25 | 25 | |
| 26 | 26 | define('THREADS_PER_PAGE', 50); |
| 27 | -define('FORUM_LH_PCT', '25%'); // width of LH column |
|
| 27 | +define('FORUM_LH_PCT', '25%'); // width of LH column |
|
| 28 | 28 | |
| 29 | 29 | $forum_error = ""; |
| 30 | 30 | // for functions that return null on error, |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | define('THREAD_SOLVED', 1); |
| 56 | 56 | |
| 57 | 57 | define('AVATAR_WIDTH', 100); |
| 58 | -define('AVATAR_HEIGHT',100); |
|
| 58 | +define('AVATAR_HEIGHT', 100); |
|
| 59 | 59 | |
| 60 | 60 | define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days |
| 61 | 61 | define('ST_NEW', 'New member'); |
@@ -80,24 +80,24 @@ discard block |
||
| 80 | 80 | define('IMAGE_HIDDEN', 'img/hidden.png'); |
| 81 | 81 | define('IMAGE_STICKY_LOCKED', 'img/sticky_locked_post.png'); |
| 82 | 82 | define('IMAGE_POST', 'img/post.png'); |
| 83 | -define('NEW_IMAGE_HEIGHT','15'); |
|
| 83 | +define('NEW_IMAGE_HEIGHT', '15'); |
|
| 84 | 84 | define('EMPHASIZE_IMAGE', 'img/emphasized_post.png'); |
| 85 | -define('EMPHASIZE_IMAGE_HEIGHT','15'); |
|
| 85 | +define('EMPHASIZE_IMAGE_HEIGHT', '15'); |
|
| 86 | 86 | define('FILTER_IMAGE', 'img/filtered_post.png'); |
| 87 | -define('FILTER_IMAGE_HEIGHT','15'); |
|
| 87 | +define('FILTER_IMAGE_HEIGHT', '15'); |
|
| 88 | 88 | define('RATE_POSITIVE_IMAGE', 'img/rate_positive.png'); |
| 89 | -define('RATE_POSITIVE_IMAGE_HEIGHT','9'); |
|
| 89 | +define('RATE_POSITIVE_IMAGE_HEIGHT', '9'); |
|
| 90 | 90 | define('RATE_NEGATIVE_IMAGE', 'img/rate_negative.png'); |
| 91 | -define('RATE_NEGATIVE_IMAGE_HEIGHT','9'); |
|
| 91 | +define('RATE_NEGATIVE_IMAGE_HEIGHT', '9'); |
|
| 92 | 92 | define('REPORT_POST_IMAGE', 'img/report_post.png'); |
| 93 | -define('REPORT_POST_IMAGE_HEIGHT','9'); |
|
| 93 | +define('REPORT_POST_IMAGE_HEIGHT', '9'); |
|
| 94 | 94 | |
| 95 | 95 | define('SOLUTION', tra('This answered my question')); |
| 96 | 96 | define('SUFFERER', tra('I also have this question')); |
| 97 | 97 | define('OFF_TOPIC', tra('Off-topic')); |
| 98 | 98 | |
| 99 | -define ('DEFAULT_LOW_RATING_THRESHOLD', -25); |
|
| 100 | -define ('DEFAULT_HIGH_RATING_THRESHOLD', 5); |
|
| 99 | +define('DEFAULT_LOW_RATING_THRESHOLD', -25); |
|
| 100 | +define('DEFAULT_HIGH_RATING_THRESHOLD', 5); |
|
| 101 | 101 | |
| 102 | 102 | // special user attributes |
| 103 | 103 | // |
@@ -175,15 +175,15 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | // return forum/thread title, with links. |
| 177 | 177 | // |
| 178 | -function forum_title($category, $forum, $thread, $link_thread=false) { |
|
| 178 | +function forum_title($category, $forum, $thread, $link_thread = false) { |
|
| 179 | 179 | if ($category) { |
| 180 | 180 | $is_helpdesk = $category->is_helpdesk; |
| 181 | 181 | } else { |
| 182 | 182 | $is_helpdesk = false; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $where = $is_helpdesk?tra("Questions and Answers"):tra("Message boards"); |
|
| 186 | - $top_url = $is_helpdesk?"forum_help_desk.php":"forum_index.php"; |
|
| 185 | + $where = $is_helpdesk ?tra("Questions and Answers") : tra("Message boards"); |
|
| 186 | + $top_url = $is_helpdesk ? "forum_help_desk.php" : "forum_index.php"; |
|
| 187 | 187 | |
| 188 | 188 | $x = ''; |
| 189 | 189 | if (!$forum && !$thread) { |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | return $x; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | -function team_forum_title($forum, $thread=null, $link_thread=false) { |
|
| 220 | +function team_forum_title($forum, $thread = null, $link_thread = false) { |
|
| 221 | 221 | $team = BoincTeam::lookup_id($forum->category); |
| 222 | 222 | $x = sprintf('<a href="forum_index.php">%s</a> :', |
| 223 | 223 | tra("Message boards") |
@@ -251,12 +251,12 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | function page_link($url, $page_num, $items_per_page, $text) { |
| 254 | - return " <a href=\"$url&start=" . $page_num*$items_per_page . "\">$text</a> "; |
|
| 254 | + return " <a href=\"$url&start=".$page_num*$items_per_page."\">$text</a> "; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // return a string for navigating pages |
| 258 | 258 | // |
| 259 | -function page_links($url, $nitems, $items_per_page, $start){ |
|
| 259 | +function page_links($url, $nitems, $items_per_page, $start) { |
|
| 260 | 260 | // How many pages to potentially show before and after this one: |
| 261 | 261 | $preshow = 3; |
| 262 | 262 | $postshow = 3; |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | $x = ""; |
| 265 | 265 | |
| 266 | 266 | if ($nitems <= $items_per_page) return ""; |
| 267 | - $npages = ceil($nitems / $items_per_page); |
|
| 268 | - $curpage = ceil($start / $items_per_page); |
|
| 267 | + $npages = ceil($nitems/$items_per_page); |
|
| 268 | + $curpage = ceil($start/$items_per_page); |
|
| 269 | 269 | |
| 270 | 270 | // If this is not the first page, display "previous" |
| 271 | 271 | // |
| 272 | - if ($curpage > 0){ |
|
| 272 | + if ($curpage > 0) { |
|
| 273 | 273 | $x .= page_link( |
| 274 | - $url, $curpage-1, $items_per_page, |
|
| 274 | + $url, $curpage - 1, $items_per_page, |
|
| 275 | 275 | tra("Previous")." · " |
| 276 | 276 | ); |
| 277 | 277 | } |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | // Display a list of pages surrounding this one |
| 288 | 288 | // |
| 289 | - for ($i=$curpage-$preshow; $i<=$curpage+$postshow; $i++){ |
|
| 290 | - $page_str = (string)($i+1); |
|
| 289 | + for ($i = $curpage - $preshow; $i <= $curpage + $postshow; $i++) { |
|
| 290 | + $page_str = (string)($i + 1); |
|
| 291 | 291 | if ($i < 0) continue; |
| 292 | 292 | if ($i >= $npages) break; |
| 293 | 293 | |
@@ -296,20 +296,20 @@ discard block |
||
| 296 | 296 | } else { |
| 297 | 297 | $x .= page_link($url, $i, $items_per_page, $page_str); |
| 298 | 298 | } |
| 299 | - if ($i == $npages-1) break; |
|
| 300 | - if ($i == $curpage+$postshow) break; |
|
| 299 | + if ($i == $npages - 1) break; |
|
| 300 | + if ($i == $curpage + $postshow) break; |
|
| 301 | 301 | $x .= " · "; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ($curpage + $postshow < $npages-1) { |
|
| 304 | + if ($curpage + $postshow < $npages - 1) { |
|
| 305 | 305 | $x .= " . . . "; |
| 306 | - $x .= page_link($url, $npages-1, $items_per_page, $npages); |
|
| 306 | + $x .= page_link($url, $npages - 1, $items_per_page, $npages); |
|
| 307 | 307 | } |
| 308 | 308 | // If there is a next page |
| 309 | 309 | // |
| 310 | - if ($curpage < $npages-1){ |
|
| 310 | + if ($curpage < $npages - 1) { |
|
| 311 | 311 | $x .= page_link( |
| 312 | - $url, $curpage+1, $items_per_page, |
|
| 312 | + $url, $curpage + 1, $items_per_page, |
|
| 313 | 313 | " · ".tra("Next") |
| 314 | 314 | ); |
| 315 | 315 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | function cleanup_title($title) { |
| 331 | 331 | $x = sanitize_tags(bb2html($title)); |
| 332 | 332 | $x = trim($x); |
| 333 | - if (strlen($x)==0) return "(no title)"; |
|
| 333 | + if (strlen($x) == 0) return "(no title)"; |
|
| 334 | 334 | else return $x; |
| 335 | 335 | } |
| 336 | 336 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $i = 0; |
| 393 | 393 | foreach ($posts as $post) { |
| 394 | 394 | if ($post->id == $postid) { |
| 395 | - $start = $i - ($i % $num_to_show); |
|
| 395 | + $start = $i - ($i%$num_to_show); |
|
| 396 | 396 | $jump_to_post = $post; |
| 397 | 397 | break; |
| 398 | 398 | } |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | // if jump to post, figure out what page to show |
| 420 | 420 | // |
| 421 | 421 | if ($jump_to_post) { |
| 422 | - $start = $ibest - ($ibest % $num_to_show); |
|
| 422 | + $start = $ibest - ($ibest%$num_to_show); |
|
| 423 | 423 | } else { |
| 424 | 424 | $start = $default_start; |
| 425 | 425 | } |
@@ -527,8 +527,8 @@ discard block |
||
| 527 | 527 | // Generates a table row with two cells: author and message |
| 528 | 528 | // |
| 529 | 529 | function show_post( |
| 530 | - $post, $thread, $forum, $logged_in_user, $start=0, |
|
| 531 | - $latest_viewed=0, $controls=FORUM_CONTROLS, $filter=true |
|
| 530 | + $post, $thread, $forum, $logged_in_user, $start = 0, |
|
| 531 | + $latest_viewed = 0, $controls = FORUM_CONTROLS, $filter = true |
|
| 532 | 532 | ) { |
| 533 | 533 | global $country_to_iso3166_2; |
| 534 | 534 | |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | // If the user no longer exists, skip the post |
| 538 | 538 | // |
| 539 | - if (!$user){ |
|
| 539 | + if (!$user) { |
|
| 540 | 540 | return; |
| 541 | 541 | } |
| 542 | 542 | |
@@ -557,9 +557,9 @@ discard block |
||
| 557 | 557 | // check whether the poster is on the list of people to ignore |
| 558 | 558 | // |
| 559 | 559 | $ignore_poster = false; |
| 560 | - if ($logged_in_user){ |
|
| 560 | + if ($logged_in_user) { |
|
| 561 | 561 | $tokens = url_tokens($logged_in_user->authenticator); |
| 562 | - if (is_ignoring($logged_in_user, $user)){ |
|
| 562 | + if (is_ignoring($logged_in_user, $user)) { |
|
| 563 | 563 | $ignore_poster = true; |
| 564 | 564 | } |
| 565 | 565 | } |
@@ -573,8 +573,8 @@ discard block |
||
| 573 | 573 | if (is_moderator($logged_in_user, $forum)) { |
| 574 | 574 | $can_edit = true; |
| 575 | 575 | } else if (can_reply($thread, $forum, $logged_in_user)) { |
| 576 | - $time_limit = $post->timestamp+MAXIMUM_EDIT_TIME; |
|
| 577 | - $can_edit = time()<$time_limit; |
|
| 576 | + $time_limit = $post->timestamp + MAXIMUM_EDIT_TIME; |
|
| 577 | + $can_edit = time() < $time_limit; |
|
| 578 | 578 | } else { |
| 579 | 579 | $can_edit = false; |
| 580 | 580 | } |
@@ -584,24 +584,24 @@ discard block |
||
| 584 | 584 | // Print the special user lines, if any |
| 585 | 585 | // |
| 586 | 586 | global $special_user_bitfield; |
| 587 | - $fstatus=""; |
|
| 587 | + $fstatus = ""; |
|
| 588 | 588 | $keys = array_keys($special_user_bitfield); |
| 589 | 589 | $is_posted_by_special = false; |
| 590 | - for ($i=0; $i<sizeof($special_user_bitfield);$i++) { |
|
| 590 | + for ($i = 0; $i < sizeof($special_user_bitfield); $i++) { |
|
| 591 | 591 | if ($user->prefs && $user->prefs->privilege($keys[$i])) { |
| 592 | - $fstatus.="<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
| 592 | + $fstatus .= "<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
| 593 | 593 | $is_posted_by_special = true; |
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | // Highlight special users if set in prefs; |
| 598 | 598 | // |
| 599 | - if ($logged_in_user && $logged_in_user->prefs){ |
|
| 599 | + if ($logged_in_user && $logged_in_user->prefs) { |
|
| 600 | 600 | $highlight = $logged_in_user->prefs->highlight_special && $is_posted_by_special; |
| 601 | 601 | } else { |
| 602 | 602 | $highlight = $is_posted_by_special; |
| 603 | 603 | } |
| 604 | - $class = $highlight?' style="border-left: 5px solid LightGreen" ':''; |
|
| 604 | + $class = $highlight ? ' style="border-left: 5px solid LightGreen" ' : ''; |
|
| 605 | 605 | |
| 606 | 606 | // row and start of author col |
| 607 | 607 | // |
@@ -613,12 +613,12 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | echo user_links($user, 0, 30); |
| 615 | 615 | echo "<br>"; |
| 616 | - if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."<br>"; |
|
| 616 | + if ($user->create_time > time() - ST_NEW_TIME) $fstatus .= ST_NEW."<br>"; |
|
| 617 | 617 | echo "<span class=\"small\">"; |
| 618 | 618 | if ($fstatus) echo "$fstatus"; |
| 619 | 619 | |
| 620 | - if (!$filter || !$ignore_poster){ |
|
| 621 | - if ($user->prefs && $user->prefs->avatar!="" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars==false))) { |
|
| 620 | + if (!$filter || !$ignore_poster) { |
|
| 621 | + if ($user->prefs && $user->prefs->avatar != "" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars == false))) { |
|
| 622 | 622 | echo "<img width=\"".AVATAR_WIDTH."\" height=\"".AVATAR_HEIGHT."\" src=\"".avatar_url($user->prefs->avatar)."\" alt=\"Avatar\"><br>"; |
| 623 | 623 | } |
| 624 | 624 | } |
@@ -626,14 +626,14 @@ discard block |
||
| 626 | 626 | |
| 627 | 627 | $url = "pm.php?action=new&userid=".$user->id; |
| 628 | 628 | $name = $user->name; |
| 629 | - show_button_small($url, tra("Send message"), tra("Send %1 a private message",$name)); |
|
| 629 | + show_button_small($url, tra("Send message"), tra("Send %1 a private message", $name)); |
|
| 630 | 630 | echo '<br>'.tra("Joined: %1", gmdate('j M y', $user->create_time)), "<br>"; |
| 631 | 631 | |
| 632 | 632 | if (!isset($user->nposts)) { |
| 633 | 633 | $user->nposts = BoincPost::count("user=$user->id"); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - if (function_exists('project_forum_user_info')){ |
|
| 636 | + if (function_exists('project_forum_user_info')) { |
|
| 637 | 637 | project_forum_user_info($user); |
| 638 | 638 | } else { |
| 639 | 639 | echo tra("Posts: %1", $user->nposts)."<br>"; |
@@ -642,8 +642,8 @@ discard block |
||
| 642 | 642 | // |
| 643 | 643 | //echo "ID: ".$user->id."<br>"; |
| 644 | 644 | if (!NO_COMPUTING) { |
| 645 | - echo tra("Credit: %1", number_format($user->total_credit)) ."<br>"; |
|
| 646 | - echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
| 645 | + echo tra("Credit: %1", number_format($user->total_credit))."<br>"; |
|
| 646 | + echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | // to use this feature: |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | echo "<form action=\"forum_rate.php?post=", $post->id, "\" method=\"post\">"; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - if ($logged_in_user && $post->timestamp > $latest_viewed){ |
|
| 675 | + if ($logged_in_user && $post->timestamp > $latest_viewed) { |
|
| 676 | 676 | show_image(NEW_IMAGE, tra("You haven't read this message yet"), tra("Unread"), NEW_IMAGE_HEIGHT); |
| 677 | 677 | } |
| 678 | 678 | |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | if ($post->modified) { |
| 693 | 693 | echo "<br>".tra("Last modified: %1", pretty_time_Str($post->modified)); |
| 694 | 694 | } |
| 695 | - if ($ignore_poster && $filter){ |
|
| 696 | - echo "<br>" .tra( |
|
| 695 | + if ($ignore_poster && $filter) { |
|
| 696 | + echo "<br>".tra( |
|
| 697 | 697 | "This post is hidden because the sender is on your 'ignore' list. Click %1 here %2 to view hidden posts", |
| 698 | 698 | "<a href=\"?id=".$thread->id."&filter=false&start=$start#".$post->id."\">", |
| 699 | 699 | "</a>" |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | <p> |
| 707 | 707 | "; |
| 708 | 708 | |
| 709 | - if (!$filter || !$ignore_poster){ |
|
| 709 | + if (!$filter || !$ignore_poster) { |
|
| 710 | 710 | $posttext = $post->content; |
| 711 | 711 | |
| 712 | 712 | // If the creator of this post has a signature and |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | // user has signatures enabled: show it |
| 715 | 715 | // |
| 716 | 716 | $posttext = output_transform($posttext, $options); |
| 717 | - if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)){ |
|
| 717 | + if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)) { |
|
| 718 | 718 | $sig = output_transform($user->prefs->signature, $options); |
| 719 | 719 | $posttext .= "<hr>$sig\n"; |
| 720 | 720 | } |
@@ -748,10 +748,10 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | if (($controls == FORUM_CONTROLS) && (can_reply($thread, $forum, $logged_in_user))) { |
| 750 | 750 | echo " "; |
| 751 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "&no_quote=1#input"; |
|
| 751 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."&no_quote=1#input"; |
|
| 752 | 752 | // "Reply" is used as a verb |
| 753 | 753 | show_button($url, tra("Reply"), tra("Post a reply to this message")); |
| 754 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "#input"; |
|
| 754 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."#input"; |
|
| 755 | 755 | // "Quote" is used as a verb |
| 756 | 756 | show_button($url, tra("Quote"), tra("Post a reply by quoting this message")); |
| 757 | 757 | } |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | $content = output_transform($post->content, $options); |
| 774 | 774 | $when = time_diff_str($post->timestamp, time()); |
| 775 | 775 | $user = BoincUser::lookup_id($post->user); |
| 776 | - if (!$user){ |
|
| 776 | + if (!$user) { |
|
| 777 | 777 | return; |
| 778 | 778 | } |
| 779 | 779 | |
@@ -787,10 +787,10 @@ discard block |
||
| 787 | 787 | switch ($forum->parent_type) { |
| 788 | 788 | case 0: |
| 789 | 789 | $category = BoincCategory::lookup_id($forum->category); |
| 790 | - $title= forum_title($category, $forum, $thread, true); |
|
| 790 | + $title = forum_title($category, $forum, $thread, true); |
|
| 791 | 791 | break; |
| 792 | 792 | case 1: |
| 793 | - $title= team_forum_title($forum); |
|
| 793 | + $title = team_forum_title($forum); |
|
| 794 | 794 | break; |
| 795 | 795 | } |
| 796 | 796 | row_array([ |
@@ -828,9 +828,9 @@ discard block |
||
| 828 | 828 | function post_rules() { |
| 829 | 829 | if (defined('FORUM_RULES')) return FORUM_RULES; |
| 830 | 830 | if (function_exists("project_forum_post_rules")) { |
| 831 | - $project_rules=project_forum_post_rules(); |
|
| 831 | + $project_rules = project_forum_post_rules(); |
|
| 832 | 832 | } else { |
| 833 | - $project_rules=""; |
|
| 833 | + $project_rules = ""; |
|
| 834 | 834 | } |
| 835 | 835 | return sprintf(" |
| 836 | 836 | <ul> |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | ); |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | -function post_warning($forum=null) { |
|
| 862 | +function post_warning($forum = null) { |
|
| 863 | 863 | $x = '<p><div style="text-align:left">'; |
| 864 | 864 | |
| 865 | 865 | // let projects add extra instructions in specific forums, |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | $content = substr($content, 0, 64000); |
| 946 | 946 | $content = BoincDb::escape_string($content); |
| 947 | 947 | $now = time(); |
| 948 | - $sig = $signature?1:0; |
|
| 948 | + $sig = $signature ? 1 : 0; |
|
| 949 | 949 | $id = BoincPost::insert("(thread, user, timestamp, content, modified, parent_post, score, votes, signature, hidden) values ($thread->id, $user->id, $now, '$content', 0, $parent_id, 0, 0, $sig, 0)"); |
| 950 | 950 | if (!$id) { |
| 951 | 951 | $forum_error = "Failed to add post to DB."; |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | // |
| 966 | 966 | function update_thread_timestamp($thread) { |
| 967 | 967 | $posts = BoincPost::enum("thread=$thread->id and hidden=0 order by timestamp desc limit 1"); |
| 968 | - if (count($posts)>0) { |
|
| 968 | + if (count($posts) > 0) { |
|
| 969 | 969 | $post = $posts[0]; |
| 970 | 970 | $thread->update("timestamp=$post->timestamp"); |
| 971 | 971 | } |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | |
| 974 | 974 | function update_forum_timestamp($forum) { |
| 975 | 975 | $threads = BoincThread::enum("forum=$forum->id and hidden=0 order by timestamp desc limit 1"); |
| 976 | - if (count($threads)>0) { |
|
| 976 | + if (count($threads) > 0) { |
|
| 977 | 977 | $thread = $threads[0]; |
| 978 | 978 | $forum->update("timestamp=$thread->timestamp"); |
| 979 | 979 | } |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | if (is_news_forum($forum) && !$export) { |
| 997 | 997 | $status = 1; |
| 998 | 998 | } |
| 999 | - $id = BoincThread::insert("(forum, owner, status, title, timestamp, views, replies, activity, sufferers, score, votes, create_time, hidden, sticky, locked) values ($forum->id, $user->id, $status, '$title', $now, 0, -1, 0, 0, 0, 0, $now, 0, 0, 0)"); |
|
| 999 | + $id = BoincThread::insert("(forum, owner, status, title, timestamp, views, replies, activity, sufferers, score, votes, create_time, hidden, sticky, locked) values ($forum->id, $user->id, $status, '$title', $now, 0, -1, 0, 0, 0, 0, $now, 0, 0, 0)"); |
|
| 1000 | 1000 | if (!$id) { |
| 1001 | 1001 | $forum_error = "Failed to add thread to DB."; |
| 1002 | 1002 | return null; |
@@ -1125,22 +1125,22 @@ discard block |
||
| 1125 | 1125 | // $sticky - bool (not directly passed to SQL) |
| 1126 | 1126 | // |
| 1127 | 1127 | function get_forum_threads( |
| 1128 | - $forumID, $start=-1, $nRec=-1, $sort_style=MODIFIED_NEW, |
|
| 1128 | + $forumID, $start = -1, $nRec = -1, $sort_style = MODIFIED_NEW, |
|
| 1129 | 1129 | $show_hidden = 0, $sticky = 1 |
| 1130 | 1130 | ) { |
| 1131 | 1131 | //if (! (is_numeric($forumID) && is_numeric($min) && is_numeric($nRec))) { |
| 1132 | 1132 | // return NULL; // Something is wrong here. |
| 1133 | 1133 | //} |
| 1134 | 1134 | |
| 1135 | - $sql = 'forum = ' . $forumID ; |
|
| 1135 | + $sql = 'forum = '.$forumID; |
|
| 1136 | 1136 | $stickysql = ""; |
| 1137 | - if ($sticky){ |
|
| 1137 | + if ($sticky) { |
|
| 1138 | 1138 | $stickysql = "sticky DESC, "; |
| 1139 | 1139 | } |
| 1140 | 1140 | if (!$show_hidden) { |
| 1141 | 1141 | $sql .= ' AND hidden = 0'; |
| 1142 | 1142 | } |
| 1143 | - switch($sort_style) { |
|
| 1143 | + switch ($sort_style) { |
|
| 1144 | 1144 | case MODIFIED_NEW: |
| 1145 | 1145 | $sql .= ' ORDER BY '.$stickysql.'timestamp DESC'; |
| 1146 | 1146 | break; |
@@ -1193,7 +1193,7 @@ discard block |
||
| 1193 | 1193 | if (!$show_hidden) { |
| 1194 | 1194 | $sql .= ' AND hidden = 0'; |
| 1195 | 1195 | } |
| 1196 | - switch($sort_style) { |
|
| 1196 | + switch ($sort_style) { |
|
| 1197 | 1197 | case CREATE_TIME_NEW: |
| 1198 | 1198 | $sql .= ' ORDER BY timestamp desc'; |
| 1199 | 1199 | break; |
@@ -1215,7 +1215,7 @@ discard block |
||
| 1215 | 1215 | // |
| 1216 | 1216 | function show_post_moderation_links( |
| 1217 | 1217 | $config, $logged_in_user, $post, $forum, $tokens |
| 1218 | -){ |
|
| 1218 | +) { |
|
| 1219 | 1219 | $moderators_allowed_to_ban = parse_bool($config, "moderators_allowed_to_ban"); |
| 1220 | 1220 | $moderators_vote_to_ban = parse_bool($config, "moderators_vote_to_ban"); |
| 1221 | 1221 | |
@@ -1302,14 +1302,14 @@ discard block |
||
| 1302 | 1302 | // We do not tell the (ab)user how much this is - |
| 1303 | 1303 | // no need to make it easy for them to break the system. |
| 1304 | 1304 | // |
| 1305 | - if ($user->total_credit<$forum->post_min_total_credit || $user->expavg_credit<$forum->post_min_expavg_credit) { |
|
| 1305 | + if ($user->total_credit < $forum->post_min_total_credit || $user->expavg_credit < $forum->post_min_expavg_credit) { |
|
| 1306 | 1306 | error_page(tra("To create a new thread in %1 you must have a certain level of average credit. This is to protect against abuse of the system.", $forum->title)); |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | // If the user is posting faster than forum regulations allow |
| 1310 | 1310 | // Tell the user to wait a while before creating any more posts |
| 1311 | 1311 | // |
| 1312 | - if (time()-$user->prefs->last_post <$forum->post_min_interval) { |
|
| 1312 | + if (time() - $user->prefs->last_post < $forum->post_min_interval) { |
|
| 1313 | 1313 | error_page(tra("You cannot create threads right now. Please wait before trying again. This is to protect against abuse of the system.")); |
| 1314 | 1314 | } |
| 1315 | 1315 | } |
@@ -1335,10 +1335,10 @@ discard block |
||
| 1335 | 1335 | // - edit their posts at any time |
| 1336 | 1336 | // - hide/unhide/move threads and posts |
| 1337 | 1337 | |
| 1338 | -function is_moderator($user, $forum=null) { |
|
| 1338 | +function is_moderator($user, $forum = null) { |
|
| 1339 | 1339 | if (!$user) return false; |
| 1340 | 1340 | BoincForumPrefs::lookup($user); |
| 1341 | - $type = $forum?$forum->parent_type:0; |
|
| 1341 | + $type = $forum ? $forum->parent_type : 0; |
|
| 1342 | 1342 | switch ($type) { |
| 1343 | 1343 | case 0: |
| 1344 | 1344 | if ($user->prefs->privilege(S_MODERATOR)) return true; |
@@ -1355,7 +1355,7 @@ discard block |
||
| 1355 | 1355 | return false; |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | -function thread_list_header($subscriptions=false) { |
|
| 1358 | +function thread_list_header($subscriptions = false) { |
|
| 1359 | 1359 | if ($subscriptions) { |
| 1360 | 1360 | $x = [ |
| 1361 | 1361 | tra("Thread"), |
@@ -1378,13 +1378,13 @@ discard block |
||
| 1378 | 1378 | // show a 1-line summary of thread and its forum. |
| 1379 | 1379 | // Used for search results and subscription list |
| 1380 | 1380 | // |
| 1381 | -function thread_list_item($thread, $user, $subscriptions=false) { |
|
| 1381 | +function thread_list_item($thread, $user, $subscriptions = false) { |
|
| 1382 | 1382 | $thread_forum = BoincForum::lookup_id($thread->forum); |
| 1383 | 1383 | if (!$thread_forum) return; |
| 1384 | 1384 | if (!is_forum_visible_to_user($thread_forum, $user)) return; |
| 1385 | 1385 | $owner = BoincUser::lookup_id($thread->owner); |
| 1386 | 1386 | if (!$owner) return; |
| 1387 | - switch($thread_forum->parent_type) { |
|
| 1387 | + switch ($thread_forum->parent_type) { |
|
| 1388 | 1388 | case 0: |
| 1389 | 1389 | $category = BoincCategory::lookup_id($thread_forum->category); |
| 1390 | 1390 | $title = forum_title($category, $thread_forum, $thread, true); |
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | } else { |
| 1406 | 1406 | $x = [ |
| 1407 | 1407 | $title, |
| 1408 | - $thread->replies+1, |
|
| 1408 | + $thread->replies + 1, |
|
| 1409 | 1409 | user_links($owner), |
| 1410 | 1410 | $thread->views, |
| 1411 | 1411 | time_diff_str($thread->timestamp, time()) |
@@ -1440,13 +1440,13 @@ discard block |
||
| 1440 | 1440 | |
| 1441 | 1441 | function subscribed_thread_web_line($notify) { |
| 1442 | 1442 | $thread = BoincThread::lookup_id($notify->opaque); |
| 1443 | - return tra("New posts in the thread %1","<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
| 1443 | + return tra("New posts in the thread %1", "<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | function subscribed_thread_rss($notify) { |
| 1447 | 1447 | $thread = BoincThread::lookup_id($notify->opaque); |
| 1448 | 1448 | $title = tra("New posts in subscribed thread"); |
| 1449 | - $msg = tra("There are new posts in the thread '%1'",$thread->title); |
|
| 1449 | + $msg = tra("There are new posts in the thread '%1'", $thread->title); |
|
| 1450 | 1450 | $url = secure_url_base()."forum_thread.php?id=$thread->id"; |
| 1451 | 1451 | return [$title, $msg, $url]; |
| 1452 | 1452 | } |
@@ -1458,13 +1458,13 @@ discard block |
||
| 1458 | 1458 | |
| 1459 | 1459 | function subscribed_forum_web_line($notify) { |
| 1460 | 1460 | $forum = BoincForum::lookup_id($notify->opaque); |
| 1461 | - return tra("New threads in the forum %1","<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
| 1461 | + return tra("New threads in the forum %1", "<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | 1464 | function subscribed_forum_rss($notify) { |
| 1465 | 1465 | $forum = BoincForum::lookup_id($notify->opaque); |
| 1466 | 1466 | $title = tra("New posts in subscribed forum"); |
| 1467 | - $msg = tra("There are new threads in the forum '%1'",$forum->title); |
|
| 1467 | + $msg = tra("There are new threads in the forum '%1'", $forum->title); |
|
| 1468 | 1468 | $url = secure_url_base()."forum_forum.php?id=$forum->id"; |
| 1469 | 1469 | return [$title, $msg, $url]; |
| 1470 | 1470 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | // show a forum. |
| 27 | 27 | // $user is null if not logged in |
| 28 | 28 | // |
| 29 | -function forum_page($forum, $user, $msg=null) { |
|
| 29 | +function forum_page($forum, $user, $msg = null) { |
|
| 30 | 30 | global $forum_sort_styles; |
| 31 | 31 | |
| 32 | 32 | if (DISABLE_FORUMS) { |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | if (!$sort_style) { |
| 55 | 55 | // get the sort style either from the logged in user or a cookie |
| 56 | - if ($user){ |
|
| 56 | + if ($user) { |
|
| 57 | 57 | $sort_style = $user->prefs->forum_sorting; |
| 58 | 58 | } else { |
| 59 | 59 | list($sort_style, $thread_style) = parse_forum_cookie(); |
| 60 | 60 | } |
| 61 | 61 | } else { |
| 62 | 62 | // set the sort style |
| 63 | - if ($user){ |
|
| 63 | + if ($user) { |
|
| 64 | 64 | $user->prefs->forum_sorting = $sort_style; |
| 65 | 65 | $user->prefs->update("forum_sorting=$sort_style"); |
| 66 | 66 | } else { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | echo "<td><a href=\"forum_thread.php?id=$thread->id\">$title</a><br></td>"; |
| 249 | 249 | |
| 250 | 250 | echo ' |
| 251 | - <td>'.($thread->replies+1).'</td> |
|
| 251 | + <td>'.($thread->replies + 1).'</td> |
|
| 252 | 252 | <td>'.user_links($owner, BADGE_HEIGHT_SMALL).'</td> |
| 253 | 253 | <td>'.$thread->views.'</td> |
| 254 | 254 | <td>'.time_diff_str($thread->timestamp, time()).'</td> |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | flush(); |
| 258 | 258 | } |
| 259 | 259 | end_table(); |
| 260 | - echo "<br>$page_nav"; // show page links |
|
| 260 | + echo "<br>$page_nav"; // show page links |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $id = get_int("id"); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | if ($n === false) return ''; |
| 34 | 34 | $m = strpos($p, ']', $n); |
| 35 | 35 | if ($m === false) return ''; |
| 36 | - $x = substr($p, $n+5, $m-$n-5); |
|
| 36 | + $x = substr($p, $n + 5, $m - $n - 5); |
|
| 37 | 37 | |
| 38 | 38 | $n = strpos($x, ' '); |
| 39 | 39 | if ($n !== false) return substr($x, 0, $n); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | if ($n === false) return ''; |
| 48 | 48 | $m = strpos($p, ']', $n); |
| 49 | 49 | if ($m === false) return ''; |
| 50 | - $x = substr($p, $n+5, $m-$n-5); |
|
| 50 | + $x = substr($p, $n + 5, $m - $n - 5); |
|
| 51 | 51 | $n = strpos($x, '_'); |
| 52 | 52 | if ($n !== false) return substr($x, 0, $n); |
| 53 | 53 | $n = strpos($x, 'r'); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | function main() { |
| 59 | 59 | global $max_days; |
| 60 | - $t = time()-$max_days*86400; |
|
| 60 | + $t = time() - $max_days*86400; |
|
| 61 | 61 | $hosts = BoincHost::enum("rpc_time>$t"); |
| 62 | 62 | $descs = []; |
| 63 | 63 | foreach ($hosts as $host) { |