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

📄 discuzcode.func.php

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

/*
	[Discuz!] (C)2001-2006 Comsenz Inc.
	This is NOT a freeware, use is subject to license terms

	$RCSfile: discuzcode.func.php,v $
	$Revision: 1.38.2.3 $
	$Date: 2006/09/11 01:39:03 $
*/

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

$discuzcodes = array(
	'pcodecount' => -1,
	'codecount' => 0,
	'codehtml' => '',
	'searcharray' => array(),
	'replacearray' => array(),
	'seoarray' => array(
		0 => '',
		1 => $_SERVER['HTTP_HOST'],
		2 => $bbname,
		3 => $seotitle,
		4 => $seokeywords,
		5 => $seodescription
	)
);

if(!is_array($_DCACHE['bbcodes']) || !is_array($_DCACHE['smilies'])) {
	@include DISCUZ_ROOT.'./forumdata/cache/cache_bbcodes.php';
}

foreach($_DCACHE['smilies']['replacearray'] as $key => $smiley) {
	$_DCACHE['smilies']['replacearray'][$key] = '<img src="'.SMDIR.'/'.$smiley.'" smilieid="'.$key.'" border="0" alt="" />';
}

mt_srand((double)microtime() * 1000000);

function attachtag($pid, $aid, &$postlist) {
	global $language, $attachrefcheck, $attachurl;
	if(isset($postlist[$pid]['attachments'][$aid])) {
		include_once language('misc');
		$attach = $postlist[$pid]['attachments'][$aid];
		unset($postlist[$pid]['attachments'][$aid]);

		$replacement = "<br><br>$attach[attachicon] ";
		if($attach['attachimg']) {
			$replacement .= "<a href=\"member.php?action=credits&view=getattach\" title=\"$language[attach_credits_policy]\" target=\"_blank\">$language[attach_img]</a>: ".
				($attach['readperm'] ? ", $language[attach_readperm] $attach[readperm]" : '').
				($attach['description'] ? "[{$attach[description]}]" : '').
				" <a href=\"attachment.php?aid=$attach[aid]\" target=\"_blank\" class=\"bold\">$attach[filename]</a> ($attach[dateline], $attach[attachsize])<br><br>".
				($attachrefcheck ? "<img src=\"attachment.php?aid=$attach[aid]&noupdate=yes\" border=\"0\" onload=\"if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='$language[attach_img_zoom]';}\" onmouseover=\"if(this.resized) this.style.cursor='hand';\" onclick=\"if(!this.resized) {return false;} else {window.open('attachment.php?aid=$attach[aid]');}\" onmousewheel=\"return imgzoom(this);\">" : "<img src=\"$attachurl/$attach[attachment]\" border=\"0\" onload=\"if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='$language[attach_img_zoom]';}\" onmouseover=\"if(this.resized) this.style.cursor='hand';\" onclick=\"if(!this.resized) {return false;} else {window.open('".addslashes("$attachurl/$attach[attachment]")."');}\" onmousewheel=\"return imgzoom(this);\" alt=\"\" />");
		} else {
			$replacement .= "<a href=\"member.php?action=credits&view=getattach\" title=\"$language[attach_credits_policy]\" target=\"_blank\">$language[attach]</a>: ".
					($attach['description'] ? "[{$attach[description]}]" : '').
					" <a href=\"attachment.php?aid=$attach[aid]\" target=\"_blank\" class=\"bold\">$attach[filename]</a> ($attach[dateline], $attach[attachsize])<br><span class=\"smalltxt\">$language[attach_download_count] $attach[downloads]".
					($attach['readperm'] ? ", $language[attach_readperm] $attach[readperm]" : '').
					"</span><br>";
		}

		return $replacement;
	} else {
		return '<strike>[attach]'.$aid.'[/attach]</strike>';
	}
}

function censor($message) {
	global $_DCACHE;
	require_once(DISCUZ_ROOT.'/forumdata/cache/cache_censor.php');

	if($_DCACHE['censor']['banned'] && preg_match($_DCACHE['censor']['banned'], $message)) {
		showmessage('word_banned');
	} else {
		return empty($_DCACHE['censor']['filter']) ? $message :
			@preg_replace($_DCACHE['censor']['filter']['find'], $_DCACHE['censor']['filter']['replace'], $message);
	}
}

