0

My PHP knowledge is limited and I am trying to implement http://www.tutorialchip.com/php-download-file-script/ this script into my site. I have pushed up their files unchanged here http://brooksmemories.com/test/. If a file is clicked I get the following errors

Strict Standards: main() [function.main]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 /home/inspire/public_html/brooksmemories.com/test/download.php on line 16

Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /home/inspire/public_html/brooksmemories.com/test/download.php on line 16

I am not sure how to correct these errors to get it working. Any help would be greatly appreciated. Thank you.

Help Inspire
  • 336
  • 5
  • 24
  • The `__DIR__` constant does not exist in PHP <= 5.2; use `dirname(__FILE__)` in its place. The timezone warning is [explained by the Google](http://www.google.de/search?q=Strict+Standards:+main()+%5Bfunction.main%5D:+It+is+not+safe+to+rely+on+the+system's+timezone+settings.+Please+use+the+date.timezone+setting,+the+TZ+environment+variable+or+the+date_default_timezone_set()+function). – mario Apr 27 '12 at 17:32
  • @mario: Timezone warning is caused by this notice as far I can see. For some reason, even errors can cause errors in PHP. Weird, but that's how it works. I would fix the config, so this warning wouldn't happen, but in this case it means nothing at all. – Konrad Borowski Apr 27 '12 at 17:36

2 Answers2

1

Check your PHP version... __DIR__ is a new constant only available in PHP 5.3+, the way to achieve the same in older versions of PHP was with: dirname(__FILE__) in place of __DIR__

The timezone message can be fixed with an php.ini entry:

;approx line 1005
[Date]
date.timezone = "America/Chicago";

Or by adding date_default_timezone_set to the top of your PHP document:

<?php
date_default_timezone_set('America/Chicago');
//...
Rudu
  • 15,682
  • 4
  • 47
  • 63
0

The first warning is about usage of certain date function. In this case, I think that warning itself activates it (it stores it in log). The server warning is more important, it mentions usage of undefined magic constant __DIR__ (current script directory). It was introduces in PHP 5.3.

So, you have two options.

  1. Update to PHP 5.3 5.4
  2. Replace __DIR__ with dirname(__FILE__).
Konrad Borowski
  • 11,584
  • 3
  • 57
  • 71