initial commit with snapshot 20140213
This commit is contained in:
64
inc/models/BansModel.class.php
Normal file
64
inc/models/BansModel.class.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class BansModel extends Model
|
||||
{
|
||||
private $ban_info = null;
|
||||
public function getBans()
|
||||
{
|
||||
$query = 'SELECT b.ban_id as ban_id, b.user_id as user_id, u.nick as nick, b.reason as reason
|
||||
FROM '.BANLIST_TABLE.' b
|
||||
LEFT JOIN '.USERS_TABLE.' u ON u.user_id = b.user_id';
|
||||
|
||||
return $this->select_query($query);
|
||||
}
|
||||
|
||||
public function getBan($ban_id)
|
||||
{
|
||||
if ($this->ban_info == null)
|
||||
{
|
||||
$query = 'SELECT b.ban_id as ban_id, b.user_id as user_id, u.nick as nick, b.reason as reason
|
||||
FROM '.BANLIST_TABLE.' b
|
||||
LEFT JOIN '.USERS_TABLE.' u ON u.user_id = b.user_id
|
||||
WHERE `ban_id`=\''.$ban_id.'\'';
|
||||
|
||||
$out = $this->select_query($query);
|
||||
|
||||
if (count($out) > 0)
|
||||
$this->ban_info = $out[0];
|
||||
}
|
||||
|
||||
return $this->ban_info;
|
||||
}
|
||||
|
||||
public function getUserBan($user_id)
|
||||
{
|
||||
$out = $this->select(BANLIST_TABLE, '*', 'user_id=\''.$user_id.'\'');
|
||||
|
||||
if (count($out) > 0)
|
||||
return $out[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addBan($user_id, $reason)
|
||||
{
|
||||
$query = 'INSERT INTO '.BANLIST_TABLE.'
|
||||
(`ban_id`, `user_id`, `reason`)
|
||||
VALUES (NULL, \''.$user_id.'\', \''.$reason.'\')';
|
||||
|
||||
$this->db->query($query);
|
||||
|
||||
$query = 'DELETE FROM '.SESSIONS_TABLE.' WHERE `user_id`=\''.$user_id.'\'';
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function deleteBan($ban_id)
|
||||
{
|
||||
$query = 'DELETE FROM '.BANLIST_TABLE.' WHERE `ban_id`=\''.$ban_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
inc/models/ConfigModel.class.php
Normal file
38
inc/models/ConfigModel.class.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class ConfigModel extends Model
|
||||
{
|
||||
private $confList = array();
|
||||
|
||||
public function __construct(&$db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
$result = $this->select (CONFIG_TABLE);
|
||||
|
||||
for ($i=0; $i<count($result); $i++)
|
||||
$this->confList[$result[$i]['name']] = $result[$i]['value'];
|
||||
|
||||
}
|
||||
|
||||
public function getConf($name)
|
||||
{
|
||||
if (isset($this->confList[$name]))
|
||||
return $this->confList[$name];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function updateConf($name, $value)
|
||||
{
|
||||
$query = 'UPDATE '.CONFIG_TABLE.'
|
||||
SET `value`=\''.$value.'\'
|
||||
WHERE `name`=\''.$name.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
119
inc/models/ForumsModel.class.php
Normal file
119
inc/models/ForumsModel.class.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class ForumsModel extends Model
|
||||
{
|
||||
private $forum_info = null;
|
||||
private $cat_info = null;
|
||||
public function getForums()
|
||||
{
|
||||
return $this->select (FORUMS_VIEW);
|
||||
}
|
||||
|
||||
public function getCats()
|
||||
{
|
||||
return $this->select (CATS_TABLE);
|
||||
}
|
||||
|
||||
public function getForumsNames()
|
||||
{
|
||||
$out = $this->select (FORUMS_TABLE, 'forum_id, name', '', 'forum_id ASC');
|
||||
if (count($out) > 0)
|
||||
return $out;
|
||||
else
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getForum($forum_id)
|
||||
{
|
||||
if ($this->forum_info == null)
|
||||
{
|
||||
$out = $this->select(FORUMS_TABLE, '*', 'forum_id=\''.$forum_id.'\'');
|
||||
|
||||
if (count($out) > 0)
|
||||
$this->forum_info = $out[0];
|
||||
}
|
||||
|
||||
return $this->forum_info;
|
||||
}
|
||||
|
||||
public function getTopics($forum_id)
|
||||
{
|
||||
$out = $this->select(TOPICS_VIEW, '*', 'forum_id=\''.$forum_id.'\'', 'lastpost_post_id DESC');
|
||||
if (count($out) > 0)
|
||||
return $out;
|
||||
else
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCat($cat_id)
|
||||
{
|
||||
if ($this->cat_info == null)
|
||||
{
|
||||
$out = $this->select(CATS_TABLE, '*', 'category_id=\''.$cat_id.'\'');
|
||||
|
||||
if (count($out) > 0)
|
||||
$this->cat_info = $out[0];
|
||||
}
|
||||
|
||||
return $this->cat_info;
|
||||
}
|
||||
|
||||
public function changeCat($cat_id, $cat_name)
|
||||
{
|
||||
$query = 'UPDATE '.CATS_TABLE.'
|
||||
SET `name`=\''.$cat_name.'\'
|
||||
WHERE `category_id`=\''.$cat_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function addCat($cat_name)
|
||||
{
|
||||
$query = 'INSERT INTO '.CATS_TABLE.'
|
||||
(category_id, name)
|
||||
VALUES (NULL, \''.$cat_name.'\')';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function deleteCat($cat_id)
|
||||
{
|
||||
$query = 'DELETE FROM '.CATS_TABLE.'
|
||||
WHERE `category_id`=\''.$cat_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function changeForum($forum_id, $forum_name, $forum_desc, $forum_category_id, $forum_locked)
|
||||
{
|
||||
$query = 'UPDATE '.FORUMS_TABLE.'
|
||||
SET `name`=\''.$forum_name.'\',
|
||||
`desc`=\''.$forum_desc.'\',
|
||||
`category_id`=\''.$forum_category_id.'\',
|
||||
`locked`=\''.$forum_locked.'\'
|
||||
WHERE `forum_id`=\''.$forum_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function addForum($forum_name, $forum_desc, $forum_category_id, $forum_locked)
|
||||
{
|
||||
$query = 'INSERT INTO '.FORUMS_TABLE.'
|
||||
(`forum_id`, `name`, `desc`, `category_id`, `locked`)
|
||||
VALUES (NULL, \''.$forum_name.'\', \''.$forum_desc.'\', \''.$forum_category_id.'\', \''.$forum_locked.'\')';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function deleteForum($forum_id)
|
||||
{
|
||||
$query = 'DELETE FROM '.FORUMS_TABLE.'
|
||||
WHERE `forum_id`=\''.$forum_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
43
inc/models/NavigationModel.class.php
Normal file
43
inc/models/NavigationModel.class.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class NavigationModel extends Model
|
||||
{
|
||||
private $linksList = array();
|
||||
private $title = '';
|
||||
|
||||
public function setForumName($fn)
|
||||
{
|
||||
$this->addLink('Forum '.$fn, 'index.php');
|
||||
$this->title = $fn. ' • ';
|
||||
}
|
||||
public function addLink($name, $url = '')
|
||||
{
|
||||
if ($url == null)
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
$l = array(
|
||||
'name' => $name,
|
||||
'url' => $url
|
||||
);
|
||||
|
||||
array_push($this->linksList, $l);
|
||||
}
|
||||
|
||||
public function setSubTitle($t)
|
||||
{
|
||||
$this->title .= $t;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function getNav()
|
||||
{
|
||||
return $this->linksList;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
126
inc/models/PostsModel.class.php
Normal file
126
inc/models/PostsModel.class.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class PostsModel extends Model
|
||||
{
|
||||
private $topic_info = null;
|
||||
private $post_info = null;
|
||||
|
||||
public function getTopic($topic_id)
|
||||
{
|
||||
if ($this->topic_info == null)
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
t.topic_id as topic_id, t.title as topic_title, t.locked as topic_locked, t.forum_id as forum_id, f.name as forum_name, f.locked as forum_locked, pc.post_count as post_count
|
||||
FROM '.TOPICS_TABLE.' t
|
||||
LEFT JOIN '.FORUMS_TABLE.' f ON f.forum_id = t.forum_id
|
||||
LEFT JOIN '.TOPICS_PC_VIEW.' pc ON pc.topic_id = t.topic_id
|
||||
WHERE t.topic_id=\''.$topic_id.'\'';
|
||||
$out = $this->select_query($query);
|
||||
if (count($out) > 0)
|
||||
$this->topic_info = $out[0];
|
||||
}
|
||||
|
||||
return $this->topic_info;
|
||||
}
|
||||
|
||||
public function getPosts($topic_id)
|
||||
{
|
||||
$out = $this->select (POSTS_VIEW, '*', 'topic_id=\''.$topic_id.'\'', 'post_id ASC');
|
||||
|
||||
if ($out != null)
|
||||
return $out;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPost($post_id)
|
||||
{
|
||||
$out = $this->select (POSTS_VIEW, '*', 'post_id=\''.$post_id.'\'');
|
||||
|
||||
if (count($out) > 0)
|
||||
return $out[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getFirstPost($topic_id)
|
||||
{
|
||||
$out = $this->select (POSTS_VIEW, 'post_id', 'topic_id=\''.$topic_id.'\'', 'post_id ASC', 1);
|
||||
|
||||
if (count($out) > 0)
|
||||
return $out[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
//mod options
|
||||
public function deletePost($post_id)
|
||||
{
|
||||
$query = 'DELETE FROM '.POSTS_TABLE.' WHERE post_id=\''.$post_id.'\';';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function deleteTopic($topic_id)
|
||||
{
|
||||
$query = 'call delete_topic(\''.$topic_id.'\');';
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function lockTopic($topic_id, $locked = true)
|
||||
{
|
||||
$query = 'UPDATE '.TOPICS_TABLE.' SET locked=\''.$locked.'\' WHERE topic_id=\''.$topic_id.'\';';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function moveTopic($topic_id, $forum_id)
|
||||
{
|
||||
$query = 'UPDATE '.TOPICS_TABLE.' SET forum_id=\''.$forum_id.'\' WHERE topic_id=\''.$topic_id.'\';';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function addTopic($title, $content, $forum_id, $user_id)
|
||||
{
|
||||
$query = 'call add_topic(\''.$title.'\',
|
||||
\''.$content.'\',
|
||||
\''.$forum_id.'\',
|
||||
\''.$user_id.'\',
|
||||
\''.$_SERVER['HTTP_USER_AGENT'].'\',
|
||||
@out);';
|
||||
$this->db->query($query);
|
||||
$result = $this->db->query('select @out as topic_id');
|
||||
|
||||
if ($result != null)
|
||||
return $result->fetch_assoc()['topic_id'];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function changePost($post_id, $content)
|
||||
{
|
||||
$query = 'UPDATE '.POSTS_TABLE.' SET `content`=\''.$content.'\' WHERE `post_id`=\''.$post_id.'\'';
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function changeTopic($topic_id, $title)
|
||||
{
|
||||
$query = 'UPDATE '.TOPICS_TABLE.' SET `title`=\''.$title.'\' WHERE `topic_id`=\''.$topic_id.'\'';
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function addPost($topic_id, $user_id, $content)
|
||||
{
|
||||
$query = 'INSERT INTO '.POSTS_TABLE.'
|
||||
(post_id, topic_id, user_id, content, date, user_agent)
|
||||
VALUES
|
||||
(NULL, \''.$topic_id.'\', \''.$user_id.'\', \''.$content.'\', NOW(), \''.$_SERVER['HTTP_USER_AGENT'].'\')';
|
||||
$this->db->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
125
inc/models/SessionModel.class.php
Normal file
125
inc/models/SessionModel.class.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class SessionModel extends Model
|
||||
{
|
||||
private $userdata = array();
|
||||
|
||||
public function __construct(&$db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
if (isset($_COOKIE[COOKIE_NAME]))
|
||||
{
|
||||
$result = $this->select(SESSIONS_TABLE, '*', 'session_id=\''.$_COOKIE[COOKIE_NAME].'\' AND expiry_time>=NOW()');
|
||||
if (count($result) > 0)
|
||||
{
|
||||
//update session expiry time in database and in cookie
|
||||
if ($result[0]['IP'] != $_SERVER['REMOTE_ADDR'])
|
||||
{
|
||||
$this->deleteSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->updateSession();
|
||||
$uid = $result[0]['user_id'];
|
||||
|
||||
$result = $this->select(USERS_TABLE, 'user_id, nick, rank', 'user_id=\''.$uid.'\'');
|
||||
$this->userdata = $result[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->deleteSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateSession()
|
||||
{
|
||||
/*$this->db->query('UPDATE '.SESSIONS_TABLE.' SET expiry_time=(NOW() + INTERVAL 120 MINUTE) WHERE session_id=\''.$_COOKIE[COOKIE_NAME].'\'');
|
||||
setcookie(COOKIE_NAME, $_COOKIE[COOKIE_NAME], $_SERVER['REQUEST_TIME']+7200, COOKIE_PATH, COOKIE_DOMAIN, false, true); */
|
||||
$newid = $this->generateSessionID();
|
||||
$this->db->query('UPDATE '.SESSIONS_TABLE.' SET expiry_time=(NOW() + INTERVAL 120 MINUTE), session_id=\''.$newid.'\' WHERE session_id=\''.$_COOKIE[COOKIE_NAME].'\'');
|
||||
setcookie(COOKIE_NAME, $newid, $_SERVER['REQUEST_TIME']+7200, COOKIE_PATH, COOKIE_DOMAIN, false, true);
|
||||
$_COOKIE[COOKIE_NAME] = $newid;
|
||||
}
|
||||
|
||||
public function deleteSession()
|
||||
{
|
||||
setcookie(COOKIE_NAME, '', $_SERVER['REQUEST_TIME']-3600, COOKIE_PATH, COOKIE_DOMAIN, false, true);
|
||||
$this->db->query('DELETE FROM '.SESSIONS_TABLE.' WHERE session_id=\''.$_COOKIE[COOKIE_NAME].'\'');
|
||||
}
|
||||
|
||||
private function generateSessionID()
|
||||
{
|
||||
$out = $_SERVER['HTTP_USER_AGENT'].$_SERVER['REQUEST_TIME_FLOAT'].$_SERVER['REMOTE_ADDR'].rand(1, 50000);
|
||||
return md5($out);
|
||||
}
|
||||
|
||||
public function registerNewSession($user_id)
|
||||
{
|
||||
$newID = $this->generateSessionID();
|
||||
$query = 'UPDATE '.USERS_INFO_TABLE.'
|
||||
SET lastvisit=NOW()
|
||||
WHERE user_id=\''.$user_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
|
||||
$query =
|
||||
'INSERT INTO
|
||||
'.SESSIONS_TABLE.'
|
||||
(session_id, user_id, IP, expiry_time)
|
||||
VALUES
|
||||
(\''.$newID.'\', \''.$user_id.'\', \''.$_SERVER['REMOTE_ADDR'].'\', (NOW() + INTERVAL 120 MINUTE) );';
|
||||
|
||||
$this->db->query($query);
|
||||
|
||||
setcookie(COOKIE_NAME, $newID, $_SERVER['REQUEST_TIME']+7200, COOKIE_PATH, COOKIE_DOMAIN, false, true);
|
||||
}
|
||||
|
||||
public function tryGetUser($nick, $passwd)
|
||||
{
|
||||
$result = $this->select(USERS_TABLE, 'user_id, nick', 'nick=\''.$nick.'\' AND password=\''.$passwd.'\'', '', 1);
|
||||
|
||||
if (count($result) > 0 )
|
||||
return $result[0];
|
||||
else
|
||||
return array();
|
||||
}
|
||||
|
||||
public function isLogged()
|
||||
{
|
||||
if (count($this->userdata) > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getNick()
|
||||
{
|
||||
if ($this->isLogged())
|
||||
return $this->userdata['nick'];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRank()
|
||||
{
|
||||
if ($this->isLogged())
|
||||
return $this->userdata['rank'];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
if ($this->isLogged())
|
||||
return $this->userdata['user_id'];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
56
inc/models/StatisticsModel.class.php
Normal file
56
inc/models/StatisticsModel.class.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class StatisticsModel extends Model
|
||||
{
|
||||
private $logged_users = null;
|
||||
|
||||
public function getPostsCount()
|
||||
{
|
||||
$out = $this->select(POSTS_TABLE, 'count(post_id) AS posts_count');
|
||||
return $out[0]['posts_count'];
|
||||
}
|
||||
|
||||
public function getTopicsCount()
|
||||
{
|
||||
$out = $this->select(TOPICS_TABLE, 'count(topic_id) AS topics_count');
|
||||
return $out[0]['topics_count'];
|
||||
}
|
||||
|
||||
public function getUsersCount()
|
||||
{
|
||||
$out = $this->select(USERS_TABLE, 'count(user_id) AS users_count');
|
||||
return $out[0]['users_count'];
|
||||
}
|
||||
|
||||
public function getLastRegisteredUser()
|
||||
{
|
||||
$out = $this->select(USERS_TABLE, 'user_id, nick, rank', '', 'user_id DESC', '1');
|
||||
return $out[0];
|
||||
}
|
||||
|
||||
private function retrieveLoggedUsers()
|
||||
{
|
||||
if ($this->logged_users == null)
|
||||
{
|
||||
$this->logged_users = $this->select(LOGGED_USERS_VIEW);
|
||||
}
|
||||
}
|
||||
|
||||
public function getLoggedUsersCount()
|
||||
{
|
||||
$this->retrieveLoggedUsers();
|
||||
|
||||
return count($this->logged_users);
|
||||
}
|
||||
|
||||
public function getLoggedUsers()
|
||||
{
|
||||
$this->retrieveLoggedUsers();
|
||||
|
||||
return $this->logged_users;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
128
inc/models/UsersModel.class.php
Normal file
128
inc/models/UsersModel.class.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
require_once('./inc/model.class.php');
|
||||
|
||||
class UsersModel extends Model
|
||||
{
|
||||
private $user_info = null;
|
||||
|
||||
public function nickExists($nick)
|
||||
{
|
||||
$out = $this->select(USERS_TABLE, 'nick', '`nick`=\''.$nick.'\'', '', 1);
|
||||
if (count($out) > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createNewUser($nick, $passwd, $email)
|
||||
{
|
||||
$this->db->query('call add_user(\''.$nick.'\', \''.$passwd.'\', \''.$email.'\');');
|
||||
}
|
||||
|
||||
public function getUsersNicks()
|
||||
{
|
||||
$out = $this->select (USERS_TABLE, 'user_id, nick', '', 'user_id ASC');
|
||||
if (count($out) > 0)
|
||||
return $out;
|
||||
else
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getUserInformation($user_id, $passwd = false)
|
||||
{
|
||||
if ($this->user_info == null)
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
u.nick as nick, u.email as email, u.rank as rank, u.active as active,
|
||||
ui.regdate as regdate, ui.lastvisit as lastvisit, ui.avatar as avatar, ui.location as location, ui.signature as signature, pc.post_count as post_count, lu.IP as user_IP ';
|
||||
if ($passwd)
|
||||
$query .= ',u.password as password ';
|
||||
$query .= '
|
||||
FROM '.USERS_TABLE.' u
|
||||
LEFT JOIN '.USERS_INFO_TABLE.' ui on ui.user_id = u.user_id
|
||||
LEFT JOIN '.USERS_PC_VIEW.' pc on pc.user_id = u.user_id
|
||||
LEFT JOIN '.LOGGED_USERS_VIEW.' lu on lu.user_id = u.user_id
|
||||
WHERE u.user_id = \''.$user_id.'\'';
|
||||
|
||||
$out = $this->select_query($query);
|
||||
if (count($out) > 0)
|
||||
$this->user_info = $out[0];
|
||||
}
|
||||
|
||||
return $this->user_info;
|
||||
}
|
||||
|
||||
public function changeUserPassword($user_id, $passwd)
|
||||
{
|
||||
$query =
|
||||
'UPDATE .'.USERS_TABLE.'
|
||||
SET `password`=\''.$passwd.'\'
|
||||
WHERE `user_id` = \''.$user_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function changeUserRank($user_id, $rank)
|
||||
{
|
||||
$query =
|
||||
'UPDATE .'.USERS_TABLE.'
|
||||
SET `rank`=\''.$rank.'\'
|
||||
WHERE `user_id` = \''.$user_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function updateUserProfile($user_id, $nick, $email, $location, $signature, $avatar)
|
||||
{
|
||||
$query =
|
||||
'UPDATE .'.USERS_TABLE.'
|
||||
SET ';
|
||||
if ($nick != null)
|
||||
$query .= '`nick`=\''.$nick.'\',';
|
||||
$query .= '`email`=\''.$email.'\'
|
||||
WHERE `user_id` = \''.$user_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
|
||||
//profile informations
|
||||
$query =
|
||||
'UPDATE .'.USERS_INFO_TABLE.'
|
||||
SET
|
||||
`avatar`=\''.$avatar.'\',
|
||||
`location`=\''.$location.'\',
|
||||
`signature`=\''.$signature.'\'
|
||||
WHERE `user_id` = \''.$user_id.'\'';
|
||||
|
||||
$this->db->query($query);
|
||||
}
|
||||
|
||||
public function getUsers($stype, $sorder, $rank)
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
u.user_id as user_id, u.nick as nick, u.rank as rank, ui.regdate as regdate, ui.lastvisit as lastvisit, pc.post_count as post_count
|
||||
FROM '.USERS_TABLE.' u
|
||||
LEFT JOIN '.USERS_INFO_TABLE.' ui on ui.user_id = u.user_id
|
||||
LEFT JOIN '.USERS_PC_VIEW.' pc on pc.user_id = u.user_id ';
|
||||
if ($rank !== '')
|
||||
$query .= 'WHERE rank=\''.$rank.'\'';
|
||||
$query .= '
|
||||
ORDER BY '.$stype.' '.$sorder;
|
||||
|
||||
$out = $this->select_query($query);
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function deleteUser($user_id)
|
||||
{
|
||||
$query =
|
||||
'DELETE FROM .'.USERS_TABLE.'
|
||||
WHERE `user_id` = \''.$user_id.'\'';
|
||||
$this->db->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user