post_proc.inc.t

来自「eGroupWare is a multi-user, web-based gr」· T 代码 · 共 601 行 · 第 1/2 页

T
601
字号
<?php/**************************************************************************** copyright            : (C) 2001-2003 Advanced Internet Designs Inc.* email                : forum@prohost.org* $Id: post_proc.inc.t,v 1.3 2003/12/18 18:20:49 iliaa Exp $** This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or * (at your option) any later version.***************************************************************************/$GLOBALS['seps'] = array(' '=>' ', "\n"=>"\n", "\r"=>"\r", "'"=>"'", '"'=>'"', '['=>'[', ']'=>']', '('=>'(', ';'=>';', ')'=>')', "\t"=>"\t", '='=>'=', '>'=>'>', '<'=>'<');function fud_substr_replace($str, $newstr, $pos, $len){        return substr($str, 0, $pos).$newstr.substr($str, $pos+$len);}function char_fix(&$str){	$str = str_replace(		array('&amp;#0', '&amp;#1', '&amp;#2', '&amp;#3', '&amp;#4', '&amp;#5', '&amp;#6', '&amp;#7','&amp;#8','&amp;#9'),		array('&#0', '&#1', '&#2', '&#3', '&#4', '&#5', '&#6', '&#7', '&#8', '&#9'),		$str);}function tags_to_html($str, $allow_img=1, $no_char=0){	if (!$no_char) {		$str = htmlspecialchars($str);	}	$str = nl2br($str);	$ostr = '';	$pos = $old_pos = 0;	while (($pos = strpos($str, '[', $pos)) !== false) {		if (isset($GLOBALS['seps'][$str[$pos + 1]])) {			++$pos;			continue;		}		if (($epos = strpos($str, ']', $pos)) === false) {			break;		}		if (!($epos-$pos-1)) {			$pos = $epos + 1;			continue;		}		$tag = substr($str, $pos+1, $epos-$pos-1);		if (($pparms = strpos($tag, '=')) !== false) {			$parms = substr($tag, $pparms+1);			if (!$pparms) { /*[= exception */				$pos = $epos+1;				continue;			}			$tag = substr($tag, 0, $pparms);		} else {			$parms = '';		}		$tag = strtolower($tag);		switch ($tag) {			case 'quote title':				$tag = 'quote';				break;			case 'list type':				$tag = 'list';				break;		}		if ($tag[0] == '/') {			if (isset($end_tag[$pos])) {				if( ($pos-$old_pos) ) $ostr .= substr($str, $old_pos, $pos-$old_pos);				$ostr .= $end_tag[$pos];				$pos = $old_pos = $epos+1;			} else {				$pos = $epos+1;			}			continue;		}		$cpos = $epos;		$ctag = '[/'.$tag.']';		$ctag_l = strlen($ctag);		$otag = '['.$tag;		$otag_l = strlen($otag);		$rf = 1;		while (($cpos = strpos($str, '[', $cpos)) !== false) {			if (isset($end_tag[$cpos]) || isset($GLOBALS['seps'][$str[$cpos + 1]])) {				++$cpos;				continue;			}			if (($cepos = strpos($str, ']', $cpos)) === false) {				break 2;			}			if (strcasecmp(substr($str, $cpos, $ctag_l), $ctag) == 0) {				--$rf;			} else if (strcasecmp(substr($str, $cpos, $otag_l), $otag) == 0) {				++$rf;			} else {				++$cpos;				continue;			}			if (!$rf) {				break;			}			$cpos = $cepos;		}		if (!$cpos || ($rf && $str[$cpos] == '<')) { /* left over [ handler */			++$pos;			continue;		}		if ($cpos !== false) {			if (($pos-$old_pos)) {				$ostr .= substr($str, $old_pos, $pos-$old_pos);			}			switch ($tag) {				case 'notag':					$ostr .= '<span name="notag">'.substr($str, $epos+1, $cpos-1-$epos).'</span>';					$epos = $cepos;					break;				case 'url':					if (!$parms) {						$url = substr($str, $epos+1, ($cpos-$epos)-1);					} else {						$url = $parms;					}					if (!strncasecmp($url, 'www.', 4)) {						$url = 'http&#58;&#47;&#47;'. $url;					} else if (strpos(strtolower($url), 'javascript:') !== false) {						$ostr .= substr($str, $pos, $cepos - $pos + 1);						$epos = $cepos;						$str[$cpos] = '<';						break;					} else {						$url = str_replace('://', '&#58;&#47;&#47;', $url);					}					$end_tag[$cpos] = '</a>';					$ostr .= '<a href="'.$url.'" target="_blank">';					break;				case 'i':				case 'u':				case 'b':				case 's':				case 'sub':				case 'sup':					$end_tag[$cpos] = '</'.$tag.'>';					$ostr .= '<'.$tag.'>';					break;				case 'email':					if (!$parms) {						$parms = str_replace('@', '&#64;', substr($str, $epos+1, ($cpos-$epos)-1));						$ostr .= '<a href="mailto:'.$parms.'" target="_blank">'.$parms.'</a>';						$epos = $cepos;						$str[$cpos] = '<';					} else {						$end_tag[$cpos] = '</a>';						$ostr .= '<a href="mailto:'.str_replace('@', '&#64;', $parms).'" target="_blank">';					}					break;				case 'color':				case 'size':				case 'font':					if ($tag == 'font') {						$tag = 'face';					}					$end_tag[$cpos] = '</font>';					$ostr .= '<font '.$tag.'="'.$parms.'">';					break;				case 'code':					$param = substr($str, $epos+1, ($cpos-$epos)-1);					reverse_nl2br($param);					$ostr .= '<div class="pre"><pre>'.$param.'</pre></div>';					$epos = $cepos;					$str[$cpos] = '<';					break;				case 'pre':					$param = substr($str, $epos+1, ($cpos-$epos)-1);					reverse_nl2br($param);					$ostr .= '<pre>'.$param.'</pre>';					$epos = $cepos;					$str[$cpos] = '<';					break;				case 'php':					$param = substr($str, $epos+1, ($cpos-$epos)-1);					reverse_nl2br($param);					reverse_fmt($param);					$param = trim($param);					if (strncmp($param, '<?php', 5)) {						if (strncmp($param, '<?', 2)) {							$param = "<?php\n" . $param;						} else {							$param = "<?php\n" . substr($param, 3);						}					}					if (substr($param, -2) != '?>') {						$param .= "\n?>";					}					$ostr .= '<span name="php">'.trim(@highlight_string($param, true)).'</span>';					$epos = $cepos;					$str[$cpos] = '<';					break;				case 'img':					if (!$allow_img) {						$ostr .= substr($str, $pos, ($cepos-$pos)+1);					} else {						if (!$parms) {							$parms = substr($str, $epos+1, ($cpos-$epos)-1);							if (strpos(strtolower($parms), 'javascript:') === false) {								$ostr .= '<img src="'.$parms.'" border=0 alt="'.$parms.'">';							} else {								$ostr .= substr($str, $pos, ($cepos-$pos)+1);							}						} else {							if (strpos(strtolower($parms), 'javascript:') === false) {								$ostr .= '<img src="'.$parms.'" border=0 alt="'.substr($str, $epos+1, ($cpos-$epos)-1).'">';							} else {								$ostr .= substr($str, $pos, ($cepos-$pos)+1);							}						}					}					$epos = $cepos;					$str[$cpos] = '<';					break;				case 'quote':					if (!$parms) {						$parms = 'Quote:';					}					$ostr .= '<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"><tr><td class="SmallText"><b>'.$parms.'</b></td></tr><tr><td class="quote"><br>';					$end_tag[$cpos] = '<br></td></tr></table>';					break;				case 'align':					$end_tag[$cpos] = '</div>';					$ostr .= '<div align="'.$parms.'">';					break;				case 'list':					$tmp = substr($str, $epos, ($cpos-$epos));					$tmp_l = strlen($tmp);					$tmp2 = str_replace(array('[*]', '<br />'), array('<li>', ''), $tmp);					$tmp2_l = strlen($tmp2);					$str = str_replace($tmp, $tmp2, $str);					$diff = $tmp2_l - $tmp_l;					$cpos += $diff;					if (isset($end_tag)) {						foreach($end_tag as $key => $val) {							if ($key < $epos) {								continue;							}							$end_tag[$key+$diff] = $val;						}					}					switch (strtolower($parms)) {						case '1':						case 'a':							$end_tag[$cpos] = '</ol>';							$ostr .= '<ol type="'.$parms.'">';							break;						case 'square':						case 'circle':						case 'disc':							$end_tag[$cpos] = '</ul>';							$ostr .= '<ul type="'.$parms.'">';							break;						default:							$end_tag[$cpos] = '</ul>';							$ostr .= '<ul>';					}					break;				case 'spoiler':					$rnd = get_random_value(64);					$end_tag[$cpos] = '</div></div>';					$ostr .= '<div class="dashed" style="padding: 3px;" align="center" width="100%"><a href="javascript://" OnClick="javascript: layerVis(\''.$rnd.'\', 1);">{TEMPLATE: post_proc_reveal_spoiler}</a><div align="left" id="'.$rnd.'" style="visibility: hidden;">';					break;			}			$str[$pos] = '<';			$pos = $old_pos = $epos+1;		} else {			$pos = $epos+1;		}	}

⌨️ 快捷键说明

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