", $text); if($tag){ $text = preg_replace("/\//", "\\\/", $text); $text = preg_replace("/([^<]\/)\//im", "", $text); $text = preg_replace("/<(br([ \n]+?clear=\"(left|right|all)\")?)>/im", "\001$1\002", $text); $text = preg_replace("/<(nobr)>/im", "\001$1\002", $text); $text = preg_replace("/<(img(([ \n][^<>]+?=\"[^<>]+\")+)?)>/", "\001$1\002", $text); $text = preg_replace("/<(\?php[ \n].+[ \n]\?)>/im", "\001$1\002", $text); while(preg_match("/.*?<([^\/<>]+?(([ \n].[^<>]+?=\".[^<>]+\")+)? *?|\/[^\/<>]+?)>/im", $text, $match)){ $sss = $text; $text = $this->stackset($text); if($sss == $text){ echo("Rutine Error"); break; } } foreach($this->save as $s){ $text = preg_replace("/{$s}\001(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)? *?)\002/im", "{$s}<$1>", $text, 1); } } $text = preg_replace("/\\\\\//", "/", $text); # だから何故そうなる? $text = preg_replace("/&/", "&", $text); $text = preg_replace("/( | ) /", "$1 ", $text); $text = preg_replace("//", ">", $text); $text = preg_replace("/\004/", ">", $text); $text = preg_replace("/\001/", "<", $text); $text = preg_replace("/\002/", ">", $text); return($text); } #-------------------------------------------------------------------------- # ● 欠損タグの破壊(ループ部分) #-------------------------------------------------------------------------- protected function stackset($text){ $match = array(); $slast = array_last($this->save); $tlast = array_last($this->tag); $stast = array_last($this->stack); if(count($this->stack) > 0){ if(preg_match("/(<([^\/<>]+)(([ \n][^<>]+?=\"[^<>]+\")+)?.*?>|<\/([^<>]+?)>)/im", $text, $match)){ if(isset($match[5])){ if($stast == strtolower($match[5])){ $bmatch = $match[5]; if(preg_match("/({$slast})\001({$tlast})\002(.*?)<\/({$bmatch})>/im", $text, $match)){ $text = preg_replace("/({$slast})\001({$tlast})\002(.*?)<\/({$bmatch})>/im", "$1\001$2\002$3\001/$4\002", $text, 1); $this->tagset = "{$match[1]}\001{$match[2]}\002{$match[3]}\001/{$match[4]}\002"; array_pop($this->save); array_pop($this->tag); array_pop($this->stack); } }elseif(preg_match("/({$slast})\001({$tlast})\002<\/({$stast})>/im", $text, $match)){ $text = preg_replace("/({$match[1]})\001({$match[2]})\002<\/({$match[3]})>/im", "$1\003$2\004\003/$3\004", $text, 1); }else{ $text = preg_replace("/(.*?)<\/([^<>]+?)>/im", "$1\003/$2\004", $text, 1); } }else{ if(in_array(strtolower($match[2]), CGIsystem::can_use_tag($stast))){ if($this->tagset == "" or preg_match("/(.*?)<\/{$stast}>/im", $this->tagset)){ if(preg_match("/(.*?)<(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)?)>/im", $text, $match)){ $text = preg_replace("/(.*?)<(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)?)>/im", "$1\001$2\002", $text, 1); array_push($this->save, $match[1]); array_push($this->stack, strtolower($match[3])); array_push($this->tag, $match[2]); } }else{ $text = preg_replace("/(.*?)<(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)?)>/im", "$1\003$2\004", $text, 1); } }else{ $text = preg_replace("/(.*?)<(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)?)>/im", "$1\003$2\004", $text, 1); } } }else{ $text = preg_replace("/(.*?)<(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)?)>/im", "$1\003$2\004", $text, 1); } }else{ if(preg_match("/(.*?)<(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)?)>/im", $text, $match)){ $text = preg_replace("/(.*?)<(([^\/<>]+?)(([ \n][^<>]+?=\"[^<>]+\")+)?)>/im", "$1\001$2\002", $text, 1); array_push($this->save, $match[1]); array_push($this->stack, strtolower($match[3])); array_push($this->tag, $match[2]); } } return($text); } } ?>