+ Changed from MySQL to MySQLi native driver.
+ 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
This commit is contained in:
@@ -19,7 +19,7 @@ class Admin_Forum
|
||||
$cat = Forum::ForumInformation($fid,'c_id');
|
||||
$all='';
|
||||
$query = DataBase::sql_query("SELECT `name`, `c_id` FROM `".CATS_TABLE."`",'GENERAL','Could not obtain category information');
|
||||
while($t = @mysql_fetch_array($query))
|
||||
while($t = DataBase::fetch($query))
|
||||
{
|
||||
|
||||
if ($t['c_id']==$cat)
|
||||
|
||||
@@ -38,7 +38,7 @@ class Admin_Over
|
||||
global $default_skin;
|
||||
$all='';
|
||||
$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)
|
||||
@@ -104,14 +104,14 @@ class Admin_Over
|
||||
{
|
||||
$result = User::UserInformation($_SESSION['uid'],'skin');
|
||||
$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'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $forum_config['defaultskin'];
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
@@ -131,14 +131,14 @@ class Admin_Over
|
||||
{
|
||||
$sql = "SELECT `t_id` FROM ".TOPICS_TABLE.";";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
|
||||
$result = mysql_num_rows($query);
|
||||
$result = DataBase::num_rows($query);
|
||||
return($result);
|
||||
}
|
||||
function TotalPosts()
|
||||
{
|
||||
$sql = "SELECT `p_id` FROM ".POSTS_TABLE.";";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
|
||||
$result = mysql_num_rows($query);
|
||||
$result = DataBase::num_rows($query);
|
||||
return($result);
|
||||
}
|
||||
function GenerateHeader()
|
||||
|
||||
8
includes/cache/cache_forums.php
vendored
8
includes/cache/cache_forums.php
vendored
@@ -14,7 +14,7 @@ if(!defined('IN_uF'))
|
||||
//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'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
|
||||
if ($result['name']=='')
|
||||
{
|
||||
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`";
|
||||
$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'];
|
||||
}
|
||||
/*$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))
|
||||
while($result = DataBase::fetch($query))
|
||||
{
|
||||
$lastpost[$result['t_id']]['tp_id']=$result['tp_id'];
|
||||
$lastpost[$result['t_id']]['u_id']=$result['u_id'];
|
||||
@@ -65,7 +65,7 @@ else
|
||||
$limit = 'LIMIT 0, '.$limiter;
|
||||
$page=1;
|
||||
}
|
||||
$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 `f_id`='$fid'",'GENERAL','Could not obtain count amout of topics'));
|
||||
$count = $count['t_id'];
|
||||
$count = ceil($count / $limiter);
|
||||
|
||||
19
includes/cache/cache_index.php
vendored
19
includes/cache/cache_index.php
vendored
@@ -15,34 +15,23 @@ if(!defined('IN_uF'))
|
||||
//cache forums and posts - version v1.0 Alpha 2---------------------------------
|
||||
//
|
||||
//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);
|
||||
$post_count = @mysql_num_rows($query);
|
||||
while($result = @mysql_fetch_array($query))
|
||||
{
|
||||
$last_post[$result['f_id']]['tp_id'] = $result['tp_id'];
|
||||
$last_post[$result['f_id']]['u_id'] = $result['u_id'];
|
||||
$last_post[$result['f_id']]['t_id'] = $result['t_id'];
|
||||
$last_post[$result['f_id']]['time'] = $result['ptime'];
|
||||
$last_post[$result['f_id']]['user_rank'] = $result['rank'];
|
||||
$last_post[$result['f_id']]['user_nick'] = $result['nick'];
|
||||
}*/
|
||||
//cache forums --don't modify!!!
|
||||
$cache_id=1;
|
||||
$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.');
|
||||
while($result = @mysql_fetch_array($query))
|
||||
while($result = DataBase::fetch($query))
|
||||
{
|
||||
$forum[$cache_id]['f_id'] = $result['f_id'];
|
||||
$forum[$cache_id]['name'] = $result['name'];
|
||||
$forum[$cache_id]['desc'] = $result['desc'];
|
||||
$forum[$cache_id]['c_id'] = $result['c_id'];
|
||||
$forum[$cache_id]['sort'] = $result['sort'];
|
||||
$forum[$cache_id]['lastpost'] = $result['lastpost'];
|
||||
$count_forum[$result['f_id']] = $result['amout'];
|
||||
$cache_id+=1;
|
||||
}
|
||||
$sql = "SELECT `u_id`,`nick`, `regdate` AS count FROM ".USERS_TABLE." ORDER BY `regdate` DESC";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain amout of count users information');
|
||||
$lastuser = @mysql_fetch_array($query);
|
||||
$count_users = @mysql_num_rows($query) -1;
|
||||
$lastuser = DataBase::fetch($query);
|
||||
$count_users = DataBase::num_rows($query) -1;
|
||||
?>
|
||||
|
||||
10
includes/cache/cache_topic.php
vendored
10
includes/cache/cache_topic.php
vendored
@@ -13,7 +13,7 @@ if(!defined('IN_uF'))
|
||||
}
|
||||
//||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 = @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['t_id']=='')
|
||||
{
|
||||
message_forum($lng['no_topic'], 'index.php');
|
||||
@@ -30,8 +30,8 @@ $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 = mysql_num_rows($query);
|
||||
while ($result = @mysql_fetch_array($query))
|
||||
$result = DataBase::num_rows($query);
|
||||
while ($result = DataBase::fetch($query))
|
||||
{
|
||||
if(!isset($user_warnlevel[$result['u_id']]))
|
||||
{
|
||||
@@ -50,7 +50,7 @@ while ($result = @mysql_fetch_array($query))
|
||||
//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 = @mysql_fetch_array($query))
|
||||
while($result = DataBase::fetch($query))
|
||||
{
|
||||
$user[$result['u_id']]['online']='1';
|
||||
}
|
||||
@@ -81,7 +81,7 @@ else
|
||||
$limit = 'LIMIT 0, '.$limiter;
|
||||
$page=1;
|
||||
}
|
||||
$count = @mysql_fetch_array(DataBase::sql_query("SELECT COUNT(`p_id`) as `p_id`
|
||||
$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);
|
||||
|
||||
@@ -19,7 +19,7 @@ class Forum
|
||||
$forum = Topic::TopicInformation($tid,'f_id');
|
||||
$all='';
|
||||
$query = DataBase::sql_query("SELECT `name`, `f_id` FROM `".FORUMS_TABLE."` ORDER BY `f_id`",'GENERAL','Could not obtain forum information');
|
||||
while($t = @mysql_fetch_array($query))
|
||||
while($t = DataBase::fetch($query))
|
||||
{
|
||||
|
||||
if ($t['f_id']==$forum)
|
||||
@@ -39,7 +39,7 @@ class Forum
|
||||
{
|
||||
$sql = "SELECT count(*) as `p_id` FROM ".POSTS_TABLE." WHERE f_id='$forum_name'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain posts information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
return $result['p_id'];
|
||||
}
|
||||
|
||||
@@ -47,17 +47,18 @@ class Forum
|
||||
{
|
||||
global $lng;
|
||||
global $user;
|
||||
global $last_post;
|
||||
global $lastpost;
|
||||
global $userdata;
|
||||
global $forum_config;
|
||||
if ($posts==0) { return '<p align="center" class="fstandard">'.$lng['nopost'].'</p>';}
|
||||
else
|
||||
{
|
||||
$id = $last_post[$forum]['tp_id'];
|
||||
$topic = $last_post[$forum]['t_id'];
|
||||
$userid = $last_post[$forum]['u_id'];
|
||||
$un = $last_post[$forum]['user_nick'];
|
||||
$rank = $last_post[$forum]['user_rank'];
|
||||
$id = $lastpost[0];
|
||||
$userid = $lastpost[1];
|
||||
$topic = $lastpost[2];
|
||||
$rank = $lastpost[4];
|
||||
$un = $lastpost[5];
|
||||
|
||||
switch($rank)
|
||||
{
|
||||
case '0':
|
||||
@@ -93,13 +94,13 @@ class Forum
|
||||
{
|
||||
$page='';
|
||||
}
|
||||
return '<p align="center"><span class="fverysmall"><b>'.GenerateTime($last_post[$forum]['time']).'</b><br></span> <a href="topic.php?t='.$topic.$page.'#p'.$id.'" class="fverysmall"><b>'.$lng['topic'].' #'.$topic.'</b></a><a class="fsmall">: </a><a href="user.php?id='.$userid.'" class="fverysmall">'.$user_color_name.'</a></p>';
|
||||
return '<p align="center"><span class="fverysmall"><b>'.GenerateTime($lastpost[3]).'</b><br></span> <a href="topic.php?t='.$topic.$page.'#p'.$id.'" class="fverysmall"><b>'.$lng['topic'].' #'.$topic.'</b></a><a class="fsmall">: </a><a href="user.php?id='.$userid.'" class="fverysmall">'.$user_color_name.'</a></p>';
|
||||
}
|
||||
}
|
||||
|
||||
function LastPostImg($postsinforum)
|
||||
{
|
||||
global $last_post;
|
||||
global $lastpost;
|
||||
global $i;
|
||||
global $forum;
|
||||
global $default_skin;
|
||||
@@ -108,7 +109,7 @@ class Forum
|
||||
{
|
||||
if ($postsinforum>0)
|
||||
{
|
||||
if ($last_post[$forum[$i]['f_id']]['time']>$time)
|
||||
if ($lastpost[3]>$time)
|
||||
{
|
||||
return 'folder_new_posts';
|
||||
}
|
||||
@@ -132,7 +133,7 @@ class Forum
|
||||
{
|
||||
$sql = "SELECT `f_id`, `$inf` FROM ".FORUMS_TABLE." WHERE f_id='$fid';";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain forum information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result[$inf];
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class Mod
|
||||
{
|
||||
$sql="SELECT * FROM ".POSTS_TABLE." WHERE `t_id`='$topicid'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain post information');
|
||||
while($item = @mysql_fetch_array($query))
|
||||
while($item = DataBase::fetch($query))
|
||||
{
|
||||
$uid = Topic::PostInformation($item['p_id'],'u_id');
|
||||
$posts = User::UserInformation($uid,'posts');
|
||||
@@ -84,7 +84,7 @@ class Mod
|
||||
DataBase::sql_query($sql2,'GENERAL','Could not delete post.');
|
||||
$sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id>'$postid' AND `t_id`='$tid';";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain post information.');
|
||||
while($item=mysql_fetch_array($query))
|
||||
while($item=DataBase::fetch($query))
|
||||
{
|
||||
$number = $item['tp_id'];
|
||||
$number = $number-1;
|
||||
|
||||
@@ -20,7 +20,7 @@ class Post
|
||||
#read last post in topic
|
||||
$sql = "SELECT * FROM ".POSTS_TABLE." WHERE t_id='$tid' ORDER BY tp_id DESC LIMIT 1;";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not last post information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$forum = $result['f_id'];//forum id
|
||||
$moderate = Forum::ForumInformation($forum,'moderate');
|
||||
$tpid = $result['tp_id'];//post in topic id
|
||||
@@ -61,7 +61,7 @@ class Post
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not add new post.');
|
||||
$sql = "SELECT * FROM ".USERS_TABLE." WHERE u_id='$uid';";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['posts'];
|
||||
$result = $result+1;
|
||||
$sql = "UPDATE ".USERS_TABLE." SET posts='$result' WHERE u_id='$uid' ";
|
||||
@@ -76,7 +76,7 @@ class Post
|
||||
$sql = "SELECT * FROM ".SMILES_TABLE."";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Cold not obtain smiles information.');
|
||||
$i = 1;
|
||||
while($smile = mysql_fetch_array($query))
|
||||
while($smile = DataBase::fetch($query))
|
||||
{
|
||||
$action = "insertSmile('".$smile['url']."','".$smile['smile']."')";
|
||||
$mouse = "this.style.cursor='hand';";
|
||||
@@ -100,7 +100,7 @@ class Post
|
||||
$sql = "SELECT * FROM ".SMILES_TABLE."";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain emoticons information.');
|
||||
$i = 1;
|
||||
while($result = mysql_fetch_array($query))
|
||||
while($result = DataBase::fetch($query))
|
||||
{
|
||||
$smile[$i]['smile'] = $result['smile'];
|
||||
$smile[$i]['url'] = $result['url'];
|
||||
|
||||
@@ -116,7 +116,7 @@ class Topic
|
||||
{
|
||||
$sql = "SELECT * FROM ".TOPICS_TABLE." WHERE t_id='$tid';";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain topic information');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result[$mode];
|
||||
return $result;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class Topic
|
||||
{
|
||||
$sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id='$pid';";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain topic information');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result[$mode];
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class User
|
||||
{
|
||||
$sql = "SELECT `$inf` FROM ".USERS_TABLE." WHERE u_id='$uid';";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result[$inf];
|
||||
return $result;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class User
|
||||
function UserIdByNick($nick)
|
||||
{
|
||||
$sql = "SELECT * FROM `".USERS_TABLE."` WHERE `nick`='$nick';";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = $result['u_id'];
|
||||
/*if ($result=='')
|
||||
{
|
||||
@@ -120,7 +120,7 @@ class User
|
||||
{
|
||||
$sql = "SELECT * FROM ".USERS_TABLE." WHERE u_id='$uid'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain user`s rank information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$rank = $result['rank'];
|
||||
if (($rank=='1') or ($rank=='2'))
|
||||
{
|
||||
@@ -194,7 +194,7 @@ class User
|
||||
if($uid>0)
|
||||
{
|
||||
$sql = "SELECT count(*) as `m_id` FROM ".PM_INBOX_TABLE." WHERE `u_id`='$uid' AND `read`='0'";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain amounts PM of User.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain amounts PM of User.'));
|
||||
$result = $result['m_id'];
|
||||
if ($result>0)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ class Secure
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM ".FORUMS_TABLE." WHERE f_id='$fid'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain forum information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['f_id'];
|
||||
if ($result=='')
|
||||
{
|
||||
@@ -32,7 +32,7 @@ class Secure
|
||||
{
|
||||
$sql = "SELECT * FROM ".CENSORLIST_TABLE.";";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain censorlist information.');
|
||||
while($word = mysql_fetch_array($query))
|
||||
while($word = DataBase::fetch($query))
|
||||
{
|
||||
$text = str_replace($word['word'],'[censored]', $text);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class Secure
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM ".PM_INBOX_TABLE." WHERE m_id='$mid'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['m_id'];
|
||||
if ($result=='')
|
||||
{
|
||||
@@ -81,7 +81,7 @@ class Secure
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM ".PM_SENTBOX_TABLE." WHERE m_id='$mid'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['u_n_id'];
|
||||
if ($result!=$_SESSION['uid'])
|
||||
{
|
||||
@@ -92,7 +92,7 @@ class Secure
|
||||
{
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM ".PM_INBOX_TABLE." WHERE m_id='$mid'";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = $result['u_id'];
|
||||
if ($result!=$_SESSION['uid'])
|
||||
{
|
||||
@@ -103,7 +103,7 @@ class Secure
|
||||
{
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM ".PM_SENTBOX_TABLE." WHERE m_id='$mid'";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = $result['m_id'];
|
||||
if ($result=='')
|
||||
{
|
||||
@@ -115,7 +115,7 @@ class Secure
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM `".TOPICS_TABLE."` WHERE `t_id`='$tid'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain topic information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['t_id'];
|
||||
if ($result=='')
|
||||
{
|
||||
@@ -127,7 +127,7 @@ class Secure
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id='$pid'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain topic information.');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['p_id'];
|
||||
if ($result=='')
|
||||
{
|
||||
@@ -138,7 +138,7 @@ class Secure
|
||||
{
|
||||
global $lng;
|
||||
$sql = "SELECT * FROM ".USERS_TABLE." WHERE u_id='$uid'";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
|
||||
$result = $result['u_id'];
|
||||
if (($result=='') or ($result=='-1'))
|
||||
{
|
||||
@@ -149,7 +149,7 @@ class Secure
|
||||
{
|
||||
global $lng;
|
||||
$sql = "SELECT `g_id` FROM `".GROUPS_TABLE."` WHERE g_id='$gid'";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain group information.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain group information.'));
|
||||
$result = $result['g_id'];
|
||||
if ($result=='')
|
||||
{
|
||||
@@ -170,10 +170,10 @@ class Secure
|
||||
{
|
||||
global $lng;
|
||||
$sql = "SELECT `f_id`,`lock` FROM `".TOPICS_TABLE."` WHERE `t_id`='$tid'";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain topic information'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain topic information'));
|
||||
$fid = $result['f_id'];
|
||||
$sql2 = "SELECT `lock` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
|
||||
$result2 = mysql_fetch_array(DataBase::sql_query($sql2,'GENERAL','Could not obtain forum information'));
|
||||
$result2 = DataBase::fetch(DataBase::sql_query($sql2,'GENERAL','Could not obtain forum information'));
|
||||
if (($result['lock']=='1') or ($result2['lock']=='1'))
|
||||
{
|
||||
message_forum($lng['no_posting_topic_locked'],'topic.php?t='.$tid);
|
||||
@@ -183,7 +183,7 @@ class Secure
|
||||
{
|
||||
global $lng;
|
||||
$sql = "SELECT `lock` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
|
||||
$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['lock']=='1')
|
||||
{
|
||||
message_forum($lng['no_posting_forum_locked'],'forum.php?f='.$fid);
|
||||
|
||||
@@ -11,16 +11,35 @@ if ( !defined('IN_uF') )
|
||||
{
|
||||
die('Hacking attempt');
|
||||
}
|
||||
|
||||
$db;
|
||||
|
||||
class DataBase
|
||||
{
|
||||
function db_connect()
|
||||
{
|
||||
$connect = mysql_pconnect(DB_HOST, DB_USER, DB_PASS) or message_die('CRITICAL',' Could not connect to database server.',mysql_error());
|
||||
mysql_query("SET NAMES 'utf8'",$connect);
|
||||
mysql_select_db(DB_NAME, $connect) or message_die('CRITICAL',' Could not connect to database.',mysql_error());
|
||||
global $db;
|
||||
|
||||
$db = new mysqli(DB_HOST, DB_USER, DB_PASS);
|
||||
if (mysqli_connect_errno() != 0)
|
||||
{
|
||||
message_die('CRITICAL',' Could not connect to database server.',$db->error);
|
||||
}
|
||||
|
||||
if (!$db->set_charset("UTF8"))
|
||||
{
|
||||
message_die('CRITICAL', 'Could not set character set UTF-8', $db->error);
|
||||
}
|
||||
if (!$db->select_db(DB_NAME))
|
||||
{
|
||||
message_die('CRITICAL',' Could not select database.', $db->error);
|
||||
}
|
||||
}
|
||||
|
||||
function sql_query($sql, $type, $msg, $no_count = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (isset($_COOKIE['queries']))
|
||||
{
|
||||
$no_count = false;
|
||||
@@ -30,11 +49,28 @@ class DataBase
|
||||
}
|
||||
}
|
||||
//echo '<span class="fsmall">'.$sql.'<br></span>'; //for optimizing only
|
||||
$query = mysql_query($sql) or message_die($type, $msg, mysql_error());
|
||||
if (!$query = $db->query($sql))
|
||||
{
|
||||
message_die($type, $msg, $db->error);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
function fetch($query)
|
||||
{
|
||||
return $query->fetch_array();
|
||||
}
|
||||
|
||||
function num_rows($query)
|
||||
{
|
||||
return $query->num_rows;
|
||||
}
|
||||
|
||||
function new_id($table)
|
||||
{
|
||||
global $db;
|
||||
|
||||
//check table id
|
||||
switch($table)
|
||||
{
|
||||
@@ -55,7 +91,7 @@ class DataBase
|
||||
case WARNINGS_TABLE: { $id = 'w_id'; break; }
|
||||
}
|
||||
$sql = "SELECT `$id` FROM $table ORDER BY `$id` DESC LIMIT 1";
|
||||
$return_id = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Error with obtain last id.<br> File: db.php, Line: '.__LINE__));
|
||||
$return_id = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Error with obtain last id.<br> File: db.php, Line: '.__LINE__));
|
||||
$return_id = $return_id[$id];
|
||||
$return_id = $return_id+1;
|
||||
return $return_id;
|
||||
|
||||
@@ -79,7 +79,7 @@ function SendMassEmail($title,$content)
|
||||
{
|
||||
$sql = "SELECT `email`,`u_id` FROM ".USERS_TABLE." WHERE `u_id`>0";
|
||||
$query = DataBase::sql_query($sql,'CRITICAL','Could not read users table');
|
||||
while($item = @mysql_fetch_array($query))
|
||||
while($item = DataBase::fetch($query))
|
||||
{
|
||||
SendEmail($item['email'], $title, $content);
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ function AddSkins()
|
||||
global $default_skin;
|
||||
$all='';
|
||||
$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)
|
||||
@@ -278,7 +278,7 @@ function TotalPosts()
|
||||
{
|
||||
$sql = "SELECT count(*) as `p_id` FROM ".POSTS_TABLE."";
|
||||
$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'];
|
||||
|
||||
return($result);
|
||||
@@ -338,15 +338,13 @@ function ViewSkinName()
|
||||
$result = $forum_config['defaultskin'];
|
||||
}
|
||||
$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'];
|
||||
}
|
||||
|
||||
function GenerateLastPost($id, $type)
|
||||
{
|
||||
$last_post = '';
|
||||
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
/** field lastpost in forum format
|
||||
@@ -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";
|
||||
$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 .= ':';
|
||||
@@ -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";
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GeneratePosts($id, $type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 1: //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;
|
||||
}
|
||||
|
||||
/** field lastpost in topic format
|
||||
tp_id:u_id:ptime:rank:nick
|
||||
*/
|
||||
case 2: //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');
|
||||
$result = DataBase::fetch($query);
|
||||
|
||||
$last_post .= $result['tp_id'];
|
||||
$last_post .= ':';
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
//
|
||||
$sql = "SELECT `u_id`,`nick`,`rank` FROM `".USERS_TABLE."`";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain forums information');
|
||||
$user['count']= mysql_num_rows($query);
|
||||
$user['count']= DataBase::num_rows($query);
|
||||
|
||||
while($result = mysql_fetch_array($query))
|
||||
while($result = DataBase::fetch($query))
|
||||
{
|
||||
$user[$result['u_id']]['u_id']=$result['u_id'];
|
||||
$user[$result['u_id']]['nick']=$result['nick'];
|
||||
@@ -53,7 +53,7 @@ switch($_GET['submode'])
|
||||
}
|
||||
|
||||
$query = DataBase::sql_query($sql,'CRITICAL','Could not obtain messages information');
|
||||
$count = mysql_num_rows($query);
|
||||
$count = DataBase::num_rows($query);
|
||||
|
||||
if ($count==0)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ if ($count==0)
|
||||
}
|
||||
else
|
||||
{
|
||||
while($item=mysql_fetch_array($query))
|
||||
while($item=DataBase::fetch($query))
|
||||
{
|
||||
$skin=array(
|
||||
'mid'=>$item['m_id'],
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
$sql = "SELECT * FROM ".SMILES_TABLE."";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain emoticons information.');
|
||||
$i = 1;
|
||||
while($result = mysql_fetch_array($query))
|
||||
while($result = DataBase::fetch($query))
|
||||
{
|
||||
$smile[$i]['smile'] = $result['smile'];
|
||||
$smile[$i]['url'] = $result['url'];
|
||||
@@ -34,7 +34,7 @@ switch($_GET['submode'])
|
||||
}
|
||||
}
|
||||
$query = DataBase::sql_query($sql,'CRITICAL','Could not obtain messages information');
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
//if message exist....
|
||||
if ($result['m_id']=='')
|
||||
{
|
||||
@@ -69,7 +69,7 @@ if ($_GET['submode']=='user')
|
||||
$sql = "SELECT * FROM ".USERS_TABLE." WHERE `u_id`='".$result['u_n_id']."'";
|
||||
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information');
|
||||
$user = @mysql_fetch_array($query);
|
||||
$user = DataBase::fetch($query);
|
||||
|
||||
$folder = ($_GET['submode']=='author') ? '<a href="pms.php?mode=folder&submode=sentbox" class="navigator">'.$lng['sentbox'].'</a>' : '<a href="pms.php?mode=folder&submode=inbox" class="navigator">'.$lng['inbox'].'</a>';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ if ((isset($_POST['textedit'])) and (isset($_POST['nmsg'])) and (isset($_POST['u
|
||||
{
|
||||
$nick = strip_tags($_POST['username']);
|
||||
$sql = "SELECT * FROM `".USERS_TABLE."` WHERE `nick`='$nick'";
|
||||
$result = mysql_fetch_array(DataBase::sql_query($sql, 'CRITICAL','Could not obtain user information.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql, 'CRITICAL','Could not obtain user information.'));
|
||||
if ($result['u_id']!='')
|
||||
{
|
||||
$_POST['textedit'] = Secure::TagsReplace($_POST['textedit']);
|
||||
|
||||
@@ -58,8 +58,16 @@ function SessRegister()
|
||||
SessDelete($uid);
|
||||
$time = 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
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +84,7 @@ function SessDelInvalid()
|
||||
{
|
||||
$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);
|
||||
$result = mysql_fetch_array($query);
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['session_id'];
|
||||
if ($_COOKIE[SESS_NAME]!=$result)
|
||||
{
|
||||
@@ -90,9 +98,13 @@ function SessDelete($uid)
|
||||
{
|
||||
$time = time();
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
|
||||
function SessView()
|
||||
@@ -104,9 +116,9 @@ function SessView()
|
||||
$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;";
|
||||
$query = DataBase::sql_query($sql, 'GENERAL','Could not obtain sessions information.');
|
||||
if (@mysql_num_rows($query)>0)
|
||||
if (DataBase::num_rows($query)>0)
|
||||
{
|
||||
while($result = @mysql_fetch_array($query))
|
||||
while($result = DataBase::fetch($query))
|
||||
{
|
||||
$uid = $result['u_id'];
|
||||
switch($result['rank'])
|
||||
@@ -134,6 +146,6 @@ function SessView()
|
||||
{
|
||||
$name = '<span class="userlink">'.$lng['empty'].'</span>';
|
||||
}
|
||||
return array($name, @mysql_num_rows($query));
|
||||
return array($name, DataBase::num_rows($query));
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user