【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“vforum.php”一文,供大家参考学习
<?php
if(!defined('SEO-BOARD'))
{
die($lang['fatal_error']);
}
require ('smilies/smilies.php');
if (!isset($f) || !is_numeric($f))
die($lang['fatal_error']);
//generate forum_path & validate $f (forum_id)
if (isset($_POST["createtopic"]))
$forum_path = get_forum_path($f, $lang['preview_topic']);
else
$forum_path = get_forum_path($f);
if (!isset($p))
$p = 1;
if (!is_numeric($p) || ($p<1))
die($lang['fatal_error']);
if (!forum_visible($user_id, $f))
die($lang['access_denied']);
$f_index = $f_lookup_by_id[$f];
$title = $forumtitle.' » '.$f_rows[$f_index][3];
require('forumheader.php');
$errormessage = null;
//if is forum category or has sub-forums then print them
if (isset($f_lookup_by_parent[$f]) && !isset($_POST["createtopic"]))
{
$forums_html = array();
$cell_iterator = 0;
$template_forum = get_template('forumcell');
$shownforums = 0;
$f_index = $f_lookup_by_parent[$f];
while (isset($f_rows[$f_index]) && ($f_rows[$f_index][1] == $f))
{
list($f_id, , , $f_name, $forum_desc, $num_topics, $num_replies, $lastpost_time, $lastposter) = $f_rows[$f_index];
if (!forum_visible($user_id, $f_id))
{
++$f_index;
continue;
}
$forum_link = get_forum_link($f_id, $f_name, 'forumlink');
$subforums = '';
$moderated_by = ($showmoderators == 0) ? null : get_forum_moderators($f_id);
if ($num_topics == 0)
$lastpost = $lang['no_posts_yet'];
else
$lastpost = $lastposter.'<br>'.format_datetime($lastpost_time, $user_timezone);
$num_subforums = 0;
if (isset($f_lookup_by_parent[$f_id]))
{
$subf_index = $f_lookup_by_parent[$f_id];
$subforums = "<div class=subforums>» {$lang['sub_forums']}: ";
while (true)
{
$subf_id = $f_rows[$subf_index][0];
if (forum_visible($user_id, $subf_id))
{
$subforums .= get_forum_link($subf_id, $f_rows[$subf_index][3], 'forumlink');
++$num_subforums;
}
if (isset($f_rows[++$subf_index]) && ($f_rows[$subf_index][1] == $f_id))
{
if ($num_subforums > 0)
$subforums .= ',  ';
}
else
break;
}
}
if ($num_subforums == 0)
$subforums = null;
else
$subforums .= '</div>';
array_push($forums_html, eval($template_forum));
++$shownforums;
++$f_index;
$cell_iterator = 1 - $cell_iterator;
}
$forums_html = implode('',$forums_html);
if ($shownforums != 0)
print eval(get_template('mainforumtable'));
}
// show topics
if (($f_rows[$f_lookup_by_id[$f]][1]!=0) && !isset($_POST["createtopic"]))
{
$startfrom = ($p-1) * $topicsperpage;
if (($p!=1) && ($f_rows[$f_lookup_by_id[$f]][5] <= $startfrom))
die($lang['fatal_error']);
$pagination = get_forum_pages($f, $p, $f_rows[$f_lookup_by_id[$f]][5]);
if (!in_array($f, $articleforums))
$result = mysql_query("SELECT topic_id, topic_title, topic_poster_name, topic_poster_id, topic_lastposter_name, topic_lastposter_id, topic_created_time, topic_lastpost_time, topic_numreplies, topic_numviews, topic_sticky, topic_locked, topic_moved FROM {$dbpref}topics WHERE forum_id='$f' ORDER BY topic_sticky DESC, topic_lastpost_time DESC LIMIT $startfrom,$topicsperpage");
else
$result = mysql_query("SELECT topic_id, topic_title, topic_poster_name, topic_poster_id, topic_lastposter_name, topic_lastposter_id, topic_created_time, topic_lastpost_time, topic_numreplies, topic_numviews, topic_sticky, topic_locked, topic_moved FROM {$dbpref}topics WHERE forum_id='$f' ORDER BY topic_sticky DESC, topic_created_time DESC LIMIT $startfrom,$topicsperpage");
if (mysql_num_rows($result) == 0)
{
show_message($lang['no_topics_yet']);
}
else
{
$cell_iterator = 0;
$topics_html = array();
$template_topic = get_template('maintopiccell');
while($row = mysql_fetch_row($result))
{
list($id, $title, $author, $author_id, $lastposter, $lastposter_id, $createdtime, $lastposttime, $num_replies, $num_views, $sticky, $locked, $moved) = $row;
$topic_link = get_topic_link($id, $title, $num_replies+1, 'topiclink');
if (($lastposttime > $user_lastsession) && ($lastposter_id != $user_id) && ($user_id != 0))
if ($createdtime < $user_lastsession) //created before lastsession
$topic_link = '<sup>'.$lang['new'].'</sup> '.$topic_link;
else//created after lastsession
if ($author_id != $user_id)
$topic_link = '<sup>'.$lang['new'].'</sup> '.$topic_link;
$topic_ind = array ();
if ($sticky == 1)
array_push($topic_ind, $lang['sticky']);
if ($moved == 1)
array_push($topic_ind, $lang['moved']);
if ($locked == 1)
array_push($topic_ind, $lang['locked']);
if (!empty($topic_ind))
$topic_link .= ' <sup>'.implode(', ',$topic_ind).'</sup>';
$started_by = $lang['started_by'].' '.$author;
$lastpost = $lastposter.'<br>'.format_datetime($lastposttime, $user_timezone);
array_push($topics_html, eval($template_topic));
$cell_iterator = 1 - $cell_iterator;
}
$topics_html = implode('', $topics_html);
print eval(get_template('maintopicstable'));
unset($template_topic);
}
}
//END show list of topics
if (isset($_POST["createtopic"]))
{
if (!can_user_create_topic($user_id, $f))
die($lang['access_denied']);
$message = stripslashes($message);
$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 (is_null($errormessage) && (strlen($topictitle)==0))
$errormessage = get_error($lang['title_empty']);
if (is_null($errormessage) && (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);
$topictitle = format_html(stripslashes($topictitle));
$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('usercreatetopic'));
}
else
{
if (isset($preview))
{
$cell_iterator = 0;
$pagination = '<br>';
if (!in_array($f, $allowhtmlforums))
$message = format_html($message);
$topictitle = format_html(stripslashes($topictitle));
$post_title = $lang['preview_topic'].': '.$topictitle;
$post_message = $message;
if (isse
上一篇:
version.php
下一篇:
法律专业开题报告范文