Location: PHPKode > projects > Phpfastnews > forum_reply.php
<?php
/*	Copyright (c) 2001-02 by Ken Williams (hide@address.com)*/
/*	http://phpfastnews.sourceforge.net/ & http://www.phpfastnews.com*/
/*									*/
/*	You can redistribute and/or modify the following code under the	*/
/*	terms of the GNU General Public License as published by the	*/
/*	the Free Software Foundation.					*/
/*									*/
/*	All code by Ken Williams (HDwebdev) unless otherwise noted	*/
/* This is an alpha test release -- not intended for live site	use	*/

$pg = "forum_reply";
$tpl = "forum.tpl";

//broken, fix in all 'reply' php files
if ($post == "post")    {
        $r->set_var('METAREFRESH','<meta http-equiv=Refresh content=4;url=forum_posts.php?f_id=". $f_id . "&r_id=" . $r_id . ">');
        }
//end broken

require('Lib/prependphpfn.php');

$r->set_block('TPL','FORUM_REPLY');
$r->set_block('TPL','REPLIES');

if ($type == "preview" || !$type)
	{
	if ($type == "preview")	{
	$r->set_block('FORUM_REPLY','PREVIEW');
	$r->set_var(array(
		"BODY" => stripslashes(scrub($text)),
		"SUBJECT" => stripslashes(scrub($text_s)),
		"POSTEDBY" => $handle,
		"DATETIME"	=> 'needtoputthisin'
	));

        $r->parse(temp,'REPLIES');
	$r->set_var('PREV',$r->get_var(temp));
	$r->parse('body','PREVIEW',true);

	}

	if ($r_id)
		{
		$query = "select subject,body,handle,ff_name,ff_description from fn_forum,fn_user,fn_fposts where (post_id = '$r_id') and (user_idfk = user_id2) and (forum_id = forum_idfk)";
		$db->next_record($db->query($query));
		$r->set_block('FORUM_REPLY','ORIGPOST');
		$r->set_var(array(
			"SUBJECT"	=> $db->f("subject"),
			"BODY"		=> $db->f("body"),
			"POSTEDBY"	=> $db->f("handle"),
		));
		$text_s = re_fix($db->f("subject"));
		if ($quote && $r2_id) { $text = $db->f("body"); }
                $r->parse('PREV','REPLIES');
                $r->parse('body','ORIGPOST',true);

                }

	if ($r2_id)
		{
		$query = "select * from fn_user,fn_fposts where (post_id = '$r2_id') and (user_idfk = user_id2)";
		$db->next_record($db->query($query));
		$r->set_block('FORUM_REPLY','INREPLYTO');
		$r->set_var(array(
			"SUBJECT"	=>	$db->f("subject"),
			"BODY"		=>	$db->f("body"),
			"POSTEDBY"	=> $db->f("handle")
			));
		if ($quote && !$r2_id) { $text = $db->f("body"); }
		$text_s = re_fix($db->f("subject"));
                $r->parse('PREV','REPLIES');
                $r->parse('body','INREPLYTO',true);

	}
	$text = $text;
	$text_s = $text_s;
	$r->set_block('FORUM_REPLY','REPLY');
	$r->set_var(array(
		"F_ID"		=> $f_id,
		"R_ID"		=> $r_id,
		"R2_ID"		=> $r2_id,
		"TEXT"		=> stripslashes($text),
		"TEXvar_dump($auth);T_S"		=> stripslashes($text_s),
		"NAME"		=>	$db->f("ff_name"),
		"DESC"		=>	$db->f("ff_description")
		));

	if ($quote) {
		$text = $db->f("body");
		$r->set_var("TEXT",_("<i>" . $text . "</i><br><br>"));
		 }
	$r->parse('body','REPLY',true);
}

if ($type == "post")	{
	$now = time();
	$text = scrub($text);
	$text_s = scrub($text_s); 
        // change text_s to default to RE: thepostsubject
        if ($text_s == '') { $text_s = '&nbsp;'; }

	if ($handle == $anonname) { $useridfk = '0'; } else { $useridfk = $auth["user_id"]; }
	$query = "insert into fn_fposts SET repliedto = '$r2_id', parent= '$r_id',
		forum_idfk='$f_id', subject = '$text_s', body = '$text', fp_cdate = '$now',
		user_idfk = '$useridfk'";
	$db->query($query);
	$query = "update fn_forum SET posts = posts+1 where forum_id = '$f_id'";
	$db->query($query);
	$query = "update fn_forum SET f_lastsubj = '$text_s' where forum_id = '$f_id'";
	$db->query($query);
	$query = "update fn_forum SET f_luser= '$auth[user]' where forum_id = '$f_id'";
	$db->query($query);
	$query = "update fn_forum SET f_ldate = '$now' where forum_id = '$f_id'";
	$db->query($query);
	$query = "update fn_fposts SET fp_ldate = '$now' where post_id = '$r_id'";
	$db->query($query);
	$query = "update fn_fposts SET fp_replies = fp_replies+1 where post_id = '$r_id'";
	$db->query($query);
	
	$r->set_block('FORUM_REPLY','DONEPOSTING');
	$r->parse('body','DONEPOSTING',true);
	}

require('Lib/appendphpfn.php');
?>
Return current item: Phpfastnews