Skip to content

Commit e7b7aa9

Browse files
committed
auth only apache/php module, fix warning datetime zone
1 parent 94635f1 commit e7b7aa9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

phpwpinfo.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19-
define('LOGIN', 'wordpress');
20-
define('PASSWORD', 'wordpress');
21-
22-
if( !isset($_SERVER['PHP_AUTH_USER']) || ($_SERVER['PHP_AUTH_PW'] != PASSWORD || $_SERVER['PHP_AUTH_USER'] != LOGIN) ) {
23-
header('WWW-Authenticate: Basic realm="Authentification"');
24-
header('HTTP/1.0 401 Unauthorized');
25-
echo 'Authentification failed';
26-
exit();
19+
// Suppress DateTime warnings
20+
date_default_timezone_set(@date_default_timezone_get());
21+
22+
// Auth only for PHP/Apache
23+
if ( strpos( php_sapi_name( ), 'cgi' ) === false ) {
24+
define('LOGIN', 'wordpress');
25+
define('PASSWORD', 'wordpress');
26+
27+
if( !isset($_SERVER['PHP_AUTH_USER']) || ($_SERVER['PHP_AUTH_PW'] != PASSWORD || $_SERVER['PHP_AUTH_USER'] != LOGIN) ) {
28+
header('WWW-Authenticate: Basic realm="Authentification"');
29+
header('HTTP/1.0 401 Unauthorized');
30+
echo 'Authentification failed';
31+
exit();
32+
}
2733
}
2834

2935
function phpwpinfo( ) {

0 commit comments

Comments
 (0)