From 6499b26ae8e148fa5481db5b7a4e9fc0e55aad94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 1 Jun 2013 08:29:37 +0200 Subject: [PATCH] demo mode (you can't update password in demo mode --- img/messages/close.png | Bin img/messages/cross.png | Bin img/messages/help.png | Bin img/messages/tick.png | Bin img/messages/warning.png | Bin inc/config.php | 1 + inc/store/sqlite.class.php | 7 +++++++ index.php | 11 +++++++---- 8 files changed, 15 insertions(+), 4 deletions(-) mode change 100755 => 100644 img/messages/close.png mode change 100755 => 100644 img/messages/cross.png mode change 100755 => 100644 img/messages/help.png mode change 100755 => 100644 img/messages/tick.png mode change 100755 => 100644 img/messages/warning.png diff --git a/img/messages/close.png b/img/messages/close.png old mode 100755 new mode 100644 diff --git a/img/messages/cross.png b/img/messages/cross.png old mode 100755 new mode 100644 diff --git a/img/messages/help.png b/img/messages/help.png old mode 100755 new mode 100644 diff --git a/img/messages/tick.png b/img/messages/tick.png old mode 100755 new mode 100644 diff --git a/img/messages/warning.png b/img/messages/warning.png old mode 100755 new mode 100644 diff --git a/inc/config.php b/inc/config.php index 2de725f..bd9287f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -14,6 +14,7 @@ if (!is_dir('db/')) { @mkdir('db/',0705); } +define ('MODE_DEMO', FALSE); define ('ABS_PATH', 'assets/'); define ('CONVERT_LINKS_FOOTNOTES', TRUE); define ('REVERT_FORCED_PARAGRAPH_ELEMENTS',FALSE); diff --git a/inc/store/sqlite.class.php b/inc/store/sqlite.class.php index 4bfbb29..2108160 100644 --- a/inc/store/sqlite.class.php +++ b/inc/store/sqlite.class.php @@ -74,6 +74,13 @@ class Sqlite extends Store { return isset($pass[0]['value']) ? $pass[0]['value'] : FALSE; } + public function updatePassword($password) + { + $sql_update = "UPDATE config SET value=? WHERE name='password'"; + $params_update = array($password); + $query = $this->executeQuery($sql_update, $params_update); + } + private function executeQuery($sql, $params) { try { diff --git a/index.php b/index.php index 91d0b30..0a778d0 100644 --- a/index.php +++ b/index.php @@ -54,14 +54,17 @@ elseif (isset($_GET['config'])) { if (isset($_POST['password']) && isset($_POST['password_repeat'])) { if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { logm('password updated'); - $store->updatePassword(encode_string($_POST['password'] . $_SESSION['login'])); - $msg->add('s', 'your password has been updated'); + if (!DEMO) { + $store->updatePassword(encode_string($_POST['password'] . $_SESSION['login'])); + $msg->add('s', 'your password has been updated'); + } + else { + $msg->add('i', 'in demo mode, you can\'t update password'); + } } else $msg->add('e', 'your password can\'t be empty and you have to repeat it in the second field'); } - else - $msg->add('e', 'error in your password update'); } # Traitement des paramètres et déclenchement des actions