View file pages/smiles.php

File size: 2.47Kb
<?
include('../core/core.php');
include(BASEDIR.INC.'func.php');
include(BASEDIR.INC.'session.php');
include(BASEDIR.INC.'session_user.php');
$mode = htmlspecialchars($_GET['mode']);
include(BASEDIR.INC.'head.php');
show_title('Список смайлов');
 echo '<div class="razdel">Список смайлов</div>';
switch ($mode):
case 'index':
echo'<div class="menu"><b>Общие смайлы</b> | <a href="?mode=admsmiles">Админские смайлы</a></div><div class="menu">';
define('TOPAGE',10);
$page=(int)$_GET['page'];  
     
   $q=mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles` WHERE `smiles_cats`='1'"),0);  
      
    $total = intval(($q - 1) / TOPAGE) + 1;  
      
    if(empty($page) or $page < 0) $page = 1;  
      
    if($page > $total) $page = $total;  
      
    $start = $page * TOPAGE -TOPAGE;  

    $g=mysql_query("SELECT * FROM `smiles` WHERE `smiles_cats`='1' LIMIT $start,".TOPAGE."");  
while($u=mysql_fetch_array($g)){ 
echo'<img src="/'.IMG.'smiles/'.$u['smiles_name'].'"> - '.$u['smiles_code'].'<br />';
}  
if ($page != $total) $nextpage = ' <a href="?mode=index&page='. ($page + 1) .'">Далее</a>';  
if($page - 1 > 0) $pageback = '<a href="?mode=index&page='. ($page - 1) .'">Назад</a> ';  

echo'</div>';
echo''.$pageback.'  '.$nextpage.'';
break;
case 'admsmiles':
echo'<div class="menu"><a href="?mode=index">Общие смайлы</a> | <b>Админские смайлы</b></div><div class="menu">';
define('TOPAGE',10);
$page=(int)$_GET['page'];  
     
   $q=mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles` WHERE `smiles_cats`='2'"),0);  
      
    $total = intval(($q - 1) / TOPAGE) + 1;  
      
    if(empty($page) or $page < 0) $page = 1;  
      
    if($page > $total) $page = $total;  
      
    $start = $page * TOPAGE -TOPAGE;  

    $g=mysql_query("SELECT * FROM `smiles` WHERE `smiles_cats`='2' LIMIT $start,".TOPAGE."");  
while($u=mysql_fetch_array($g)){ 
echo'<img src="/'.IMG.'smiles2/'.$u['smiles_name'].'"> - '.$u['smiles_code'].'<br />';
}  
if ($page != $total) $nextpage = ' <a href="?mode=admsmiles&page='. ($page + 1) .'">Далее</a>';  
if($page - 1 > 0) $pageback = '<a href="?mode=admsmiles&page='. ($page - 1) .'">Назад</a> ';  

echo'</div>';
echo''.$pageback.'  '.$nextpage.'';
break;
default: 
header ('location: ?mode=index'); 
endswitch;
echo'<div class="menu"><a href="/">На главную</a></div>';
include(BASEDIR.INC.'foot.php');
?>