Du befindest Dich im Archiv vom ABAKUS Online Marketing Forum. Hier kannst Du Dich für das Forum mit den aktuellen Beiträgen registrieren.

Pagerank abruf code (checksum kalkulation) in ASP?

Ajax, Hijax, Microformats, RDF, Markup, HTML, PHP, CSS, MySQL, htaccess, robots.txt, CGI, Java, Javascript usw.
Neues Thema Antworten
Webby
Administrator
Administrator
Beiträge: 5420
Registriert: 17.10.2001, 01:00

Beitrag von Webby » 10.01.2005, 04:37

Gibt es jemand hier das schon eine pagerank abruf (checksum calculation) mit ASP progamiert hat oder jemand das die PHP version (code unten) auf ASP programmierte könnte?

Falls eine weis wo ich die finden kann sag bitte bescheid (es gibt eine ins net aber das checksum kalkulation ist veraltet und stimmt nicht mehr).
Falls eine das programmieren möchtest, naturlich bezahlt, Ich bitte an eine pn.

PHP Code

Code: Alles auswählen

<html>
<body style="font-family&#58;verdana;font-size&#58;13px">
<?php
/*
This code is released unto the public domain

Raistlin Majere

*/
define&#40;'GOOGLE_MAGIC', 0xE6359A60&#41;;

//unsigned shift right
function zeroFill&#40;$a, $b&#41;
&#123;
$z = hexdec&#40;80000000&#41;;
if &#40;$z & $a&#41;
&#123;
$a = &#40;$a>>1&#41;;
$a &= &#40;~$z&#41;;
$a |= 0x40000000;
$a = &#40;$a>>&#40;$b-1&#41;&#41;;
&#125;
else
&#123;
$a = &#40;$a>>$b&#41;;
&#125;
return $a;
&#125;


function mix&#40;$a,$b,$c&#41; &#123;
$a -= $b; $a -= $c; $a ^= &#40;zeroFill&#40;$c,13&#41;&#41;;
$b -= $c; $b -= $a; $b ^= &#40;$a<<8&#41;;
$c -= $a; $c -= $b; $c ^= &#40;zeroFill&#40;$b,13&#41;&#41;;
$a -= $b; $a -= $c; $a ^= &#40;zeroFill&#40;$c,12&#41;&#41;;
$b -= $c; $b -= $a; $b ^= &#40;$a<<16&#41;;
$c -= $a; $c -= $b; $c ^= &#40;zeroFill&#40;$b,5&#41;&#41;;
$a -= $b; $a -= $c; $a ^= &#40;zeroFill&#40;$c,3&#41;&#41;;
$b -= $c; $b -= $a; $b ^= &#40;$a<<10&#41;;
$c -= $a; $c -= $b; $c ^= &#40;zeroFill&#40;$b,15&#41;&#41;;

return array&#40;$a,$b,$c&#41;;
&#125;

function GoogleCH&#40;$url, $length=null, $init=GOOGLE_MAGIC&#41; &#123;
if&#40;is_null&#40;$length&#41;&#41; &#123;
$length = sizeof&#40;$url&#41;;
&#125;
$a = $b = 0x9E3779B9;
$c = $init;
$k = 0;
$len = $length;
while&#40;$len >= 12&#41; &#123;
$a += &#40;$url&#91;$k+0&#93; +&#40;$url&#91;$k+1&#93;<<8&#41; +&#40;$url&#91;$k+2&#93;<<16&#41; +&#40;$url&#91;$k+3&#93;<<24&#41;&#41;;
$b += &#40;$url&#91;$k+4&#93; +&#40;$url&#91;$k+5&#93;<<8&#41; +&#40;$url&#91;$k+6&#93;<<16&#41; +&#40;$url&#91;$k+7&#93;<<24&#41;&#41;;
$c += &#40;$url&#91;$k+8&#93; +&#40;$url&#91;$k+9&#93;<<8&#41; +&#40;$url&#91;$k+10&#93;<<16&#41;+&#40;$url&#91;$k+11&#93;<<24&#41;&#41;;
$mix = mix&#40;$a,$b,$c&#41;;
$a = $mix&#91;0&#93;; $b = $mix&#91;1&#93;; $c = $mix&#91;2&#93;;
$k += 12;
$len -= 12;
&#125;

