PHP skripta za PR
 
frenky 6. dec 2006 23:12:50 Pridružen od:
31. avg 2006
593 objav
155 4 0
#1

Spodnjo kodo bi rad uporabil za določanje PR v PHPLD.



Žal imam samo eno php gostovanje in zato ne morem stestirat, če je hosting provider kriv, da mi skripta vedno vrne -1 namesto dejanski PR.



Če ima kdo par minut bi bil zelo vesel če lahko sproba če njemu deluje.


<?php
/******************
* PageRankXor32 class created by MagicBeanDip
* PageRank class was created by others
* Look for updates at http://v1.magicbeandip.com/mbd-file/PageRankReport.php
* This code is released into the Public Domain
*
* Sample use:
* include('PageRankXor32.php');
* $oPR=new PageRankXor32();
* echo $oPR->getRank('http://www.amazon.com');
*
******************/


define('GOOGLE_MAGIC', 0xE6359A60);

// Use this class if your server is having problems with bitwise operations
class PageRankXor32 extends PageRank {
function xor32($a, $b) {
return $this->int32($a) ^ $this->int32($b);
}
//return least significant 32 bits
//works by telling unserialize to create an integer even though we provide a double value
function int32($x) {
return unserialize("i:$x;");
//return intval($x); // This line doesn't work on all servers.
}

function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a = $this->xor32($a,$this->zeroFill($c,13));
$b -= $c; $b -= $a; $b = $this->xor32($b,$a<<8);
$c -= $a; $c -= $b; $c = $this->xor32($c,$this->zeroFill($b,13));
$a -= $b; $a -= $c; $a = $this->xor32($a,$this->zeroFill($c,12));
$b -= $c; $b -= $a; $b = $this->xor32($b,$a<<16);
$c -= $a; $c -= $b; $c = $this->xor32($c,$this->zeroFill($b,5));
$a -= $b; $a -= $c; $a = $this->xor32($a,$this->zeroFill($c,3));
$b -= $c; $b -= $a; $b = $this->xor32($b,$a<<10);
$c -= $a; $c -= $b; $c = $this->xor32($c,$this->zeroFill($b,15));
return array($a,$b,$c);
}
}

//This class should work on most servers
class PageRank {
function zeroFill($a, $b){
$z = hexdec(80000000);
if ($z & $a){
$a = ($a>>1);
$a &= (~$z);
$a |= 0x40000000;
$a = ($a>>($b-1));
}else{
$a = ($a>>$b);
}
return $a;
}

function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,13));
$b -= $c; $b -= $a; $b ^= ($a<<8);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,13));
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,12));
$b -= $c; $b -= $a; $b ^= ($a<<16);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,5));
$a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,3));
$b -= $c; $b -= $a; $b ^= ($a<<10);
$c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,15));
return array($a,$b,$c);
}

function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
if(is_null($length)) {
$length = sizeof($url);
}
$a = $b = 0x9E3779B9;
$c = $init;
$k = 0;
$len = $length;
while($len >= 12) {
$a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
$b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
$c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
$mix = $this->mix($a,$b,$c);
$a = $mix[0]; $b = $mix[1]; $c = $mix[2];
$k += 12;
$len -= 12;
}
$c += $length;
switch($len){
case 11: $c+=($url[$k+10]<<24);
case 10: $c+=($url[$k+9]<<16);
case 9 : $c+=($url[$k+8]<<8);
/* the first byte of c is reserved for the length */
case 8 : $b+=($url[$k+7]<<24);
case 7 : $b+=($url[$k+6]<<16);
case 6 : $b+=($url[$k+5]<<8);
case 5 : $b+=($url[$k+4]);
case 4 : $a+=($url[$k+3]<<24);
case 3 : $a+=($url[$k+2]<<16);
case 2 : $a+=($url[$k+1]<<8);
case 1 : $a+=($url[$k+0]);
}
$mix = $this->mix($a,$b,$c);
/* report the result */
return $mix[2];
}

