Просмотр файла comm/group_board.php

Размер файла: 2.7Kb
  1. <?php
  2. include_once '../sys/inc/start.php';
  3. include_once '../sys/inc/compress.php';
  4. include_once '../sys/inc/sess.php';
  5. include_once '../sys/inc/home.php';
  6. include_once '../sys/inc/settings.php';
  7. include_once '../sys/inc/db_connect.php';
  8. include_once '../sys/inc/ipua.php';
  9. include_once '../sys/inc/fnc.php';
  10. include_once '../sys/inc/user.php';
  11.  
  12. if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `group` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"),0)==1)
  13. {
  14. $id = intval($_GET['id']);
  15. $g = mysql_fetch_array(mysql_query("SELECT * FROM `group` WHERE `id` = '$id' LIMIT 1"));
  16. $ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $g[user] LIMIT 1"));
  17.  
  18. if (isset($_GET['del']) && isset($user))
  19. {
  20. $p = mysql_fetch_array(mysql_query("SELECT * FROM `group_board` WHERE `id` = '".intval($_GET['del'])."' LIMIT 1"));
  21. $a = mysql_fetch_array(mysql_query("SELECT `level` FROM `user` WHERE `id` = '$p[user]' LIMIT 1"));
  22. if ($user['level']>$a['level'] || $user['id']==$ank['id'])mysql_query("DELETE FROM `group_board` WHERE `id` = '".intval($_GET['del'])."' LIMIT 1");
  23. else {header("Location: index.php?");exit;}
  24.  
  25. header("Location: group_board.php?id=$id");exit;
  26. }
  27.  
  28. $set['title'] = 'Чат сообщества '.$g['name'];
  29. include_once '../sys/inc/thead.php';
  30. title();
  31. aut();
  32.  
  33. $k_m=mysql_result(mysql_query("SELECT COUNT(*) FROM `group_board` WHERE `g` = '$id'"), 0);
  34. $k_page=k_page($k_m,$set['p_str']);
  35. $page=page($k_page);
  36. $start=$set['p_str']*$page-$set['p_str'];
  37.  
  38. if ($k_m == '0')echo '<div class="p_m"> Нет сообщений</div>';
  39.  
  40. $q = mysql_query("SELECT * FROM `group_board` WHERE `g` = '$id' ORDER BY time DESC LIMIT $start, $set[p_str]");
  41. while ($p = mysql_fetch_array($q))
  42. {
  43.  
  44. $a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $p[user] LIMIT 1"));
  45.  
  46. $inf = '';
  47. if (mysql_result(mysql_query("SELECT COUNT(*) FROM `group_u` WHERE `id` = '$id' AND `user` = '$a[id]' LIMIT 1"),0)==0)$inf = 'Гость ';
  48. elseif ($a['id']==$ank['id'])$inf = '<img src="m.png"alt=""> ';
  49.  
  50. echo ' <a href="/info.php?id='.$a['id'].'">'.$a['nick'].'</a> '.$inf.online($p['user']).' ('.vremja($p['time']).')';
  51.  
  52. echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($p['msg']))))))))."\n";
  53.  
  54. if (isset($user) && ($user['level']>$a['level'] || $user['id']==$ank['id']))echo ' <a href="group_board.php?id='.$id.'&amp;del='.$p['id'].'"><b>x</b></a>';
  55.  
  56.  
  57. }
  58.  
  59. if ($k_page>1)str("?id=$id&",$k_page,$page);
  60. if (isset($user) && $_SESSION['g_board']+30 < $time)echo '<div class="p_t"> :: <a href="board_add.php?id='.$id.'">Добавить сообщение</a></div>';
  61.  
  62. echo '<br /> :: <a href="index.php?id='.$id.'">Назад</a><br>';
  63.  
  64. include_once '../sys/inc/tfoot.php';
  65. }
  66. header('Location: index.php?');
  67. ?>