function censormod($message) {
	global $_DCACHE;
	require_once(DISCUZ_ROOT.'/forumdata/cache/cache_censor.php');
	return $_DCACHE['censor']['mod'] && preg_match($_DCACHE['censor']['mod'], $message);
}

function creditshide($creditsrequire, $message) {
	global $language;
	include_once language('misc');

	if($GLOBALS['credits'] < $creditsrequire && !$GLOBALS['forum']['ismoderator']) {
		return '<b>'.eval("return \"$language[post_hide_credits_hidden]\";").'</b>';
	} else {
		return '<b>'.eval("return \"$language[post_hide_credits]\";").'</b><br>'.
			'==============================<br><br>'.
			str_replace('\\"', '"', $message).'<br><br>'.
			'==============================';
	}
}

function codedisp($code) {
	global $discuzcodes;
	$discuzcodes['pcodecount']++;
	$code = htmlspecialchars(str_replace('\\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
	$discuzcodes['codehtml'][$discuzcodes['pcodecount']] = "<br><br><div class=\"msgheader\"><div class=\"right\"><a href=\"###\" class=\"smalltxt\" onclick=\"copycode($('code$discuzcodes[codecount]'));\">[Copy to clipboard]</a></div>CODE:</div><div class=\"msgborder\" id=\"code$discuzcodes[codecount]\">$code</div><br>";
	$discuzcodes['codecount']++;
	return "[\tDISCUZ_CODE_$discuzcodes[pcodecount]\t]";
}

function karmaimg($rate, $ratetimes) {
	$karmaimg = '';
	if($rate && $ratetimes) {
		$image = $rate > 0 ? 'agree.gif' : 'disagree.gif';
		for($i = 0; $i < ceil(abs($rate) / $ratetimes); $i++) {
			$karmaimg .= '<img src="'.IMGDIR.'/'.$image.'" border="0" align="right" alt="" />';
		}
	}
	return $karmaimg;
}

function parseurl($message) {
	return preg_match("/\[code\].+?\[\/code\]/is", $message) ? $message :
		substr(preg_replace(	array(
						"/(?<=[^\]a-z0-9-=\"'\\/])(http:\/\/[a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+\.(jpg|gif|png|bmp))/i",
						"/(?<=[^\]\)a-z0-9-=\"'\\/])((https?|ftp|gopher|news|telnet|rtsp|mms|callto):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+)/i",
						"/(?<=[^\]\)a-z0-9\/\-_.~?=:.])([_a-z0-9-+]+(\.[_a-z0-9-+]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/i"
					), array(
						"[img]\\1[/img]",
						"[url]\\1\\3[/url]",
						"[email]\\0[/email]"
					), ' '.$message), 1);
}

function parsetable($width, $message) {
	$width = substr($width, -1) == '%' ? (substr($width, 0, -1) <= 98 ? $width : '98%') : ($width <= 560 ? $width : '98%');
	return '<table '.
		($width == '' ? NULL : 'width="'.$width.'" ').
		'align="center" class="t_table">'.
		str_replace(array('[tr]', '[td]', '[/td]', '[/tr]', '\\"'), array('<tr>', '<td>', '</td>', '</tr>', '"'), preg_replace("/\[td=(\d{1,2}),(\d{1,2})(,(\d{1,3}%?))?\]/is", '<td colspan="\\1" rowspan="\\2" width="\\4">', $message)).
		'</table>';
}

function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0') {
	global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre;


	if($parsetype != 1 && !$bbcodeoff && $allowbbcode) {
		$message = preg_replace("/\s*\[code\](.+?)\[\/code\]\s*/ies", "codedisp('\\1')", $message);
	}

	if(!$htmlon && !$allowhtml) {
		$message = $jammer ? preg_replace("/\r\n|\n|\r/e", "jammer()", dhtmlspecialchars($message)) : dhtmlspecialchars($message);
	}

	if(!$smileyoff && $allowsmilies && !empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) {
		$message = preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $message, $maxsmilies);
	}

	if(!$bbcodeoff && $allowbbcode) {

⌨️ 快捷键说明

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