🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.www.server-side
Article #61506

Re: newbie: logowanie przed wejściem na podstronę administracyjnę

#61506
From: Jivanmukta
Date: Wed, 22 Feb 2017 12:22
47 lines
2733 bytes
W dniu 2017-02-21 o 05:21, Jivanmukta pisze:
> Zrobię tak: http://www.php.rk.edu.pl/w/p/uwierzytelnianie-http/

Zrobiłem tak:
Plik controllers/Admin.php zawiera:

public function index() {
	$users = explode('|', ADMINS);
	$passwords = explode('|', PASSWORDS);
	$currentAdmin = $this->common->identifyCurrentAdmin();
	if ($passwords[$currentAdmin] != $_SERVER['PHP_AUTH_PW'] || 
!in_array($currentAdmin, $users)) {
		header("WWW-Authenticate: Basic realm=Logowanie do systemu");
		header("HTTP/1.0 401 Unauthorized");
		show_error(ERRMSG_LOGIN_FAILED);
		return;
	}
     ...
     $this->load->view('admin/index', $params);
}

Plik libraries/Common.php zawiera:

// ustalenie bieżącego administratora:
public function identifyCurrentAdmin() {
     $admin = $this->ci->session->userdata('currentAdmin');
     if (is_empty($admin)) {
         if (isset($_SERVER['PHP_AUTH_USER']) && 
!is_empty($_SERVER['PHP_AUTH_USER'])) {
             $this->ci->session->set_userdata('currentAdmin', 
$_SERVER['PHP_AUTH_USER']);
         } elseif (isset($_SERVER['REDIRECT_REMOTE_USER']) && 
!is_empty($_SERVER['REDIRECT_REMOTE_USER'])) {
             $this->ci->session->set_userdata('currentAdmin', 
$_SERVER['REDIRECT_REMOTE_USER']);
         }
     }
     return $this->ci->session->userdata('currentAdmin');
}

i nie wyświetla mi się okienko z pytaniem o użytkownika i hasło. 
Domyślam się, że coś powinienem wpisać do wamp\www\.htaccess, ale nie 
wiem co. Proszę o pomoc.

---
Ta wiadomość została sprawdzona na obecność wirusów przez oprogramowanie antywirusowe Avast.
https://www.avast.com/antivirus
Technical Details
Message-ID: <o8k3bb$qns$1@news.icm.edu.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!.POSTED!not-for-mail
References: <o8bi3m$133t$1@gioia.aioe.org> <lkpdox2km7fi$.7hd71v0x1iq6.dlg@40tude.net> <o8giob$6s1$1@news.icm.edu.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!.POSTED!not-for-mail
From: Jivanmukta <jivanmukta@poczta.onet.pl>
Newsgroups: pl.comp.www.server-side
Subject: Re: newbie: logowanie przed wejściem na
 podstronę administracyjnę
Date: Wed, 22 Feb 2017 13:22:50 +0100
Organization: ICM, Uniwersytet Warszawski
Lines: 48
Message-ID: <o8k3bb$qns$1@news.icm.edu.pl>
References: <o8bi3m$133t$1@gioia.aioe.org> <lkpdox2km7fi$.7hd71v0x1iq6.dlg@40tude.net> <o8giob$6s1$1@news.icm.edu.pl>
NNTP-Posting-Host: 89-73-113-134.dynamic.chello.pl
Mime-Version: 1.0
X-Trace: news.icm.edu.pl 1487769771 27388 89.73.113.134 (22 Feb 2017 13:22:51 GMT)
X-Complaints-To: usenet@news.icm.edu.pl
NNTP-Posting-Date: Wed, 22 Feb 2017 13:22:51 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Thunderbird/45.7.1
In-Reply-To: <o8giob$6s1$1@news.icm.edu.pl>
X-Antivirus: Avast (VPS 170222-0, 2017-02-22), Outbound message
X-Antivirus-Status: Clean
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit