본문으로 바로가기

 

$skin_path = $_SERVER['DOCUMENT_ROOT']."/sample.php";
if (file_exists($skin_path)) {
   include_once ($skin_path);
} else {
   echo "Bad Request";
}

 

 

<!-- PHP 파일 존재 여부 체크 -->

<?

 

echo file_exists('../img/crosshair.gif');

 

echo "<br>";

 

echo file_exists($_SERVER['DOCUMENT_ROOT'].'/img/crosshair.gif');

 

 

echo "<br>";

 

function url_exists($url) {

$a_url = parse_url($url);

if (!isset($a_url['port'])) $a_url['port'] = 80;

$errno = 0;

$errstr = '';

$timeout = 30;

if(isset($a_url['host']) && $a_url['host']!=gethostbyname($a_url['host'])){

$fid = fsockopen($a_url['host'], $a_url['port'], $errno, $errstr, $timeout);

if (!$fid) return false;

$page = isset($a_url['path'])  ?$a_url['path']:'';

$page .= isset($a_url['query'])?'?'.$a_url['query']:'';

fputs($fid, 'HEAD '.$page.' HTTP/1.0'."\r\n".'Host: '.$a_url['host']."\r\n\r\n");

$head = fread($fid, 4096);

fclose($fid);

return preg_match('#^HTTP/.*\s+[200|302]+\s#i', $head);

} else {

return false;

}

}

 

 

echo url_exists('http://도메인/img/crosshair.gif');

 

?>