List Info

Thread: note 78656 added to function.file-exists




note 78656 added to function.file-exists
user name
2007-10-22 02:26:37
For some reason, none of the url_exists() functions posted
here worked for me, so here is my own tweaked version of
it.

<?php
    function url_exists($url){
        $url = str_replace("http://", "",
$url);
        if (strstr($url, "/")) {
            $url = explode("/", $url, 2);
            $url[1] = "/".$url[1];
        } else {
            $url = array($url, "/");
        }

        $fh = fsockopen($url[0], 80);
        if ($fh) {
            fputs($fh,"GET ".$url[1]."
HTTP/1.1nHost:".$url[0]."nn");
            if (fread($fh, 22) == "HTTP/1.1 404 Not
Found") { return FALSE; }
            else { return TRUE;    }

        } else { return FALSE;}
    }
?>
----
Server IP: 66.207.199.35
Probable Submitter: 67.71.136.73
----
Manual Page -- http://www.php.net/manual/en/function.file-exists.php
Edit        -- https://master
.php.net/note/edit/78656
Del: integrated  -- h
ttps://master.php.net/note/delete/78656/integrated
Del: useless     -- http
s://master.php.net/note/delete/78656/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/78656/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/78656/spam
Del: non-english -- 
https://master.php.net/note/delete/78656/non-english
Del: in docs     -- http
s://master.php.net/note/delete/78656/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78656
Reject      -- https://mast
er.php.net/note/reject/78656
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )