Просмотр файла gchat/inc/chat.class.php

Размер файла: 3.55Kb
  1. <?php
  2.  
  3. class gchat
  4. {
  5. var $room;
  6. var $page;
  7. var $clientVersion = 2109;
  8. function __construct ()
  9. {
  10. if (!empty ($_GET['room']))
  11. $this->room = (int) $_GET['room'];
  12. if (empty ($_GET['page']))
  13. $this->page = 1;
  14. else
  15. $this->page = (int) $_GET['page'];
  16. }
  17.  
  18. function readMsgs ($chatMsgs = null)
  19. {
  20. if (empty ($chatMsgs))
  21. {
  22. echo "<div class='".DIV_SECTION_1."'>GlobalChat временно пуст<br />
  23. Вы можете стать первым :)</div>";
  24. return false;
  25. }
  26. foreach ($chatMsgs AS $post)
  27. {
  28. echo "<div class='".alternDivs (DIV_SECTION_1, DIV_SECTION_2)."'>
  29. <img src='icons/sex_".intval ($post->user_sex).".png' alt='' /> <a href='?room=$this->room&amp;update_mod=2&amp;answer=".filtOut ($post->user_nick)."'>".filtOut ($post->user_nick)."</a> ".(intval ($post->user_id) > 0?'[ID'.intval ($post->user_id).']':null).' '.processText ($post->msg).'</div>';
  30. }
  31. }
  32. function readRooms ($chatRooms = null)
  33. {
  34. if (empty ($chatRooms))
  35. {
  36. echo "<div class='".DIV_SECTION_1."'>Комнаты временно отсутствуют<br />
  37. Вы можете стать первым :)</div>";
  38. return false;
  39. }
  40. foreach ($chatRooms AS $room)
  41. {
  42. /* print_r ($room); */
  43. echo "<div class='".alternDivs (DIV_SECTION_1, DIV_SECTION_2)."'><a href='?room=$room->id'>
  44. <img src='icons/room.png' alt='' /> $room->name</a><br />";
  45. if (!empty ($room->users))
  46. {
  47. echo "<img src='icons/point.png' alt='' /> ";
  48. foreach ($room->users AS $user)
  49. {
  50. $roomUsers[] = "<a href='?room=$room->id&amp;answer=$user->user_nick'>$user->user_nick</a>";
  51. }
  52. echo implode (', ', $roomUsers).'.';
  53. }
  54. echo '</div>';
  55. }
  56. }
  57.  
  58. function formMsg ()
  59. {
  60. global $server;
  61. if (empty ($_SESSION['update_mode']))
  62. {
  63. if (defined ('USER_ID'))
  64. $result = "
  65. <form method='post' action='?room=$this->room'>
  66. <input type='text' name='msg' ".(isset ($_GET['answer'])?'value="[b]'.filtOut (@$_GET['answer']).'[/b], "':null)." autofocus='1' /><input type='submit' name='send' value='Send' /></form>";
  67. else
  68. $result = '<img src="icons/error.png" alt="" /> Писать могут только зарегистрированные пользователи';
  69. return $result;
  70. }
  71. }
  72. function navigation ()
  73. {
  74. $result = null;
  75. $result .= "<a href='?room=$this->room&amp;u=".rand (1, 3)."&amp;update_mode=2'><img src='icons/update.png' alt='up' /></a> ";
  76. $links = " <a href='?room=$this->room&amp;module=smiles'><img src='icons/smiles.png' alt='' /></a> <a href='?room=$this->room&amp;module=bbcodes'><img src='icons/bbcodes.png' alt='' /></a> ";
  77. if (empty ($_SESSION['update_mode']))
  78. {
  79. $result .= "<a href='?room=$this->room&amp;update_mode=1'><img src='icons/auto_update.png' alt='aup' /></a>$links";
  80. }
  81. else
  82. {
  83. if (!empty ($_GET['update_interval']))
  84. {
  85. if ($_GET['update_interval'] < 3)
  86. $_GET['update_interval'] = 3;
  87. $_SESSION['update_interval'] = (int) $_GET['update_interval'];
  88. }
  89. if (empty ($_SESSION['update_interval']))
  90. $_SESSION['update_interval'] = 10;
  91. header ("Refresh: $_SESSION[update_interval]; url=?room=$this->room&amp;update_mode=1&".rand (1,9));
  92. $result .= "<a href='?room=$this->room&amp;update_mode=2'><img src='icons/auto_update.png' alt='aup' /></a>$links<br />
  93. Интервал обновления: <form method='get' action=''><input type='hidden' name='room' value='$this->room' /><input type='text' size='2' name='update_interval' value='$_SESSION[update_interval]' /> сек <input type='submit' value='Save' /></form>";
  94. }
  95. return $result;
  96. }
  97. }