Bernd Wurst commited on 2013-01-21 16:28:08
Zeige 1 geänderte Dateien mit 33 Einfügungen und 22 Löschungen.
| ... | ... |
@@ -22,39 +22,51 @@ require_once('su.php');
|
| 22 | 22 |
|
| 23 | 23 |
require_role(ROLE_SYSADMIN); |
| 24 | 24 |
|
| 25 |
-if (isset($_GET['do'])) |
|
| 26 |
-{
|
|
| 27 |
- if ($_SESSION['su_ajax_timestamp'] < time() - 30) {
|
|
| 28 |
- system_failure("Die su-Auswahl ist schon abgelaufen!");
|
|
| 29 |
- } |
|
| 30 |
- $type = $_GET['do'][0]; |
|
| 31 |
- $id = (int) substr($_GET['do'], 1); |
|
| 25 |
+ |
|
| 26 |
+function su($type, $id) {
|
|
| 32 | 27 |
$role = NULL; |
| 33 | 28 |
$admin_user = $_SESSION['userinfo']['username']; |
| 34 | 29 |
$_SESSION['admin_user'] = $admin_user; |
| 35 |
- if ($type == 'c') {
|
|
| 36 | 30 |
$role = find_role($id, '', True); |
| 31 |
+ if (!$role) {
|
|
| 32 |
+ unset($_SESSION['admin_user']); |
|
| 33 |
+ return; |
|
| 34 |
+ } |
|
| 37 | 35 |
setup_session($role, $id); |
| 36 |
+ if ($type == 'c') {
|
|
| 37 |
+ if (! (ROLE_CUSTOMER & $_SESSION['role'])) {
|
|
| 38 |
+ session_destroy(); |
|
| 39 |
+ system_failure('Es wurde ein "su" zu einem Kundenaccount angefordert, das war aber kein Kundenaccount!');
|
|
| 40 |
+ } |
|
| 38 | 41 |
} elseif ($type == 'u') {
|
| 39 |
- $role = find_role($id, '', True); |
|
| 40 |
- setup_session($role, $id); |
|
| 41 |
- } else {
|
|
| 42 |
+ if (! (ROLE_SYSTEMUSER & $_SESSION['role'])) {
|
|
| 43 |
+ session_destroy(); |
|
| 44 |
+ system_failure('Es wurde ein "su" zu einem Benutzeraccount angefordert, das war aber kein Benutzeraccount!');
|
|
| 45 |
+ } |
|
| 46 |
+ } elseif ($type) {
|
|
| 47 |
+ // wenn type leer ist, dann ist es auch egal |
|
| 42 | 48 |
system_failure('unknown type');
|
| 43 | 49 |
} |
| 44 | 50 |
|
| 45 |
- header('Location: ../../go/index/index');
|
|
| 51 |
+ redirect('../../go/index/index');
|
|
| 46 | 52 |
die(); |
| 47 | 53 |
} |
| 48 | 54 |
|
| 49 |
-if (isset($_POST['submit'])) |
|
| 55 |
+if (isset($_GET['do'])) |
|
| 50 | 56 |
{
|
| 51 |
- check_form_token('su_su');
|
|
| 52 |
- $id = (int) $_POST['destination']; |
|
| 53 |
- $role = find_role($id, '', True); |
|
| 54 |
- setup_session($role, $id); |
|
| 57 |
+ if ($_SESSION['su_ajax_timestamp'] < time() - 30) {
|
|
| 58 |
+ system_failure("Die su-Auswahl ist schon abgelaufen!");
|
|
| 59 |
+ } |
|
| 60 |
+ $type = $_GET['do'][0]; |
|
| 61 |
+ $id = (int) substr($_GET['do'], 1); |
|
| 62 |
+ su($type, $id); |
|
| 63 |
+} |
|
| 55 | 64 |
|
| 56 |
- header('Location: ../../go/index/index');
|
|
| 57 |
- die(); |
|
| 65 |
+if (isset($_POST['query'])) |
|
| 66 |
+{
|
|
| 67 |
+ check_form_token('su_su');
|
|
| 68 |
+ $id = filter_input_general($_POST['query']); |
|
| 69 |
+ su(NULL, $id); |
|
| 58 | 70 |
} |
| 59 | 71 |
|
| 60 | 72 |
title("Benutzer wechseln");
|
| ... | ... |
@@ -72,9 +84,8 @@ html_header('
|
| 72 | 84 |
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.0/jquery-ui.js" ></script> |
| 73 | 85 |
'); |
| 74 | 86 |
|
| 75 |
-output('<label for="query"><strong>Suchtext:</strong></label> <input type="text" id="query" />
|
|
| 76 |
-<input type="hidden" id="query_id" name="query_id" /> |
|
| 77 |
-'); |
|
| 87 |
+output(html_form('su_su', '', '', '<label for="query"><strong>Suchtext:</strong></label> <input type="text" name="query" id="query" />
|
|
| 88 |
+')); |
|
| 78 | 89 |
output('
|
| 79 | 90 |
<script> |
| 80 | 91 |
$("#query").autocomplete({
|
| 81 | 92 |