528ec3c737d36961ebb4086207e79b67c42f0713
[mailer.git] / inc / modules / admin / what-lock_user.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/28/2003 *
4  * ===============                              Last change: 06/10/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-lock_user.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Lock members                                     *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mitglieder sperren                               *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Add description as navigation point
42 ADD_DESCR("admin", basename(__FILE__));
43
44 if (!empty($_GET['u_id']))
45 {
46         $result_user = SQL_QUERY_ESC("SELECT status, sex, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
47          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
48         $ACT = false;
49         if (SQL_NUMROWS($result_user) == 1)
50         {
51                 // User found
52                 list($status, $sex, $sname, $fname, $email) = SQL_FETCHROW($result_user);
53                 SQL_FREERESULT($result_user);
54                 if (empty($_GET['u_id']))
55                 {
56                         // Output selection form with all confirmed user accounts listed
57                         ADD_MEMBER_SELECTION_BOX();
58                 } elseif (!empty($_POST['lock'])) {
59                         // Ok, lock the account!
60                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='LOCKED' WHERE userid=%s LIMIT 1",
61                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
62                         if (SQL_AFFECTEDROWS() == 1)
63                         {
64                                 // Send an email to the user! In later version you can optionally switch this feature off
65                                 $msg = LOAD_EMAIL_TEMPLATE("lock-user", $_POST['reason'], bigintval($_GET['u_id']));
66
67                                 // Send away...
68                                 SEND_EMAIL($email, ADMIN_LOCKED_SUBJ, $msg);
69                         }
70
71                         // Prepare message
72                         $MSG = USER_ACCOUNT_LOCKED_1.$_GET['u_id'].USER_ACCOUNT_LOCKED_2;
73                         $ACT = true;
74                 } elseif (!empty($_POST['unlock'])) {
75                         // Ok, unlock the account!
76                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED' WHERE userid=%s LIMIT 1",
77                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
78                         if (SQL_AFFECTEDROWS() == 1)
79                         {
80                                 // Send an email to the user! In later version you can optionally switch this feature off
81                                 $msg = LOAD_EMAIL_TEMPLATE("unlock-user", $_POST['reason'], bigintval($_GET['u_id']));
82
83                                 // Send away...
84                                 SEND_EMAIL($email, ADMIN_UNLOCKED_SUBJ, $msg);
85                                 if (EXT_IS_ACTIVE("rallye"))
86                                 {
87                                         RALLYE_AUTOADD_USER($_GET['u_id']);
88                                 }
89                         }
90
91                         // Prepare message
92                         $MSG = USER_ACCOUNT_UNLOCKED_1.$_GET['u_id'].USER_ACCOUNT_UNLOCKED_2;
93                         $ACT = true;
94                 }
95                  elseif (isset($_POST['del']))
96                 {
97                         // Delete the account
98                         $ACT = true;
99                         require_once(PATH."inc/modules/admin/what-del_user.php");
100                 }
101                  elseif (!empty($_POST['no']))
102                 {
103                         // Do not lock him...
104                         $URL = URL."/modules.php?module=admin&amp;what=list_user&amp;u_id=".$_GET['u_id'];
105                 }
106                  else
107                 {
108                         $result = SQL_QUERY_ESC("SELECT email, surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
109                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
110                         if (SQL_NUMROWS($result) == 1)
111                         {
112                                 // Load data
113                                 list ($email, $sname, $fname) = SQL_FETCHROW($result);
114                                 SQL_FREERESULT($result);
115
116                                 // Transfer data to constants for the template
117                                 define('__EMAIL', CREATE_EMAIL_LINK($email, "user_data"));
118                                 define('__SNAME', $sname);
119                                 define('__FNAME', $fname);
120                                 define('__UID'  , $_GET['u_id']);
121
122                                 // Transfer data to constants for the template
123                                 define('__UID_VALUE', $_GET['u_id']);
124
125                                 // Realy want to lock?
126                                 switch ($status)
127                                 {
128                                 case "CONFIRMED": // Yes, lock him down... ;-)
129                                         define('__OK_VALUE'    , "lock");
130                                         define('__HEADER_VALUE', ADMIN_HEADER_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_LOCK_ACCOUNT_2);
131                                         define('__TEXT_VALUE'  , ADMIN_TEXT_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_LOCK_ACCOUNT_2);
132                                         break;
133
134                                 case "LOCKED": // Unlock the user
135                                         define('__OK_VALUE'    , "unlock");
136                                         define('__HEADER_VALUE', ADMIN_HEADER_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_UNLOCK_ACCOUNT_2);
137                                         define('__TEXT_VALUE'  , ADMIN_TEXT_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_UNLOCK_ACCOUNT_2);
138                                         break;
139
140                                 case "UNCONFIRMED": // Unconfirmed accounts cannot be unlocked!
141                                         define('__OK_VALUE'    , "del");
142                                         define('__HEADER_VALUE', ADMIN_HEADER_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_DEL_ACCOUNT_2);
143                                         define('__TEXT_VALUE'  , ADMIN_TEXT_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_DEL_ACCOUNT_2);
144                                         break;
145                                 }
146
147                                 // Output form
148                                 LOAD_TEMPLATE("admin_lock_user");
149                         }
150                          else
151                         {
152                                 // Account does not exists!
153                                 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
154                         }
155                 }
156                 if (!empty($URL))
157                 {
158                         // Reload and die...
159                         LOAD_URL($URL);
160                 }
161                  elseif ($ACT)
162                 {
163                         // An action was performed...
164                         if (!empty($MSG))
165                         {
166                                 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_green\">".$MSG."</STRONG>");
167                         }
168                          else
169                         {
170                                 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_green\">".ADMIN_USER_UPDATED."</STRONG>");
171                         }
172                 }
173         }
174          else
175         {
176                 // Account does not exists!
177                 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
178         }
179 } else {
180         // List all users
181         ADD_MEMBER_SELECTION_BOX();
182 }
183
184 //
185 ?>