WXforum.net

Web Weather => Weather Web Site Help => Topic started by: Anole on July 26, 2006, 08:01:18 PM

Title: Weather Sticker PHP Script
Post by: Anole on July 26, 2006, 08:01:18 PM
Version 5.0 is now available:

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

There are a lot changes starting with some new parameters added to config.txt:

Moved the icon placement parameters out into the config.txt file to make it easier to control placement of the icon. I meant to do this in 4.0 but somehow overlooked it. Here's what the section looks like from the new config.txt:

Code: [Select]

/***** ICON PLACEMENT: this section defines where the current      *****/
/***** conditions/forecast icon will be placed if you are using it *****/
// $sticker_icon_x: x coordinate on sticker of the upper left pixel of icon
// $sticker_icon_y: y coordinate on sticker of the upper left pixel of icon
$sticker_icon_x = '2';
$sticker_icon_y = '2';
// $banner_icon_x: x coordinate on banner of the upper left pixel of icon
// $banner_icon_y: y coordinate on banner of the upper left pixel of icon
$banner_icon_x = '300';
$banner_icon_y = '2';
// $banner_big_icon_x: x coordinate on banner_big of the upper left pixel of icon
// $banner_big_icon_y: y coordinate on banner_big of the upper left pixel of icon
$banner_big_icon_x = '2';
$banner_big_icon_y = '2';


Made it possible to choose your image format with a single parameter in config.txt. Options are gif, png, or jpeg. Background and current conditions icons have been provided for all three formats. Here's what the section looks like from the new config.txt:


Code: [Select]

/***** IMAGE FORMAT: defines the image format *****/
// The script supports 3 image formats: GIF, PNG, and JPG
// set $image_format for each as follows:
// for GIF: $image_format = 'gif';
// for PNG: $image_format = 'png';
// for JPEG: $image_format = 'jpeg';
$image_format = 'gif';


Probably the biggest change is the addition of current condition icons for VWS users! To use this feature the following tags are added to the VWS template file:

^climate_cconds1^,^vst144^,^vst145^

Thanks to Gordon C. @ http://oldlineweather.com for coming up with the list of possible values for ^climate_cconds1^ and making this possible!

Added some functionality to handle conditions where the data file is not present. Since its possible that the data file could be in the process of being uploaded at the time we try to get it, we can end up with a situation where we have no data. This can result in either script errors or blank images. The script is now much more robust in dealing with problems pulling the data file. Specifically:
 
If the data file is not found on the first attempt it will try again after a two second sleep.

If the data file is not found on the second attempt it will try again after another two second sleep.

If the data file is not found on the third attempt an image in the appropriate size (sticker, banner, banner_big) will be output indicating that there was no data available.


You can modify the text output in this instance by change the line (currently line 68 ) in sticker.php that reads:

Code: [Select]
nodataimage("Data Currently", "Unavailable");

Thanks to kenmtrue @ http://saratoga-weather.org/ for the idea/suggestion on handling the no data file issue.

And finally a couple of minor corrections:

Corrected some problems with icon images names.
Corrected text locations in the default images so they'll look a bit better initially.

One thing that I did not add that I had talked about doing was static images. If you need static images, it's probably best to tackle that through a cronjob. If you only want static images so you can use the banner in your signature on a phpBB forum or other location that will not allow php script calls, on a good way to accomplish that is through server redirects. Most control panels will let you do this through them or you can do it with an .htacess file if you are comfortable with that.

This will probably be the last major revision of the script. Of course, I'll continue to issue bug fixes, but the script is pretty much doing everything I want it to do for now.
Title: New version coming soon complete with avatarly goodness!
Post by: Anole on July 26, 2006, 08:06:45 PM
Thanks to a suggestion from Drew (KCWX) I'm adding a fourth image type to the script, the dreaded avatar!

Basically, the script will have the capability to output a 100 X 100 avatar sized image in addition to the other three image sizes. Look to the left and you'll see it! As of this writing, it's a testing version but the code is all there with only some minor testing left to do and documentatin to update. I expect that will all be ready before the end of the week.
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 26, 2006, 09:09:36 PM
Could somebody please post the URL for checking PHP and GD on a server. For some reason I can not get GD to work.
Title: Weather Sticker PHP Script
Post by: NoQuitters on July 26, 2006, 09:14:59 PM
Quote
Thanks to a suggestion from Drew (KCWX) I'm adding a fourth image type to the script, the dreaded avatar!


