📄 post_parser.php
字号:
$html = preg_replace( "#\\)#", ")", $html );
$html = preg_replace( "#\\(#", "(", $html );
$html = preg_replace( "/^<br>/", "", $html );
$html = preg_replace( "/^\\s+/", "", $html );
$html = preg_replace( "#<([^&<>]+)>#", "<<span style='color:blue'>\\1</span>>", $html );
$html = preg_replace( "#<([^&<>]+)=#", "<<span style='color:blue'>\\1</span>=", $html );
$html = preg_replace( "#</([^&]+)>#", "</<span style='color:blue'>\\1</span>>", $html );
$html = preg_replace( "!=("|')(.+?)("|')(\\s|>)!", "=\\1<span style='color:orange'>\\2</span>\\3\\4", $html );
$html = preg_replace( "!<!--(.+?)-->!", "<!<span style='color:red'>--\\1--</span>>", $html );
$wrap = $this->wrap_style( array( "STYLE" => "HTML" ) );
return "<!--html-->{$wrap['START']}<!--html1-->{$html}<!--html2-->{$wrap['END']}<!--html3-->";
}
function regex_sql_tag( $sql = "" )
{
if ( $sql == "" )
{
return;
}
if ( preg_match( "/\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\]/i", $sql ) )
{
return $default;
}
$sql = preg_replace( "/^<br>/", "", $sql );
$sql = preg_replace( "/^\\s+/", "", $sql );
if ( !preg_match( "/\\s+\$/", $sql ) )
{
$sql = $sql." ";
}
$sql = preg_replace( "#(=|\\+|\\-|>|<|~|==|\\!=|LIKE|NOT LIKE|REGEXP)#i", "<span style='color:orange'>\\1</span>", $sql );
$sql = preg_replace( "#(MAX|AVG|SUM|COUNT|MIN)\\(#i", "<span style='color:blue'>\\1</span>(", $sql );
$sql = preg_replace( "!("|'|')(.+?)("|'|')!i", "<span style='color:red'>\\1\\2\\3</span>", $sql );
$sql = preg_replace( "#\\s{1,}(AND|OR)\\s{1,}#i", " <span style='color:blue'>\\1</span> ", $sql );
$sql = preg_replace( "#(WHERE|MODIFY|CHANGE|AS|DISTINCT|IN|ASC|DESC|ORDER BY)\\s{1,}#i", "<span style='color:green'>\\1</span> ", $sql );
$sql = preg_replace( "#LIMIT\\s*(\\d+)\\s*,\\s*(\\d+)#i", "<span style='color:green'>LIMIT</span> <span style='color:orange'>\\1, \\2</span>", $sql );
$sql = preg_replace( "#(FROM|INTO)\\s{1,}(\\S+?)\\s{1,}#i", "<span style='color:green'>\\1</span> <span style='color:orange'>\\2</span> ", $sql );
$sql = preg_replace( "#(SELECT|INSERT|UPDATE|DELETE|ALTER TABLE|DROP)#i", "<span style='color:blue;font-weight:bold'>\\1</span>", $sql );
$html = $this->wrap_style( array( "STYLE" => "SQL" ) );
return "<!--sql-->{$html['START']}<!--sql1-->{$sql}<!--sql2-->{$html['END']}<!--sql3-->";
}
function regex_code_tag( $txt = "" )
{
global $ibforums;
$default = "\\[code\\]{$txt}\\[/code\\]";
if ( $txt == "" )
{
return;
}
if ( preg_match( "/\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\].+?\\[(quote|code|html|sql)\\]/i", $txt ) )
{
return $default;
}
$txt = preg_replace( "#<#", "<", $txt );
$txt = preg_replace( "#>#", ">", $txt );
$txt = preg_replace( "#"#", """, $txt );
$txt = preg_replace( "#:#", ":", $txt );
$txt = preg_replace( "#\\[#", "[", $txt );
$txt = preg_replace( "#\\]#", "]", $txt );
$txt = preg_replace( "#\\)#", ")", $txt );
$txt = preg_replace( "#\\(#", "(", $txt );
$txt = preg_replace( "#\r#", "<br>", $txt );
$txt = preg_replace( "#\n#", "<br>", $txt );
$txt = preg_replace( "#\\s{1};#", ";", $txt );
$txt = preg_replace( "#\\s{2}#", " ", $txt );
$html = $this->wrap_style( array( "STYLE" => "CODE" ) );
return "<!--c1-->{$html['START']}<!--ec1-->{$txt}<!--c2-->{$html['END']}<!--ec2-->";
}
function regex_parse_quotes( $the_txt = "" )
{
if ( $the_txt == "" )
{
return;
}
$txt = $the_txt;
$this->quote_html = $this->wrap_style( array( "STYLE" => "QUOTE" ) );
$txt = preg_replace( "#\\[quote\\]#ie", "\$this->regex_simple_quote_tag()", $txt );
$txt = preg_replace( "#\\[quote=(.+?),(.+?)\\]#ie", "\$this->regex_quote_tag('\\1', '\\2')", $txt );
$txt = preg_replace( "#\\[quote=(.+?)\\]#ie", "\$this->regex_quote_tag('\\1', '')", $txt );
$txt = preg_replace( "#\\[/quote\\]#ie", "\$this->regex_close_quote()", $txt );
$txt = preg_replace( "/\n/", "<br>", $txt );
if ( $this->quote_open == $this->quote_closed && $this->quote_error == 0 )
{
$txt = preg_replace( "#(<!--QuoteEBegin-->.+?<!--QuoteEnd-->)#es", "\$this->regex_preserve_spacing('\\1')", trim( $txt ) );
return $txt;
}
else
{
return $the_txt;
}
}
function regex_preserve_spacing( $txt = "" )
{
$txt = preg_replace( "#\\s{2}#", " ", trim( $txt ) );
return $txt;
}
function regex_simple_quote_tag( )
{
global $ibforums;
++$this->quote_open;
return "<!--QuoteBegin-->{$this->quote_html['START']}<!--QuoteEBegin-->";
}
function regex_close_quote( )
{
if ( $this->quote_open == 0 )
{
++$this->quote_error;
}
else
{
++$this->quote_closed;
return "<!--QuoteEnd-->{$this->quote_html['END']}<!--QuoteEEnd-->";
}
}
function regex_quote_tag( $name = "", $date = "" )
{
global $ibforums;
$name = str_replace( "+", "+", $name );
$default = "\\[quote={$name},{$date}\\]";
++$this->quote_open;
if ( $date == "" )
{
$html = $this->wrap_style( array(
"STYLE" => "QUOTE",
"EXTRA" => "({$name})"
) );
}
else
{
$html = $this->wrap_style( array(
"STYLE" => "QUOTE",
"EXTRA" => "({$name} @ {$date})"
) );
}
$extra = "--{$name}+{$date}";
return "<!--QuoteBegin".$extra."-->{$html['START']}<!--QuoteEBegin-->";
}
function regex_check_flash( $width = "", $height = "", $url = "" )
{
global $ibforums;
$default = "\\[flash={$width},{$height}\\]{$url}\\[/flash\\]";
if ( !$ibforums->vars['allow_flash'] )
{
return $default;
}
if ( $ibforums->vars['max_w_flash'] < $width )
{
$this->error = "flash_too_big";
return $default;
}
if ( $ibforums->vars['max_h_flash'] < $height )
{
$this->error = "flash_too_big";
return $default;
}
if ( !preg_match( "/^http:\\/\\/(\\S+)\\.swf\$/i", $url ) )
{
$this->error = "flash_url";
return $default;
}
return "<!--Flash {$width}+{$height}+{$url}--><OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH={$width} HEIGHT={$height}><PARAM NAME=MOVIE VALUE={$url}><PARAM NAME=PLAY VALUE=TRUE><PARAM NAME=LOOP VALUE=TRUE><PARAM NAME=QUALITY VALUE=HIGH><EMBED SRC={$url} WIDTH={$width} HEIGHT={$height} PLAY=TRUE LOOP=TRUE QUALITY=HIGH></EMBED></OBJECT><!--End Flash-->";
}
function regex_check_image( $url = "" )
{
global $ibforums;
global $INFO;
if ( !$url )
{
return;
}
$url = trim( $url );
$default = "[img]".$url."[/img]";
++$this->image_count;
if ( $ibforums->vars['max_images'] && $ibforums->vars['max_images'] < $this->image_count )
{
$this->error = "too_many_img";
return $default;
}
if ( $ibforums->vars['allow_dynamic_img'] != 1 )
{
if ( preg_match( "/[?&;]/", $url ) )
{
$this->error = "no_dynamic";
return $default;
}
if ( preg_match( "/javascript(\\:|\\s)/i", $url ) )
{
$this->error = "no_dynamic";
return $default;
}
}
if ( $ibforums->vars['img_ext'] )
{
$extension = preg_replace( "#^.*\\.(\\S+)\$#", "\\1", $url );
$extension = strtolower( $extension );
if ( !$extension || preg_match( "#/#", $extension ) )
{
$this->error = "invalid_ext";
return $default;
}
$ibforums->vars['img_ext'] = strtolower( $ibforums->vars['img_ext'] );
if ( !preg_match( "/{$extension}(\\||\$)/", $ibforums->vars['img_ext'] ) )
{
$this->error = "invalid_ext";
return $default;
}
}
if ( !preg_match( "/^(http|https|ftp):\\/\\//i", $url ) )
{
$this->error = "no_dynamic";
return $default;
}
$valu = "0";
if ( $INFO['changetype'] != "none" )
{
if ( getimagesize( $url ) != NULL )
{
$getsize = @getimagesize( $url );
if ( $INFO['maximagew'] < $getsize[0] || $INFO['maximageh'] < $getsize[1] )
{
if ( $INFO['changetype'] == "link" )
{
return "<a href='".$url."' target='_blank'>[用户发布图片,按此查看]</a>";
}
else
{
$scale = min( 1, $INFO['maximagew'] / $getsize[0], $INFO['maximageh'] / $getsize[1] );
$wide = $getsize[0] * $scale;
$high = $getsize[1] * $scale;
$valu = "<a href='".$url."' target='_blank'><img src='".$url."' border='0' width='".$wide."' height='".$high."' alt='请点击放大图片'></a><br>[<a href='".$url."' target='_blank'>请点击图片进行放大</a>]";
}
}
}
if ( $valu != "0" )
{
return $valu;
}
else
{
return "<img src='".$url."' border='0' alt='用户发布图片'>";
}
}
}
function regex_font_attr( $IN )
{
if ( !is_array( $IN ) )
{
return "";
}
if ( preg_match( "/;/", $IN['1'] ) )
{
$attr = explode( ";", $IN['1'] );
$IN['1'] = $attr[0];
}
if ( $IN['s'] == "size" )
{
$IN['1'] = $IN['1'] + 7;
if ( 30 < $IN['1'] )
{
$IN['1'] = 30;
}
return "<span style='font-size:".$IN['1']."pt;line-height:100%'>".$IN['2']."</span>";
}
else if ( $IN['s'] == "col" )
{
return "<span style='color:".$IN['1']."'>".$IN['2']."</span>";
}
else if ( $IN['s'] == "font" )
{
return "<span style='font-family:".$IN['1']."'>".$IN['2']."</span>";
}
}
function regex_build_url( $url = array( ) )
{
$skip_it = 0;
if ( preg_match( "/([\\.,\\?]|!)\$/", $url['html'], $match ) )
{
$url['end'] .= $match[1];
$url['html'] = preg_replace( "/([\\.,\\?]|!)\$/", "", $url['html'] );
$url['show'] = preg_replace( "/([\\.,\\?]|!)\$/", "", $url['show'] );
}
if ( preg_match( "/\\[\\/(html|quote|code|sql)/i", $url['html'] ) )
{
return $url['html'];
}
$url['html'] = preg_replace( "/&/", "&", $url['html'] );
$url['html'] = preg_replace( "/javascript:/i", "java script: ", $url['html'] );
if ( !preg_match( "#^(http|news|https|ftp|aim)://#", $url['html'] ) )
{
$url['html'] = "http://".$url['html'];
}
if ( preg_match( "/^<img src/i", $url['show'] ) )
{
$skip_it = 1;
}
$url['show'] = preg_replace( "/&/", "&", $url['show'] );
$url['show'] = preg_replace( "/javascript:/i", "javascript: ", $url['show'] );
if ( strlen( $url['show'] ) < 55 )
{
$skip_it = 1;
}
if ( !preg_match( "/^(http|ftp|https|news):\\/\\//i", $url['show'] ) )
{
$skip_it = 1;
}
$show = $url['show'];
if ( $skip_it != 1 )
{
$stripped = preg_replace( "#^(http|ftp|https|news)://(\\S+)\$#i", "\\2", $url['show'] );
$uri_type = preg_replace( "#^(http|ftp|https|news)://(\\S+)\$#i", "\\1", $url['show'] );
$show = $uri_type."://".substr( $stripped, 0, 35 )."...".substr( $stripped, -15 );
}
return $url['st']."<a href='".$url['html']."' target='_blank'>".$show."</a>".$url['end'];
}
function regex_bash_session( $start_tok, $end_tok )
{
$start_tok = str_replace( "&", "&", $start_tok );
$end_tok = str_replace( "&", "&", $end_tok );
if ( $start_tok == "?" && $end_tok == "" )
{
return "";
}
else if ( $start_tok == "?" && $end_tok == "&" )
{
return "?";
}
else if ( $start_tok == "&" && $end_tok == "" )
{
return "";
}
else if ( $start_tok == "&" && $end_tok == "&" )
{
return "&";
}
else
{
return $start_tok.$end_tok;
}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -