make login work for php-fastcgi

This commit is contained in:
Claude 2016-09-04 14:09:12 +02:00
parent 15ad0457e5
commit 6d00897ed1
2 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,9 @@ RewriteEngine on
RewriteCond $1 !^(index\.php|static|favicon\.ico|robots\.txt|sitemap.xml|google(.+)\.html)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
# basic auth for PHP with fastcgi
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
SetOutputFilter DEFLATE
FileETag MTime Size
@ -32,3 +35,5 @@ FileETag MTime Size
#AuthName "Backend"
#AuthUserFile /path/to/.htpasswd #create one with htpasswd -c .htpasswd username
#Require user username
AddHandler php5-fastcgi .php .php5

View File

@ -21,6 +21,9 @@ class Spamadmin extends CI_Controller
//protection
$user = $this->config->item('spamadmin_user');
$pass = $this->config->item('spamadmin_pass');
// basic auth for fastcgi
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
if ($user == '' || $pass == '' || !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass)
{