Location: PHPKode > projects > Phpfastnews > article_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 = "article_reply";
$tpl = "article.tpl";

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

require('Lib/prependphpfn.php');

$r->set_block('TPL','ARTICLE_REPLY');

if ($type == "preview" || !$type)
	{
$r->set_block('TPL','REPLY');
$r->set_block('ARTICLE_REPLY','showareply');
$query = "select * from fn_aposts,fn_user where post_id = '$r2_id' and user_id2 = user_idfk";
	
$db->query($query);
	while ($db->next_record())	{
		$r->set_var('lnkVIEWREPLY',"article_reply.php&r_id=" . $db->f("post_id"));
		$r->set_var('SUBJECT',$db->f("subject"));
		$r->set_var('BODY',$db->f("body"));
		$r->set_var('POSTEDBY',$db->f("user_handle"));
		$r->set_var('DATETIME', $ndate($db->f("when_posted")));
		$r->parse('body','showareply',true);
	}

$r->set_block('ARTICLE_REPLY','showpreview');
if ($type == "preview")	{

	$r->set_var(array(
		"SUBJECT"	=>	stripslashes(scrub($text_s)),
		"POSTEDBY"	=> $handle,
		"DATETIME"	=> $ndate(time()),
		"BODY"		=> stripslashes(scrub($text)) . "<br>"));
	$r->parse('body','showpreview',true);
	}

$r->set_block('ARTICLE_REPLY','REPLY');
$r->set_var("SUBJECT", $db->f("subject"));
$r->set_var("BODY", $db->f("body"));
$r->set_var("R_ID", $r_id);
$r->set_var("R2_ID", $r2_id);
$r->set_var("TEXT", $text);
$r->set_var("TEXT_S", $text_s);
$r->parse('body','REPLY',true);
	}

if ($type == "post")	{

	$now = time();
	scrub($text);
	scrub($text_s);
	if ($handle == $anonname) { $useridfk = '0'; } else { $useridfk = $auth[user_id]; }
	$query = "insert into fn_aposts SET user_idfk = '$useridfk', parent = '$r_id', article_idfk= '$r_id', subject = '$text_s', body = '$text', apost_cdate = '$now'";
	$db->query($query);
	$query = "update fn_article SET replies = replies+1 where article_id = '$r_id'";
	$db->query($query);
	
	//$t->set_file('AR', 'article.tpl');
	//$t->set_block('AR', 'DONEPOSTING', 'done');
	//$t->parse('body','DONEPOSTING',true);
	
}

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