A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
2.7 KiB

<?php
/**
* @package uForum
* @file includes/cache/cache_topic.php
* @version $Id$
* @copyright 2007-2010 (c) PioDer <[email protected]>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
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 = array(
'name' => $result['topic_name'],
'lock' => $result['topic_lock'],
'sticky' => $result['sticky'],
'f_id' => $result['f_id']
);
$forum = array(
'name' => $result['name'],
'lock' => $result['lock'],
'moderate' => $result['moderate']
);
$fid = $topic['f_id'];
//user warnings level
$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
//
?>