Can we add date.timezone to php.ini?

  • Since PHP5.3 requires either date.timezone be define in php.ini or date_default_timezone_set() function within the php pages. Can we add date.timezone to the php.ini file? Have it use a variable so its the same setting that is set from the System:General Setup?

    I hope this can be added to the /etc/ec.php_ini_setup file. I ask because this would fix a TON of errors that vnstat2 is having and who knows what else.

    I'm going to write a quick how-to so users can start using vnstat2 again. If date.timezone can be added to the core, then its only 1 line change for vnstat.php

  • LAYER 8 Global Moderator

    Dude - that is so funny.. I was just looking at this as well ;)

    I grabbed the lastest version 1.5.1 of the php frontent since before it was 1.4.1 and that got rid of the previous error.  But then started seeing

    Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead in /usr/local/www/vnstat2/vnstat.php on line 140

  • Rebel Alliance Developer Netgate

    Looks like we went the other way with it:

    $ grep -nr "timezone_set" *

    I don't recall the exact reason we did that rather than using php.ini, perhaps it made php pick it up faster and didn't require restarting lighttpd/php

  • thanks for the quick reply… I changed my code back and just added "date_default_timezone_set("EST5EDT");" into vnstat.php for now(cleaner and doesn't touch the core)... I tried to include/require_once(""); but it kicked out errors for that file...

  • LAYER 8 Global Moderator

    So you have it up and running then?  Looking forward to your writeup on getting it working again.

    Then what do we have to do to get the package updated, etc. ;)

    edit: I just went to go put in the timezone stuff - and my vnstat is back to before.
    Function split() is deprecated in /usr/local/www/vnstat2/vnstat.php on line 130

    I updated to new snap this morning to see if that fixed the upnp errors I was seeing in the log.  I really want to get 1.5.1 vs the 1.4.1 but keep the formatting that was there in the package.  But the code from 1.5.1 points to themes folder and locale, etc.

    Hope I can find some time at work today to play with it.  Maybe your writeup will be available this afternoon?

  • not sure when i'm going to get it done.. haven't started yet… :-(

    on line 130, change split to explode

  • LAYER 8 Global Moderator

    I know how to fix that portion ;)  Version 1.5.1 of phpfrontend already has that change in place.

    I think we are about in the same place - I had gotten to the Warning: strftime() yesterday but ran out of play time ;) to move forward with it.

    From the commit history for the package

    Looks like perry mason is the dev for the package, but has not made a commit for like 8 months.  Maybe we can just submit the right changes for the package?

  • Rebel Alliance Developer Netgate

    If you can make it work, and others confirm your fixes work, submit a pull request and I'll approve it.

  • I got 1.5.1 to work after some hacking… I'll have to see what needs to be changed from the package itself to make sure it creates the db and the config.php page... Biggest issue I see, this package downloads the frontend.. Its not in the package itself... Which isn't a big deal I guess, we would just have to overwrite/add some files to it. The theme was built into the config.php page in the past, now it has its own folder. And for the life of me, can't figure how to add date_default_timezone_set("$timezone").. hate to have it as a manual hack..

  • The code for the front end is all bundled up in
    On the vnstat GUI, when you "Enable vnstat php frontend" then it unpacks this tar and suddenly you have files in /usr/local/www/vnstat2 - like vnstat.php
    I suppose that each time you press save it unpacks the tar again, overwriting whatever edits you made to vnstat.php
    The problem is that this code is not in the repository. It is a kind of standard distribution of vnstat scripts and stuff. So the scripts would need to be fixed to work with the latest PHP version then make another tar, or find where this came from and get an updated tar that has scripts that work with the current PHP.
    And I am guessing that it runs somewhat standalone, not integrated into the pfSense menu tree. So it probably won't understand $timezone.
    Someone will need to do a bit of research to sort out the best way to proceed with this.

  • LAYER 8 Global Moderator

    Well that frontend is not the actual tar.gz from original site, its been modified to contain the pfsense.css, etc.

    You can grab the 1.5.1 tar.gz for the original website here.

    You can grab the original 1.4.1 here

    Cino, can you post your hacks to get 1.5.1 working - thanks!

  • @johnpoz:

    Cino, can you post your hacks to get 1.5.1 working - thanks!

    let me know how you make out,47241.msg274510.html#msg274510

    we kinda went off topic a lot so i posted the how-to on your old post

  • Rebel Alliance Developer Netgate

    Looks like the reason we went this way is that the php.ini setup script is a shell script (by necessity) and it doesn't have any knowledge of the timezone in the config.xml file.

    It could probably be done, we have other shell scripts that use some shell-fu to grep/awk out values from the config, it's not just a quick/easy fix.

  • thanks jimp… I had a feeling that could be the case :-(  I figured out how to get vnstat2 to work for now.... I really need to learn how to program

Log in to reply