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

Associate
Joined
29 Oct 2002
Posts
903
Location
Abingdon, Oxfordshire
Well you can have a look but you won't see anything :(

Here is the webpage ----> http://members.lycos.co.uk/widget66/paul.php


Here is the script :-

<?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="Test";
$PostText="WU's";
$TextRed=100;
$TextGreen=100;
$TextBlue=100;
$FontSize=12;
$TextX=350;
$TextY=12;
$ImageURL="http://homepage.ntlworld.com/paul.eccles/m3.jpg";
$UpdatePeriod=900; //Maximum frequency in seconds at which the script will poll Berkeley

//Setup Variables For Webspace - Must be absolute paths
$LocalFile="/data/members/free/tripod/uk/w/i/d/widget66/seti/WUTotal.dat";
$FontFile="/data/members/free/tripod/uk/w/i/d/widget66/font/arial.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);
}
?>
 
Man of Honour
Joined
4 Nov 2002
Posts
15,508
Location
West Berkshire
Add this immediately after the <?php
Code:
  echo " ";
That may cause any errors to be displayed. You can ignore the warning about header information.

Remove the echo line once you've fixed any other errors.
 
Associate
Joined
12 Feb 2003
Posts
693
Location
Beflast Norn Iron
Trying this on lycos too, HERE
Add this immediately after the <?php
echo " ";

Nice 1, at least im getting an error now to see where im going wrong. Im getting this error now
Parse error: parse error in sigs.php on line 22

Line 22 being the path to where the wutotal.dat file will be. Ive yet to find the correct absolute path that i should use for this, but at least ive figured out how to chmod 777 the directory:D

Dont let this thread die, id love to get this working. Thanks for all the help so far:cool:
 
Associate
Joined
12 Feb 2003
Posts
693
Location
Beflast Norn Iron
Yeah i was using backslash, so i have changed it to the folowing

Code:
$LocalFile="="\data\members\free\tripod\uk\leakymeat\files\WUTotal.dat";
   $FontFile="="\data\members\free\tripod\uk\leakymeat\files\verdana.ttf";

Now im getting 2 errors on line 22.

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in sigs.php on line 22

Parse error: parse error in sigs.php on line 22


Is there a way to find out if im using the correct path, or would an email to the admins at lycos be needed? Thanks Mark.

[edit] DOH, think im getting :confused: between back and forward slash, i was using forward slash after all :D
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
10,676
Location
Castle Anthrax
tbh if it's reporting a parse error then php is throwing a wobbler before it's even tried to do anything with the string so it's unlikely to be an problem with the path itself.

Although I'm not sure what your trying to do with that latest code above :confused:
 
Associate
Joined
29 Oct 2002
Posts
903
Location
Abingdon, Oxfordshire
I might be getting somewhere now, when I try and open the page the next time I log onto lycos ftp there is a hand with \data\members\free\tripod\uk\widget66\seti\WUTotal.dat next to it so this suggests the scirpt is doing something.

Edit piccy now:-

php.jpg
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
4,139
Location
North Wales
Originally posted by Widget
Well I have enough fiddling trying to get this to work, is there anyone who could host one for me please ?

I'll host it for you if you like. Just e-mail me the relevant files and I'll get it done :)

[edit] You can use the PHP file you've got already or I can add you to my db and you can use mine, whichever you like [/edit]
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
4,139
Location
North Wales
I have changed the script slightly to stop it overwriting the wucount file (and therefore displaying the images with no unit count) when there is no response from Berkeley.

Tested and confirmed working by TrUz.

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
//Further revised by Phil Rea (taliesyn) May 2003
//Visit the OcUK team forum: [url]http://forums.overclockers.co.uk/forumdisplay.php?&forumid=39[/url]
//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 only if there is a response from Berkeley
     if ($WUs != "User not found.")
     {
      $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);
   }
?>
 
Back
Top Bottom