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