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

Размер файла: 2.26Kb
  1. <?php
  2. include '../wap/config.php';
  3. include '../wap/guestbook/mylib.php';
  4. include 'acl.php';
  5. $access=4;
  6. $addr=$_SERVER['REMOTE_ADDR'];
  7. list ($uid, $pl) = priv_level();
  8. $agent=$_SERVER['HTTP_USER_AGENT'];
  9. $addr=$_SERVER['REMOTE_ADDR'];
  10. $f=htmlspecialchars(trim($_POST['f']),ENT_QUOTES);
  11. $t=htmlspecialchars(trim($_POST['t']),ENT_QUOTES);
  12. if ((!$f)&&(!$t)) exit;
  13. if (!$t) $theme=$_POST['theme'];
  14. $message=htmlspecialchars(trim($message),ENT_QUOTES);
  15. if (!$t) $theme=htmlspecialchars(trim($theme),ENT_QUOTES);
  16. if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) exit;
  17. pg_query($conn,"SET CLIENT_ENCODING TO 'KOI8';");
  18. if (!$t) {
  19. $res=pg_query($conn,"select flag from forums where id='$f';");
  20. if (!pg_numrows($res)) { pg_close($conn); exit; }
  21. $flag=pg_result($res,0,0);
  22. } else {
  23. $res=pg_query($conn,"select forums.id,forums.flag from forums,themes where forums.id=themes.forum and themes.id='$t';");
  24. if (!pg_numrows($res)) { pg_close($conn); exit; }
  25. $f=pg_result($res,0,0);
  26. $flag=pg_result($res,0,1);
  27. }
  28. $dtime=time()-300;
  29.  
  30. $mtime=time();
  31. pg_query($conn,"begin;");
  32. if (!$t) {
  33. pg_query($conn,"insert into themes (forum,uid,name,time,lastrepl) values ('$f','$uid','$theme','$mtime','$mtime');");
  34. $res=pg_query($conn,"select currval('public.themes_id_seq');");
  35. $t=pg_result($res,0,0);
  36. pg_query($conn,"update forums set nthemes=nthemes+1 where id='$f';");
  37. pg_query($conn,"insert into threads (theme,message,uid,agent,host,time) values ('$t','$message','$uid','$agent','$addr','$mtime');");
  38. } else {
  39. pg_query($conn,"insert into threads (theme,message,uid,agent,host,time) values ('$t','$message','$uid','$agent','$addr','$mtime');");
  40. pg_query($conn,"update forums set nrepl=nrepl+1 where id='$f';");
  41. pg_query($conn,"update themes set rplnum=rplnum+1,lastrepl='$mtime' where id='$t';");
  42. pg_query($conn,"delete from seen_by where theme='$t';");
  43. }
  44. pg_query($conn,"update users set lastact='$mtime',fposts=fposts+1,lastagent='$agent',lastforum='$mtime' where id='$uid';");
  45. pg_query($conn,"end;");
  46. if (!$res) { pg_close($conn); exit; }
  47. pg_close($conn);
  48. $link=sprintf("Location: forum.php?lang=%s&t=%s&f=%s", $lang, $t, $f);
  49. header($link);
  50. ?>
  51. hp?lang=%s&t=%s&f=%s", $lang, $t, $f);
  52. header($link);
  53. ?>