cloudy

Author Topic: Switching to PHP  (Read 12646 times)

0 Members and 1 Guest are viewing this topic.

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Switching to PHP
« on: March 26, 2005, 12:27:56 PM »
Ok, let me get this straight....

1) Start uploading clientraw
2) Extract clientraw data using PHP
3) Make .php pages
4) Add php tags where WD custom tags used to be
5) Check for correctness
6) Redirect .html to .php pages
7) Quit uploading anything from WD except graphics and clientraw

Kevin, that correct?

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline lehautfourneau

  • Posts: 816
  • Belgium
    • Weather in Oster Manhay Belgium
Re: Switching to PHP
« Reply #1 on: March 26, 2005, 01:52:22 PM »
Hi carterlake.
I'd like also to switch to PHP. My internet access provider does not support PHP on his server. Or I switch to another provider, or I install a small server at home.
I found those two Software's which might help:
EasyPhp (http://www.easyphp.org/) to configure automatically an Apache webserver, a Mysql database server and the Php support on your own computer.
I also found before yesterday this great software called PHP Designer 2005 (http://www.mpsoftware.dk/). This last soft supports Php5 and 4. The latest EasyPhp supports so far PHP4.  Those two soft are free for private use.
Cheers.
 :lol:
Clarence
----Very satisfied by WD and WDL------
WMR 968 + 3 extra temp/hum sensors + Windows 7 Pro

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,914
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Switching to PHP
« Reply #2 on: March 26, 2005, 01:57:22 PM »
Ok, let me get this straight....

1) Start uploading clientraw
2) Extract clientraw data using PHP
3) Make .php pages
4) Add php tags where WD custom tags used to be
5) Check for correctness
6) Redirect .html to .php pages
7) Quit uploading anything from WD except graphics and clientraw

Kevin, that correct?

Chances are you are already uploading clientraw for WDL.  The other clientraw files too.

Extracting the data from clientraw instead of using WD's tags really depends on what is easier for you.  The clientraw data is fairly clean, and raw.  You have to do the conversions if you want other than the raw data format that it uses.  If you use clientraw, then you are parsing the data and can format it anyway you like though.

As for using .php on your pages, that only has to be for any page you want to use php in it.  If your page does not have php in it, you don't need to have it end in .php

Redirection of page type could be done several different ways.  You could have dummy html versions that simply redirect to the php version, have an .htaccess file that uses mod_rewrite to force the use of .php etc.

Php might be a tad bit slower than a raw html file in that it needs to be parsed by the webserver when it is served.  So pages that are just plain basic might be best being what they are.

You can however end up with some more control in that you can then detect things like browser type and act on what you find within the page itself.

There are many tags that have no clientraw counter part. This could be fixed by using the fulldata.xml file that WD creates to get the some of them, or creating a simple custom text file that just has the tags you need from it to parse into your pages.

I'm currently working on a custom text file that outputs most  WD tags with a index number, the value and a brief description so that I can use any tag from it without the overhead of the XML.  It looks kinda like:

Code: [Select]
# Weather RAW date by Tags
#
#######################################################################################
# General or NON Weather Specific
#######################################################################################
%time%:::Time
%date%:::Date
%sunrise%:::Sunrise
%sunset%:::Sunset
%dayornight%:::Day or Night
%moonrise%:::Moon Rise
%moonset%:::Moon Set
%moonphase%:::Moon Phase
%marchequinox%:::March equinox date
%junesolstice%:::June solstice date
%sepequinox%:::September equinox date
%decsolstice%:::December solstice date
%moonperihel%:::Next Moon perihel date
%moonperihel%:::Next Moon perihel date
%moonperigee%:::Next moon perigee date
%moonapogee:::Next Moon Apogee Date
%newmoon%:::Date/time of the next/last new moon
%nextnewmoon%:::Date/time of the next new moon for next month
%firstquarter%:::Date/time of the next/last first quarter moon
%lastquarter%:::Date/time of the next/last last quarter moon
%fullmoon%:::Date/time of the next/last full moon

But will have an index number put in front of each tag type so that I can quickly find it by id number and use it in any page.   Then any tag I can't get from the clientraw files, I can get from it instead.  You can also find tags you had not used before in it.

As for graphics, it might be you start making your own charts using something like JPgraph for a uniform look, and or, replace existing graphics with non-graphics like the Extreme data graphics.

you would in the end have a lot less sent to the web page, possibly a more uniform looking page and a lot more control over how and where things are formatted.

but yes... you pretty much got it right.

Like most languages, you can start off with baby steps doing real basic stuff until you get better at it and then start building some really sophisticated pages.

I had planned on doing some coding this weekend for a change, but I now have to rebuild my weather machine since its hard drive blew up.

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

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Switching to PHP
« Reply #3 on: March 26, 2005, 02:21:10 PM »
Chances are you are already uploading clientraw for WDL.  The other clientraw files too.

Extracting the data from clientraw instead of using WD's tags really depends on what is easier for you.  The clientraw data is fairly clean, and raw.  You have to do the conversions if you want other than the raw data format that it uses.  If you use clientraw, then you are parsing the data and can format it anyway you like though.

As for using .php on your pages, that only has to be for any page you want to use php in it.  If your page does not have php in it, you don't need to have it end in .php

Redirection of page type could be done several different ways.  You could have dummy html versions that simply redirect to the php version, have an .htaccess file that uses mod_rewrite to force the use of .php etc.