//converts a string into an array of integers containing the numeric value of the char
function strord($string) {
for($i=0;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}
return $result;
}

//returns -1 if no page rank was found
function getRank($url){
$ch = "6".$this->GoogleCH($this->strord("info:" . $url));

$pagerank=-1;
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)
\n";
} else {
$out = "GET /search?client=navclient-auto&ch=" . $ch . "&features=Rank&q=info:" . $url . " HTTP/1.1\r\n" ;
$out .= "Host: www.google.com\r\n" ;
$out .= "Connection: Close\r\n\r\n" ;
fwrite($fp, $out);
while (!feof($fp)) {
$data = fgets($fp, 128);
$pos = strpos($data, "Rank_");
if($pos === false){
}else{
$pagerank = trim(substr($data, $pos + 9));
}
}
fclose($fp);
}
return $pagerank;
}
}

$oPR=new PageRankXor32();
echo $oPR->getRank('http://www.amazon.com');

?>

Hvala. :)


všeč(0) ni všeč(0) spam(0)
Dynamic color chart and color picker for HTML Color Codes.
 
frisby 7. dec 2006 00:12:18 Pridružen od:
6. sep 2006
1625 objav
7 0 0
#2

Sem na enih dveh probu pa na localu pa dela brez problema, na večih se mi ni dalo. Kje maš gostovanje.



Kaže pa PR mal drugač kot nekateri znani, prchecker.info, iwebtool, seolog, recimo za novejše strani tudi amazon.com (ko je v resnici 9), kaže nulo, ker ma tisti DC taki info, pa še za kakega drugega sem najdu to... Sem pa vidu, da kaže mi po novem moj ff pr toolbar od google tud te ko so drugačni (drugačn je cirka na 20% DC-jih kuk sem na hiter vidu). :/



Recimo če pa gledam na uradni strani od skripte pa kaže vredu PR, to je menda od loakcije odvisn, sam sem preveu na slovenskih in ameršikih. :/



Mater sem zabluzo no, vglavnem skripta dela.



EDIT: lahka da je kak problem s funkcijo fsockopen, je kje dizajblana al pa kej, vklopi si errorje, ti javi kaj? errorreporting(EALL) na vrhu kode. Ker pred fsockopen nastavi PR na -1 in tak zgleda da tud ostane.


všeč(0) ni všeč(0) spam(0)
 
frenky 7. dec 2006 01:12:16 Pridružen od:
31. avg 2006
593 objav
155 4 0
#3

Hvala za pomoč, sedaj mi pokaže tole:



Notice: unserialize() [function.unserialize]: Error at offset 0 of 20 bytes in /home/aonewebs/public_html/test.php on line 26



Notice: unserialize() [function.unserialize]: Error at offset 0 of 20 bytes in /home/aonewebs/public_html/test.php on line 26



Notice: unserialize() [function.unserialize]: Error at offset 0 of 20 bytes in /home/aonewebs/public_html/test.php on line 26



Notice: unserialize() [function.unserialize]: Error at offset 0 of 19 bytes in /home/aonewebs/public_html/test.php on line 26



Notice: unserialize() [function.unserialize]: Error at offset 0 of 20 bytes in /home/aonewebs/public_html/test.php on line 26

-1



Testiram tukaj:

http://a1-website-hosting-directory.com/test.php


všeč(0) ni všeč(0) spam(0)
Dynamic color chart and color picker for HTML Color Codes.
 
frenky 7. dec 2006 01:12:18 Pridružen od:
31. avg 2006
593 objav
155 4 0
#4

26 vrstica je tale:



return unserialize("i:$x;");


všeč(0) ni všeč(0) spam(0)
Dynamic color chart and color picker for HTML Color Codes.
 
frenky 7. dec 2006 08:12:41 Pridružen od:
31. avg 2006
593 objav
155 4 0
#5

