cvs: phpweb / get_download.php mirrors.php /include mirrortable.inc
| From: | Gabor Hojtsy | Date: | Sun, 04 May 2003 11:22:13 +0000 |
| Subject: | cvs: phpweb / get_download.php mirrors.php /include mirrortable.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-17295@lists.php.net to get a copy of this message | ||
goba Sun May 4 07:22:13 2003 EDT
Added files:
/phpweb/include mirrortable.inc
Modified files:
/phpweb get_download.php mirrors.php
Log:
Let the mirror table code be defined at one place,
which honors the specialities of the two varations,
while handles the common things together
Index: phpweb/get_download.php diff -u phpweb/get_download.php:1.21 phpweb/get_download.php:1.22 --- phpweb/get_download.php:1.21 Sun May 4 06:39:44 2003 +++ phpweb/get_download.php Sun May 4 07:22:13 2003 @@ -1,5 +1,6 @@ <?php include_once 'prepend.inc'; +include_once 'mirrortable.inc'; // Try to make this page non-cached header_nocache(); @@ -41,99 +42,8 @@ Please choose the mirror closest to you from which to download the file. The current mirror is highlighted in yellow, mirror sites detected to be out of date or disfunctional are not listed for your convenience. - +</p> + <?php - -// If we have a valid country, and we have at least one mirror -// in that country, provide some intro text and the list of mirrors -if (i2c_valid_country()) { - $close = count_mirrors($COUNTRY); - if ($close > 0) { - $mnum = (($close > 1) ? "mirrors" : "mirror"); - echo "We have automatically detected the following $mnum to be close\n" . - "to you. If you use a mirror close to you for downloads and\n" . - "your usual daily work, you will get better response times.</p>\n"; - mirror_list($COUNTRY); - echo "<p>Here is the list of all the other sites in case our detection\n" . - "did something wrong, or the local mirror sites are busy.\n"; - mirror_list('', $COUNTRY); - } else { echo "</p>\n"; mirror_list(); } -} else { echo "</p>\n"; mirror_list(); } - -// List mirrors for download with a possible country matching -function mirror_list($cmatch = '', $cnomatch = '') { - - global $MIRRORS, $MYSITE, $df, $COUNTRIES; - - // Print out start of the table centered - echo '<div align="center">' . "\n" . - '<table border="0" cellpadding="3" cellspacing="1" width="500">' . "\n"; - - // Maintain previous country code information - $prevcc = 'aa'; - - // Go through all mirror sites and print out download links - $MURLS = array_keys($MIRRORS); - foreach ($MURLS as $murl) { - - // If the mirror is not all right, skip it - // Virtual mirrors *are listed* here, because local unofficial - // mirrors can be used in this way for download. - if (mirror_status($murl) != MIRROR_OK) { continue; } - - // Get the country code and check if it is - // matching the country provided (or does not - // match the country, which it should not be) - $country = mirror_country($murl); - if (!empty($cmatch) && $country != $cmatch) { continue; } - if (!empty($cnomatch) && $country == $cnomatch) { continue; } - - // Print out a country header, if a new country is found - if ($prevcc != $country) { - echo '<tr><td colspan="3"></td></tr>' . "\n"; - echo '<tr bgcolor="#cccccc"><td width="40" align="center">'; - print_image( - 'flags/' . strtolower($country) . '.png', - $COUNTRIES[$country], - FALSE, - 'CLASS="flag"' - ); - echo '<br /></td>'; - echo '<td colspan="2"><b>' . $COUNTRIES[$country] . '</b><br /></td>'; - echo '</tr>' . "\n"; - } - - // We print out a line for the current mirror - $thismirror = ($MYSITE == $murl); - - // Highlight this mirror if it is the current one - echo '<tr bgcolor="' . ($thismirror ? '#ffffcc' : '#e0e0e0') . '">' . "\n"; - - // Print out caret (in bold if current mirror) - echo '<td bgcolor="#ffffff" align="right">'; - print_image( ($thismirror ? 'caret-r.gif' : 'caret-rg.gif') ); - echo '<br /></td>' . "\n"; - - // Print out mirror site download link - echo '<td><small>'; - $mirrorshort = substr($murl, strpos($murl, '//') + 2, -1); - $mirrorname = ($thismirror ? "this" : $mirrorshort); - print_link("/get/$df/from/$mirrorname/mirror", $mirrorshort); - echo '</small><br /></td>' . "\n"; - - // Print out mirror provider's name - echo '<td><small>'; - echo mirror_provider($murl); - echo '</small><br /></td>' . "\n"; - - // End row for this mirror - echo "</tr>\n"; - - // Maintain previous country code - $prevcc = $country; - } - - echo "</table>\n</div>\n"; -} - +mirror_list($df); commonFooter(); Index: phpweb/mirrors.php diff -u phpweb/mirrors.php:1.22 phpweb/mirrors.php:1.23 --- phpweb/mirrors.php:1.22 Thu Apr 24 03:01:54 2003 +++ phpweb/mirrors.php Sun May 4 07:22:13 2003 @@ -1,12 +1,13 @@ <?php include_once 'prepend.inc'; +include_once 'mirrortable.inc'; commonHeader("Mirror Sites"); ?> <h1>Mirror Sites</h1> <p> - Here you can find information about the mirrors of php.net. This table only + Here you can find information about the mirrors of php.net. This page only lists the official mirrors, registered in our database. The mirrors automatically detected to be outdated or disfunctional are not listed for your convinience, so there may be a mirror (or some mirrors) with problems in your country additionaly @@ -26,65 +27,6 @@ <?php print_link("/mirroring.php", "here's how"); ?>. </p> -<div align="center"> -<table border="0" cellpadding="3" cellspacing="1" width="560"> <?php - -// Previous mirror country code -$prevcc = 'aa'; - -// Go through all mirror sites and print out information about them -$MURLS = array_keys($MIRRORS); -foreach ($MURLS as $murl) { - - // If the mirror is not all right or it is virtual (not an official mirror), skip it - if (mirror_status($murl) != MIRROR_OK || mirror_type($murl) == MIRROR_VIRTUAL) { continue; } - - // Get country code, print out a - // country header, if it is a new one - $country = mirror_country($murl); - if ($prevcc != $country) { - echo '<tr><td colspan="4"></td></tr>' . "\n"; - echo '<tr bgcolor="#cccccc"><td width="40" align="center">'; - print_image('flags/' . strtolower($country) . '.png', $COUNTRIES[$country], FALSE, 'CLASS="flag"'); - echo '<br /></td>'; - echo '<td colspan="3"><b>' . $COUNTRIES[$country] . '</b><br /></td>'; - echo '</tr>' . "\n"; - } - - // Highlight this mirror if it is the current one - echo '<tr bgcolor="' . ($MYSITE == $murl ? '#ffffcc' : '#e0e0e0') . '">' . "\n"; - - // Print out caret (in bold if current mirror) - echo '<td bgcolor="#ffffff" align="right">'; - print_image( ($MYSITE == $murl ? 'caret-r.gif' : 'caret-rg.gif') ); - echo '<br /></td>' . "\n"; - - // Print out mirror site link - echo '<td><small>'; - $ps = strpos($murl, '//') + 2; - print_link($murl, substr($murl, $ps, -1)); - echo '</small><br /></td>' . "\n"; - - // Print out mirror provider's link - echo '<td><small>'; - print_link(mirror_provider_url($murl), mirror_provider($murl)); - echo '</small><br /></td>' . "\n"; - - // Print out search support information - echo '<td><small>'; - echo (have_search($murl) ? "with local search" : " "); - echo '</small><br /></td>' . "\n"; - - // End row for this mirror - echo "</tr>\n"; - - // Maintain previous country code - $prevcc = $country; -} - -?> -</table> -</div> - -<?php commonFooter(); ?> +mirror_list(); +commonFooter(); Index: phpweb/include/mirrortable.inc +++ phpweb/include/mirrortable.inc <?php /* $Id: mirrortable.inc,v 1.1 2003/05/04 11:22:13 goba Exp $ */ /* This file includes functions to find close mirrors and list the sites in to tables below each other. First is the close mirror's table (sites in the same country as the user), second is the other mirror's table. Include this file only if you are going to output a page which should list mirror sites. */ // If we have a valid country, and we have at least one mirror // in that country, provide some intro text and the list of // close mirrors, and other mirrors function mirror_list($df = '') { global $COUNTRY; // Valid country code present in $COUNTRY if (i2c_valid_country()) { // Count number of active mirrors in this country $close = count_mirrors($COUNTRY); // There is at least one close mirror if ($close > 0) { // Print out close mirrors' table $mnum = (($close > 1) ? "mirrors" : "mirror"); echo "<p>We have automatically detected the following $mnum to be close\n" . "to you. If you use a mirror close to you for downloads and\n" . "your usual daily work, you will get better response times.</p>\n"; mirror_table($df, $COUNTRY); // Print out table of other mirror sites echo "<p>Here is the list of all the other sites in case our detection\n" . "did something wrong, or the local mirror sites are busy.\n"; mirror_table($df, '', $COUNTRY); } else { mirror_table($df); } } else { mirror_table($df); } } // List mirrors, possibly restricted function mirror_table($df = '', $cmatch = '', $cnomatch = '') { global $MIRRORS, $COUNTRIES, $MYSITE; // Configure the table based on whether this is a download // table or a usual mirror listing table if (!empty($df)) { $cnf = array( 'width' => 500, 'virtual' => TRUE, 'datacols' => 2, 'download' => TRUE ); } else { $cnf = array( 'width' => 560, 'virtual' => FALSE, 'datacols' => 3, 'download' => FALSE ); } echo '<div align="center">' . "\n" . '<table border="0" cellpadding="3" cellspacing="1" width="' . $cnf['width'] . '">' . "\n"; // Previous mirror country code $prevcc = 'aa'; // Go through all mirror sites and print out information about them $MURLS = array_keys($MIRRORS); foreach ($MURLS as $murl) { // If the mirror is not all right or it is virtual (not an official mirror), skip it if (mirror_status($murl) != MIRROR_OK || (!$cnf['virtaul'] && mirror_type($murl) == MIRROR_VIRTUAL)) { continue; } // Get the country code and check if it is // matching the country provided (or does not // match the country, which it should not be) $country = mirror_country($murl); if (!empty($cmatch) && $country != $cmatch) { continue; } if (!empty($cnomatch) && $country == $cnomatch) { continue; } // Print out a country header, if a new country is found if ($prevcc != $country) { echo '<tr><td colspan="' . ($cnf['datacols'] + 1) . '"></td></tr>' . "\n"; echo '<tr bgcolor="#cccccc"><td width="40" align="center">'; print_image( 'flags/' . strtolower($country) . '.png', $COUNTRIES[$country], FALSE, 'CLASS="flag"' ); echo '<br /></td>'; echo '<td colspan="' . $cnf['datacols'] . '"><b>' . $COUNTRIES[$country] . '</b><br /></td>'; echo '</tr>' . "\n"; } // We print out a row for the current mirror $thismirror = ($MYSITE == $murl); // Highlight this mirror if it is the current one echo '<tr bgcolor="' . ($thismirror ? '#ffffcc' : '#e0e0e0') . '">' . "\n"; // Print out caret (in bold if current mirror) echo '<td bgcolor="#ffffff" align="right">'; print_image( ($thismirror ? 'caret-r.gif' : 'caret-rg.gif') ); echo '<br /></td>' . "\n"; // Get short name of the mirror site $mirrorshort = substr($murl, strpos($murl, '//') + 2, -1); // If this is a download table print out download links if ($cnf['download']) { // Print out mirror site download link echo '<td><small>'; $mirrorname = ($thismirror ? "this" : $mirrorshort); print_link("/get/$df/from/$mirrorname/mirror", $mirrorshort); echo '</small><br /></td>' . "\n"; // Print out mirror provider's name echo '<td><small>'; echo mirror_provider($murl); echo '</small><br /></td>' . "\n"; } // If this is a normal table, print out information else { // Print out mirror site link echo '<td><small>'; print_link($murl, $mirrorshort); echo '</small><br /></td>' . "\n"; // Print out mirror provider's link echo '<td><small>'; print_link(mirror_provider_url($murl), mirror_provider($murl)); echo '</small><br /></td>' . "\n"; // Print out search support information echo '<td><small>'; echo (have_search($murl) ? "with local search" : " "); echo '</small><br /></td>' . "\n"; } // End row for this mirror echo "</tr>\n"; // Maintain previous country code $prevcc = $country; } echo "</table>\n</div>"; }
Index: phpweb/get_download.php diff -u phpweb/get_download.php:1.21 phpweb/get_download.php:1.22 --- phpweb/get_download.php:1.21 Sun May 4 06:39:44 2003 +++ phpweb/get_download.php Sun May 4 07:22:13 2003 @@ -1,5 +1,6 @@ <?php include_once 'prepend.inc'; +include_once 'mirrortable.inc'; // Try to make this page non-cached header_nocache(); @@ -41,99 +42,8 @@ Please choose the mirror closest to you from which to download the file. The current mirror is highlighted in yellow, mirror sites detected to be out of date or disfunctional are not listed for your convenience. - +</p> + <?php - -// If we have a valid country, and we have at least one mirror -// in that country, provide some intro text and the list of mirrors -if (i2c_valid_country()) { - $close = count_mirrors($COUNTRY); - if ($close > 0) { - $mnum = (($close > 1) ? "mirrors" : "mirror"); - echo "We have automatically detected the following $mnum to be close\n" . - "to you. If you use a mirror close to you for downloads and\n" . - "your usual daily work, you will get better response times.</p>\n"; - mirror_list($COUNTRY); - echo "<p>Here is the list of all the other sites in case our detection\n" . - "did something wrong, or the local mirror sites are busy.\n"; - mirror_list('', $COUNTRY); - } else { echo "</p>\n"; mirror_list(); } -} else { echo "</p>\n"; mirror_list(); } - -// List mirrors for download with a possible country matching -function mirror_list($cmatch = '', $cnomatch = '') { - - global $MIRRORS, $MYSITE, $df, $COUNTRIES; - - // Print out start of the table centered - echo '<div align="center">' . "\n" . - '<table border="0" cellpadding="3" cellspacing="1" width="500">' . "\n"; - - // Maintain previous country code information - $prevcc = 'aa'; - - // Go through all mirror sites and print out download links - $MURLS = array_keys($MIRRORS); - foreach ($MURLS as $murl) { - - // If the mirror is not all right, skip it - // Virtual mirrors *are listed* here, because local unofficial - // mirrors can be used in this way for download. - if (mirror_status($murl) != MIRROR_OK) { continue; } - - // Get the country code and check if it is - // matching the country provided (or does not - // match the country, which it should not be) - $country = mirror_country($murl); - if (!empty($cmatch) && $country != $cmatch) { continue; } - if (!empty($cnomatch) && $country == $cnomatch) { continue; } - - // Print out a country header, if a new country is found - if ($prevcc != $country) { - echo '<tr><td colspan="3"></td></tr>' . "\n"; - echo '<tr bgcolor="#cccccc"><td width="40" align="center">'; - print_image( - 'flags/' . strtolower($country) . '.png', - $COUNTRIES[$country], - FALSE, - 'CLASS="flag"' - ); - echo '<br /></td>'; - echo '<td colspan="2"><b>' . $COUNTRIES[$country] . '</b><br /></td>'; - echo '</tr>' . "\n"; - } - - // We print out a line for the current mirror - $thismirror = ($MYSITE == $murl); - - // Highlight this mirror if it is the current one - echo '<tr bgcolor="' . ($thismirror ? '#ffffcc' : '#e0e0e0') . '">' . "\n"; - - // Print out caret (in bold if current mirror) - echo '<td bgcolor="#ffffff" align="right">'; - print_image( ($thismirror ? 'caret-r.gif' : 'caret-rg.gif') ); - echo '<br /></td>' . "\n"; - - // Print out mirror site download link - echo '<td><small>'; - $mirrorshort = substr($murl, strpos($murl, '//') + 2, -1); - $mirrorname = ($thismirror ? "this" : $mirrorshort); - print_link("/get/$df/from/$mirrorname/mirror", $mirrorshort); - echo '</small><br /></td>' . "\n"; - - // Print out mirror provider's name - echo '<td><small>'; - echo mirror_provider($murl); - echo '</small><br /></td>' . "\n"; - - // End row for this mirror - echo "</tr>\n"; - - // Maintain previous country code - $prevcc = $country; - } - - echo "</table>\n</div>\n"; -} - +mirror_list($df); commonFooter(); Index: phpweb/mirrors.php diff -u phpweb/mirrors.php:1.22 phpweb/mirrors.php:1.23 --- phpweb/mirrors.php:1.22 Thu Apr 24 03:01:54 2003 +++ phpweb/mirrors.php Sun May 4 07:22:13 2003 @@ -1,12 +1,13 @@ <?php include_once 'prepend.inc'; +include_once 'mirrortable.inc'; commonHeader("Mirror Sites"); ?> <h1>Mirror Sites</h1> <p> - Here you can find information about the mirrors of php.net. This table only + Here you can find information about the mirrors of php.net. This page only lists the official mirrors, registered in our database. The mirrors automatically detected to be outdated or disfunctional are not listed for your convinience, so there may be a mirror (or some mirrors) with problems in your country additionaly @@ -26,65 +27,6 @@ <?php print_link("/mirroring.php", "here's how"); ?>. </p> -<div align="center"> -<table border="0" cellpadding="3" cellspacing="1" width="560"> <?php - -// Previous mirror country code -$prevcc = 'aa'; - -// Go through all mirror sites and print out information about them -$MURLS = array_keys($MIRRORS); -foreach ($MURLS as $murl) { - - // If the mirror is not all right or it is virtual (not an official mirror), skip it - if (mirror_status($murl) != MIRROR_OK || mirror_type($murl) == MIRROR_VIRTUAL) { continue; } - - // Get country code, print out a - // country header, if it is a new one - $country = mirror_country($murl); - if ($prevcc != $country) { - echo '<tr><td colspan="4"></td></tr>' . "\n"; - echo '<tr bgcolor="#cccccc"><td width="40" align="center">'; - print_image('flags/' . strtolower($country) . '.png', $COUNTRIES[$country], FALSE, 'CLASS="flag"'); - echo '<br /></td>'; - echo '<td colspan="3"><b>' . $COUNTRIES[$country] . '</b><br /></td>'; - echo '</tr>' . "\n"; - } - - // Highlight this mirror if it is the current one - echo '<tr bgcolor="' . ($MYSITE == $murl ? '#ffffcc' : '#e0e0e0') . '">' . "\n"; - - // Print out caret (in bold if current mirror) - echo '<td bgcolor="#ffffff" align="right">'; - print_image( ($MYSITE == $murl ? 'caret-r.gif' : 'caret-rg.gif') ); - echo '<br /></td>' . "\n"; - - // Print out mirror site link - echo '<td><small>'; - $ps = strpos($murl, '//') + 2; - print_link($murl, substr($murl, $ps, -1)); - echo '</small><br /></td>' . "\n"; - - // Print out mirror provider's link - echo '<td><small>'; - print_link(mirror_provider_url($murl), mirror_provider($murl)); - echo '</small><br /></td>' . "\n"; - - // Print out search support information - echo '<td><small>'; - echo (have_search($murl) ? "with local search" : " "); - echo '</small><br /></td>' . "\n"; - - // End row for this mirror - echo "</tr>\n"; - - // Maintain previous country code - $prevcc = $country; -} - -?> -</table> -</div> - -<?php commonFooter(); ?> +mirror_list(); +commonFooter(); Index: phpweb/include/mirrortable.inc +++ phpweb/include/mirrortable.inc <?php /* $Id: mirrortable.inc,v 1.1 2003/05/04 11:22:13 goba Exp $ */ /* This file includes functions to find close mirrors and list the sites in to tables below each other. First is the close mirror's table (sites in the same country as the user), second is the other mirror's table. Include this file only if you are going to output a page which should list mirror sites. */ // If we have a valid country, and we have at least one mirror // in that country, provide some intro text and the list of // close mirrors, and other mirrors function mirror_list($df = '') { global $COUNTRY; // Valid country code present in $COUNTRY if (i2c_valid_country()) { // Count number of active mirrors in this country $close = count_mirrors($COUNTRY); // There is at least one close mirror if ($close > 0) { // Print out close mirrors' table $mnum = (($close > 1) ? "mirrors" : "mirror"); echo "<p>We have automatically detected the following $mnum to be close\n" . "to you. If you use a mirror close to you for downloads and\n" . "your usual daily work, you will get better response times.</p>\n"; mirror_table($df, $COUNTRY); // Print out table of other mirror sites echo "<p>Here is the list of all the other sites in case our detection\n" . "did something wrong, or the local mirror sites are busy.\n"; mirror_table($df, '', $COUNTRY); } else { mirror_table($df); } } else { mirror_table($df); } } // List mirrors, possibly restricted function mirror_table($df = '', $cmatch = '', $cnomatch = '') { global $MIRRORS, $COUNTRIES, $MYSITE; // Configure the table based on whether this is a download // table or a usual mirror listing table if (!empty($df)) { $cnf = array( 'width' => 500, 'virtual' => TRUE, 'datacols' => 2, 'download' => TRUE ); } else { $cnf = array( 'width' => 560, 'virtual' => FALSE, 'datacols' => 3, 'download' => FALSE ); } echo '<div align="center">' . "\n" . '<table border="0" cellpadding="3" cellspacing="1" width="' . $cnf['width'] . '">' . "\n"; // Previous mirror country code $prevcc = 'aa'; // Go through all mirror sites and print out information about them $MURLS = array_keys($MIRRORS); foreach ($MURLS as $murl) { // If the mirror is not all right or it is virtual (not an official mirror), skip it if (mirror_status($murl) != MIRROR_OK || (!$cnf['virtaul'] && mirror_type($murl) == MIRROR_VIRTUAL)) { continue; } // Get the country code and check if it is // matching the country provided (or does not // match the country, which it should not be) $country = mirror_country($murl); if (!empty($cmatch) && $country != $cmatch) { continue; } if (!empty($cnomatch) && $country == $cnomatch) { continue; } // Print out a country header, if a new country is found if ($prevcc != $country) { echo '<tr><td colspan="' . ($cnf['datacols'] + 1) . '"></td></tr>' . "\n"; echo '<tr bgcolor="#cccccc"><td width="40" align="center">'; print_image( 'flags/' . strtolower($country) . '.png', $COUNTRIES[$country], FALSE, 'CLASS="flag"' ); echo '<br /></td>'; echo '<td colspan="' . $cnf['datacols'] . '"><b>' . $COUNTRIES[$country] . '</b><br /></td>'; echo '</tr>' . "\n"; } // We print out a row for the current mirror $thismirror = ($MYSITE == $murl); // Highlight this mirror if it is the current one echo '<tr bgcolor="' . ($thismirror ? '#ffffcc' : '#e0e0e0') . '">' . "\n"; // Print out caret (in bold if current mirror) echo '<td bgcolor="#ffffff" align="right">'; print_image( ($thismirror ? 'caret-r.gif' : 'caret-rg.gif') ); echo '<br /></td>' . "\n"; // Get short name of the mirror site $mirrorshort = substr($murl, strpos($murl, '//') + 2, -1); // If this is a download table print out download links if ($cnf['download']) { // Print out mirror site download link echo '<td><small>'; $mirrorname = ($thismirror ? "this" : $mirrorshort); print_link("/get/$df/from/$mirrorname/mirror", $mirrorshort); echo '</small><br /></td>' . "\n"; // Print out mirror provider's name echo '<td><small>'; echo mirror_provider($murl); echo '</small><br /></td>' . "\n"; } // If this is a normal table, print out information else { // Print out mirror site link echo '<td><small>'; print_link($murl, $mirrorshort); echo '</small><br /></td>' . "\n"; // Print out mirror provider's link echo '<td><small>'; print_link(mirror_provider_url($murl), mirror_provider($murl)); echo '</small><br /></td>' . "\n"; // Print out search support information echo '<td><small>'; echo (have_search($murl) ? "with local search" : " "); echo '</small><br /></td>' . "\n"; } // End row for this mirror echo "</tr>\n"; // Maintain previous country code $prevcc = $country; } echo "</table>\n</div>"; }