A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

  1. <?php
  2. /**
  3. * @package Dynamic Script Forum
  4. * @file includes/class_shoutbox.php
  5. * @version 1.0.x, 27-08-2007, 17:02
  6. * @copyright 2008(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/dsf.html
  8. * @license GNU GPL v3
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class ShoutBox
  15. {
  16. function new_message($message,$uid)
  17. {
  18. $time = time();
  19. $sql = "INSERT INTO ".SHOUTBOX_TABLE." VALUES ('', '$uid', '$message','$time')";
  20. DataBase::sql_query($sql,'GENERAL','Could not add shoutbox message.');
  21. }
  22. function read_messages($limit)
  23. {
  24. $sb_content = '';
  25. $rank_mod = ($_SESSION['uid']>0) ? User::UserInformation($_SESSION['uid'],'rank') : 0;
  26. global $user;
  27. global $default_skin;
  28. $sql = "SELECT * FROM ".SHOUTBOX_TABLE." ORDER BY `time` LIMIT $limit";
  29. $query = DataBase::sql_query($sql,'CRITICAL', 'Could not read shoutbox table');
  30. while($sb_msg = @mysql_fetch_array($query))
  31. {
  32. $del_edit_msg = ($rank_mod>0) ? '<a href="shoutbox.php?mode=
  33. delete&amp;id='.$sb_msg.'" class="fsmall">x</a> <a href="
  34. shoutbox.php?mode=edit&amp;id='.$sb_msg.'" class="fsmall">e</a>' : '&nbsp;';
  35. $sb_content .= '<tr><td>'.$del_edit_msg.'<span class="fsmall">
  36. <a href="user.php?id='.$b_msg['u_id'].'" class="fsmall">'
  37. .Topic::UserName($user[$sb_msg['u_id']]['nick'],$user[$sb_msg['u_id']]['rank']).
  38. '</a> <span class="fsmall">['.date('d-m, G:i',$sb_msg['time']).']:
  39. '.$sb_msg['msg_content'].'</span></td></tr>';
  40. }
  41. return $sb_content;
  42. }
  43. function del_old_msgs($limiter)
  44. {
  45. $sql = "DELETE FROM ".SHOUTBOX_TABLE." WHERE `time`+$limiter<'".time()."'";
  46. DataBase::sql_query($sql,'GENERAL','Could not delete old messages in shoutbox');
  47. unset($sql);
  48. }
  49. }
  50. ?>