All I have to say is...(http://www.couronnedeluxe.com/phpBB2/images/smiles/occasion14.gif)
Title: Weather Sticker PHP Script
Post by: saratogaWX on July 27, 2006, 12:14:49 AM
Sure.. here's the test.php page:

Code: [Select]
<html>
<head>
<title>PHP test</title>
</head>
<body>
<h1>Does PHP work?</h1>

<?php echo "<h2>Yes, it does.  PHP Version " phpversion&#40;&#41; ."</h2>"; 
  
echo "<p>To run the WXSTICKER script, you need GD enabled in PHP.\n";
  echo 
"<br />Current GD status&#58;</p>\n";
  echo 
describeGDdyn&#40;&#41;;
  
// Retrieve information about the currently installed GD library
// script by phpnet at furp dot com &#40;08-Dec-2004 06&#58;59&#41;
//   from the PHP usernotes about gd_info
function describeGDdyn&#40;&#41; &#123;
 
echo "\n<ul><li>GD support&#58; ";
 if&
#40;function_exists&#40;"gd_info"&#41;&#41;&#123;
  
echo "<font color=\"#00ff00\">yes</font>";
  
$info gd_info&#40;&#41;;
  
$keys array_keys&#40;$info&#41;;
  
for&#40;$i=0; $i<count&#40;$keys&#41;; $i++&#41; &#123;
if&#40;is_bool&#40;$info[$keys[$i&#93;&#93;&#41;&#41; echo "</li>\n<li>" . $keys[$i&#93; ."&#58; " . yesNo&#40;$info[$keys[$i&#93;&#93;&#41;;
else echo "</li>\n<li>" $keys[$i&#93; ."&#58; " . $info[$keys[$i&#93;&#93;;
  
&#125;
 
&#125; else &#123; echo "<font color=\"#ff0000\">NO</font>"; &#125;
 
echo "</li></ul>";
&
#125;
function yesNo&#40;$bool&#41;&#123;
 
if&#40;$bool&#41; return "<font color=\"#00ff00\"> yes</font>";
 
else return "<font color=\"#ff0000\"> no</font>";
&
#125;


?>


<p>If you don't see "Yes, it does." above, then PHP is not enabled.</p>
</body>
</html>


If you have PHP and GD you should see something like this:
Quote
Does PHP work?
Yes, it does. PHP Version 4.4.2

To run the WXSTICKER script, you need GD enabled in PHP.
Current GD status:

    * GD support: yes
    * GD Version: 2.0 or higher
    * FreeType Support: yes
    * FreeType Linkage: with freetype
    * T1Lib Support: no
    * GIF Read Support: yes
    * GIF Create Support: yes
    * JPG Support: yes
    * PNG Support: yes
    * WBMP Support: yes
    * XBM Support: no
    * JIS-mapped Japanese Font Support: no

If you don't see "Yes, it does." above, then PHP is not enabled.


If you only see
Quote
Does PHP work?
If you don't see "Yes, it does." above, then PHP is not enabled.

 or worse, a bunch of stuff like
Quote
<?php echo "<h2>Yes, it does.  PHP Version " . phpversion() ."</h2>";
  echo "<p>To run the WXSTICKER script, you need GD enabled in PHP.\n";
  echo "<br />Current GD status:</p>\n";
  echo describeGDdyn();
...
the HTML is not parsed by the PHP interpreter and is treated as badly formed HTML -- In other words, PHP is not working on your site.

Best regards,
Ken
Title: Version 5.2 is now available
Post by: Anole on July 27, 2006, 01:34:27 PM
Version 5.2 is now available and can be downloaded at:

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

This new version includes a fourth image size designed to be used as a forum avatar...

<<<-----------------------  Look over there.

Thanks to Drew (KCWX) for the suggestion.

Avatar image size is 100px X 100px. The following changes are made to config.txt to enable this new image size:

The section where the current conditions icon is set has added some additional lines and now looks like this:

Code: [Select]

/***** ICON PLACEMENT: this section defines where the current      *****/
/***** conditions/forecast icon will be placed if you are using it *****/
// $sticker_icon_x: x coordinate on sticker of the upper left most pixel of icon
// $sticker_icon_y: y coordinate on sticker of the upper left most pixel of icon
$sticker_icon_x = '2';
$sticker_icon_y = '2';
// $banner_icon_x: x coordinate on banner of the upper left most pixel of icon
// $banner_icon_y: y coordinate on banner of the upper left most pixel of icon
$banner_icon_x = '300';
$banner_icon_y = '2';
// $banner_big_icon_x: x coordinate on banner_big of the upper left most pixel of icon
// $banner_big_icon_y: y coordinate on banner_big of the upper left most pixel of icon
$banner_big_icon_x = '2';
$banner_big_icon_y = '2';
// $avatar_icon_x: x coordinate on avatar of the upper left most pixel of icon
// $avatar_icon_y: y coordinate on avatar of the upper left most pixel of icon
$avatar_icon_x = '2';
$avatar_icon_y = '2';


A new function "write_avatar" was added to write the data onto the avatar image:

Code: [Select]

/*****************************************************************************/
/***** write_avatar: This function writes your values onto the sticker. *****/
/*****************************************************************************/
function write_avatar() {
  // let's start by defining some global variables that will be passed between
  // functions. This is kind of clunky!
  // NOTE: IF YOU ADD ADDITIONAL COLORS YOU'LL NEED TO ADD THEM HERE TOO!
  global $color1, $color2, $color3, $color4, $color5, $date, $time, $temp, $degree_units,
         $winds, $wind_units, $gust, $raintoday, $rain_units, $barom, $barom_units,
         $baromtrendwords, $dewpt, $humidity, $heatindex, $heat_index_threshold,
         $windchill, $wind_chill_threshold, $sticker_icon_x, $sticker_icon_y;

  // this section does the heat index and wind chill
  // it figures out what to show, wind chill, heatindex or nothing
  // depending upon your settings
  switch (TRUE){
  // if windchill is <= $wind_chill_threshold we'll output it
  case ($windchill <= $wind_chill_threshold):
       $feelslike = "WindCh: $windchill$degree_units";
       imagecenteredtext(50, 50, "$feelslike", 1, 7, $color3, 0);
  break;
  // if heat index >= $heat_index_threshold we'll output it
  case ($heatindex >= $heat_index_threshold):
       $feelslike = "HeatIdx: $heatindex$degree_units";
       imagecenteredtext(50, 50, "$feelslike", 1, 7, $color1, 0);
  break;
  } // end switch

  // this section controls what is written to the image, where it is written.
  // see the explanation above for details on what each parameter represents
  imagecenteredtext(65, 10, "Title Here", 2, 8, $color2, 0);
  imagecenteredtext(65, 20, "Curr Wx", 2, 8, $color2, 0);
  imagecenteredtext(50, 40, "$temp$degree_units", 5, 14, $color4, 0);
  imagecenteredtext(50, 60, "Rain: $raintoday$rain_units", 3, 9, $color3, 0);
  imagecenteredtext(50, 72, "$winds", 3, 9, $color4, 0);
  imagecenteredtext(50, 82, "$barom$barom_units", 1, 8, $color4, 0);
  imagecenteredtext(50, 96, "$date $time", 1, 7, $color2, 0);

} /***** end function write_avatar *****/


These are the only changes in this version.
Title: Weather Sticker PHP Script
Post by: NoQuitters on July 27, 2006, 03:00:18 PM
Works like a charm. Thanks Larry!! :D
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 27, 2006, 07:51:04 PM
Thanks Ken, I knew I had PHP running guess now I need to figure out the GD installation
Title: Weather Sticker PHP Script
Post by: ncpilot on July 28, 2006, 09:43:47 AM
Is there a way.........to....

I'm using free hosting right now, so no PHP on the server. I'd like to try to implement a weathersticker, but process it on my PC, then upload the image to my host--I'm looking at doing it on 15 min intervals, same as my current page update--not real time.

Before I try to convert the code to PERL (has anyone done this already?), is it possible to run PHP on my home computer (just generate the image, then upload to host)? (without a lot of pain?)

I'll most likely, eventually, get a real hosting service, but until then...
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 28, 2006, 09:54:20 AM
I am having the same problem with Earthlink. Although I am runing my own server I'm having an issue with the GD. So for the time being my sticker is generated with GraphWeather and the Weatherlink plugin, not perfect but it works.
Title: Weather Sticker PHP Script
Post by: saratogaWX on July 28, 2006, 10:35:20 AM
According to the PHP site ( www.php.net ), there is a command-line interface for PHP http://us2.php.net/manual/en/features.commandline.php

You can download the latest windows binary for 4.4.2 in .zip format, and give it a try :-)

To save the sticker to a graphic file, you just have to change the lines that say (in sticker.php V5.2):
Code: [Select]
// send header to browser
switch (TRUE) {
  case ($image_format == 'gif') :
       header('Content-type: image/gif');
       imagegif($img);
  break;
  case ($image_format == 'png') :
       header('Content-Type: image/png');
       imagepng($img);
  break;
  case ($image_format == 'jpeg') :
       header('Content-type: image/jpeg');
       imagejpeg($img);
  break;
} // end switch


to have a filename as the second argument of the imagennnn function like this:
Code: [Select]
// send header to browser
switch (TRUE) {
  case ($image_format == 'gif') :
       header('Content-type: image/gif');
       imagegif($img,"./current-sticker.gif");
  break;
  case ($image_format == 'png') :
       header('Content-Type: image/png');
       imagepng($img,"./current-sticker.png");
  break;
  case ($image_format == 'jpeg') :
       header('Content-type: image/jpeg');
       imagejpeg($img,"./current-sticker.jpg");
  break;
} // end switch


That will save a current-sticker.[gif|png|jpg] file in the sticker.php directory.  You could then upload it to your website using WD or VWS.

It's not recommended you do this mod on the website though.. there may be a file-lock problem if more than one browser is accessing the script at the same time (two or more scripts may try to write the same file).  But for a command line thing, it should work fine (no conflicts there).

BTW.. I'd used a similar technique to save the www.wrh.noaa.gov Icons stamped with a PoP for my get-nws-forecast-test.php (Tom's advforecast.php script adapted for Western Region NOAA).

