cloudy

Author Topic: Weather Sticker PHP script v 3.0  (Read 107149 times)

0 Members and 1 Guest are viewing this topic.

Offline Stuntman

  • Posts: 731
  • Hemet, California USA
    • Hemet Weather
Re: Weather Sticker PHP script v 3.0
« Reply #30 on: November 15, 2005, 09:14:19 PM »
OK, so I'm being a bit dense!  :?

I can't figure out how to incorporate an image into my sig. I have the PHP weather sticker working, but can't work out how to display it!

Any instructions would be much appreciated.

Thanks

I first went to the my 'Profile" then selected "Forum Profile Information" and added the link to the bottom of my signature like this...
img]http://wx.hemetweather.com/weather/wxsticker/sticker.php?type=banner[/img
But add an opening and closing bracket to the above line..

Hope that helps!
« Last Edit: November 15, 2005, 09:23:24 PM by Stuntman »

Offline SandhurstWX

  • Ian
  • Posts: 376
  • Another satisfied WD user!
  • Royal County of Berkshire, UK
    • Sandhurst Weather
Re: Weather Sticker PHP script v 3.0
« Reply #31 on: November 15, 2005, 09:27:40 PM »
Thanks Stuntman, got it now! I was missing the img & /img bits.

Ian

Offline anole

  • Posts: 139
  • St. James City, FL USA
    • St. James City Weather
Re: Weather Sticker PHP script v 3.0
« Reply #32 on: November 17, 2005, 08:51:40 PM »
One thing I thought about today regarding the newly broken out config.txt file. If you leave the file in the same directory as the sticker.php script your configuration will be viewable to anyone who wants to look at it on your site. The only thing in the config.txt that might be of concern to folks is the path to your data file. If you are using an absolute path you are advertising your directory structure to the world. I don't really see this as a big issue since the structure on most servers is fairly standard and easily guessed at anyway. And a lot of servers will present the full path in script error messages as well.

Regardless, if you are uncomfortable having your config.txt file available for viewing you can solve that problem by moving it outside of your document root. Here's how to do that:

Depending upon how your server is set up, your document root will usually be something like: /home/username/public_html or /home/username/httpdocs

If you are unsure of what your document root is you should contact your hosting servicej or ISP to find out.

1) Uplooad the config.txt file to a directory that is outside of the document root. For example, if your document root is

/home/username/public_html

put the config.txt file anywhere but the public_html directory _or_ any of it's subdirectories. You might create a subdirectory like /home/username/scripts and upload the config.txt to that location as an example.

NOTE: Nearly all hosting companies will allow you to create directories in your user directory outside of your document root but there is no guarantee that this will be the case with yours. Likewise if you use your ISP provided web pages it's likely that you will _not_ be able to create such directory. If you aren't sure contact your hosting service/ISP.

2) change the line in the sticker.php file that reads:

require "./config.txt";

so that it points to the new location for config.txt. If you uploaded your config.txt to /home/username/scripts you would set it to:

require "/home/username/scripts/config.txt";

3) upload the modified version of the sticker.php script to your server inside your document root just as you did before.


If you are unable to create a directory outside of your document root and you want to keep your config.txt from being viewable there is one other option you can use. Eliminate the config.txt file by placing the configuration back in the sticker.php file. To do this, replace the line in sticker.php that reads:

require "./config.txt";

with the contents of your config.txt file. Copy everything between the <? and ?> leaving those two lines out. Paste it over the require line.

St. James City, FL Weather
http://weather.anolecomputer.com


Offline broadstairs

  • Stuart
  • Posts: 6,248
  • Broadstairs, Kent, UK
    • Broadstairs
Re: Weather Sticker PHP script v 3.0
« Reply #33 on: November 17, 2005, 09:17:30 PM »
I have renamed mine to config.php and now when you try to view it you get a blank page back!!!! I think this is a better solution and should work for everyone...

Stuart

Offline 41South

  • Colin
  • Posts: 1,030
  • Strathmore, Wellington, NZ
    • 41south.net.nz
Re: Weather Sticker PHP script v 3.0
« Reply #34 on: November 17, 2005, 10:04:01 PM »
Hmmmm - trying to set this up but I get ;

Quote
<br />
<b>Warning</b>:  file_get_contents(./) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: Permission denied in <b>C:\apachefriends\xampp\htdocs\mambo\weather\wxsticker\sticker.php</b> on line <b>49</b><br />
#-o

The directory permissions are 755 - do they need to be 775? I have put a copy of the clientraw.txt file in the wxsticker directory while I get things going,  so is the path ./ correct for that?

The url is www.41south.net.nz/weather/wxsticker/sticker.php I have left the config file viewable too.

Any help - as always - much appreciated.

Cheers, Colin.
Dallas 1-wire v3.0, Lightning, Humidity, Rain, Solar, Pressure, Temp sensors. Member of the Lightning Radar project.

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Weather Sticker PHP script v 3.0
« Reply #35 on: November 17, 2005, 10:22:12 PM »
When I started making dynamic images, I used a similar approach.  However I quickly found that many place you want to use the image in won't accept .php as an image.  (phpBB forums for example).

That is when I switched to using php cli (command line interface) and exporting the result to an actual png file instead.  this is run by cron and the source, config etc.. can be anywhere on the server.  You just place the images in the web accessible area.

And if you use a move along with the create, you can basically eliminate the possiblity of someone downloading an image that is being written to.

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline broadstairs

  • Stuart
  • Posts: 6,248
  • Broadstairs, Kent, UK
    • Broadstairs
