<?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 = "news_index";
$tpl = "news.tpl";
//broken, fix in all 'reply' php files
if ($post == "post") {
$r->set_var('METAREFRESH','<meta http-equiv=Refresh content=4;url=news_view.php?r_id=". $r_id . ">');
}
//end broken
require('Lib/prependphpfn.php');
$r->set_block('TPL','NEWS_REPLY');
$r->set_block('TPL','REPLIES');
if ($type == "preview" || !$type) {
if ($type == "preview") {
$r->set_block('TPL','PREVIEW');
if (!$handle) { $handle = 'Anonymous'; }
$r->set_var(array(
"SUBJECT" => stripslashes(scrub($text_s)),
"POSTEDBY" => $handle,
"DATETIME" => $ndate(time()),
"BODY" => stripslashes(scrub($text)) . "<br>"));
$r->parse('PREV','REPLIES');
$r->parse('body','PREVIEW',true);
}
if ($r_id) {
$query = "select * from fn_news,fn_user,fn_user2 where (news_id = '$r_id') and (user_idfk = fn_user.user_id2) and (user_idfk = fn_user2.user_id2)";
$db->next_record($db->query($query));
$r->set_block('TPL','ORIGPOST');
$r->set_var(array(
"SUBJECT" => $db->f("subject"),
"POSTEDBY" => $db->f("handle"),
"DATETIME" => $ndate($db->f("n_cdate")),
"BODY" => $db->f("body")));
$r->parse('PREV','REPLIES');
$r->parse('body','ORIGPOST',true);
$text_s = re_fix($db->f("subject"));
}
if ($r2_id) {
$query = "select * from fn_nposts,fn_user where (post_id = '$r2_id') and (user_id2 = user_idfk)";
$db->next_record($db->query($query));
$r->set_block('TPL','INREPLYTO');
$r->set_var(array(
"SUBJECT" => $db->f("subject"),
"POSTEDBY" => $db->f("handle"),
"DATETIME" => $ndate($db->f("p_cdate")),
"BODY" => $db->f("body")));
//$r->doloop('REPLIES','PREV','INREPLYTO');
$r->parse('PREV','REPLIES');
$r->parse('body','INREPLYTO',true);
$text_s = re_fix($db->f('subject'));
}
$r->set_block('TPL','REPLY');
$r->set_var(array(
"POSTINGAS" => $handle,
"R_ID" => $r_id,
"R2_ID" => $r2_id,
"TEXT" => stripslashes($text),
"TEXT_S" => stripslashes($text_s)));
$r->parse('body','REPLY',true);
}
if ($type == "post") {
$r->set_block('TPL','DONEPOSTING');
$now = time();
$text = scrub($text);
$text_s = scrub($text_s);
if ($handle == $anonname) { $useridfk = '0'; } else { $useridfk = $auth[user_id]; }
$query = "insert into fn_nposts
SET parent = '$r2_id',
news_idfk= '$r_id',
subject = '$text_s',
body = '$text',
p_cdate = '$now',
user_idfk = '$useridfk'";
$db->query($query);
$query = "update fn_news SET replies = replies+1 where news_id = '$r_id'";
$db->query($query);
$query = "update fn_news SET n_ldate = '$now' where news_id = '$r_id'";
$db->query($query);
$r->parse('body','DONEPOSTING',true);
}
require('Lib/appendphpfn.php');
?>