I'm on my knees begging (PHP stats related)

Once Mark G has done his bit to the script tomorrow, rekon a donny could squeeze this code into the sticky as quite a lot of people wont it. More so now the stats counters are messed up.

EDIT: Just spotted the sticky isnt locked, Mark rekon you could post your updated version straight into the sticky?
 
Originally posted by TrUz
EDIT: Just spotted the sticky isnt locked, Mark rekon you could post your updated version straight into the sticky?
I'll do that once someone else has verified that my changes work.:)
 
Hey neat, I just got this working on IIS on w2k :D

[edit] Seems to work ok too! [/edit]
 
Last edited:
Ive been intrigued by this thread.
I havent a clue about php, and would like to have a go at adding my wu count to my sig also. Would anyone know if ntlworlds homepage servers have php enabled for me to host 1.
I dont want this to seem like a roundabout way of asking someone to do all the work and host one for me (although that would be sweet:D). Would be self gratifieing if I could do it myself.
 
Code:
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo "<p>Hello World</p>"; ?>
 </body>
</html>

upload that and see if it works, after that all the tutorials etc you could need are at www.php.net welcome to the wonderful world of php =)

Valor.
 
Originally posted by LeakyMeat
Ive been intrigued by this thread.
I havent a clue about php, and would like to have a go at adding my wu count to my sig also. Would anyone know if ntlworlds homepage servers have php enabled for me to host 1.
I dont want this to seem like a roundabout way of asking someone to do all the work and host one for me (although that would be sweet:D). Would be self gratifieing if I could do it myself.

Im not sure if it does, try the php test if it doesnt ill host you 1 or someone else will there pleanty of people hosting siggys.
 
Good advice Valor.

However, you also need to know if you have the GD module installed in your PHP setup. The best way of doing this is to create a file called "test.php" containing the following:

<HTML>
<HEAD>
<TITLE>Test PHP Script</TITLE>
</HEAD>
<BODY>
<?PHP
phpinfo();
?>
</BODY>
</HTML>

Upload it to your webspace, and load it up in your browser.

Mine is here

What you're looking for is something similar to this :

gd.jpg


That confirms that you have GD graphics library installed (with Freetype is useful for rendering truetype fonts), and it means that you can produce your own .jpg/.png/.bmp images (and .gif too if you have the older version of GD installed).

If you just get a blank page with Test PHP Script as the title, your webspace providers do not have PHP installed.
 
Thanks for the help, it would appear that Ntl's sevrers dont have php support:(
T'would seem the door to the wonderful world of php has be firmly slammed in my face
brickwall.gif
 
if your intrested in getting new hosting I cant reccomend enets enough.

mail [email protected] and hopefully he will reduce my charge ;)

hehe ok so there are lots good php hosting places, though you will prolly have to play.

Or if you just want this image hosting I'm sure someone will volounteer.

Valor.
 
Here's my revised script. This should survive a Berkeley outage in most cases.

Code:
<?php

//Code for overlaying SETI stats over a JPEG or PNG image
//By Phil Cutler (kaiowas) of Team OcUK Oct 2002
//Revised by Mark Gray Apr 2003
//Visit the OcUK team forum: http://forums.overclockers.co.uk/forumdisplay.php?&forumid=39
//Uses a local file to cache the users total and reduce bandwidth hit on Berkeley

//Setup Variables For Sig
   $UserEmail="[email protected]";
   $PreText="Team OcUK - Get WU's Or Die Tryin'";
   $PostText="WU's owned";
   $TextRed=251;
   $TextGreen=251;
   $TextBlue=251; 
   $FontSize=12;
   $TextX=350;
   $TextY=12;
   $ImageURL="http://www.digital-designs.biz/seti/truz/truz.jpg";
   $UpdatePeriod=900; //Maximum frequency in seconds at which the script will poll Berkeley 

