Go Back   nV News Forums > Software Forums > Software Development

Newegg Daily Deals

Reply
 
Thread Tools
Old 08-28-07, 04:09 PM   #1
fivefeet8
Ngemu Mod
 
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Detecting Bad Links

Hello guys.

I need to make the server be able to detect a bad internet link on the webpage. The server is running Apache2 and another server with Apache1, both with PHP/Mysql installed. If the link is bad it redirects to another site. If the link is good, it redirects to the link. Any ideas how to go about this.

I'm open to suggestions from PHP, Javascript, or server side options.

Thanks.
__________________
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]
fivefeet8 is offline   Reply With Quote
Old 08-29-07, 12:56 AM   #2
supra
2JZ powered
 
supra's Avatar
 
Join Date: Dec 2004
Location: Aus
Posts: 1,321
Send a message via MSN to supra
Default Re: Detecting Bad Links

look in ur httpd.conf file and check out the ErrorDocument 404 setting.

i spose u could just put some javascript in ur 404 page to redirect to what ever link you want.
__________________
supra is offline   Reply With Quote
Old 08-29-07, 01:30 AM   #3
fivefeet8
Ngemu Mod
 
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: Detecting Bad Links

Quote:
Originally Posted by supra
look in ur httpd.conf file and check out the ErrorDocument 404 setting.

i spose u could just put some javascript in ur 404 page to redirect to what ever link you want.
Hmm.. I wasn't clear enough. The clickable links will be on a webpage on the servers, but the they link to other pages outside the server. I want to be able to check if a link on the webpage which points to another site works or not.
__________________
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]
fivefeet8 is offline   Reply With Quote
Old 08-29-07, 01:49 AM   #4
supra
2JZ powered
 
supra's Avatar
 
Join Date: Dec 2004
Location: Aus
Posts: 1,321
Send a message via MSN to supra
Default Re: Detecting Bad Links

Quote:
Originally Posted by fivefeet8
Hmm.. I wasn't clear enough. The clickable links will be on a webpage on the servers, but the they link to other pages outside the server. I want to be able to check if a link on the webpage which points to another site works or not.
ohhhhh. . well i spose u could do something like this

Code:
$test = get_meta_tags('http://www.example.com/');
and test if $test is null or not. Null being the website is not working
__________________
supra is offline   Reply With Quote
Old 08-29-07, 11:01 AM   #5
fivefeet8
Ngemu Mod
 
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: Detecting Bad Links

Quote:
Originally Posted by supra
ohhhhh. . well i spose u could do something like this

Code:
$test = get_meta_tags('http://www.example.com/');
and test if $test is null or not. Null being the website is not working
Thanks for your help. I'm think I'm not being specific enough in my question though. PHP is server side, so that function will originate from the server it's running. There's a link that the server will never be able to reach, but the client can depending on where they are connected to the internet.

What I need is a way to detect non working links on the client side. Essentially, if the client can't connect to a certain webpage, they get directed to another. If they can, then they get sent to it.

To be more specific the scenario is this:

A clients connects to the web server, the web server probably needs to send some type of client side script that upon page load, checks if the client can connect to another website. If they can connect to that other website, they get sent there. If they can't then they stay at the original web server they connected to.

I know how to send them to other URLs with javascript, but I need a way to check if they can connect to certain URLs from where they are connected.
__________________
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]
fivefeet8 is offline   Reply With Quote
Old 08-29-07, 11:20 AM   #6
evilghost
Registered User
 
Join Date: Jul 2005
Posts: 3,606
Default Re: Detecting Bad Links

You may run into some security restrictions on the DOM model but you could try loading your target site into a hidden IFRAME, detect if there's body in the IFRAME, and if not, then keep them on the page else parent.window.location.href redirect them.
evilghost is offline   Reply With Quote
Old 08-29-07, 01:10 PM   #7
fivefeet8
Ngemu Mod
 
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: Detecting Bad Links

Quote:
Originally Posted by evilghost
You may run into some security restrictions on the DOM model but you could try loading your target site into a hidden IFRAME, detect if there's body in the IFRAME, and if not, then keep them on the page else parent.window.location.href redirect them.
Thanks for the help, but the document loaded in the Iframe is from another webserver/domain. I get an access denied error when I try to count the number of body tags in the document.

Is there a way to detect 404 errors in an iframe?
__________________
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]
fivefeet8 is offline   Reply With Quote
Old 08-29-07, 04:56 PM   #8
fivefeet8
Ngemu Mod
 
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: Detecting Bad Links

I've figured a way to do it, but I'm not sure if it will work in all instances. I've created a simple javascript that creates and image object. The source points to an image on the server I need to check for connection. Once that's done, I check if the image returned has a height larger than zero. Seems to work so far.

I also welcome other suggestions or a better approach.
__________________
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]
fivefeet8 is offline   Reply With Quote

Old 08-29-07, 06:48 PM   #9
evilghost
Registered User
 
Join Date: Jul 2005
Posts: 3,606
Default Re: Detecting Bad Links

Quote:
Originally Posted by fivefeet8
I've figured a way to do it, but I'm not sure if it will work in all instances. I've created a simple javascript that creates and image object. The source points to an image on the server I need to check for connection. Once that's done, I check if the image returned has a height larger than zero. Seems to work so far.

I also welcome other suggestions or a better approach.
That was exactly what I was going to suggest, you were running into the DOM security model which prevents one parent domain from accessing content outside of it's own domain or a child domain of the parent domain.
evilghost is offline   Reply With Quote
Old 08-31-07, 11:05 AM   #10
radekhulan
 
radekhulan's Avatar
 
