Author Topic: Virtual Weather Station WeatherFlash  (Read 8095 times)

0 Members and 1 Guest are viewing this topic.

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
Virtual Weather Station WeatherFlash
« on: September 09, 2008, 01:21:33 PM »
I would like to move my server from PHP 4 to PHP 5.  I know from reading the other forum that there were some changes that needed to be made in the scripts.  Does anyone know what those were?  Help please.
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Virtual Weather Station WeatherFlash
« Reply #1 on: September 09, 2008, 02:09:35 PM »
Yes, the scripts need to have the $HTTP_POST_VARS replaced with $_POST and $HTTP_GET_VARS replaced with $_GET.

So Config.php would read
Code: [Select]
<?php
header
("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 
header("Expires: Mon,26 JUL 1997 05:00:00 GMT");

$fp=fopen("../Config/".$_POST["Page"], "w"); 
while (list(
$lvar$lvalue) = each($_POST)){
   if ((
$lvar !="End")AND($lvar !="Page")){
      
fwrite($fp$lvar."=".$lvalue."&");
   }
}
fwrite($fp,"End=true");

fclose($fp);
?>

SetUnits.php would read
Code: [Select]
<?php
header
("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 
header("Expires: Mon,26 JUL 1997 05:00:00 GMT");

$fp=fopen("../Config/Units.txt""w");
while (list(
$lvar$lvalue) = each($_POST)){
   if (
$lvar !="End"){
      
fwrite($fp$lvar."=".$lvalue."&");
   }
}
fwrite($fp,"End=true");

fclose($fp);

?>

SetUser.php would read
Code: [Select]
<?php
header
("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 
header("Expires: Mon,26 JUL 1997 05:00:00 GMT");
 
$fp=fopen("../Config/User.txt""w");
fwrite($fp"Token=".$_POST["Token"]);
fclose($fp);
?>

and the submit.php (which should be renamed on your site to a unique name) would read
Code: [Select]
<?php
header
("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 
header("Expires: Mon,26 JUL 1997 05:00:00 GMT");

if (
$_GET["I"]=="DEMO" ){
   if (
$_GET["F"] != ""){ 
      
$fp=fopen("../Data/wflash.txt""w");
      
$TempStr=$_GET["F"];
      
$TempStr2=str_replace(" ","+",$TempStr);
      
fwrite($fp"F=".$TempStr2);
   }else{
      
$fp=fopen("../Data/wflash2.txt""w");
      
$TempStr=$_GET["S"];
      
$TempStr2=str_replace(" ","+",$TempStr);   
      
fwrite($fp"S=".$TempStr2);
   }
   
fclose($fp);
}
?>

Hope this helps...
Best regards,
Ken
Edit: replaced one $HTTP_POST_VARS with $_POST .. thanks Jay for spotting that
« Last Edit: September 09, 2008, 02:39:54 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
Re: Virtual Weather Station WeatherFlash
« Reply #2 on: September 09, 2008, 02:21:57 PM »
Ken,

Thanks,

I did notice in the Config.php there was one instance of $HTTP_POST_VARS left in the script you gave.  Does that stay?

Will these scripts run with PHP 4?
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Virtual Weather Station WeatherFlash
« Reply #3 on: September 09, 2008, 02:40:30 PM »
Oops... no it's shouldn't stay.  Sorry I missed it. (I've corrected the post above)

Yes, these scripts will run in PHP4 also. 

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
Re: Virtual Weather Station WeatherFlash
« Reply #4 on: September 09, 2008, 03:45:57 PM »
Ken,

Are you sure these will work in PHP 4?  I installed them on my server and the data would not update.  The pages looked fine, just no new data.  I have since reverted back to the old scripts.
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Virtual Weather Station WeatherFlash
« Reply #5 on: September 10, 2008, 12:58:36 AM »
That's strange.. the PHP manual says
Quote
HTTP GET variables: $_GET
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_GET_VARS.

An associative array of variables passed to the current script via the HTTP GET method. Automatically global in any scope.

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_GET; to access it within functions or methods, as you do with $HTTP_GET_VARS.

$HTTP_GET_VARS contains the same initial information, but is not an autoglobal. (Note that $HTTP_GET_VARS and $_GET are different variables and that PHP handles them as such)

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_GET and $HTTP_GET_VARS arrays. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals.

HTTP POST variables: $_POST
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_POST_VARS.

An associative array of variables passed to the current script via the HTTP POST method. Automatically global in any scope.

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_POST; to access it within functions or methods, as you do with $HTTP_POST_VARS.

$HTTP_POST_VARS contains the same initial information, but is not an autoglobal. (Note that $HTTP_POST_VARS and $_POST are different variables and that PHP handles them as such)

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_POST and $HTTP_POST_VARS arrays. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals.

  So if your PHP is 4.1.0 or greater, it should work ?!?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
Re: Virtual Weather Station WeatherFlash
« Reply #6 on: September 10, 2008, 06:32:37 PM »
Just an update,

I upgraded my server to PHP5.  I changed the WF scripts and all is well.
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline jjocsak

  • Senior Member
  • **
  • Posts: 69
Re: Virtual Weather Station WeatherFlash
« Reply #7 on: February 18, 2009, 06:13:39 AM »

and the submit.php (which should be renamed on your site to a unique name) would read
Code: [Select]
<?php
header
("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 
header("Expires: Mon,26 JUL 1997 05:00:00 GMT");

if (
$_GET["I"]=="DEMO" ){
   if (
$_GET["F"] != ""){ 
      
$fp=fopen("../Data/wflash.txt""w");
      
$TempStr=$_GET["F"];
      
$TempStr2=str_replace(" ","+",$TempStr);
      
fwrite($fp"F=".$TempStr2);
   }else{
      
$fp=fopen("../Data/wflash2.txt""w");
      
$TempStr=$_GET["S"];
      
$TempStr2=str_replace(" ","+",$TempStr);   
      
fwrite($fp"S=".$TempStr2);
   }
   
fclose($fp);
}
?>

Hope this helps...
Best regards,
Ken


I could not figure out why my WF was not working until I saw this post.
In the PHP5 version of submit.php has (GGP9M9) as the user ID instead of (DEMO).
I changed that and it is now working.

Thanks for this post.

Jeff