1 |
1815
|
Luisehahne
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
*
|
5 |
|
|
* @category admin
|
6 |
|
|
* @package pages
|
7 |
|
|
* @author Ryan Djurovich (2004-2009), WebsiteBaker Project
|
8 |
|
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
9 |
|
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
|
|
* @requirements PHP 5.2.2 and higher
|
13 |
|
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
/* -------------------------------------------------------- */
|
20 |
|
|
// Must include code to stop this file being accessed directly
|
21 |
|
|
if(!defined('WB_URL')) {
|
22 |
|
|
require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
|
23 |
|
|
throw new IllegalFileException();
|
24 |
|
|
}
|
25 |
|
|
/* -------------------------------------------------------- */
|
26 |
2098
|
darkviper
|
function delete_user($admin, $aActionRequest)
|
27 |
1815
|
Luisehahne
|
{
|
28 |
2098
|
darkviper
|
$oDb = WbDatabase::getInstance();
|
29 |
|
|
$oTrans = Translate::getInstance();
|
30 |
1815
|
Luisehahne
|
$aUserID = array();
|
31 |
|
|
$bRetVal = false;
|
32 |
|
|
|
33 |
2065
|
Luisehahne
|
$action = 'default';
|
34 |
|
|
$action = (isset($aActionRequest['delete']) ? 'delete' : $action );
|
35 |
2076
|
darkviper
|
$action = (isset($aActionRequest['delete_outdated']) ? 'delete_outdated' : $action );
|
36 |
|
|
$action = (isset($aActionRequest['enable_outdated']) ? 'enable_outdated' : $action );
|
37 |
2065
|
Luisehahne
|
|
38 |
|
|
switch($action) :
|
39 |
|
|
case 'delete': // delete the user
|
40 |
|
|
if(isset($aActionRequest['user_id'])) {
|
41 |
|
|
if(!is_array($aActionRequest['user_id'])) {
|
42 |
|
|
$aUserID[] = $aActionRequest['user_id'];
|
43 |
|
|
} else {
|
44 |
|
|
$aUserID = $aActionRequest['user_id'];
|
45 |
|
|
}
|
46 |
2076
|
darkviper
|
}
|
47 |
2065
|
Luisehahne
|
break;
|
48 |
|
|
case 'delete_outdated': // delete Users awaiting activation
|
49 |
|
|
if(isset($aActionRequest['activation_user_id'])) {
|
50 |
|
|
if(!is_array($aActionRequest['activation_user_id'])) {
|
51 |
|
|
$aUserID[] = $aActionRequest['activation_user_id'];
|
52 |
|
|
} else {
|
53 |
|
|
$aUserID = $aActionRequest['activation_user_id'];
|
54 |
|
|
}
|
55 |
|
|
}
|
56 |
|
|
break;
|
57 |
2076
|
darkviper
|
case 'enable_outdated': // enable Users awaiting activation
|
58 |
|
|
if(isset($aActionRequest['activation_user_id'])) {
|
59 |
|
|
if(!is_array($aActionRequest['activation_user_id'])) {
|
60 |
|
|
$aUserID[] = $aActionRequest['activation_user_id'];
|
61 |
|
|
} else {
|
62 |
|
|
$aUserID = $aActionRequest['activation_user_id'];
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
break;
|
66 |
2065
|
Luisehahne
|
default: // show userlist with empty modify mask
|
67 |
|
|
endswitch; // end of switch
|
68 |
2076
|
darkviper
|
|
69 |
2065
|
Luisehahne
|
// if(isset($aActionRequest['activation_user_id'])) {
|
70 |
|
|
// if(!is_array($aActionRequest['activation_user_id'])) {
|
71 |
2076
|
darkviper
|
//
|
72 |
2065
|
Luisehahne
|
// $aUserID[] = $aActionRequest['activation_user_id'];
|
73 |
|
|
// } else {
|
74 |
|
|
// $aUserID = $aActionRequest['activation_user_id'];
|
75 |
|
|
// }
|
76 |
|
|
// } else {
|
77 |
|
|
// if(isset($aActionRequest['user_id'])) {
|
78 |
|
|
// if(!is_array($aActionRequest['user_id'])) {
|
79 |
2076
|
darkviper
|
//
|
80 |
2065
|
Luisehahne
|
// $aUserID[] = $aActionRequest['user_id'];
|
81 |
|
|
// } else {
|
82 |
|
|
// $aUserID = $aActionRequest['user_id'];
|
83 |
|
|
// }
|
84 |
2076
|
darkviper
|
// }
|
85 |
|
|
// }
|
86 |
2065
|
Luisehahne
|
|
87 |
2076
|
darkviper
|
|
88 |
1815
|
Luisehahne
|
foreach ( $aUserID AS $key => $value)
|
89 |
|
|
{
|
90 |
|
|
switch ($_SERVER['REQUEST_METHOD']) :
|
91 |
|
|
case 'GET': // insert/update user
|
92 |
|
|
$_GET['user_id'] =$aUserID[$key];
|
93 |
|
|
break;
|
94 |
|
|
default: // show userlist with empty modify mask
|
95 |
|
|
$_POST['user_id'] =$aUserID[$key];
|
96 |
|
|
endswitch; // end of switch
|
97 |
|
|
$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
|
98 |
|
|
|
99 |
|
|
// Check if user id is a valid number and doesnt equal 1
|
100 |
|
|
if($user_id == 0){
|
101 |
2098
|
darkviper
|
msgQueue::add($oTrans->MESSAGE_GENERIC_FORGOT_OPTIONS );
|
102 |
1815
|
Luisehahne
|
return $bRetVal;
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
if( ($user_id < 2 ) )
|
106 |
|
|
{
|
107 |
|
|
// if($admin_header) { $admin->print_header(); }
|
108 |
2098
|
darkviper
|
msgQueue::add($oTrans->MESSAGE_GENERIC_SECURITY_ACCESS );
|
109 |
1815
|
Luisehahne
|
return $bRetVal;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
if( ($msg = msgQueue::getError()) == '')
|
113 |
|
|
{
|
114 |
2076
|
darkviper
|
|
115 |
|
|
switch($action) :
|
116 |
|
|
case 'enable_outdated': // enable Users awaiting activation
|
117 |
2098
|
darkviper
|
$sql = 'SELECT `display_name` FROM `'.$oDb->TablePrefix.'users` '.
|
118 |
2076
|
darkviper
|
'WHERE `user_id` = '.$user_id;
|
119 |
2098
|
darkviper
|
if( ($sDisplayUser = $oDb->getOne($sql)) != null ) {
|
120 |
|
|
$sql = 'UPDATE `'.$oDb->TablePrefix.'users` '
|
121 |
2076
|
darkviper
|
. 'SET `active`=1, '
|
122 |
|
|
. '`confirm_code`=\'\', '
|
123 |
|
|
. '`confirm_timeout`=0 '
|
124 |
|
|
. 'WHERE `user_id`='.$user_id;
|
125 |
2098
|
darkviper
|
if($oDb->doQuery($sql)) {
|
126 |
|
|
msgQueue::add($oTrans->MESSAGE_USERS_ADDED.' ('.$sDisplayUser.')', true);
|
127 |
2076
|
darkviper
|
$bRetVal = true;
|
128 |
|
|
} else {
|
129 |
2098
|
darkviper
|
msgQueue::add($oTrans->TEXT_ENABLE.$oTrans->MESSAGE_GENERIC_NOT_COMPARE.' ('.$sDisplayUser.')');
|
130 |
1815
|
Luisehahne
|
}
|
131 |
2076
|
darkviper
|
}
|
132 |
|
|
break;
|
133 |
|
|
default: // show userlist with empty modify mask
|
134 |
2098
|
darkviper
|
$sql = 'SELECT `active` FROM `'.$oDb->TablePrefix.'users` '.
|
135 |
2076
|
darkviper
|
'WHERE `user_id` = '.$user_id;
|
136 |
2098
|
darkviper
|
if( ($iDeleteUser = $oDb->getOne($sql)) != null ) {
|
137 |
2076
|
darkviper
|
if($iDeleteUser) {
|
138 |
|
|
// Deactivate the user
|
139 |
2098
|
darkviper
|
$sql = 'UPDATE `'.$oDb->TablePrefix.'users` SET '.
|
140 |
2076
|
darkviper
|
'`active` = 0 '.
|
141 |
|
|
'WHERE `user_id` = '.$user_id;
|
142 |
2098
|
darkviper
|
if( $oDb->doQuery($sql) ) {
|
143 |
|
|
msgQueue::add($oTrans->TEXT_USERS_MARKED_DELETED, true);
|
144 |
2076
|
darkviper
|
}
|
145 |
|
|
} else {
|
146 |
2065
|
Luisehahne
|
|
147 |
|
|
|
148 |
2098
|
darkviper
|
$sql = 'DELETE FROM `'.$oDb->TablePrefix.'users` '.
|
149 |
2076
|
darkviper
|
'WHERE `user_id` = '.$user_id;
|
150 |
2098
|
darkviper
|
if( $oDb->doQuery($sql) ) {
|
151 |
|
|
msgQueue::add($oTrans->MESSAGE_USERS_DELETED, true);
|
152 |
2076
|
darkviper
|
}
|
153 |
1815
|
Luisehahne
|
}
|
154 |
2076
|
darkviper
|
$bRetVal = true;
|
155 |
1815
|
Luisehahne
|
}
|
156 |
2098
|
darkviper
|
if($oDb->isError()) {
|
157 |
|
|
msgQueue::add( implode('<br />',explode(';',$oDb->getError())) );
|
158 |
2076
|
darkviper
|
$bRetVal = false;
|
159 |
|
|
}
|
160 |
|
|
endswitch; // end of switch
|
161 |
|
|
} // getError
|
162 |
|
|
} // foreach users
|
163 |
1815
|
Luisehahne
|
if(isset($aActionRequest['clearmsg'])) { msgQueue::clear(); }
|
164 |
1844
|
Luisehahne
|
return $bRetVal;
|
165 |
1815
|
Luisehahne
|
}
|
166 |
|
|
|
167 |
|
|
if(!isset($aActionRequest)) {
|
168 |
|
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
169 |
|
|
$aActionRequest = (isset(${$requestMethod})) ? ${$requestMethod} : null;
|
170 |
|
|
$aActionRequest['clearmsg'] = true;
|
171 |
2076
|
darkviper
|
}
|