From d89b9056cd97f2d114d891a284ea56e6540ff3dc Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 21 Aug 2013 16:11:01 +0200 Subject: Màj install.php pour prise en compte token MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le token est généré automatiquement à l'installation si on précise une adresse mail de connexion --- public/install.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'public/install.php') diff --git a/public/install.php b/public/install.php index f5801acc6..31c96fb39 100644 --- a/public/install.php +++ b/public/install.php @@ -65,6 +65,15 @@ function writeArray ($f, $array) { } } +function small_hash ($txt) { + $t = rtrim (base64_encode (hash ('crc32', $txt, true)), '='); + $t = str_replace ('+', '-', $t); // Get rid of characters which need encoding in URLs. + $t = str_replace ('/', '_', $t); + $t = str_replace ('=', '@', $t); + + return $t; +} + // gestion internationalisation $translates = array (); $actual = 'en'; @@ -143,6 +152,12 @@ function saveStep2 () { } $_SESSION['mail_login'] = addslashes ($_POST['mail_login']); + $token = ''; + if ($_SESSION['mail_login']) { + $token = small_hash (time () . $_SESSION['sel']) + . small_hash ($_SESSION['base_url'] . $_SESSION['sel']); + } + $file_data = PUBLIC_PATH . '/data/Configuration.array.php'; $f = fopen ($file_data, 'w'); @@ -151,7 +166,8 @@ function saveStep2 () { writeArray ($f, array ( 'language' => $_SESSION['language'], 'old_entries' => $_SESSION['old_entries'], - 'mail_login' => $_SESSION['mail_login'] + 'mail_login' => $_SESSION['mail_login'], + 'token' => $token )); writeLine ($f, ');'); fclose ($f); -- cgit v1.2.3