View file top100.php

File size: 2.25Kb
<?php
require('includes/header.php');
require('includes/config.php');
require('includes/db.php');

$sites_per_page = 10;
?>
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="top100" title="Top100">
<do type="prev" label="&#x041D;&#x0430;&#x0437;&#x0430;&#x0434;"><prev/></do>
<p>
<?php
   if(isset($_GET['from']))
      $from = $_GET['from'];
   else
      $from = 0;

   if(isset($_GET['sort']))
      $sort = $_GET['sort'];
   else
      $sort = 0;

   $date = date('Y-m-d');
   mysql_query("UPDATE counter SET today = 0 WHERE last_date < '$date'");

   $sites = mysql_query('SELECT count(*) FROM counter');
   list($total_sites) = mysql_fetch_array($sites);
   if($total_sites > 100)
      $total_sites = 100;
   $total_pages = ceil($total_sites / $sites_per_page);

   if($sort == 0)
      $sites = mysql_query('SELECT id, today, total FROM counter ORDER BY total DESC LIMIT ' . $from*$sites_per_page . ', ' . $sites_per_page);
   else
      $sites = mysql_query('SELECT id, today, total FROM counter ORDER BY today DESC LIMIT ' . $from*$sites_per_page . ', ' . $sites_per_page);

   $sites_list = '';
   while($site = mysql_fetch_array($sites, MYSQL_ASSOC))
   {
      $site_names = mysql_query('SELECT login FROM users WHERE id = "' . $site['id'] . '"');
      list($site_name) = mysql_fetch_array($site_names);

      $sites_list .= "<a href=\"http://$site_name.$server_name\">$site_name.$server_name</a><br/>Всего посещений: $site[total], сегодня: $site[today]\n<br/>\n";
   }

?>
Сортировка: <a href="top100.php?from=<?php echo $from; ?>&amp;sort=0">Всего</a> <a href="top100.php?from=<?php echo $from; ?>&amp;sort=1">Сегодня</a>
<br/>
 &#x0421;&#x0442;&#x0440;. <?php if($total_pages != 0) echo $from+1; else echo '0'; ?> &#x0438;&#x0437; <?php echo $total_pages; ?><br/>
<?php echo $sites_list; ?>
<br/>
<?php
if(($from+1) != $total_pages)
{
   echo "<a href=\"top100.php?from=" . ($from+1) . "&amp;sort=" . $sort . "\">Далее</a>";
   echo "<br/>";
}

if($from != 0)
{
   echo "<a href=\"top100.php?from=" . ($from-1) . "&amp;sort=" . $sort . "\">Назад</a>";
   echo "<br/>";
}

?>
</p>
<p align="center">
</p>
</card>
</wml>