PHP Classes

File: sig.php

Recommend this page to a friend!
  Classes of Sebastien Renauld   PHP Fetch   sig.php   Download  
File: sig.php
Role: Example script
Content type: text/plain
Description: An example: sig generator
Class: PHP Fetch
Fetch information about PHP Classes authors
Author: By
Last change: PHPClasses changed their class view system; I added a strip_tags to remove the new problems (which were a <font size='+1'> staying in the code, followed by a <b>)
Date: 19 years ago
Size: 1,969 bytes
 

Contents

Class file image Download
<?
header
("Content-Type: image/gif");
class
PHPFetch {
    var
$classes;
    var
$infos;
    function
fetch_phpclasses($id) {
       
$data = file("http://www.phpclasses.org/browse/author/$id.html");
        foreach (
$data as $id2 => $line) {
            if (
eregi("<a href=\"/browse/package/([0-9]{1,4}).html\">(.+)</a>",$line,$ar)) {
               
$this->classes[] = array("pkg" => $ar[1], "name" => strip_tags($ar[2]));
            }
            elseif (
eregi("<TH ALIGN=right WIDTH=\"1%\" NOWRAP><!--htdig_noindex-->(.+)<!--/htdig_noindex-->:</TH>",$line,$ar)) {
                if (
$ar[1] != "Name") {
                   
$cinfo = $ar[1];
                }
            }
            elseif (
eregi("<TD NOWRAP>(.+)</TD>",$line,$ar) and $cinfo) {
                switch (
$cinfo) {
                    case
"Published packages":
                       
$this->infos["pkgs"] = $ar[1];
                        break;
                    case
"Age":
                       
$this->infos["age"] = $ar[1];
                        break;
                    case
"Country":
                       
$this->infos["country"] = eregi_replace("</a>","",eregi_replace("<a href=\"(.+)\">","",$ar[1]));
                        break;
                    case
"Home page":
                       
$this->infos["hpage"] = eregi_replace("<(/{0,1})tt>","",eregi_replace("<!--/htdig_noindex-->","",eregi_replace("<!--htdig_noindex-->","",$ar[1])));
                        break;
                    case
"All time rank":
                       
$this->infos["arank"] = $ar[1];
                        break;
                    case
"Week rank":
                       
$this->infos["wrank"] = $ar[1];
                }
                unset(
$cinfo);
            }
        }
    }
}
$siggy = imagecreatefromgif("./clear.gif") or die();
$phpc = new PHPFetch;
if (isset(
$HTTP_GET_VARS['id'])) {
   
$phpc->fetch_phpclasses($HTTP_GET_VARS['id']);
   
sleep("0.5");
   
$background = imagecolorallocate($siggy, 255, 0, 0);
   
$truc = imagestring($siggy,"2","228","26",$HTTP_GET_VARS['id'],$background);
   
$truc = imagestring($siggy,"2","228","42",count($phpc->classes),$background);
   
$truc = imagestring($siggy,"2","228","58",$phpc->infos['wrank'],$background);
   
$truc = imagestring($siggy,"2","228","74",$phpc->infos['arank'],$background);
    echo
imagegif($siggy);
}
else {
    echo
imagegif($siggy);
}
?>