Merge commit 'origin/fusionax' into account
[platal.git] / modules / platal.php
index 951803b..123a1c0 100644 (file)
@@ -62,6 +62,11 @@ class PlatalModule extends PLModule
 
     function handler_index(&$page)
     {
+        // Include X-XRDS-Location response-header for Yadis discovery
+        global $globals;
+        header('X-XRDS-Location: ' . $globals->baseurl . '/openid/idp_xrds');
+
+        // Redirect to the suitable page
         if (S::logged()) {
             pl_redirect('events');
         } else if (!@$GLOBALS['IS_XNET_SITE']) {
@@ -87,7 +92,7 @@ class PlatalModule extends PLModule
         $page->changeTpl('platal/changeLog.tpl');
 
         $clog = pl_entities(file_get_contents(dirname(__FILE__).'/../ChangeLog'));
-        $clog = preg_replace('/=+\s*/', '</pre><hr /><pre>', $clog);
+        $clog = preg_replace('/===+\s*/', '</pre><hr /><pre>', $clog);
         // url catch only (not all wiki syntax)
         $clog = preg_replace(array(
             '/((?:https?|ftp):\/\/(?:\.*,*[\w@~%$£µ&i#\-+=_\/\?;])*)/ui',
@@ -204,7 +209,6 @@ class PlatalModule extends PLModule
         global $globals;
 
         if (Post::has('response2'))  {
-            require_once 'secure_hash.inc.php';
             S::assert_xsrf_token();
 
             $_SESSION['password'] = $password = Post::v('response2');
@@ -228,7 +232,8 @@ class PlatalModule extends PLModule
             S::logger()->log('passwd', '');
 
             if (Cookie::v('ORGaccess')) {
-                setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0);
+                setcookie('ORGaccess', sha1($password), (time()+25920000), '/', '' ,0);
+                S::logger()->log('cookie_on', '');
             }
 
             $page->changeTpl('platal/motdepasse.success.tpl');
@@ -351,8 +356,7 @@ Adresse de secours : " . Post::v('email') : ""));
             $mymail->send();
 
             // on cree un objet logger et on log l'evenement
-            $logger = $_SESSION['log'] = new PlLogger($uid);
-            S::logger()->log('recovery', $mails);
+            S::logger(uid)->log('recovery', $mails);
         } else {
             $page->trigError('Les informations que tu as rentrées ne permettent pas de récupérer ton mot de passe.<br />'.
                         'Si tu as un homonyme, utilise prenom.nom.promo comme login');
@@ -390,8 +394,7 @@ Adresse de secours : " . Post::v('email') : ""));
                 }
             }
 
-            $logger = new PlLogger($uid);
-            S::logger()->log("passwd","");
+            S::logger($uid)->log("passwd", "");
             $page->changeTpl('platal/tmpPWD.success.tpl');
         } else {
             $page->changeTpl('platal/motdepasse.tpl');
@@ -438,8 +441,7 @@ Adresse de secours : " . Post::v('email') : ""));
         if ($level == 'forget' || $level == 'forgetall') {
             setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
             Cookie::kill('ORGaccess');
-            if (isset($_SESSION['log']))
-                S::logger()->log("cookie_off");
+            S::logger()->log("cookie_off");
         }
 
         if ($level == 'forgetuid' || $level == 'forgetall') {
@@ -449,10 +451,8 @@ Adresse de secours : " . Post::v('email') : ""));
             Cookie::kill('ORGdomain');
         }
 
-        if (isset($_SESSION['log'])) {
-            $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
-            S::logger()->log('deconnexion',$ref);
-        }
+        $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
+        S::logger()->log('deconnexion',$ref);
         Platal::session()->destroy();
 
         if (Get::has('redirect')) {
@@ -464,6 +464,10 @@ Adresse de secours : " . Post::v('email') : ""));
 
     function handler_review(&$page, $action = null, $mode = null) 
     {
+        // Include X-XRDS-Location response-header for Yadis discovery
+        global $globals;
+        header('X-XRDS-Location: ' . $globals->baseurl . '/openid/idp_xrds');
+
         $this->load('review.inc.php');
         $dom = 'Review';
         if (@$GLOBALS['IS_XNET_SITE']) {