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.

73 lines
2.3 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file shoutbox.php
  5. * @version $Id$
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. if (!defined('IN_uF'))
  11. {
  12. die('Hacking attempt');
  13. }
  14. if (isset($_GET['mode']))
  15. {
  16. switch($_GET['mode'])
  17. {
  18. case 'shoutbox_add':
  19. {
  20. if (isset($_POST['shoutbox_message']))
  21. {
  22. $content = strip_tags($_POST['shoutbox_message']);
  23. $content = Post::SmilesReplace($content);
  24. if ((strlen($content)>3) and (strlen($content)<300))
  25. {
  26. $sql = "DELETE FROM ".SHOUTBOX_TABLE." WHERE `mtime`<'".(time()-$forum_config['shoutbox_max_time'])."'";
  27. DataBase::sql_query($sql,'GENERAL','Could not delete old messages');
  28. $sql = "INSERT INTO ".SHOUTBOX_TABLE." VALUES('','".$_SESSION['uid']."','".$content."','".time()."')";
  29. DataBase::sql_query($sql,'GENERAL','Could not add shoutbox message');
  30. }
  31. }
  32. echo '<meta http-equiv="refresh" content="0; url=index.php">';
  33. break;
  34. }
  35. case 'shoutbox_delete':
  36. {
  37. if (isset($_GET['id']) && (RANK>0))
  38. {
  39. DataBase::sql_query("DELETE FROM ".SHOUTBOX_TABLE." WHERE `m_id`='".intval($_GET['id'])."'",'GENERAL','Could not delete shoutbox message');
  40. }
  41. break;
  42. }
  43. case 'shoutbox_desc':
  44. {
  45. $desc = '';
  46. break;
  47. }
  48. }
  49. }
  50. if(!isset($desc))
  51. {
  52. $desc = 'DESC';
  53. }
  54. else
  55. {
  56. $desc = '';
  57. }
  58. $shoutbox_content = '';
  59. $sql = "SELECT ".SHOUTBOX_TABLE.".*, ".USERS_TABLE.".* FROM ".SHOUTBOX_TABLE." LEFT JOIN ".USERS_TABLE." ON ".SHOUTBOX_TABLE.".u_id = ".USERS_TABLE.".u_id ORDER BY `mtime` $desc LIMIT ".$forum_config['shoutbox_max'];
  60. $query = DataBase::sql_query($sql,'CRITICAL','Could not obtain shoutbox information');
  61. while($sb_msg = @mysql_fetch_array($query))
  62. {
  63. $allow_del = (RANK>0) ? '<a href="index.php?mode=shoutbox_delete&amp;id='.$sb_msg['m_id'].'" class="fsmall">X</a><span class="small">&nbsp;</span>' : '';
  64. $shoutbox_content .= '
  65. <tr>
  66. <td class="fitem" height="7">
  67. '.$allow_del.'<a href="user.php?id='.$sb_msg['u_id'].'" class="fsmall">'.Topic::UserName($sb_msg['nick'], $sb_msg['rank']).'</a><span class="fsmall"><b> ['.GenerateTime($sb_msg['mtime']).']</b>: '.$sb_msg['message'].'</span>
  68. </td>
  69. </tr>';
  70. }
  71. include('./skins/'.$default_skin.'/shoutbox_body.tpl');
  72. ?>