View file katrinka.ru/admin/forum_sign.php

File size: 2.26Kb
<?php
  include '../wap/config.php';
  include '../wap/guestbook/mylib.php';
  include 'acl.php';
  $access=4;
  $addr=$_SERVER['REMOTE_ADDR'];
  list ($uid, $pl) = priv_level();
  $agent=$_SERVER['HTTP_USER_AGENT'];
  $addr=$_SERVER['REMOTE_ADDR'];
  $f=htmlspecialchars(trim($_POST['f']),ENT_QUOTES);
  $t=htmlspecialchars(trim($_POST['t']),ENT_QUOTES);
  if ((!$f)&&(!$t)) exit;
  if (!$t) $theme=$_POST['theme'];
  $message=htmlspecialchars(trim($message),ENT_QUOTES);
  if (!$t) $theme=htmlspecialchars(trim($theme),ENT_QUOTES);
    if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) exit;
  pg_query($conn,"SET CLIENT_ENCODING TO 'KOI8';");
	if (!$t) {
		$res=pg_query($conn,"select flag from forums where id='$f';");
		if (!pg_numrows($res)) { pg_close($conn); exit; }
		$flag=pg_result($res,0,0);
	} else {
		$res=pg_query($conn,"select forums.id,forums.flag from forums,themes where forums.id=themes.forum and themes.id='$t';");
		if (!pg_numrows($res)) { pg_close($conn); exit; }
		$f=pg_result($res,0,0);
		$flag=pg_result($res,0,1);
	}
	$dtime=time()-300;

	$mtime=time();
	pg_query($conn,"begin;");
	if (!$t) {
		pg_query($conn,"insert into themes (forum,uid,name,time,lastrepl) values ('$f','$uid','$theme','$mtime','$mtime');");
		$res=pg_query($conn,"select currval('public.themes_id_seq');");
		$t=pg_result($res,0,0);
		pg_query($conn,"update forums set nthemes=nthemes+1 where id='$f';");
		pg_query($conn,"insert into threads (theme,message,uid,agent,host,time) values ('$t','$message','$uid','$agent','$addr','$mtime');");
	} else {
		pg_query($conn,"insert into threads (theme,message,uid,agent,host,time) values ('$t','$message','$uid','$agent','$addr','$mtime');");
		pg_query($conn,"update forums set nrepl=nrepl+1 where id='$f';");
		pg_query($conn,"update themes set rplnum=rplnum+1,lastrepl='$mtime' where id='$t';");
		pg_query($conn,"delete from seen_by where theme='$t';");
	}
	pg_query($conn,"update users set lastact='$mtime',fposts=fposts+1,lastagent='$agent',lastforum='$mtime' where id='$uid';");
	
	pg_query($conn,"end;");
	if (!$res) { pg_close($conn); exit; }
    pg_close($conn);
	$link=sprintf("Location: forum.php?lang=%s&t=%s&f=%s", $lang, $t, $f);
		header($link);
?>
hp?lang=%s&t=%s&f=%s", $lang, $t, $f);
		header($link);
?>