Файл: wapxl.ru/shaxty/func_seo.php
Строк: 390
<?php
function getGoogleStr($url)
{
$file = new Snoopy();
$file->fetchtext("http://www.google.com/search?q=site:".$url."&nomo=1&hl=ru");
$text = @iconv('windows-1251', 'UTF-8', $file->results);
$findStr = preg_match("/Результатов: примерно ([0-9_ ]+)/i",$text,$match);
if($match[1])
{
return $match[1];
}
else
{
return 0;
}
}
function checkhash($Hashnum) {
$CheckByte = 0;
$Flag = 0;
$HashStr = sprintf('%u', $Hashnum);
$length = strlen($HashStr);
for ($i = $length - 1; $i >= 0; $i--) {
$Re = $HashStr{$i};
if (1 === ($Flag % 2)) {
$Re += $Re;
$Re = (int) ($Re / 10) + ($Re % 10);
}
$CheckByte += $Re;
$Flag++;
}
$CheckByte %= 10;
if (0 !== $CheckByte) {
$CheckByte = 10 - $CheckByte;
if (1 === ($Flag % 2)) {
if (1 === ($CheckByte % 2)) {
$CheckByte += 9;
}
$CheckByte >>= 1;
}
}
return '7' . $CheckByte . $HashStr;
}
function getch($url) {
return checkhash(hash_url($url));
}
function pr($url) {
$googlehost = 'toolbarqueries.google.com';
$googleua = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5';
$ch = getch($url);
$fp = fsockopen($googlehost, 80, $errno, $errstr, 30);
if ($fp) {
$out = "GET /tbr?features=Rank&sourceid=navclient-ff&client=navclient-auto-ff&ch=$ch&q=info:$url HTTP/1.1rn";
$out .= "User-Agent: $googleuarn";
$out .= "Host: $googlehostrn";
$out .= "Connection: Closernrn";
fwrite($fp, $out);
while (!feof($fp)) {
$data = fgets($fp, 128);
$pos = strpos($data, "Rank_");
if ($pos === false) {
} else {
$pr = substr($data, $pos + 9);
$pr = trim($pr);
$pr = str_replace("n", '', $pr);
return $pr;
}
}
fclose($fp);
}
return 0;
}
function strtonum($Str, $Check, $Magic) {
$Int32Unit = 4294967296;
$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
$Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
}
$Check += ord($Str{$i});
}
return $Check;
}
function hash_url($String) {
$Check1 = strtonum($String, 0x1505, 0x21);
$Check2 = strtonum($String, 0, 0x1003F);
$Check1 >>= 2;
$Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
$Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
$Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
$T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) << 2 ) | ($Check2 & 0xF0F );
$T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
return ($T1 | $T2);
}
function pagerank($url, $width=40, $method='style') {
if (!preg_match('/^(http://)?([^/]+)/i', $url))
$url = 'http://' . $url;
$pr = $this->get_pr($url);
if ($pr == "")
$pr = 0;
$out = '' . $pagerank . '';
return $out;
}
function ginfo($url){
preg_match('#<span class="c">(.*)/</span>#Ui', file_get_contents('http://www.google.com/m?q=info:'.$url), $out);
if (!isset($out[1])){ $out[1] = $url;} if($out[1] !== $url){$r='(клей с '.$out[1].')';}else{$r=' ';} return $r;}
function google_backs($url){
$site = fopen('http://www.google.com/search?q=link%3A'.urlencode($url),'r');
while($cont = fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression = '/of about <b>(.*)</b> linking to/Us';
preg_match($match_expression,$total,$matches);
return $matches[1];
}
function yahoo_backs($url){
$site = fopen('http://siteexplorer.search.yahoo.com/search?p='.urlencode($url).'&bwm=i&bwmf=a&bwms=p','r');
while($cont = fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression = '/of about <strong>(.*) </strong>/Us';
preg_match($match_expression,$total,$matches);
return $matches[1];
}
function yaCa($site_url){
$xml = simplexml_load_file("http://bar-navig.yandex.ru/u?ver=2&url=http://".urlencode($site_url)."/&show=1");
if(!$xml->topics->topic['title'] and !$xml->topics->topic['url']) {
return 'нет'; } else { return 'есть'; }
}
function lookup($domain)
{
if (true) {
$ch = curl_init('http://dns.com.ua/whois/?domain='.$domain);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$url = curl_exec($ch);
curl_close($ch);
} else {
$url = file_get_contents('http://dns.com.ua/whois/?domain='.$domain);
}
$url = preg_match('~<pre>(.*)</pre>~si', preg_replace('~%(.*)).~s', null, $url), $info);
return nl2br(trim($info[1])).'<br/>';
}
$snoopy = new Snoopy();
function getDmoz($url)
{
@$file = file_get_contents('http://www.dmoz.org/search?q='.$url);
if(preg_match('#<strong>Opens*Directorys*Sites</strong>#ui',$file)){
return 'есть';
}else{
return 'нет';
}
}
function getBackRambler($url)
{
global $snoopy;
$snoopy->fetchtext('http://nova.rambler.ru/search?query=%22'.$url.'%22&news=2');
preg_match("/Найдено (.*) документов/",$snoopy->results,$match);
if(empty($match[1]))$match[1] = 0;
return $match[1];
}
function getBing($url)
{ @$file = file_get_contents('http://www.bing.com/search?q=site:'.$url.'&setmkt=ru-RU&setlang=en-US');
preg_match("/of (.*) results/",$file,$match);
if(empty($match[1]))$match[1] = 0;
return $match[1];
}
function getBingLink($url)
{
@$file = file_get_contents('http://www.bing.com/search?q=%22'.$url.'%22-site:'.$url.'&setmkt=ru-RU&setlang=en-US');
preg_match("/of ([0-9 ]*) results/",$file,$match);
if(empty($match[1]))$match[1] = 0;
return $match[1];
}
function getYahoo($url)
{
global $snoopy;
@$file = $snoopy->fetchtext('http://siteexplorer.search.yahoo.com/search?p='.$url.'&bwmf=s&bwmo=d');
preg_match('/Pages (.*)Inlinks/',$snoopy->results,$match);
if(empty($match[1]))$match[1] = 0;
return $match[1];
}
function getYahooLink($url)
{
global $snoopy;
$snoopy->fetchtext('http://siteexplorer.search.yahoo.com/search?p='.$url.'&bwmf=s&bwmo=d');
preg_match("/Inlinks (.*)Show /",$snoopy->results,$match);
if(empty($match[1]))$match[1] = 0;
return $match[1];
}
function getSite($url)
{
@$file = file_get_contents('http://'.$url);
preg_match('#name="keywords" content="([.]*|[^>]*)"#i',$file,$match1);
preg_match('/name="description" content="([.]*|[^>]*)"/i',$file,$match2);
if(empty($match1[1]))$match1[1] = "нет";
if(empty($match2[1]))$match2[1] = "нет";
return array($match1[1],$match2[1]);
}
function getTitle($url)
{
@$file = file_get_contents('http://'.$url);
preg_match('/<title>(.*)</title>/',$file,$match1);
if(empty($match1[1]))$match1[1] = "нет";
return $match1[1];
}
function getH1($url)
{
@$file = file_get_contents('http://'.$url);
preg_match('/<h1>(.*)</h1>/',$file,$match1);
if(empty($match1[1]))$match1[1] = "нет";
return $match1[1];
}
function GetRobotsMeta($url)
{
@$file = file_get_contents('http://'.$url);
preg_match("/<meta name=["|']robots["|'] content=("|')(.*)("/>|">|>|/>)/isU",$file,$match1);
if(empty($match1[1]))$match1[1] = "нет";
return $match1[1];
}
class Seo {
public $Gorequest = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&key=ABQIAAAAQsyJlHF7zz9LVvcJd4ZPGhQZ3u_AO1Uwtt9AExGkl2DbkaY66BSJAucV_lcjAbYvdReMHB2tRnqOVQ";
public $GoBrequest = "http://ajax.googleapis.com/ajax/services/search/blogs?v=1.0&key=ABQIAAAAQsyJlHF7zz9LVvcJd4ZPGhQZ3u_AO1Uwtt9AExGkl2DbkaY66BSJAucV_lcjAbYvdReMHB2tRnqOVQ";
public $Yarequest = "http://xmlsearch.yandex.ru/xmlsearch?user=Rainexxx&key=03.103870741:8605b7d7a5ef6e8a91e3b793a64eb25f";
/* Google Index : FILTERS : duplicate, porn, ru */
public function google_index($site_url){
$data = json_decode(file_get_contents($this->Gorequest.'&lr=ru&filter=1&safe=active&q=site:'.urlencode($site_url)));
return " ".intval($data->responseData->cursor->estimatedResultCount);
}
/* Google Links : FILTERS : duplicate, porn, ru*/
public function google_links($site_url){
$data = json_decode(file_get_contents($this->Gorequest.'&lr=ru&filter=1&safe=active&hl=ru&q=link:'.urlencode($site_url)));
return " ".intval($data->responseData->cursor->estimatedResultCount);
}
/* Google blogs : FILTERS : default */
public function google_blogs($site_url){
$data = json_decode(file_get_contents($this->GoBrequest.'&q=link:'.urlencode($site_url)));
return " ".intval($data->responseData->cursor->estimatedResultCount);
}
/* INDEXED PAGES */
public function Yandex_Index($site_url){
$requestFormat = <<<DOC
<?xml version='1.0' encoding='utf-8'?>
<request><query>host:"$site_url"</query></request>
DOC;
$context = stream_context_create(array(
'http' => array(
'method'=>"POST",
'header'=>"Content-type: application/xmlrn" . "Content-length: ".strlen($requestFormat),
'content'=>$requestFormat
)
));
$response = file_get_contents($this->Yarequest, true, $context);
if ($response) {
$xmldoc = new SimpleXMLElement($response);
$error = $xmldoc->response->error;
$inIndex = $xmldoc->response->found;
if ($error) { return "0"; // have problem
} else { return $inIndex; } // yes we catch something
} else { return "err."; } // have unknown problem
}
/* INCOMING LIKS */
public function Yandex_Links($site_url){
$requestFormat = <<<DOC
<?xml version='1.0' encoding='utf-8'?>
<request><query>"http://$site_url"</query></request>
DOC;
$context = stream_context_create(array(
'http' => array(
'method'=>"POST",
'header'=>"Content-type: application/xmlrn" . "Content-length: ".strlen($requestFormat),
'content'=>$requestFormat
)
));
$response = file_get_contents($this->Yarequest, true, $context);
if ($response) {
$xmldoc = new SimpleXMLElement($response);
$error = $xmldoc->response->error;
$inLinks = $xmldoc->response->found;
if ($error) { return "0"; // have problem with description
} else { return " ".$inLinks; } // yes we catch something
} else { return "err."; } // have problem
}
}
function seo_news(){
function updates(){
error_reporting(0);
$str=@file_get_contents('http://www.pr-cy.ru/updates.xml');
preg_match( "'<cy>(.*?)</cy>'si", $str, $rez1 );
preg_match( "'<pr>(.*?)</pr>'si", $str, $rez2 );
preg_match( "'<yav>(.*?)</yav>'si", $str, $rez3 );
$rez4 = array ($rez1[1],$rez2[1],$rez3[1]);
return $rez4;
}
function elm($str){
$elms = explode(" ", $str); // Выбрать из строки даты день, месяц и год
return $elms;
}
function days($m, $d, $y){ // Дней назад
$tm=time(); // Сегодня
$rez1=intval(($tm-mktime(0, 0, 0, $m, $d, $y))/86400,10); // Разница между сегодня и апдейтом (в сутках 86400 секунд)
if($rez1==0){$rez=' (сегодня)';}else
if($rez1==1){$rez=' (вчера)';}else
if($rez1==2){$rez=' (позавчера)';}else
if($rez1==3){$rez=' (' .$rez1 .' дня назад)';}else
if($rez1==4){$rez=' (' .$rez1 .' дня назад)';}else
$rez=' (' .$rez1 .' дней назад)';
return $rez;
}
$out = updates();
$cy=$out[0]; $pr=$out[1]; $yv=$out[2];
$cy1=preg_replace ( "'.'si", ' ',$cy); // Замена точек на пробелы в строке даты
$pr1=preg_replace ( "'.'si", ' ',$pr);
$yv1=preg_replace ( "'.'si", ' ',$yv);
$ecy=elm($cy1); $epr=elm($pr1); $eyv=elm($yv1);
$cyd=$ecy[0]; $cym=$ecy[1]; $cyy=$ecy[2];
$prd=$epr[0]; $prm=$epr[1]; $pry=$epr[2];
$yvd=$eyv[0]; $yvm=$eyv[1]; $yvy=$eyv[2];
$daycy=days($cym,$cyd,$cyy); $daypr=days($prm,$prd,$pry); $dayyv=days($yvm,$yvd,$yvy);
$rezlt = '<div class="xl"><b>Яндекс ТИЦ:</b> ' .$cy .$daycy .'</div>
<div class="xl"><b>Google PR:</b> ' .$pr .$daypr .'</div>
<div class="xl"><b>Яндекс выдача:</b> ' .$yv .$dayyv .'</div>';
return $rezlt;
}
function utf8_str_split($str) {
// place each character of the string into and array
$split=1;
$array = array();
for ( $i=0; $i < strlen( $str ); ){
$value = ord($str[$i]);
if($value > 127){
if($value >= 192 && $value <= 223)
$split=2;
elseif($value >= 224 && $value <= 239)
$split=3;
elseif($value >= 240 && $value <= 247)
$split=4;
}else{
$split=1;
}
$key = NULL;
for ( $j = 0; $j < $split; $j++, $i++ ) {
$key .= $str[$i];
}
array_push( $array, $key );
}
return $array;
}
/**
* Функция вырезки
* @param <string> $str
* @return <string>
*/
function clearstr($str){
$sru = 'ёйцукенгшщзхъфывапролджэячсмитьбю';
$s1 = array_merge(utf8_str_split($sru), utf8_str_split(strtoupper($sru)), range('A', 'Z'), range('a','z'), range('0', '9'));
$codes = array();
for ($i=0; $i<count($s1); $i++){
$codes[] = ord($s1[$i]);
}
$str_s = utf8_str_split($str);
for ($i=0; $i<count($str_s); $i++){
if (!in_array(ord($str_s[$i]), $codes)){
$str = str_replace($str_s[$i], '', $str);
}
}
return $str;
}
// Проверка корректности url
function check_urls($url,$data) { // (www.)?
$a = false;
if (preg_match("/^(([w,-]+.)($data))$/i", $url)) {
$a = true;
}
if (preg_match("/^(([0-9А-яёЁтТыЫ-]+.)(рф))$/",$url)) {
$a = true;
}
return $a;
}
?>