cloudy

Author Topic: Html, Java or php for dated file retrieval - Form Select?  (Read 4975 times)

0 Members and 1 Guest are viewing this topic.

Offline TokKiwi

  • Techno Dad
  • Posts: 4,297
  • Mech Engineer and Hobbyist
  • Tokoroa, Sth Waikato, New Zealand
    • Tokoroa North Weather
Html, Java or php for dated file retrieval - Form Select?
« on: November 11, 2007, 07:43:38 AM »
I want to be able to retrieve the day dated gifs for the graphs generated by WD and held on my website.

eg 20070810.gif  for the 10th of August graph.

And then there are the daily webcam.gif's using the same date principle.

I have been looking at the straight selection method as applied in WD for the Month files of html averages and extremes Viz "July2007.htm" and also a catenated method used by WU using asp on theitr website receiving Form data by three selections - one for Year, one for Month and one for Day and together they combine to transfer the three Names "Year", "Month" and "Day" back to their website and it selects data to be displayed related exactly to that date.  The file below shows the code they have used, and below that, is the code with javascript used by WD for the WD generated website.

Can someone pleae help me sort this code out, it is probably best done by javascript I gather, and the suffux obviouslyhas to be added to the selection as well or be a hidden preselected object that is a fourth element.

I hope others find a use similar to mine for the gathering heap of files on our websites...

Thanks in anticiaption...

Graeme
Dad's have hobbies because they are children's rugby, football and Committee Fathers!!

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #1 on: November 11, 2007, 09:49:22 AM »
Way too much time on my hands tonight... should be in bed...

The attached is a PHP combined script that acts as a form and as the result.

It generates the form based on values set in the script for $FIRST_YEAR $LAST_YEAR, $STATION_NAME, creates the form with the current date selected.

After input, it checks the input to see if it is valid (could do more checking)... too many days in month selected, correct date range...   if it passes mustard... it then generates the filename to used based on the obtained date in ISO date format and preconfigured $FILEPATH and $FILEEXT end $MWVEXT for video and displays it.

All in PHP..

Play with Live Version:
http://www.tnetweather.com/test/getdate.php

View Source:
http://www.tnetweather.com/test/getdate.txt
Just a symbolic link to the same file using txt as the filename.

Note that it uses my servers idea of day and time... which is US/Arizona (-0700) so the day might be off by one depending where in the world you play with it from.

The form should have labels etc... but I skipped on doing that.  Easy to add though.
« Last Edit: November 11, 2007, 10:05:19 AM by krelvinaz (TNETWeather) »

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

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #2 on: November 11, 2007, 10:00:40 AM »
Hi Kevin

Wow that is excactly what i have been looking for.

But - in the result page I would like to present the datestamped .gif (graph ex. 20071110.gif) and the datestamped .wmv (alldayvideo ex. 20071110dayvideo.wmv) file at the same time.

Do you think it would be possible to make?

Best regards,

Henrik

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #3 on: November 11, 2007, 10:04:31 AM »
It already does that.

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

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #4 on: November 11, 2007, 10:07:19 AM »
Hi Kevin

Cool - you are really fast.

Thanks - now I have something to play with today.

Best regards,

Henrik

Offline TokKiwi

  • Techno Dad
  • Posts: 4,297
  • Mech Engineer and Hobbyist
  • Tokoroa, Sth Waikato, New Zealand
    • Tokoroa North Weather
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #5 on: November 11, 2007, 10:11:27 AM »
Kevin - hmmm, 4:00 on Sunday morning - sorry about the challenge!! But thanks for the reply. ;)

I guess I would have to have that on a seperate php file and use a link to it from my html file, and Henrik - that's not a bad idea too...  I have dailywebcam.gif and dailywebcam2.gif files instead of the alldayvideos.  :roll: The thumbnail images of first half and second half of the day.

TokKiwi
Dad's have hobbies because they are children's rugby, football and Committee Fathers!!

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #6 on: November 11, 2007, 10:16:57 AM »
Actually, I've been updating websites all day today (actually yesterday) to my new WebGen scripts to get them up to date, so I've been doing a ton of editing.... which was really boring...

Was kinda fun to program the form to do the auto sensing of the date etc...

It shouldn't take much to strip out the parts you don't need and just include it into another script.  Generating the output file is simple text.

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

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #7 on: November 11, 2007, 10:17:36 AM »
Hi

I just disvored a little problem. The dateformat of the gifs are yyyymmdd.gif (ie. 20071103.gif)

and the dateformat of the .wmv´s are yyyymmd.wmv (ie. 2007113dayvideo.wmv)

Best regards,

Henrik

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #8 on: November 11, 2007, 10:25:14 AM »

You just change the string to be whatever you need it to be.

The lines:

    $filename = $FILEPATH . sprintf('%04d%02d%02d', $foundyear,
        $foundmonth, $foundday) . $FILEEXT;
       
    $filename2 = $FILEPATH . sprintf('%04d%02d%02d', $foundyear,
        $foundmonth, $foundday) . $MWVEXT;


