File size: 3.21Kb
<? $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_smile`");
$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_smile` limit $start,$num");
$ava_2=mysql_fetch_array($ava_1);
do{echo "<div class=aa><img src=../images/smile/$ava_2[url]> - $ava_2[text] - <a href=smile.php?del=$ava_2[id]>[удал]</a></div>";}
while($ava_2=mysql_fetch_array($ava_1));
//////////////////////////
$url_for_pstr="smile.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=smile.php?new=1>Добавить смайл</a>';
}
if(isset($_GET['del']))
{$id=$_GET['del']; $delete=mysql_query("delete from `shurik_smile` where id=$id");
if($delete)echo "Смайл удален";
else echo error("Смайл не удален", '');}
if(isset($_GET['new']))
{if(!isset($_POST['url']) and !isset($_POST['text']))echo '<form action="smile.php?new=2" method="post"><div class=aa>Адрес смайла<br/>/images/smile/<input name="url" type="text" /></div><div class=aa>Текст смайла(что заменять)<input name="text" type="text"></div><input name="" type="submit" value="Создать" /></form>';
else {$url=$_POST['url'];$text=$_POST['text']; $new_ava=mysql_query("insert into `shurik_smile` set `url`='$url', text='$text'");
if($new_ava)echo "Смайл добавлен";
else echo error("Смайл не добавлен", '');}
}
echo '<br/><br/><a href=index.php>В админку</a>';
include("../include/2.php"); ?>