b56d7a511553dc8fb3841f2b1acc6de16611d57a
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) 
56) function doRequest() {
57)   ajax_request(\'su_ajax\', \''.$debug.'q=\'+document.getElementById(\'query\').value, got_response)
58) }
59) 
60) function keyPressed() {
61)   if(window.mytimeout) window.clearTimeout(window.mytimeout);
62)   window.mytimeout = window.setTimeout(doRequest, 500);
63)   return true;
64) }
65) 
66) function got_response() {
67)   if (xmlHttp.readyState == 4) {
68)     document.getElementById(\'response\').innerHTML = xmlHttp.responseText;
69)   }
70) }
71) 
72) // -->
73) </script>
74) ');
75) 
76) output(html_form('su_su_ajax', '', '', '<strong>Suchtext:</strong> <input type="text" id="query" onkeyup="keyPressed()" />
77) '));
78) output('<div id="response"></div>
79) <div style="height: 3em;">&#160;</div>');
80) 
81) 
82) 
bernd Su-Login für Admins

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

96) '));
97) 
98) $customers = list_customers();
99) $options = '';
100) foreach ($customers as $customer)
101) {
102)   $options .= "  <option value=\"{$customer->id}\">{$customer->id} - {$customer->name}</option>\n";
103) }
104) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

110) </p>