+ Added 2 new functions in DataBase class: fetch($query) and num_rows($query)
git-svn-id: https://svn.pioder.pl/uf-svn/uF@20 72ec579a-5ced-4fa4-82f3-afba5d98df2f
$sql="SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
$sql="SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
$last=@mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum sort id'));
$last=DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum sort id'));
$sort=$last['sort'];
$sort=$last['sort'];
$sort=$sort+1;
$sort=$sort+1;
$sql="SELECT `f_id` FROM `".FORUMS_TABLE."` ORDER BY `f_id` DESC LIMIT 1";
$sql="SELECT `f_id` FROM `".FORUMS_TABLE."` ORDER BY `f_id` DESC LIMIT 1";
$last=@mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum id'));
$last=DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum id'));
$last=$last['f_id'];
$last=$last['f_id'];
$last=$last+1;
$last=$last+1;
$sql="INSERT INTO `".FORUMS_TABLE."` VALUES ('$last','$forum_lock','$allow_moderate', '$forum_name', '$forum_desc','$forum_cat','$sort')";
$sql="INSERT INTO `".FORUMS_TABLE."` VALUES ('$last','$forum_lock','$allow_moderate', '$forum_name', '$forum_desc','$forum_cat','$sort')";
@ -243,13 +243,13 @@ switch($_GET['mode'])
{
{
$i1=$_GET['c'];
$i1=$_GET['c'];
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
$s1=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s1=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s1=$s1['sort'];
$s1=$s1['sort'];
$s2=$s1-1;
$s2=$s1-1;
if($s1>1)
if($s1>1)
{
{
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
$s2=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s2=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$i2=$s2['c_id'];
$i2=$s2['c_id'];
$s2=$s2['sort'];
$s2=$s2['sort'];
$sql="UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
$sql="UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
@ -266,14 +266,14 @@ switch($_GET['mode'])
{
{
$i1=$_GET['f'];
$i1=$_GET['f'];
$sql="SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
$sql="SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
$s1=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$s1=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$cid=$s1['c_id'];
$cid=$s1['c_id'];
$s1=$s1['sort'];
$s1=$s1['sort'];
$s2=$s1-1;
$s2=$s1-1;
if($s1>1)
if($s1>1)
{
{
$sql="SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2' AND `c_id`='$cid'";
$sql="SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2' AND `c_id`='$cid'";
$s2=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not forum forum information.'));
$s2=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not forum forum information.'));
$i2=$s2['f_id'];
$i2=$s2['f_id'];
$s2=$s2['sort'];
$s2=$s2['sort'];
$sql="UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
$sql="UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
@ -306,15 +306,15 @@ switch($_GET['mode'])
$i1=$_GET['c'];
$i1=$_GET['c'];
$i2=$i1+1;
$i2=$i1+1;
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
$s1=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s1=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s1=$s1['sort'];
$s1=$s1['sort'];
$s2=$s1+1;
$s2=$s1+1;
$sql="SELECT `c_id` FROM ".CATS_TABLE;
$sql="SELECT `c_id` FROM ".CATS_TABLE;
$count=@mysql_num_rows(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$count=DataBase::num_rows(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
if($s1<$count)
if($s1<$count)
{
{
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
$sql="SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
$s2=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s2=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$i2=$s2['c_id'];
$i2=$s2['c_id'];
$s2=$s2['sort'];
$s2=$s2['sort'];
$sql="UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
$sql="UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
@ -332,16 +332,16 @@ switch($_GET['mode'])
$i1=$_GET['f'];
$i1=$_GET['f'];
$i2=$i1+1;
$i2=$i1+1;
$sql="SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
$sql="SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
$s1=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$s1=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$cid=$s1['c_id'];
$cid=$s1['c_id'];
$s1=$s1['sort'];
$s1=$s1['sort'];
$s2=$s1+1;
$s2=$s1+1;
$sql="SELECT `f_id` FROM ".FORUMS_TABLE." WHERE `c_id`='$cid'";
$sql="SELECT `f_id` FROM ".FORUMS_TABLE." WHERE `c_id`='$cid'";
$count=@mysql_num_rows(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$count=DataBase::num_rows(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
if($s1<$count)
if($s1<$count)
{
{
$sql="SELECT `sort`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2'";
$sql="SELECT `sort`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2'";
$s2=@mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$s2=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$i2=$s2['f_id'];
$i2=$s2['f_id'];
$s2=$s2['sort'];
$s2=$s2['sort'];
$sql="UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
$sql="UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
@ -369,11 +369,11 @@ switch($_GET['mode'])
$cid=intval($_GET['c']);
$cid=intval($_GET['c']);
$sql="SELECT * FROM `".CATS_TABLE."` WHERE `c_id`='$cid'";
$sql="SELECT * FROM `".CATS_TABLE."` WHERE `c_id`='$cid'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain category information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain category information');
$result=@mysql_fetch_array($query);
$result=DataBase::fetch($query);
$sort=$result['sort'];
$sort=$result['sort'];
$sql="SELECT * FROM `".CATS_TABLE."` WHERE `sort`>'$sort'";
$sql="SELECT * FROM `".CATS_TABLE."` WHERE `sort`>'$sort'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain categories information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain categories information');
while($item=@mysql_fetch_array($query))
while($item=DataBase::fetch($query))
{
{
$new_sort=$item['sort']-1;
$new_sort=$item['sort']-1;
$cid2=$item['c_id'];
$cid2=$item['c_id'];
@ -382,7 +382,7 @@ switch($_GET['mode'])
}
}
$sql="SELECT `f_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cid'";
$sql="SELECT `f_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cid'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forum information.');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forum information.');
while($item=@mysql_fetch_array($query))
while($item=DataBase::fetch($query))
{
{
$fid=$item['f_id'];
$fid=$item['f_id'];
$sql="DELETE FROM `".POSTS_TABLE."` WHERE `f_id`='$fid'";
$sql="DELETE FROM `".POSTS_TABLE."` WHERE `f_id`='$fid'";
@ -403,11 +403,11 @@ switch($_GET['mode'])
$fid=intval($_GET['f']);
$fid=intval($_GET['f']);
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forum information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forum information');
$result=@mysql_fetch_array($query);
$result=DataBase::fetch($query);
$sort=$result['sort'];
$sort=$result['sort'];
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `sort`>'$sort'";
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `sort`>'$sort'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forums information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forums information');
while($item=@mysql_fetch_array($query))
while($item=DataBase::fetch($query))
{
{
$new_sort=$item['sort']-1;
$new_sort=$item['sort']-1;
$fid1=$item['f_id'];
$fid1=$item['f_id'];
@ -439,7 +439,7 @@ switch($_GET['mode'])
{
{
$cat_name=strip_tags($_POST['cat_name']);
$cat_name=strip_tags($_POST['cat_name']);
$sql="SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cat_name' ORDER BY `sort` DESC LIMIT 1";
$sql="SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cat_name' ORDER BY `sort` DESC LIMIT 1";
$last=@mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum sort id'));
$last=DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum sort id'));
$sort=$last['sort'];
$sort=$last['sort'];
$sort=$sort+1;
$sort=$sort+1;
$sql="UPDATE `".CATS_TABLE."` SET `name`='$cat_name', `sort`='$sort' WHERE `c_id`='$cid'";
$sql="UPDATE `".CATS_TABLE."` SET `name`='$cat_name', `sort`='$sort' WHERE `c_id`='$cid'";
@ -455,7 +455,7 @@ switch($_GET['mode'])
}
}
else
else
{
{
$tmp=mysql_fetch_array(DataBase::sql_query("SELECT `name` FROM `".CATS_TABLE."` WHERE `c_id`='$cid'",'GENERAL','Could not obtain category information'));
$tmp=DataBase::fetch(DataBase::sql_query("SELECT `name` FROM `".CATS_TABLE."` WHERE `c_id`='$cid'",'GENERAL','Could not obtain category information'));
$tmp=$tmp['name'];
$tmp=$tmp['name'];
$_POST['cat_name']=$tmp;
$_POST['cat_name']=$tmp;
if($tmp['name']=='')
if($tmp['name']=='')
@ -496,14 +496,14 @@ switch($_GET['mode'])
$forum_cat=$_POST['forum_cat'];
$forum_cat=$_POST['forum_cat'];
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forum information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forum information');
$result=@mysql_fetch_array($query);
$result=DataBase::fetch($query);
$actual_cid=$result['c_id'];
$actual_cid=$result['c_id'];
$sort=$result['sort'];
$sort=$result['sort'];
if($actual_cid!=$forum_cat)
if($actual_cid!=$forum_cat)
{
{
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
$sql="SELECT * FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forums information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain forums information');
$result=@mysql_fetch_array($query);
$result=DataBase::fetch($query);
$sort=$result['sort']+1;
$sort=$result['sort']+1;
}
}
@ -535,7 +535,7 @@ switch($_GET['mode'])
}
}
else
else
{
{
$tmp=mysql_fetch_array(DataBase::sql_query("SELECT `name`, `desc` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'",'GENERAL','Could not obtain forum information'));
$tmp=DataBase::fetch(DataBase::sql_query("SELECT `name`, `desc` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'",'GENERAL','Could not obtain forum information'));
$sql="SELECT ".TOPICS_TABLE.".*, ".USERS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".TOPICS_TABLE.".author = ".USERS_TABLE.".u_id WHERE f_id='$fid' ORDER BY `sticky` DESC, `lastpost_time` DESC $limit;";
$sql="SELECT ".TOPICS_TABLE.".*, ".USERS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".TOPICS_TABLE.".author = ".USERS_TABLE.".u_id WHERE f_id='$fid' ORDER BY `sticky` DESC, `lastpost_time` DESC $limit;";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain topics information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain topics information');
$sql="SELECT ".USERS_GROUP_TABLE.".*, ".USERS_TABLE.".* FROM `".USERS_GROUP_TABLE."` LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id =".USERS_GROUP_TABLE.".u_id WHERE `g_id`='$gid'";
$sql="SELECT ".USERS_GROUP_TABLE.".*, ".USERS_TABLE.".* FROM `".USERS_GROUP_TABLE."` LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id =".USERS_GROUP_TABLE.".u_id WHERE `g_id`='$gid'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain users in groups information.');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain users in groups information.');
//cache forums and posts - version v1.0 Alpha 2---------------------------------
//cache forums and posts - version v1.0 Alpha 2---------------------------------
$default_skin=ViewSkinName();
$default_skin=ViewSkinName();
$sql="SELECT `name`,`lock` FROM ".FORUMS_TABLE." WHERE `f_id`='$fid' LIMIT 1";
$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'));
$result=DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
if($result['name']=='')
if($result['name']=='')
{
{
message_forum($lng['no_forum'],'index.php');
message_forum($lng['no_forum'],'index.php');
@ -25,13 +25,13 @@ $forum = array(
);
);
$sql="SELECT COUNT(*) as `p_id`, `t_id` FROM ".POSTS_TABLE." GROUP BY `t_id`";
$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');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in forum');
while($result=@mysql_fetch_array($query))
while($result=DataBase::fetch($query))
{
{
$count_topic[$result['t_id']]=$result['p_id'];
$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`";
/*$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');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in forum');
//cache forums and posts - version v1.0 Alpha 2---------------------------------
//cache forums and posts - version v1.0 Alpha 2---------------------------------
//
//
//lastpost in forum cache
//lastpost in forum cache
/*$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".POSTS_TABLE.".u_id = ".USERS_TABLE.".u_id GROUP BY `f_id`, `ptime` ORDER BY `ptime`";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain last post in topic',true);
$sql="SELECT ".FORUMS_TABLE.".*, COUNT(".POSTS_TABLE.".p_id) as amout, ".POSTS_TABLE.".f_id AS count FROM ".FORUMS_TABLE." LEFT JOIN ".POSTS_TABLE." ON ".FORUMS_TABLE.".f_id= ".POSTS_TABLE.".f_id GROUP BY `f_id` ORDER BY `c_id`, `sort`";
$sql="SELECT ".FORUMS_TABLE.".*, COUNT(".POSTS_TABLE.".p_id) as amout, ".POSTS_TABLE.".f_id AS count FROM ".FORUMS_TABLE." LEFT JOIN ".POSTS_TABLE." ON ".FORUMS_TABLE.".f_id= ".POSTS_TABLE.".f_id GROUP BY `f_id` ORDER BY `c_id`, `sort`";
$query=DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.');
$query=DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.');
$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";
$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=@mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
$result=DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
$query=DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
$query=DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
while($t=@mysql_fetch_array($query))
while($t=DataBase::fetch($query))
{
{
if($t['name']==$default_skin)
if($t['name']==$default_skin)
@ -278,7 +278,7 @@ function TotalPosts()
{
{
$sql="SELECT count(*) as `p_id` FROM ".POSTS_TABLE."";
$sql="SELECT count(*) as `p_id` FROM ".POSTS_TABLE."";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
$result=mysql_fetch_array($query);
$result=DataBase::fetch($query);
$result=$result['p_id'];
$result=$result['p_id'];
return($result);
return($result);
@ -338,15 +338,13 @@ function ViewSkinName()
$result=$forum_config['defaultskin'];
$result=$forum_config['defaultskin'];
}
}
$sql="SELECT * FROM `".SKINS_TABLE."` WHERE `s_id`='$result'";
$sql="SELECT * FROM `".SKINS_TABLE."` WHERE `s_id`='$result'";
$result=mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain skin information.'));
$result=DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain skin information.'));
return$result['name'];
return$result['name'];
}
}
functionGenerateLastPost($id,$type)
functionGenerateLastPost($id,$type)
{
$last_post='';
{
switch($type)
switch($type)
{
{
/**fieldlastpostinforumformat
/**fieldlastpostinforumformat
@ -356,8 +354,8 @@ function GenerateLastPost($id, $type)
{
{
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".POSTS_TABLE.".u_id = ".USERS_TABLE.".u_id WHERE `f_id`='$id' ORDER BY `ptime` LIMIT 1";
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".POSTS_TABLE.".u_id = ".USERS_TABLE.".u_id WHERE `f_id`='$id' ORDER BY `ptime` LIMIT 1";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain last post in forum',true);
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain last post in forum',true);
$post_count=@mysql_num_rows($query);
$result=mysql_fetch_array($query);
$post_count=DataBase::num_rows($query);
$result=DataBase::fetch($query);
$last_post.=$result['tp_id'];
$last_post.=$result['tp_id'];
$last_post.=':';
$last_post.=':';
@ -385,7 +383,55 @@ function GenerateLastPost($id, $type)
{
{
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` LIMIT 1";
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` LIMIT 1";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in topic');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in topic');
$result=mysql_fetch_array($query);
$result=DataBase::fetch($query);
$last_post.=$result['tp_id'];
$last_post.=':';
$last_post.=$result['u_id'];
$last_post.=':';
$last_post.=$result['ptime'];
$last_post.=':';
$last_post.=$result['rank'];
$last_post.=':';
$last_post.=$result['nick'];
$sql="UPDATE ".TOPICS_TABLE." SET
`lastpost`='$last_post'
WHERE`t_id`='$id'";
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in topic');
break;
}
}
}
functionGeneratePosts($id,$type)
{
switch($type)
{
case1://for forum
{
$sql="SELECT COUNT (`p_id`) AS 'count', `f_id` FROM ".POSTS_TABLE." WHERE `f_id`='$id'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain posts in forum',true);
$post_count=DataBase::num_rows($query);
$result=DataBase::fetch($query);
$posts=$result['count'];
$sql="UPDATE ".FORUMS_TABLE." SET
`posts`='$last_post'
WHERE`f_id`='$id'";
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in forum');
break;
}
/**fieldlastpostintopicformat
tp_id:u_id:ptime:rank:nick
*/
case2://for topic
{
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` LIMIT 1";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in topic');
$sql="INSERT INTO ".SESSIONS_TABLE." VALUES ('', '".$_COOKIE[SESS_NAME]."','$uid','$time')";
$sql="INSERT INTO ".SESSIONS_TABLE." VALUES ('', '".$_COOKIE[SESS_NAME]."','$uid','$time')";
$result=@mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not add new session.',true));
return$result;
$query=DataBase::sql_query($sql,'GENERAL','Could not add new session.',true);
if(DataBase::num_rows($query)>0)
{
$result=DataBase::fetch();
return$result;
}
else
{
returnfalse;
}
}
}
}
}
@ -76,7 +84,7 @@ function SessDelInvalid()
{
{
$sql="SELECT `session_id`, `u_id` FROM ".SESSIONS_TABLE." WHERE `u_id`='".$_SESSION['uid']."'";
$sql="SELECT `session_id`, `u_id` FROM ".SESSIONS_TABLE." WHERE `u_id`='".$_SESSION['uid']."'";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain session information',true);
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain session information',true);
$result=mysql_fetch_array($query);
$result=DataBase::fetch($query);
$result=$result['session_id'];
$result=$result['session_id'];
if($_COOKIE[SESS_NAME]!=$result)
if($_COOKIE[SESS_NAME]!=$result)
{
{
@ -90,9 +98,13 @@ function SessDelete($uid)
{
{
$time=time();
$time=time();
$sql="DELETE FROM ".SESSIONS_TABLE." WHERE u_id='$uid'";
$sql="DELETE FROM ".SESSIONS_TABLE." WHERE u_id='$uid'";
$result=@mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not delete session',true));
$_SESSION['sessionid']='0';
return$result['count'];
$query=DataBase::sql_query($sql,'GENERAL','Could not delete session',true);
if(DataBase::num_rows($query)>0)
{
$result=DataBase::fetch($query);
$_SESSION['sessionid']='0';
return$result['count'];
}
}
}
functionSessView()
functionSessView()
@ -104,9 +116,9 @@ function SessView()
$time=time();
$time=time();
$sql="SELECT ".SESSIONS_TABLE.".*, ".USERS_TABLE.".*, ".SESSIONS_TABLE.".u_id AS u_id FROM ".SESSIONS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".SESSIONS_TABLE.".u_id = ".USERS_TABLE.".u_id WHERE time+1250>$time;";
$sql="SELECT ".SESSIONS_TABLE.".*, ".USERS_TABLE.".*, ".SESSIONS_TABLE.".u_id AS u_id FROM ".SESSIONS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".SESSIONS_TABLE.".u_id = ".USERS_TABLE.".u_id WHERE time+1250>$time;";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain sessions information.');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain sessions information.');
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id ORDER BY `ptime`";
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id ORDER BY `ptime`";
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in forum');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in forum');
$sql="SELECT COUNT(*) as `p_id`, `t_id` FROM ".POSTS_TABLE." GROUP BY `t_id`";
$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');
$query=DataBase::sql_query($sql,'GENERAL','Could not obtain amout of posts in forum');
while($result=@mysql_fetch_array($query))
while($result=DataBase::fetch($query))
{
{
$count_topic[$result['t_id']]=$result['p_id'];
$count_topic[$result['t_id']]=$result['p_id'];
}
}
@ -104,7 +104,7 @@ if ((isset($_POST['keywords'])) || ($_GET['content']=='lastposts') || ($_GET['co
{
{
if(isset($_GET['u']))
if(isset($_GET['u']))
{
{
$count=@mysql_fetch_array(DataBase::sql_query("SELECT COUNT(`t_id`) as `t_id`
$count=DataBase::fetch(DataBase::sql_query("SELECT COUNT(`t_id`) as `t_id`
FROM".TOPICS_TABLE."WHERE`author`='".intval($_GET['u'])."'",'GENERAL','Could not obtain count amout of topics'));
FROM".TOPICS_TABLE."WHERE`author`='".intval($_GET['u'])."'",'GENERAL','Could not obtain count amout of topics'));
$count=$count['t_id'];
$count=$count['t_id'];
$count=ceil($count/$limiter);
$count=ceil($count/$limiter);
@ -139,7 +139,7 @@ if ((isset($_POST['keywords'])) || ($_GET['content']=='lastposts') || ($_GET['co
$like_where.=' OR `text` LIKE \'%'.$keyword[$i].'%\'';
$like_where.=' OR `text` LIKE \'%'.$keyword[$i].'%\'';
}
}
$sql="SELECT COUNT(".TOPICS_TABLE.".t_id) as `count`, ".POSTS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".POSTS_TABLE." ON ".POSTS_TABLE.".t_id = ".TOPICS_TABLE.".t_id WHERE $like_where GROUP BY `t_id`";
$sql="SELECT COUNT(".TOPICS_TABLE.".t_id) as `count`, ".POSTS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".POSTS_TABLE." ON ".POSTS_TABLE.".t_id = ".TOPICS_TABLE.".t_id WHERE $like_where GROUP BY `t_id`";
$count=@mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain count amout of topics'));
$count=DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain count amout of topics'));
$count=$count['count'];
$count=$count['count'];
$count=ceil($count/$limiter);
$count=ceil($count/$limiter);
if($count==0)
if($count==0)
@ -179,11 +179,11 @@ if ((isset($_POST['keywords'])) || ($_GET['content']=='lastposts') || ($_GET['co
$sql="SELECT ".SHOUTBOX_TABLE.".*, ".USERS_TABLE.".* FROM ".SHOUTBOX_TABLE." LEFT JOIN ".USERS_TABLE." ON ".SHOUTBOX_TABLE.".u_id = ".USERS_TABLE.".u_id ORDER BY `mtime` $desc LIMIT ".$forum_config['shoutbox_max'];
$sql="SELECT ".SHOUTBOX_TABLE.".*, ".USERS_TABLE.".* FROM ".SHOUTBOX_TABLE." LEFT JOIN ".USERS_TABLE." ON ".SHOUTBOX_TABLE.".u_id = ".USERS_TABLE.".u_id ORDER BY `mtime` $desc LIMIT ".$forum_config['shoutbox_max'];
$query=DataBase::sql_query($sql,'CRITICAL','Could not obtain shoutbox information');
$query=DataBase::sql_query($sql,'CRITICAL','Could not obtain shoutbox information');
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".*, ".USERS_TABLE.".u_id AS user_id,".SESSIONS_TABLE.".* FROM `".POSTS_TABLE."` LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id LEFT JOIN ".SESSIONS_TABLE." ON ".SESSIONS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE t_id='$tid' ORDER BY tp_id $limit;";
$sql="SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".*, ".USERS_TABLE.".u_id AS user_id,".SESSIONS_TABLE.".* FROM `".POSTS_TABLE."` LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id LEFT JOIN ".SESSIONS_TABLE." ON ".SESSIONS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE t_id='$tid' ORDER BY tp_id $limit;";
$query=DataBase::sql_query($sql,'CRITICAL','Could not obtain post information.');
$query=DataBase::sql_query($sql,'CRITICAL','Could not obtain post information.');