note 73175 added to function.file-exists

From: Date: Mon, 12 Feb 2007 13:24:01 +0000
Subject: note 73175 added to function.file-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-123275@lists.php.net to get a copy of this message
Updated funtion url_exist It work right! http://www.bbc.co.uk/newsa/n5ctrl/progs/frost/latest.ram - (true) http://www.bbc.co.uk/newsa/n5ctrl/progs/frost/latest1.ram - (false) http://www.bbc.co.uk/newsa/n5ctrl/progs/frost1/latest.ram - (false) ----- <?php 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); $head = substr($head,0,strpos($head, 'Connection: close')); fclose($fid); if (preg_match('#^HTTP/.*\s+[200|302]+\s#i', $head)) { $pos = strpos($head, 'Content-Type'); return $pos !== false; } } else { return false; } } ?> ---- Server IP: 195.248.191.91 Probable Submitter: 80.91.170.142 ---- Manual Page -- http://www.php.net/manual/en/function.file-exists.php Edit -- https://master.php.net/note/edit/73175 Del: integrated -- https://master.php.net/note/delete/73175/integrated Del: useless -- https://master.php.net/note/delete/73175/useless Del: bad code -- https://master.php.net/note/delete/73175/bad+code Del: spam -- https://master.php.net/note/delete/73175/spam Del: non-english -- https://master.php.net/note/delete/73175/non-english Del: in docs -- https://master.php.net/note/delete/73175/in+docs Del: other reasons-- https://master.php.net/note/delete/73175 Reject -- https://master.php.net/note/reject/73175 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123275) next »