Weather Sticker PHP script v 3.0

Version 3.0 of my weather sticker script is now available:

http://scripts.anolecomputer.com/download.shtml

This version contains one important bug fix (I missed destroying one of the temporary images) and introduces support for Weather Display’s clientraw.txt data file.

The biggest change is obviously the addition of support for clientraw.txt. If you upload Weather Display’s clientraw.txt file to your site you can now use it’s data instead of having to create and upload a separate template file. Because of the nature of the data contained in clientraw.txt, several additional parameters specific to it’s use have been added.

In addition, since the clientraw.txt provides a value for a current conditions icon, I’ve added the capability to include a current conditions icon (25X25 px) to the sticker and banner. You can turn this off if you don’t want to use it. I have included a set of 25X25px icons but I’m not a graphics guy so you aren’t going to hurt my feelings if you want to use a different set.

Version 3.1 is now available:

http://scripts.anolecomputer.com/download.shtml

Contains a minor bug fix. An error log entry was being generated if you weren’t using the WD clientraw.txt current conditions icon.

Could you give an example of the correct way to sprecify the data path to the clientraw? I put sticker.php, sticker.gif, and banner.gif in my main WD directory so clientraw is in the same place as the sticker files. I have $data_file_path = ‘/frank.pinkston/frankpinkston_com/www/weather’ but it is not seeing the clientraw file. How do I set $data_file_path?

Thanks for such great contribution!

Frank

If it’s in the same directory as sticker.php then you should be able to set it to:

$data_file_path = ‘./clientraw.txt’';

I’m having trouble with this as well. I cannot get it to produce anything. I have clientraw.txt in the same directory as the sticker.php and have the path set to ‘./clientraw.txt’ and I’m running on my private Linux server using PHP5 and Apache btw, dont know if this may have a bearing on it?’ Just keep getting the broen image icon instead of any meaningful output for both sticker and banner.

Stuart

Is any error log being generated?

[quote author=anole link=topic=12227.msg94068#msg94068 date=1131986716]
If it’s in the same directory as sticker.php then you should be able to set it to:
$data_file_path

Yes quite a few, mainly about type in $_Request[type] on line 381 amongst others. most of the others are warnings wher it assumes something and so wont stop it.

Stuart

Can you post the exact log entries for me?

… and a the URL you are using to call the script.

The logs are

[client 192.168.0.7] PHP Notice: Use of undefined constant float - assumed ‘float’ in /var/www/html/wxsticker/sticker.php on line 281, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 381, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 391, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant float - assumed ‘float’ in /var/www/html/wxsticker/sticker.php on line 281, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 381, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Undefined index: type in /var/www/html/wxsticker/sticker.php on line 381, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 384, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 391, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Undefined index: type in /var/www/html/wxsticker/sticker.php on line 391, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 394, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 412, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Use of undefined constant type - assumed ‘type’ in /var/www/html/wxsticker/sticker.php on line 412, referer: http://192.168.0.7/sticker.html
[client 192.168.0.7] PHP Notice: Undefined index: type in /var/www/html/wxsticker/sticker.php on line 412, referer: http://192.168.0.7/sticker.html

Cant post a URL as it is a private server on my lan…

Stuart

It almost looks like your install or setup isn’t allowing the superglobal $_REQUEST to be populated.

Create a php page with markup and php and go to it in your browser giving it some garbage variables like http://test.php?var1=x1&var2=x2. What do you get?

<?php print("Request method: " . $_SERVER['REQUEST_METHOD']." "); print("Dump of HTTP RAW POST DATA ". var_dump($HTTP_RAW_POST_DATA)." "); print("Dump of POST Data" . var_dump($_POST)." "); print("Dump of REQUEST Data" . var_dump($_REQUEST)." "); ?>

Your suggested script gives output of:

Request method: GET

Notice: Undefined variable: HTTP_RAW_POST_DATA in /var/www/html/test.php on line 7
NULL Dump of HTTP RAW POST DATA
array(0) { } Dump of POST Data
array(2) { [“var1”]=> string(2) “x1” [“var2”]=> string(2) “x2” } Dump of REQUEST Data

Stuart

Stuart,
I just sent you an IM.

I am trying to run this using Apache 2.0, PHP5 and Windows XP Pro…

I get the following error when I run it…
Fatal error: Call to undefined function imagecreatefromgif() in C:\Program Files\Apache Group\Apache2\htdocs\weather\sticker.php on line 343

You can see this yourself at http://wx.hemetweather.com/weather/sticker.php

I believe it has something to do with the imagecreatfromgif function being removed from current versions of PHP, or something of that nature… can anybody supply a work around for this?

Thanks!

According to what I found imagecreatefromgif() wont work if you have the 1.6 level of the GD library since all GIF support was removed from the GD lib at this level.

Stuart

Actually it’s more likely the version of GD that your are running. gif support was removed from GD at one point because of the licensing issues but was added back in 7/2004 with release 2.0.28 . So the first thing to look at is which version of GD you have installed. You can check this quickly by creating a page with the following in it:

<?PHP print_r(gd_info()); ?> 

I’m running 2.0.33 on Mandrake which says it has GIF create support. As I said I did see the error meesage once but on recent runs of the script it does not appear for me.

Stuart

I’ve sorted my problem. I had to add double quotes around each occurance of “type” and “float”. I am now getting my stickers and banners created. Now to play with them…

Stuart

Excellent!

Bad mistake on my part. I’ll fix it for the next version!

Thanks Stuart!

EDIT: Bug fixes are done, I just need to do a little more testing and I’m thinking about breaking the config out into it’s own separate file to make updating easier in the future. The new version should be up in a few hours.