Sem na googlu ( http://www.pmachine.com/forums/viewthread/39028/P0/ ) našel da moram pobrisati cache takole:

CP Home › Admin › Utilities › Clear Cached Data



Jaz imam CPanel XP Revolution in tega "Clear Cached Data" nikjer ne najdem. Help? :)


všeč(0) ni všeč(0) spam(0)
Dynamic color chart and color picker for HTML Color Codes.
 
Vini 7. dec 2006 11:12:44 Pridružen od:
1. sep 2006
6612 objav
5234 611 56
#6

Problem imas s stringom, ki ga podajas funkciji serialize()... zakaj do tega problema pride, zdejle na hitro res ne bi vedel. poskusi uporabit kar PageRank class namesto PageRankXor32, v komentarjih pise, da naj bi prvi delal na vecini serverjev, ta serialize() pa uporablja drugi. Katero verzijo PHPja imas na serverju?


všeč(0) ni všeč(0) spam(0)
 
frenky 7. dec 2006 13:12:01 Pridružen od:
31. avg 2006
593 objav
155 4 0
#7

Sem poskusil uporabiti PageRank class, pa mi sedaj vrne "-1" brez vseh napak.



Imam pa hosting na hostmonster.com:

Operating system Linux

Kernel version 2.6.17-11_4.BHsmp

Apache version 1.3.37 (Unix)

PERL version 5.8.7l

PHP version 4.4.4

MySQL version 4.1.21-standard-log

cPanel Build 10.9.0-RELEASE 57


všeč(0) ni všeč(0) spam(0)
Dynamic color chart and color picker for HTML Color Codes.
 
Vini 7. dec 2006 13:12:35 Pridružen od:
1. sep 2006
6612 objav
5234 611 56
#8

hmm... prav nimam moznosti kjerkoli poskusit s PHP 4.4, jaz povsod uporabljam 5.1



poskusi pred vrstico


return unserialize("i:$x;");

napisati


echo "i:$x;\n";

pa povej kaksen je output... tako bomo videli, pri kaksnih vrednostih se mu zatakne...

pa seveda poskusi s PageRankXor32 classom :)


všeč(0) ni všeč(0) spam(0)
 
frenky 7. dec 2006 14:12:42 Pridružen od:
31. avg 2006
593 objav
155 4 0
#9

Ekola:



i:-4738698913; i:568102; i:-45675229; i:0; i:4653896912; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:-2937611353; i:203123; i:389218034; i:0; i:1663987311; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:27989; i:0; i:-26; i:0; i:26; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; i:0; GET /search?client=navclient-auto&ch=60&features=Rank&q=info:http://www.amazon.com HTTP/1.1 Host: www.google.com Connection: Close



Sem probal tudi drugo PR skripto, pa tudi ne dela:

http://a1-website-hosting-directory.com/test1.php



Warning: filegetcontents(http://toolbarqueries.google.com/search?client=navclient-auto&ch=64267538756&ie=UTF-8&oe=UTF-8&q=info:http://www.amazon.com/) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/aonewebs/public_html/test1.php on line 148



Checksum <2.0.114: ..... 64267538756 ...... link .... PR =



Warning: filegetcontents(http://toolbarqueries.google.com/search?client=navclient-auto&ch=62289308828&ie=UTF-8&oe=UTF-8&q=info:http://www.amazon.com/) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/aonewebs/public_html/test1.php on line 163



Checksum >=2.0.114: ..... 62289308828 ...... link .... PR =



Koda:


<?php
/*
Written and contributed by
Alex Stapleton,
Andy Doctorow,
Tarakan,
Bill Zeller,
Vijay "Cyberax" Bhatter
traB
This code is released into the public domain
*/

//header("Content-Type: text/plain; charset=utf-8");
define('GOOGLE_MAGIC', 0xE6359A60);

function obtainPR($data)
{
$ret = array();

$parser = xml_parser_create();
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
xml_parse_into_struct($parser,$data,$values,$tags);
xml_parser_free($parser);

$hash_stack = array();

foreach ($values as $key => $val)
{
switch ($val['type'])
{
case 'complete':
array_push($hash_stack, $val['tag']);
$type = implode($hash_stack, "][");
if ($type == "RK")
{
$PageRank = $val[value];
}
array_pop($hash_stack);
break;
}//swhitch
}//foreach

return $PageRank;
}//obtainPR

//unsigned shift right
function zeroFill($a, $b)
{
$z = hexdec(80000000);
if ($z & $a)
{
$a = ($a>>1);
$a &= (~$z);
$a |= 0x40000000;
$a = ($a>>($b-1));
}
else
{
$a = ($a>>$b);
}
return $a;
}

function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
$b -= $c; $b -= $a; $b ^= ($a<<8);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
$a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
$b -= $c; $b -= $a; $b ^= ($a<<16);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
$a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
$b -= $c; $b -= $a; $b ^= ($a<<10);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,15));

