회원가입∴아이디/비번찾기
홈으로


원격지 파일의 존재 여부를 체크 사용자 함수
14년 전
<?php
/**
* @description  : 원격 파일 체크
* @param        :  url (http://domain.com/file.gif)
*/

function remote_file_exist($url)
{
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        // don't download content
        curl_setopt($ch, CURLOPT_NOBODY, 1);
        curl_setopt($ch, CURLOPT_FAILONERROR, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        if(curl_exec($ch)!==FALSE)
        {
            return TRUE;
        }
        else
        {
            return FALSE;
        }
}

// or

function url_exists($url)
{
    if(@file_get_contents($url,0,NULL,0,1))
    {
        return 1;
    }
    else
    {
        return 0;
     }
}

?>


예제)
<?php

if( remote_file_exist('http://xespresso.net/filies/text.txt') == true )
{
echo '파일이 존재 합니다.';
}
else
{
echo '파일이 존재하지 않습니다.';
}

?>

원격 이미지 파일 존재여부 체크
<?php

    $external_link = 'http://www.xespresso.com/example.jpg';

    if (@GetImageSize($external_link)) {

        echo "image exists";

    } else {

        echo "image does not exist";

    }

?>

URL 존재 여부 체크
<?php

function url_exists($url)
{
    if(strstr($url, "http://")) $url = str_replace("http://", "", $url);
    $fp = @fsockopen($url, 80);
    if($fp === false) return false;
  return true;

}

// or

function url_exists($url)
{

    if ((strpos($url, "http")) === false) $url = "http://" . $url;
    if (is_array(@get_headers($url)))
        return true;
    else
        return false;

}


// or


function is_valid_url($url)
{

    $url = @parse_url($url);
    if (!$url)
    {
        return false;
    }
    $url = array_map('trim', $url);
    $url['port'] = (!isset($url['port'])) ? 80 : (int)$url['port'];
    $path = (isset($url['path'])) ? $url['path'] : '';
    if ($path == '')
    {
        $path = '/';
    }
    $path .= (isset($url['query'])) ? "?$url[query]" : '';
    if (isset($url['host']) AND $url['host'] != gethostbyname($url['host']))
    {
        if (PHP_VERSION >= 5)
        {
           $headers = get_headers("$url[scheme]://$url[host]:$url[port]$path");
        }
        else
        {
            $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30);
            if (!$fp)
            {
            return false;
            }
            fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $url[host]\r\n\r\n");
            $headers = fread($fp, 4096);
            fclose($fp);
        }
        $headers = (is_array($headers)) ? implode("\n", $headers) : $headers;
        return (bool)preg_match('#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers);
    }
    return false;

}

?>

메일 존재 여부 체크
<?php



if(!function_exists('checkdnsrr'))

function checkdnsrr($hostName, $recType = '')
{

if(!empty($hostName)) {
   if( $recType == '' ) $recType = "MX";
   exec("nslookup -type=$recType $hostName", $result);
   // check each line to find the one that starts with the host
   // name. If it exists then the function succeeded.
   foreach ($result as $line) {
     if(eregi("^$hostName",$line)) {
       return true;
     }
   }
   // otherwise there was no mail handler for the domain
   return false;
}
return false;

}


function email_exist($email) {

    list($userid, $domain) = split("@", $email);
    if (checkdnsrr($domain, "MX")) { return true;} else { return false;}

}

// or

function check_email($email)
{

    $email_error = false;
    $Email = htmlspecialchars(stripslashes(strip_tags(trim($email)))); //parse unnecessary characters to prevent exploits
    if ($Email == "") { email_error = true; }
    elseif (!eregi("^([a-zA-Z0-9._-])+@([a-zA-Z0-9._-])+\.([a-zA-Z0-9._-])([a-zA-Z0-9._-])+", $Email)) { email_error = true; }

    else {
    list($Email, $domain) = split("@", $Email, 2);
        if (! checkdnsrr($domain, "MX")) { email_error = true; }
        else {
        $array = array($Email, $domain);
        $Email = implode("@", $array);
        }
    }
    if (email_error) { return false; } else{return true;}

}

// or

function check_email($email)
{

    $email_error = false;
    $Email = htmlspecialchars(stripslashes(strip_tags(trim($email)))); //parse unnecessary characters to prevent exploits
    if ($Email == "") { email_error = true; }
    elseif (!eregi("^([a-zA-Z0-9._-])+@([a-zA-Z0-9._-])+\.([a-zA-Z0-9._-])([a-zA-Z0-9._-])+", $Email)) { email_error = true; }
    else {
    list($Email, $domain) = split("@", $Email, 2);
        if (! checkdnsrr($domain, "MX")) { email_error = true; }
        else {
        $array = array($Email, $domain);
        $Email = implode("@", $array);
        }
    }
    if (email_error) { return false; } else{return true;}

}


?>






추천추천 : 734 추천 목록
번호 제목
2,891
입력 필드에서 특정단어(예:#err)가 포함되었을 때 실시간 감지 및 경고창 띄우기
2,890
데이터베이스 최적화와 쿼리 효율성을 높이 검색 성능을 개선하는 방법
2,889
간단한 게시판 만들기
2,888
PHP의 php.ini 파일에서 설정할 수 있는 주요 항목들을 카테고리별로 정리
2,887
유튜브 동영상의 썸네일 이미지를 체크하여 유효한 영상이아닐때 연결된 체크박스를 자동으로 체크
2,886
이미지 URL이 유효하지 않을 때, 해당 이미지와 연결된 체크박스를 자동으로 체크
2,885
HTTPS로 접속한 사용자를 강제로 HTTP로 리디렉션 하려면
2,884
PHP에서 MP3 파일을 직접 읽고 스트리밍 하기
2,883
현재 페이지가 location.reload()에 의해 새로고침되었는지
2,882
텍스트 파일을 읽고, 각 줄의 끝에서 6글자를 삭제한 후, 결과를 새로운 파일에 저장합니다.
2,881
cURL을 사용하여 리다이렉트를 따라가 최종 URL 가져오기
2,880
[PHP] $_SERVER 환경변수
2,879
10진수 <-> 16진수 변환기 PHP소스
2,878
텍스트에 직접 그라데이션 색상을 적용하려면?
2,877
CSS를 사용하여 요소의 내용물에 따라 width를 조정하는 방법
2,876
웹서버 ip 확인
2,875
웹호스팅의 절대경로를 확인
2,874
input 입력 필드 앞뒤 공백 실시간 제거
2,873
Placeholder 포커스시 감추기
2,872
MySQL 중복된 데이터를 삭제
2,871
MySQL 중복 데이터 확인
2,870
sessionStorage.getItem 와 sessionStorage.setItem
2,869
제이쿼리 랜덤으로 배경색 변경
2,868
preg match에 관한 정규식
2,867
Stream an audio file with MediaPlayer 오디오 파일 스트리밍 하기
2,866
Audio Streaming PHP Code
2,865
PHP $ SERVER 환경 변수 정리
2,864
Vimeo (비메오) API 를 사용하여 플레이어 컨트롤하기
2,863
iframe 사용시 하단에 발생하는 공백 제거방법
2,862
아이프레임(iframe) 전체화면 가능하게 하기
목록
뮤직트로트 부산광역시 부산진구 가야동 ㅣ 개인정보취급방침ㅣ모바일버전
Copyright ⓒ musictrot All rights reserved.