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

📄 discuzcode.func.php

📁 极限网络智能办公系统 Office Automation V3.0官方100%源代码.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

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

	$RCSfile: discuzcode.func.php,v $
	$Revision: 1.89.2.14 $
	$Date: 2007/03/22 15:44:08 $
*/

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(!isset($_DCACHE['bbcodes']) || !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, $thumbstatus, $extcredits, $creditstrans, $ftp;
	if(isset($postlist[$pid]['attachments'][$aid])) {
		include_once language('misc');
		$attach = $postlist[$pid]['attachments'][$aid];
		if(isset($attach['unpayed'])) {
			return $attach['attachicon'].' <span class="bold">'.$language['attach_pay'].': '.$attach['filename'].'</span>';
		}
		unset($postlist[$pid]['attachments'][$aid]);

		if($attach['attachimg']) {
			if($thumbstatus && $attach['thumb']) {
				$replacement .= ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl']) ? '<a href="attachment.php?aid='.$attach['aid'].'&amp;noupdate=yes&amp;nothumb=yes" target="_blank"><img src="attachment.php?aid='.$attach['aid'].'" border="0" alt="'.$language['attach_img_thumb'].'" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1)" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" /></a>' :
					'<a href="'.$attach['url'].'/'.$attach['attachment'].'" target="_blank"><img src="'.$attach['url'].'/'.$attach['attachment'].'.thumb.jpg" border="0" alt="'.$language['attach_img_thumb'].'" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1)" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" /></a>';
			} else {
				$replacement .= ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl']) ? '<img src="attachment.php?aid='.$attach['aid'].'&amp;noupdate=yes" border="0" onload="attachimg(this, \'load\', \''.$language['attach_img_zoom'].'\')" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1);attachimg(this, \'mouseover\')" onclick="attachimg(this, \'click\', \'attachment.php?aid='.$attach['aid'].'\')" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" onmousewheel="return imgzoom(this)" alt="" />' :
					'<img src="'.$attach['url'].'/'.$attach['attachment'].'" border="0" onload="attachimg(this, \'load\', \''.$language['attach_img_zoom'].'\')" onmouseover="attachimginfo(this, \'attach_'.$attach['aid'].'\', 1);attachimg(this, \'mouseover\')" onclick="attachimg(this, \'click\', \''.addslashes("$attach[url]/$attach[attachment]").'\')" onmouseout="attachimginfo(this, \'attach_'.$attach['aid'].'\', 0, event)" onmousewheel="return imgzoom(this)" alt="" />';
			}
			$replacement .= '<div style="display:none" id="attach_'.$attach['aid'].'" onmouseover="showMenu(this.id, 0, 1)"><img src="'.IMGDIR.'/attachimg.gif" border="0"></div><div title="menu" class="t_attach" id="attach_'.$attach['aid'].'_menu" style="display: none">'.
				$attach['attachicon'].' <a href="attachment.php?aid='.$attach['aid'].'&amp;nothumb=yes" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')<br>'.
				($attach['description'] ? $attach['description'].'<br>' : '');
		} else {
			$replacement .= $attach['attachicon'].' <span style="white-space:nowrap" id="attach_'.$attach['aid'].'" onmouseover="showMenu(this.id)"><a href="attachment.php?aid='.$attach['aid'].'" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')</span>'.
				'<div title="menu" class="t_attach" id="attach_'.$attach['aid'].'_menu" style="display: none">'.$attach['attachicon'].' <a href="attachment.php?aid='.$attach['aid'].'" target="_blank" class="bold">'.$attach['filename'].'</a> ('.$attach['attachsize'].')<br>'.
				($attach['description'] ? $attach['description'].'<br>' : '').
				$language['attach_downloads'].': '.$attach['downloads'].'<br>'.
				($attach['readperm'] ? $language['attach_readperm'].': '.$attach['readperm'].'<br>' : '');
		}
		$replacement .= ($attach['price'] ? $language['price'].': '.$extcredits[$creditstrans]['title'].' '.$attach['price'].' '.$extcredits[$creditstrans]['unit'].' &nbsp;<a href="misc.php?action=viewattachpayments&amp;aid='.$aid.'" target="_blank">['.$language['pay_view'].']</a>'.
				($attach['payed'] ? '' : '&nbsp;<a href="misc.php?action=attachpay&amp;aid='.$attach['aid'].'" target="_blank">['.$language['attachment_buy'].']</a>') : '').'<div class="right smalltxt">'.$attach['dateline'].'</div></div>';

		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, $hideattach;
	include_once language('misc');

	if($GLOBALS['credits'] < $creditsrequire && !$GLOBALS['forum']['ismoderator']) {
		$hideattach = 1;
		return '<br><b>'.eval("return \"$language[post_hide_credits_hidden]\";").'</b><br>';
	} else {
		$hideattach = 0;
		return '<br><span class="bold">'.eval("return \"$language[post_hide_credits]\";").'</span><br>'.
			'==============================<br><br>'.
			str_replace('\\"', '"', $message).'<br><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=\"msgbody\"><div class=\"msgheader\"><div class=\"right\"><a href=\"###\" class=\"smalltxt\" onclick=\"copycode($('code$discuzcodes[codecount]'));\">[Copy to clipboard]</a> <a class=\"smalltxt\" href=\"###\" onclick=\"toggle_collapse('code$discuzcodes[codecount]');\">[ <span id=\"code$discuzcodes[codecount]_symbol\">-</span> ]</a></div>CODE:</div><div class=\"msgborder\" id=\"code$discuzcodes[codecount]\">$code</div></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" alt="" />';
		}
	}
	return $karmaimg;
}

function parsetable($width, $bgcolor, $message) {
	$width = substr($width, -1) == '%' ? (substr($width, 0, -1) <= 98 ? $width : '98%') : ($width <= 560 ? $width : '98%');
	return '<table cellspacing="0" '.
		($width == '' ? NULL : 'width="'.$width.'" ').
		'align="center" class="t_table"'.($bgcolor ? ' style="background: '.$bgcolor.'">' : '>').
		str_replace('\\"', '"', preg_replace(array(
				"/\[tr(?:=([\(\)%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ie",
				"/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ie",
				"/\[\/td\]\s*\[\/tr\]/i"
			), array(
				"parsetrtd('\\1', '\\2', '\\3', '\\4')",
				"parsetrtd('td', '\\1', '\\2', '\\3')",
				'</td></tr>'
			), $message)
		).'</table>';
}

function parsetrtd($bgcolor, $colspan, $rowspan, $width) {
	return ($bgcolor == 'td' ? '</td>' : '<tr'.($bgcolor ? ' style="background: '.$bgcolor.'"' : '').'>').'<td'.($colspan > 1 ? ' colspan="'.$colspan.'"' : '').($rowspan > 1 ? ' rowspan="'.$rowspan.'"' : '').($width ? ' width="'.$width.'"' : '').'>';
}

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, $hideattach;


	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);
	}

⌨️ 快捷键说明

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