File size: 3.05Kb
<? $page_name="Админ-меню"; $dir="../"; include("../include/1.php"); require "../include/avto.php";
if(!isset($_SESSION['user_id']) or @$me['admin']!=3)exit("Нет доступа");
if(!isset($_GET['del']) && !isset($_GET['new']))
{$num = 10;
@$page = $_GET['page'];
$result00 = mysql_query("SELECT COUNT(*) FROM `shurik_ava`");
$temp = mysql_fetch_array($result00);
$posts = $temp[0];
$total = (($posts - 1) / $num) + 1;
$total = intval($total);
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$ava_1=mysql_query("select * from `shurik_ava` limit $start,$num");
$ava_2=mysql_fetch_array($ava_1);
do{echo "<div class=aa><img src=../images/ava/$ava_2[url]> - images/ava/$ava_2[url] - <a href=ava.php?del=$ava_2[id]>[удал]</a></div>";}
while($ava_2=mysql_fetch_array($ava_1));
//////////////////////////
$url_for_pstr="ava.php?page=";
if($page - 5 > 0) $page5left = ' <a href='.$url_for_pstr.($page - 5) .'>'. ($page - 5) .'</a> | ';
if($page - 4 > 0) $page4left = ' <a href='.$url_for_pstr.($page - 4) .'>'. ($page - 4) .'</a> | ';
if($page - 3 > 0) $page3left = ' <a href='.$url_for_pstr.($page - 3) .'>'. ($page - 3) .'</a> | ';
if($page - 2 > 0) $page2left = ' <a href='.$url_for_pstr.($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = ' <a href='.$url_for_pstr.($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 5 <= $total) $page5right = ' | <a href='.$url_for_pstr.($page + 5) .'>'. ($page + 5) .'</a>';
if($page + 4 <= $total) $page4right = ' | <a href='.$url_for_pstr.($page + 4) .'>'. ($page + 4) .'</a>';
if($page + 3 <= $total) $page3right = ' | <a href='.$url_for_pstr.($page + 3) .'>'. ($page + 3) .'</a>';
if($page + 2 <= $total) $page2right = ' | <a href='.$url_for_pstr.($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href='.$url_for_pstr.($page + 1) .'>'. ($page + 1) .'</a>';
if($page - 1 > 0) $nazad = '<a href='.$url_for_pstr.($page - 1) .'>Назад</a>';
if($page + 1 <= $total) $vpered = '<a href='.$url_for_pstr.($page + 1) .'>Далее</a>';
if ($total > 1)
{
Error_Reporting(E_ALL & ~E_NOTICE);
echo $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$page3right.$page4right.$page5right.$nextpage.'<br>'.$nazad.' | '.$vpered;
}
echo '<br/><a href=ava.php?new=1>Добавить аватар</a>';
}
if(isset($_GET['del']))
{$id=$_GET['del']; $delete=mysql_query("delete from `shurik_ava` where id=$id");
if($delete)echo "Аватара удалена";
else echo error("Аватара не удалена", '');}
if(isset($_GET['new']))
{if(!isset($_POST['url']))echo '<form action="ava.php?new=2" method="post">Адрес аватара<br/>/images/ava/<input name="url" type="text" /><input name="" type="submit" value="Создать" /></form>';
else {$url=$_POST['url']; $new_ava=mysql_query("insert into `shurik_ava` set `url`='$url'");
if($new_ava)echo "Аватара добавлена";
else echo error("Аватара не добавлена", '');}
}
echo '<br/><br/><a href=index.php>В админку</a>';
include("../include/2.php"); ?>