보험최저가로 가입하는요령 쉬운 돈벌기 방법
글수 769
safehtml - 사용자가 입력한 html 조금은 더 안전하게 만드는 함수
<?
function safehtml(&$text){
$text=preg_replace_callback("/\<(\/?)(\w+)*([^<>]*)>/" ,"addnoclosetag" ,$text);
}
function addnoclosetag($in){
$tags=" a img embed font b div center p br ";
//허용태그입니다 스페이스바로 연결하세요
//첫번째칸과 마지막 칸에 반드시 공백이 있어야 합니다
$in[2]=strtolower($in[2]);
if (strpos($tags, " ".$in[2]." ")) $add="<";
else $add="<";
if ($in[2]=="a" && !$in[1]) $in[2]="a target=\"_blank\"" ;
//링크는 무조건 새창으로 열어야 안전하지 않을까해서요
$atts="on|javascript-x:|vbscript-x:|tpl:";
//속성중에 허용하지 않는것들입니다 막대기로 연결하세요
//이들은 모두 사라집니다
//on : 이벤트를 없애기 위해서 , 나머지:링크 유알엘로 부를수 있는 스크립트 언어들입니다
$in[3]=preg_replace("/($atts)/i","",$in[3]);
return $add."$in[1]$in[2]$in[3]>";
}
?>
<?
function safehtml(&$text){
$text=preg_replace_callback("/\<(\/?)(\w+)*([^<>]*)>/" ,"addnoclosetag" ,$text);
}
function addnoclosetag($in){
$tags=" a img embed font b div center p br ";
//허용태그입니다 스페이스바로 연결하세요
//첫번째칸과 마지막 칸에 반드시 공백이 있어야 합니다
$in[2]=strtolower($in[2]);
if (strpos($tags, " ".$in[2]." ")) $add="<";
else $add="<";
if ($in[2]=="a" && !$in[1]) $in[2]="a target=\"_blank\"" ;
//링크는 무조건 새창으로 열어야 안전하지 않을까해서요
$atts="on|javascript-x:|vbscript-x:|tpl:";
//속성중에 허용하지 않는것들입니다 막대기로 연결하세요
//이들은 모두 사라집니다
//on : 이벤트를 없애기 위해서 , 나머지:링크 유알엘로 부를수 있는 스크립트 언어들입니다
$in[3]=preg_replace("/($atts)/i","",$in[3]);
return $add."$in[1]$in[2]$in[3]>";
}
?>
$text="여기에 태그";
safehtml($text);
echo $text;
태초에 나는 개그이야기를 만들었다.
내말을 믿고 나를 따르면 천당,
내말을 믿지않고 나를 따르지 않으면 지옥,
나는 하늘나라(우주)에 사느니라.
그럼 난 외계인?




웃대가리