//Setup Variables For Webspace - Must be absolute paths
   $LocalFile="/home/www/digitalth/seti/truz/WUTotal.dat";
   $FontFile="/home/www/digitalth/seti/fonts/disco___.ttf"; 


   if(!file_exists($LocalFile) or !FileMTime($LocalFile) or time()-FileMTime($LocalFile)>$UpdatePeriod)
   {

    //Get Total Number Of WUs from personal stats page at Berkeley
    $fp =@fopen ("http://setiathome.ssl.berkeley.edu/fcgi-bin/fcgi?email=" . $UserEmail . "&cmd=user_stats_new", "r");
    if ($fp)
    {
     while (!feof($fp))
     {
      $WebPage.=fgets($fp,200);
     }
     fclose($fp);

     if (strpos($WebPage,"No user with that name was found")==0)
     {
      $TotalStart=strpos($WebPage,"Results Received");
      $StartPos=strpos($WebPage,"<td>",$TotalStart)+4;
      $EndPos=strpos($WebPage,"</td>",$StartPos);
      $WUs=ltrim(rtrim(substr($WebPage,$StartPos,$EndPos-$StartPos)));
     }
     else
     { 
      $WUs="User not found."; 
     }

     //Update Local File With Total
     $Output = fopen ($LocalFile, "a"); 
     ftruncate ($Output, 0);
     fseek($Output,0);
     fwrite($Output, $WUs);
     fclose($Output);
    }
   }

   //Read Total from Local File
   $Local=@fopen ($LocalFile, "r");
   $WUs=fgets($Local,200);
   fclose($Local);


   //Build Text String
   $Text=$PreText . "\r\n" . $WUs . " " . $PostText;

   //Create Image
   $size = ImageTTFBbox ($FontSize, 0, $FontFile , $Text);

   $im_x=abs($size[4]-$size[0]);
   $im_y=abs($size[5]-$size[1]);

   if (substr($ImageURL,strlen($ImageURL)-3,3)=="jpg")
   {
    //Create a Sig image based on a JPEG
    Header("Content-type: image/jpeg");
    Header("Expires: " . gmdate("D, d M Y H:i:s", time() + 900) . " GMT");
    $im_size = GetImageSize ($ImageURL); 
    $imageWidth = $im_size[0];
    $imageHeight = $im_size[1];
    $im = ImageCreateFromJPEG($ImageURL); 
    $text_color = imagecolorclosest ($im, $TextRed, $TextGreen, $TextBlue);
    if ($TextX+$im_x>$imageWidth){$TextX=$imageWidth-$im_x-2;}
    if ($TextY>$imageHeight){$TextY=$imageHeight-2;}
    imagettftext ($im, $FontSize, 0, $TextX, $TextY, $text_color, $FontFile, $Text);
    ImageJpeg ($im);
    ImageDestroy ($im);
   }
   elseif (substr($ImageURL,strlen($ImageURL)-3,3)=="png")
   {
    //Create a Sig image based on a PNG
    Header("Content-type: image/png");
    Header("Expires: " . gmdate("D, d M Y H:i:s", time() + 900) . " GMT");
    $im_size = GetImageSize ($ImageURL); 
    $imageWidth = $im_size[0];
    $imageHeight = $im_size[1];
    $im = ImageCreateFromPNG($ImageURL); 
    $text_color = imagecolorclosest ($im, $TextRed, $TextGreen, $TextBlue);
    if ($TextX+$im_x>$imageWidth){$TextX=$imageWidth-$im_x-2;}
    if ($TextY>$imageHeight){$TextY=$imageHeight-2;}
    imagettftext ($im, $FontSize, 0, $TextX, $TextY, $text_color, $FontFile, $Text);
    ImagePNG ($im);
    ImageDestroy ($im);
   }
?>
 
Last edited:
Look at mine for example mate, just change the paths to suit your host, also make sure the directory you wont the dat file to be stored in you chmod it to 777.
 
Originally posted by TrUz
ooooo all setup for me...
That's because I used your script as a starting point. I assume my version still works.

Most of my edits were just to move things around a bit to make the script more stable.
 
Ye still works perfect mate, i updated mine with your edited version and as you can see its still working, just. :p :D
 
Back
Top Bottom