8a8065ee7b5cb928d0047e433a62d903f659892f
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) 
Bernd Wurst Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

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 Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

25) 
26) function su($type, $id) {
bernd AJAXified

bernd authored 15 years ago

27)   $role = NULL;
bernd back-to-admin feature

bernd authored 15 years ago

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

bernd authored 13 years ago

29)   $_SESSION['admin_user'] = $admin_user;
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

30)   $role = find_role($id, '', True);
31)   if (!$role) {
32)     unset($_SESSION['admin_user']);
33)     return;
34)   }
35)   setup_session($role, $id);
Bernd Wurst su-Modul auf jQuery umgeste...

Bernd Wurst authored 11 years ago

36)   if ($type == 'c') {
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

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)     }
Bernd Wurst su-Modul auf jQuery umgeste...

Bernd Wurst authored 11 years ago

41)   } elseif ($type == 'u') {
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

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
bernd AJAXified

bernd authored 15 years ago

48)     system_failure('unknown type');
49)   }
50) 
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

51)   redirect('../../go/index/index');
bernd AJAXified

bernd authored 15 years ago

52)   die();
53) }
54) 
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

55) if (isset($_GET['do']))
bernd Su-Login für Admins

bernd authored 16 years ago

56) {
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

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) }
bernd Su-Login für Admins

bernd authored 16 years ago

64) 
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

65) if (isset($_POST['query']))
66) {
67)   check_form_token('su_su');
68)   $id = filter_input_general($_POST['query']);
69)   su(NULL, $id);
bernd Su-Login für Admins

bernd authored 16 years ago

70) }
71) 
bernd Benutze überall title() sta...

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 13 years ago

74) 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

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

bernd authored 16 years ago

76) 
bernd AJAXified

bernd authored 15 years ago

77) $debug = '';
78) if ($debugmode)
79)   $debug = 'debug&amp;';
80) 
Bernd Wurst su-Modul auf jQuery umgeste...

Bernd Wurst authored 11 years ago

81) html_header('
82) <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css">
83) <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js" ></script>
84) <script type="text/javascript" src="http://code.jquery.com/ui/1.10.0/jquery-ui.js" ></script>
bernd AJAXified

bernd authored 15 years ago

85) ');
86) 
Bernd Wurst Erlaube auch das Absenden d...

Bernd Wurst authored 11 years ago

87) output(html_form('su_su', '', '', '<label for="query"><strong>Suchtext:</strong></label> <input type="text" name="query" id="query" />
88) '));
Bernd Wurst su-Modul auf jQuery umgeste...

Bernd Wurst authored 11 years ago

89) output('
90) <script>
91) $("#query").autocomplete({
92)     source: "su_ajax",
93)     select: function( event, ui ) {
94)       if (ui.item) {
95)         window.location.href = "?do="+ui.item.id;
96)       }
97) }
98)  });
99) </script>');
bernd AJAXified

bernd authored 15 years ago

100) 
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

101) /*
bernd AJAXified

bernd authored 15 years ago

102) 
103) 
bernd Su-Login für Admins

bernd authored 16 years ago

104) $users = list_system_users();
105) $options = '';
106) foreach ($users as $user)
107) {
108)   $options .= "  <option value=\"{$user->uid}\">{$user->username} ({$user->uid})</option>\n";
109) }
110) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

117) '));
118) 
119) $customers = list_customers();
120) $options = '';
121) foreach ($customers as $customer)
122) {
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

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

bernd authored 16 years ago

124) }
125) 
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

132) '));
133) 
bernd Einige Dummheiten repariert...

bernd authored 14 years ago

134) */