diff options
-rw-r--r-- | news.php | 25 | ||||
-rw-r--r-- | versions.php | 28 |
2 files changed, 29 insertions, 24 deletions
@@ -8,22 +8,21 @@ $agent = $_SERVER['HTTP_USER_AGENT']; if (substr($agent, 0, 3) == "TMW") { - file_put_contents('versions.txt', "$agent\n", FILE_APPEND); + $file = 'versions/' . date('Y-m-d') . '.txt'; + touch($file); + file_put_contents($file, '[' . date('H:i') . "] $agent\n", FILE_APPEND); } -if ($agent == "TMW/0.0.23") -{ - echo "##1 The client you're using is no longer\n". - "##1 supported! Please upgrade to 0.0.25 or\n". - "##1 higher!\n \n"; -} -else if ($agent == "TMW/0.0.24" || - $agent == "TMW/0.0.24.1") +$old_versions = array("TMW/0.0.23", "TMW/0.0.24", "TMW/0.0.24.1"); +$min_version = '0.0.25'; + +if (array_search($agent, $old_versions) !== FALSE) // Explicit check for saftey { - echo "##1 On Monday, November 3rd, support for your\n". - "##1 client version will be dropped. Please\n". - "##1 upgrade to 0.0.25 or later!\n \n TMW Staff\n \n"; + echo "##1 The client you're using is no longer\n". + "##1 supported! Please upgrade to $min_version or\n". + "##1 higher!\n \n". + "##1 TMW Staff\n \n"; } -print file_get_contents ("news.txt"); +print file_get_contents("news.txt"); ?> diff --git a/versions.php b/versions.php index 3b2729de..c805f77e 100644 --- a/versions.php +++ b/versions.php @@ -1,19 +1,25 @@ <?php -$versions = file('versions.txt'); +$file = 'versions/' . date('Y-m-d') . '.txt'; +if (!file_exists($file)) touch($file); // Make sure it exists + +$versions = file($file); $verinfo = array(); -foreach($versions as $ver) { - if ($verinfo[$ver] != null) { - $verinfo[$ver]++; - } else { - $verinfo[$ver] = 1; - } +foreach($versions as $version) { + $ver = substr($version, 8); // Ignore time information + if ($verinfo[$ver] != null) { + $verinfo[$ver]++; + } else { + $verinfo[$ver] = 1; + } } + arsort($verinfo); + $total = count($versions); -echo '<table border="1px" cellspacing="0px"><tr><th>Client</th><th>No.</th><th>%</th></tr>'; +print '<table border="1px" cellspacing="0px" cellpadding="1px"><tr><th>Client</th><th title="Count">n</th><th title="Percent of total">%</th></tr>'; foreach($verinfo as $vi=>$vc) { - echo '<tr><td>' . $vi . '</td><td>' . $vc . '</td><td>' . round((100/$total)*$vc,2) . '</td></tr>'; + echo '<tr><td>' . $vi . '</td><td>' . $vc . '</td><td>' . round((100 / $total) * $vc, 2) . '</td></tr>'; } -echo '</table><br />Total number of connections: ' . $total . '<br />Number of different clients reported: ' - . count($verinfo) . '<br /><br />Data retrieved: ' . date('D M d y, g:i a T', filemtime('versions.txt')); +print '</table><br />Total number of connections: ' . $total . '<br />Number of different clients reported: ' + . count($verinfo) . '<br /><br />Data retrieved: ' . date('D M d y, g:i a T', filemtime($file)); ?>
\ No newline at end of file |