i have been trying to check if a given URL to my class is valid or not
im not looking for ereg, im looking for the script to go to the site and tell me if its valid or not, basically ive been trying to use various system tools such as nslookup to achieve this, all without luck
Is there any bullet-proof methods of doing this?
Thanks
Mal
[SOLVED] check valid URL
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
[SOLVED] check valid URL
Last edited by malcolmboston on Tue Apr 04, 2006 11:03 am, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
the following code
gives me
whats this mean?
Code: Select all
$fp = fsockopen($this->URL, 80, $errno, $errstr, 30);when i do a var_dump of the class i getPHP wrote: Warning: fsockopen(): unable to connect to http://www.evolution-interactive.co.uk:80 in /home/discwo/public_html/linkchecker.class.php on line 17
Code: Select all
object(linkchecker)(3) {
["URL"]=>
string(38) "http://www.evolution-interactive.co.uk"
["errno"]=>
int(13)
["errstr"]=>
string(17) "Permission denied"
}-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
ok, did that, works to an extent anyway, now i get
any ideas?
erm, yes there is a website configured at that address....results wrote: HTTP/1.1 200 OK Date: Tue, 04 Apr 2006 15:45:05 GMT Server: Last-Modified: Mon, 28 Feb 2005 10:01:46 GMT ETag: "760128-b9d-4222ec0a" Accept-Ranges: bytes Content-Length: 2973 Connection: close Content-Type: text/html
cPanel
There is no website configured at this address.
You are seeing this page because there is nothing configured for the site you have requested. If you think you are seeing this page in error, please contact the site administrator or datacenter responsible for this site.
any ideas?
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
NvM
if you basically do
and then check if $fp has failed or not, then that will give you the correct answer from what ive tested so far
if you basically do
Code: Select all
$fp = fsockopen($this->URL, 80, $errno, $errstr, 30);- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
[feyd@home]>php -r "$fp = fsockopen('www.evolution-interactive.co.uk',80,$errno,$errstr,30); if($fp){ fputs($fp, 'GET / HTTP/1.0'.PHP_EOL.'Host: www.evolution-interactive.co.uk'.PHP_EOL.PHP_EOL); do{ $str = fread($fp, 512); echo $str; }while(strlen($str));}"
HTTP/1.1 200 OK
Date: Tue, 04 Apr 2006 16:03:33 GMT
Server:
X-Powered-By: PHP/4.4.1
Connection: close
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="web design, CSS designs, web programming,PHP programming,online shop, promotion, listings, ranking, online shopping, templates, web hosting, ecommerce site, template, email service">
<meta name="description" content="Evolution Interactive are an web-design & web programming company specialising in PHP / MySQL developments, CSS based layouts and Search Enging Optimisation.">
<title>Evolution Interactive :: Evolve With Us</title>
<link href="css/silver.css" rel="stylesheet" type="text/css">
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
:snip: