Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.php Subject: Re: 404 error Date: Tue, 22 Apr 2014 23:26:13 +0200 Organization: PointedEars Software (PES) Lines: 84 Message-ID: <1747044.jrh1OFUs5G@PointedEars.de> References: <7f2rl4.2fb.17.1@news.alt.net> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1398201980 19551 eJwFwQkBwDAIA0BLUAhhcugT/xJ2hyivwyxUQtCOwaYwNrepcW6yTT3SW22InIZ9PFfP3/oBLSMRmA== (22 Apr 2014 21:26:20 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 22 Apr 2014 21:26:20 +0000 (UTC) User-Agent: KNode/4.11.5 X-User-ID: eJwNwokRwDAIA7CVIObLODEH+4/QnuQIjU4LD/P91cCBzmo69ChrG7wFN5VTmTEtVWvNC6U4V/mCK9rz8gMycRUs Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. > > > Fine so far. The other site has different results. > […] > http://guitarsnotguns.org/rot.php > > Notice the error message and incorrect date in the footer. It is not an error message, it is a *warning*. > I'm guessing it's a server configuration issue. Any thoughts? > > BTW, here's the PHP I use on both sites: > > $current_file_name = ($_SERVER['REQUEST_URI']); > $current_path = ($_SERVER['DOCUMENT_ROOT']); It is pointless and confusing for people accustomed to writing PHP code to put the RHS into parentheses here. > $full_name = $current_path.$current_file_name; > $last_modified = filemtime($full_name); Look closely at that warning. This approach is not going to work reliably because the HTTP request URI does not need to have anything to do with the file path of the resource. In fact, there does not even need to be a real file for a URI, the served content could have been generated entirely by PHP (and usually is). As a result, in those cases filemtime() returns FALSE … > print(date("F j, Y - h:i A", $last_modified)); … which date() converts to 0 (UNIX epoch) – as it expects an int (UNIX timestamp), not a boolean value, for the second argument – and formats that accordingly to “December 31, 1969” (not “January 1, 1970 - 12:00 AM” probably because of timezone issues), which is then send to stdout by print(). (You should use “echo” instead, unless in an expression where you need “print”’s return value. Think sh, not perl.) ,---- | $ php -r 'echo date("F, j Y - h:i A", filemtime("Slartibartfast")) . | "\n";' | PHP Warning: filemtime(): stat failed for Slartibartfast in Command line | code on line 1 | PHP Stack trace: | PHP 1. {main}() Command line code:0 | PHP 2. filemtime() Command line code:1 | January, 1 1970 - 01:00 AM | | $ php -v | PHP 5.5.11-3 (cli) (built: Apr 19 2014 16:46:26) | Copyright (c) 1997-2014 The PHP Group | Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies | with XCache v3.1.0, Copyright (c) 2005-2013, by mOo | with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend | Technologies | with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans | with XCache Optimizer v3.1.0, Copyright (c) 2005-2013, by mOo | with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo | with XCache Coverager v3.1.0, Copyright (c) 2005-2013, by mOo `---- (I am in UTC+2 now because of European Summer Time, and date.timezone is set to “Europe/Zurich”; the latter would account for the one-hour advance.) You might be looking for filemtime(__FILE__) instead. PointedEars -- realism: HTML 4.01 Strict evangelism: XHTML 1.0 Strict madness: XHTML 1.1 as application/xhtml+xml -- Bjoern Hoehrmann