PHP Classes

File: claseurlcheck.php

Recommend this page to a friend!
  Classes of markitos   urlcheck   claseurlcheck.php   Download  
File: claseurlcheck.php
Role: ???
Content type: text/plain
Description: main class
Class: urlcheck
check if the web servers are alive or a link
Author: By
Last change:
Date: 21 years ago
Size: 1,875 bytes
 

Contents

Class file image Download
<? class urlcheck { var $NombreCompleto; var $ExtraUrlParam; function urlcheck ($Url) { $this->_Set ($Url); return $this; } function CambiaUrl ($Url) { $this->_Set ($Url); } function IsAlive ($Url=0) { $Retorno=0; if ($Url){ $this->_Set ($Url); } if (!$this->_BienFormada ($this->NombreCompleto)){ return $Retorno; } if (!$this->_MandaGet()){ return $Retorno; } $Retorno=1; return $Retorno; } function _BienFormada ($Url) { $Retorno=0; eregi ("(h{0,1}t{0,2}p{0,1}:{0,1}/{0,1}/{0,1})(w{0,3}\.{0,1})([aA-zZ]+)?\.{1}([aA-zZ]{2,3})", $Url, $ItemsUrl); if ($ItemsUrl[3] && $ItemsUrl[4]){ $Retorno=1; } return $Retorno; } function _Set ($Url) { $this->NombreCompleto=''; $this->ExtraUrlParam =''; if (!$this->_BienFormada ($Url)){ return; } eregi ("(h{0,1}t{0,2}p{0,1}:{0,1}/{0,1}/{0,1})(w{0,3}\.{0,1})([aA-zZ]+)?\.{1}([aA-zZ]{2,3})(.*)", $Url, $ItemsUrl); $this->NombreCompleto = "http://".$ItemsUrl[2].$ItemsUrl[3].'.'.$ItemsUrl[4]; $this->ExtraUrlParam = $ItemsUrl[5]; if (!$this->ExtraUrlParam){ $this->ExtraUrlParam = '/'; } return; } function _MandaGet() { $Retorno=0; $Sock = $this->_AbreConexion(); if (!$Sock){ return $Retorno; } $Mensaje = "GET ".$this->NombreCompleto.$this->ExtraUrlParam." \n\n"; if (!fwrite ($Sock, $Mensaje)) {$this->_CierraConexion ($Sock); return $Retorno;} $Contenido=''; while (!feof ($Sock)) {$Contenido .= fgets ($Sock, 4096);} $this->_CierraConexion ($Sock); if (!eregi ("<title>.*404", $Contenido)){ $Retorno=1; } return $Retorno; } function _AbreConexion() { $Retorno=0; eregi ("http://(.+)", $this->NombreCompleto, $ItemsNombre); $Retorno = fsockopen ($ItemsNombre[1], 80, $errno, $errstr, 60); return $Retorno; } function _CierraConexion ($HSock) { fclose ($HSock); } } ?>