Просмотр файла katrinka.ru/admin/forum.php

Размер файла: 5.41Kb
  1. <?php
  2. include '../wap/guestbook/mylib.php';
  3. include '../wap/config.php';
  4. include 'acl.php';
  5. $addr=$_SERVER['REMOTE_ADDR'];
  6. list ($uid, $pl) = priv_level();
  7. $fppp=30;
  8. $ftpp=30;
  9. $fnewtop='f';
  10. if ($uid==1) $fnewtop='t';
  11. # $pflag=0;
  12. $lang=$_GET['lang'];
  13. $f=htmlspecialchars(trim($_GET['f']),ENT_QUOTES);
  14. $t=htmlspecialchars(trim($_GET['t']),ENT_QUOTES);
  15. $p=htmlspecialchars(trim($_GET['p']),ENT_QUOTES);
  16. ?>
  17. <?php
  18. if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass")))
  19. {
  20. exit;
  21. }
  22. pg_query($conn,"SET CLIENT_ENCODING TO 'KOI8';");
  23.  
  24. if (($f==0)&&($t==0)) {
  25. header("Cache-Control: no-cache");
  26. ?>
  27. <html>
  28. <head><meta http-equiv="Cache-Control" content="no-cache"></head>
  29. <body>
  30. <?php
  31. print "<p align=\"center\">\n";
  32. $res=pg_query($conn,"select id,name,flag,nthemes,nrepl,note from forums order by id;");
  33. $rows=pg_numrows($res);
  34. $timex=time()-300;
  35. for ($i=0; $i<$rows; $i++) {
  36. $rid=pg_result($res,$i,0);
  37. $nthemes=pg_result($res,$i,3);
  38. $nrepl=pg_result($res,$i,4);
  39. $note=pg_result($res,$i,5);
  40. $forum='';
  41. $flag=pg_result($res,$i,2);
  42. if (($flag!=1)||(($flag==1)&&($access))) {
  43. if ($uid) {
  44. $isnew='';
  45. $fres=pg_query($conn,"select id from fseen_by where uid='$uid' and forum='$rid';");
  46. if (!pg_numrows($fres)) $isnew='*';
  47. }
  48. $forum=pg_result($res,$i,1);
  49. print "<a href=\"forum.php?f=".$rid."&amp;lang=".$lang."\">".$isnew." ".$forum." (".$nthemes.") [".$nrepl."]</a><br/>".$note."<br/><br/>\n";
  50. }
  51. }
  52. }
  53.  
  54. if (($f>0)&&(!$t)) {
  55. header("Cache-Control: no-cache");
  56. ?>
  57. <html>
  58. <head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
  59. <body>
  60. <?php
  61. $res=pg_query($conn,"select name,flag from forums where id='$f';");
  62. if (!pg_numrows($res)) { pg_close($conn); exit; }
  63. $name=pg_result($res,0,0);
  64. $flag=pg_result($res,0,1);
  65. if ($uid) {
  66. $res=pg_query($conn,"select id from fseen_by where uid='$uid' and forum='$f';");
  67. if (!pg_numrows($res))
  68. pg_query($conn,"insert into fseen_by (uid,forum) values ('$uid','$f');");
  69. }
  70. print "<p>\n";
  71. $offset=$p*$ftpp;
  72. $res=pg_query($conn,"select themes.id,themes.name,themes.rdnum,themes.rplnum,themes.time,themes.uid,users.login,themes.closed,themes.sticker from themes,users where users.id=themes.uid and users.moder=0 and themes.forum='$f' order by sticker desc,themes.lastrepl desc limit '$ftpp' offset '$offset';");
  73. $rows=pg_numrows($res);
  74. for ($i=0; $i<$rows; $i++) {
  75. $id=pg_result($res,$i,0);
  76. $name=pg_result($res,$i,1);
  77. $rdnum=pg_result($res,$i,2);
  78. $rplnum=pg_result($res,$i,3);
  79. $time=strftime("%d/%m %H:%M", pg_result($res,$i,4));
  80. $fr_u=pg_result($res,$i,5);
  81. $login=pg_result($res,$i,6);
  82. $closed=pg_result($res,$i,7);
  83. $sticker=pg_result($res,$i,8);
  84. if ($closed) $isclosed='(closed)'; else $isclosed='';
  85. if ($sticker=='t') $issticker='(*)'; else $issticker='';
  86. $isnew='';
  87. if ($uid) {
  88. $fres=pg_query($conn,"select id from seen_by where uid='$uid' and theme='$id';");
  89. if (!pg_numrows($fres)) $isnew='(new)';
  90. }
  91. print "<a href=\"forum_del.php?t=".$id."\">[x]</a> <a href=\"forum_close.php?t=".$id."\">[c]</a> <a href=\"user_edit.php?id=".$fr_u."\">".$login." [".$rplnum."] &lt;".$rdnum."&gt;</a> ".$time."<br/>".$name."<br/><a href=\"forum.php?t=".$id."&amp;lang=".$lang."\">".$issticker.$isclosed.$isnew."&gt;&gt;&gt;&gt;</a><br/>\n";
  92. print "<hr>\n";
  93. }
  94. print "<br/>\n";
  95. if ($p) print "<a href=\"forum.php?f=".$f."&amp;p=".($p-1)."\">Prev ".$ftpp."</a><br/>";
  96. if ($rows==$ftpp) print "<a href=\"forum.php?f=".$f."&amp;p=".($p+1)."\">Next ".$ftpp."</a><br>";
  97. print "<a href=\"forum.php\">уРЙУПЛ жПТХНПЧ</a>&nbsp;&nbsp;\n";
  98. print "<a href=\"forum_post.php?f=".$f."\">оПЧБС ФЕНБ</a>\n";
  99. }
  100.  
  101. if ($t>0) {
  102. header("Cache-Control: no-cache");
  103. ?>
  104. <html>
  105. <head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
  106. <body>
  107. <?php
  108. if (!$p) pg_query($conn,"update themes set rdnum=rdnum+1 where id='$t';");
  109. if ($uid) {
  110. $res=pg_query($conn,"select id from seen_by where uid='$uid' and theme='$t';");
  111. if (!pg_numrows($res))
  112. pg_query($conn,"insert into seen_by (uid,theme) values ('$uid','$t');");
  113. }
  114. $res=pg_query($conn,"select themes.forum,forums.flag from themes,forums where themes.id='$t' and forums.id=themes.forum;");
  115. $f=pg_result($res,0,0);
  116. $flag=pg_result($res,0,1);
  117. print "<p>\n";
  118. $offset=$p*$fppp;
  119. if ($fnewtop=='t') $rev='desc'; else $rev='';
  120. $res=pg_query($conn,"select threads.id,threads.message,threads.uid,threads.time,users.login where users.id=threads.uid and users.moder=0 and threads.theme='$t' order by threads.id $rev limit '$fppp' offset '$offset';");
  121. $rows=pg_numrows($res);
  122. for ($i=0; $i<$rows; $i++) {
  123. $id=pg_result($res,$i,0);
  124. $message=pg_result($res,$i,1);
  125. $fr_u=pg_result($res,$i,2);
  126. $time=strftime("%d/%m %H:%M",pg_result($res,$i,3));
  127. $login=pg_result($res,$i,4);
  128. print "<a href=\"forum_del.php?pid=".$id."\">[x]</a> <a href=\"user_edit.php?id=".$fr_u."\">".$login."</a> ".$time."<br/>".$message."<br/>\n";
  129. print "<hr>\n";
  130. }
  131. print "<br/>\n";
  132. if ($p) print "<a href=\"forum.php?t=".$t."&amp;p=".($p-1)."\">Prev ".$fppp."</a><br/>";
  133. if ($rows==$fppp) print "<a href=\"forum.php?t=".$t."&amp;p=".($p+1)."\">Next ".$fppp."</a>";
  134. ?>
  135. <FORM NAME="message" METHOD=POST ACTION="forum_sign.php">
  136. <input type="text" name="message" size="80">
  137. <?php print "<input type=\"hidden\" name=\"t\" value=\"".$t."\">\n"; ?>
  138. <INPUT TYPE=SUBMIT VALUE="рЕТЕУМБФШ">
  139. </FORM>
  140. <?php
  141. print "<a href=\"forum.php?f=".$f."\">уРЙУПЛ фЕН</a>\n";
  142. }
  143.  
  144. ?>
  145. </p>
  146. </body>
  147. </html>