post.php

来自「速度很快的PHP论坛源程序」· PHP 代码 · 共 161 行

PHP
161
字号
<?php

/*
	[DISCUZ!] post.php - post module for new threads & replies or editing post
	This is NOT a freeware, use is subject to license terms

	Version: 4.0.0
	Web: http://www.comsenz.com
	Copyright: 2001-2005 Comsenz Technology Ltd.
	Last Modified: 2004/11/23 04:02
*/

require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
require_once DISCUZ_ROOT.'./include/post.func.php';

if(empty($action)) {
	showmessage('undefined_action', NULL, 'HALTED');
} elseif($action == 'smilies') {
	include template('post_smilies');
	exit();
}

if($adminid != 1 && $maintspans) {
	$spanarray = array();
	$now = gmdate('G', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600).'.'
		.intval(gmdate('i', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600));

	foreach(explode(',', str_replace(array(' ', ':'), array('', '.'), $maintspans)) as $span) {
		list($spanbegin, $spanend) = explode('-', $span);
		if($now > doubleval($spanbegin) && $now < doubleval($spanend)) {
			showmessage('post_maintspans');
		}
	}
}

$attachextensions = $forum['attachextensions'] ? $forum['attachextensions'] : $attachextensions;
$allowpostattach = $forum['allowpostattach'] || (!$forum['postattachperm'] && $allowpostattach) || ($forum['postattachperm'] && strstr($forum['postattachperm'], "\t$groupid\t"));

$postcredits = $forum['postcredits'] != -1 ? $forum['postcredits'] : $postcredits;
$replycredits = $forum['replycredits'] != -1 ? $forum['replycredits'] : $replycredits;

if($tid && $fid) {
	$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
	$thread = $db->fetch_array($query);
	$fid = $thread['fid'];
	$navigation = "&raquo; <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a>";
	$navtitle = " - $thread[subject]";
}

$navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a> $navigation";
$navtitle = ' - '.strip_tags($forum['name']).$navtitle;
if($forum['type'] == 'sub') {
	$query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
	$fup = $db->fetch_array($query);
	$navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> $navigation";
	$navtitle = ' - '.strip_tags($fup['name']).$navtitle;
}

if(!$forum['allowview']) {
	if(!$forum['viewperm'] && !$allowview) {
		showmessage('group_nopermission', NULL, 'NOPERM');
	} elseif($forum['viewperm'] && !strstr($forum['viewperm'], "\t$groupid\t")) {
		showmessage('forum_nopermission', NULL, 'NOPERM');
	}
}

if($thread['creditsrequire'] && $thread['creditsrequire'] > $credits && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
	showmessage('thread_nopermission', NULL, 'NOPERM');
}

if(!$bbcodeoff && !$allowhidecode && preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {
	showmessage('post_hide_nopermission');
}

if(!$adminid && $newbiespan && (!$lastpost || $timestamp - $lastpost < $newbiespan * 3600)) {
	$query = $db->query("SELECT regdate FROM {$tablepre}members WHERE uid='$discuz_uid'");
	if($timestamp - ($db->result($query, 0)) < $newbiespan * 3600) {
		showmessage('post_newbie_span');
	}
}

$urloffcheck = $usesigcheck = $smileoffcheck = $codeoffcheck = $htmloncheck = '';
$modnewthreads = (!$allowdirectpost || $allowdirectpost == 1) && $forum['modnewposts'] ? 1 : 0;
$modnewreplies = (!$allowdirectpost || $allowdirectpost == 2) && $forum['modnewposts'] == 2 ? 1 : 0;

$subject = dhtmlspecialchars(censor(trim($subject)));
$message = censor(trim($message));

if($previewpost || (!$previewpost && !$topicsubmit && !$replysubmit && !$editsubmit)) {

	$enctype = $allowpostattach ? 'enctype="multipart/form-data"' : NULL;

	$moresmilies = 0;
	if($smileyinsert && is_array($_DCACHE['smilies'])) {
		$smileyinsert = 1;
		$smcols = $smcols ? $smcols : 3;
		$smilies .= '<tr align="center">';
		foreach(array_reverse($_DCACHE['smilies']) as $key => $smiley) {
			if($key >= $smcols * 6) {
				$moresmilies = 1;
				break;
			}
			$smilies .= '<td valign="top"><img src="'.SMDIR.'/'.$smiley['url'].'" border="0" onmouseover="this.style.cursor=\'hand\';" onclick="AddText(\''.htmlspecialchars(addcslashes($smiley['code'], '\\\'')).'\');"></td>'."\n";
			$smilies .= !(++$key % $smcols) ? '</tr><tr align="center">' : '';
		}
	} else {
		$smileyinsert = 0;
	}

	$maxattachsize_kb = $maxattachsize / 1000;

	if($discuz_user && $sigstatus && !$usesigcheck) {
		$usesigcheck = 'checked';
	}

	if($previewpost) {

		$currtime = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
		$subject = stripslashes($subject);
		$message = stripslashes($message);
		$subject_preview = $subject;
		$message_preview = discuzcode($message, $smileyoff, $bbcodeoff, $htmlon, $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml']);
		$message = dhtmlspecialchars($message);

		$urloffcheck = $parseurloff ? 'checked' : '';
		$usesigcheck = $usesig ? 'checked' : '';
		$smileoffcheck = $smileyoff ? 'checked' : '';
		$codeoffcheck = $bbcodeoff ? 'checked' : '';
		$htmloncheck = $htmlon ? 'checked' : '';

		$topicsubmit = $replysubmit = $editsubmit = '';

	} else {

		$subject = $message = '';

	}

} else {

	if(!$parseurloff) {
		$message = parseurl($message);
	}

}

if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
	header("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
	exit();
}

if($action == 'newthread') {
	require_once DISCUZ_ROOT.'./include/newthread.inc.php';
} elseif($action == 'reply') {
	require_once DISCUZ_ROOT.'./include/newreply.inc.php';
} elseif($action == 'edit') {
	require_once DISCUZ_ROOT.'./include/editpost.inc.php';
}

?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?