2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/02/2011 *
4 * =================== Last change: 06/02/2011 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : Filters for ext- *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Filter fuer ext- *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Filter for adding extra data to the query
44 function FILTER_ADD_EXTRA_SQL_DATA ($add = '') {
45 // Is the admins extension updated? (should be!)
46 if (isExtensionInstalledAndNewer('admins', '0.3.0')) $add .= ', `default_acl` AS def_acl';
47 if (isExtensionInstalledAndNewer('admins', '0.6.7')) $add .= ', `la_mode`';
48 if (isExtensionInstalledAndNewer('admins', '0.7.2')) $add .= ', `login_failures`, UNIX_TIMESTAMP(`last_failure`) AS last_failure';
49 if (isExtensionInstalledAndNewer('admins', '0.7.3')) $add .= ', `expert_settings`, `expert_warning`';
55 // Reset the login failures
56 function FILTER_RESET_ADMINS_LOGIN_FAILURES ($data) {
57 // Store it in session
58 setSession('mailer_admin_failures' , getAdminLoginFailures($data['id']));
59 setSession('mailer_admin_last_failure', getAdminLastFailure($data['id']));
61 // Prepare update data
62 $postData['login'][getCurrentAdminId()] = $data['login'];
63 $postData['login_failures'][getCurrentAdminId()] = '0';
64 $postData['last_failure'][getCurrentAdminId()] = null;
66 // Change it in the admin
67 adminsChangeAdminAccount($postData);
69 // Always make sure the cache is destroyed
70 rebuildCache('admin');
72 // Return the data for further processing
76 // Count the login failure
77 function FILTER_COUNT_ADMINS_LOGIN_FAILURE ($data) {
78 // Prepare update data
79 $postData['login'][getCurrentAdminId()] = $data['login'];
80 $postData['login_failures'][getCurrentAdminId()] = '`login_failures`+1';
81 $postData['last_failure'][getCurrentAdminId()] = 'NOW()';
83 // Change it in the admin
84 adminsChangeAdminAccount($postData);
86 // Always make sure the cache is destroyed
87 rebuildCache('admin');
89 // Return the data for further processing
93 // Rehashes the given plain admin password and stores it the database
94 function FILTER_REHASH_ADMINS_PASSWORD ($data) {
96 $newHash = generateHash($data['plain_pass']);
98 // Prepare update data
99 $postData['login'][getCurrentAdminId()] = $data['login'];
100 $postData['password'][getCurrentAdminId()] = $newHash;
102 // Change it in the admin
103 adminsChangeAdminAccount($postData);
105 // Update cookie/session and data array
106 setAdminMd5(encodeHashForCookie($newHash));
107 $data['pass_hash'] = $newHash;
109 // Always make sure the cache is destroyed
110 rebuildCache('admin');
112 // Return the data for further processing