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://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 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
47 if (isExtensionInstalledAndNewer('admins', '0.3.0')) $add .= ',`default_acl`';
48 if (isExtensionInstalledAndNewer('admins', '0.6.7')) $add .= ',`la_mode`';
49 if (isExtensionInstalledAndNewer('admins', '0.7.2')) $add .= ',`login_failures`,UNIX_TIMESTAMP(`last_failure`) AS `last_failure`';
50 if (isExtensionInstalledAndNewer('admins', '0.7.3')) $add .= ',`expert_settings`,`expert_warning`';
53 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
57 // Reset the login failures
58 function FILTER_RESET_ADMINS_LOGIN_FAILURES ($filterData) {
59 // Store it in session
60 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
61 setSession('mailer_admin_failures' , getAdminLoginFailures($filterData['id']));
62 setSession('mailer_admin_last_failure', getAdminLastFailure($filterData['id']));
64 // Prepare update data
65 $postData['login'][getCurrentAdminId()] = $filterData['login'];
66 $postData['login_failures'][getCurrentAdminId()] = '0';
67 $postData['last_failure'][getCurrentAdminId()] = NULL;
69 // Change it in the admin
70 adminsChangeAdminAccount($postData);
72 // Always make sure the cache is destroyed
73 rebuildCache('admin');
75 // Return the data for further processing
76 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
80 // Count the login failure
81 function FILTER_COUNT_ADMINS_LOGIN_FAILURE ($filterData) {
82 // Prepare update data
83 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
84 $postData['login'][getCurrentAdminId()] = $filterData['login'];
85 $postData['login_failures'][getCurrentAdminId()] = '`login_failures`+1';
86 $postData['last_failure'][getCurrentAdminId()] = 'NOW()';
88 // Change it in the admin
89 adminsChangeAdminAccount($postData);
91 // Always make sure the cache is destroyed
92 rebuildCache('admin');
94 // Return the data for further processing
95 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
99 // Rehashes the given plain admin password and stores it the database
100 function FILTER_REHASH_ADMINS_PASSWORD ($filterData) {
102 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
103 $newHash = generateHash($filterData['plain_pass']);
105 // Prepare update data
106 $postData['login'][getCurrentAdminId()] = $filterData['login'];
107 $postData['password'][getCurrentAdminId()] = $newHash;
109 // Change it in the admin
110 adminsChangeAdminAccount($postData);
112 // Update cookie/session and data array
113 setAdminMd5(encodeHashForCookie($newHash));
114 $filterData['pass_hash'] = $newHash;
116 // Always make sure the cache is destroyed
117 rebuildCache('admin');
119 // Return the data for further processing
120 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');