Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date.timezone support to PHP "Other Settings". #14

Closed
wants to merge 1 commit into from

Conversation

lewellyn
Copy link
Contributor

Hi there! This is my first pull request for Webmin, so please be kind. :)

Problem:

  • Starting in PHP 5.1.0, you can now define the time zone to be used by PHP.
  • Starting in PHP 5.3.0, it's practically required if you don't want to be inundated with warnings:
    [Thu Apr 14 02:24:09 2011] [warn] mod_fcgid: stderr: PHP Warning:
    date(): 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/Los_Angeles' for 'PDT/-7.0/DST'
    instead in /home/blahblahblah/public_html/plugins/log/log.php on line 44

Solution:

  • Add a dropdown on the "Other Settings" page in Webmin's PHP Configuration module.

Implementation:

  1. Read all time zones from the system's zone.tab.
  2. Create a hash containing each time zone "name" as the key, along with the other data available via the zonetab as a multidimensional hash, for potential use by others looking to add the latitude/longitude in the future (or perhaps other PHP options which may be able to use this same data sanely).
  3. Place an empty ('') entry at the top of the list, allowing the user to revert to the default behavior.
  4. Add "comments" for the empty entry and any custom entry which may have been manually entered by the user.
  5. Display a table row with a select element, containing the list of time zones.
  6. Save their selection to the configuration.

Known problems:

  1. This is also displayed for systems running PHP 4. I do not see a way to discriminate based on PHP version. However, it should be harmless for those users.

Future functionality:

  • It would be nice to see the descriptions/comments from the time zone database be visible to the user somehow. I haven't figured out a good way to do that yet.
  • This should also be usable as the jumping-off point for someone to add date.default_latitude and date.default_longitude support. (They'd have to parse %tzlist{$tzname}{'coords'} to get it, but that should be fairly trivial.)

Additional information:

  • I also have added a help file for the new option, as there aren't enough help links as there aren't enough help links in some of the modules, PHP included. :)
  • Support for an "Other" menu option was purposely omitted. There is almost no reason for someone to choose an unavailable time zone, such as old System V "legacy" names e.g. PST8PDT. (It is retained, however, if they have set one and save again without choosing another value from the list.)
  • I have not made the location of the zonetab configurable, as it is in a standard location. There is very little compelling reason to accommodate the very few users/admins who even know that they can have two time zone databases on one system. (And I believe every system supported by Webmin has it in this location; the big ones [Linux, BSD, Solaris] do...)

@jcameron
Copy link
Collaborator

Awesome! I have integrated your change and committed it to the Webmin repository with some small changes to use an existing function to get the list of timezones.

@jcameron jcameron closed this Apr 14, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants