<?
function CurlPage($path, $post, $proxy) {
$agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)";
$ch = curl_init ( $path );
@curl_setopt ( $ch , CURLOPT_USERAGENT , $agent );
@curl_setopt ( $ch , CURLOPT_HTTPHEADER , false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate");
curl_setopt($ch, CURLOPT_REFERER, "");
if($post!='')
{
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($proxy!='')
{
curl_setopt ( $ch , CURLOPT_PROXY, $proxy);
}
$tmp = @curl_exec ( $ch );
curl_close ( $ch );
return $tmp;
}
function iny($url,$post,$proxy)// определяем количество проиндексированных страниц
{
$url=explode(".",$url);
for($i=count($url)-1;$i>=0;$i--)
$ur.=$url[$i].".";
$ur=substr($ur,0,strlen($ur)-1);
$str = CurlPage("http://xmlsearch.yandex.ru/xmlsearch", xml($ur), $proxy);
$find1=preg_match('|<found priority="all">(.+)</found>|U', $str, $tic);
$iny=(int)trim($tic[1]);
return $iny;
}
function xml($host) {
$host ='rhost="'.$host.'"|rhost="'.$host.'.*"';
$xml_code = '<?xml version="1.0" encoding="windows-1251"?>
<request>
<query>'.$host.'</query>
<groupings>
<groupby attr="d" mode="deep" groups-on-page="1" docs-in-group="1" />
</groupings>
</request>';
return $xml_code;
}
if(isset($_POST['urlall'])){
$url=explode("\n", $_POST['urlall']);
foreach($url as $urlall){
$mam[]='/(^|\s)(http:\/\/)?(www\.)*/i';
$mam[]='/(\/)?([^-\.А-яA-z0-9].*)/i';
$site=trim(preg_replace($mam,"",$urlall));
$iny=iny($site,"","");
if($iny>0){
echo $site."<br>";
}
}
}
echo '<form method="POST" action="index.php">
<p><textarea rows="13" name="urlall" cols="70"></textarea></p>
<p><input type="submit" value="Добавить все" name="B2"></p>
</form><br>';
?>