# HG changeset patch # User Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> # Date 1385425119 -3600 # Node ID df016fc8bbdbd87944e2adb84cde619a7f14f0b2 # Parent c294569b0725b6d5236f25b40a674b834bf501db correct authentication and put the login/password in the config template. diff -r c294569b0725 -r df016fc8bbdb web/common.php --- a/web/common.php Mon Nov 25 22:28:08 2013 +0100 +++ b/web/common.php Tue Nov 26 01:18:39 2013 +0100 @@ -407,16 +407,28 @@ $realm = 'Polemictweet restricted area'; +/*function authenticate($users, $translate) { + if (!isset($_SESSION['user_id'])) + { + // Fetch current URL + $this_url = $_SERVER['REQUEST_URI']; + + // Redirect to login page passing current URL + header('Location: login.php?return_url=' . urlencode($this_url)); + exit; + } +}*/ + function authenticate($users, $translate) { global $realm; - if (empty($_SERVER['PHP_AUTH_DIGEST'])) { + + if (empty($_SERVER['PHP_AUTH_DIGEST']) || !isset($_SESSION['http_digest_nonce'])) { $_SESSION['http_digest_nonce'] = uniqid(); header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Digest realm="'.$realm. '",qop="auth",nonce="'.$_SESSION['http_digest_nonce'].'",opaque="'.md5($realm).'"'); - return array('error' => $translate->_('This area is restricted, please authenticate')); } @@ -425,6 +437,8 @@ if (!($data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) || !isset($users[$data['username']])) { $_SERVER['PHP_AUTH_DIGEST'] = ''; + unset($_SESSION['auth']); + unset($_SESSION['http_digest_nonce']); return array('error' => $translate->_('Wrong Credentials!')); } @@ -436,20 +450,21 @@ if ($data['response'] != $valid_response) { $_SERVER['PHP_AUTH_DIGEST'] = ''; + unset($_SESSION['http_digest_nonce']); + unset($_SESSION['auth']); return array('error' => $translate->_('Wrong Credentials!')); } // ok, valid username & password - $_SESSION['auth'] = $data; + $_SESSION['auth'] = $data['username']; return $data; } function logout() { global $realm; - $_SESSION['auth'] = null; - header('HTTP/1.1 401 Unauthorized'); - header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$_SESSION['http_digest_nonce'].'",opaque="'.md5($realm).'"'); + unset($_SESSION['auth']); + unset($_SESSION['http_digest_nonce']); } diff -r c294569b0725 -r df016fc8bbdb web/config.php.tmpl --- a/web/config.php.tmpl Mon Nov 25 22:28:08 2013 +0100 +++ b/web/config.php.tmpl Tue Nov 26 01:18:39 2013 +0100 @@ -10,5 +10,6 @@ define('SECRET', '^e)3u&jwy@#156no9lmc1s&$g-x0n@lb=(+xgovk#5^kb)qvkb'); $C_default_registry = 'cdn'; +$C_event_users = array('polemictweet' => 'polemictweet'.date('Y/m/d')); $ldt_platform = 'http://ldt.iri.centrepompidou.fr/'; diff -r c294569b0725 -r df016fc8bbdb web/event_form.php --- a/web/event_form.php Mon Nov 25 22:28:08 2013 +0100 +++ b/web/event_form.php Tue Nov 26 01:18:39 2013 +0100 @@ -167,7 +167,7 @@
- + - - - - -
-
-
-
-
-
-