Could not connect to server\n".mysql_error()."\n");
mysql_select_db($sql_db, $dbLink) or die("
Could not select DB\n".mysql_error()."\n
");
$sql_ok = false;
if($dbLink = mysql_pconnect("$sql_host:$sql_port", $sql_user, $sql_pass))
if(mysql_select_db($sql_db, $dbLink))
$sql_ok = true;
$site = "";
if(isset($_POST['site']))
$site = $_POST['site'];
echo "
Проверка ответов сайта
Служебный скрипт.
";
$spisok_serverov = "SELECT site, manag, clientid FROM client_site WHERE id=1";
$result = mysql_query($spisok_serverov) or die("Query failed : " . mysql_error());
echo "";
function get_content($hostname, $path)
{
$line = "";
$fp = fsockopen($hostname, 80, $errno, $errstr, 30);
if (!$fp) echo "$errstr ($errno)
\n";
else
{
$headers = "GET $path HTTP/1.1\r\n";
$headers .= "Host: $hostname\r\n";
$headers .= "Connection: Close\r\n\r\n";
fwrite($fp, $headers);
$end = $false;
while (!$end)
{
$line = fgets($fp, 1024);
if (trim($line) == "") $end = true;
else $out[] = $line;
}
fclose ($fp);
}
return $out;
}
$path = "/";
set_time_limit (180) ;
while ($resp = mysql_fetch_array($result, MYSQL_ASSOC))
{
$hostname = $resp["site"];
$pos = strrpos($hostname,"/");
$mastakkila = substr($hostname,$pos);
$out = get_content($hostname, $path);
//print_r($out);
echo "
$hostname | $out[0] | $path | $hostname |
";
$kn = $resp["manag"];
$kl = $resp["clientid"];
$result1 = mysql_query("INSERT INTO `answers` (`id`, `site`, `date`, `response`, `manag`, `clientid`) VALUES (NULL, '$hostname', NOW(), '$out[0]', '$kn', '$kl')")or die("Query failed : " . mysql_error());
}
echo "
";
?>