Best regards,
Ken
Title: Weather Sticker PHP Script
Post by: Anole on July 28, 2006, 01:47:42 PM
It can be done on a local machine but it's not exactly an easy task. You need to:

1) install a webserver like Apache on the local machine
2) install PHP with GD support on the local machine.

The second part that makes it difficult is that the script doesn't generate static images on its own so you'd need to:

1) Come up with a script that runs the sticker script and create a file from the results that it outputs. I can help you here.
2) Have this happen on a scheduled basis, possibly using the windows task scheduler. I say possibly because I've never tried running a PHP script with the task scheduler but I can't think of any reason why it shouldn't work.

EDIT: Seems Ken and I were typing at the same time. His solution for generating the static image is much easier than what I would have done. You'll still have to schedule it though.

On the command line interface I _thought_ that you still had to install Apache (or another web server) to make that work. But I very easily could be wrong.
Title: Weather Sticker PHP Script
Post by: ncpilot on July 28, 2006, 03:36:53 PM
Ugh! As I might have suspected, it sounds like it would be easier to just get hosted (but not HOSED...) with a service that supports PHP... which will happen one day... as much as I'd just LOVE  :roll: to learn the hard way by  installing Apache and PHP on my home computer, I think I'll pass for now...

If I'm looking to just generate a relatively static avatar or banner, couldn't I use something like ImageSalsa? For now I don't so much care about generating a "real-time" image. There are probably a few other packages that would also work like ImageSalsa...

