Commit: 0e511803a5fdc430897d53e76d4eaeea407f1e1e Author: Peter Kokot <peterko...@gmail.com> Mon, 10 Dec 2018 03:26:03 +0100 Parents: bce0f6fa023edad1b61285bea51b554a00ab488b Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=0e511803a5fdc430897d53e76d4eaeea407f1e1e Log: Refactor long array() syntax to short [] Since app is using PHP 5.4+ already, the longer `array()` syntax can be refactored to shorter `[]`. Changed paths: M entry/event.php M entry/subscribe.php M entry/svn-account.php M entry/user-note.php M entry/user-notes-vote.php M fetch/allusers.php M fetch/cvsauth.php M fetch/events.php M fetch/user-notes-rss.php M fetch/user-notes.php M fetch/user-profile.php M fetch/user.php M forgot.php M github-webhook.php M include/functions.inc M include/languages.inc M include/login.inc M include/note-reasons.inc M include/spam-lib.inc M manage/challenge-response.php M manage/event.php M manage/github.php M manage/mirrors.php M manage/user-notes.php M manage/users.php M network/status/index.php M scripts/conference_teaser M scripts/countries.inc M scripts/event_listing M scripts/ip-to-country M scripts/mirror-summary M scripts/mirror-test M scripts/pregen_flickr M scripts/pregen_news M scripts/rss_parser
diff --git a/entry/event.php b/entry/event.php index 80c4899..2fc07ad 100644 --- a/entry/event.php +++ b/entry/event.php @@ -3,7 +3,7 @@ $mailto = 'php-webmaster@lists.php.net'; #$mailto = 'j...@apache.org'; -$re = array( +$re = [ 1 => 'First', 2 => 'Second', 3 => 'Third', @@ -11,8 +11,8 @@ $re = array( -1 => 'Last', -2 => 'Second to Last', -3 => 'Third to Last' - ); -$cat = array("unknown", "User Group Event", "Conference", "Training"); +]; +$cat = ["unknown", "User Group Event", "Conference", "Training"]; function day($in) { return strftime('%A',mktime(12,0,0,4,$in,2001)); @@ -23,7 +23,7 @@ function day($in) { @mysql_select_db("phpmasterdb") or die("failed to select database"); -$valid_vars = array('sdesc','ldesc','email','country','category','type','url','sane','smonth','sday','syear','emonth','eday','eyear','recur','recur_day'); +$valid_vars = ['sdesc','ldesc','email','country','category','type','url','sane','smonth','sday','syear','emonth','eday','eyear','recur','recur_day']; foreach($valid_vars as $k) { $$k = isset($_REQUEST[$k]) ? mysql_real_escape_string($_REQUEST[$k]) : false; } diff --git a/entry/subscribe.php b/entry/subscribe.php index 7500cc5..350a11d 100644 --- a/entry/subscribe.php +++ b/entry/subscribe.php @@ -22,7 +22,7 @@ if (!is_emailable_address($_POST['email'])) { } // Check request mode -if (!in_array($_POST['request'], array("subscribe", "unsubscribe"))) { +if (!in_array($_POST['request'], ["subscribe", "unsubscribe"])) { die("Invalid request mode"); } diff --git a/entry/svn-account.php b/entry/svn-account.php index a27d22b..5b14fd8 100644 --- a/entry/svn-account.php +++ b/entry/svn-account.php @@ -4,7 +4,7 @@ require dirname(__FILE__) . '/../include/email-validation.inc'; require dirname(__FILE__) . '/../include/cvs-auth.inc'; require dirname(__FILE__) . '/../include/functions.inc'; -$valid_vars = array('name','email','username','passwd','note','group','yesno'); +$valid_vars = ['name','email','username','passwd','note','group','yesno']; foreach($valid_vars as $k) { if(isset($_REQUEST[$k])) $$k = $_REQUEST[$k]; } @@ -50,7 +50,7 @@ $username = strtolower($username); # placed in qmail-smtpd's badmailfrom to block future emails.) some of these # latter addresses were used as examples in the documentation at one point, # which means they appear on all sorts of spam lists. -if (in_array($username,array('nse','roys','php','foo','group','core','webmaster','web','aardvark','zygote','jag','sites','er','sqlite','cvs2svn','nobody','svn','git','root'))) +if (in_array($username,['nse','roys','php','foo','group','core','webmaster','web','aardvark','zygote','jag','sites','er','sqlite','cvs2svn','nobody','svn','git','root'])) die("that username is not available"); if (!preg_match('@^[a-z0-9_.-]+$@', $username)) { diff --git a/entry/user-note.php b/entry/user-note.php index 7a4afd2..776a03c 100644 --- a/entry/user-note.php +++ b/entry/user-note.php @@ -18,13 +18,13 @@ function validateUser($user) { // If its not a valid email then strip all tags and \r & \n (since this will be used in the mail "from" header) / if(!$ret) { $ret = filter_var($user, FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_HIGH); - $ret = str_replace(array("\r", "\n"), "", $ret); + $ret = str_replace(["\r", "\n"], "", $ret); } return trim($ret); } -$user = filter_input(INPUT_POST, "user", FILTER_CALLBACK, array("filter" => FILTER_CALLBACK, "options" => "validateUser")); +$user = filter_input(INPUT_POST, "user", FILTER_CALLBACK, ["filter" => FILTER_CALLBACK, "options" => "validateUser"]); $note = filter_input(INPUT_POST, "note", FILTER_UNSAFE_RAW); $sect = filter_input(INPUT_POST, "sect", FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_HIGH); $ip = filter_input(INPUT_POST, "ip", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE); diff --git a/entry/user-notes-vote.php b/entry/user-notes-vote.php index bcaa62a..8037d26 100644 --- a/entry/user-notes-vote.php +++ b/entry/user-notes-vote.php @@ -28,36 +28,36 @@ undo_magic_quotes(); */ function undo_magic_quotes() { if (!empty($_POST)) { - $args = array(); - foreach ($_POST as $key => $val) $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args = []; + foreach ($_POST as $key => $val) $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; $_POST = filter_input_array(INPUT_POST, $args); $_REQUEST = filter_input_array(INPUT_POST, $args); } if (!empty($_GET)) { - $args = array(); - foreach ($_GET as $key => $val) $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args = []; + foreach ($_GET as $key => $val) $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; $_GET = filter_input_array(INPUT_GET, $args); $_REQUEST += filter_input_array(INPUT_GET, $args); } if (!empty($_COOKIE)) { - $args = array(); - foreach ($_COOKIE as $key => $val) $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args = []; + foreach ($_COOKIE as $key => $val) $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; $_COOKIE = filter_input_array(INPUT_COOKIE, $args); $_REQUEST += filter_input_array(INPUT_COOKIE, $args); } if (!empty($_SERVER)) { - $args = array(); - $append = array(); + $args = []; + $append = []; foreach ($_SERVER as $key => $val) { if ($key == 'REQUEST_TIME' || $key == 'REQUEST_TIME_FLOAT') { $append[$key] = $val; continue; } - $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; } $_SERVER = filter_input_array(INPUT_SERVER, $args); $_SERVER += $append; @@ -116,7 +116,7 @@ function vote_validate_request(PDO $dbh) { if (!$noteStmt) { return false; } - if (!$noteStmt->execute(array('id' => $id))) { + if (!$noteStmt->execute(['id' => $id])) { return false; } if (false === $noteResult = $noteStmt->fetch(PDO::FETCH_ASSOC)) { @@ -131,7 +131,7 @@ function vote_validate_request(PDO $dbh) { if (!$remoteStmt) { return false; } - if (!$remoteStmt->execute(array('ip' => $ip, 'id' => $id))) { + if (!$remoteStmt->execute(['ip' => $ip, 'id' => $id])) { return false; } if (false === $remoteResult = $remoteStmt->fetch(PDO::FETCH_ASSOC)) { @@ -146,7 +146,7 @@ function vote_validate_request(PDO $dbh) { if (!$hostStmt) { return false; } - if (!$hostStmt->execute(array('ip' => $ip, 'id' => $id))) { + if (!$hostStmt->execute(['ip' => $ip, 'id' => $id])) { return false; } if (false === $hostResult = $hostStmt->fetch(PDO::FETCH_ASSOC)) { @@ -161,7 +161,7 @@ function vote_validate_request(PDO $dbh) { if (!$voteStmt) { return false; } - if (!$voteStmt->execute(array('id' => $id, 'ip' => $ip, 'host' => $hostip, 'ts' => $ts, 'vote' => $vote))) { + if (!$voteStmt->execute(['id' => $id, 'ip' => $ip, 'host' => $hostip, 'ts' => $ts, 'vote' => $vote])) { return false; } @@ -171,7 +171,7 @@ function vote_validate_request(PDO $dbh) { if (!$voteStmt) { return false; } - if (!$voteStmt->execute(array('id' => $id))) { + if (!$voteStmt->execute(['id' => $id])) { return false; } if (false === $voteResult = $voteStmt->fetch(PDO::FETCH_ASSOC)) { diff --git a/fetch/allusers.php b/fetch/allusers.php index bb76b02..6f2b945 100644 --- a/fetch/allusers.php +++ b/fetch/allusers.php @@ -15,7 +15,7 @@ function error($text, $status) header("HTTP/1.0 401 Unauthorized"); break; } - echo json_encode(array("error" => $text)); + echo json_encode(["error" => $text]); exit; } diff --git a/fetch/cvsauth.php b/fetch/cvsauth.php index 2c72aa4..4281bbd 100644 --- a/fetch/cvsauth.php +++ b/fetch/cvsauth.php @@ -3,20 +3,20 @@ CVS username+password authentication service for .php.net sites. Usage: $post = http_build_query( - array( + [ "token" => getenv("TOKEN"), "username" => $username, "password" => $password, - ) + ] ); -$opts = array( +$opts = [ "method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded", "content" => $post, -); +]; -$ctx = stream_context_create(array("http" => $opts)); +$ctx = stream_context_create(["http" => $opts]); $s = file_get_contents("https://master.php.net/fetch/cvsauth.php", false, $ctx); @@ -44,29 +44,29 @@ define("E_PASSWORD", 2); function exit_forbidden($why) { switch($why) { case E_USERNAME: - echo serialize(array("errstr" => "Incorrect username", "errno" => E_USERNAME)); + echo serialize(["errstr" => "Incorrect username", "errno" => E_USERNAME]); break; case E_PASSWORD: - echo serialize(array("errstr" => "Incorrect password", "errno" => E_PASSWORD)); + echo serialize(["errstr" => "Incorrect password", "errno" => E_PASSWORD]); break; case E_UNKNOWN: default: - echo serialize(array("errstr" => "Unknown error", "errno" => E_UNKNOWN)); + echo serialize(["errstr" => "Unknown error", "errno" => E_UNKNOWN]); } exit; } function exit_success() { - echo serialize(array("SUCCESS" => "Username and password OK")); + echo serialize(["SUCCESS" => "Username and password OK"]); exit; } $MQ = get_magic_quotes_gpc(); // Create required variables and kill MQ -$fields = array("token", "username", "password"); +$fields = ["token", "username", "password"]; foreach($fields as $field) { if (isset($_POST[$field])) { $$field = $MQ ? stripslashes($_POST[$field]) : $_POST[$field]; diff --git a/fetch/events.php b/fetch/events.php index 9c6cba4..9c32a91 100644 --- a/fetch/events.php +++ b/fetch/events.php @@ -1,6 +1,6 @@ <?php -$valid_vars = array('token','cm','cy','cd','nm'); +$valid_vars = ['token','cm','cy','cd','nm']; foreach($valid_vars as $k) { if(isset($_GET[$k])) $$k = $_GET[$k]; } @@ -82,7 +82,7 @@ function weekday($year, $month, $day, $which) function load_month($year, $month, $cat) { // Empty events array - $events = array(); + $events = []; // Get approved events starting or ending in the // specified year/month, and all recurring events @@ -97,7 +97,7 @@ function load_month($year, $month, $cat) ); // Cannot get results, return with event's not found - if (!$result) { echo mysql_error(); return array(); } + if (!$result) { echo mysql_error(); return []; } // Go through found events while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { diff --git a/fetch/user-notes-rss.php b/fetch/user-notes-rss.php index 5894a69..47e2884 100644 --- a/fetch/user-notes-rss.php +++ b/fetch/user-notes-rss.php @@ -33,7 +33,7 @@ if (!$res = @mysql_query($query, $conn)) { die('Query failed'); } -$notes = array(); +$notes = []; while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) { $notes[$row['id']] = $row; } diff --git a/fetch/user-notes.php b/fetch/user-notes.php index 9496fd3..cb87b1e 100644 --- a/fetch/user-notes.php +++ b/fetch/user-notes.php @@ -39,7 +39,7 @@ while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $row['rate'] = empty($row['rate']) ? 0 : $row['rate']; if ($user != "php-gene...@lists.php.net" && $user != "u...@example.com") { if (preg_match("!(.+)@(.+)\.(.+)!", $user)) { - $user = str_replace(array('@', '.'), array(' at ', ' dot '), $user); + $user = str_replace(['@', '.'], [' at ', ' dot '], $user); } } else { $user = ''; diff --git a/fetch/user-profile.php b/fetch/user-profile.php index 95b2bd6..15f1a38 100644 --- a/fetch/user-profile.php +++ b/fetch/user-profile.php @@ -15,7 +15,7 @@ function error($text, $status) header("HTTP/1.0 401 Unauthorized"); break; } - render(array("error" => $text)); + render(["error" => $text]); exit; } @@ -40,7 +40,7 @@ $stmt = $pdo->prepare(" WHERE u.username = ? AND cvsaccess LIMIT 1 "); -if (!$stmt->execute(array($USERNAME))) { +if (!$stmt->execute([$USERNAME])) { error("This error should never happen", 500); } diff --git a/fetch/user.php b/fetch/user.php index 99a2071..d312e2b 100644 --- a/fetch/user.php +++ b/fetch/user.php @@ -15,7 +15,7 @@ function error($text, $status) header("HTTP/1.0 401 Unauthorized"); break; } - echo json_encode(array("error" => $text)); + echo json_encode(["error" => $text]); exit; } @@ -26,7 +26,7 @@ $USERNAME = filter_input(INPUT_GET, "username", FILTER_SANITIZE_STRING, FILTER_F $pdo = new PDO("mysql:host=localhost;dbname=phpmasterdb", "nobody", ""); $stmt = $pdo->prepare("SELECT userid, name, email, username, spamprotect, use_sa, greylist, enable FROM users WHERE username = ? AND cvsaccess LIMIT 1"); -if (!$stmt->execute(array($USERNAME))) { +if (!$stmt->execute([$USERNAME])) { error("This error should never happen", 500); } @@ -36,7 +36,7 @@ if (!$results) { } $stmt = $pdo->prepare("SELECT note, entered FROM users_note WHERE userid = ?"); -if (!$stmt->execute(array($results["userid"]))) { +if (!$stmt->execute([$results["userid"]])) { error("This error should never happen", 500); } diff --git a/forgot.php b/forgot.php index 43d33bc..c8e2d77 100644 --- a/forgot.php +++ b/forgot.php @@ -2,7 +2,7 @@ require dirname(__FILE__) . '/include/functions.inc'; require dirname(__FILE__) . "/include/cvs-auth.inc"; -$valid_vars = array('id','user','key','n1','n2'); +$valid_vars = ['id','user','key','n1','n2']; foreach($valid_vars as $k) { $$k = isset($_REQUEST[$k]) ? $_REQUEST[$k] : false; } diff --git a/github-webhook.php b/github-webhook.php index 9004252..a76f657 100644 --- a/github-webhook.php +++ b/github-webhook.php @@ -41,14 +41,14 @@ function send_mail($to, $subject, $message, $headers) { } -$CONFIG = array( - 'repos' => array( +$CONFIG = [ + 'repos' => [ 'php-langspec' => 'standa...@lists.php.net', 'php-src' => 'git-pu...@lists.php.net', 'web-' => 'php-webmaster@lists.php.net', 'pecl-' => 'pecl-...@lists.php.net', - ), -); + ], +]; $body = file_get_contents("php://input"); diff --git a/include/functions.inc b/include/functions.inc index 5ea2be1..c37f74f 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -16,35 +16,35 @@ function require_token() // ----------------------------------------------------------------------------------- -function head($title="", $config = array()) { - $dconfig = array("columns" => 1); +function head($title="", $config = []) { + $dconfig = ["columns" => 1]; $config = array_merge($dconfig, $config); $SUBDOMAIN = "master"; $TITLE = $title ?: "master"; - $LINKS = array( - array("href" => "/manage/event.php", "text" => "Events"), - array("href" => "/manage/mirrors.php", "text" => "Mirrors"), - array("href" => "/manage/users.php", "text" => "Users"), - array("href" => "/manage/user-notes.php", "text" => "Notes"), - array("href" => "/manage/github.php", "text" => "Github"), - ); - $CSS = array("/styles/master.css"); - $SEARCH = array(); + $LINKS = [ + ["href" => "/manage/event.php", "text" => "Events"], + ["href" => "/manage/mirrors.php", "text" => "Mirrors"], + ["href" => "/manage/users.php", "text" => "Users"], + ["href" => "/manage/user-notes.php", "text" => "Notes"], + ["href" => "/manage/github.php", "text" => "Github"], + ]; + $CSS = ["/styles/master.css"]; + $SEARCH = []; if (strstr($_SERVER["SCRIPT_FILENAME"], "users.php")) { - $SEARCH = array("method" => "get", "action" => "/manage/users.php", "placeholder" => "Search profiles", "name" => "search"); + $SEARCH = ["method" => "get", "action" => "/manage/users.php", "placeholder" => "Search profiles", "name" => "search"]; $CSS[] = "/styles/user-autocomplete.css"; } if (strstr($_SERVER["SCRIPT_FILENAME"], "event.php")) { - $SEARCH = array("method" => "get", "action" => "/manage/event.php", "placeholder" => "Search Events", "name" => "search"); + $SEARCH = ["method" => "get", "action" => "/manage/event.php", "placeholder" => "Search Events", "name" => "search"]; } if (strstr($_SERVER["SCRIPT_FILENAME"], "user-notes.php")) { - $SEARCH = array("method" => "get", "action" => "/manage/user-notes.php", "placeholder" => "Search notes (keyword, ID or sect:)", "name" => "keyword"); + $SEARCH = ["method" => "get", "action" => "/manage/user-notes.php", "placeholder" => "Search notes (keyword, ID or sect:)", "name" => "keyword"]; } if (isset($_SESSION['credentials'])) { - array_unshift($LINKS, array("href" => "/manage/users.php?username=" . $_SESSION["credentials"][0], "text" => "My Profile")); - $LINKS[] = array("href" => "/login.php?action=logout", "text" => "Logout"); + array_unshift($LINKS, ["href" => "/manage/users.php?username=" . $_SESSION["credentials"][0], "text" => "My Profile"]); + $LINKS[] = ["href" => "/login.php?action=logout", "text" => "Logout"]; } include __DIR__ . "/../shared/templates/header.inc"; if ($config["columns"] > 1) { @@ -57,9 +57,9 @@ function head($title="", $config = array()) { function foot($secondscreen = null) { $SECONDSCREEN = $secondscreen; - $JS = array( + $JS = [ "/js/master.js", - ); + ]; if (strstr($_SERVER["SCRIPT_FILENAME"], "users.php")) { array_push( $JS, @@ -134,8 +134,8 @@ function db_get_one($query) // ----------------------------------------------------------------------------------- -function array_to_url($array,$overlay=array()) { - $params = array(); +function array_to_url($array,$overlay=[]) { + $params = []; foreach($array as $k => $v) { $params[$k] = rawurlencode($k) . "=" . rawurlencode($v); } @@ -151,7 +151,7 @@ function array_to_url($array,$overlay=array()) { return join($params, "&"); } -function show_prev_next($begin, $rows, $skip, $total, $extra = array(), $table = true) +function show_prev_next($begin, $rows, $skip, $total, $extra = [], $table = true) {?> <?php if ($table): ?> <table border="0" cellspacing="1" width="100%"> @@ -162,7 +162,7 @@ function show_prev_next($begin, $rows, $skip, $total, $extra = array(), $table = if ($begin > 0) { printf("<a href=\"%s?%s\">« Previous %d", $_SERVER['PHP_SELF'], - array_to_url($extra, array("begin" => max(0,$begin-$skip))), + array_to_url($extra, ["begin" => max(0,$begin-$skip)]), min($skip,$begin)); } ?> @@ -181,7 +181,7 @@ function show_prev_next($begin, $rows, $skip, $total, $extra = array(), $table = if ($begin+$rows < $total) { printf("<a href=\"%s?%s\">Next %d »", $_SERVER['PHP_SELF'], - array_to_url($extra, array("begin" => $begin+$skip)), + array_to_url($extra, ["begin" => $begin+$skip]), min($skip,$total-($begin+$skip))); } ?> @@ -204,7 +204,7 @@ function show_country_options($cc = "") function is_sqlite_type_available($avails, $check) { // All possible sqlite types associated with our assigned bitwise values - $all = array('sqlite' => 1, 'sqlite3' => 2, 'pdo_sqlite' => 4, 'pdo_sqlite2' => 8); + $all = ['sqlite' => 1, 'sqlite3' => 2, 'pdo_sqlite' => 4, 'pdo_sqlite2' => 8]; if (!$avails || empty($all[$check])) { return false; @@ -221,8 +221,8 @@ function is_sqlite_type_available($avails, $check) { function decipher_available_sqlites($avails) { - $all = array(1 => 'sqlite', 2 => 'sqlite3', 4 => 'pdo_sqlite', 8 => 'pdo_sqlite2'); - $mine = array(); + $all = [1 => 'sqlite', 2 => 'sqlite3', 4 => 'pdo_sqlite', 8 => 'pdo_sqlite2']; + $mine = []; $avails = (int) $avails; if (($avails & 15) === 15) { @@ -243,11 +243,11 @@ function verify_ssh_keys($string) { } function get_ssh_keys($string) { - $results = array(); + $results = []; if (preg_match_all('@(ssh-(?:rsa|dss) ([^\s]+) ([^\s]*))@', $string, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { - $results[] = array('key' => $match[1], - 'name' => $match[3]); + $results[] = ['key' => $match[1], + 'name' => $match[3]]; } } @@ -286,36 +286,36 @@ include_once dirname(__FILE__) . '/../vendor/michelf/php-markdown-extra/markdown */ function undo_magic_quotes() { if (!empty($_POST)) { - $args = array(); - foreach ($_POST as $key => $val) $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args = []; + foreach ($_POST as $key => $val) $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; $_POST = filter_input_array(INPUT_POST, $args); $_REQUEST = filter_input_array(INPUT_POST, $args); } if (!empty($_GET)) { - $args = array(); - foreach ($_GET as $key => $val) $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args = []; + foreach ($_GET as $key => $val) $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; $_GET = filter_input_array(INPUT_GET, $args); $_REQUEST += filter_input_array(INPUT_GET, $args); } if (!empty($_COOKIE)) { - $args = array(); - foreach ($_COOKIE as $key => $val) $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args = []; + foreach ($_COOKIE as $key => $val) $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; $_COOKIE = filter_input_array(INPUT_COOKIE, $args); $_REQUEST += filter_input_array(INPUT_COOKIE, $args); } if (!empty($_SERVER)) { - $args = array(); - $append = array(); + $args = []; + $append = []; foreach ($_SERVER as $key => $val) { if ($key == 'REQUEST_TIME' || $key == 'REQUEST_TIME_FLOAT') { $append[$key] = $val; continue; } - $args[$key] = array('filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? - FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR); + $args[$key] = ['filter' => FILTER_UNSAFE_RAW, 'flags' => is_array($val) ? + FILTER_REQUIRE_ARRAY : FILTER_REQUIRE_SCALAR]; } $_SERVER = filter_input_array(INPUT_SERVER, $args); $_SERVER += $append; @@ -408,7 +408,7 @@ function user_remove($id) { } function is_admin($user) { - $admins = array( + $admins = [ "jimw", "rasmus", "andrei", @@ -433,12 +433,12 @@ function is_admin($user) { "cmb", "kalle", "krakjoe" - ); + ]; return in_array($user, $admins); } function is_mirror_site_admin($user) { - $admins = array( + $admins = [ "jimw", "rasmus", "andrei", @@ -460,7 +460,7 @@ function is_mirror_site_admin($user) { "dm", "kalle", "googleguy" - ); + ]; return in_array($user, $admins); } diff --git a/include/languages.inc b/include/languages.inc index 8dbc5c7..37cff28 100644 --- a/include/languages.inc +++ b/include/languages.inc @@ -11,7 +11,7 @@ http://www.unicode.org/unicode/onlinedat/languages.html */ -$LANGUAGES = array( +$LANGUAGES = [ 'en' => 'English', 'ar' => 'Arabic', 'pt_BR' => 'Brazilian Portuguese', @@ -37,12 +37,12 @@ $LANGUAGES = array( 'es' => 'Spanish', 'sv' => 'Swedish', 'tr' => 'Turkish', -); +]; -$INACTIVE_ONLINE_LANGUAGES = array( +$INACTIVE_ONLINE_LANGUAGES = [ 'el' => 'Greek', 'ar' => 'Arabic', -); +]; // Convert between language codes back and forth // [We use non standard languages codes and so conversion diff --git a/include/login.inc b/include/login.inc index 94d0bb7..3d536be 100644 --- a/include/login.inc +++ b/include/login.inc @@ -22,14 +22,14 @@ require 'functions.inc'; $cuser = $cpw = FALSE; if (isset($_POST["user"], $_POST["pw"])) { - list($cuser, $cpw) = array($_POST['user'], $_POST['pw']); + list($cuser, $cpw) = [$_POST['user'], $_POST['pw']]; } elseif (isset($_SESSION["credentials"]) && count($_SESSION["credentials"]) == 2) { list($cuser, $cpw) = $_SESSION["credentials"]; } // Login form, if the user is not yet logged in if (!$cuser || !$cpw || !verify_password($cuser,$cpw)) { - $_SESSION = array(); + $_SESSION = []; session_destroy(); // IS_DEV was 1 or 0 until 22 Feb 2012. It's now a @php.net username hint. @@ -69,11 +69,11 @@ if (!$cuser || !$cpw || !verify_password($cuser,$cpw)) { </tr> <?php if ($cpw): ?> <?php - $msgs = array( + $msgs = [ "Nope.. Wrong (username?) password", "Nope.. Thats not it", "This isn't going very well..", - ); + ]; shuffle($msgs); $msg = array_pop($msgs); ?> @@ -91,7 +91,7 @@ if (!$cuser || !$cpw || !verify_password($cuser,$cpw)) { session_regenerate_id(); // At this point, we have logged in successfully -$_SESSION["credentials"] = array($cuser, $cpw); +$_SESSION["credentials"] = [$cuser, $cpw]; $_SESSION["username"] = $cuser; // Killing magic cookie diff --git a/include/note-reasons.inc b/include/note-reasons.inc index f2d9647..1eaaef1 100644 --- a/include/note-reasons.inc +++ b/include/note-reasons.inc @@ -2,14 +2,14 @@ /* $Id: */ // stock reasons for deleting notes -$note_del_reasons = array( +$note_del_reasons = [ 'integrated', 'useless', 'bad code', 'spam', 'non-english', 'in docs', -); +]; $note_del_reasons_pad = 0; foreach ($note_del_reasons AS $r) { if (($l = strlen($r)) > $note_del_reasons_pad) { diff --git a/include/spam-lib.inc b/include/spam-lib.inc index dd2d3a7..605243e 100644 --- a/include/spam-lib.inc +++ b/include/spam-lib.inc @@ -5,7 +5,7 @@ $spamassassin_path = '/opt/ecelerity/3rdParty/bin/spamassassin'; // List of usual SPAM words -$words_blacklist = array( +$words_blacklist = [ '000webhost', 'adipex', 'alprazolam', @@ -51,7 +51,7 @@ $words_blacklist = array( 'xanax', 'zanaflex', 'http://republika.pl', -); +]; function check_spam_words ($text, $badwords) { foreach($badwords as $badword) { @@ -97,8 +97,8 @@ function is_spam_ip ($ip) { // spammers lists // [0] => dns server, [1] => exclude ip - $lists[] = array('bl.spamcop.net'); - $lists[] = array('dnsbl.sorbs.net', '127.0.0.10'); // exclude dynamic ips list + $lists[] = ['bl.spamcop.net']; + $lists[] = ['dnsbl.sorbs.net', '127.0.0.10']; // exclude dynamic ips list foreach ($lists as $list) { $host = $reverse_ip . '.' . $list[0]; diff --git a/manage/challenge-response.php b/manage/challenge-response.php index b8ce0d4..d49c7c9 100644 --- a/manage/challenge-response.php +++ b/manage/challenge-response.php @@ -24,7 +24,7 @@ if (isset($_POST['confirm_them']) && isset($_POST['confirm']) && is_array($_POST $user_db = mysql_real_escape_string($user); $res = db_query("select distinct sender from phpmasterdb.users left join accounts.quarantine on users.email = rcpt where username='$user_db' and not isnull(id)"); -$inmates = array(); +$inmates = []; while ($row = mysql_fetch_row($res)) { $inmates[] = $row[0]; } diff --git a/manage/event.php b/manage/event.php index d45a59f..f63dde5 100644 --- a/manage/event.php +++ b/manage/event.php @@ -15,15 +15,15 @@ for ($i = 1; $i <= 12; $i++) { $months[$i] = strftime('%B',mktime(12,0,0,$i,1,2001)); } -$re = array(1=>'First',2=>'Second',3=>'Third',4=>'Fourth',-1=>'Last',-2=>'2nd Last',-3=>'3rd Last'); -$cat = array("unknown", "User Group Event", "Conference", "Training"); +$re = [1=>'First',2=>'Second',3=>'Third',4=>'Fourth',-1=>'Last',-2=>'2nd Last',-3=>'3rd Last']; +$cat = ["unknown", "User Group Event", "Conference", "Training"]; -$type = array(1=>'single',2=>'multi',3=>'recur'); +$type = [1=>'single',2=>'multi',3=>'recur']; head("event administration"); db_connect(); -$valid_vars = array('id', 'action','in','begin','max','search','order','full','unapproved'); +$valid_vars = ['id', 'action','in','begin','max','search','order','full','unapproved']; foreach($valid_vars as $k) { $$k = isset($_REQUEST[$k]) ? $_REQUEST[$k] : false; } @@ -231,7 +231,7 @@ $limit = "LIMIT $begin,$max"; $orderby=""; $forward = filter_input(INPUT_GET, "forward", FILTER_VALIDATE_INT) ?: 0; if ($order) { - if (!in_array($order, array('sdato', 'sdesc', 'email', 'country', 'category'))) { + if (!in_array($order, ['sdato', 'sdesc', 'email', 'country', 'category'])) { $order = 'sdato'; } if ($forward) { @@ -261,7 +261,7 @@ $query = "SELECT phpcal.*,country.name AS cname FROM phpcal LEFT JOIN country ON #echo "<pre>$query</pre>"; $res = db_query($query); -$extra = array( +$extra = [ "search" => stripslashes($search), "order" => $order, "begin" => $begin, @@ -269,18 +269,18 @@ $extra = array( "full" => $full, "unapproved" => $unapproved, "forward" => $forward, -); +]; show_prev_next($begin,mysql_num_rows($res),$max,$total,$extra); ?> <table class="useredit"> <tr> - <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,array("full" => $full ? 0 : 1));?>"><?php echo $full ? "⊗" : "⊕";?></a></th> - <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,array("order"=>"sdato"));?>">date</a></th> - <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,array("order"=>"sdesc"));?>">summary</a></th> - <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,array("order"=>"email"));?>">email</a></th> - <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,array("order"=>"country"));?>">country</a></th> - <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,array("order"=>"category"));?>">category</a></th> + <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,["full" => $full ? 0 : 1]);?>"><?php echo $full ? "⊗" : "⊕";?></a></th> + <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,["order"=>"sdato"]);?>">date</a></th> + <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,["order"=>"sdesc"]);?>">summary</a></th> + <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,["order"=>"email"]);?>">email</a></th> + <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,["order"=>"country"]);?>">country</a></th> + <th><a href="<?php echo PHP_SELF,'?',array_to_url($extra,["order"=>"category"]);?>">category</a></th> </tr> <?php while ($row = mysql_fetch_array($res,MYSQL_ASSOC)) { diff --git a/manage/github.php b/manage/github.php index bf32cda..4ecbceb 100644 --- a/manage/github.php +++ b/manage/github.php @@ -16,12 +16,12 @@ if (!defined('GITHUB_USER_AGENT')) { define('GITHUB_USER_AGENT', 'php.net repository management (master.php.net, syst...@php.net, johan...@php.net)'); } -function github_api($endpoint, $method = 'GET', $options = array()) +function github_api($endpoint, $method = 'GET', $options = []) { $options['method'] = $method; $options['user_agent'] = GITHUB_USER_AGENT; - $ctxt = stream_context_create(array('http' => $options)); + $ctxt = stream_context_create(['http' => $options]); $url = 'https://api.github.com'.$endpoint; $s = @file_get_contents($url, false, $ctxt); @@ -58,24 +58,24 @@ function github_require_valid_user() } if (isset($_GET['code'])) { - $data = array( + $data = [ 'client_id' => GITHUB_CLIENT_ID, 'client_secret' => GITHUB_CLIENT_SECRET, 'code' => $_GET['code'] - ); + ]; $data_encoded = http_build_query($data); - $opts = array( + $opts = [ 'method' => 'POST', 'user_agent' => GITHUB_USER_AGENT, 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $data_encoded, - ); - $ctxt = stream_context_create(array('http' => $opts)); + ]; + $ctxt = stream_context_create(['http' => $opts]); $s = @file_get_contents('https://github.com/login/oauth/access_token', false, $ctxt); if (!$s) { die('Failed while checking with GitHub,either you are trying to hack us or our configuration is wrong (GITHUB_CLIENT_SECRET outdated?)'); } - $gh = array(); + $gh = []; parse_str($s, $gh); if (empty($gh['access_token'])) { die("GitHub responded but didn't send an access_token"); @@ -84,8 +84,8 @@ function github_require_valid_user() $user = github_current_user($gh['access_token']); $endpoint = '/teams/'.urlencode(GITHUB_PHP_OWNER_TEAM_ID).'/members/'.urlencode($user->login); - $opts = array('user_agent' => GITHUB_USER_AGENT); - $ctxt = stream_context_create(array('http' => $opts)); + $opts = ['user_agent' => GITHUB_USER_AGENT]; + $ctxt = stream_context_create(['http' => $opts]); $is_member = file_get_contents('https://api.github.com'.$endpoint.'?access_token='.urlencode($gh['access_token']), false, $ctxt); if ($is_member === false) { @@ -148,7 +148,7 @@ function action_create_repo() { github_require_valid_user(); - $data = array( + $data = [ 'name' => $_POST['name'], 'description' => $_POST['description'], @@ -158,11 +158,11 @@ function action_create_repo() 'has_wiki' => false, 'has_downloads' => false, 'team_id' => GITHUB_REPO_TEAM_ID, - ); + ]; $data_j = json_encode($data); - $opts = array( + $opts = [ 'content' => $data_j, - ); + ]; $res = github_api('/orgs/php/repos?access_token='.urlencode($_SESSION['github']['access_token']), 'POST', $opts); head("github administration"); diff --git a/manage/mirrors.php b/manage/mirrors.php index 1645edd..e9f8480 100644 --- a/manage/mirrors.php +++ b/manage/mirrors.php @@ -5,10 +5,10 @@ include '../include/login.inc'; define('PHP_SELF', hsc($_SERVER['PHP_SELF'])); // This page is for mirror administration -head("mirror administration", array("columns" => 2)); +head("mirror administration", ["columns" => 2]); db_connect(); -$valid_fields = array( +$valid_fields = [ 'hostname', 'mode', 'active', @@ -25,7 +25,7 @@ $valid_fields = array( 'reason', 'original_log', 'load_balanced', -); +]; foreach($valid_fields as $k) { if (isset($_REQUEST[$k])) $$k = $_REQUEST[$k]; @@ -148,12 +148,12 @@ elseif (isset($id)) { // The $id is not valid, so provide common defaults for new mirror else { - $row = array( + $row = [ 'providerurl' => 'http://', 'active' => 1, 'mirrortype' => 1, 'lang' => 'en' - ); + ]; } // Print out mirror data table with or without values @@ -324,7 +324,7 @@ function page_mirror_list($moreinfo = false) global $checktime; // For counting versions and building a statistical analysis - $php_versions = array( + $php_versions = [ '53' => 0, '54' => 0, '55' => 0, @@ -334,7 +334,7 @@ function page_mirror_list($moreinfo = false) '72' => 0, '73' => 0, 'other' => 0, - ); + ]; // Query the whole mirror list and display all mirrors. The query is // similar to the one in the mirror fetch script. We need to get mirror // status data to show proper icons and need to order by country too @@ -354,10 +354,10 @@ function page_mirror_list($moreinfo = false) // Previous country code $prevcc = "n/a"; - $stats = array( + $stats = [ 'mirrors' => mysql_num_rows($res), - 'sqlite_counts' => array('none' => 0, 'sqlite' => 0, 'pdo_sqlite' => 0, 'pdo_sqlite2' => 0, 'sqlite3' => 0), - ); + 'sqlite_counts' => ['none' => 0, 'sqlite' => 0, 'pdo_sqlite' => 0, 'pdo_sqlite2' => 0, 'sqlite3' => 0], + ]; // Go through all mirror sites while ($row = mysql_fetch_array($res)) { @@ -672,7 +672,7 @@ return $statusscreen; function show_mirrortype_options($type = 1) { // There are two mirror types - $types = array(1 => "standard", 2 => "special"); //, 0 => "download"); + $types = [1 => "standard", 2 => "special"]; //, 0 => "download"); // Write out an <option> for all types foreach ($types as $code => $name) { diff --git a/manage/user-notes.php b/manage/user-notes.php index 12ead05..f32c60e 100644 --- a/manage/user-notes.php +++ b/manage/user-notes.php @@ -402,7 +402,7 @@ if (!$action) { $lastweek = !date('w') ? strtotime('midnight -1 week') : strtotime('Last Sunday -1 week'); $lastmonth = strtotime('First Day of last month'); /* Handle stats queries for voting here */ - $stats_sql = $stats = array(); + $stats_sql = $stats = []; $stats_sql['Total'] = "SELECT COUNT(votes.id) AS total FROM votes"; $stats_sql['Total Up'] = "SELECT COUNT(votes.id) AS total FROM votes WHERE votes.vote = 1"; $stats_sql['Total Down'] = "SELECT COUNT(votes.id) AS total FROM votes WHERE votes.vote = 0"; @@ -467,7 +467,7 @@ case 'mass': exit; } $step = (isset($_REQUEST["step"]) ? (int)$_REQUEST["step"] : 0); - $where = array(); + $where = []; if (!empty($_REQUEST["old_sect"])) { $where[] = "sect = '". real_clean($_REQUEST["old_sect"]) ."'"; } @@ -737,7 +737,7 @@ case 'deletevotes': if (empty($_POST['deletevote']) || !is_array($_POST['deletevote'])) { die("No vote ids supplied!"); } - $ids = array(); + $ids = []; foreach ($_POST['deletevote'] as $id) { $ids[] = (int) $id; } @@ -819,22 +819,22 @@ function highlight_php($code, $return = FALSE) // Fix output to use CSS classes and wrap well $highlighted = '<div class="phpcode">' . str_replace( - array( + [ ' ', '<br />', '<font color="', '</font>', "\n ", ' ' - ), - array( + ], + [ ' ', "<br />\n", '<span class="', '</span>', "\n ", ' ' - ), + ], $highlighted ) . '</div>'; @@ -881,9 +881,9 @@ function allow_mass_change($user) { if (in_array( $user, - array( + [ "vrana", "goba", "nlopess", "didou", "bjori", "philip", "bobby", "danbrown", "mgdm", "googleguy", "levim", - ) + ] ) ) { return TRUE; @@ -893,11 +893,11 @@ function allow_mass_change($user) // Return safe to print version of email address function safe_email($mail) { - if (in_array($mail, array("php-gene...@lists.php.net", "u...@example.com"))) { + if (in_array($mail, ["php-gene...@lists.php.net", "u...@example.com"])) { return ''; } elseif (preg_match("!(.+)@(.+)\.(.+)!", $mail)) { - return str_replace(array('@', '.'), array(' at ', ' dot '), $mail); + return str_replace(['@', '.'], [' at ', ' dot '], $mail); } return $mail; } @@ -917,7 +917,7 @@ function wildcard_ip($ip) return false; } } - $end = array(); + $end = []; foreach (array_keys($start, "*", true) as $key) { $start[$key] = "0"; $end[$key] = "255"; @@ -933,5 +933,5 @@ function wildcard_ip($ip) if ($end - $start <= 0) { return false; } - return array($start, $end); + return [$start, $end]; } diff --git a/manage/users.php b/manage/users.php index b5e1ff1..2f8106a 100644 --- a/manage/users.php +++ b/manage/users.php @@ -32,15 +32,15 @@ function csrf_validate(&$mydata, $name) { return true; } -$indesc = array( +$indesc = [ "id" => FILTER_VALIDATE_INT, "rawpasswd" => FILTER_UNSAFE_RAW, "rawpasswd2" => FILTER_UNSAFE_RAW, "svnpasswd" => FILTER_SANITIZE_STRIPPED, - "cvsaccess" => array("filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }), - "enable" => array("filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }), - "spamprotect" => array("filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }), - "greylist" => array("filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }), + "cvsaccess" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], + "enable" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], + "spamprotect" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], + "greylist" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], "verified" => FILTER_VALIDATE_INT, "use_sa" => FILTER_VALIDATE_INT, "email" => FILTER_SANITIZE_EMAIL, @@ -48,10 +48,10 @@ $indesc = array( "sshkey" => FILTER_SANITIZE_SPECIAL_CHARS, "purpose" => FILTER_SANITIZE_SPECIAL_CHARS, "profile_markdown" => FILTER_UNSAFE_RAW, -); +]; -$rawin = filter_input_array(INPUT_POST) ?: array(); -$in = isset($rawin["in"]) ? filter_var_array($rawin["in"], $indesc, false) : array(); +$rawin = filter_input_array(INPUT_POST) ?: []; +$in = isset($rawin["in"]) ? filter_var_array($rawin["in"], $indesc, false) : []; $id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT) ?: 0; $username = filter_input(INPUT_GET, "username", FILTER_SANITIZE_STRIPPED) ?: 0; @@ -61,7 +61,7 @@ db_connect(); # ?username=whatever will look up 'whatever' by email or username if ($username) { - $tmp = filter_input(INPUT_GET, "username", FILTER_CALLBACK, array("options" => "mysql_real_escape_string")) ?: ""; + $tmp = filter_input(INPUT_GET, "username", FILTER_CALLBACK, ["options" => "mysql_real_escape_string"]) ?: ""; $query = "SELECT userid FROM users" . " WHERE username='$tmp' OR email='$tmp'"; $res = db_query($query); @@ -79,7 +79,7 @@ if ($id) { } } -$action = filter_input(INPUT_POST, "action", FILTER_CALLBACK, array("options" => "validateAction")); +$action = filter_input(INPUT_POST, "action", FILTER_CALLBACK, ["options" => "validateAction"]); if ($id && $action) { csrf_validate($_SESSION, $action); if (!is_admin($_SESSION["username"])) { @@ -138,7 +138,7 @@ if ($in) { . " WHERE userid=$id"; if (!empty($in['passwd'])) { // Kill the session data after updates :) - $_SERVER["credentials"] = array(); + $_SERVER["credentials"] = []; db_query($query); } else { db_query($query); @@ -319,8 +319,8 @@ $unapproved = filter_input(INPUT_GET, "unapproved", FILTER_VALIDATE_INT) ?: 0; $begin = filter_input(INPUT_GET, "begin", FILTER_VALIDATE_INT) ?: 0; $max = filter_input(INPUT_GET, "max", FILTER_VALIDATE_INT) ?: 20; $forward = filter_input(INPUT_GET, "forward", FILTER_VALIDATE_INT) ?: 0; -$search = filter_input(INPUT_GET, "search", FILTER_CALLBACK, array("options" => "mysql_real_escape_string")) ?: ""; -$order = filter_input(INPUT_GET, "order", FILTER_CALLBACK, array("options" => "mysql_real_escape_string")) ?: ""; +$search = filter_input(INPUT_GET, "search", FILTER_CALLBACK, ["options" => "mysql_real_escape_string"]) ?: ""; +$order = filter_input(INPUT_GET, "order", FILTER_CALLBACK, ["options" => "mysql_real_escape_string"]) ?: ""; $query = "SELECT DISTINCT SQL_CALC_FOUND_ROWS users.userid,cvsaccess,username,name,email,GROUP_CONCAT(note) note FROM users "; $query .= " LEFT JOIN users_note ON users_note.userid = users.userid "; @@ -354,14 +354,14 @@ $res2 = db_query("SELECT FOUND_ROWS()"); $total = mysql_result($res2,0); -$extra = array( +$extra = [ "search" => $search, "order" => $order, "forward" => $forward, "begin" => $begin, "max" => $max, "unapproved" => $unapproved, -); +]; ?> <h1 class="browse">Browse users<ul> @@ -374,14 +374,14 @@ $extra = array( </thead> <tbody> <tr> - <th><a href="?<?php echo array_to_url($extra,array("unapproved"=>!$unapproved));?>"><?php echo $unapproved ? "&otimes" : "&oplus"; ?>;</a></th> - <th><a href="?<?php echo array_to_url($extra,array("order"=>"username"));?>">username</a></th> - <th><a href="?<?php echo array_to_url($extra,array("order"=>"name"));?>">name</a></th> + <th><a href="?<?php echo array_to_url($extra,["unapproved"=>!$unapproved]);?>"><?php echo $unapproved ? "&otimes" : "&oplus"; ?>;</a></th> + <th><a href="?<?php echo array_to_url($extra,["order"=>"username"]);?>">username</a></th> + <th><a href="?<?php echo array_to_url($extra,["order"=>"name"]);?>">name</a></th> <?php if (!$unapproved) { ?> - <th colspan="2"><a href="?<?php echo array_to_url($extra,array("order"=>"email"));?>">email</a></th> + <th colspan="2"><a href="?<?php echo array_to_url($extra,["order"=>"email"]);?>">email</a></th> <?php } else { ?> - <th><a href="?<?php echo array_to_url($extra,array("order"=>"email"));?>">email</a></th> - <th><a href="?<?php echo array_to_url($extra,array("order"=>"note"));?>">note</a></th> + <th><a href="?<?php echo array_to_url($extra,["order"=>"email"]);?>">email</a></th> + <th><a href="?<?php echo array_to_url($extra,["order"=>"note"]);?>">note</a></th> <?php } ?> <th> </th> </tr> diff --git a/network/status/index.php b/network/status/index.php index 1a7e2f5..a0fffe8 100644 --- a/network/status/index.php +++ b/network/status/index.php @@ -71,10 +71,10 @@ function page_mirror_list($moreinfo = false) // Previous country code $prevcc = "n/a"; - $stats = array( + $stats = [ 'mirrors' => mysql_num_rows($res), - 'sqlite_counts' => array('none' => 0, 'sqlite' => 0, 'pdo_sqlite' => 0, 'pdo_sqlite2' => 0, 'sqlite3' => 0), - ); + 'sqlite_counts' => ['none' => 0, 'sqlite' => 0, 'pdo_sqlite' => 0, 'pdo_sqlite2' => 0, 'sqlite3' => 0], + ]; // Go through all mirror sites while ($row = mysql_fetch_array($res)) { diff --git a/scripts/conference_teaser b/scripts/conference_teaser index ce5758a..38d0932 100644 --- a/scripts/conference_teaser +++ b/scripts/conference_teaser @@ -18,7 +18,7 @@ function pregenerate_conf_teaser($rssfile, $outfile) $sxe->registerXPathNamespace("php", "http://php.net/ns/news"); // Loop over the items and store them in a array - $STORE = array(); + $STORE = []; foreach($sxe->entry as $item) { $url = (string)$item->link["href"]; $subject = (string)$item->category["term"]; diff --git a/scripts/countries.inc b/scripts/countries.inc index 518588b..acce0ef 100644 --- a/scripts/countries.inc +++ b/scripts/countries.inc @@ -1,7 +1,7 @@ <?php /* GeoDNS zone IDs @ EasyDNS */ //"country-code" => "geozone_id", //geozone_name -return array( +return [ "NA East" => 1, //North America East "NA West" => 2, //North America West "Europe" => "3", //Europe @@ -258,4 +258,4 @@ return array( "ZA" => "252", //South Africa "ZM" => "253", //Zambia "ZW" => "254", //Zimbabwe -); +]; diff --git a/scripts/event_listing b/scripts/event_listing index f67caeb..e3a1dbf 100644 --- a/scripts/event_listing +++ b/scripts/event_listing @@ -19,10 +19,10 @@ function pregenerate_events($csvfile, $outfile, $months = 2) // Current month number, current category and categories list $cm = $ccat = 0; - $cats = array('unknown', 'User Group Events', 'Conferences', 'Training'); + $cats = ['unknown', 'User Group Events', 'Conferences', 'Training']; // Event duplication check hash - $seen = array(); + $seen = []; // Start output file with PHP code fwrite( @@ -31,7 +31,7 @@ function pregenerate_events($csvfile, $outfile, $months = 2) "<h4>Upcoming Events <a href=\"/submit-event.php\">[add]</a></h4>\n" ); - $content = ""; $buffer = array(); + $content = ""; $buffer = []; $endts = strtotime("+$months months"); $endm = date("n", $endts); $endy = date("Y", $endts); @@ -60,10 +60,10 @@ function pregenerate_events($csvfile, $outfile, $months = 2) $headline = '<h4 class="eventmonth">' . strftime('%B', mktime(12, 0, 0, $cm, $d, $y)) . "</h4>\n"; - $buffer[$headline] = array(); + $buffer[$headline] = []; // We have not seen any events in this month - $seen = array(); + $seen = []; // New category header needed $ccat = 0; @@ -102,12 +102,12 @@ function pregenerate_events($csvfile, $outfile, $months = 2) $buffer[$headline][$ccat] = $content; // Organize the output - $order = array( + $order = [ 2, // Conferences 1, // User Group Events 3, // Training 0, // Unkown - ); + ]; foreach($buffer as $headline => $categories) { // Prevent empty listing diff --git a/scripts/ip-to-country b/scripts/ip-to-country index 85b9d16..5388690 100644 --- a/scripts/ip-to-country +++ b/scripts/ip-to-country @@ -111,7 +111,7 @@ function create_ip_to_country_index($ipdb, $ipidx, $indexby) $lastidx = $recnum = 0; // We store the index in a PHP array temporarily - $idx_list = array($indexby, "0,0"); + $idx_list = [$indexby, "0,0"]; // Open database for reading $ipdbf = fopen($ipdb, "r"); diff --git a/scripts/mirror-summary b/scripts/mirror-summary index c59be66..b647f9a 100755 --- a/scripts/mirror-summary +++ b/scripts/mirror-summary @@ -24,7 +24,7 @@ function email($address, $subject, $content) { set_time_limit (0); // Empty arrays by default -$inactives = $disabled = $lines = array(); +$inactives = $disabled = $lines = []; // Try to connect to the database and select phpmasterdb database mysql_connect("localhost","nobody","") or die("unable to connect to database"); diff --git a/scripts/mirror-test b/scripts/mirror-test index 5069839..a094e6e 100755 --- a/scripts/mirror-test +++ b/scripts/mirror-test @@ -63,7 +63,7 @@ EOF; email($row["maintainer"], $subject, $content); } function MIRRORINFO($row, $content) { - $RETURN = array(); + $RETURN = []; /* Parse our mirror configuration from /mirror-info */ $info = explode("|", trim($content)); @@ -147,24 +147,24 @@ function bfetch($url, $ctx, &$headers) { if ($content) { $headers = $http_response_header; } else { - $headers = array(); + $headers = []; } return $content; } -function fetch($host, $filename, $ashostname = NULL, &$headers = array()) { - $opts = array( +function fetch($host, $filename, $ashostname = NULL, &$headers = []) { + $opts = [ "user_agent" => "PHP.net Mirror Site check", "max_redirects" => 0, "timeout" => 15, "ignore_errors" => "1", - "header" => array( + "header" => [ "Host: " . ($ashostname ?: $host), "Connection: close", - ), - ); - $ctx = stream_context_create(array("http" => $opts)); + ], + ]; + $ctx = stream_context_create(["http" => $opts]); $url = "http://$host$filename"; @@ -263,10 +263,10 @@ WHERE id = :id "; $stmt = $pdo->prepare($query); - $params = array( + $params = [ ":reason" => $errmsg, ":id" => $mirror["id"], - ); + ]; /* Mail the maintainer right away if it wasn't disabled already */ if (!$mirror["ocmt"]) { @@ -296,7 +296,7 @@ WHERE id = :id "; $stmt = $pdo->prepare($query); - $params = array( + $params = [ ":lastupdated" => (int)$info["mirrorupdated"], ":has_search" => (int)$info["has_search"], ":has_stats" => (int)$info["has_stats"], @@ -307,7 +307,7 @@ WHERE id = :id ":local_hostname" => $info["local_hostname"], ":ipv4_addr" => $info["ipv4_addr"], ":id" => $mirror["id"], - ); + ]; $stmt->execute($params); } @@ -319,20 +319,20 @@ function GEOLS() { return json_decode($json, true); } - return array(); + return []; } function GEORM($id) { sleep(1); - $opts = array( + $opts = [ "user_agent" => "PHP.net Mirror Site check", "timeout" => 15, "ignore_errors" => "1", "method" => "DELETE", - ); + ]; - $ctx = stream_context_create(array("http" => $opts)); + $ctx = stream_context_create(["http" => $opts]); $retval = file_get_contents(sprintf(GEORM, $id), false, $ctx); p($retval); @@ -348,7 +348,7 @@ sleep(1); return; } - $data = array( + $data = [ "domain" => ZONE, "host" => "@", "ttl" => 0, @@ -356,16 +356,16 @@ sleep(1); "prio" => 0, "type" => "CNAME", "rdata" => $cname, - ); - $opts = array( + ]; + $opts = [ "user_agent" => "PHP.net Mirror Site check", "timeout" => 15, "ignore_errors" => "1", "method" => "PUT", "header" => "Content-type: text/x-javascript", "content" => $t = json_encode($data), - ); - $ctx = stream_context_create(array("http" => $opts)); + ]; + $ctx = stream_context_create(["http" => $opts]); $retval = file_get_contents(GEOADD, false, $ctx); p("Adding $cname => " . GEOADD . ": $t\n"); p($retval); @@ -379,7 +379,7 @@ function geoDNS($HOSTS) { $HOSTS["php-web2.php.net."] = "North America"; /* Remove disabled hosts */ - $GEO = array(); + $GEO = []; foreach($GEOLIST["data"] as $k => $entry) { /* Only deal with records we have declared as GEO */ if (empty($entry["geozone_id"])) { @@ -431,7 +431,7 @@ $stmt = $pdo->prepare($query); $stmt->execute(); -$HOSTS = array(); +$HOSTS = []; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $timeoutfail = 0; p($row["hostname"]); diff --git a/scripts/pregen_flickr b/scripts/pregen_flickr index 8a74f13..01ab6dd 100644 --- a/scripts/pregen_flickr +++ b/scripts/pregen_flickr @@ -32,7 +32,7 @@ function pregen_flickr($apiKey, $outputPath, $limit = 100) // construct flickr api call // extras is set to 'url_sq' to get the href of the square thumbnail. // see http://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html - $url = FLICKR_REST_URL . '?' . http_build_query(array( + $url = FLICKR_REST_URL . '?' . http_build_query([ 'api_key' => $apiKey, 'per_page' => $limit, 'extras' => 'url_sq', @@ -40,7 +40,7 @@ function pregen_flickr($apiKey, $outputPath, $limit = 100) 'method' => FLICKR_REST_METHOD, 'format' => FLICKR_REST_FORMAT, 'nojsoncallback' => 1 - )); + ]); // fetch photo info $response = file_get_contents($url); @@ -53,7 +53,7 @@ function pregen_flickr($apiKey, $outputPath, $limit = 100) } // fetch all of the photos - $fresh = array(); + $fresh = []; $photos = $decoded['photos']['photo']; foreach ($photos as $key => &$photo) { diff --git a/scripts/pregen_news b/scripts/pregen_news index 3369e81..b0728ec 100644 --- a/scripts/pregen_news +++ b/scripts/pregen_news @@ -24,7 +24,7 @@ function pregen_atom($feed, $feedDest, $newsDest) { return; } - $timestamps = array(); + $timestamps = []; foreach ($dom->getElementsByTagName("updated") as $node) { $timestamps[] = strtotime($node->nodeValue, $_SERVER["REQUEST_TIME"]); } @@ -44,7 +44,7 @@ function format_atom_feed($filename) { $r = new XMLReader; $r->XML($filename, "UTF-8"); - $entries = array(); + $entries = []; while($r->read()) { if ($r->nodeType === XMLReader::ELEMENT && $r->name === "entry") { $entries[] = $current = format_atom_entry($r); @@ -56,7 +56,7 @@ function format_atom_feed($filename) { // {{{ Parse the entry into array(element => value) function format_atom_entry($r) { - $retval = array(); + $retval = []; while($r->read()) { if ($r->nodeType !== XMLReader::ELEMENT) { @@ -153,7 +153,7 @@ function format_atom_entry($r) { // {{{ Return all attrs for current element as an array(attr-name => attr-value) function format_attributes($r) { - $retval = array(); + $retval = []; if (!$r->hasAttributes) { return $retval; @@ -180,7 +180,7 @@ function get_link($data, $rel = "alternate") { function legacy_rss($atom, $newsDest, $confDest) { $sxe = new SimpleXMLElement($atom, $GLOBALS["XML_OPTIONS"], true); $CONF = $CONF_ITEMS = $NEWS = $NEWS_ITEMS= ""; - $links = array(); + $links = []; foreach($sxe->entry as $entry) { $item = ""; diff --git a/scripts/rss_parser b/scripts/rss_parser index 34b5b3f..3f572d8 100644 --- a/scripts/rss_parser +++ b/scripts/rss_parser @@ -75,10 +75,10 @@ function ParseNews ($index_page = "", $aboutLink) { #DEBUG# print "<pre>"; print_r($lines); print "</pre>"; // Define month conversion hash - $mos = array( + $mos = [ "Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12 - ); + ]; // We have not started to parse the // news and we have no headlines right here
-- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php