1 |
1386
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package users
|
6 |
1529
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
1710
|
Luisehahne
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
1386
|
Luisehahne
|
* @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$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
1804
|
Luisehahne
|
*/
|
17 |
1386
|
Luisehahne
|
|
18 |
1815
|
Luisehahne
|
/**
|
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 |
1804
|
Luisehahne
|
|
34 |
1815
|
Luisehahne
|
function admin_users_index($aActionRequest)
|
35 |
|
|
{
|
36 |
|
|
$database = WbDatabase::getInstance();
|
37 |
2065
|
Luisehahne
|
$mLang = Translate::getinstance();
|
38 |
|
|
$mLang->enableAddon('admin\users');
|
39 |
1804
|
Luisehahne
|
|
40 |
1815
|
Luisehahne
|
$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 |
1823
|
Luisehahne
|
$action = (isset($aActionRequest['save_back']) ? 'save' : $action );
|
49 |
1815
|
Luisehahne
|
$action = (isset($aActionRequest['modify']) ? 'modify' : $action );
|
50 |
|
|
$action = (isset($aActionRequest['delete']) ? 'delete' : $action );
|
51 |
|
|
$action = (isset($aActionRequest['delete_outdated']) ? 'delete_outdated' : $action );
|
52 |
1386
|
Luisehahne
|
|
53 |
1815
|
Luisehahne
|
switch($action) :
|
54 |
|
|
case 'delete': // delete the user
|
55 |
1842
|
Luisehahne
|
case 'delete_outdated': // delete Users awaiting activation
|
56 |
1815
|
Luisehahne
|
$admin = new admin('Access', 'users_delete',false);
|
57 |
|
|
include($sAdminPath.'/delete.php');
|
58 |
1844
|
Luisehahne
|
delete_user($admin,$aActionRequest);
|
59 |
1815
|
Luisehahne
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
60 |
|
|
$admin = new admin('Access', 'users');
|
61 |
|
|
include($sAdminPath.'/user_list.php');
|
62 |
|
|
$output .= show_userlist($admin, $aActionRequest);
|
63 |
|
|
break;
|
64 |
|
|
case 'add': // insert/update user
|
65 |
|
|
$admin = new admin('Access', 'users_add',false);
|
66 |
|
|
include($sAdminPath.'/add.php');
|
67 |
1844
|
Luisehahne
|
add_user($admin,$aActionRequest);
|
68 |
1815
|
Luisehahne
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
69 |
|
|
$admin = new admin('Access', 'users');
|
70 |
|
|
include($sAdminPath.'/user_list.php');
|
71 |
|
|
$output .= show_userlist($admin, $aActionRequest);
|
72 |
|
|
break;
|
73 |
|
|
case 'save': // insert/update user
|
74 |
|
|
$admin = new admin('Access', 'users_modify',false);
|
75 |
|
|
// hold the cancel_url if request comes outside from users
|
76 |
|
|
if(isset($aActionRequest['BackLink'])) {
|
77 |
|
|
$sBackLink = $aActionRequest['BackLink'];
|
78 |
|
|
$aActionRequest['cancel_url'] = $sBackLink;
|
79 |
|
|
$aActionRequest['BackLink'] = $sBackLink;
|
80 |
|
|
}
|
81 |
|
|
include($sAdminPath.'/save.php');
|
82 |
|
|
$user_id = save_user($admin, $aActionRequest);
|
83 |
|
|
$admin = new admin('Access', 'users_modify');
|
84 |
|
|
include($sAdminPath.'/user_form.php');
|
85 |
|
|
$aActionRequest['user_id'] = $user_id;
|
86 |
|
|
$output = show_usermask($admin,$aActionRequest);
|
87 |
|
|
break;
|
88 |
|
|
case 'modify': // insert/update user
|
89 |
|
|
// first check acess to auth users can change his own preferences
|
90 |
|
|
$admin = new admin('Preferences', 'preferences_view',false);
|
91 |
|
|
$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
|
92 |
|
|
// Check if user id is a valid number and doesnt equal 1
|
93 |
|
|
$aActionRequest['user_id'] = $user_id;
|
94 |
|
|
if($user_id == 0){
|
95 |
2065
|
Luisehahne
|
$admin = new admin('Access', 'users');
|
96 |
|
|
msgQueue::clear();
|
97 |
|
|
msgQueue::add($mLang->MESSAGE_GENERIC_FORGOT_OPTIONS );
|
98 |
|
|
$aActionRequest['user_id'] = $user_id;
|
99 |
|
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
100 |
|
|
include($sAdminPath.'/user_list.php');
|
101 |
|
|
$output = show_userlist($admin, $aActionRequest);
|
102 |
|
|
break;
|
103 |
1815
|
Luisehahne
|
}
|
104 |
1492
|
Luisehahne
|
|
105 |
1815
|
Luisehahne
|
if( ($user_id == $admin->get_user_id() ) )
|
106 |
|
|
{
|
107 |
|
|
$sQueryString = (isset($_SERVER['QUERY_STRING'])&& ($_SERVER['QUERY_STRING']!='')) ? $_SERVER['QUERY_STRING'] : 'tool=uaerat';
|
108 |
|
|
$admin->send_header(ADMIN_URL.'/preferences/index.php?'.$sQueryString);
|
109 |
|
|
}
|
110 |
1492
|
Luisehahne
|
|
111 |
1815
|
Luisehahne
|
$admin = new admin('Access', 'users_modify');
|
112 |
1492
|
Luisehahne
|
|
113 |
1815
|
Luisehahne
|
if( ($user_id < 2 ) )
|
114 |
|
|
{
|
115 |
|
|
// if($admin_header) { $admin->print_header(); }
|
116 |
2065
|
Luisehahne
|
msgQueue::add($mLang->MESSAGE_GENERIC_SECURITY_ACCESS );
|
117 |
1815
|
Luisehahne
|
}
|
118 |
|
|
$admin_header = false;
|
119 |
|
|
if(isset($aActionRequest['BackLink'])) {
|
120 |
|
|
$sBackLink = $aActionRequest['BackLink'];
|
121 |
|
|
$aActionRequest['cancel_url'] = $sBackLink;
|
122 |
|
|
$aActionRequest['BackLink'] = $sBackLink;
|
123 |
|
|
} else {
|
124 |
|
|
$sBackLink = (isset($_SERVER['QUERY_STRING'])&& ($_SERVER['QUERY_STRING']!='')) ? $_SERVER['HTTP_REFERER'].'?'.$_SERVER['QUERY_STRING'] : $_SERVER['HTTP_REFERER'];
|
125 |
|
|
$aActionRequest['cancel_url'] = $sBackLink;
|
126 |
|
|
$aActionRequest['BackLink'] = $sBackLink;
|
127 |
|
|
}
|
128 |
|
|
include($sAdminPath.'/user_form.php');
|
129 |
|
|
$output = show_usermask($admin,$aActionRequest);
|
130 |
|
|
break;
|
131 |
|
|
default: // show userlist with empty modify mask
|
132 |
|
|
$admin = new admin('Access', 'users');
|
133 |
|
|
msgQueue::clear();
|
134 |
|
|
$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
|
135 |
|
|
// Check if user id is a valid number and doesnt equal 1
|
136 |
|
|
$aActionRequest['user_id'] = $user_id;
|
137 |
|
|
$aActionRequest['cancel_url'] = ADMIN_URL.'/access/index.php';
|
138 |
|
|
if($user_id > 1) // prevent 'admin' [ID 1] from modify
|
139 |
|
|
{
|
140 |
|
|
include($sAdminPath.'/user_form.php');
|
141 |
|
|
$output .= show_usermask($admin, $aActionRequest);
|
142 |
|
|
} elseif($user_id == 0) { // if invalid UserID is called, fall back to 'show-mode'
|
143 |
|
|
include($sAdminPath.'/user_list.php');
|
144 |
|
|
$output = show_userlist($admin, $aActionRequest);
|
145 |
|
|
}
|
146 |
|
|
endswitch; // end of switch
|
147 |
1823
|
Luisehahne
|
|
148 |
1815
|
Luisehahne
|
if( ($msg = msgQueue::getSuccess()) != '')
|
149 |
|
|
{
|
150 |
|
|
$output = $admin->format_message($msg, 'ok').$output;
|
151 |
|
|
}
|
152 |
|
|
if( ($msg = msgQueue::getError()) != '')
|
153 |
|
|
{
|
154 |
|
|
$output = $admin->format_message($msg, 'error').$output;
|
155 |
|
|
}
|
156 |
1823
|
Luisehahne
|
|
157 |
1815
|
Luisehahne
|
print $output;
|
158 |
1823
|
Luisehahne
|
if( isset($aActionRequest['BackLink']) && isset($aActionRequest['save_back']) ) {
|
159 |
|
|
$sBackLink = $aActionRequest['BackLink'];
|
160 |
|
|
echo "<script type=\"text/javascript\">
|
161 |
|
|
<!--
|
162 |
|
|
// Get the location object
|
163 |
|
|
var locationObj = document.location;
|
164 |
|
|
// Set the value of the location object
|
165 |
|
|
document.location = '$sBackLink';
|
166 |
|
|
-->
|
167 |
|
|
</script>";
|
168 |
|
|
}
|
169 |
1815
|
Luisehahne
|
$admin->print_footer();
|
170 |
1823
|
Luisehahne
|
|
171 |
1815
|
Luisehahne
|
}
|
172 |
1386
|
Luisehahne
|
|
173 |
1815
|
Luisehahne
|
if(!defined('WB_URL'))
|
174 |
|
|
{
|
175 |
|
|
$config_file = realpath('../../config.php');
|
176 |
|
|
if(file_exists($config_file) && !defined('WB_URL'))
|
177 |
|
|
{
|
178 |
|
|
require($config_file);
|
179 |
|
|
}
|
180 |
|
|
}
|
181 |
|
|
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
|
182 |
1386
|
Luisehahne
|
|
183 |
1815
|
Luisehahne
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
184 |
|
|
$aActionRequest = (isset(${$requestMethod})) ? ${$requestMethod} : null;
|
185 |
1804
|
Luisehahne
|
|
186 |
1815
|
Luisehahne
|
admin_users_index($aActionRequest);
|
187 |
|
|
exit;
|
188 |
|
|
// end of file
|