Actually, after looking again at the ImageSalsa website, and from hearing some support issue stories about Ambient, and the following:

"Veo Observer Network Camera -- Does not provide static image URL required to load images from network cameras.  I've asked the company for network communications protocol that could be incorporated into ImageSalsa, but have received no response."

This is completely untrue, and I emailed Ambient about it, and gave them the URL to get an image off the Veo cam (which I own), yet they still claim you can't get a static image off of it...

blah...
Title: Weather Sticker PHP Script
Post by: Anole on July 28, 2006, 03:45:38 PM
Yes, lots of folks use ImageSalsa for exactly that purpose.
Title: Weather Sticker PHP Script
Post by: ncpilot on July 28, 2006, 03:46:39 PM
Oops, I was in the middle of an edit when you replied my green lizard weather watcher anole...  :lol:
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 28, 2006, 04:17:14 PM
Thanks Guys.
I upgraded my PHP to 5.x with GD support and PHP work but I believe the problem might be my webserver [xitami].
So for now I guss I'll stick with GraphWeather for my sticker
Title: Weather Sticker PHP Script
Post by: SLOweather on July 28, 2006, 06:03:16 PM
Quote from: "Dragonfly"
Thanks Guys.
I upgraded my PHP to 5.x with GD support and PHP work but I believe the problem might be my webserver [xitami].
So for now I guss I'll stick with GraphWeather for my sticker


What problems are you having? Got all the permissions set right? That always messes me up.
Title: Weather Sticker PHP Script
Post by: Ravenstar on July 28, 2006, 09:05:56 PM
pilot I'd be gald to work with ya on a sticker sounds like you're stuck between a rock and a hard place. It's not like Ken's and Anole's (hope I'm not leaving anyone out and I'm not trying to steal anyone's thunder) but we could work on the design of it. All you'd have to do is get the data to me. I'm currently grabbing data from other sites for my custom graphs very similier to RSS feed. Works like a champ and very simple to do.

Up to you.
Title: Weather Sticker PHP Script
Post by: weatheroz on July 29, 2006, 08:52:45 AM
Quote from: "ncpilot"


If I'm looking to just generate a relatively static avatar or banner, couldn't I use something like ImageSalsa? For now I don't so much care about generating a "real-time" image. There are probably a few other packages that would also work like ImageSalsa...


Yep, that's what I use for my avatars and sig's here.
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 29, 2006, 03:36:35 PM
Thanks again, Had to dump PHP and did a clean install.

Does PHP work?
Yes, it does. PHP Version 5.1.4
To run the WXSTICKER script, you need GD enabled in PHP.
Current GD status:

GD support: yes
GD Version: bundled (2.0.28 compatible)
FreeType Support: yes
FreeType Linkage: with freetype
T1Lib Support: yes
GIF Read Support: yes
GIF Create Support: yes
JPG Support: yes
PNG Support: yes
WBMP Support: yes
XPM Support: no
XBM Support: yes
JIS-mapped Japanese Font Support: no
If you don't see "Yes, it does." above, then PHP is not enabled.

