838077f18b71321a685c84329342e6a711d22d09
bernd Su-Login für Admins

bernd authored 16 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
5) Written 2008-2012 by schokokeks.org Hosting, namely
6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd Su-Login für Admins

bernd authored 16 years ago

16) 
bernd AJAXified

bernd authored 15 years ago

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

bernd authored 16 years ago

18) require_once('inc/debug.php');
19) 
20) require_once('session/start.php');
21) require_once('su.php');
22) 
23) require_role(ROLE_SYSADMIN);
24) 
bernd AJAXified

bernd authored 15 years ago

25) if (isset($_GET['type']))
26) {
27)   check_form_token('su_su_ajax', $_GET['formtoken']);
28)   $role = NULL;
bernd back-to-admin feature

bernd authored 15 years ago

29)   $admin_user = $_SESSION['userinfo']['username'];
bernd Setze lastlogin nur bei Nic...

bernd authored 13 years ago

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

bernd authored 15 years ago

31)   if ($_GET['type'] == 'customer') {
32)     $role = find_role($_GET['id'], '', True);
33)     setup_session($role, $_GET['id']);
34)   } elseif ($_GET['type'] == 'systemuser') {
35)     $role = find_role($_GET['uid'], '', True);
36)     setup_session($role, $_GET['uid']);
37)   } else {
38)     system_failure('unknown type');
39)   }
40) 
41)   header('Location: ../../go/index/index');
42)   die();
43) }
44) 
bernd Su-Login für Admins

bernd authored 16 years ago

45) if (isset($_POST['submit']))
46) {
47)   check_form_token('su_su');
48)   $id = (int) $_POST['destination'];
49)   $role = find_role($id, '', True);
50)   setup_session($role, $id);
51) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

53)   die();
54) }
55) 
bernd Benutze überall title() sta...

bernd authored 13 years ago

56) title("Benutzer wechseln");
bernd Su-Login für Admins

bernd authored 16 years ago

57) 
bernd Benutze überall title() sta...

bernd authored 13 years ago

58) output('<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

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

bernd authored 16 years ago

60) 
bernd AJAXified

bernd authored 15 years ago

61) $debug = '';
62) if ($debugmode)
63)   $debug = 'debug&amp;';
64) 
65) html_header('<script type="text/javascript" src="'.$prefix.'js/ajax.js" ></script>
66) <script type="text/javascript">
67) 
68) function doRequest() {
69)   ajax_request(\'su_ajax\', \''.$debug.'q=\'+document.getElementById(\'query\').value, got_response)
70) }
71) 
72) function keyPressed() {
73)   if(window.mytimeout) window.clearTimeout(window.mytimeout);
74)   window.mytimeout = window.setTimeout(doRequest, 500);
75)   return true;
76) }
77) 
78) function got_response() {
79)   if (xmlHttp.readyState == 4) {
80)     document.getElementById(\'response\').innerHTML = xmlHttp.responseText;
81)   }
82) }
83) 
84) </script>
85) ');
86) 
87) output(html_form('su_su_ajax', '', '', '<strong>Suchtext:</strong> <input type="text" id="query" onkeyup="keyPressed()" />
88) '));
89) output('<div id="response"></div>
90) <div style="height: 3em;">&#160;</div>');
91) 
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

92) /*
bernd AJAXified

bernd authored 15 years ago

93) 
94) 
bernd Su-Login für Admins

bernd authored 16 years ago

95) $users = list_system_users();
96) $options = '';
97) foreach ($users as $user)
98) {
99)   $options .= "  <option value=\"{$user->uid}\">{$user->username} ({$user->uid})</option>\n";
100) }
101) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

108) '));
109) 
110) $customers = list_customers();
111) $options = '';
112) foreach ($customers as $customer)
113) {
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

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

bernd authored 16 years ago

115) }
116) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

123) '));
124) 
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

125) */