[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 function smarty_cms_function_googlepr($params, &$smarty) { 20 $domain = $_SERVER['SERVER_NAME']; 21 if (!empty($params['domain'])) 22 $domain = $params['domain']; 23 24 define('GMAG', 0xE6359A60); 25 26 //unsigned shift right 27 function zeroFill($a, $b){ 28 $z = hexdec(80000000); 29 if ($z & $a){ 30 $a = ($a>>1); 31 $a &= (~$z); 32 $a |= 0x40000000; 33 $a = ($a>>($b-1)); 34 }else{ 35 $a = ($a>>$b); 36 } 37 return $a; 38 } 39 40 41 function mix($a,$b,$c) { 42 $a -= $b; $a -= $c; $a ^= (zeroFill($c,13)); 43 $b -= $c; $b -= $a; $b ^= ($a<<8); 44 $c -= $a; $c -= $b; $c ^= (zeroFill($b,13)); 45 $a -= $b; $a -= $c; $a ^= (zeroFill($c,12)); 46 $b -= $c; $b -= $a; $b ^= ($a<<16); 47 $c -= $a; $c -= $b; $c ^= (zeroFill($b,5)); 48 $a -= $b; $a -= $c; $a ^= (zeroFill($c,3)); 49 $b -= $c; $b -= $a; $b ^= ($a<<10); 50 $c -= $a; $c -= $b; $c ^= (zeroFill($b,15)); 51 52 return array($a,$b,$c); 53 } 54 55 function GCH($url, $length=null, $init=GMAG) { 56 if(is_null($length)) 57 $length = sizeof($url); 58 $a = $b = 0x9E3779B9; 59 $c = $init; 60 $k = 0; 61 $len = $length; 62 while($len >= 12) { 63 $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24)); 64 $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24)); 65 $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24)); 66 $mix = mix($a,$b,$c); 67 $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; 68 $k += 12; 69 $len -= 12; 70 } 71 72 $c += $length; 73 switch($len){ /* all the case statements fall through */ 74 case 11: $c+=($url[$k+10]<<24); 75 case 10: $c+=($url[$k+9]<<16); 76 case 9 : $c+=($url[$k+8]<<8); 77 /* the first byte of c is reserved for the length */ 78 case 8 : $b+=($url[$k+7]<<24); 79 case 7 : $b+=($url[$k+6]<<16); 80 case 6 : $b+=($url[$k+5]<<8); 81 case 5 : $b+=($url[$k+4]); 82 case 4 : $a+=($url[$k+3]<<24); 83 case 3 : $a+=($url[$k+2]<<16); 84 case 2 : $a+=($url[$k+1]<<8); 85 case 1 : $a+=($url[$k+0]); 86 /* case 0: nothing left to add */ 87 } 88 $mix = mix($a,$b,$c); 89 /*-------------------------------------------- report the result */ 90 return $mix[2]; 91 } 92 93 //converts a string into an array of integers containing the numeric value of the char 94 function strord($string) { 95 for($i=0;$i<strlen($string);$i++) { 96 $result[$i] = ord($string{$i}); 97 } 98 return $result; 99 } 100 101 function getPR($_url) { 102 $url = 'info:'.$_url; 103 $ch = GCH(strord($url)); 104 $url='info:'.urlencode($_url); 105 $pr = file("http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url"); 106 $pr_str = implode("", $pr); 107 return substr($pr_str,strrpos($pr_str, ":")+1); 108 } 109 110 return getPR($domain); 111 } 112 113 function smarty_cms_help_function_googlepr() { 114 ?> 115 <h3>What does this do?</h3> 116 <p>Display's a number that represents your google pagerank.</p> 117 <h3>How do I use it?</h3> 118 <p>Just insert the tag into your template/page like: <code>{googlepr}</code><br> 119 <br> 120 121 <h3>What parameters does it take?</h3> 122 <ul> 123 <li><em>(optional)</em> domain - The website to display the pagerank for.</li> 124 </ul> 125 </p> 126 <?php 127 } 128 129 function smarty_cms_about_function_googlepr() { 130 ?> 131 <p>Author: Brett Batie<brett-cms@classicwebdevelopment.com></p> 132 <p>Version: 1.0</p> 133 <p> 134 Change History:<br/> 135 None 136 </p> 137 <?php 138 } 139 140 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |