com web/master: Remove mirrors related code (in rather non-risky, not so intrusive way): entry/user-notes-vote.php fetch/mirrordns.php
fetch/mirrors.php include/functions.inc include/languages.inc manage/mirrors.php network/status/api.php network/status/index.php
network/status/style.css scripts/conference_teaser scripts/ event_listing scripts/mirror-summary scripts/mirror-test scripts/update-backend

From: Date: Sat, 18 Apr 2020 21:21:37 +0000
Subject: com web/master: Remove mirrors related code (in rather non-risky, not so intrusive way): entry/user-notes-vote.php fetch/mirrordns.php
fetch/mirrors.php include/functions.inc include/languages.inc manage/mirrors.php network/status/api.php network/status/index.php
network/status/style.css scripts/conference_teaser scripts/ event_listing scripts/mirror-summary scripts/mirror-test scripts/update-backend
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-28590@lists.php.net to get a copy of this message
Commit: 54328e85c23e296dfd79f62a0d032fd1586c9c83 Author: Sobak <msobaczewski@gmail.com> Sat, 18 Apr 2020 23:21:37 +0200 Parents: 182dbad7294df74bba110475bcf871a52fb71601 Branches: master Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=54328e85c23e296dfd79f62a0d032fd1586c9c83 Log: Remove mirrors related code (in rather non-risky, not so intrusive way) I tried to keep backwards compatibility where it seemed to make sense (e.g. the API endpoint) or the script that might still be called somehow. Hopefully I didn't break anything but if I did feel free to point it at me and sorry in advance :/ Changed paths: M entry/user-notes-vote.php M fetch/mirrordns.php D fetch/mirrors.php M include/functions.inc D include/languages.inc D manage/mirrors.php M network/status/api.php M network/status/index.php M network/status/style.css M scripts/conference_teaser M scripts/event_listing D scripts/mirror-summary D scripts/mirror-test M scripts/update-backend

