post_proc.inc.t
来自「eGroupWare is a multi-user, web-based gr」· T 代码 · 共 601 行 · 第 1/2 页
T
601 行
$ostr .= substr($str, $old_pos, strlen($str)-$old_pos); /* url paser */ $pos = 0; $ppos = 0; while (($pos = @strpos($ostr, '://', $pos)) !== false) { if ($pos < $ppos) { break; } // check if it's inside any tag; $i = $pos; while (--$i && $i > $ppos) { if ($ostr[$i] == '>' || $ostr[$i] == '<') { break; } } if ($ostr[$i]=='<') { $pos+=3; continue; } // check if it's inside the a tag if (($ts = strpos($ostr, '<a ', $pos)) === false) { $ts = strlen($ostr); } if (($te = strpos($ostr, '</a>', $pos)) == false) { $te = strlen($ostr); } if ($te < $ts) { $ppos = $pos += 3; continue; } // check if it's inside the pre tag if (($ts = strpos($ostr, '<pre>', $pos)) === false) { $ts = strlen($ostr); } if (($te = strpos($ostr, '</pre>', $pos)) == false) { $te = strlen($ostr); } if ($te < $ts) { $ppos = $pos += 3; continue; } // check if it's inside the span tag if (($ts = strpos($ostr, '<span>', $pos)) === false) { $ts = strlen($ostr); } if (($te = strpos($ostr, '</span>', $pos)) == false) { $te = strlen($ostr); } if ($te < $ts) { $ppos = $pos += 3; continue; } $us = $pos; $l = strlen($ostr); while (1) { --$us; if ($ppos > $us || $us >= $l || isset($GLOBALS['seps'][$ostr[$us]])) { break; } } unset($GLOBALS['seps']['=']); $ue = $pos; while (1) { ++$ue; if ($ue >= $l || isset($GLOBALS['seps'][$ostr[$ue]])) { break; } if ($ostr[$ue] == '&') { if ($ostr[$ue+4] == ';') { $ue += 4; continue; } if ($ostr[$ue+3] == ';' || $ostr[$ue+5] == ';') { break; } } if ($ue >= $l || isset($GLOBALS['seps'][$ostr[$ue]])) { break; } } $GLOBALS['seps']['='] = '='; $url = substr($ostr, $us+1, $ue-$us-1); if (!strncasecmp($url, 'javascript', strlen('javascript'))) { $pos = $ue; continue; } $html_url = '<a href="'.$url.'" target="_blank">'.$url.'</a>'; $html_url_l = strlen($html_url); $ostr = fud_substr_replace($ostr, $html_url, $us+1, $ue-$us-1); $ppos = $pos; $pos = $us+$html_url_l; } /* email parser */ $pos = 0; $ppos = 0; while (($pos = @strpos($ostr, '@', $pos)) !== false) { if ($pos < $ppos) { break; } // check if it's inside any tag; $i = $pos; while (--$i && $i>$ppos) { if ( $ostr[$i] == '>' || $ostr[$i] == '<') { break; } } if ($ostr[$i]=='<') { ++$pos; continue; } // check if it's inside the a tag if (($ts = strpos($ostr, '<a ', $pos)) === false) { $ts = strlen($ostr); } if (($te = strpos($ostr, '</a>', $pos)) == false) { $te = strlen($ostr); } if ($te < $ts) { $ppos = $pos += 1; continue; } // check if it's inside the pre tag if (($ts = strpos($ostr, '<div class="pre"><pre>', $pos)) === false) { $ts = strlen($ostr); } if (($te = strpos($ostr, '</pre></div>', $pos)) == false) { $te = strlen($ostr); } if ($te < $ts) { $ppos = $pos += 1; continue; } for ($es = ($pos - 1); $es > ($ppos - 1); $es--) { if ( ( ord($ostr[$es]) >= ord('A') && ord($ostr[$es]) <= ord('z') ) || ( ord($ostr[$es]) >= ord(0) && ord($ostr[$es]) <= ord(9) ) || ( $ostr[$es] == '.' || $ostr[$es] == '-' || $ostr[$es] == '\'') ) { continue; } ++$es; break; } if ($es == $pos) { $ppos = $pos += 1; continue; } if ($es < 0) { $es = 0; } for ($ee = ($pos + 1); @isset($ostr[$ee]); $ee++) { if ( ( ord($ostr[$ee]) >= ord('A') && ord($ostr[$ee]) <= ord('z') ) || ( ord($ostr[$ee]) >= ord(0) && ord($ostr[$ee]) <= ord(9) ) || ( $ostr[$ee] == '.' || $ostr[$ee] == '-' ) ) { continue; } break; } if ($ee == ($pos+1)) { $ppos = $pos += 1; continue; } $email = str_replace('@', '@', substr($ostr, $es, $ee-$es)); $email_url = '<a href="mailto:'.$email.'" target="_blank">'.$email.'</a>'; $email_url_l = strlen($email_url); $ostr = fud_substr_replace($ostr, $email_url, $es, $ee-$es); $ppos = $es+$email_url_l; $pos = $ppos; } return $ostr;}if (!function_exists('html_entity_decode')) { function html_entity_decode($s) { return strtr($s, array_flip(get_html_translation_table(HTML_ENTITIES))); }}function html_to_tags($fudml){ while (preg_match('!<span name="php">(.*?)</span>!is', $fudml, $res)) { $tmp = trim(html_entity_decode(strip_tags(str_replace('<br />', "\n", $res[1])))); $m = md5($tmp); $php[$m] = $tmp; $fudml = str_replace($res[0], "[php]\n".$m."\n[/php]", $fudml); } if (strpos($fudml, '<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"><tr><td class="SmallText"><b>') !== false) { $fudml = str_replace(array('<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"><tr><td class="SmallText"><b>','</b></td></tr><tr><td class="quote"><br>','<br></td></tr></table>'), array('[quote title=', ']', '[/quote]'), $fudml); } if (preg_match('!<div class="dashed" style="padding: 3px;" align="center" width="100%"><a href="javascript://" OnClick="javascript: layerVis\(\'.*?\', 1\);">{TEMPLATE: post_proc_reveal_spoiler}</a><div align="left" id=".*?" style="visibility: hidden;">!is', $fudml)) { $fudml = preg_replace('!\<div class\="dashed" style\="padding: 3px;" align\="center" width\="100%"\>\<a href\="javascript://" OnClick\="javascript: layerVis\(\'.*?\', 1\);">{TEMPLATE: post_proc_reveal_spoiler}\</a\>\<div align\="left" id\=".*?" style\="visibility: hidden;"\>!is', '[spoiler]', $fudml); $fudml = str_replace('</div></div>', '[/spoiler]', $fudml); } while (preg_match('!<font (color|face|size)=".+?">.*?</font>!is', $fudml)) { $fudml = preg_replace('!<font (color|face|size)="(.+?)">(.*?)</font>!is', '[\1=\2]\3[/\1]', $fudml); } while (preg_match('!<(o|u)l type=".+?">.*?</\\1l>!is', $fudml)) { $fudml = preg_replace('!<(o|u)l type="(.+?)">(.*?)</\\1l>!is', '[list type=\2]\3[/list]', $fudml); } $fudml = str_replace( array( '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<s>', '</s>', '<sub>', '</sub>', '<sup>', '</sup>', '<div class="pre"><pre>', '</pre></div>', '<div align="center">', '<div align="left">', '<div align="right">', '</div>', '<ul>', '</ul>', '<span name="notag">', '</span>', '<li>', '@', '://', '<br />', '<pre>', '</pre>' ), array( '[b]', '[/b]', '[i]', '[/i]', '[/u]', '[/u]', '[s]', '[/s]', '[sub]', '[/sub]', '[sup]', '[/sup]', '[code]', '[/code]', '[align=center]', '[align=left]', '[align=right]', '[/align]', '[list]', '[/list]', '[notag]', '[/notag]', '[*]', '@', '://', '', '[pre]', '[/pre]' ), $fudml); while (preg_match('!<img src="(.*?)" border=0 alt="\\1">!is', $fudml)) { $fudml = preg_replace('!<img src="(.*?)" border=0 alt="\\1">!is', '[img]\1[/img]', $fudml); } while (preg_match('!<a href="mailto:(.+?)" target="_blank">\\1</a>!is', $fudml)) { $fudml = preg_replace('!<a href="mailto:(.+?)" target="_blank">\\1</a>!is', '[email]\1[/email]', $fudml); } while (preg_match('!<a href="(.+?)" target="_blank">\\1</a>!is', $fudml)) { $fudml = preg_replace('!<a href="(.+?)" target="_blank">\\1</a>!is', '[url]\1[/url]', $fudml); } if (strpos($fudml, '<img src="') !== false) { $fudml = preg_replace('!<img src="(.*?)" border=0 alt="(.*?)">!is', '[img=\1]\2[/img]', $fudml); } if (strpos($fudml, '<a href="mailto:') !== false) { $fudml = preg_replace('!<a href="mailto:(.+?)" target="_blank">(.+?)</a>!is', '[email=\1]\2[/email]', $fudml); } if (strpos($fudml, '<a href="') !== false) { $fudml = preg_replace('!<a href="(.+?)" target="_blank">(.+?)</a>!is', '[url=\1]\2[/url]', $fudml); } if (isset($php)) { $fudml = str_replace(array_keys($php), array_values($php), $fudml); } /* unhtmlspecialchars */ reverse_fmt($fudml); return $fudml;}function filter_ext($file_name){ include $GLOBALS['FORUM_SETTINGS_PATH'] . 'file_filter_regexp'; if (!count($GLOBALS['__FUD_EXT_FILER__'])) { return; } if (($p = strrpos($file_name, '.')) === false) { return 1; } return !in_array(strtolower(substr($file_name, ($p + 1))), $GLOBALS['__FUD_EXT_FILER__']);}function safe_tmp_copy($source, $del_source=0, $prefx=''){ if (!$prefx) { $prefx = getmypid(); } $umask = umask(($GLOBALS['FUD_OPT_2'] & 8388608 ? 0177 : 0111)); if (!move_uploaded_file($source, ($name = tempnam($GLOBALS['TMP'], $prefx.'_')))) { return; } umask($umask); if ($del_source) { @unlink($source); } umask($umask); return basename($name);}function reverse_nl2br(&$data){ $data = str_replace('<br />', '', $data);}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?