RE: [PHP-ES] File get contents fallara?

From: Date: Thu, 06 Nov 2003 15:42:34 +0000
Subject: RE: [PHP-ES] File get contents fallara?
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-42275@lists.php.net to get a copy of this message
//Dos funciones para verificar una URL en tiempo real: //versión sencilla: function verificar_url($url) { //abrimos el archivo en lectura $id = @fopen($url,"r"); //hacemos las comprobaciones if ($id) $abierto = true; else $abierto = false; //devolvemos el valor return $abierto; //cerramos el archivo fclose($id); } //versión completa function url_exists( $web, $errors = array(404, 500), $timeout = 30 ) { $url = parse_url($web); $host = $url['host']; $path = $url['path']; if ($path == '') $path = '/'; if ($url['port']) { $port = $url['port']; } elseif ($scheme = strtolower($url['scheme'])) { $port = getservbyname($sheme, 'udp'); } if (! $port) $port = 80; if ($url['query']) $path .= "?$url[query]"; $fp = fsockopen($host, $port, &$errno, &$errstr, $timeout); if($fp) { $head = ''; fputs($fp , "GET $path HTTP/1.0\nHost: $host\n\n"); while(! feof($fp)) { $head = fgets($fp, 1024); // echo "$head<br>"; // descomentar la línea anterior para ver las cabeceras if ($head === "\r\n" or $head === "\n") return 1; foreach($errors as $error) { if (strpos($head, " $error ")) { fclose($fp); return 0; } } } fclose($fp); } else { return 0; } return 1; } -----Mensaje original----- De: Amador Cubino [Necostek.com] [mailto:acubino3@necostek.com] Enviado el: jueves, 06 de noviembre de 2003 16:20 Para: lista@phpes.com Asunto: [PHP-ES] File get contents fallara? Hola, esa es mi duda necesito saber si una url existe para reducir mi trabajo. Por ejemplo pepe.com si no da error. Lo he pensado hacer con file_get_contents y he visto que hay servidores como gratishost.com que por ejemplo en los dominios .tk ponen su url y les dice que no existe. Entonces no se si pasaria tambien con esta funcion, tambien si hay alguna funcion mejor, que no tener que bajar el fuente completo etc. Un saludo ************************************************* D. Amador Cubino Presidente de Necostek y asociadas http://www.NECOSTEK.com Imagen Comercial http://www.HISPADOMINIO.com Hosting Gratis hasta 5 gb espacio http://www.DISENTWEB.COM Hosting, Diseño Web y Marketing ************************************************* --------------------------------------------------------------------- Archivo On-line: http://www.phpes.com/ via news: news://news.phpes.com/ Manual PHP en español: http://www.php.net/manual/es/ Para dar de baja la suscripción, mande un mensaje a: lista-unsubscribe@phpes.com

« previous php.general.es (#42275) next »