class cording{
function cording_p($buffer, $add_p=TRUE){
global $a_target;
$end = count($buffer);
for ($i=0; $i<$end; $i++){
$str = $buffer[$i];
$str = preg_replace("/<([^\.=]*)>/", "<$1>", $str);
$str = preg_replace("/[\\\]{2} +/", "
", $str);
$str = preg_replace("/\*\*([^\*]*)\*\*/", "$1", $str);
$str = preg_replace("/\/\/([^\/\[\]\{\}]*)\/\//", "$1", $str);
$str = preg_replace("/__([^_]*)__/", "$1", $str);
$str = preg_replace("/--([^-]*)--/", "$1", $str);
$str = preg_replace("/\[\[http:\/\/([^\|\]]*)\|([^\]]*)\]\]/", '$2', $str);
$str = preg_replace("/\[\[http:\/\/([^\|\]]*)\]\]/", '$1', $str);
$str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\}\}/", '', $str);
$str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*)\}\}/", '', $str);
$str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*)\}\}/", '', $str);
$str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*) *\}\}/", '', $str);
$str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*) *\}\}/", '', $str);
$str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*) *\}\}/", '', $str);
$str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\}\}/", '', $str);
$str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*)\}\}/", '', $str);
$str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*)\}\}/", '', $str);
$str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*) +\}\}/", '', $str);
$str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*) +\}\}/", '', $str);
$str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*) +\}\}/", '', $str);
$str = preg_replace("/< ?\.([^\| ]*) ?\|([^>]*)>/", '$2', $str);
$str = preg_replace("/< ?= ?([^\| ]*) ?\|([^>]*)>/", '$2', $str);
if ($add_p){
$result .= "
".$str."
\n"; }else{ $result .= $str; } } return $result; } function cording_div($buffer){ $start_line = array_shift($buffer); if (preg_match("/^\#([^\.\#]*) ?\.([^\.\#\{]*)\{$/", $start_line, $data)){ $result = '$/", $line)){
$result = "cording_code";
$mode_fix = TRUE;
}else if (preg_match("/^[\.\#]([^\{]*)\{$/", $line)){
$result = "cording_div";
$mode_fix = TRUE;
}else if ($line === "}"){
$result = "cording_div";
}else{
$result = "cording_p";
}
}else if (($result === "cording_code" && $line === '</code>') || ($result === "cording_div" && $line === "}")){
$mode_fix = FALSE;
}
return $result;
}
function is_buffer($current_line, $follow_line){
global $_cording;
$result = FALSE;
if (($_cording = $this->get_type($current_line)) == $this->get_type($follow_line)){
$result = TRUE;
}
return $result;
}
function cording_start($text){
global $_cording;
$corded = array();
$buffer = array();
$before_cording = preg_split("/[\r\n]/", $text, -1, PREG_SPLIT_NO_EMPTY);
$end = count($before_cording);
for ($i=0; $i<$end; $i++){
$current_line = $before_cording[$i];
$follow_line = $before_cording[$i+1];
array_push ($buffer, $current_line);
if (!$this->is_buffer($current_line, $follow_line)){
array_push ($corded, $this->$_cording($buffer));
$buffer = array();
}
}
$this->cording_finish($corded);
}
function cording_finish($corded = array()){
while ($line = array_shift($corded)){
echo $line."\n";
}
}
}
?>