Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
function checkLink($link) {
$url_info = parse_url($link);
$url_info['port'] = isset($url_info['port']) ? $url_info['port'] : 80;
$url_info['path'] = isset($url_info['path']) ? $url_info['path'] : "/";
$url_info['query'] = isset($url_info['query']) ? "?" . $url_info['query'] : "";
$query = "GET " . $url_info['path'] . " HTTP/1.1\r\n";
$query = $query . "Content-Type: text/html\r\n";
$query = $query . "Host: " . $url_info['host'] . "\r\n";
$query = $query . "Content-length: " . (strlen($request)) . "\r\n\r\n";
$query = $query . $request;
$socket = fsockopen($url_info['host'], $url_info['port'], $errno, $error, 30);
fputs($socket, $query);
$s = fread($socket, 1024);
if( strpos($s, "200 OK") ) {
return true;
} else {
return false;
}
}
у тебя хостинг закрыает исходящию связь для скриптов
"fsockopen() has been disabled for security reasons"
попробуй другой хостинг, или через denwer на своем компьютере.
а где файл link.txtя чекаю так:
<?php
set_time_limit(0);
$data = file_get_contents('links.txt');
$data = explode(PHP_EOL, $data);
foreach($data as $k=>$v) {
if(!checkLink($v)) echo 'BAD LINK: ' . $v '<br />';
}
function checkLink($link) {
$url_info = parse_url($link);
$url_info['port'] = isset($url_info['port']) ? $url_info['port'] : 80;
$url_info['path'] = isset($url_info['path']) ? $url_info['path'] : "/";
$url_info['query'] = isset($url_info['query']) ? "?" . $url_info['query'] : "";
$query = "GET " . $url_info['path'] . " HTTP/1.1\r\n";
$query = $query . "Content-Type: text/html\r\n";
$query = $query . "Host: " . $url_info['host'] . "\r\n";
$query = $query . "Content-length: " . (strlen($request)) . "\r\n\r\n";
$query = $query . $request;
$socket = fsockopen($url_info['host'], $url_info['port'], $errno, $error, 30);
fputs($socket, $query);
$s = fread($socket, 1024);
if( strpos($s, "200 OK") ) {
return true;
} else {
return false;
}
}
?>
<?php
error_reporting(0);
function download($site,$url)
{
$fp = fsockopen($site, 80, $errno, $errstr, 60);
if ($fp) {
$out = "GET ".$url." HTTP/1.0\r\n";
$out .= "Host: ".$site."\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
$answ = fgets($fp, 128);
fclose($fp);
return $answ;
}
};
$handle = fopen("./link.txt", "r");
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
preg_match("!http://(.*?)/(.*?)\n!si",$buffer,$ok);
$rezult=download($ok[1],"/".$ok[2]);
if(strstr($rezult,"200 OK")){echo $buffer."\n";};
}
fclose($handle);
?>
allsu
вот последняя версия, проверенно
если сервер отвечает - значит ссылка выводится.
PHP:<?php error_reporting(0); function download($site,$url) { $fp = fsockopen($site, 80, $errno, $errstr, 60); if ($fp) { $out = "GET ".$url." HTTP/1.0\r\n"; $out .= "Host: ".$site."\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); $answ = fgets($fp, 128); fclose($fp); return $answ; } }; $handle = fopen("./link.txt", "r"); while (!feof($handle)) { $buffer = fgets($handle, 4096); preg_match("!http://(.*?)/(.*?)\n!si",$buffer,$ok); $rezult=download($ok[1],"/".$ok[2]); if(strstr($rezult,"200 OK")){echo $buffer."\n";}; } fclose($handle); ?>