Просмотр файла smiles.php

Размер файла: 3.4Kb
<?php 
/*
smiles.php
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$userdata = session_pagestart($user_ip, $page_id);
init_userprefs($userdata);

if ( isset($HTTP_POST_VARS['start1']) )
{
   $start1 = abs(intval($HTTP_POST_VARS['start1']));
   $start = (($start1 - 1) * $board_config['topics_per_page']);
} 
else 
{
   $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
   $start = ($start < 0) ? 0 : $start;
}
$page_title = 'Смайлики';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

switch($_GET['mod'])
{
  case'show':
       $id = abs(intval($_GET['id']));
       $q = mysql_query('SELECT `id`,`cat_title` FROM `'.$table_prefix.'smilies_cat` WHERE `id`='.$id);
       $q1 = mysql_fetch_assoc($q);
       if(!mysql_num_rows($q) || empty($id))
       {
            message_die(GENERAL_MESSAGE, 'Категория не существует');
       }

       $sql = "SELECT COUNT(smilies_id) as total FROM `".$table_prefix."smilies` WHERE `smile_cat` = '$id'";
       if ( !($result = $db->sql_query($sql)))
       {
            message_die(GENERAL_ERROR, 'Could not query private message information', '', __LINE__, __FILE__, $sql);
       }
       $smile_count = $db->sql_fetchrow($result);
       if ($smile_count['total'] > $board_config['topics_per_page'])
       {
             $pagination = generate_pagination("smiles.$phpEx?mod=show&id=$id", $smile_count['total'], $board_config['topics_per_page'], $start);
       }
       if($smile_count['total']!=0)
       {
             $sql = "SELECT  * FROM " . SMILIES_TABLE . " WHERE `smile_cat` = '$id' ORDER BY `smilies_id`	
                     LIMIT " . $start . ", " . $board_config['topics_per_page'];
             $template->set_filenames(array(
	     'smiliesbody' => 'posting_smilies_show.tpl')
              );	
             $template->assign_vars(array(
             'CAT_TITLE' => $q1['cat_title'],
             'PAGINATION' => $pagination)
              );
       if ($result = $db->sql_query($sql))
        {
                while ($row = $db->sql_fetchrow($result))
                {
                    $template->assign_block_vars('smilies_row', array(
                    'SM_URL' => '<img src="' .$board_config['smilies_path'] . '/'.$row['smile_url'].'" alt="'.$row['code'].'"/></a> '.$row['code'])
                    );
                }
        }
       }
       else
       {
             message_die(GENERAL_MESSAGE, 'Категория пуста');
       }
   $template->pparse('smiliesbody');
   break;

   default:
   $sql = "SELECT * FROM `".$table_prefix."smilies_cat` ORDER BY id ASC ";
   $template->set_filenames(array(
	  'body' => 'posting_smilies_body.tpl')
   );	

   if ($result = $db->sql_query($sql))
   {
        while ($row = $db->sql_fetchrow($result))
        {
          $cat_sm = mysql_result(mysql_query("SELECT COUNT(*) FROM `".$table_prefix."smilies` WHERE `smile_cat` = '".$row['id']."' "), 0);
          $template->assign_block_vars('catrow', array(
                  'CAT_LIST' => '<a href="?mod=show&id='.$row['id'].'">'.$row['cat_title'] .'</a>',
                  'SM_CAT' => $cat_sm)
                  );
        }
   }
  $template->pparse('body');
break;
}
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>