function print_message($thread, $msg) { global $template_dir, $user, $forum; global $tpl; /* hack to get current page */ $mtpl = new Template($template_dir, "comment"); $mtpl->set_file("message", "message.tpl"); message_set_block($mtpl); $iid = mid_to_iid($msg['mid']); if (isset($iid)) { $sql = "update f_messages{$iid} set views = views + 1 where mid = ?"; db_exec($sql, array($msg['mid'])); } $uuser = new ForumUser($msg['aid']); $mtpl->set_var("parent", ""); render_message($mtpl, $msg, $user, $uuser); /* in threaded mode, subject is a link. override MSG_SUBJECT set above. */ $mtpl->set_var("MSG_SUBJECT", "<a href=\"../msgs/" . $msg['mid'] . ".phtml\" name=\"" . $msg['mid'] . "\">" . $msg['subject'] . "</a>"); $mtpl->set_var("FORUM_SHORTNAME", $forum['shortname']); $mtpl->set_var("PAGE", $tpl->get_var('PAGE')); $mtpl->parse("MESSAGE", "message"); return $mtpl->get_var("MESSAGE"); }
} /* Check the data to make sure they entered stuff */ if (!isset($mid) || !isset($forum)) { /* Hmm, how did this happen? Redirect them back to the main page */ header("Location: http://{$server_name}{$script_name}{$path_info}/"); exit; } require_once "strip.inc"; require_once "message.inc"; $tpl->set_file(array("del" => "delete.tpl", "message" => "message.tpl", "forum_header" => array("forum/" . $forum['shortname'] . ".tpl", "forum/generic.tpl"))); $tpl->set_block("del", "disabled"); message_set_block($tpl); $tpl->set_var("FORUM_NAME", $forum['name']); $tpl->set_var("FORUM_SHORTNAME", $forum['shortname']); $tpl->parse("FORUM_HEADER", "forum_header"); $iid = mid_to_iid($mid); if (!isset($iid)) { echo "Invalid message!\n"; exit; } $sql = "select * from f_messages{$iid} where mid = ?"; $msg = db_query_first($sql, array($mid)); if ($msg['aid'] != $user->aid) { echo "This message does not belong to you!\n"; exit; } if (!isset($forum['option']['PostEdit'])) { $tpl->set_var(array("image" => "", "preview" => "", "form" => "", "accept" => "")); print generate_page('Delete Message Denied', $tpl->parse("CONTENT", "disabled")); exit; }
if (!$accepted || isset($preview)) { require_once "postform.inc"; render_postform($tpl, "post", $user, $msg, $imgpreview); $tpl->set_var(array("accept" => "", "duplicate" => "")); } else { require_once "postmessage.inc"; /* sets $msg['mid'] to the new message id */ if (postmessage($user, $forum['fid'], $msg, $_POST) == true) { $tpl->set_var("duplicate", ""); } require_once "mailfrom.inc"; $sql = "select * from f_tracking where fid = ? and tid = ? and options = 'SendEmail' and aid != ?"; $sth = db_query($sql, array($forum['fid'], $msg['tid'], $user->aid)); $track = $sth->fetch(); if ($track) { $iid = mid_to_iid($thread['mid']); if (!isset($iid)) { throw new RuntimeException("no iid for thread mid " . $thread['mid']); } $sql = "select subject from f_messages{$iid} where mid = ?"; $row = db_query_first($sql, array($thread['mid'])); list($t_subject) = $row; $e_message = substr($msg['message'], 0, 1024); if (strlen($msg['message']) > 1024) { $bytes = strlen($msg['message']) - 1024; $plural = $bytes == 1 ? '' : 's'; $e_message .= "...\n\nMessage continues for another {$bytes} byte{$plural}\n"; } $tpl->set_var(array("THREAD_SUBJECT" => $t_subject, "USER_NAME" => $user->name, "HOST" => $_url, "FORUM_NAME" => $forum['name'], "FORUM_SHORTNAME" => $forum['shortname'], "MSG_MID" => $msg['mid'], "MAIL_MSG_SUBJECT" => $msg['subject'], "MAIL_MSG_MESSAGE" => $e_message, "PHPVERSION" => phpversion())); do { $uuser = new ForumUser($track['aid']);