Re: Weather Sticker PHP script v 3.0
« Reply #36 on: November 17, 2005, 10:29:21 PM »
41south my permissions are 604 on my web host and 666 on my own apache server on Linux, both of which work just fine.

krelvinaz you are OK doing that if you have your own server, but if you are just using hosting as most people do then a cron job is likely to be out of the question

Stuart

Offline anole

  • Posts: 139
  • St. James City, FL USA
    • St. James City Weather
Re: Weather Sticker PHP script v 3.0
« Reply #37 on: November 17, 2005, 10:41:51 PM »
I have renamed mine to config.php and now when you try to view it you get a blank page back!!!! I think this is a better solution and should work for everyone...

Stuart

Duh!! I didn't even think about that approach. Certainly a simpler solution.
« Last Edit: November 17, 2005, 10:51:25 PM by anole »
St. James City, FL Weather
http://weather.anolecomputer.com


Offline anole

  • Posts: 139
  • St. James City, FL USA
    • St. James City Weather
Re: Weather Sticker PHP script v 3.0
« Reply #38 on: November 17, 2005, 10:44:35 PM »
When I started making dynamic images, I used a similar approach.  However I quickly found that many place you want to use the image in won't accept .php as an image.  (phpBB forums for example).

That is when I switched to using php cli (command line interface) and exporting the result to an actual png file instead.  this is run by cron and the source, config etc.. can be anywhere on the server.  You just place the images in the web accessible area.

And if you use a move along with the create, you can basically eliminate the possiblity of someone downloading an image that is being written to.

Only problem with that is that lots of folks don't have access/permission to run cron jobs.
Regardless, a static image generation version via cron is one of the things I already have on my to do list.
St. James City, FL Weather
http://weather.anolecomputer.com


Offline anole

  • Posts: 139
  • St. James City, FL USA
    • St. James City Weather
Re: Weather Sticker PHP script v 3.0
« Reply #39 on: November 17, 2005, 10:57:55 PM »
Hmmmm - trying to set this up but I get ;
 #-o

The directory permissions are 755 - do they need to be 775? I have put a copy of the clientraw.txt file in the wxsticker directory while I get things going,  so is the path ./ correct for that?

The url is www.41south.net.nz/weather/wxsticker/sticker.php I have left the config file viewable too.

Any help - as always - much appreciated.



You haven't told the script what the data file is:
$data_file_path  = './';

this should look something like:

$data_file_path  = './clientraw.txt'; (if the clientraw.txt is in the same directory as the script)
or
$data_file_path  = '/home/41south/public_html/weather/wdl/clientraw.txt';



Where is your data file and what is it called?
St. James City, FL Weather
http://weather.anolecomputer.com


Offline 41South

  • Colin
  • Posts: 1,030
  • Strathmore, Wellington, NZ
    • 41south.net.nz
Re: Weather Sticker PHP script v 3.0
« Reply #40 on: November 17, 2005, 11:48:39 PM »
 #-o I did wonder about that - should have tried it myself. Works now. Thanks :thumbright:


Cheers, Colin.
Dallas 1-wire v3.0, Lightning, Humidity, Rain, Solar, Pressure, Temp sensors. Member of the Lightning Radar project.

Offline anole

  • Posts: 139
  • St. James City, FL USA
    • St. James City Weather
Re: Weather Sticker PHP script v 3.0
« Reply #41 on: November 18, 2005, 12:21:52 AM »
Groovy!  :geek:

I got something right today!
St. James City, FL Weather
http://weather.anolecomputer.com


Offline weatherbee

  • Posts: 577
  • Sherman, Ct.
    • http://www.shermanctweather.com
Re: Weather Sticker PHP script v 3.0
« Reply #42 on: November 18, 2005, 01:46:20 AM »
I just can't find what I am doing wrong with this.  My site is at http://www.shermanctweather.com/sticker.php and the congig file is at http://www.shermanctweather.com/config.txt
Any help would be apprciated.
Sony Pentium 4, 1.6 GHZ,512 MB Ram, Windows XP Pro, SP2

Offline 41South

  • Colin
  • Posts: 1,030
  • Strathmore, Wellington, NZ
    • 41south.net.nz
Re: Weather Sticker PHP script v 3.0
« Reply #43 on: November 18, 2005, 01:48:44 AM »
Quote
$data_file_path  = 'http://www.shermanctweather.com/clientraw.txt'

This needs to be a path - not a url.   :wink:

In my case because I created a subdir below where my clientraw.txt file lives I entered $data_file_path  = '../clientraw.txt'

If the clientraw.txt is in the same dir as the config.txt and sticker files then all you need is $data_file_path  = './clientraw.txt'
« Last Edit: November 18, 2005, 01:55:04 AM by 41South »
Cheers, Colin.
Dallas 1-wire v3.0, Lightning, Humidity, Rain, Solar, Pressure, Temp sensors. Member of the Lightning Radar project.

Offline weatherbee

  • Posts: 577
  • Sherman, Ct.
    • http://www.shermanctweather.com
Re: Weather Sticker PHP script v 3.0
« Reply #44 on: November 18, 2005, 01:54:21 AM »
I changed it to $data_file_path  = './clientraw.txt';  but it still doesn't work.
Sony Pentium 4, 1.6 GHZ,512 MB Ram, Windows XP Pro, SP2

 

cumulus