Join Date: Apr 2005
Location: Prague
Posts: 749
Default Re: Detecting Bad Links

Create a simple table with URL, query time and its status. When query time is older than (e.g.) one week, try to get URL headers via http://us.php.net/manual/en/function.get-headers.php PHP get_headers() function, and see if it exists, ie. return "HTTP/1.1 200 OK" (or is 301 Moved Permanently - in this case your can auto change the link, 404 page not found, etc.). No need to query each link one million times a day via JavaScript, that would be a very silly approach...
__________________
[size=1][b]CPU:[/b] Core 2 Quad Q6600 @ 3.2GHz | [b]Memory:[/b] 4x2GB Patriot DDR2-800 | 4GB A-Data PD7 ReadyBoost USB | [b]Sound:[/b] X-Fi FPS
[b]Board:[/b] Asus Commando | [b]GPU: 8800GTX @ 650/1050[/b] | [b]HDD:[/b] 3x WD3200KS 320GB + 500GB | [b]Power:[/b] Fortron EPSILON 600W-GLN
[b]Mouse:[/b] Logitech G5 | [b]Kbd:[/b] Logitech G15 | [b]DVD:[/b] Plextor 130B + LITE-ON LH-18A1H | [b]LCD[/b] [b]24" HP2465 1920x1200[/b] | Vista Ultimate x64
My websites: [url=http://hulan.cz/en][b]HULAN.cz[/b][/url], [url=http://radekhulan.cz/][b]RADEKHULAN.cz[/b][/url], [url=http://hulan.info/][b]HULAN.info[/b][/url], [url=http://blogcms.com/][b]BLOGCMS.com[/b][/url], [url=http://www.megablog.cz/][b]MEGABLOG.cz[/b][/url] | [url=http://hulan.cz/temp/games.png][b]Games played[/b][/url] | [URL=http://hulan.cz/temp/sestava.png][B]CPU-Z[/B][/URL] -- [URL="http://radekhulan.cz/img/stacker-830/stacker-830-bocnice.jpg"][B]case foto[/B][/URL][/size]
radekhulan is offline   Reply With Quote
Old 08-31-07, 11:26 AM   #11
evilghost
Registered User
 
Join Date: Jul 2005
Posts: 3,606
Default Re: Detecting Bad Links

Quote:
Originally Posted by radekhulan
Create a simple table with URL, query time and its status. When query time is older than (e.g.) one week, try to get URL headers via http://us.php.net/manual/en/function.get-headers.php PHP get_headers() function, and see if it exists, ie. return "HTTP/1.1 200 OK" (or is 301 Moved Permanently - in this case your can auto change the link, 404 page not found, etc.). No need to query each link one million times a day via JavaScript, that would be a very silly approach...
He want's a client-side function to see if the client can access the page, not the webserver serving the content.
evilghost is offline   Reply With Quote
Old 08-31-07, 11:52 AM   #12
radekhulan
 
radekhulan's Avatar
 
Join Date: Apr 2005
Location: Prague
Posts: 749
Default Re: Detecting Bad Links

Quote:
Originally Posted by evilghost
He want's a client-side function to see if the client can access the page, not the webserver serving the content.
Sure. And the best way to do it, if he has PHP/MySQL, is to check the page before it is outputed to the client, once in a week (per page / link) or so.. Even if it must be done via JavaScript (very silly, what about search engines and people with JS off?), the best would be to issue XMLHttpRequest, process URL on the server (cache results), and return back the result. The server could do its verification using get_headers() function.
__________________
[size=1][b]CPU:[/b] Core 2 Quad Q6600 @ 3.2GHz | [b]Memory:[/b] 4x2GB Patriot DDR2-800 | 4GB A-Data PD7 ReadyBoost USB | [b]Sound:[/b] X-Fi FPS
[b]Board:[/b] Asus Commando | [b]GPU: 8800GTX @ 650/1050[/b] | [b]HDD:[/b] 3x WD3200KS 320GB + 500GB | [b]Power:[/b] Fortron EPSILON 600W-GLN
[b]Mouse:[/b] Logitech G5 | [b]Kbd:[/b] Logitech G15 | [b]DVD:[/b] Plextor 130B + LITE-ON LH-18A1H | [b]LCD[/b] [b]24" HP2465 1920x1200[/b] | Vista Ultimate x64
My websites: [url=http://hulan.cz/en][b]HULAN.cz[/b][/url], [url=http://radekhulan.cz/][b]RADEKHULAN.cz[/b][/url], [url=http://hulan.info/][b]HULAN.info[/b][/url], [url=http://blogcms.com/][b]BLOGCMS.com[/b][/url], [url=http://www.megablog.cz/][b]MEGABLOG.cz[/b][/url] | [url=http://hulan.cz/temp/games.png][b]Games played[/b][/url] | [URL=http://hulan.cz/temp/sestava.png][B]CPU-Z[/B][/URL] -- [URL="http://radekhulan.cz/img/stacker-830/stacker-830-bocnice.jpg"][B]case foto[/B][/URL][/size]
radekhulan is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Discovery of new "zero-day" exploit links developers of Stuxnet, Flame News Archived News Items 0 06-11-12 06:10 PM
System not detecting 128MB of graphics memory A-KO NVIDIA GeForce 7, 8, And 9 Series 21 09-27-02 08:59 PM
Is it bad to leave geforce overclocked all the time? Creole General Hardware 2 09-23-02 11:13 PM
so let's try this again in the new forum - bad performance with correctly inst.driver neutrino NVIDIA Linux 11 08-01-02 04:19 PM

All times are GMT -5. The time now is 03:02 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.