Php might be a tad bit slower than a raw html file in that it needs to be parsed by the webserver when it is served.  So pages that are just plain basic might be best being what they are.

You can however end up with some more control in that you can then detect things like browser type and act on what you find within the page itself.

There are many tags that have no clientraw counter part. This could be fixed by using the fulldata.xml file that WD creates to get the some of them, or creating a simple custom text file that just has the tags you need from it to parse into your pages.

I'm currently working on a custom text file that outputs most  WD tags with a index number, the value and a brief description so that I can use any tag from it without the overhead of the XML.  It looks kinda like:

But will have an index number put in front of each tag type so that I can quickly find it by id number and use it in any page.   Then any tag I can't get from the clientraw files, I can get from it instead.  You can also find tags you had not used before in it.

As for graphics, it might be you start making your own charts using something like JPgraph for a uniform look, and or, replace existing graphics with non-graphics like the Extreme data graphics.

you would in the end have a lot less sent to the web page, possibly a more uniform looking page and a lot more control over how and where things are formatted.

but yes... you pretty much got it right.

Like most languages, you can start off with baby steps doing real basic stuff until you get better at it and then start building some really sophisticated pages.

I had planned on doing some coding this weekend for a change, but I now have to rebuild my weather machine since its hard drive blew up.

lehautfourneau... thanks for the links... when I get some free time (this weekend is my daughter's 3 b-day and we're having family Easter dinner tomorrow)... I'll take a look at'em.

Kevin... I was also thinking the clientraw was a bit short... on data.... I'll look at using the fulldata.xml and/or my own custom tags page.

Eew! And custom graphics. I have to admit, I'm a webpage control freak. I want more more more.

I will no doubt be bombarding you with questions at some point... baby steps

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,914
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Switching to PHP
« Reply #4 on: March 26, 2005, 06:02:42 PM »
Dont forget that there are also clientrawextra.txt and clientrawdaily.txt.

At least for the VP.

WDL uses all three to do its magic and there is a lot of info in all three.

The tool I have at:
http://www.tnet.com/weather/raw/index.php

Shows all three datafile contents and their locations.

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

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Switching to PHP
« Reply #5 on: March 26, 2005, 10:54:13 PM »
Dont forget that there are also clientrawextra.txt and clientrawdaily.txt.

At least for the VP.

WDL uses all three to do its magic and there is a lot of info in all three.

The tool I have at:
http://www.tnet.com/weather/raw/index.php

Shows all three datafile contents and their locations.

I see that now... I have to leave it running for a day....

So how do I parse and use it in web pages?

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Switching to PHP
« Reply #6 on: March 27, 2005, 01:36:31 PM »
While I'm asking for info...

Do you have code to parse XML? and/or to parse that custom tags page?

And...

How do I alter my htaccess file so they always go to the .php files?

Thanks!
« Last Edit: March 27, 2005, 01:39:42 PM by carterlake »

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Switching to PHP
« Reply #7 on: March 27, 2005, 02:02:31 PM »
How do I alter my htaccess file so they always go to the .php files?

Ok, figured this part out.... I could either associate all .html with all .php or I could use redirects

redirect /www/index.html /www/index.php

Ew... custom 404 pages... (I haven't played with a .htaccess in a long time.
« Last Edit: March 27, 2005, 02:04:49 PM by carterlake »

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline administrator

  • Administrator
  • Posts: 10,528
  • Get answers to your questions - use Forum SEARCH!
  • Blackpool, UK
    • Weather-Watch.com
Re: Switching to PHP
« Reply #8 on: March 27, 2005, 02:18:42 PM »
Do you have code to parse XML?

PHP can do that for itself... http://uk2.php.net/xml
Chris
Weather Forum Administrator

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Switching to PHP
« Reply #9 on: March 27, 2005, 11:05:13 PM »
Well... at least I got the 404 page working...

http://www.carterlake.org/error.html  8)



(No, I didn't make the shockwave... don't know who did... it's unsigned.)
« Last Edit: March 27, 2005, 11:07:42 PM by carterlake »

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,914
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Switching to PHP
« Reply #10 on: March 27, 2005, 11:09:21 PM »
The dot was very good.

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

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Switching to PHP
« Reply #11 on: March 27, 2005, 11:12:17 PM »
The dot was very good.

Ah, there you are!

I've been waiting all weekend... how do I parse the clientraw and custom tags page? I kind of think I know how you did it...

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline aifan27

  • Tim
  • Posts: 2,862
  • Pennsylvania
    • Newtown Weather
Re: Switching to PHP
« Reply #12 on: March 27, 2005, 11:21:15 PM »
LOL...Carterlake, I was just watching your Live Webcame and I am guessing that members of the family have just arrived?  (Especially the kids...LOL.)

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Switching to PHP
« Reply #13 on: March 27, 2005, 11:28:23 PM »
LOL...Carterlake, I was just watching your Live Webcame and I am guessing that members of the family have just arrived?  (Especially the kids...LOL.)

LOL... that's my neighbor's yard... mine has big pine trees in it (to the right)

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline aifan27

  • Tim
  • Posts: 2,862
  • Pennsylvania
    • Newtown Weather
Re: Switching to PHP
« Reply #14 on: March 27, 2005, 11:30:41 PM »
Haha LOL...the whole time I thought it was in your yard, and I was like "Oh look, theyre playing in the yard!".  LOL.  One question: Why do you have the camera in your neighbors yard?