Размер файла: 2.86Kb
<?php
session_start();
include "file/db.php";
include "file/config.php";
if($autorize)
include "style/".$autorize['skin']."/head.php";
else
include "style/".$wap_skin."/head.php";
echo "</center><div class='menu'><center><b>Акции</b></center></div><div class='tab'>";
if (empty($m)) $m="file";
switch ($m)
{
case 'file':
$num = $nummer;
if(empty($_GET['page']) || $_GET['page']<0)$_GET['page']=1;
$page = intval($_GET['page']);
$results = mysql_query('SELECT * FROM `action`;');
$posts = mysql_num_rows($results);
$total = intval(($posts-1)/$num)+1;
if($page>$total) $page = $total;
$start = $page*$num-$num;
$result = mysql_query("SELECT * FROM `action` ORDER BY `id` DESC LIMIT $start, $num;");
if(mysql_affected_rows()==0)
{
echo "<b>Акций нет...</b><br/>";
}
else
{
while($u = mysql_fetch_array($result))
{
print "<div class='hr'></div>";
if($autorize)
{
print "<img src=\"style/".$autorize['skin']."/icon.png\" alt=\"*\"/>";
}
else
{
print "<img src=\"style/".$wap_skin."/icon.png\" alt=\"*\"/> ";
}
print "<a href='action.php?m=go&id=".$u['id']."&".session_name()."=".session_id()."'>".base64_decode($u['name'])."</a><div class='hr'></div>";
}
print '<div class="str"><b>Стр:</b>';
$num_pages=ceil($posts/$num);
if($page>$num_pages || $page<1)
{
$page=1;
$start=0;
}
for($pr='', $i=1; $i<=$num_pages; $i++)
{
print $pr=(($i == 1 || $i == $num_pages || abs($i-$page) < 2) ? ($i == $page ? " <b>$i</b> " :
' <a href="'.$_SERVER['SCRIPT_NAME'].'?page='.$i.'&'.session_name().'='.session_id().'">'.$i.'</a> ') : (($pr == ' ... ' || $pr == '')? '' : ' ... '));
}
print "</div>";
}
break;
case 'go':
$time="14400"; // Смещение в секундах от Гринвича
$date=gmdate('d.m.Y H:i',time()+$time);
$res = mysql_query('SELECT * FROM `action` where `id`="'.$_GET['id'].'";');
$z = mysql_fetch_array($res);
print "<b><center>".base64_decode($z['name'])."</center></b><div class='hr'></div>";
print "".base64_decode($z['text'])."<div class='hr'></div>";
print "Начало акции: ".$z['timego']."<div class='hr'></div>";
print "Конец акции: ".$z['timekon']."<div class='hr'></div>";
if ($date==$z['timekon'] and $date>$z['timekon'])
{
print "Статус: <font color='red'>Завершена</font>";
}
else
{
print "Статус: <font color='green'>Активна</font>";
}
print "<div class='hr'></div>";
break;
}
if ($autorize)
{
echo "</div><img src=\"style/".$autorize['skin']."/home.png\" alt=\"*\"/>";echo "<a href=\"enter.php?".session_name()."=".session_id()."\">Панель</a><br/>\n";
include "style/".$autorize['skin']."/foot2.php";
}
else
{
echo "</div><img src=\"style/".$wap_skin."/home.png\" alt=\"*\"/>";echo "<a href=\"index.php?\">Главная</a><br/>\n";
include "style/".$wap_skin."/foot2.php";
}
?>