9, January 2009

whats wrong with this snippet of code? - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

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



« on: Jan 04, 2006, 10: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..

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #1 on: Jan 04, 2006, 08:25:38 PM »

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

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

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

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #2 on: Jan 05, 2006, 09: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 Visit through proxy.. 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;

?>

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #3 on: Jan 05, 2006, 11: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 Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



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

still displaying like 10 #'s

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #5 on: Jan 11, 2006, 07:56:52 AM »

so does anyone got an idea?

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #6 on: Jan 12, 2006, 05: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: 884
1636 credits
Members referred : 4



« Reply #7 on: Jan 12, 2006, 06:45:57 AM »

yes but still does same thing

Visit through proxy Visit through proxy Visit through proxy

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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Jan 09, 2009, 08:35:49 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: 38.657
Total Topics: 7.772
Total Members: 4.659
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: sardiniasarena

28 Guests, 4 Users online :

15 users online today:



Readers

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