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