ec0c81a8b70e6ac664c291f0e583345d066b7484
bernd webinterface => /webinterface

bernd authored 17 years ago

1) <?php
2) 
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

3) require_once("inc/security.php");
4) 
bernd webinterface => /webinterface

bernd authored 17 years ago

5) function system_failure($reason)
6) {
7)         include('inc/top.php');
bernd Fehlermeldungen hübscher

bernd authored 16 years ago

8)         echo '
bernd webinterface => /webinterface

bernd authored 17 years ago

9)         <h3>Fehler</h3>
bernd Fehlermeldungen hübscher

bernd authored 16 years ago

10)         <div class="error">
11)           <p>Es ist ein Fehler aufgetreten:<br /> '.filter_input_general($reason).'</p>
bernd webinterface => /webinterface

bernd authored 17 years ago

12)         </div>';
13)         include('inc/bottom.php');
14)         die();
15) }
16) 
17) 
18) function input_error($reason)
19) {
20)   global $input_error;
21)   if (!isset($input_error))
22)     $input_error = array();
23)   array_push($input_error, $reason);
24) }
25) 
26) function warning($msg)
27) {
28)   global $warning;
29)   if (!isset($warning))
30)     $warning = array();
31)   array_push($warning, $msg);
32) }
33) 
34) function success_msg($msg)
35) {
36)   global $success_msg;
37)   if (!isset($success_msg))
38)     $success_msg = array();
39)   array_push($success_msg, $msg);
40) }
41) 
42) 
43) function show_messages()
44) {
45)   global $input_error;
46)   global $success_msg;
47)   global $warning;
48)   if (isset($input_error))
49)   {
50)     echo '<div class="error">
51)     <h3>Fehler</h3>
52)     <p>Folgende Fehler wurden festgestellt: </p>
53)     <ul>
54)     ';
55)     foreach ($input_error as $error)
56)     {
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

57)       echo '<li>'.filter_input_general($error)."</li>\n";
bernd webinterface => /webinterface

bernd authored 17 years ago

58)     }
59)     echo '</ul>
60)     </div>';
61)   }
62)   if (isset($warning))
63)   {
64)     echo '<div class="error">
65)     <ul>
66)     ';
67)     foreach ($warning as $msg)
68)     {
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

69)       echo '<li>'.filter_input_general($msg)."</li>\n";
bernd webinterface => /webinterface

bernd authored 17 years ago

70)     }
71)     echo '</ul>
72)     </div>';
73)   }
74)   if (isset($success_msg))
75)   {
76)     echo '<div class="success">
77)     <ul>
78)     ';
79)     foreach ($success_msg as $msg)
80)     {
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

81)       echo '<li>'.filter_input_general($msg)."</li>\n";
bernd webinterface => /webinterface

bernd authored 17 years ago

82)     }
83)     echo '</ul>
84)     </div>';
85)   }
86) }
87) 
88) 
89) function require_role($roles)
90) {
91)   if (! is_array($roles))
92)     $roles = array($roles);
93)   $allow = false;
94)   foreach ($roles as $role)
bernd Nachtrag zum vorigen

bernd authored 16 years ago

95)     if ($role & $_SESSION['role'])
bernd webinterface => /webinterface

bernd authored 17 years ago

96)       $allow = true;
97)   if (! $allow)
bernd Nachtrag zum vorigen

bernd authored 16 years ago

98)     if ($_SESSION['role'] == ROLE_ANONYMOUS)
99)       login_screen("Diese Seite können Sie erst benutzen, wenn Sie sich mit Ihren Zugangsdaten anmelden.");
100)     else
101)       login_screen("Diese Seite können Sie mit Ihren aktuellen Zugriffsrechten nicht benutzen, bitte melden Sie sich mit den benötigten Zugriffsrechten an!");
bernd webinterface => /webinterface

bernd authored 17 years ago

102) }
103) 
104) 
105) function login_screen($why)
106) {
107)         $title = 'Login';
108)         include('inc/top.php');
109)         echo '<h3>Sie sind nicht am System angemeldet!</h3>';
110)         if ($why != "")
111)         {
112)                 echo '<p class="warning"><b>Fehler:</b> '.$why.'</p>';
113)         }
114)         echo '<form action="" method="post">
115)         <p><span class="login_label">Benutzer<sup>*</sup>:</span> <input type="text" name="username" size="30" /></p>
116)         <p><span class="login_label">Passwort:</span> <input type="password" name="password" size="30" /></p>
bernd Entities repariert

bernd authored 16 years ago

117)         <p><span class="login_label">&#160;</span> <input type="submit" value="Anmelden" /></p>