/sources/lib/post_parser.php //////////// ///////найти //////////// //--------------------------------- // Do [CODE] tag //--------------------------------- $txt = preg_replace( "#\[code\](.+?)\[/code\]#ies", "\$this->regex_code_tag('\\1')", $txt ); ////////////////////////// ///////ниже: ////////////////////////// //--------------------------------- // Do [PHP] tag //--------------------------------- $txt = preg_replace( "#\[php\](.+?)\[/php\]#ies", "\$this->regex_php_tag('\\1')", $txt ); ////////////////////////////// ///////найти ////////////////////////////// $txt = preg_replace( "#(.+?)#", '[CODE]' , $txt ); $txt = preg_replace( "#(.+?)#", '[/CODE]' , $txt ); ////////////////////////// ///////ниже ////////////////////////// $txt = preg_replace( "#(.+?)(.+?)(.+?)#e", "\$this->unconvert_php('\\2')", $txt ); ////////////////////////////// ///////найти ////////////////////////////// //+----------------------------------------------------------------------------------------- //+----------------------------------------------------------------------------------------- // UNCONVERT FUNCTIONS //+----------------------------------------------------------------------------------------- //+----------------------------------------------------------------------------------------- ////////////////////////// ///////ниже ////////////////////////// function unconvert_php($txt) { $txt = str_replace("
", "\n", $txt); $txt = str_replace("", "", $txt); $txt = str_replace("", "", $txt); $txt = preg_replace("#\#", "", $txt); $txt = str_replace("", "", $txt); return '[PHP]' . $txt . '[/PHP]'; } ////////////////////////////// ///////найти ////////////////////////////// function regex_code_tag($txt="") { ////////////////////////// ///////выше ////////////////////////// /**************************************************/ // regex_php_tag: Builds this php tag HTML // /**************************************************/ function regex_php_tag($txt="") { global $ibforums; $default = "\[php\]$txt\[/php\]"; if ($txt == "") return; // Too many embedded code/quote/html/sql tags can crash Opera and Moz if (preg_match( "/\[(quote|code|html|sql|php)\].+?\[(quote|code|html|sql|php)\].+?\[(quote|code|html|sql|php)\].+?\[(quote|code|html|sql|php)\].+?\[(quote|code|html|sql|php)\].+?\[(quote|code|html|sql|php)\].+?\[(quote|code|html|sql|php)\]/i", $txt) ) { return $default; } $txt = @html_entity_decode($txt, ENT_QUOTES); $txt = str_replace("$", "$", $txt); if(substr_count($txt, "?>") <= 0) { $txt = ""; } $txt = highlight_string($txt, 1); $txt = str_replace("", "", $txt); $txt = str_replace("", "", $txt); while(preg_match("#\n$#", $txt)) { $txt = preg_replace("#\n$#", "", $txt); } // Take a stab at removing most of the common // smilie characters. //$txt = str_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( "#\(#" , "(", $txt ); $txt = preg_replace( "#\r#" , "
", $txt ); $txt = preg_replace( "#\n#" , "
", $txt ); $txt = preg_replace( "#\s{1};#" , ";", $txt ); // Ensure that spacing is preserved $txt = preg_replace( "#\s{2}#", "  ", $txt ); //fix stupid line break bug; $txt = preg_replace("#^\\
#", "", $txt); $txt = preg_replace("#\
\
$#", "", $txt); $html = $this->wrap_style( array( 'STYLE' => 'PHP' ) ); return "{$html['START']}$txt{$html['END']}"; }