- <?php
- /**
- * @package uForum
- * @file includes/cache/cache_topic.php
- * @version $Id$
- * @copyright 2009(c) PioDer <pioder@wp.pl>
- * @link http://pioder.gim2przemysl.int.pl/
- * @license GNU GPL v3
- **/
- if(!defined('IN_uF'))
- {
- die('Hacking attempt');
- }
- //||topic.php script cache ------------------------------------------------------------------------------
- $sql = "SELECT ".TOPICS_TABLE.".*, ".TOPICS_TABLE.".name AS topic_name, ".TOPICS_TABLE.".lock AS topic_lock, ".FORUMS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".FORUMS_TABLE." ON ".TOPICS_TABLE.".f_id = ".FORUMS_TABLE.".f_id WHERE `t_id`='$tid' LIMIT 1";
- $result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
- if ($result['t_id']=='')
- {
- message_forum($lng['no_topic'], 'index.php');
- }
- $topic['name']=$result['topic_name'];
- $topic['lock']=$result['topic_lock'];
- $topic['sticky']=$result['sticky'];
- $topic['f_id']=$result['f_id'];
- $fid = $topic['f_id'];
- $forum['name']=$result['name'];
- $forum['lock']=$result['lock'];
- $forum['moderate']=$result['moderate'];
-
-
- $sql = "SELECT `u_id`,`value` FROM `".WARNINGS_TABLE."`";
- $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user warns information');
- $result = DataBase::num_rows($query);
- while ($result = DataBase::fetch($query))
- {
- if(!isset($user_warnlevel[$result['u_id']]))
- {
- $user_warnlevel[$result['u_id']]=0;
- }
- if ($result['value']=='-')
- {
- $user_warnlevel[$result['u_id']] -=1;
- }
- else
- {
- $user_warnlevel[$result['u_id']] +=1;
- }
- }
-
- //check online for user
- $sql = "SELECT `s_id`, `u_id`, `time` FROM ".SESSIONS_TABLE." WHERE time+1250>".time();
- $query = DataBase::sql_query($sql, 'GENERAL', 'Could not read user active.');
- while($result = DataBase::fetch($query))
- {
- $user[$result['u_id']]['online']='1';
- }
- unset($sql, $query, $result);
- //
- //generate output pages
- //
- if ($_SESSION['uid']>0)
- {
- $limiter = $userdata['limit_tpid'];
- }
- else
- {
- $limiter = $forum_config['limit_tpid'];
- }
- if (isset($_GET['page'])&&($_GET['page']!=1))
- {
- if (!is_numeric($_GET['page']))
- {
- die('Hacking attempt');
- }
- $value = ($_GET['page']-1)*$limiter;
- $limit = 'LIMIT '.$value . ', '.$limiter;
- $page = $_GET['page'];
- }
- else
- {
- $limit = 'LIMIT 0, '.$limiter;
- $page=1;
- }
- $count = DataBase::fetch(DataBase::sql_query("SELECT COUNT(`p_id`) as `p_id`
- FROM ".POSTS_TABLE." WHERE `t_id`='$tid'",'GENERAL','Could not obtain count amout of posts'));
- $count = $count['p_id'];
- $count = ceil($count / $limiter);
- if(isset($_GET['page']) && ($_GET['page']>$count))
- {
- message_forum($lng['invalidpage'],'index.php');
- }
- //
- //end generating pages
- //
- ?>
|