$c += $length;
switch&#40;$len&#41; /* all the case statements fall through */
&#123;
case 11&#58; $c+=&#40;$url&#91;$k+10&#93;<<24&#41;;
case 10&#58; $c+=&#40;$url&#91;$k+9&#93;<<16&#41;;
case 9 &#58; $c+=&#40;$url&#91;$k+8&#93;<<8&#41;;
/* the first byte of c is reserved for the length */
case 8 &#58; $b+=&#40;$url&#91;$k+7&#93;<<24&#41;;
case 7 &#58; $b+=&#40;$url&#91;$k+6&#93;<<16&#41;;
case 6 &#58; $b+=&#40;$url&#91;$k+5&#93;<<8&#41;;
case 5 &#58; $b+=&#40;$url&#91;$k+4&#93;&#41;;
case 4 &#58; $a+=&#40;$url&#91;$k+3&#93;<<24&#41;;
case 3 &#58; $a+=&#40;$url&#91;$k+2&#93;<<16&#41;;
case 2 &#58; $a+=&#40;$url&#91;$k+1&#93;<<8&#41;;
case 1 &#58; $a+=&#40;$url&#91;$k+0&#93;&#41;;
/* case 0&#58; nothing left to add */
&#125;
$mix = mix&#40;$a,$b,$c&#41;;
/*-------------------------------------------- report the result */
return $mix&#91;2&#93;;
&#125;

//converts a string into an array of integers containing the numeric value of the char
function strord&#40;$string&#41; &#123;
for&#40;$i=0;$i<strlen&#40;$string&#41;;$i++&#41; &#123;
$result&#91;$i&#93; = ord&#40;$string&#123;$i&#125;&#41;;
&#125;
return $result;
&#125;

function get_pr&#40;$url&#41; &#123;
$result=array&#40;"",-1&#41;;

if &#40;&#40;$url.""!=""&#41;&&&#40;$url.""!="http&#58;//"&#41;&#41;&#58;
// check for protocol
if &#40;substr&#40;strtolower&#40;$url&#41;,0,7&#41;!="http&#58;//"&#41;&#58;
$url="http&#58;//".$url;
endif;

$url="info&#58;".$url;
$checksum=GoogleCH&#40;strord&#40;$url&#41;&#41;;
$google_url=sprintf&#40;"http&#58;//www.google.com/search?client=navclient-auto&ch=6%u&features=Rank&q=".$url,$checksum&#41;; // url to get from google

$contents="";
// let's get ranking
// this way could cause problems because the Browser Useragent is not set...
if &#40;$handle=fopen&#40;$google_url,"rb"&#41;&#41;&#58;
while&#40;true&#41;&#58;
$data=fread&#40;$handle,8192&#41;;
if &#40;strlen&#40;$data&#41;==0&#41;&#58;
break;
endif;
$contents.=$data;
endwhile;
fclose&#40;$handle&#41;;
else&#58;
$contents="Connection unavailable";
endif;

$result&#91;0&#93;=$contents;
// Rank_1&#58;1&#58;0 = 0
// Rank_1&#58;1&#58;5 = 5
// Rank_1&#58;1&#58;9 = 9
// Rank_1&#58;2&#58;10 = 10 etc
$p=explode&#40;"&#58;",$contents&#41;;
if &#40;isset&#40;$p&#91;2&#93;&#41;&#41;&#58;
$result&#91;1&#93;=$p&#91;2&#93;;
endif;
endif;

return $result;
&#125;

// GET IT !
$pr=get_pr&#40;$_GET&#91;"url"&#93;&#41;;
$output=$pr&#91;0&#93;;
$pagerank=$pr&#91;1&#93;;
?>
<br>
<form method="get" action="?r=<?=time&#40;&#41;?>">
<center>
<table style="font-family&#58;verdana;font-size&#58;13px">
<tr>
<td valign="top"><b>Url</b></td>
<td valign="top"><?=$_GET&#91;'url'&#93;?></td>
</tr>
<tr>
<td valign="top"><b>Page<br>Rank</b></td>
<td valign="top" style="color&#58;red"><b><?=$pagerank?></b></td>
</tr>
<tr>
<td valign="top"><b>Google<br>output</b></td>
<td valign="top"><div style="overflow&#58;auto;width&#58;250px;height&#58;150px;background-color&#58;#eeeeee;border&#58;1px solid #aaaaaa"><?=$output?></div></td>
</tr>
</table>

<br>

<input type="text" name="url" size="80" value="<?=isset&#40;$_GET&#91;'url'&#93;&#41;?$_GET&#91;'url'&#93;&#58;"http&#58;//"?>"><br>
<input type="submit">

</center>
</form>
</body>
</html>
ABAKUS Internet Marketing
Professionelle Suchmaschinenoptimierung und Suchmaschinenmarketing

Antworten
  • Vergleichbare Themen
    Antworten
    Zugriffe
    Letzter Beitrag