Alexa Traffic Rank Button - PHP Tutorial - php Form

Author Topic: Alexa Traffic Rank Button - PHP Tutorial  (Read 3721 times)

Offline admin

  • Administrator
  • *****
  • Posts: 67
  • Karma: +10/-0
  • Gender: Male
    • View Profile
Alexa Traffic Rank Button - PHP Tutorial
« on: June 10, 2007, 03:21:47 AM »


alexa.php

Code: [Select]
<?php
header
("Content-type: image/png");
*/ Function 
to check Alexa rank */ 
function 
get_alexa($url){
$site fopen('http://www.alexa.com/data/details/main?url='.urlencode($url),'r');
while(
$cont fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression '/for more information about the Alexa Web Information Service.-->(.*)<\/span><\/a>/Us';
preg_match($match_expression,$total,$matches);
return 
strip_tags($matches[1]);
}
*/ 
Website URL */

$urlh getenv(HTTP_HOST);
$link "http://$urlh";

/*Create an image from a PNG template*/ 

$string get_alexa($link);
$im imagecreatefrompng("button.png");
$color imagecolorallocate($im000000100);
$px = (imagesx($im) - 7.5 strlen($string)) / 2;
imagestring($im3$px10$string$color);
imagepng($im);
imagedestroy($im);
?>


button.png
200 x 35 pixels

« Last Edit: May 25, 2008, 05:01:15 PM by admin »

Offline eng65

  • Supporter
  • **
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Alexa Traffic Rank Button - PHP Tutorial
« Reply #1 on: February 12, 2008, 10:36:56 AM »
What does:Parse error: syntax error, unexpected '*' in C:\wamp\www\alexa.php on line 4?
Thanks
Eng65
Ps good snippets of code anymore?

Offline Roby

  • Supporter
  • **
  • Posts: 4
  • Karma: +1/-0
    • View Profile
Re: Alexa Traffic Rank Button - PHP Tutorial
« Reply #2 on: May 09, 2008, 02:57:08 PM »

Code: [Select]
<?php
header
("Content-type: image/png");
//Function to check Alexa rank
function get_alexa($url){
$site fopen('http://www.alexa.com/data/details/main?url='.urlencode($url),'r');
while(
$cont fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression '/for more information about the Alexa Web Information Service.-->(.*)<\/span><\/a>/Us';
preg_match($match_expression,$total,$matches);
return 
strip_tags($matches[1]);
}
//Website URL

$urlh getenv(HTTP_HOST);
$link "http://$urlh";

//Create an image from a PNG template 

$string get_alexa($link);
$text '-Alexa-';
$stringa $string $text $urlh;
$im imagecreatefrompng("button.png");
$color imagecolorallocate($im000);
imagestring($im3511$stringa$color);
imagepng($im);
imagedestroy($im);
?>

 ::) ::) ::)




« Last Edit: May 25, 2008, 05:04:23 PM by admin »