c257d797f6ffca55e40a41b66cb08666b810046e
[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 OPEN_TABLE("100%", "admin_content admin_content_align", "");
45 if (!empty($_GET['u_id']))
46 {
47         $result_user = SQL_QUERY_ESC("SELECT status, sex, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
48          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
49         $ACT = false;
50         if (SQL_NUMROWS($result_user) == 1)
51         {
52                 // User found
53                 list($status, $sex, $sname, $fname, $email) = SQL_FETCHROW($result_user);
54                 SQL_FREERESULT($result_user);
55                 if (empty($_GET['u_id']))
56                 {
57                         // Output selection form with all confirmed user accounts listed
58                         ADD_MEMBER_SELECTION_BOX();
59                 }
60                  elseif (!empty($_POST['lock']))
61                 {
62                         // Ok, lock the account!
63                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='LOCKED' WHERE userid=%d LIMIT 1",
64                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
65                         if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 1)
66                         {
67                                 // Send an email to the user! In later version you can optionally switch this feature off
68                                 $msg = LOAD_EMAIL_TEMPLATE("lock-user", stripslashes($_POST['reason']), $_GET['u_id']);
69
70                                 // Send away...
71                                 SEND_EMAIL($email, ADMIN_LOCKED_SUBJ, $msg);
72                         }
73
74                         // Prepare message
75                         $MSG = USER_ACCOUNT_LOCKED_1.$_GET['u_id'].USER_ACCOUNT_LOCKED_2;
76                         $ACT = true;
77                 }
78                  elseif (!empty($_POST['unlock']))
79                 {
80                         // Ok, unlock the account!
81                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED' WHERE userid=%d LIMIT 1",
82                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
83                         if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 1)
84                         {
85                                 // Send an email to the user! In later version you can optionally switch this feature off
86                                 $msg = LOAD_EMAIL_TEMPLATE("unlock-user", stripslashes($_POST['reason']), $_GET['u_id']);
87
88                                 // Send away...
89                                 SEND_EMAIL($email, ADMIN_UNLOCKED_SUBJ, $msg);
90                                 if (EXT_IS_ACTIVE("rallye"))
91                                 {
92                                         RALLYE_AUTOADD_USER($_GET['u_id']);
93                                 }
94                         }
95
96                         // Prepare message
97                         $MSG = USER_ACCOUNT_UNLOCKED_1.$_GET['u_id'].USER_ACCOUNT_UNLOCKED_2;
98                         $ACT = true;
99                 }
100                  elseif (isset($_POST['del']))
101                 {
102                         // Delete the account
103                         $ACT = true;
104                         require_once(PATH."inc/modules/admin/what-del_user.php");
105                 }
106                  elseif (!empty($_POST['no']))
107                 {
108                         // Do not lock him...
109                         $URL = URL."/modules.php?module=admin&amp;what=list_user&amp;u_id=".$_GET['u_id'];
110                 }
111                  else
112                 {
113                         $result = SQL_QUERY_ESC("SELECT email, surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
114                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
115                         if (SQL_NUMROWS($result) == 1)
116                         {
117                                 // Load data
118                                 list ($email, $sname, $fname) = SQL_FETCHROW($result);
119                                 SQL_FREERESULT($result);
120
121                                 // Transfer data to constants for the template
122                                 define('__EMAIL', CREATE_EMAIL_LINK($email, "user_data"));
123                                 define('__SNAME', $sname);
124                                 define('__FNAME', $fname);
125                                 define('__UID'  , $_GET['u_id']);
126
127                                 // Transfer data to constants for the template
128                                 define('__UID_VALUE', $_GET['u_id']);
129
130                                 // Realy want to lock?
131                                 switch ($status)
132                                 {
133                                 case "CONFIRMED": // Yes, lock him down... ;-)
134                                         define('__OK_VALUE'    , "lock");
135                                         define('__HEADER_VALUE', ADMIN_HEADER_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_LOCK_ACCOUNT_2);
136                                         define('__TEXT_VALUE'  , ADMIN_TEXT_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_LOCK_ACCOUNT_2);
137                                         break;
138
139                                 case "LOCKED": // Unlock the user
140                                         define('__OK_VALUE'    , "unlock");
141                                         define('__HEADER_VALUE', ADMIN_HEADER_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_UNLOCK_ACCOUNT_2);
142                                         define('__TEXT_VALUE'  , ADMIN_TEXT_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_UNLOCK_ACCOUNT_2);
143                                         break;
144
145                                 case "UNCONFIRMED": // Unconfirmed accounts cannot be unlocked!
146                                         define('__OK_VALUE'    , "del");
147                                         define('__HEADER_VALUE', ADMIN_HEADER_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_DEL_ACCOUNT_2);
148                                         define('__TEXT_VALUE'  , ADMIN_TEXT_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_DEL_ACCOUNT_2);
149                                         break;
150                                 }
151
152                                 // Output form
153                                 LOAD_TEMPLATE("admin_lock_user");
154                         }
155                          else
156                         {
157                                 // Account does not exists!
158                                 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
159                         }
160                 }
161                 if (!empty($URL))
162                 {
163                         // Reload and die...
164                         LOAD_URL($URL);
165                 }
166                  elseif ($ACT)
167                 {
168                         // An action was performed...
169                         if (!empty($MSG))
170                         {
171                                 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_green\">".$MSG."</STRONG>");
172                         }
173                          else
174                         {
175                                 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_green\">".ADMIN_USER_UPDATED."</STRONG>");
176                         }
177                 }
178         }
179          else
180         {
181                 // Account does not exists!
182                 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
183         }
184 }
185  else
186 {
187         // List all users
188         ADD_MEMBER_SELECTION_BOX();
189 }
190 CLOSE_TABLE();
191 //
192 ?>