1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package users
|
6
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker2.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: index.php 2076 2014-01-06 23:30:25Z darkviper $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/users/index.php $
|
14
|
* @lastmodified $Date: 2014-01-07 00:30:25 +0100 (Tue, 07 Jan 2014) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
/**
|
19
|
* checks if a given string is part of a line in a defined file
|
20
|
* @param string $sString
|
21
|
* @param string $sListFile
|
22
|
* @return bool TRUE if at least one match is found, otherwise FALSE
|
23
|
*/
|
24
|
function findStringInFileList( $sString, $sListFile)
|
25
|
{
|
26
|
$aMatch = array();
|
27
|
if(is_readable($sListFile)) {
|
28
|
$aList = file($sListFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
29
|
$aMatch = preg_grep('/'.preg_quote($sString, '/').'/i',$aList);
|
30
|
}
|
31
|
return (sizeof($aMatch)>0);
|
32
|
}
|
33
|
|
34
|
function admin_users_index($aActionRequest)
|
35
|
{
|
36
|
$database = WbDatabase::getInstance();
|
37
|
$mLang = Translate::getinstance();
|
38
|
$mLang->enableAddon('admin\users');
|
39
|
|
40
|
$sAdminPath = dirname(str_replace('\\', '/', __FILE__));
|
41
|
$sAdminName = basename($sAdminPath);
|
42
|
$output = '';
|
43
|
$aActionRequest['requestMethod'] = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
44
|
$action = 'show';
|
45
|
// Set parameter 'action' as alternative to javascript mechanism
|
46
|
$action = (isset($aActionRequest['add']) ? 'add' : $action );
|
47
|
$action = (isset($aActionRequest['save']) ? 'save' : $action );
|
48
|
$action = (isset($aActionRequest['save_back']) ? 'save' : $action );
|
49
|
$action = (isset($aActionRequest['modify']) ? 'modify' : $action );
|
50
|
$action = (isset($aActionRequest['delete']) ? 'delete' : $action );
|
51
|
$action = (isset($aActionRequest['delete_outdated']) ? 'delete_outdated' : $action );
|
52
|
$action = (isset($aActionRequest['enable_outdated']) ? 'enable_outdated' : $action );
|
53
|
|
54
|
switch($action) :
|
55
|
case 'delete': // delete the user
|
56
|
case 'delete_outdated': // delete Users awaiting activation
|
57
|
case 'enable_outdated': // enable Users awaiting activation
|
58
|
$admin = new admin('Access', 'users_delete',false);
|
59
|
include($sAdminPath.'/delete.php');
|
60
|
delete_user($admin,$aActionRequest);
|
61
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
62
|
$admin = new admin('Access', 'users');
|
63
|
include($sAdminPath.'/user_list.php');
|
64
|
$output .= show_userlist($admin, $aActionRequest);
|
65
|
break;
|
66
|
case 'add': // insert/update user
|
67
|
$admin = new admin('Access', 'users_add',false);
|
68
|
include($sAdminPath.'/add.php');
|
69
|
add_user($admin,$aActionRequest);
|
70
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
71
|
$admin = new admin('Access', 'users');
|
72
|
include($sAdminPath.'/user_list.php');
|
73
|
$output .= show_userlist($admin, $aActionRequest);
|
74
|
break;
|
75
|
case 'save': // insert/update user
|
76
|
$admin = new admin('Access', 'users_modify',false);
|
77
|
// hold the cancel_url if request comes outside from users
|
78
|
if(isset($aActionRequest['BackLink'])) {
|
79
|
$sBackLink = $aActionRequest['BackLink'];
|
80
|
$aActionRequest['cancel_url'] = $sBackLink;
|
81
|
$aActionRequest['BackLink'] = $sBackLink;
|
82
|
}
|
83
|
include($sAdminPath.'/save.php');
|
84
|
$user_id = save_user($admin, $aActionRequest);
|
85
|
$admin = new admin('Access', 'users_modify');
|
86
|
include($sAdminPath.'/user_form.php');
|
87
|
$aActionRequest['user_id'] = $user_id;
|
88
|
$output = show_usermask($admin,$aActionRequest);
|
89
|
break;
|
90
|
case 'modify': // insert/update user
|
91
|
// first check acess to auth users can change his own preferences
|
92
|
$admin = new admin('Preferences', 'preferences_view',false);
|
93
|
$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
|
94
|
// Check if user id is a valid number and doesnt equal 1
|
95
|
$aActionRequest['user_id'] = $user_id;
|
96
|
if($user_id == 0){
|
97
|
$admin = new admin('Access', 'users');
|
98
|
msgQueue::clear();
|
99
|
msgQueue::add($mLang->MESSAGE_GENERIC_FORGOT_OPTIONS );
|
100
|
$aActionRequest['user_id'] = $user_id;
|
101
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
102
|
include($sAdminPath.'/user_list.php');
|
103
|
$output = show_userlist($admin, $aActionRequest);
|
104
|
break;
|
105
|
}
|
106
|
|
107
|
if( ($user_id == $admin->get_user_id() ) )
|
108
|
{
|
109
|
$sQueryString = (isset($_SERVER['QUERY_STRING'])&& ($_SERVER['QUERY_STRING']!='')) ? $_SERVER['QUERY_STRING'] : 'tool=uaerat';
|
110
|
$admin->send_header(ADMIN_URL.'/preferences/index.php?'.$sQueryString);
|
111
|
}
|
112
|
|
113
|
$admin = new admin('Access', 'users_modify');
|
114
|
|
115
|
if( ($user_id < 2 ) )
|
116
|
{
|
117
|
// if($admin_header) { $admin->print_header(); }
|
118
|
msgQueue::add($mLang->MESSAGE_GENERIC_SECURITY_ACCESS );
|
119
|
}
|
120
|
$admin_header = false;
|
121
|
if(isset($aActionRequest['BackLink'])) {
|
122
|
$sBackLink = $aActionRequest['BackLink'];
|
123
|
$aActionRequest['cancel_url'] = $sBackLink;
|
124
|
$aActionRequest['BackLink'] = $sBackLink;
|
125
|
} else {
|
126
|
$sBackLink = (isset($_SERVER['QUERY_STRING'])&& ($_SERVER['QUERY_STRING']!='')) ? $_SERVER['HTTP_REFERER'].'?'.$_SERVER['QUERY_STRING'] : $_SERVER['HTTP_REFERER'];
|
127
|
$aActionRequest['cancel_url'] = $sBackLink;
|
128
|
$aActionRequest['BackLink'] = $sBackLink;
|
129
|
}
|
130
|
include($sAdminPath.'/user_form.php');
|
131
|
$output = show_usermask($admin,$aActionRequest);
|
132
|
break;
|
133
|
default: // show userlist with empty modify mask
|
134
|
$admin = new admin('Access', 'users');
|
135
|
msgQueue::clear();
|
136
|
$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
|
137
|
// Check if user id is a valid number and doesnt equal 1
|
138
|
$aActionRequest['user_id'] = $user_id;
|
139
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
140
|
if($user_id > 1) // prevent 'admin' [ID 1] from modify
|
141
|
{
|
142
|
include($sAdminPath.'/user_form.php');
|
143
|
$output .= show_usermask($admin, $aActionRequest);
|
144
|
} elseif($user_id == 0) { // if invalid UserID is called, fall back to 'show-mode'
|
145
|
include($sAdminPath.'/user_list.php');
|
146
|
$output = show_userlist($admin, $aActionRequest);
|
147
|
}
|
148
|
endswitch; // end of switch
|
149
|
|
150
|
if( ($msg = msgQueue::getSuccess()) != '')
|
151
|
{
|
152
|
$output = $admin->format_message($msg, 'ok').$output;
|
153
|
}
|
154
|
if( ($msg = msgQueue::getError()) != '')
|
155
|
{
|
156
|
$output = $admin->format_message($msg, 'error').$output;
|
157
|
}
|
158
|
|
159
|
print $output;
|
160
|
if( isset($aActionRequest['BackLink']) && isset($aActionRequest['save_back']) ) {
|
161
|
$sBackLink = $aActionRequest['BackLink'];
|
162
|
echo "<script type=\"text/javascript\">
|
163
|
<!--
|
164
|
// Get the location object
|
165
|
var locationObj = document.location;
|
166
|
// Set the value of the location object
|
167
|
document.location = '$sBackLink';
|
168
|
-->
|
169
|
</script>";
|
170
|
}
|
171
|
$admin->print_footer();
|
172
|
|
173
|
}
|
174
|
|
175
|
if(!defined('WB_URL'))
|
176
|
{
|
177
|
$config_file = realpath('../../config.php');
|
178
|
if(file_exists($config_file) && !defined('WB_URL'))
|
179
|
{
|
180
|
require($config_file);
|
181
|
}
|
182
|
}
|
183
|
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
|
184
|
|
185
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
186
|
$aActionRequest = (isset(${$requestMethod})) ? ${$requestMethod} : null;
|
187
|
|
188
|
admin_users_index($aActionRequest);
|
189
|
exit;
|
190
|
// end of file
|