Help with PHP and Apache for sig script wanted

Soldato
Joined
18 Oct 2002
Posts
4,139
Location
North Wales
Just investigated further, and it doesn't have an effect on font size at all.

What appears to be happening is that if the number in that variable is greater than 5, and it PHP doesn't have any external fonts installed, it just selects font 5 as a default (and the font is physically larger, at least on my installation).

Fontsize =1

seti.php


Fontsize =3

seti.php



Fontsize =5

seti.php


Fontsize = 500

seti.php
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
4,139
Location
North Wales
It seems that your version of PHP comes with different fonts.

[edit]Beaten to it :)[/edit]

My PHPinfo is here if it's any help.

It's very strange :confused:

(You also won't get the "Site Down" messages with the other script :))
 
Last edited:
Commissario
OP
Joined
16 Oct 2002
Posts
2,766
Location
In the radio shack
OK, using the following code:

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: [url]http://forums.overclockers.co.uk/fo...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=0;
   $TextGreen=0;
   $TextBlue=0; 
   $FontSize=10;
   $TextX=164;
   $TextY=-8;
   $ImageURL="http://www.all-one-word.com/setisig/feek.png";
   $UpdatePeriod=900; //Maximum frequency in seconds at which the script will poll Berkeley 
//Setup Variables For Webspace - Must be absolute paths
   $LocalFile="c:\Program Files\Apache Group\Apache2\htdocs\setisig\WUTotal.dat";
   $FontFile="c:\Program Files\Apache Group\Apache2\htdocs\setisig\times.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);
   }
?>

This produces lots of errors

I have the font file in the location specified, the script has created a file called WUTotal.dat but when I view that file in notepad it contains "User not found."

Summat's not right.

K.
 
Soldato
Joined
18 Oct 2002
Posts
4,139
Location
North Wales
The script (besides being the version which falls over when berkeley's down, I'd advise you to look at the end of the thread :)), can't find your font file or the image by the looks of it.

Try putting the font in a directory with no spaces in the name. It doesn't like spaces IIRC. Also your image is not externally accessible. See here. Try accessing it with a path.

Also, uncomment the following :

// $PreText="Team OcUK - Get WU's Or Die Tryin'";
// $PostText="WU's owned";

as they are being called later on in the script. Rather set them as follows:

$PreText="";
$PostText="";

That may help a bit
 
Last edited:
Back
Top Bottom