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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user