diff --git a/src/pages/LoginPage.class.php b/src/pages/LoginPage.class.php
index 195600c..0739330 100644
--- a/src/pages/LoginPage.class.php
+++ b/src/pages/LoginPage.class.php
@@ -90,18 +90,38 @@ public function printLoginForm($redirection){
$this->printHTMLFooter();
}
+ private function checkPluginLogin($username, $password) {
+ if ($this->plugEng->existPluginOfType('login')) {
+ $tmpArray = array($username, $password);
+ return $this->plugEng->doHookBoolean('login', $tmpArray);
+ }
+ return false;
+ }
+
/**
* Check for user login.
* @return true
if allowed, false
otherwise.
*/
private function checkLogin() {
- $user = $this->db->query(
- 'SELECT * ' .
- 'FROM fmb_members ' .
- 'WHERE mem_login = ? AND mem_passwd = ?',
- array($_REQUEST['login'], sha1($_REQUEST['password'])),
- DBPlugin::SQL_QUERY_FIRST
- ) ? $this->db->getSQLResult() : array();
+ $user = array();
+
+ if ($this->checkPluginLogin($_REQUEST['login'], $_REQUEST['password'])) {
+ $user = $this->db->query(
+ 'SELECT * '.
+ 'FROM fmb_members '.
+ 'WHERE mem_login = ?',
+ array($_REQUEST['login']),
+ DBPlugin::SQL_QUERY_FIRST
+ ) ? $this->db->getSQLResult() : array();
+ } else {
+ $user = $this->db->query(
+ 'SELECT * ' .
+ 'FROM fmb_members ' .
+ 'WHERE mem_login = ? AND mem_passwd = ?',
+ array($_REQUEST['login'], sha1($_REQUEST['password'])),
+ DBPlugin::SQL_QUERY_FIRST
+ ) ? $this->db->getSQLResult() : array();
+ }
if ($user != array()) {
$_SESSION['usrID'] = $user['mem_id'];
diff --git a/src/plugins/LoginPlugin.class.php b/src/plugins/LoginPlugin.class.php
new file mode 100644
index 0000000..ea0cf20
--- /dev/null
+++ b/src/plugins/LoginPlugin.class.php
@@ -0,0 +1,72 @@
+
+
+ FMB :
+ ------------
+ This software is an homemade PHP Blog engine.
+
+ This software is governed by the CeCILL license under French law and
+ abiding by the rules of distribution of free software. You can use,
+ modify and/ or redistribute the software under the terms of the CeCILL
+ license as circulated by CEA, CNRS and INRIA at the following URL
+ "http://www.cecill.info".
+
+ As a counterpart to the access to the source code and rights to copy,
+ modify and redistribute granted by the license, users are provided only
+ with a limited warranty and the software's author, the holder of the
+ economic rights, and the successive licensors have only limited
+ liability.
+
+ In this respect, the user's attention is drawn to the risks associated
+ with loading, using, modifying and/or developing or reproducing the
+ software by the user in light of its specific status of free software,
+ that may mean that it is complicated to manipulate, and that also
+ therefore means that it is reserved for developers and experienced
+ professionals having in-depth computer knowledge. Users are therefore
+ encouraged to load and test the software's suitability as regards their
+ requirements in conditions enabling the security of their systems and/or
+ data to be ensured and, more generally, to use and operate it in the
+ same conditions as regards security.
+
+ The fact that you are presently reading this means that you have had
+ knowledge of the CeCILL license and that you accept its terms.
+*/
+
+/**
+ * LoginPlugin.class.php file.
+ * This file contains the sourcecode of the abstract LoginPlugin class.
+ * Every FMB caching plugin should extends this class.
+ * @package FMB
+ * @subpackage Plugins
+ * @author Ziirish
+ * @version 0.1b
+ */
+namespace FMB\Plugins;
+use FMB\Core\Core;
+use FMB\Plugins\Plugin;
+use FMB\Plugins\LoginPluginInterface;
+
+// Loading required files.
+Core::loadFile('src/plugins/Plugin.class.php', true);
+Core::loadFile('src/plugins/LoginPlugin.interface.php', true);
+
+/**
+ * LoginPlugin abstract class.
+ * This file contains the LoginPlugin abstract class.
+ * @package FMB
+ * @subpackage Plugins
+ * @author Ziirish
+ * @version 0.1b
+ * @abstract
+ */
+abstract class LoginPlugin extends Plugin implements LoginPluginInterface
+{
+
+ public final function __construct()
+ {
+ parent::__construct('template');
+ }
+
+}
+?>
diff --git a/src/plugins/LoginPlugin.interface.php b/src/plugins/LoginPlugin.interface.php
new file mode 100644
index 0000000..85b0a25
--- /dev/null
+++ b/src/plugins/LoginPlugin.interface.php
@@ -0,0 +1,65 @@
+
+
+ FMB :
+ ------------
+ This software is an homemade PHP Blog engine.
+
+ This software is governed by the CeCILL license under French law and
+ abiding by the rules of distribution of free software. You can use,
+ modify and/ or redistribute the software under the terms of the CeCILL
+ license as circulated by CEA, CNRS and INRIA at the following URL
+ "http://www.cecill.info".
+
+ As a counterpart to the access to the source code and rights to copy,
+ modify and redistribute granted by the license, users are provided only
+ with a limited warranty and the software's author, the holder of the
+ economic rights, and the successive licensors have only limited
+ liability.
+
+ In this respect, the user's attention is drawn to the risks associated
+ with loading, using, modifying and/or developing or reproducing the
+ software by the user in light of its specific status of free software,
+ that may mean that it is complicated to manipulate, and that also
+ therefore means that it is reserved for developers and experienced
+ professionals having in-depth computer knowledge. Users are therefore
+ encouraged to load and test the software's suitability as regards their
+ requirements in conditions enabling the security of their systems and/or
+ data to be ensured and, more generally, to use and operate it in the
+ same conditions as regards security.
+
+ The fact that you are presently reading this means that you have had
+ knowledge of the CeCILL license and that you accept its terms.
+*/
+
+/**
+ * LoginPlugin.interface.php file.
+ * This file contains the sourcecode of the LoginPlugin interface.
+ * @package FMB
+ * @subpackage Plugins
+ * @author Ziirish
+ * @version 0.1b
+ */
+namespace FMB\Plugins;
+
+/**
+ * LoginPlugin interface.
+ * This file contains the LoginPlugin interface.
+ * @package FMB
+ * @subpackage Plugins
+ * @author Ziirish
+ * @version 0.1b
+ */
+interface LoginPluginInterface
+{
+ /**
+ * Check if a login/password is valid
+ * @param string $login Login to test.
+ * @param string $password Password to test.
+ * @return TRUE if login/password is valid.
+ */
+ public function checkLogin($login, $password);
+}
+
+?>
diff --git a/src/plugins/PluginEngine.class.php b/src/plugins/PluginEngine.class.php
index fb280ba..19276cb 100644
--- a/src/plugins/PluginEngine.class.php
+++ b/src/plugins/PluginEngine.class.php
@@ -433,6 +433,40 @@ public function doHookConcatBoolean($hookName, $parameters = NULL)
return $result;
}
+ /**
+ * Execute given hook with eventual parameters and return as soon as one
+ * result is true.
+ * @access public
+ * @param string $hookName Name of the hook to execute.
+ * @param array $parameters Parameters to pass to plugins methods.
+ * @return string The concatenated answers of all plugins to this hook.
+ * If all answers are false, the result will be false.
+ * Otherwise the result will be true.
+ */
+ public function doHookBoolean($hookName, $parameters = NULL)
+ {
+ $result = false;
+
+ if (isset(self::$_pluginsHooks["$hookName"])
+ && is_array(self::$_pluginsHooks["$hookName"])) {
+
+ /* Search for loaded plugins. */
+ foreach (self::$_pluginsHooks["$hookName"] as $hook) {
+ $plugin = self::getPlugin($hook['pluginName']);
+
+ if (NULL != $plugin) {
+ if (method_exists($plugin, $hook['pluginMethod'])) {
+ if ($plugin->$hook['pluginMethod']($parameters)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return $result;
+ }
+
/**
* Check required FMB version for given plugin.
* @access private