on my home computer (win98) this works fine, but on most host server (unix) it doesn’t work, even though all the setting on both server are nearly identical, is there a more reliable way of testing whether or not a url is valid?
[code=php]<?php
$back = (isset($_SERVER[‘HTTP_REFERER’]) && strpos($_SERVER[‘HTTP_REFERER’], $_SERVER[‘HTTP_HOST’]) !== false) ? $_SERVER[‘HTTP_REFERER’] : “http://{$_SERVER[‘HTTP_HOST’]}/”;
if(isset($_GET[‘id’]))
{
$sql = file_get_contents(‘includes/mysql.php’);
$sql = str_replace(‘<‘.’?php’, ”, $sql);
$sql = str_replace(‘?’.’>’, ”, $sql);
eval($sql);
$mysql->connect();
$mysql->select();
$result = $mysql->query(“SELECT `url` FROM `links` WHERE `id`='{$_GET[‘id’]}’ LIMIT 1”);
if(($url = @$mysql->result($result)) !== false)
{
$mysql->free($result);
if(($ts = @fopen($url, ‘rb’)) !== false && @fclose($ts) !== false)
{
$mysql->query(“UPDATE `stats` SET `hits`=(`hits`+1) WHERE `id`='{$_GET[‘id’]}’ LIMIT 1”);
header(“Location: $url”);
}
else
{
$mysql->query(“INSERT INTO `reports` VALUES (‘{$_GET[‘id’]}’, ‘invalid url’, ‘127.0.0.1’)”);
echo “<“.”?xml version=”1.0″ encoding=”utf-8″?”.”>n”;
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Website Not Found!</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<style type=”text/css”>
<!–
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
background-color: #FFFFFF;
margin: 25% 0px 0px 0px;
}
table {
border: 1px solid #999999;
}
td {
font-size: 10px;
}
th {
font-size: 11px;
}
–>
</style>
</head>
<body>
<table border=”0″ align=”center” cellpadding=”0″ cellspacing=”5″>
<tr>
<th>Website Not Found!</th>
</tr>
<tr>
<td align=”center” nowrap=”nowrap”><a href=”<?php echo $url; ?>”><?php echo $url; ?></a></td>
</tr>
<tr>
<td align=”center”><a href=”<?php echo htmlspecialchars($back); ?>”>previous page</a></td>
</tr>
</table>
</body>
</html>
<?php
}
}
else
{
header(“Location: $back”);
}
}
?>