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.
 
 
 
 
 
 

83 lines
2.4 KiB

<?php
/**
* @package uForum
* @file includes/cache/cache_forums.php
* @version $Id$
* @copyright 2009(c) PioDer <[email protected]>
* @link http://pioder.gim2przemysl.int.pl/
* @license GNU GPL v3
**/
if(!defined('IN_uF'))
{
die('Hacking attempt');
}
//cache forums and posts - version v1.0 Alpha 2---------------------------------
$default_skin = ViewSkinName();
$sql = "SELECT `name`,`lock` FROM ".FORUMS_TABLE." WHERE `f_id`='$fid' LIMIT 1";
$result = @mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
if ($result['name']=='')
{
message_forum($lng['no_forum'],'index.php');
}
$forum = array(
'name'=>$result['name'],
'lock'=>$result['lock']
);
$sql = "SELECT COUNT(*) as `p_id`, `t_id` FROM ".POSTS_TABLE." GROUP BY `t_id`";
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in forum');
while($result = @mysql_fetch_array($query))
{
$count_topic[$result['t_id']]=$result['p_id'];
}
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `f_id`='$fid' ORDER BY `ptime`";
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in forum');
while($result = @mysql_fetch_array($query))
{
$lastpost[$result['t_id']]['tp_id']=$result['tp_id'];
$lastpost[$result['t_id']]['u_id']=$result['u_id'];
$lastpost[$result['t_id']]['time']=$result['ptime'];
$lastpost[$result['t_id']]['user_nick']=$result['nick'];
$lastpost[$result['t_id']]['user_rank']=$result['rank'];
}
//
//generate output pages
//
if ($_SESSION['uid']>0)
{
$limiter = $userdata['limit_ftid'];
}
else
{
$limiter = $forum_config['limit_ftid'];
}
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 = @mysql_fetch_array(DataBase::sql_query("SELECT COUNT(`t_id`) as `t_id`
FROM ".TOPICS_TABLE." WHERE `f_id`='$fid'",'GENERAL','Could not obtain count amout of topics'));
$count = $count['t_id'];
$count = ceil($count / $limiter);
if ($count==0)
{
$count +=1;
}
if(isset($_GET['page']) && ($_GET['page']>$count))
{
message_forum($lng['invalidpage'],'index.php');
}
//
//end generating pages
//
?>