【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“vtopic.php”一文,供大家参考学习
<?php
if(!defined('SEO-BOARD'))
{
die($lang['fatal_error']);
}
require ('smilies/smilies.php');
if (!isset($t) || !is_numeric($t))
die($lang['fatal_error']);
if (!isset($p))
$p = 1;
if (!is_numeric($p) || ($p<1))
die($lang['fatal_error']);
if ($p > 1)
$enable_delete = 1;
$result = mysql_query("SELECT topic_title, forum_id, topic_numreplies, topic_sticky, topic_locked, topic_moved FROM {$dbpref}topics WHERE topic_id='$t'");
if (mysql_num_rows($result)!=1)
die($lang['fatal_error']);
list($title, $f, $num_replies, $t_sticky, $t_locked, $t_moved) = mysql_fetch_row($result);
if (!forum_visible($user_id, $f))
die($lang['access_denied']);
//is the logged user a moderator
$user_mod = is_user_moderator($f, $user_id);
//generate forum_path & validate $f (forum_id)
$forum_path = get_forum_path($f, $title);
require('forumheader.php');
$errormessage = null;
$startfrom = ($p-1) * $postsperpage;
if (($p!=1) && ($num_replies < $startfrom))
die($lang['fatal_error']);
if (!isset($preview))
$pagination = get_topic_pages($t, $p, $num_replies+1);
else
$pagination = '<br>';
if (isset($_POST["postreply"]))
{
if (!can_user_post_reply($user_id, $f, $t_locked))
die($lang['access_denied']);
$message = stripslashes($message);
//anti-spam protection
$poster_ip = $_SERVER["REMOTE_ADDR"];
$spam_time_limit = time()-$antispam;
if (mysql_result(mysql_query("SELECT count(*) FROM {$dbpref}posts WHERE post_author_ip='$poster_ip' AND post_time > '$spam_time_limit'"), 0) > 0)
$errormessage = get_error($lang['anti_spam']);
if (strlen($message) == 0)
$errormessage = get_error($lang['message_empty']);
if (is_null($errormessage) && isset($makeurls) && isset($bbcodes))
$message = makeURLs($message);
if (is_null($errormessage))
$errormessage = validate_text($message, isset($bbcodes));
if (!is_null($errormessage))
{
$message = format_html($message);
$bbcodes_check = isset($bbcodes) ? 'checked' : null;
$emoticons_check = isset($emoticons) ? 'checked' : null;
$makeurls_check = isset($makeurls) ? 'checked' : null;
$smiliesbar = generate_smilies_bar('document.PForm.message');
print eval(get_template('userpostreply'));
}
else
{
if (isset($preview))
{
$cell_iterator = 0;
if (!in_array($f, $allowhtmlforums))
$message = format_html($message);
$post_title = $lang['preview_reply'].': '.format_html($title);
$post_message = $message;
if (isset($emoticons))
$post_message = str_replace($sm_search, $sm_replace, $post_message);
if (isset($bbcodes))
$post_message = format_bbcodes($post_message);
$post_message = fix_tabs_spaces($post_message);
if ($user_id == 0)
{
$posted_by = '<span class=memberbutton style="text-decoration: none; cursor: default;">'.$user_name.'</span>';
$author_num_posts = null;
$author_reg_date = null;
$author_online = null;
}
else
{
$posted_by = get_member_link($user_id, $user_name);
$author_num_posts = $lang['posts'].': '.($user_numposts+1);
$author_reg_date = $lang['joined'].': '.format_shortdate($user_regdate);
if ($user_allowviewonline == 0)
$author_online = null;
else
$author_online = '<br>'.$lang['user_online'];
}
$user_type = get_user_type($user_id, $f);
$posted_on = $lang['posted'].': '.format_datetime(time(), $user_timezone);
$user_ip = null;
$edited_by = null;
$post_actions = null;
$posts_html = eval(get_template('mainpostcell'));
$topic_commands = null;
print eval(get_template('mainposttable'));
$bbcodes_check = isset($bbcodes) ? 'checked' : null;
$emoticons_check = isset($emoticons) ? 'checked' : null;
$makeurls_check = isset($makeurls) ? 'checked' : null;
$smiliesbar = generate_smilies_bar('document.PForm.message');
print eval(get_template('userpostreply'));
}
else
{
$now = time();
//create reply
$message_status = 0;
if (isset($bbcodes))
{
$message_status |= 1;
//are there any bbcodes to format?
if (format_bbcodes($message) != $message)
$message_status |= 2;
}
if (isset($emoticons))
{
$message_status |= 4;
//are there any smilies to convert?
if (str_replace($sm_search, $sm_replace, $message) != $message)
$message_status |= 8;
}
$message = addslashes($message);
mysql_query("INSERT INTO {$dbpref}posts (topic_id, post_author, post_author_id, post_author_ip, post_text, post_text_s