diff --git a/entry/user-notes-vote.php b/entry/user-notes-vote.php index 8037d26..609c24e 100644 --- a/entry/user-notes-vote.php +++ b/entry/user-notes-vote.php @@ -1,14 +1,14 @@ <?php /* This script acts as the backend communication API for the user notes vote feature. - Requests come in here from the mirrors to update the database with new votes. + Requests come in here from the php.net to update the database with new votes. master.php.net should respond with a JSON object (with one required property [status] and two optional properties [votes] and [message]). The JSON object [status] property contains a status returned by the server for that request. - It's value may be either a boolean true or false. If the status is true the mirror will know the vote went through successfully. - The optional [votes] property may then be supplied to update the mirror with the new value of the votes for that note. - If the status is false the mirror will know the request for voting failed and an optional [message] property may be - set to supply the mirror with a message string, explaining why the request failed. + It's value may be either a boolean true or false. If the status is true the php.net will know the vote went through successfully. + The optional [votes] property may then be supplied to update the php.net with the new value of the votes for that note. + If the status is false the php.net will know the request for voting failed and an optional [message] property may be + set to supply the php.net with a message string, explaining why the request failed. Example Success: diff --git a/fetch/mirrordns.php b/fetch/mirrordns.php index 484d78d..dd28e28 100644 --- a/fetch/mirrordns.php +++ b/fetch/mirrordns.php @@ -1,52 +1,3 @@ <?php -/* - The DNS table for mirror sites gets updated using the output of - this script. If there is no output, or there is any line on the - output which does not start with + or C (probably an error - occured), the DNS database is not updated. The DNS list is - fetched in approximately five minute intervals. -*/ - -// A token is required, since this should only get -// accessed from an authorized requester -if (!isset($_REQUEST['token']) || md5($_REQUEST['token']) != "19a3ec370affe2d899755f005e5cd90e") { - die("token not correct."); -} - -// Connect to local mysql database -if (@mysql_connect("localhost","nobody","")) { - - // Select phpmasterdb database - if (@mysql_select_db("phpmasterdb")) { - - // Select mirrors list ordered by hostname - $res = @mysql_query("SELECT * FROM mirrors ORDER BY hostname"); - - // If there is a mysql result - if ($res) { - - // Go through all mirrors - while ($row = @mysql_fetch_array($res)) { - - // If the mirror is not a standard one, or - // it's name is not a standard mirror name - // under php.net => skip it - if ($row['mirrortype'] != 1 || !preg_match("!^\\w{2}\\d?.php.net$!", $row['hostname'])) { - continue; - } - - // The CNAME is an IP - if (preg_match("!^\\d+\\.\\d+\\.\\d+\\.\\d+$!", $row['cname'])) { - $firstChar = '+'; - } - - // The CNAME is not an IP - else { $firstChar = 'C'; } - - // Print out DNS update code - echo $firstChar . $row['hostname'] . ':' . $row['cname'] . "\n"; - } - } - } -} +// Replaced with no-op just in case something still calls that script diff --git a/fetch/mirrors.php b/fetch/mirrors.php deleted file mode 100644 index 0b056cc..0000000 --- a/fetch/mirrors.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php - -// Current date in GMT -$date = gmdate("Y/m/d H:i:s"); - -// Info on the $MIRRORS array structure and some constants -$structinfo = " -/* - Structure of an element of the \$MIRRORS array: - - 0 Country code - 1 Provider name - 2 Local stats flag (TRUE / FALSE) - 3 Provider URL - 4 Mirror type [see type constants] - 5 SQLite availability [was originally: local search engine flag] (TRUE / FALSE) - 6 Default language code - 7 Status [see status constants] - - List generated: $date GMT -*/ - -// Mirror type constants -define('MIRROR_DOWNLOAD', 0); -define('MIRROR_STANDARD', 1); -define('MIRROR_SPECIAL', 2); -define('MIRROR_VIRTUAL', 3); - -// Mirror status constants -define('MIRROR_OK', 0); -define('MIRROR_NOTACTIVE', 1); -define('MIRROR_OUTDATED', 2); -define('MIRROR_DOESNOTWORK', 3); -"; - -// A token is required, since this should only get accessed from rsync.php.net -if (!isset($_REQUEST['token']) || md5($_REQUEST['token']) != "19a3ec370affe2d899755f005e5cd90e") { - die("token not correct."); -} - -// Connect to local mysql database -if (@mysql_connect("localhost","nobody","")) { - - // Select phpmasterdb database - if (@mysql_select_db("phpmasterdb")) { - - // Select mirrors list with some on-the-fly counted columns - $res = @mysql_query( - "SELECT mirrors.*, country.name AS cname " . - "FROM mirrors LEFT JOIN country ON mirrors.cc = country.id " . - "WHERE ocmt = '' AND active = 1 " . - "ORDER BY country.name,hostname" - ); - - // If there is a mysql result - if ($res) { - - // Start PHP script output - echo "<?php$structinfo\$MIRRORS = array(\n"; - - // Go through all result rows - while ($row = @mysql_fetch_array($res)) { - - // Prepend http:// to hostname - $row["hostname"] = "http://$row[hostname]/"; - - // Rewrite the mirrortype to use defined constants - switch (intval($row['mirrortype'])) { - case 0 : $row['mirrortype'] = 'MIRROR_DOWNLOAD'; break; - case 1 : $row['mirrortype'] = 'MIRROR_STANDARD'; break; - case 2 : $row['mirrortype'] = 'MIRROR_SPECIAL'; break; - } - - // Rewrirte has_search and has_stats to be booleans - $row["has_search"] = ($row["has_search"] ? 'TRUE' : 'FALSE'); - $row["has_stats"] = ($row["has_stats"] ? 'TRUE' : 'FALSE'); - - // Presumably the mirror is all right - $status = 'MIRROR_OK'; - - // Provide status information for mirrors - // computed from current mirror details - if (!$row["active"]) { $status = 'MIRROR_NOTACTIVE'; } - elseif ($row["ocmt"]) { $status = 'MIRROR_DOESNOTWORK'; } - - // Print out the array element for this mirror - echo " \"$row[hostname]\" => array(\n" . - " \"$row[cc]\", \"$row[providername]\", $row[has_stats],\n" . - " \"$row[providerurl]\", $row[mirrortype], $row[has_search],\n" . - " \"$row[lang]\", $status),\n"; - } - echo ");\n"; - } - } -} diff --git a/include/functions.inc b/include/functions.inc index 124968e..9694877 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -24,7 +24,6 @@ function head($title="", $config = []) { $TITLE = $title ?: "master"; $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"], @@ -68,12 +67,6 @@ function foot($secondscreen = null) { "//people.php.net/js/search.js" ); } - if (strstr($_SERVER["SCRIPT_FILENAME"], "mirror.php")) { - array_push( - $JS, - "js/curvycorners.js" - ); - } ?> </section> @@ -258,22 +251,6 @@ function unmangle($var_name,$filter_id=FILTER_UNSAFE_RAW) { return real_clean(filter_var($var_name,$filter_id)); } -/** - * If $ext is defined, return TRUE if available, FALSE if not. - * If $ext is not defined, return a string of all available extensions. - */ -function get_extension_info($mirror_hostname,$ext=null) { - $exts = db_get_one("SELECT ext_avail FROM mirrors WHERE hostname='".real_clean($mirror_hostname)."'"); - if (!is_null($ext)) { - if (preg_match('/\b'.$ext.'\b/Ui',$exts)) { - return true; - } else { - return false; - } - } - return $exts; -} - // We use markdown for people profiles include_once dirname(__FILE__) . '/../vendor/michelf/php-markdown-extra/markdown.php'; diff --git a/include/languages.inc b/include/languages.inc deleted file mode 100644 index 37cff28..0000000 --- a/include/languages.inc +++ /dev/null @@ -1,70 +0,0 @@ -<?php // -*- C++ -*- - -// $Id$ - -/* - This is a list of all manual languages hosted - on a full PHP.net mirror site - - Some codes, like "kr", "tw" and "hk" are not in - conformance with the official language code standard! - - http://www.unicode.org/unicode/onlinedat/languages.html -*/ -$LANGUAGES = [ - 'en' => 'English', - 'ar' => 'Arabic', - 'pt_BR' => 'Brazilian Portuguese', - 'zh' => 'Chinese (Simplified)', - 'hk' => 'Chinese (Hong Kong Cantonese)', - 'tw' => 'Chinese (Traditional)', - 'cs' => 'Czech', - 'nl' => 'Dutch', - 'fi' => 'Finnish', - 'fr' => 'French', - 'de' => 'German', - 'el' => 'Greek', - 'he' => 'Hebrew', - 'hu' => 'Hungarian', - 'it' => 'Italian', - 'ja' => 'Japanese', - 'kr' => 'Korean', - 'pl' => 'Polish', - 'ro' => 'Romanian', - 'ru' => 'Russian', - 'sk' => 'Slovak', - 'sl' => 'Slovenian', - 'es' => 'Spanish', - 'sv' => 'Swedish', - 'tr' => 'Turkish', -]; - -$INACTIVE_ONLINE_LANGUAGES = [ - 'el' => 'Greek', - 'ar' => 'Arabic', -]; - -// Convert between language codes back and forth -// [We use non standard languages codes and so conversion -// is needed when communicating with the outside world] -function language_convert($langcode, $to_phpweb_format = TRUE) -{ - if ($to_phpweb_format) { - switch ($langcode) { - case 'zh_cn': return 'zh'; - case 'zh_hk': return 'hk'; - case 'zh_tw': return 'tw'; - case 'ko' : return 'kr'; - default: return $langcode; - } - } - else { - switch ($langcode) { - case 'cn': return 'zh_cn'; - case 'hk': return 'zh_hk'; - case 'tw': return 'zh_tw'; - case 'kr': return 'ko'; - default: return $langcode; - } - } -} diff --git a/manage/mirrors.php b/manage/mirrors.php deleted file mode 100644 index e9f8480..0000000 --- a/manage/mirrors.php +++ /dev/null @@ -1,697 +0,0 @@ -<?php // vim: et -// Force login and include common functions -include '../include/login.inc'; - -define('PHP_SELF', hsc($_SERVER['PHP_SELF'])); - -// This page is for mirror administration -head("mirror administration", ["columns" => 2]); -db_connect(); - -$valid_fields = [ - 'hostname', - 'mode', - 'active', - 'mirrortype', - 'cname', - 'maintainer', - 'providername', - 'providerurl', - 'cc', - 'lang', - 'has_stats', - 'acmt_prev', - 'acmt', - 'reason', - 'original_log', - 'load_balanced', -]; - -foreach($valid_fields as $k) { - if (isset($_REQUEST[$k])) $$k = $_REQUEST[$k]; -} - - -// Get boolean values from form -$active = isset($active) ? 1 : 0; -$has_stats = isset($has_stats) ? 1 : 0; -$moreinfo = empty($_GET['mi']) ? 0 : 1; - -$mirrortype = isset($mirrortype) ? (int)$mirrortype : 0; - -// Select last mirror check time from table -$lct = db_query("SELECT UNIX_TIMESTAMP(lastchecked) FROM mirrors ORDER BY lastchecked DESC LIMIT 1"); -list($checktime) = mysql_fetch_row($lct); - -if (isset($_REQUEST['id'])) $id = (int)$_REQUEST['id']; - - -// We have something to update in the database -if (isset($id) && isset($hostname)) { - - // Allow everyone to disable a mirror, but only elite few to make other changes - if (is_mirror_site_admin($_SESSION["username"]) || ($mode == "update" && !$active)) { - // No query need to be made - $query = FALSE; - - // What to update? - switch($mode) { - - // Perform a full data update on a mirror - case "update": - $mod_by_time = '<b>'.strtoupper(date('d-M-Y H:i:s T')).'</b> ['.$_SESSION["username"].'] Mirror updated'; - $query = "UPDATE mirrors SET hostname='".unmangle($hostname)."', active=$active, " . - "mirrortype=$mirrortype, cname='".unmangle($cname)."', maintainer='".unmangle($maintainer)."', " . - "providername='".unmangle($providername)."', providerurl='".unmangle($providerurl)."', " . - "cc='".unmangle($cc)."', lang='".unmangle($lang)."', has_stats=$has_stats, " . - "load_balanced='".unmangle($load_balanced)."', lastedited=NOW(), " . - "acmt='".unmangle($acmt_prev)."==\n" . $mod_by_time.(isset($acmt) && !empty($acmt) ? ": ".unmangle($acmt) : ".")."'" . - "WHERE id = $id"; - $msg = "$hostname updated"; - break; - - // Delete a mirror site (specified by the ID) - case "delete": - $query = "DELETE FROM mirrors WHERE id = $id"; - $msg = "$hostname deleted"; - break; - - // Insert a new mirror site into the database - case "insert": - $query = "INSERT INTO mirrors (hostname, active, mirrortype, " . - "cname, maintainer, providername, providerurl, cc, " . - "lang, has_stats, created, lastedited, acmt, load_balanced) " . - "VALUES ('".unmangle($hostname)."', $active, $mirrortype, '".unmangle($cname)."', " . - "'".unmangle($maintainer)."', '".unmangle($providername)."', '$providerurl', '".unmangle($cc)."', " . - "'".unmangle($lang)."', $has_stats, NOW(), NOW(), '".unmangle($acmt)."', '".unmangle($load_balanced)."')"; - $msg = "$hostname added"; - break; - } - - // If there is any query to execute - if ($query) { - - // Try to execute query, and provide information if successfull - if (db_query($query)) { - echo '<h2>'.$msg.'</h2>'; - } - - // In case a mirror is deleted, mail a notice to the - // php-mirrors list, so any malicious deletions can be tracked - if ($mode == "delete" || $mode == "insert") { - $body = "The mirrors list was updated, and $hostname was " . - ($mode == "delete" ? "deleted." : "added."); - - // Also include the reason if it is provided - if (!empty($reason)) { - $body .= "\n\nReason:\n".wordwrap(unmangle($reason),70); - $body .= PHP_EOL.'=='.PHP_EOL.'Original log follows.'.PHP_EOL.'===='.PHP_EOL; - $body .= wordwrap(unmangle($original_log),70); - } - mail( - "network-status@lists.php.net", - "[mirrors] Update by " . $_SESSION["username"], - $body, - "From: mirrors@php.net", - "-fnoreply@php.net" - ); - - // If a mirror has been modified, send information safe for public eyes to the - // list: active status, hostname. - } elseif ($mode == 'update') { - $body = 'The mirror '.$hostname.' has been modified by '.$_SESSION["username"].'. It\'s status is '; - $body .= isset($active) && $active == true ? 'active.' : 'inactive, and DNS will be disabled.'; - $body .= isset($acmt) && !empty($acmt) ? ' Notes were added to the mirror\'s file.' : ''; - mail('network-status@lists.php.net','[mirrors] Status change for '.$hostname,$body,"From: mirrors@php.net\r\n", "-fnoreply@php.net"); - } - } - } else { - warn("You're not allowed to take actions on mirrors."); - } -} - -// An $id is specified, but no $hostname, show editform -elseif (isset($id)) { - - // The $id is not zero, so get mirror information - if (intval($id) !== 0) { - $res = db_query( - "SELECT *, " . - "UNIX_TIMESTAMP(created) AS ucreated, " . - "UNIX_TIMESTAMP(lastedited) AS ulastedited, " . - "UNIX_TIMESTAMP(lastupdated) AS ulastupdated, " . - "UNIX_TIMESTAMP(lastchecked) AS ulastchecked " . - "FROM mirrors WHERE id = $id" - ); - $row = mysql_fetch_assoc($res); - } - - // The $id is not valid, so provide common defaults for new mirror - else { - $row = [ - 'providerurl' => 'http://', - 'active' => 1, - 'mirrortype' => 1, - 'lang' => 'en' - ]; - } - - // Print out mirror data table with or without values -?> -<form method="POST" action="<?php echo PHP_SELF; ?>"> - <input type="hidden" name="id" value="<?php echo isset($row['id']) ? $row['id'] : ''; ?>" /> - <input type="hidden" name="mode" value="<?php echo empty($id) ? 'insert' : 'update'; ?>" /> - - <table> - <tr> - <th align="right">Hostname (without http://):</th> - <td><input type="text" name="hostname" value="<?php echo empty($row['hostname']) ? '':hscr($row['hostname']); ?>" size="40" maxlength="40" /></td> - </tr> - <tr> - <th align="right">Active?</th> - <td><input type="checkbox" name="active"<?php echo empty($row['active']) ? '' : " checked"; ?> /></td> - </tr> - <tr> - <?php if (!empty($row['hostname'])) { ?> - <th align="right">Round-Robin?</th> - <td> - <input type="checkbox" name="load_balanced" value="<?php echo substr($row['hostname'],0,2); ?>" <?php echo preg_match('/\w+/',$row['load_balanced']) ? ' checked="checked"' : ''; ?>/> - </td> - <?php } else { ?> - <th align="right">Round-Robin Country Code</th> - <td> - <input type="text" name="load_balanced" size="2" maxlength="4"/><br/> - <small>Should be the first two letters from the hostname entered above.</small> - </td> - <?php } ?> - </tr> - <tr> - <th align="right">Type:</th> - <td><select name="mirrortype"><?php show_mirrortype_options($row['mirrortype']); ?></select></td> - </tr> - <tr> - <th align="right">CNAME (without http://):</th> - <td><input type="text" name="cname" value="<?php echo empty($row['cname']) ? '' : hscr($row['cname']); ?>" size="40" maxlength="80" /></td> - </tr> - <tr> - <th align="right">Maintainer's Name and Email:</th> - <td><input type="text" name="maintainer" value="<?php echo empty($row['maintainer']) ? '' : hscr($row['maintainer']); ?>" size="40" maxlength="255" /></td> - </tr> - <tr> - <th align="right">Provider's Name:</th> - <td><input type="text" name="providername" value="<?php echo empty($row['providername']) ? '' : hscr($row['providername']); ?>" size="40" maxlength="255" /></td> - </tr> - <tr> - <th align="right">Provider URL (with http://):</th> - <td><input type="text" name="providerurl" value="<?php echo empty($row['providerurl']) ? '' : hscr($row['providerurl']); ?>" size="40" maxlength="255" /></td> - </tr> - <tr> - <th align="right">Country:</th> - <td><select name="cc"><?php show_country_options($row['cc']); ?></select></td> - </tr> - <tr> - <th align="right"> - Administrative Comments:<br/> - <small>NOTE: <i>Username and timestamp will be automatically recorded.</i></small><br/> - <i>To italicize, enclose text in ""double-double quotes"".</i><small> - </th> - <td><textarea wrap="virtual" cols="40" rows="12" name="acmt"></textarea></td> - </tr> - <tr> - <td colspan="2" align="center"><input type="submit" value="<?php echo empty($id) ? "Add" : "Change"; ?>" /> - </tr> - </table> - - <input type="hidden" name="acmt_prev" value="<?php echo empty($row['acmt']) ? '' : hscr($row['acmt']); ?>"/> - <b>Administration Comment History:</b><br/> - <?php - if (($_acmt = preg_split('/==\r?\n/',$row['acmt'])) != 0) { - foreach ($_acmt as $_c) { - $_c = preg_replace('/""(.*)""/Us','<i>$1</i>',$_c); - echo '<small>'.$_c.'</small><br/>'.PHP_EOL.'<hr/><br/>'.PHP_EOL; - } - } else { - echo 'N/A'; - } - ?> -<?php - -if (intval($id) !== 0) { - include __DIR__ ."/../include/languages.inc"; -?> - <table> - <tr> - <th colspan="2"> - <?php - if (!$row['active'] || $row['ocmt']) { - echo '<p class="error">This mirror is automatically disabled'; - $row['ocmt'] = trim($row['ocmt']); - if (!empty($row['ocmt'])) { - echo '<br />Last error: ' . $row['ocmt']; - } - echo '</p>'; - } else { echo "&nbsp;"; } - ?> - </th> - </tr> - <tr> - <th align="right">Mirror added:</th> - <td><?php echo get_print_date($row['ucreated']); ?></td> - </tr> - <tr> - <th align="right">Last edit time:</th> - <td><?php echo get_print_date($row['ulastedited']); ?></td> - </tr> - <tr> - <th align="right">Last mirror check time:</th> - <td><?php echo get_print_date($row['ulastchecked']); ?></td> - </tr> - <tr> - <th align="right">Last update time:</th> - <td><?php echo get_print_date($row['ulastupdated']); ?></td> - </tr> - <tr> - <th align="right">PHP version used:</th> - <td><?php print_version($row['phpversion']); ?></td> - </tr> - <tr> - <th align="right">SQLite available:</th> - <td><?php echo implode(' : ', decipher_available_sqlites($row['has_search'])); ?></td> - </tr> - <tr> - <th align="right">Available extensions:</th> - <td><?php echo str_replace(',',' ',get_extension_info($row['hostname'])); ?></td> - </tr> - <tr> - <th align="right">Local Stats:</th> - <td><?php echo ($row['has_stats'] ? "" : "<strong>not</strong> "); ?>supported</td> - </tr> - <tr> - <th align="right">Default Language:</th> - <td><?php echo $LANGUAGES[$row['lang']] . " [" . $row['lang'] . "]"; ?></td> - </tr> - </table> -<?php } else { echo "&nbsp;"; } ?> -</form> -<hr /> - -<?php if ($row['mirrortype'] == 1 && $id !== 0) { // only allow standard mirror deletions ?> -<form method="POST" action="<?php echo PHP_SELF; ?>"> - <input type="hidden" name="id" value="<?php echo $row['id']; ?>" /> - <input type="hidden" name="hostname" value="<?php echo $row['hostname']; ?>" /> - Delete mirror for this reason:<br /> - <small>Administrative comments will automatically append.</small><br/> - <textarea name="reason" wrap="virtual" cols="40" rows="12"></textarea> - <input type="hidden" name="original_log" value="<?php echo empty($row['acmt']) ? '' : hscr($row['acmt']); ?>"/> - <input type="submit" name="mode" value="delete"/> -</form> -<?php } - - // Form printed, exit script - foot(); - exit(); -} - -$secondscreen = page_mirror_list($moreinfo); - -foot($secondscreen); - -// ============================================================================= - -// Mirror listing page function -function page_mirror_list($moreinfo = false) -{ - global $checktime; - - // For counting versions and building a statistical analysis - $php_versions = [ - '53' => 0, - '54' => 0, - '55' => 0, - '56' => 0, - '70' => 0, - '71' => 0, - '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 - $res = db_query(" - SELECT mirrors.*, - UNIX_TIMESTAMP(lastupdated) AS ulastupdated, - UNIX_TIMESTAMP(lastchecked) AS ulastchecked, - country.name as countryname - FROM mirrors LEFT JOIN country ON mirrors.cc = country.id - ORDER BY country.name, hostname" - ); - - // Start table - $summary = ' - <table id="mirrors">'; - - // Previous country code - $prevcc = "n/a"; - - $stats = [ - 'mirrors' => mysql_num_rows($res), - '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)) { - - // Collect statistical information - @$stats['phpversion'][$row['phpversion']]++; - @$stats['phpversion_counts'][$row['phpversion'][0]]++; - - // Print out a country header, if a new country is found - if ($prevcc != $row['cc']) { - $summary .= '<tr><th colspan="7"><h3>' . $row['countryname'] . "</h3></th></tr>\n"; - } - $prevcc = $row['cc']; - - // No info on why the mirror is disabled - $errorinfo = ""; - - // Active mirror site - if ($row['active']) { - // Not up to date or not current - if ($row['ocmt']) { - if(empty($stats['autodisabled'])) $stats['autodisabled'] = 1; - else $stats['autodisabled']++; - $siteimage = "error"; - $errorinfo = $row['ocmt'] . " (problem since: " . - get_print_date($row['ulastchecked']) . ")"; - } - } - // Not active mirror site (maybe deactivated by the - // mirror check bot, because of a /manual alias, - // or deactivated by some admin) - else { - if (!empty($row['ocmt'])) { $errorinfo = $row['ocmt']; } - elseif (!empty($row['acmt'])) { $errorinfo = $row['acmt']; } - $stats['disabled']++; - } - - $sqlites = decipher_available_sqlites($row['has_search']); - if ($sqlites) { - foreach ($sqlites as $sqlite_type) { - $stats['sqlite_counts'][$sqlite_type]++; - } - } else { - $stats['sqlite_counts']['none']++; - } - - // Stats information cell - $statscell = '&nbsp;'; - if ($row['has_stats'] == "1") { - $statscell = "<a href=\"http://$row[hostname]/stats/\" target=\"_blank\">" . - "<img src=\"/images/mirror_stats.png\" /></a>"; - if(empty($stats['has_stats'])) $stats['has_stats'] = 1; - else $stats['has_stats']++; - } - - // Maintainer contact information cell - $emailcell = '&nbsp;'; - $maintainer = trim($row['maintainer']); - if ($row['maintainer']) { - if (preg_match("!<(.+)>!", $maintainer, $found)) { - $addr = $found[1]; - $name = str_replace("<$addr>", "", $maintainer); - $emailcell = '<a href="mailto:' . $addr . '?subject=' . $row['hostname'] . - '&amp;cc=php-mirrors@lists.php.net">' . $name . ' <img src="/images/mirror_mail.png" /></a>'; - } - } - - // Mirror status information - $summary .= "<tr>\n"; - - // Print out mirror site link - $summary .= '<td><a href="http://' . $row['hostname'] . '/" target="_blank">' . - $row['hostname'] . '</a>'.PHP_EOL . - ' <a href="http://'.$row['hostname'].'/mirror-info" target="_blank"></a><br /></td>' . "\n"; - - // Print out mirror provider information - $summary .= '<td><a href="' . $row['providerurl'] . '">' . - $row['providername'] . '</a><br /></td>' . "\n"; - - // Print out maintainer email cell - $summary .= '<td>' . $emailcell . '</td>' . "\n"; - - // Print out version information for this mirror - $summary .= '<td>' . $row['phpversion']. '</td>' . "\n"; - - // Increment the appropriate version for our statistical overview - if (preg_match('/^5\.3/',$row['phpversion'])) { - $php_versions['53']++; - } elseif (preg_match('/^5.4/',$row['phpversion'])) { - $php_versions['54']++; - } elseif (preg_match('/^5.5/',$row['phpversion'])) { - $php_versions['55']++; - } elseif (preg_match('/^5.6/',$row['phpversion'])) { - $php_versions['56']++; - } elseif (preg_match('/^7.0/',$row['phpversion'])) { - $php_versions['70']++; - } elseif (preg_match('/^7.1/',$row['phpversion'])) { - $php_versions['71']++; - } elseif (preg_match('/^7.2/',$row['phpversion'])) { - $php_versions['72']++; - } elseif (preg_match('/^7.3/',$row['phpversion'])) { - $php_versions['73']++; - } else { - $php_versions['other']++; - } - - $summary .= '<td>'; - $summary .= preg_match('/\w{2}/',$row['load_balanced']) ? '<img src="/images/Robin.ico" height="16" width="16"/>' : ''; - $summary .= '</td>'.PHP_EOL; - - // Print out mirror stats table cell - $summary .= '<td>' . $statscell . '</td>' . "\n"; - - // Print out mirror edit link - $summary .= '<td><a href="mirrors.php?id=' . $row['id'] . - '"><img src="/images/mirror_edit.png"></a></td>' . "\n"; - - // End of row - $summary .= '</tr>'; - - // If any info on the error of this mirror is available, print it out - if ($errorinfo) { - $summary .= "<tr>" . - "<td colspan=7><img src=\"/images/mirror_notice.png\" /> <small>"; - if (($errorblock = preg_split('/==\r?\n/',$errorinfo)) != 0) { - $summary .= nl2br($errorblock[(count($errorblock)-1)]); - } else { - $summary .= nl2br($errorinfo); - } - $summary .= '</small></td></tr>'; - } - // If additional details are desired - if ($moreinfo) { - $summary .= '<tr>' . - '<td>' . - ' Last update: ' . date(DATE_RSS, $row['ulastupdated']) . - ' SQLites: ' . implode(' : ', decipher_available_sqlites($row['has_search'])) . - '</td></tr>'; - } - } - - $summary .= '</table>'; - - // Sort by versions in use, descendingly, and produce the HTML string. - uksort($stats['phpversion'],'strnatcmp'); - $stats['phpversion'] = array_reverse($stats['phpversion']); - $versions = ""; - $vcount = count($stats['phpversion']); - $vnow = 0; - foreach($stats['phpversion'] as $version => $amount) { - if (empty($version)) { $version = "n/a"; } - $versions .= '<strong>'.$version.'</strong> ('.$amount.')<br/>'.PHP_EOL; - if (round(($vcount / 2)) == ++$vnow) { - $versions .= '</div>'.PHP_EOL.'<div>'; - } - } - //$versions = substr($versions, 0, -2); - - // Create version specific statistics - $stats['version5_percent'] = sprintf('%.1f%%', $stats['phpversion_counts'][5] / $stats['mirrors'] * 100); - $php53_percent = sprintf('%.1f%%',($php_versions['53'] / $stats['mirrors']) * 100); - $php54_percent = sprintf('%.1f%%',($php_versions['54'] / $stats['mirrors']) * 100); - $php55_percent = sprintf('%.1f%%',($php_versions['55'] / $stats['mirrors']) * 100); - $php56_percent = sprintf('%.1f%%',($php_versions['56'] / $stats['mirrors']) * 100); - $php70_percent = sprintf('%.1f%%',($php_versions['70'] / $stats['mirrors']) * 100); - $php71_percent = sprintf('%.1f%%',($php_versions['71'] / $stats['mirrors']) * 100); - $php72_percent = sprintf('%.1f%%',($php_versions['72'] / $stats['mirrors']) * 100); - $php73_percent = sprintf('%.1f%%',($php_versions['73'] / $stats['mirrors']) * 100); - $php_other_versions = sprintf('%.1f%%',($php_versions['other'] / $stats['mirrors']) * 100); - - $stats['has_stats_percent'] = sprintf('%.1f%%', $stats['has_stats'] / $stats['mirrors'] * 100); - - $last_check_time = get_print_date($checktime); - $current_time = get_print_date(time()); - - if(empty($stats['disabled'])) $stats['disabled'] = 0; - $stats['ok'] = $stats['mirrors'] - $stats['autodisabled'] - $stats['disabled']; - if ($moreinfo) { - $moreinfo_flag = 0; - $moreinfo_text = 'See less info'; - } else { - $moreinfo_flag = 1; - $moreinfo_text = 'See more info'; - } - - $has_sqlite_counts = ''; - foreach ($stats['sqlite_counts'] as $stype => $scount) { - $has_sqlite_counts .= '<tr><td><img src="/images/mirror_search.png" /></td><td>'.$stype.'</td>'; - $has_sqlite_counts .= '<td>'. $scount .' <small>('.round(($scount / $stats['mirrors']) * 100).'%)</small></td></tr>'; - } - -$statusscreen = <<< EOS - -<dl> - <dt>Last check time</dt> - <dd>{$last_check_time}</dd> - - <dt>Current time</dt> - <dd>{$current_time}</dd> -</dl> - -<hr> - -<dl> - <dt>Fully working mirrors:</dt> - <dd>{$stats['ok']}</dd> - - <dt>Manually-Disabled:</dt> - <dd>{$stats['disabled']}</dd> - - <dt>Auto-Disabled:</dt> - <dd>{$stats['autodisabled']}</dd> - - <dt><strong>Total:</strong></dt> - <dd><strong>{$stats['mirrors']}</strong></dd> - - <dt>Stats:</dt> - <dd>{$stats['has_stats_percent']}</dd> -</dl> - -<hr> - -<dl> - <dt>PHP 5.3</dt> - <dd>{$php53_percent}</dd> - - <dt>PHP 5.4</dt> - <dd>{$php54_percent}</dd> - - <dt>PHP 5.5</dt> - <dd>{$php55_percent}</dd> - - <dt>PHP 5.6</dt> - <dd>{$php56_percent}</dd> - - <dt>PHP 7.0</dt> - <dd>{$php70_percent}</dd> - - <dt>PHP 7.1</dt> - <dd>{$php71_percent}</dd> - - <dt>PHP 7.2</dt> - <dd>{$php72_percent}</dd> - - <dt>PHP 7.3</dt> - <dd>{$php73_percent}</dd> - - <dt>Other</dt> - <dd>{$php_other_versions}</dd> -</dl> - -<hr> - -<section class="mirrorinfo"> - <h3>SQLite Counts</h3> - <table style="padding-right: 0"> - {$has_sqlite_counts} - </table> -</section> - -<hr> - -<nav id="resources"> - <h1>Resources</h1> -<ul> - <li><a href="/manage/mirrors.php?mi={$moreinfo_flag}">{$moreinfo_text}</a></li> - <li><a href="http://php.net/mirroring.php" target="_blank">Guidelines</a></li> - <li><a href="mailto:php-mirrors@lists.php.net">Announcement/Discussion List</a></li> - <li><a href="mailto:network-status@lists.php.net">Network Status List</a></li> - <li><a href="https://status.php.net/">Network Health Page</a></li> - <li><a href="http://www.iana.org/domains/root/db/" target="_blank">Country TLDs</a></li> -</ul> -</nav> -<section class="mirrorinfo"> - -<p> - Note that the DNS table for mirror sites is updated directly from this list, without - human intervention, so if you add/delete/modify a mirror, it will be reflected in the - DNS table automatically in a short time. -</p> - -<p> - An automatically-deactivated mirror cannot be activated manually. It will be activated after - the next run of the automatic check (if the mirror is alright). Deactivated mirror maintainers - get notices of the deactivation weekly. Manually-deactivated mirrors are not checked by the - bot, so they need some time after reactivation to get listed again. Mirror checks are done - automatically every hour, and there is no direct manual way to start a check (at this time). -</p> - -<p> - <strong>NOTE</strong>: Manual deactivation of a mirror will now also disable its DNS. -</p> - -<div id="phpversions_off"> - <a href="#" onclick="$('#phpversions').toggle('slow');">PHP Version Summary</a> - <div id="phpversions"> - {$versions} - </div> -</div> -</section> - -<p><a href="/manage/mirrors.php?id=0">Add a new mirror</a></p> - - -EOS; -echo $summary; -return $statusscreen; - -} - -// Show mirror type options defaulting to current type -function show_mirrortype_options($type = 1) -{ - // There are two mirror types - $types = [1 => "standard", 2 => "special"]; //, 0 => "download"); - - // Write out an <option> for all types - foreach ($types as $code => $name) { - echo "<option value=\"$code\"", - $type == $code ? " selected" : "", - ">$name</option>"; - } -} - -// Print out MySQL date, with a zero default -function get_print_date($date) -{ - if (intval($date) == 0) { return 'n/a'; } - else { return gmdate("D, d M Y H:i:s", $date) . " GMT"; } -} - -// Print out PHP version number -function print_version($version) -{ - if ($version == "") { echo 'n/a'; } - else { echo $version; } -} diff --git a/network/status/api.php b/network/status/api.php index 0926c0b..e86b873 100644 --- a/network/status/api.php +++ b/network/status/api.php @@ -1,111 +1,6 @@ <?php -// We place this on the screen so that the user -// knows something should be getting ready to happen -if (!isset($_GET['host'])) die('Waiting....'); +// Replace with kind of no-op in case something is still calling that script -// If it's not a legitimate *.php.net address, make 'em buzz off -if (!preg_match('/^[a-z]+[0-9]?\.php\.net$/i',$_GET['host'])) - die('Uhhh, yeeeaaaahhh.... that\'s not gonna\' happen.'); - -// Go ahead and include the functions and configuration and such now -require_once dirname(dirname(dirname(__FILE__))).'/include/functions.inc'; - -/** - * In the interest of keeping this (free) key from - * being copied and reused, we'll store it in a file here: - * /etc/ipinfodb-api-key.txt - * If you're reading this source and are interested in - * getting your own free API key, I'd recommend going - * to http://www.ipinfodb.com/ and signing up. - */ -$ipinfodb_api_key = trim(file_get_contents('/etc/ipinfodb-api-key.txt')); - -// Database connection and query -db_connect(); -$res = db_query("SELECT * FROM mirrors LEFT JOIN country ON mirrors.cc = country.id WHERE mirrors.hostname='".mysql_real_escape_string($_GET['host'])."' LIMIT 0,1"); -$row = mysql_fetch_assoc($res); - -// Grab the real-time info from the mirror -$data = file_get_contents('http://'.$_GET['host'].'/mirror-info') or die('Unable to reach '.$_GET['host'].' via HTTP GET request.'); -$conf = explode('|',$data); - -// Last time the mirror was synchronized -$last_updated = date('\o\n l, \t\h\e jS \o\f F, Y, \a\t H:i:s',$conf[2]); - -// Available SQLites -$sqlites = implode(', ',decipher_available_sqlites($conf[3])); - -// Whether or not stats are available -$stats = $conf[4] == '1' ? 'does' : 'does not'; - -// The mirror's primary ISO language code -$lang_iso = $conf[5]; - -// Whether the mirror is active or inactive -$active = $conf[7] == '1' ? 'active' : 'inactive'; - -// The mirror's actual CNAME, IP info, and network stats -$cname = escapeshellarg($row['cname']); -$ip_info = str_replace(PHP_EOL,'; ',trim(`host $cname | grep -i address`)); -$ping_stats = nl2br(trim(`ping -c1 -i1 -w1 $cname | grep -v PING | grep -v "ping statistics"`)); -$ip_addr = gethostbyname($_GET['host']); - -// Our hostname info for showing in the probe report -$my_host = trim(`hostname`); - -// The maintainer's name with email address stripped -$maintainer = preg_replace('/\s?\<.*\>/U','',$row['maintainer']); - -// The date the mirror became official -preg_match('/^([0-9]{4,}-[0-9]{2,}-[0-9]{2,})/',$row['created'],$cd); -$ctime = strtotime(preg_replace('/([0-4\-])\s.*/','',$cd[0])); -$created = strstr('0000-00-00',$row['created']) ? 'before Tuesday, the 17th of September, 2002' : date('l, \t\h\e jS \o\f F, Y',$ctime); - -// The mirror type (normal = 1, special = 2) -$mirrortype = $row['mirrortype'] == '1' ? 'official' : 'special official'; - -// Geographical information from IP using danbrown's API key -$geoip_info = explode(';',file_get_contents('http://api.ipinfodb.com/v3/ip-city/?key='.$ipinfodb_api_key.'&ip='.$ip_addr)); - -// If we have location information to offer, build that output here -if (is_array($geoip_info) && $geoip_info[0] == 'OK') { - $geoip_info['region'] = $geoip_info[5]; - $geoip_info['city'] = $geoip_info[6]; - $geoip_info['lat_lon'] = $geoip_info[8].','.$geoip_info[9]; - $geoip_info['maplink'] = 'https://maps.google.com/maps?q='.$geoip_info['lat_lon'].'&hl=en&t=h&z=11'; - - if ($geoip_info['city'] != '-') { - $geoip_info['html'] = 'The mirror seems to be physically located in or near <b>'.$geoip_info['city']; - $geoip_info['html'] .= !empty($geoip_info['region']) && $geoip_info['region'] != $geoip_info['city'] ? ', '.$geoip_info['region'] : ''; - $geoip_info['html'] .= '</b>, which can be <b><a href="'.$geoip_info['maplink'].'" target="_blank">seen right here</a></b>.'; - } else { - $geoip_info['html'] = 'The mirror may or may not be <b><a href="'.$geoip_info['maplink'].'" target="_blank">near this point on the map.</a></b>'; - } - $geoip_info['html'] .= '<br/>'.PHP_EOL.'<br/>'.PHP_EOL; -} else { - $geoip_info['html'] = ''; -} - -// Build our HTML block -$html =<<<HTML -The node named <b><a href="{$conf[0]}" target="_blank">{$_GET['host']}</a></b> is an <b>{$active}</b> -{$mirrortype} php.net mirror serving the community from <b>{$row['name']}</b>. It is sponsored by -<b><a href="{$row['providerurl']}" target="_blank">{$row['providername']}</a></b> and -primarily maintained by <b>{$maintainer}</b>. Its hostname <b>{$ip_info}</b>. It was -last updated <b>{$last_updated}</b>. It is presently running <b>PHP {$conf[1]}</b> with -<b>{$sqlites} SQLite</b> available. The node <b>{$stats}</b> have statistics available, and -is configured to use the <b>ISO language code "{$lang_iso}"</b> as its primary language. This -mirror has been in service since <b>{$created}</b>.<br/> -<br/> - -{$geoip_info['html']} - -From here at <b>{$_SERVER['HTTP_HOST']} ({$my_host})</b>, a single probe to the node responds:<br/> -<br/> -{$ping_stats} - -HTML; - -// Output the HTML now -echo $html; +echo "Mirrors are no longer in use thus the output here is no longer relevant. "; +echo "Please adjust the script if this message appears. Thank you.\n"; diff --git a/network/status/index.php b/network/status/index.php index a0fffe8..ba5a632 100644 --- a/network/status/index.php +++ b/network/status/index.php @@ -1,285 +1,4 @@ <?php -/** - * This file is a one-glance network status page - * initially intended to show all current official - * mirrors and their respective activation status. - * It should grab some of its information in real-time - * from the mirrors so that maintainers, php.net - * admins, and others can help to diagnose issues - * with a mirror. - *------------------------------------------------------ - * Authors: Daniel P. Brown <danbrown@php.net> - * - */ -/* $Id */ - -require_once dirname(dirname(dirname(__FILE__))).'/include/functions.inc'; - -head('Network Status'); - -db_connect(); - -$lct = db_query("SELECT UNIX_TIMESTAMP(lastchecked) FROM mirrors ORDER BY lastchecked DESC LIMIT 1"); -list($checktime) = mysql_fetch_row($lct); - -page_mirror_list(); -foot(); - - - - -// ============================================================================= -// Functions -// ============================================================================= - -// Mirror listing page function -function page_mirror_list($moreinfo = false) -{ - global $checktime; - - // 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 - $res = db_query(" - SELECT mirrors.*, - UNIX_TIMESTAMP(lastupdated) AS ulastupdated, - UNIX_TIMESTAMP(lastchecked) AS ulastchecked, - country.name as countryname - FROM mirrors LEFT JOIN country ON mirrors.cc = country.id - ORDER BY country.name, hostname" - ); - - // Start table - $summary = '<br/><br/> - <div> - <table border="0" cellspacing="0" cellpadding="3" id="mirrors"> - <tr> - <td colspan="3" style="background-color:#ffdddd;"><center><b>Node Information</b></center></td> - <td colspan="5" style="background-color:#ddddff;"><center><b>Health &amp; Compliance</b></center></td> - </tr> - <tr> - <td style="background-color:#ffdddd;">&nbsp;</td> - <td style="background-color:#ffdddd;"><center><b>Node Name</b></center></td> - <td style="background-color:#ffdddd;"><center><b>Sponsor</b></center></td> - <td style="background-color:#ddddff;"><center><b>Synchrony</b></center></td> - <td style="background-color:#ddddff;"><center><b>SQLite</b></center></td> - <td style="background-color:#ddddff;"><center><b>PHP</b></center></td> - <td colspan="2" style="background-color:#ddddff;">&nbsp;</td> - </tr>'; - - // Previous country code - $prevcc = "n/a"; - - $stats = [ - 'mirrors' => mysql_num_rows($res), - '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)) { - - // Collect statistical information - @$stats['phpversion'][$row['phpversion']]++; - @$stats['phpversion_counts'][$row['phpversion'][0]]++; - - // Print separator row - $summary .= '<tr><td colspan="8"></td></tr>' . "\n"; - - // Print out a country header, if a new country is found - if ($prevcc != $row['cc']) { - $summary .= '<tr><th colspan="8" style="background-color:#dddddd;color:#444444;">' . $row['countryname'] . "</th></tr>\n"; - } - $prevcc = $row['cc']; - - // Active mirror site - if ($row['active']) { - - // Special active mirror site (green) - if ($row['mirrortype'] != 1) { $siteimage = "special"; } - - // Not special, but active - else { - $siteimage = 'green'; - } - } - // Not active mirror site (maybe deactivated by the - // mirror check bot, because of a /manual alias, - // or deactivated by some admin) - else { - $siteimage = "pulsing_red"; - } - - $sqlites = decipher_available_sqlites($row['has_search']); - if ($sqlites) { - $searchcell = implode(", ", $sqlites); - foreach ($sqlites as $sqlite_type) { - $stats['sqlite_counts'][$sqlite_type]++; - } - } else { - $stats['sqlite_counts']['none']++; - $searchcell = "&nbsp;"; - } - - // Mirrors updated within the last two hours are good. - // More than two hours but less than one day are in warning state. - // More than one day is an error. - if (strtotime($row['lastupdated']) >= strtotime('2 hours ago')) { - $synchrony_icon = '<img src="images/ok.gif" title="Last updated'.date('d-M-Y H:i',strtotime($row['lastupdated'])).' GMT"/>'; - } elseif (strtotime($row['lastupdated']) >= strtotime('24 hours ago')) { - $synchrony_icon = '<img src="images/warn.gif" title="Last updated '.date('d-M-Y H:i',strtotime($row['lastupdated'])).' GMT"/>'; - } else { - $synchrony_icon = '<img src="images/fail.gif" title="Last updated '.date('d-M-Y H:i',strtotime($row['lastupdated'])).' GMT"/>'; - } - - // If PHP is not at least 5.3.3 or 5.4.0+, warn or error, depending on version. - // PHP 5.3.10+ or 5.4.x == Okay - // PHP >= 5.3.3 && <= 5.3.9 == Warn - // All others == Fail - $_phpv = explode('.',$row['phpversion']); - $php_version = (int)$_phpv[0].$_phpv[1].str_pad($_phpv[2],2,'0',STR_PAD_LEFT); - if ($php_version >= 5310) { - $php_icon = '<img src="images/ok.gif" title="PHP '.$row['phpversion'].'"/>'; - } elseif ($php_version >= 5303) { - $php_icon = '<img src="images/warn.gif" title="PHP '.$row['phpversion'].'"/>'; - } else { - $php_icon = '<img src="images/fail.gif" title="PHP '.$row['phpversion'].'"/>'; - } - - // If the mirror doesn't have pdo_sqlite available, it's an error. - // There is no warning status here. - if (in_array('pdo_sqlite',$sqlites)) { - $sqlite_icon = '<img src="images/ok.gif" title="SQLites: '.$searchcell.'"/>'; - } else { - $sqlite_icon = '<img src="images/fail.gif" title="SQLites: '.$searchcell.'"/>'; - } - - // Mirror status information - $summary .= "<tr class=\"mirrorstatus\" onclick=\"$('#".str_replace('.','_',$row['hostname'])."_info').toggle();". - "$('#".str_replace('.','_',$row['hostname'])."_realtime').load('".$row['hostname']."');". - "$('#".str_replace('.','_',$row['hostname'])."_realtime').focus();\">". - "<td bgcolor=\"#ffffff\" align=\"right\">".PHP_EOL. - "<img src=\"images/{$siteimage}.gif\" /></td>".PHP_EOL; - - // Print out mirror site link - $summary .= '<td style="background-color:#ffdddd;"><a href="http://'.$row['hostname'].'/" target="_blank">'. - $row['hostname'].'</a><br /></td>'.PHP_EOL; - - // Print out mirror provider information - $summary .= '<td style="background-color:#ffdddd;"><a href="'.$row['providerurl'].'">'. - $row['providername'].'</a><br /></td>'.PHP_EOL; - - // Print out the sync status of the mirror - $summary .= '<td align="center" style="background-color:#ddddff;width:80px;">'.$synchrony_icon.'</td>'.PHP_EOL; - - // Print out SQLite compliance information - $summary .= '<td align="center" style="background-color:#ddddff;width:80px;">'.$sqlite_icon.'</td>'.PHP_EOL; - - // Print out PHP version compliance information - $summary .= '<td align="center" style="background-color:#ddddff;width:80px;">'.$php_icon.'</td>'.PHP_EOL; - - // AS-YET UNUSED CELL - $summary .= '<td align="right" style="background-color:#ddddff;">&nbsp;</td>' . "\n"; - - // AS-YET UNUSED CELL - $summary .= '<td align="right" style="background-color:#ddddff;">&nbsp;</td>' . "\n"; - - // End of row - $summary .= '</tr>'; - - // To show real-time info, if the row is clicked - $summary .= '<tr style="display:none;" id="'.str_replace('.','_',$row['hostname']).'_info">'.PHP_EOL; - $summary .= '<td colspan="8" id="'.str_replace('.','_',$row['hostname']).'_realtime">Hang on a sec....</td>'.PHP_EOL; - $summary .= '</tr>'.PHP_EOL; - - } - - $summary .= '</table></div>'; - - // Sort by versions in use, descendingly, and produce the HTML string. - uksort($stats['phpversion'],'strnatcmp'); - $stats['phpversion'] = array_reverse($stats['phpversion']); - $versions = ""; - $vcount = count($stats['phpversion']); - $vnow = 0; - foreach($stats['phpversion'] as $version => $amount) { - if (empty($version)) { $version = "n/a"; } - $versions .= '<span style="font-weight:bold;">'.$version.'</span> ('.$amount.')<br/>'.PHP_EOL; - if (round(($vcount / 2)) == ++$vnow) { - $versions .= '</div>'.PHP_EOL.'<div style="float:right;margin-right:35%;">';//width:120px;">'; - } - } - - $last_check_time = get_print_date($checktime); - $current_time = get_print_date(time()); - - if(empty($stats['disabled'])) $stats['disabled'] = 0; - $stats['ok'] = $stats['mirrors'] - $stats['disabled']; - $moreinfo_flag = empty($moreinfo) ? 1 : 0; - - $has_sqlite_counts = ''; - foreach ($stats['sqlite_counts'] as $stype => $scount) { - $has_sqlite_counts .= '<tr><td><img src="/images/mirror_search.png" /></td><td>'.$stype.'</td>'; - $has_sqlite_counts .= '<td>'. $scount .' <small>('.round(($scount / $stats['mirrors']) * 100).'%)</small></td></tr>'; - } - -echo <<<EOS -<div> - -<h1>PHP Global Network Infrastructure Health</h1> -<b>Last check time:</b> {$last_check_time}<br/> -<b>Current time:</b> {$current_time}<br/> -<br/> - -<b>In each node's compliance entries, you can place your -mouse over the icon to get additional details. Or, for -more than you ever wanted to know about the mirror, click -anywhere in its respective row.</b><br/> -<br/> - -If you're interested in receiving network status updates -for the small army of global machines that comprise the -<a href="http://php.net">php.net</a> network, you may -subscribe to the notification list -(<code>network-status@lists.php.net</code>) by sending a -blank email to -<a href="mailto:network-status-subscribe@lists.php.net">network-status-subscribe@lists.php.net</a>.<br/> -<br/> - -<h2>Key:</h2> -<br/> - -&nbsp;<img src="images/green.gif"/> Node Active -<img src="images/pulsing_red.gif"/> Node Inactive -<img src="images/special.gif"/> Special Node<br/> -<br/> - -<img src="images/ok.gif"/> Node Is Fully Compliant -<img src="images/warn.gif"/> Node Is Partially Compliant -<img src="images/fail.gif"/> Node Is Non-Compliant<br/> - -<br/> - -<div id="phpversions_off" style="display:block;width:100%;"> - <!--<a href="#" onclick="javascript:pop('phpversions');">PHP Version Summary</a>--> - <a href="#" onclick="$('#phpversions').toggle('slow');">PHP Version Summary</a> - <div id="phpversions" style="display:none;text-align:center;width:100%;"> - <div style="float:left;margin-left:35%;"> - {$versions} - </div> - <div style="clear:left;height:1px;"></div> - </div> -</div> - -$summary - -</div> -EOS; - -} - -// Print out MySQL date, with a zero default -function get_print_date($date) { - if (intval($date) == 0) { return 'n/a'; } - else { return gmdate("D, d M Y H:i:s", $date) . " GMT"; } -} +header('Location: http://php.net'); +exit; diff --git a/network/status/style.css b/network/status/style.css index e7c0181..a1594a4 100644 --- a/network/status/style.css +++ b/network/status/style.css @@ -22,54 +22,6 @@ p.notepreview { white-space: pre; } -/* Resources box on mirror management page */ -div#resources { - float: right; - border: 2px solid black; - background-color: #f5f5f5; - font-family: sans-serif; - padding: 3px; - margin: 3px; -} -div#resources h1 { - font-size: 120%; - margin: 0px; - padding: 0px; -} -div#resources ul { - margin: 3px; - padding: 0px; -} -div#resources table { - float: left; - border: 1px solid black; - margin: 3px; -} - -/* Mirrors table */ -table#mirrors { - clear: both; -} -table#mirrors td, table#mirrors th { - vertical-align: middle; - font-family: sans-serif; - margin-left:15px; -} -table#mirrors a { - text-decoration: none; -} -table#mirrors th { - text-align: left; - text-indent:15px; - font-weight: bold; - background-color:#5a5993; - font-size: 120%; - color:#b5b5e9; -} -.mirrorstatus, .mirrordetails, .mirrorerror { - background-color:#e8e8fc; -} - /* General image style */ img { border: 0px; diff --git a/scripts/conference_teaser b/scripts/conference_teaser index 38d0932..3f96d23 100644 --- a/scripts/conference_teaser +++ b/scripts/conference_teaser @@ -2,7 +2,7 @@ /* vim: ft=php This code is used to pregenerate the conference teaser array displayed - on the PHP.net (and all mirror's) homepage. It gets the filename + on the PHP.net homepage. It gets the filename of the RSS where the info is already fetched, and generates the PHP code ready to be included to $outfile */ diff --git a/scripts/event_listing b/scripts/event_listing index e3a1dbf..0d46f7a 100644 --- a/scripts/event_listing +++ b/scripts/event_listing @@ -2,7 +2,7 @@ /* This code is used to pregenerate the events listing displayed - on the PHP.net (and all mirror's) homepage. It gets the filename + on the PHP.net homepage. It gets the filename of the CSV where the info is already fetched, and generates the PHP code ready to be included to $outfile */ diff --git a/scripts/mirror-summary b/scripts/mirror-summary deleted file mode 100755 index b647f9a..0000000 --- a/scripts/mirror-summary +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/local/bin/php -q -<?php -/* - This script alerts the php-mirrors team about dead mirrors, - as well as tries to mail notifications of deactivations - to the individual mirror maintainers (using the provided - contact details). -*/ - -// Please edit this when testing to print the mail out, not send them to the list every time -define("DEBUG", true); - -function email($address, $subject, $content) { - if (DEBUG) { - echo $subject, "\n", $content, "\n\n\n\n"; - return; - } - - $headers = "From: network-status@lists.php.net"; - $extrah = "-fnoreply@php.net"; - return mail($address, $subject, $content, $headers, $extrah); -} -// This script will run for a long time -set_time_limit (0); - -// Empty arrays by default -$inactives = $disabled = $lines = []; - -// Try to connect to the database and select phpmasterdb database -mysql_connect("localhost","nobody","") or die("unable to connect to database"); -mysql_select_db("phpmasterdb"); - -// Select last mirror check time from table -$lct = mysql_query("SELECT UNIX_TIMESTAMP(lastchecked) FROM mirrors ORDER BY lastchecked DESC LIMIT 1"); -list($checktime) = mysql_fetch_row($lct); - -// Select all mirrors ordered by hostname -$query = "SELECT maintainer, active, hostname, id, has_search, UNIX_TIMESTAMP(lastupdated) AS lastupdate, " . - "phpversion, acmt, ocmt " . - "FROM mirrors WHERE mirrortype = 1 ORDER BY hostname"; - -// Execute SQL query -$result = mysql_query($query) or die("unable to get from the database"); - -while ($host = mysql_fetch_assoc($result)) { - - if (!$host["active"] || $host["ocmt"]) { - $error = ""; - if (!$host["active"]) { - $disabled[$host["hostname"]] = $host; - $error .= $host["acmt"]; - } - if ($host["ocmt"]) { - $inactives[$host["hostname"]] = $host; - $error .= $host["ocmt"]; - } - - $message = "Hi!\n\nOur automatic mirror site check found a permanent " - ."fatal error in your mirror setup.\n" - ."Therefore our bot automatically disabled your listing as an\n" - ."official PHP.net mirror site.\n" - ."\n$error\n" - ."Please correct the problem or reply to this mail with your\n" - ."questions, if you think that the problem is not on your side.\n" - ."Your mirror will be kept disabled until the error is fixed.\n\n" - ."Mail sent out by the PHP.net automatic mirror site monitoring system"; - - email( - $host["maintainer"], - "{$host["hostname"]} mirror site deactivated", - $message - ); - } else { - $has_search = empty($host['has_search']) ? 'N' : 'Y'; - - $lines[]= sprintf(" %s%s%s%s%s%s%s\n", - $host['hostname'], pad(12, 'hostname'), - $host['phpversion'], pad(6, 'phpversion'), - $has_search, pad(1, 'has_search'), - date('F j, Y, g:i a', $host['lastupdate']) - ); - } -} - -// This is the common text for the php-mirrors mail -$body = "Following is data gathered from the various mirrors. It is ordered by those\n" - . "that are suspected to be dead, mirrors which are alive but have errors, and\n" - . "finally the rest, sorted by hostname. The maintainers of inactive and disabled\n" - . "mirror sites are automatically notified the same time, as this mail goes out.\n\n" - . "View the mirror trouble guide here: http://php.net/mirroring-troubles.php\n\n"; - -if (count($inactives)) { - $body .= "These mirrors are badly broken:\n\n"; - $body .= wordwrap(join(', ', array_keys($inactives))) . "\n"; -} - -if (count($disabled)) { - $body .= "\nThese mirrors are manually disabled:\n\n"; - $body .= wordwrap(join(', ', array_keys($disabled))) . "\n"; -} - -$body .= "\nAnd now for the rest of the mirrors:\n" - . "----------------------------------------------------------------------------------------\n" - . " Host \t\t PHP Version \t\t SQLite \t\t Last Updated\n" - . "----------------------------------------------------------------------------------------\n"; - -/* A note about the padding - given that email readers produce interesting results for spacing, -i've gone for tabs here to help seperate the text columns. to make sure i don't over tab, i do -a quick strlen check, and depending on how different it is from the string length i give as avg -(first argument), will determine how many tabs i use, or alternatively a space. */ - -// Padd an item, respecting a default length -function pad($deflen, $item) { - global $host; - $str = strlen($host[$item]); - if ($str >= $deflen*2) { - $sp =" "; - } - else if ($str <= $deflen){ - $sp ="\t\t"; - } else { - $sp = "\t"; - } - return $sp; -} - - -$body .= join("", $lines); -$body . "---------------------------------------------------------------------------------------\n"; - -email( - "network-status@lists.php.net", - "[mirrors] Status information", - $body -); - - diff --git a/scripts/mirror-test b/scripts/mirror-test deleted file mode 100755 index a094e6e..0000000 --- a/scripts/mirror-test +++ /dev/null @@ -1,585 +0,0 @@ -#!/usr/bin/env php -<?php # vim: ft=php et -// This script is executed on master - -/* - Check the state of each mirror site, and store the - current data in the database. This data is then used - to generate the official mirror listing with deactived - mirrors delisted. The gathered information is also - mailed to the php-mirrors mailing list periodically - by the mirror-summary script, and the maintainers also - get notices of deactivations weekly. -*/ - -// This script will run for a long time -set_time_limit(30 * 60); - - -function lap() { - static $then = 0; - static $now; - - $now = microtime(true); - $ret = $now - $then; - $then = $now; - return $ret; -} -function isDebug() { - return getenv("PHPWEBDEV") || file_exists(".DEV"); -} -function p($msg) { - return fprintf(STDERR, "%s", $msg); -} -function email($address, $subject, $content) { - if (isDebug()) { - return fprintf(STDERR, "\n\nMailed %s -- %s\n%s\n\n", $address, $subject, $content); - } - - $headers = "From: mirrors@php.net"; - $extrah = "-fnoreply@php.net"; - return mail($address, $subject, $content, $headers, $extrah); -} -function emailMirror($row, $problem) { - $subject = "{$row["hostname"]} Disabled"; - $content = <<<EOF -Dear {$row["maintainer"]} - -The mirror you are maintaing for php.net ({$row["hostname"]}) has been disabled -due to: - - $problem - - -For more information please checkout our mirroring-troubles page: -http://{$row["hostname"]}/mirroring-troubles.php - -Please resolve this issue ASAP. If the reason is unclear, please contact -php-mirrors@lists.php.net - -- php.net mirror surveillance - -EOF; - email($row["maintainer"], $subject, $content); -} -function MIRRORINFO($row, $content) { - $RETURN = []; - - /* Parse our mirror configuration from /mirror-info */ - $info = explode("|", trim($content)); - - if (count($info) != 11) { - FAIL($row, "/mirror-info", "Invalid data received. See: http://php.net/mirroring-troubles.php#invalid-data\n", $row["cname"]); - return false; - } - - if (preg_match("@^\d+\.\d+\.\d+@", $info[1], $matches)) { - $RETURN["phpversion"] = $matches[0]; - } else { - FAIL($row, "/mirror-info|version", "Doesn't look like PHP version", $row["cname"]); - return false; - } - - if (!version_compare($RETURN["phpversion"], "5.3.3", "ge")) { - FAIL($row, "/mirror-info|version", "Running pre 5.3.3", $row["cname"]); - return false; - } - - $RETURN["mirrorupdated"] = (int)$info[2]; - $RETURN["has_search"] = (int)$info[3]; - $RETURN["has_stats"] = (int)$info[4]; - - if ($RETURN["mirrorupdated"] < strtotime("6 hours ago")) { - FAIL($row, "/mirror-info|stale", "Stale mirror, not been updated for a while", $row["cname"]); - return false; - } - // If language value is SQL safe, update it - if (preg_match("!^[a-zA-Z_]+$!", $info[5])) { - $RETURN["lang"] = $info[5]; - } else { - FAIL($row, "/mirror-info|lang", "Invalid language string", $row["cname"]); - return false; - } - - if (!(bool)$info[7]) { - FAIL($row, "/mirror-info|rsync", "Rsync setup problems, see /mirroring.php.", $row["cname"]); - return false; - } - - - // Get the list of available extensions on the mirror - $RETURN["ext_avail"] = (string)$info[8]; - // Get the system"s local hostname - $RETURN["local_hostname"] = (string)$info[9]; - // Get the system"s IP address - $RETURN["ipv4_addr"] = (string)$info[10]; - - // Check if mirror has correct ServerName/ServerAlias entries - // Most likely cause is unofficial hostname as ServerName instead of ServerAlias - // Important to keep my php.net cookie around - $mysite = parse_url($info[0]); - if (!$mysite) { - FAIL($row, "/mirror-info|parsing", "Can't parse URL from mirror-info", $row["cname"]); - return false; - } - if ($mysite["host"] != $row["hostname"]) { - $errmsg = "Apache ServerName directive does not match '{$row['hostname']}'." - . " Consider swapping ServerName and ServerAlias, see /mirroring.php."; - FAIL($row, "/mirror-info|hostname", $errmsg, $row["cname"]); - return false; - } - - return $RETURN; -} - -function bfetch($url, $ctx, &$headers) { - lap(); - - $content = file_get_contents($url, false, $ctx); - - $base = basename($url); - if (strpos($base, "?")) { - $base = strstr($base, "?", true); - } - $msg = sprintf("\t%s: %.2f", $base, lap()); - p($msg); - - if ($content) { - $headers = $http_response_header; - } else { - $headers = []; - } - - return $content; -} - -function fetch($host, $filename, $ashostname = NULL, &$headers = []) { - $opts = [ - "user_agent" => "PHP.net Mirror Site check", - "max_redirects" => 0, - "timeout" => 15, - "ignore_errors" => "1", - "header" => [ - "Host: " . ($ashostname ?: $host), - "Connection: close", - ], - ]; - $ctx = stream_context_create(["http" => $opts]); - - - $url = "http://$host$filename"; - - $content = bfetch($url, $ctx, $headers); - - return $content; -} - -function HTTPCODE($headers, $code) { - $code = strtolower($code); - foreach($headers as $header) { - if (strpos(strtolower($header), $code) !== false) { - return true; - } - } - - return false; -} -function FAIL($mirror, $check, $reason, $testhost) { - global $pdo; - - // Try to extract something reasonable out of the content - $reason = htmlentities(substr(str_replace("\n", "", strip_tags($reason)), 0, 128)); - - switch($check) { - case "/mirror-info|version": - $help = "Your PHP version is too old"; - $help .= "\n\n\tTest URL: http://$testhost/mirror-info\n"; - break; - case "/mirror-info|stale": - $help = "Please run rsync on hourly basis"; - $help .= "\n\n\tTest URL: http://$testhost/mirror-info\n"; - break; - case "/mirror-info|lang": - $help = "Unknown language"; - $help .= "\n\n\tTest URL: http://$testhost/mirror-info\n"; - break; - case "/mirror-info|rsync": - $help = "Rsync issues"; - $help .= "\n\n\tTest URL: http://$testhost/mirror-info\n"; - break; - case "/mirror-info|hostname": - $help = "Please make sure your ServerName is configured correctly"; - $help .= "\n\n\tTest URL: http://$testhost/mirror-info\n"; - break; - - case "www.php.net": - $help = "Does not answer to www.php.net. "; - $help .= "www.php.net is now experimenting with GeoDNS and we have requested all mirrors to add www.php.net as ServerAlias. "; - $help .= "Please see:"; - $help = wordwrap($help, 75, "\n\t"); - $help .= " http://grokbase.com/t/php/php-mirrors/15190w93m0/www-php-net-over-geodns-please-update-your-serveralias\n"; - break; - - case "cc.php.net": - $help = "Does not answer to country-code.php.net"; - break; - - case "/manual/noalias.txt": - $help = "Apache manual alias. See: http://php.net/mirroring-troubles.php#manual-redirect"; - $help .= "\n\n\tTest URL: http://$testhost/$check\n"; - break; - - case "/manual/en/faq.html.php": - $help = "Content-Type. See: http://php.net/mirroring-troubles.php#content-type"; - $help .= "\n\n\tTest URL: http://$testhost/$check\n"; - break; - - case "/functions": - $help = "MultiViews on. See: http://php.net/mirroring-troubles.php#multiviews"; - $help .= "\n\n\tTest URL: http://$testhost/$check\n"; - break; - - case "/manual/en/ref.var.php": - $help = "Var Handler. See: http://php.net/mirroring-troubles.php#var"; - $help .= "\n\n\tTest URL: http://$testhost/$check\n"; - break; - - case "/results.php?q=example&p=manual&l=en": - $help = "Outbound connections appear disabled. See: http://php.net/mirroring-troubles.php#outbound"; - $help .= "\n\n\tTest URL: http://$testhost/$check\n"; - break; - - default: - $help = ""; - } - - $errmsg = "Failed '$check' check: $reason\n\nLikely cause:\n\t$help"; - - $query = " -UPDATE mirrors SET - ocmt = :reason, - lastchecked = NOW() -WHERE id = :id -"; - $stmt = $pdo->prepare($query); - - $params = [ - ":reason" => $errmsg, - ":id" => $mirror["id"], - ]; - - /* Mail the maintainer right away if it wasn't disabled already */ - if (!$mirror["ocmt"]) { - emailMirror($mirror, $errmsg); - } - - $stmt->execute($params); - p("\n"); -} - -function UPDATE($mirror, $info) { - global $pdo; - - $query = " -UPDATE mirrors SET - lastchecked = NOW(), - lastupdated = FROM_UNIXTIME(:lastupdated), - has_search = :has_search, - has_stats = :has_stats, - phpversion = :phpversion, - lang = :lang, - ocmt = :ocmt, - ext_avail = :ext_avail, - local_hostname = :local_hostname, - ipv4_addr = :ipv4_addr -WHERE id = :id -"; - - $stmt = $pdo->prepare($query); - $params = [ - ":lastupdated" => (int)$info["mirrorupdated"], - ":has_search" => (int)$info["has_search"], - ":has_stats" => (int)$info["has_stats"], - ":phpversion" => $info["phpversion"], - ":lang" => $info["lang"], - ":ocmt" => "", - ":ext_avail" => $info["ext_avail"], - ":local_hostname" => $info["local_hostname"], - ":ipv4_addr" => $info["ipv4_addr"], - ":id" => $mirror["id"], - ]; - $stmt->execute($params); -} - -function GEOLS() { - p(GEOLS. "\n"); - $json = file_get_contents(GEOLS); - - if ($json) { - return json_decode($json, true); - } - - return []; -} - -function GEORM($id) { -sleep(1); - - $opts = [ - "user_agent" => "PHP.net Mirror Site check", - "timeout" => 15, - "ignore_errors" => "1", - "method" => "DELETE", - ]; - - $ctx = stream_context_create(["http" => $opts]); - $retval = file_get_contents(sprintf(GEORM, $id), false, $ctx); - - p($retval); - p("Removed $id\n"); -} - -function GEOADD($cname, $country) { -sleep(1); - $countries = include __DIR__ . "/countries.inc"; - - if (!isset($countries[$country])) { - p("Can't find country code for $country\n"); - return; - } - - $data = [ - "domain" => ZONE, - "host" => "@", - "ttl" => 0, - "geozone_id" => $countries[$country], - "prio" => 0, - "type" => "CNAME", - "rdata" => $cname, - ]; - $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(["http" => $opts]); - $retval = file_get_contents(GEOADD, false, $ctx); - p("Adding $cname => " . GEOADD . ": $t\n"); - p($retval); -} - -function geoDNS($HOSTS) { - $GEOLIST = GEOLS(); - if (!$GEOLIST) { - p("Not updating EasyDNS GeoDNS, couldn't get the list!\n"); - } - $HOSTS["php-web2.php.net."] = "North America"; - - /* Remove disabled hosts */ - $GEO = []; - foreach($GEOLIST["data"] as $k => $entry) { - /* Only deal with records we have declared as GEO */ - if (empty($entry["geozone_id"])) { - p("No GEOZONE_ID set for {$entry["rdata"]}\n"); - continue; - } - - if (empty($HOSTS[$entry["rdata"]])) { - unset($HOSTS[$entry["rdata"]]); - p("{$entry["rdata"]} not a current host\n"); - GEORM($entry["id"]); - } else { - p("{$entry["rdata"]} is current host\n"); - $GEO[$entry["rdata"]] = $entry["id"]; - } - } - - p("Now using mirror-check\n"); - foreach($HOSTS as $cname => $country) { - if (isset($GEO[$cname]) && $country) { - /* CNAME listed in GEO zone and is enabled in our system */ - continue; - } - - if ($country) { - /* CNAME enabled in our system, make new zone record for it */ - GEOADD($cname, $country); - continue; - } elseif (isset($GEO[$cname])) { - /* CNAME disabled in our system, remove the zone record for it */ - GEORM($GEO[$cname]); - } else { - /* CNAME disabled in our system, and no zone record for it */ - continue; - } - - } -} - -$pdo = new PDO("mysql:host=localhost;dbname=phpmasterdb", "nobody", ""); - - -// Get mirror information for all mirrors (except our special mirrors, such as www and docs) -$query = "SELECT mirrors.id, cc, hostname, cname, maintainer, load_balanced, ocmt, country.alpha2 FROM mirrors,country WHERE mirrortype = 1 --- AND hostname IN('us1.php.net', 'us2.php.net', 'ca3.php.net', 'ua1.php.net', 'uk3.php.net') -AND mirrors.cc=country.id -ORDER BY hostname"; -$stmt = $pdo->prepare($query); -$stmt->execute(); - - -$HOSTS = []; -while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $timeoutfail = 0; - p($row["hostname"]); - $HOSTS[$row["cname"]."."] = false; - - - $filename = "/manual/noalias.txt"; - $content = fetch($row["cname"], $filename, null, $headers); - - if ($content != "manual-noalias") { - if (!$headers && $timeoutfail < 2) { - $timeoutfail++; - } else { - FAIL($row, "/manual/noalias.txt", "Expected 'manual-noalias', got '$content'", $row["cname"]); - continue; - } - } - - /* GeoDNS for www.php.net */ - $content = fetch($row["cname"], $filename, "www.php.net", $headers); - if ($content != "manual-noalias") { - if (!$headers && $timeoutfail < 2) { - $timeoutfail++; - } else { - FAIL($row, "www.php.net", "Couldn't fetch $filename from www.php.net", "www.php.net"); - continue; - } - } - - /* Round-robin for country-code.php.net */ - if ($row["load_balanced"]) { - $content = fetch($row["cname"], $filename, $row["load_balanced"] . ".php.net", $headers); - if ($content != "manual-noalias") { - if (!$headers) { - $timeoutfail++; - } else { - FAIL($row, "cc.php.net", "Couldn't fetch $filename from {$row["load_balanced"]}.php.net", "{$row["load_balanced"]}.php.net"); - continue; - } - } - } - - - /* bug#26840 Content negotiation screwups; ".html.php" */ - $content = fetch($row["cname"], "/manual/en/faq.html.php", $row["hostname"], $headers); - if (!$content) { - if (!$headers && $timeoutfail < 2) { - $timeoutfail++; - } else { - FAIL($row, "/mirror-info", "Received no response in 15 seconds", $row["hostname"]); - continue; - } - } - if (!HTTPCODE($headers, "200 OK")) { - FAIL($row, "/mirror-info", "Expected 200 OK -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - if (!HTTPCODE($headers, "Content-Type: text/html")) { - FAIL($row, "/manual/en/faq.html.php", "Expected Content-Type: text/html -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - - /* bug#31852 Apache multiviews */ - $content = fetch($row["cname"], "/functions", $row["hostname"], $headers); - if (!$content) { - if (!$headers && $timeoutfail < 2) { - $timeoutfail++; - } else { - FAIL($row, "/mirror-info", "Received no response in 15 seconds", $row["hostname"]); - continue; - } - } - if (!HTTPCODE($headers, "200 OK")) { - FAIL($row, "/functions", "Expected 200 OK -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - if (!HTTPCODE($headers, "Content-Type: text/html")) { - FAIL($row, "/functions", "Expected Content-Type: text/html -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - - /* bug#35970 `var` handler */ - $content = fetch($row["cname"], "/manual/en/ref.var.php", $row["hostname"], $headers); - if (!$content) { - if (!$headers && $timeoutfail < 2) { - $timeoutfail++; - } else { - FAIL($row, "/mirror-info", "Received no response in 15 seconds", $row["hostname"]); - continue; - } - } - if (!HTTPCODE($headers, "200 OK")) { - FAIL($row, "/manual/en/ref.var.php", "Expected 200 OK -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - if (!HTTPCODE($headers, "Content-Type: text/html")) { - FAIL($row, "/manual/en/ref.var.php", "Expected Content-Type: text/html -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - - /* bug#46423 outbound connections for internal search */ - $content = fetch($row["cname"], "/results.php?q=example&p=manual&l=en", $row["hostname"], $headers); - if (!$content) { - if (!$headers && $timeoutfail < 2) { - $timeoutfail++; - } else { - FAIL($row, "/mirror-info", "Received no response in 15 seconds", $row["hostname"]); - continue; - } - } - if (!HTTPCODE($headers, "200 OK")) { - FAIL($row, "/manual/en/ref.var.php", "Expected 200 OK -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - if (!HTTPCODE($headers, "Content-Type: text/html")) { - FAIL($row, "/manual/en/ref.var.php", "Expected Content-Type: text/html -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - - - $content = fetch($row["cname"], "/mirror-info", $row["hostname"], $headers); - if (!$content) { - if (!$headers && $timeoutfail < 2) { - $timeoutfail++; - } else { - FAIL($row, "/mirror-info", "Received no response in 15 seconds", $row["hostname"]); - continue; - } - } - if (!HTTPCODE($headers, "200 OK")) { - FAIL($row, "/mirror-info", "Expected 200 OK -- got:\n\t" . join("\n\t", $headers), $row["hostname"]); - continue; - } - if ($info = MIRRORINFO($row, $content)) { - UPDATE($row, $info); - $HOSTS[$row["cname"]."."] = $row["alpha2"]; - } - p("\n"); -} - -if ($creds = getenv("EASYDNS_CREDENTIALS")) { - $GEOROOT = "https://{$creds}@rest.easydns.net"; - define("ZONE", "www.php.net"); - define("GEOLS", "$GEOROOT/zones/records/all/" . ZONE . "?format=json"); - define("GEORM", "$GEOROOT/zones/records/" . ZONE . "/%s?format=json"); - define("GEOADD", "$GEOROOT/zones/records/add/" . ZONE . "/CNAME?format=json"); - geoDNS($HOSTS); -} else { - p("Not updating EasyDNS GeoDNS, No credentials provided"); -} - diff --git a/scripts/update-backend b/scripts/update-backend index b2e989e..bfc611c 100755 --- a/scripts/update-backend +++ b/scripts/update-backend @@ -16,10 +16,6 @@ $root = $argv[1]; // due to remote data fetching set_time_limit(30 * 60); -// Get list of mirror sites -fetch_into_file("https://master.php.net/fetch/mirrors.php?token=$token", - "$root/include/mirrors.inc"); - // Get list of upcoming events fetch_into_file("https://master.php.net/fetch/events.php?token=$token", "$root/backend/events.csv");
« previous php.webmaster (#28590) next »