<?php
//외부링크 존재유무 체크	
function ext_url($contents){

	preg_match_all("/(src=|href=)(\'|\")?([^<>\s\'\"]*)(\'|\"|\s|)/i", $contents, $match);
	$list = $match[0];

	$arr_site = array();

	//허용 도메인
	$arr_site[0] = $_SERVER["SERVER_NAME"];
	$arr_site[1] = "youtube.com";

	$ex_url = false;
	for ($i=0; $i < count($list); $i++) {
		$str = $list[$i];

		$ex = 0;
		for ($s=0; $s < count($arr_site); $s++) {
			$pos = strpos($str, $arr_site[$s]);

			if (!($pos !== false)) {
				$ex++;
			}
		}

		if ($ex == count($arr_site)) {
			$ex_url = true;
			break;
		}
	}

	return $ex_url;
}

if (ext_url($wr_content)) alert("외부 링크를 사용할 수 없습니다.");
?>