return array($a,$b,$c);
}

function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
if(is_null($length)) {
$length = sizeof($url);
}
$a = $b = 0x9E3779B9;
$c = $init;
$k = 0;
$len = $length;
while($len >= 12) {
$a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
$b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
$c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
$mix = mix($a,$b,$c);
$a = $mix[0]; $b = $mix[1]; $c = $mix[2];
$k += 12;
$len -= 12;
}

$c += $length;
switch($len) /* all the case statements fall through */
{
case 11: $c+=($url[$k+10]<<24);
case 10: $c+=($url[$k+9]<<16);
case 9 : $c+=($url[$k+8]<<8);
/* the first byte of c is reserved for the length */
case 8 : $b+=($url[$k+7]<<24);
case 7 : $b+=($url[$k+6]<<16);
case 6 : $b+=($url[$k+5]<<8);
case 5 : $b+=($url[$k+4]);
case 4 : $a+=($url[$k+3]<<24);
case 3 : $a+=($url[$k+2]<<16);
case 2 : $a+=($url[$k+1]<<8);
case 1 : $a+=($url[$k+0]);
/* case 0: nothing left to add */
}
$mix = mix($a,$b,$c);
/*-------------------------------------------- report the result */
return $mix[2];
}

//converts a string into an array of integers containing the numeric value of the char
function strord($string) {
for($i=0;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}
return $result;
}

// converts an array of 32 bit integers into an array with 8 bit values. Equivalent to (BYTE *)arr32

function c32to8bit($arr32) {
for($i=0;$i<count($arr32);$i++) {
for ($bitOrder=$i*4;$bitOrder<=$i*4+3;$bitOrder++) {
$arr8[$bitOrder]=$arr32[$i]&255;
$arr32[$i]=zeroFill($arr32[$i], 8);
}
}
return $arr8;
}

// http://www.example.com/ - Checksum: 6540747202
$url='http://www.amazon.com/';
print("**URL .... $url**\n");
$url = 'info:' . $url;
$ch = GoogleCH(strord($url));
$url_to_parse = sprintf ("http://toolbarqueries.google.com/search?client=navclient-auto&ch=6%u&ie=UTF-8&oe=UTF-8&q=%s", $ch, $url);
$value = obtainPR(file_get_contents($url_to_parse));
printf("[*] <u>Checksum <2.0.114:</u> ..... 6%u ...... $url_to_parse>link</A>"" target="_blank" rel="noopener noreferrer"> <u>Checksum >=2.0.114:</u> ..... 6%u ...... <A href=$url_to_parse>link .... PR = $value\n",$ch);

?>

Mogoče je google blokiral zahtevke iz hotmonsterjevega IPja.


všeč(0) ni všeč(0) spam(0)
Dynamic color chart and color picker for HTML Color Codes.
 
Vini 7. dec 2006 14:12:46 Pridružen od:
1. sep 2006
6612 objav
5234 611 56
#10

ja, kje so pa zdej napake? :)


všeč(0) ni všeč(0) spam(0)
 
 

🔒 Za odgovor na to temo se moraš prijaviti.

Prijavi se