Now to building the sticker in PHP
Title: Version 5.3 now available
Post by: Anole on July 30, 2006, 09:47:29 AM
Version 5.3 is now available:

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

NOTE: There is no reason to download this version if you have version 5.2 up and working. No changes have been made to the actual script or configuration.

The script archive now includes a web page you can upload to your server to verify PHP and GD support on your server. This file is named:
PHP_verify.php

Simply upload it to your server and call it with a URL to verify if:


Additionally, I've put together a web page with more details on setting up and using the script:
http://scripts.anolecomputer.com/wxsticker/
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 30, 2006, 01:03:12 PM
anole,
I get a 404 error when trying to download from your link
Title: Weather Sticker PHP Script
Post by: Anole on July 30, 2006, 01:31:48 PM
Are you still getting it? I'm not seeing any problems here and I've seen several downloads since posting.
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 30, 2006, 02:32:10 PM
Yes I am.
Not Found
The requested URL /wxsticker/ was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


--------------------------------------------------------------------------------

Apache/1.3.33 Server at 66.78.27.230 Port 80

Reset the modem for another IP but still the same
Title: Weather Sticker PHP Script
Post by: Anole on July 30, 2006, 03:18:02 PM
If you go here:
http://scripts.anolecomputer.com/

and click on the Weather Sticker link what happens?
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 30, 2006, 03:25:03 PM
I get a directory tree

Private - looking for username and password
cgi-bin - forbidden
images - empty
Title: Weather Sticker PHP Script
Post by: Anole on July 30, 2006, 03:28:46 PM
cut and paste the tree for me.
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 30, 2006, 03:31:21 PM
Index of /
 Name                    Last modified       Size  Description
--------------------------------------------------------------------------------
 Parent Directory        28-Feb-2005 22:17      -  
 _private/               25-Feb-2005 20:35      -  
 cgi-bin/                25-Feb-2005 20:35      -  
 images/                 25-Feb-2005 20:35      -  
 postinfo.html           25-Feb-2005 20:35     2k  


--------------------------------------------------------------------------------

Apache/1.3.33 Server at 66.78.27.230 Port 80
Title: Weather Sticker PHP Script
Post by: Anole on July 30, 2006, 03:34:32 PM
:shock:  :?:

I don't know where you are but that's not my site.

Cut and paste the URL from your browser for me.
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 30, 2006, 03:38:10 PM
http://scripts.anolecomputer.com/
Title: Weather Sticker PHP Script
Post by: Anole on July 30, 2006, 03:42:37 PM
I have to be honest. I don't have a clue what's going on here. The site you are hitting isn't mine. There are no files named "postinfo.html" anywhere on my server that I can find. What browser are you using?

What do you get if you go to these sites:
http://weather.anolecomputer.com/
http://anolecomputer.com/
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 30, 2006, 03:46:04 PM
One is your Weather site the other is your Computer site.
Title: Weather Sticker PHP Script
Post by: Anole on July 30, 2006, 03:53:11 PM
I PMed you. Regardless, I'd like to figure out what is actually happening here.

Is anyone else experiencing this?
Is anyone besides me able to access the site?
Title: Weather Sticker PHP Script
Post by: Dragonfly on July 30, 2006, 04:16:59 PM
Problem solved.
Have access to your scipt with IE6 from another PC, so there is something else for me to piddle with since I have IE7 on my other PC
Title: Weather Sticker PHP Script
Post by: PSJohn on July 30, 2006, 04:26:44 PM
I'm not having any problems here!  A-OK
Title: Weather Sticker PHP Script
Post by: Anole on July 30, 2006, 04:37:42 PM
Quote from: "Dragonfly"
Problem solved.
Have access to your scipt with IE6 from another PC, so there is something else for me to piddle with since I have IE7 on my other PC


I don't think it's an IE7 specific problem/bug. I'm using it with no problems here. Might be something in the setup. The biggest difference between the pages you can access and the ones you can't is that the ones you can are .php and the ones you can't are .shtml.

I'm still digging in the logs.
Title: Weather Sticker PHP Script
Post by: aifan27 on July 30, 2006, 05:05:02 PM
Anole,

I know you're busy at the moment, but when you get a chance, could you please help me?

I am just having some problems setting this up.

I have specified in the config.txt file where my clientraw.txt file is located (since I am using WD) and in the sticker.php file where my config.txt file is located.

I would appreciate any help.

Thanks.
Title: Changing graphics sizes.
Post by: Anole on August 01, 2006, 06:51:46 PM
For anyone interested in changing the size of the graphics, such as making the 100 X 100 avatar into a 75 X 75 avatar, here's the simple two step process to do so. This works for all four graphics types:

1) Create a new background graphic in the size you want it to be and replace the default background graphic.

