Code:
<html>
<head>
<Title>404 Test Thingy or whatever</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff">
<br>
<form method="post">
<div align="center"><strong>Test URLs:</strong><br>
<textarea name="urls" id="urls" cols="45" rows="5"><?=isset($_REQUEST['urls'])?$_REQUEST['urls']:"";?></textarea>
<br>
<input type="submit" name="submit" id="submit" value="Check Response">
</div>
</form>
<?php
// This is hardly an example of good PHP. Ugh.
@require_once("class.curl.php");
// trim() to get rid of errant enter keys.
$myurls = (isset($_REQUEST['urls'])?explode("\n", trim($_REQUEST['urls'])): array());
foreach ($myurls as $url) {
// lame
$search="";
$breakshit = @explode("|", $url);
if (!empty($breakshit["1"])) {
$url = $breakshit["0"];
$search = $breakshit["1"];
}
// use our cURL class.
$curlInit = new curl($url);
// Make sure we don't follow redirects.
$curlInit->setopt(CURLOPT_FOLLOWLOCATION, FALSE) ;
$curlInit->setopt(CURLOPT_RETURNTRANSFER, TRUE) ;
// Do it.
$return = $curlInit->exec();
// If we returned a connection error, say so.
if ($myError = $curlInit->hasError()) {
echo "ERR: $url ($myError)<br>\n";
} else {
// Reinit our array
if (!eregi($search, $return)) {
echo "<font color='red'>Did not find "".$search.""</font>: <a href='$url' target='_new'>[link]</a> $url<br>\n";
}
}
// We're done, close the socket.
$curlInit->close();
}
?>
</body>
</html>
This one lets you search for a specific word in the full text of the html. It uses eregi rather than preg, because I hate perl's regex.
Format:
http://site.com/|searchterm
If searchterm is empty, it doesn't fall back to 404. I don't feel like actually turning this pile of shit code into something worthwhile. I'm not bored anymore.
