75feee8b9da782dc92d0e7ba2f67349942809ed1
bernd Su-Login für Admins

bernd authored 16 years ago

1) <?php
2) 
bernd AJAXified

bernd authored 15 years ago

3) require_once('inc/base.php');
bernd Su-Login für Admins

bernd authored 16 years ago

4) require_once('inc/debug.php');
5) 
6) require_once('session/start.php');
7) require_once('su.php');
8) 
9) require_role(ROLE_SYSADMIN);
10) 
bernd AJAXified

bernd authored 15 years ago

11) if (isset($_GET['type']))
12) {
13)   check_form_token('su_su_ajax', $_GET['formtoken']);
14)   $role = NULL;
bernd back-to-admin feature

bernd authored 15 years ago

15)   $admin_user = $_SESSION['userinfo']['username'];
bernd AJAXified

bernd authored 15 years ago

16)   if ($_GET['type'] == 'customer') {
17)     $role = find_role($_GET['id'], '', True);
18)     setup_session($role, $_GET['id']);
19)   } elseif ($_GET['type'] == 'systemuser') {
20)     $role = find_role($_GET['uid'], '', True);
21)     setup_session($role, $_GET['uid']);
22)   } else {
23)     system_failure('unknown type');
24)   }
bernd back-to-admin feature

bernd authored 15 years ago

25)   $_SESSION['admin_user'] = $admin_user;
bernd AJAXified

bernd authored 15 years ago

26) 
27)   header('Location: ../../go/index/index');
28)   die();
29) }
30) 
bernd Su-Login für Admins

bernd authored 16 years ago

31) if (isset($_POST['submit']))
32) {
33)   check_form_token('su_su');
34)   $id = (int) $_POST['destination'];
35)   $role = find_role($id, '', True);
36)   setup_session($role, $id);
37) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

38)   header('Location: ../../go/index/index');
bernd Su-Login für Admins

bernd authored 16 years ago

39)   die();
40) }
41) 
42) $title = "Benutzer wechseln";
43) 
44) output('<h3>Benutzer wechseln</h3>
45) <p>Hiermit können Sie (als Admin) das Webinterface mit den Rechten eines beliebigen anderen Benutzers benutzen.</p>
bernd Viele XHTML-Fehler korrigie...

bernd authored 16 years ago

46) ');
bernd Su-Login für Admins

bernd authored 16 years ago

47) 
bernd AJAXified

bernd authored 15 years ago

48) $debug = '';
49) if ($debugmode)
50)   $debug = 'debug&amp;';
51) 
52) html_header('<script type="text/javascript" src="'.$prefix.'js/ajax.js" ></script>
53) <script type="text/javascript">
54) 
55) function doRequest() {
56)   ajax_request(\'su_ajax\', \''.$debug.'q=\'+document.getElementById(\'query\').value, got_response)
57) }
58) 
59) function keyPressed() {
60)   if(window.mytimeout) window.clearTimeout(window.mytimeout);
61)   window.mytimeout = window.setTimeout(doRequest, 500);
62)   return true;
63) }
64) 
65) function got_response() {
66)   if (xmlHttp.readyState == 4) {
67)     document.getElementById(\'response\').innerHTML = xmlHttp.responseText;
68)   }
69) }
70) 
71) </script>
72) ');
73) 
74) output(html_form('su_su_ajax', '', '', '<strong>Suchtext:</strong> <input type="text" id="query" onkeyup="keyPressed()" />
75) '));
76) output('<div id="response"></div>
77) <div style="height: 3em;">&#160;</div>');
78) 
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

79) /*
bernd AJAXified

bernd authored 15 years ago

80) 
81) 
bernd Su-Login für Admins

bernd authored 16 years ago

82) $users = list_system_users();
83) $options = '';
84) foreach ($users as $user)
85) {
86)   $options .= "  <option value=\"{$user->uid}\">{$user->username} ({$user->uid})</option>\n";
87) }
88) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

89) output(html_form('su_su', 'su', '', '<p>Benutzer auswählen:
bernd Viele XHTML-Fehler korrigie...

bernd authored 16 years ago

90) <select name="destination" size="1">
bernd Su-Login für Admins

bernd authored 16 years ago

91) '.$options.'
92) </select>
93) <input type="submit" name="submit" value="zum Benutzer wechseln" />
bernd Viele XHTML-Fehler korrigie...

bernd authored 16 years ago

94) </p>
bernd Su-Login für Admins

bernd authored 16 years ago

95) '));
96) 
97) $customers = list_customers();
98) $options = '';
99) foreach ($customers as $customer)
100) {
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

101)   $options .= "  <option value=\"{$customer->id}\">{$customer->id} - ".htmlspecialchars($customer->name)."</option>\n";
bernd Su-Login für Admins

bernd authored 16 years ago

102) }
103) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

104) output(html_form('su_su', 'su', '', '<p>Kunde auswählen:
bernd Viele XHTML-Fehler korrigie...

bernd authored 16 years ago

105) <select name="destination" size="1">
bernd Su-Login für Admins

bernd authored 16 years ago

106) '.$options.'
107) </select>
108) <input type="submit" name="submit" value="zum Kunden wechseln" />
bernd Viele XHTML-Fehler korrigie...

bernd authored 16 years ago

109) </p>
bernd Su-Login für Admins

bernd authored 16 years ago

110) '));
111) 
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

112) */