28, May 2012

whats wrong with this snippet of code? - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: whats wrong with this snippet of code?
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: whats wrong with this snippet of code?  (Read 1182 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« on: Jan 04, 2006, 09:29:35 am »

Code:
/* begin my edit (pr addition)*/
$clean_url = parse_url ( $data['weblink_url'] );
$clean_url = $clean_url[ 'host' ];
echo "<img src='".THEME."images/bullet.gif'> <a href='".$data['weblink_url']."' title='".$data['weblink_name']."' class='side'> ".$itemsubject."</a>--PR: ";
    include('http://justinlove.net/pagerank.php?url=$cleanurl');
echo "<br>";
/* end my edit (pr addition)*/

it is supposed to display the PR of the cleaned url. (nik, you know what this is) instead of usng an image it uses text. for each link, it will display like 10 different numbers, when its supposed to only display the 1 PR # for that site..


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Jan 04, 2006, 07:25:38 pm »

It is obvious that the problem is in the page http://justinlove.net/pagerank.php

Propably you should write this snippet to give you an answer.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #2 on: Jan 05, 2006, 08:00:02 am »

hmm but it seems to display the PR of any site fine, if i dont use it inside another file. like if i use include('pathtopagerank.php?url=www.webdigity.com') it will work fine, showing 1 number.. heres an example of the PR of sleekpixel, http://www.justinlove.net/pr.php.. but here is code for pagerank.php

Code:
<?php 

/* 

    This code is released unto the public domain 

*/ 

header("Content-Type: text/plain; charset=utf-8"); 

define('GOOGLE_MAGIC'0xE6359A60); 


//unsigned shift right 

function zeroFill($a$b


    
$z hexdec(80000000);
    
//echo $z;

        
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 
$c+=($url[$k+8]<<8); 

          
/* the first byte of c is reserved for the length */ 

        
case $b+=($url[$k+7]<<24); 

        case 
$b+=($url[$k+6]<<16); 

        case 
$b+=($url[$k+5]<<8); 

        case 
$b+=($url[$k+4]); 

        case 
$a+=($url[$k+3]<<24); 

        case 
$a+=($url[$k+2]<<16); 

        case 
$a+=($url[$k+1]<<8); 

        case 
$a+=($url[$k+0]); 

         
/* case 0: nothing left to add */ 

    

    

    
$mix mix($a,$b,$c); 

    
//echo $mix[0];

    /*-------------------------------------------- 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


// http://www.example.com/ - Checksum: 6540747202 

$url $_GET['url']; 
//print("url:\t{$_GET['url']}\n"); 

$ch "6" GoogleCH(strord("info:" $url)); 


$fp fsockopen("www.google.com"80$errno$errstr30);
if (!
$fp) {
   echo 
"$errstr ($errno)<br />\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);
   
   
//$pagerank = substr(fgets($fp, 128), 4);
   //echo $pagerank;
   
while (!feof($fp)) {
$data fgets($fp128);
$pos strpos($data"Rank_");
if($pos === false){} else{
$pagerank substr($data$pos 9);
echo $pagerank;
}
   }
   
fclose($fp);
}
//echo "ch: 6".$ch;

?>


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Jan 05, 2006, 10:20:08 pm »

Change this :

Code:
<?php
$url 
$_GET['url']; 
?>


to :

Code:
<?php
if ( isset ( $clean_url ) )
{
    
$url $clean_url;
}else{
    
$url $_GET['url']; 
}
?>


Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #4 on: Jan 06, 2006, 12:55:01 am »

still displaying like 10 #'s


Last blog : phpHaze 1.59.1 in Development
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #5 on: Jan 11, 2006, 06:56:52 am »

so does anyone got an idea?


Last blog : phpHaze 1.59.1 in Development
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0



« Reply #6 on: Jan 12, 2006, 04:01:31 am »

It looks fine to me (after the change that Nikolas proposed)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #7 on: Jan 12, 2006, 05:45:57 am »

yes but still does same thing


Last blog : phpHaze 1.59.1 in Development
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=1139
Tags : domains pagerank snippets Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: whats wrong with this snippet of code?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 01:34:39 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 62.814
Total Topics: 11.028
Total Members: 21.451
Tutorials : 58
Resources : 929
Designs : 395
Latest Member: sobbin

109 Guests, 2 Users online :

10 users online today:




Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.