Project

General

Profile

Actions

Bug #2280

closed

pfblocker date() and mktime() warnings from cron job

Added by Phillip Davis over 13 years ago. Updated about 13 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
03/12/2012
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Affected Version:
2.1
Affected Plus Version:
Affected Architecture:

Description

When pfblocker runs from crontab to reload various lists at user-specified intervals, it reports warnings about the PHP date.timezone not being set. This is new behavior in recent versions of PHP.

Sample command and warning:
/usr/local/bin/php -q /usr/local/www/pfblocker.php cron
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 'Asia/Katmandu' for 'NPT/5.0/no DST' instead in /usr/local/www/pfblocker.php on line 27

Code to handle this has recently been added to /etc/inc/config.inc by:
https://redmine.pfsense.org/projects/pfsense/repository/revisions/34d70cc09a2f9868a33f75a19f25da1faf15392b

All that is needed is to add to /usr/local/www/pfblocker.php :
require_once("/etc/inc/config.inc");
to the cron section:

if ($argv1=='cron'){
require_once("/etc/inc/util.inc");
require_once("/etc/inc/functions.inc");
require_once("/etc/inc/pkg-utils.inc");
require_once("/etc/inc/globals.inc");
require_once("/etc/inc/filter.inc");
require_once("/etc/inc/config.inc");

$hour=date('H');

Note that the warning message doesn't seem to appear on 2.0.1, it has PHP 5.2.17.
On 2.1-DEVELOPMENT the warning message appears, it has PHP 5.3.10.
So, I guess this 1-line addition can be applied to 2.1


Files

pfblocker.php (9.35 KB) pfblocker.php Modified pfblocker.php with config.inc line added Phillip Davis, 03/12/2012 08:04 AM
Actions

Also available in: Atom PDF