2) Move the data around on the background in config.txt to put it where you want it on the newly sized graphic.

That's all there is to it!
Title: Weather Sticker PHP Script
Post by: Dragonfly on August 01, 2006, 08:29:37 PM
Quote from: "anole"
Quote from: "Dragonfly"
Problem solved.
Have access to your scipt with IE6 from another PC, so there is something else for me to piddle with since I have IE7 on my other PC


I don't think it's an IE7 specific problem/bug. I'm using it with no problems here. Might be something in the setup. The biggest difference between the pages you can access and the ones you can't is that the ones you can are .php and the ones you can't are .shtml.

I'm still digging in the logs.


Your correct, it was my firewall.
Title: Weather Sticker PHP Script
Post by: W3DRM on August 09, 2006, 06:32:11 PM
I have a question regarding how do I set up my profile in a phpBB forum so I see my weather sticker in my signature line? The weather sticker php script is working fine but I just can't seem to get it to display in my signature area. I have tried using a variety of formats but none of them seem to work. Can anyone give me the syntax I need to use?

Any help would be greatly appreciated!!

If you look at my signature line below you will see it has the code in it but not the weather sticker image. I'm obviously doing something wrong...
Title: Weather Sticker PHP Script
Post by: SLOweather on August 09, 2006, 07:00:15 PM
Most php forums block PHP sigs and such. You need to create a .htaccess file for your Linux server, or add a line to the existing one, with an entry pointing ..../banner.gif to ...../banner.php and it will work. I can supply better details when I can check my server, or Saratoga Ken can help as well.

If you can run the script but not access or create the .htaccess file, then contact me. Interestingly enough, it can be repointed off-server. I do that for the Capitola CA weather site.
Title: Weather Sticker PHP Script
Post by: SLOweather on August 09, 2006, 07:09:12 PM
Try this:

http://franklin.tbo.net/mindenban.gif

(http://franklin.tbo.net/mindenban.gif)

In my .htaccess file the line looks like this:

Redirect /mindenban.gif http://wx.themcroberts.net/sticker.php?type=banner
Title: Weather Sticker PHP Script
Post by: Anole on August 09, 2006, 07:24:23 PM
Don't forget that it may actually be easier, and it's often preferred, to accomplish the redirect using your hosting control panel if possible. That way you don't run the risk of overwriting an exisiting .htaccess and breaking something that was working.
Title: Weather Sticker PHP Script
Post by: SLOweather on August 09, 2006, 07:33:38 PM
I usually forget that because my Linux box doesn't have a Control Panel. I'd never seen a server CP before until I started up a hosted site for our water company a few weeks ago.
Title: Weather Sticker PHP Script
Post by: W3DRM on August 09, 2006, 09:34:21 PM
Okay, here's what I've tried so far and without any luck relative to getting it to show in my signature line in this forum...

1) Tried creating a file named ".htaccess" and FTP'd it to my wx.themcroberts.net directory. I received a successful transmission message but I am unable to find any file anywhere by that name. I also checked to see if it was working and, it wasn't.

2) I then found my Control Panel as suggested by Anole, and it had a control for "Redirect URL". I entered the info in and it shows as being the following:

.....URL: http://wx.themcroberts.net/mindenban.gif
.....Redirect Target: http://wx.themcroberts.net/sticker.php?type=banner

Now, since neither of these seems to be working, comes the question - What next? Is there anyway for me to check to see if the redirect is really working?

I can click on the above URL and the Redirect Target links shown above and everything looks fine. I just can't get my signature line to work.

All of this is in the stratosphere for me so if I'm being a real dunce, it's because I'm into an area I am completely clueless about.

By the way, thanks for all the suggestions. I'm sure I am just missing something here...
Title: Weather Sticker PHP Script
Post by: saratogaWX on August 09, 2006, 09:42:54 PM
Don.. should be just a slight change in your sig code:

You have [img=http://wx.themcroberts.net/mindenban.gif][/img]

You should replace the first = with a ] and remove the ] before the closing img tag and it should work fine

Code: [Select]
[img]http://wx.themcroberts.net/mindenban.gif[/img]

like this

