|
<?php
|
|
/**
|
|
* @package uForum
|
|
* @file includes/class_shoutbox.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');
|
|
}
|
|
class ShoutBox
|
|
{
|
|
function new_message($message,$uid)
|
|
{
|
|
$time = time();
|
|
$sql = "INSERT INTO ".SHOUTBOX_TABLE." VALUES ('', '$uid', '$message','$time')";
|
|
DataBase::sql_query($sql,'GENERAL','Could not add shoutbox message.');
|
|
}
|
|
function read_messages($limit)
|
|
{
|
|
$sb_content = '';
|
|
$rank_mod = ($_SESSION['uid']>0) ? User::UserInformation($_SESSION['uid'],'rank') : 0;
|
|
global $user;
|
|
global $default_skin;
|
|
$sql = "SELECT * FROM ".SHOUTBOX_TABLE." ORDER BY `time` LIMIT $limit";
|
|
$query = DataBase::sql_query($sql,'CRITICAL', 'Could not read shoutbox table');
|
|
while($sb_msg = @mysql_fetch_array($query))
|
|
{
|
|
$del_edit_msg = ($rank_mod>0) ? '<a href="shoutbox.php?mode=
|
|
delete&id='.$sb_msg.'" class="fsmall">x</a> <a href="
|
|
shoutbox.php?mode=edit&id='.$sb_msg.'" class="fsmall">e</a>' : ' ';
|
|
$sb_content .= '<tr><td>'.$del_edit_msg.'<span class="fsmall">
|
|
<a href="user.php?id='.$b_msg['u_id'].'" class="fsmall">'
|
|
.Topic::UserName($user[$sb_msg['u_id']]['nick'],$user[$sb_msg['u_id']]['rank']).
|
|
'</a> <span class="fsmall">['.date('d-m, G:i',$sb_msg['time']).']:
|
|
'.$sb_msg['msg_content'].'</span></td></tr>';
|
|
}
|
|
return $sb_content;
|
|
|
|
}
|
|
function del_old_msgs($limiter)
|
|
{
|
|
$sql = "DELETE FROM ".SHOUTBOX_TABLE." WHERE `time`+$limiter<'".time()."'";
|
|
DataBase::sql_query($sql,'GENERAL','Could not delete old messages in shoutbox');
|
|
unset($sql);
|
|
}
|
|
}
|
|
?>
|