Are what do it.  Just take off the 0 in the last entry to make it %2d and you end up with a non-padding day.

Not sure why WD doesn't use padded dates though. 

The logfiles that WD creates are a royal pain because they are DMYYYY ... which makes it very hard to find a particular month in a particular year and they are not sortable.

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

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,336
  • Mauston, WI, USA
    • Juneau County Weather
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #9 on: November 11, 2007, 10:35:47 AM »
The logfiles that WD creates are a royal pain because they are DMYYYY ... which makes it very hard to find a particular month in a particular year and they are not sortable.

A little script to check for these and rename them?    hmmmmm

 Home of NSLog NexStorm Lightning Data Manager

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #10 on: November 11, 2007, 10:46:26 AM »
That unfortunately is a recipe for disaster... as WD uses the logfiles it creates and if I renamed them they would then be broken.

I already rename files that I move over to the Unix side since once they are there it doesn't matter any longer but the other day trying to sort out which logfile was the one I needed to try to correct a graph got so frustrating that I just quit trying.

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

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #11 on: November 11, 2007, 12:09:18 PM »
You just change the string to be whatever you need it to be.

The lines:

    $filename = $FILEPATH . sprintf('%04d%02d%02d', $foundyear,
        $foundmonth, $foundday) . $FILEEXT;
       
    $filename2 = $FILEPATH . sprintf('%04d%02d%02d', $foundyear,
        $foundmonth, $foundday) . $MWVEXT;


Are what do it.  Just take off the 0 in the last entry to make it %2d and you end up with a non-padding day.

Not sure why WD doesn't use padded dates though. 

The logfiles that WD creates are a royal pain because they are DMYYYY ... which makes it very hard to find a particular month in a particular year and they are not sortable.


Hi Kevin

Thanks - i have it almost working - but there seems to be a "space" between month and day in this line:

    $filename2 = $FILEPATH . sprintf('%04d%02d%2d', $foundyear,
        $foundmonth, $foundday) . $MWVEXT;

See www.buskelundtoften.dk/vejret/test.php and choose 8. november 2007

Best regards,

Henrik
« Last Edit: November 11, 2007, 01:43:16 PM by jwwd »

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #12 on: November 11, 2007, 05:51:39 PM »
Sorry....

That should be

$filename2 = $FILEPATH . sprintf('%04d%02d%d', $foundyear,
        $foundmonth, $foundday) . $MWVEXT;


BTW... sprintf is a very common function used in Basic, Perl and PHP...  Google for the function would give you hundreds of links on it and its formats.

Google Search: PHP sprintf

To learn, you sometimes have to experiment a bit.

« Last Edit: November 11, 2007, 05:58:04 PM by TNETWeather (krelvinaz) »

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

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #13 on: November 11, 2007, 07:02:04 PM »
Hi Kevin

I have it working now - thank you very much for all your help.

Have a nice day.

Best regards,

Henrik

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: Html, Java or php for dated file retrieval - Form Select?
« Reply #14 on: November 12, 2007, 02:17:31 PM »
Hi Kevin

Im struggeling with your script.

I want to implement it on my site. But I cant figure out how to include the ajax-scripts, header (top.php), menu (menu.php) etc.

Can you guide me in the right direction?

I have tried this under the // Function outputs Start of HTML:

Code: [Select]
<?php ...


echo 
'<?php include("vejrdata/testtags.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="dk" lang="dk">
  <head>
    <meta http-equiv="content-type" content="application/xhtml+xml; charset=ISO-8859-1" />
    <meta name="author" content="Vejret på Buskelundtoften" />
    <meta name="generator" content="author" />
    <link rel="stylesheet" type="text/css" href="http://www.buskelundtoften.dk/vejret/css/sinorca-screen.css" media="screen" title="Sinorca (screen)" />
    <link rel="stylesheet" type="text/css" href="http://www.buskelundtoften.dk/vejret/css/sinorca-print.css" media="print" />
<script type="text/javascript" src="http://www.buskelundtoften.dk/vejret/ajax-images/ajaxWDwx.js"></script>
    <script type="text/javascript" src="http://www.buskelundtoften.dk/vejret/ajax-images/ajaxgizmo.js"></script>
    <script type="text/javascript">useKnots = false;ajax_set_units('M');</script>
    <title> Vejret på Buskelundtoften - test</title>
  </head>
  <body>
<script type="text/javascript" src="http://www.buskelundtoften.dk/stat/track.php?mode=js"></script><noscript><img src="http://wwww.buskelundtoften.dk/stat/track_noscript.php" border="0" alt="" width="1" height="1" /></noscript>
<?php
$TITLE 
"Page title to display";
$CURPAGE basename(  $_SERVER['PHP_SELF'] ); 
include(
"top.php");
?>

<?php
$doInclude 
true;
include(
"menu.php"); ?>
'; }// Function output End of HTML
function html_end () {

    echo '</body></html>' . "\n";
}

Best regards,

Henrik
« Last Edit: November 12, 2007, 04:08:38 PM by TNETWeather (krelvinaz) »