(http://wx.themcroberts.net/mindenban.gif)

Silly BBcode.. the = is only used in the URL= directive to highlight a phrase with a hotlink.  Images only use the surrounding open/closing tags.

Best regards,
Ken
Title: Weather Sticker PHP Script
Post by: W3DRM on August 09, 2006, 10:12:51 PM
Thanks for the tip. I was attempting to make the image a linked image and had a URL tag that surrounded the IMG tag. Guess it doesn't work in signatures.

Anyway, I just had an email from ICDSOFT support (my ISP) saying I couldn't the "?" character in a URL redirect statement as it hangs the system. Funny, since it did appear to be working.

Will keep trying to see what happens with the .htaccess file they indicate I can edit via their control panel.

Thanks again to all for the support. Hopefully, this issue will be resolved soon (tonight!)
Title: Weather Sticker PHP Script
Post by: saratogaWX on August 09, 2006, 10:39:55 PM
Don:

You can surround the img tags with a url= tag with the url to your site.

Code: [Select]
[url=someaddress][img]siggifaddress[/img][/url]

and... it looks like the redirect has become undone.. now showing a broken image for your sig :-(
Ken
Title: Weather Sticker PHP Script
Post by: W3DRM on August 09, 2006, 10:57:14 PM
Yahooooo, it works!!!

Yes, the redirect broke when support deleted the entries. I have now manually entered the info in the .htaccess file and all is now working fine.

Thanks again for all the help!
Title: Version 5.0 is now available
Post by: Anole on September 04, 2006, 08:18:10 PM
Version 5.0 is now available:

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



Please check out the info at:

 http://scripts.anolecomputer.com/wxsticker/

if you're interested in the transparency feature.
Title: Version 5.5 is now available
Post by: Anole on September 09, 2006, 06:55:35 AM
Version 5.5 is now available:

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

Bug Fix: corrected typo in config.txt where "$anti-alias" should have been "$anti_alias"

Thanks to Erik at http://MemphisWeather.Net for catching and reporting that one.
Title: Weather Sticker PHP Script
Post by: W3DRM on September 09, 2006, 06:40:53 PM
Anole,

I'm not very proficient at PHP coding but is there a problem with the positioning of the current condition icon for the banner sticker? My icon shows up at the top but about 2/3 of the way over to the right and not at the far left of the banner.

It currently reads as follows:

   // $banner_icon_x: x coordinate on banner of the upper left most pixel of icon
   // $banner_icon_y: y coordinate on banner of the upper left most pixel of icon
   $banner_icon_x = '300';
   $banner_icon_y = '2';

If it is going to be in the upper left pixel of the icon shouldn't it be the same as you have for the other sticker types i.e.:

   $banner_icon_x = '2';
   $banner_icon_y = '2';

NOTE: I changed the "x" setting to 2 and it positions correctly.
Title: Weather Sticker PHP Script
Post by: Anole on September 09, 2006, 10:58:30 PM
Yes, if you want it to appear in the banner at the upper left then you should set it at 2 and 2. I set it different by default intentionally as an illustration/example of how you can move it where you want to. I set it to 300 specifically because that's where I have it in my banner which you can see below.
Title: Weather Sticker PHP Script
Post by: PSJohn on September 15, 2006, 05:18:13 PM
This topic is all over the place so I thought i'd ask my question here...  Ever since installing version 5.5 I get artifacts in the background and the font quality is lousey.  I have antialias set to 'off'.  I'm using Arial.  The artifacts come and go in different locations on the background.

Could the transparency feature be the cause and is there a way to disable it?

Thanks for any help.

my sticker page: http://www.desertweather.com/stickers.php

-John
Title: Weather Sticker PHP Script
Post by: Anole on September 15, 2006, 08:21:11 PM
Yep, most likely the transparent color is causing the problem. Probably the easiest thing to do is to comment out the following line in config.txt:

 
Code: [Select]
$trans_color = imagecolortransparent($img,$trans_color);

like so:

Code: [Select]
//$trans_color = imagecolortransparent($img,$trans_color);

Let me know if that does the trick and I'll look at finding a way to "robustify" things a bit.
Title: Weather Sticker PHP Script
Post by: PSJohn on September 16, 2006, 12:53:08 PM
Thank you, that seemed to work!

bye the way, thanks for this great piece of code, and sharing it for others to use!

-John
Title: Re: Weather Sticker PHP Script
Post by: SolidState on August 28, 2007, 07:01:28 AM
I'm having trouble getting this script to work correctly.  My initial error is:

Fatal error: Call to undefined function: mb_convert_case() in /home/sandel/public_html/wxgraphic.php on line 290

If I comment out line 290 (or remove the call to mb_convert_case()), the script works to a degree.  I haven't seen anyone else post about this mb_convert_case issue so maybe I'm the first?

Also, when I can get the script to work, it only seems to populate my graphic with the default x,y coordinates.  In other words, whether the script calls the default, banner, banner_big or avatar subroutines, my text is always in the same area as default.  Here's an example:

http://216.73.124.252/wxgraphic.php?type=banner_big

What am I doing wrong?  This is another issue I haven't seen raised around here.

Todd
Title: Re: Weather Sticker PHP Script
Post by: Anole on August 28, 2007, 07:06:42 AM
On the text positioning, this is a bug in the script. It doesn't affect everyone and I don't have a handle on why some people are having this while others don't. Regardless, there is a fix but I have to get some time to implement and test it.

On the mb_convert_case(), I've not seen anyone have this problem. What version of PHP are you running? What program are you using for your data (VWS, WD, WL etc.)?
Title: Re: Weather Sticker PHP Script
Post by: SolidState on August 28, 2007, 07:25:29 AM
Anole,

I figured it was a bug, but I couldn't figure out where in the code this would happen.  The weird part is that the script generates the correct size graphic outline, but the text is out of place.

I am using VWS to create/upload the .htm file (VWS_graphictags.htm -- from original unmodified .htx) which seems to be populating the fields in the sticker okay.

As far as PHP, I'm running v. 4.4.6

You can hit the PHP_verify.php file on the server from my previous post for more detailed info.

It may be a few hours before I can reply...I'm in Cali and I'm turning in after a nice night of eclipse photographing.

Todd

P.S. the .php script you clicked in the previous link had the mb_convert_case function removed so the line just reads:
Code: [Select]
$forecast = trim($data[13]);
Title: Re: Weather Sticker PHP Script
Post by: saratogaWX on August 28, 2007, 03:35:39 PM
You could also replace
Code: [Select]
    $forecast = trim(mb_convert_case($data[13], MB_CASE_UPPER));
with the built-in function strtoupper with the same effect
Code: [Select]
    $forecast = trim(strtoupper($data[13]));

The uppercase for the condition is needed to use the lookup table for the icon ;-)

The mb_convert_case function is part of the Unicode support and is available in PHP from (PHP 4 >= 4.3.0, PHP 5).  The strtoupper function has been around since PHP3 and uses only 8-bit characters, so it is sensitive to locale settings.  It won't uppercase any characters such as umlaut-a (ä), so Anole's use of the more general mb_convert_case is a wise choice for general use.  Your PHP 4.4.6 should have the function.. like Anole says, it's strange that you don't have it.

I'd recommend you use the strtoupper function instead so your condition icon can be set correctly.

Best regards,
Ken
Title: Re: Weather Sticker PHP Script
Post by: SolidState on August 28, 2007, 05:09:50 PM
Ken,

Thanks for the suggestions.  I have made the code change.  I'm wondering why my PHP doesn't have the built-in fuction mb_convert_case, but I'll have to talk to my ISP about that one.

I was just inspecting my .htm file of my graphictags and noticed that the 14th variable ($data[13]), the one affected by the mb_convert_case function, is blank.  It is the only datapoint in the file without any info.  Maybe this is part of the cause of both errors?

I'm eager to get the sticker working, but without being able to generate a useable format (except for _default), I'm stuck.

Todd
Title: Re: Weather Sticker PHP Script
Post by: saratogaWX on August 28, 2007, 06:31:56 PM
Todd, you didn't say which weather software package you're using.
If it's VWS, then you need to pick a nearby METAR as your first entry to set the condition icon for your station.. that will be picked up by the ^climate_cconds1^ variable, and interpreted by the $vws_icon lookup to pick the right icon to use.

If you're using Weather-Display, then you should us the clientraw.txt file as the data source, and it will have the icon to use.

If you're using WeatherLink or another package, then the condition icon is not available, since the packages don't produce one :-(


BTW.. it would help if you updated your profile to include your weather software used and a link to the homepage of your weather website :-)

As for why mb_convert_case seems to be missing in your PHP, that's definitely a thing to take up with your ISP.

Best regards,
Ken
Title: Re: Weather Sticker PHP Script
Post by: SolidState on August 28, 2007, 07:15:46 PM
Ken,

Thanks again for the info.  I've updated my profile.

I'm using VWS 13.01 p00 and a Davis VantagePro2.
Title: Re: Weather Sticker PHP Script
Post by: carseman on August 29, 2007, 04:43:59 AM
Quote from: "SolidState"

Also, when I can get the script to work, it only seems to populate my graphic with the default x,y coordinates.  In other words, whether the script calls the default, banner, banner_big or avatar subroutines, my text is always in the same area as default.  Here's an example:

http://216.73.124.252/wxgraphic.php?type=banner_big

What am I doing wrong?  This is another issue I haven't seen raised around here.

Todd

Todd,
I was having the same problem.  We discussed it on the weather-watch forum here:
http://www.weather-watch.com/smf/index.php/topic,12227.300.html

Try insering the following code before the switch statements that start at approx line 508 in wxgraphic.php.
Code: [Select]
if ( isset($_REQUEST["type"] ))
   $type = $_REQUEST["type"];
else
   $type = "";

(With thanks to Kevin of tnetweather.com for help in tidying my fix of the code.)
Chris
Title: Re: Weather Sticker PHP Script
Post by: SolidState on August 29, 2007, 06:20:14 AM
Chris,

That seems to have done the trick! Thanks 1,000,000

Now, I've gotta pretty up the sticker and add it as a sig!

Todd