⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newreply.php

📁 支持中、英、繁三种语言; 3、提供9套风格任意转换; 4、内嵌全球免费可视电话系统
💻 PHP
字号:
<?php

/*
	[DISCUZ!] include/newreply.php - post replying for post module
	This is NOT a freeware, use is subject to license terms

	Version: 2.0.0
	Author: Crossday (info@discuz.net)
	Copyright: Crossday Studio (www.crossday.com)
	Last Modified: 2002/12/5 10:00
*/


if(!defined('IN_DISCUZ')) {
        exit('Access Denied');
}

$discuz_action = 12;

if(empty($thread)) {
	showmessage('thread_nonexistence');
}

if(!$replysubmit) {

	if($repquote) {
		$query = $db->query("SELECT message, fid, author, dateline FROM $table_posts WHERE pid='$repquote'");
		$thaquote = $db->fetch_array($query);
		$quotefid = $thaquote['fid'];
		$message = $thaquote['message'];

		$time = gmdate("$dateformat $timeformat", $thaquote[dateline] + ($timeoffset * 3600));
		$message = preg_replace("/\[hide=?\d*\](.+?)\[\/hide\]/is", "[b]**** Hidden message by originally poster *****[/b]", $message);
		$message = preg_replace("/(\[quote])(.*)(\[\/quote])/siU", "", $message);
		$message = wordscut(dhtmlspecialchars(trim($message)), 200);

		$message = preg_replace("/\n{2}\[ Last edited by .+? on .+? at .+? \]$/s", '', $message);
		$message = "[quote]Originally posted by [i]$thaquote[author][/i] at $time:\n$message [/quote]\n";
	}

	if($thread['replies'] <= $ppp) {
		$altbg1 = ALTBG1;
		$altbg2 = ALTBG2;
		$postcount = 0;
		$postlist = array();
		$query = $db->query("SELECT * FROM $table_posts WHERE tid='$tid' ORDER BY dateline DESC");
		while($post = $db->fetch_array($query)) {
			$bgno = $postcount++ % 2 + 1;
			$post['thisbg'] = ${altbg.$bgno};
			$post['dateline'] = gmdate("$dateformat $timeformat", $post[dateline] + $timeoffset * 3600);;
			$post['message'] = preg_replace("/\[hide=?\d*\](.+?)\[\/hide\]/is","[b]**** Hidden message by originally poster *****[/b]", $post['message']);
			$post['message'] = postify($post['message'], $post['smileyoff'], $post['bbcodeoff'], $forum['allowsmilies'], $forum['allowhtml'], $forum['allowbbcode'], $forum['allowimgcode']);

			$postlist[] = $post;
		}
	}

	include template('post_newreply');

} else {

	if(($subject == "" || ereg("^ *$", $subject)) && $message == "") {
		showmessage('post_sm_isnull');
	}

	if(strlen($subject) > 100) {
		showmessage('post_subject_toolang');
	}

	if(!$issupermod && $maxpostsize && strlen($message) > $maxpostsize) {
		showmessage('post_message_toolang');
	}

	if(!$isadmin && !$issupermod && $forum[lastpost]) {
		$lastpost = explode("\t", $forum[lastpost]);
		if(($timestamp - $floodctrl) <= $lastpost[1] && $username == $lastpost[2]) {
			showmessage('post_flood_ctrl');
		}
	}

	$subject = dhtmlspecialchars($subject);
	if($thread['closed'] && !$ismoderator) {
		showmessage('post_thread_closed');
	} else {
		$emails = $comma = '';
		$notifytime = $timestamp - 43200;
		$query = $db->query("SELECT email FROM $table_subscriptions WHERE username<>'$username' AND tid='$tid' AND lastnotify<'$notifytime'");
		while($subs = $db->fetch_array($query)) {
			$emails .= $comma.$subs['email'];
			$comma = ', ';
		}
		if($emails) {
			sendmail($emails, 'email_notify_subject', 'email_notify_content');
		}
		if($emailnotify && $username != 'Guest') {
			$query = $db->query("SELECT COUNT(*) FROM $table_subscriptions WHERE tid='$tid' AND username='$username'");
			if(!$db->result($query, 0)) {
				$db->unbuffered_query("INSERT INTO $table_subscriptions (username, email, tid)
					VALUES ('$username', '$email', '$tid')");
			}
		}
		if(attach_upload() && ((!$forum['postattachperm'] && $allowpostattach) || ($forum['postattachperm'] && strstr($forum['postattachperm'], "\t$groupid\t")))) {
			$attachperm = $allowsetattachperm ? $attachperm : 0;
			$db->query("INSERT INTO $table_attachments (tid, pid, creditsrequire, filename, filetype, filesize, attachment)
				VALUES ('$tid', '', '$attachperm', '$attach_name', '$attach_type', '$attach_size', '$attach_fname')");
			$aid = $db->insert_id();
			$attach_type = substr(strrchr($attach_name, '.'), 1)."\t".$attach_type;
		} else {
			$attach_type = '';
			$aid = 0;
		}

		$db->query("INSERT INTO $table_posts  (fid, tid, aid, icon, author, subject, dateline, message, useip, usesig, bbcodeoff, smileyoff, parseurloff)
			VALUES ('$fid', '$tid', '$aid', '$posticon', '$username', '$subject', '$timestamp', '$message', '$onlineip', '$usesig', '$bbcodeoff', '$smileyoff', '$parseurloff')");
		$pid = $db->insert_id();
		if($aid) {
			$db->query("UPDATE $table_attachments SET pid='$pid' WHERE aid='$aid'");
			$db->unbuffered_query("UPDATE $table_threads SET lastposter='$username', lastpost='$timestamp', replies=replies+1, attachment='$attach_type' WHERE tid='$tid' AND fid='$fid'");
		} else {
			$db->unbuffered_query("UPDATE $table_threads SET lastposter='$username', lastpost='$timestamp', replies=replies+1 WHERE tid='$tid' AND fid='$fid'");
		}
		updatemember('+', $username);
		$db->unbuffered_query("UPDATE $table_forums SET lastpost='".addslashes($thread[subject])."\t$timestamp\t$username', posts=posts+1 WHERE fid='$fid' $fupadd");
	}

	@$topicpages = ceil(($thread['replies'] + 2) / $ppp);

	showmessage('post_reply_succeed', "viewthread.php?tid=$tid&pid=$pid&page=$topicpages#pid$pid");
}

?>

⌨️ 快捷键说明

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