Forum Moderators: coopster

Message Too Old, No Replies

If page contains

I need a php script

         

TheAlbinoEthiopian

12:57 pm on May 16, 2007 (gmt 0)

10+ Year Member



I need a php script that will be given a url in a form (I can handle that part without a problem), then take that url, and search for a certain string in it's source code (html and javascript), if the string is there, it would output one thing, if it isn't, it would output another. I plan to output images, but I can handle that part. The main thing I can't figure out is how to tell the PHP to read the source of the page. I currently run PHP 4.3.11, so it needs to be compatible with that. Any help is greatly appreciated.

coopster

1:01 pm on May 16, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, TheAlbinoEthiopian.

file_get_contents() [php.net] will retrieve a file and put it's contents into a string for you.

TheAlbinoEthiopian

11:17 am on May 17, 2007 (gmt 0)

10+ Year Member



Thanks for the help, this is what I'm now using:

<?php
$RSlink = strip_tags($_GET["rs"]);
$htmlString = file_get_contents($RSlink);
if ($RSlink=="")
{
die;
}
elseif (eregi('<p><script>alert', $htmlString))
{
echo @file_get_contents("invalid.png");
}
else
{
echo @file_get_contents("valid.png");
}
?>