8eb4e9f15da8d77b56e5e705727c9c067e5ce460
bernd webinterface => /webinterface

bernd authored 17 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 Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

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 webinterface => /webinterface

bernd authored 17 years ago

16) 
bernd XSS/CSRF-Bugs behoben

bernd authored 17 years ago

17) require_once("inc/security.php");
18) 
bernd webinterface => /webinterface

bernd authored 17 years ago

19) function system_failure($reason)
20) {
Hanno Böck Allows calling system_failu...

Hanno Böck authored 4 years ago

21)     if (!isset($_SESSION['role'])) {
22)         $_SESSION['role'] = ROLE_ANONYMOUS;
23)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

24)     input_error($reason);
25)     show_page();
26)     die();
bernd webinterface => /webinterface

bernd authored 17 years ago

27) }
28) 
29) 
30) function input_error($reason)
31) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

32)     global $input_error;
33)     if (!isset($input_error)) {
34)         $input_error = array();
35)     }
36)     array_push($input_error, $reason);
bernd webinterface => /webinterface

bernd authored 17 years ago

37) }
38) 
39) function warning($msg)
40) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

41)     if (!isset($_SESSION['warning'])) {
42)         $_SESSION['warning'] = array();
43)     }
44)     array_push($_SESSION['warning'], $msg);
45)     $backtrace = debug_backtrace();
46)     DEBUG('WARNING:<br>'.$backtrace[0]['file'].':'.$backtrace[0]['line'].': '.$msg);
bernd webinterface => /webinterface

bernd authored 17 years ago

47) }
48) 
49) function success_msg($msg)
50) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

51)     if (!isset($_SESSION['success_msg'])) {
52)         $_SESSION['success_msg'] = array();
53)     }
54)     array_push($_SESSION['success_msg'], $msg);
bernd webinterface => /webinterface

bernd authored 17 years ago

55) }
56) 
57) 
bernd Erste Version des vmail-Modul

bernd authored 17 years ago

58) function we_have_an_error()
59) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

60)     global $input_error;
bernd Erste Version des vmail-Modul

bernd authored 17 years ago

61) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

62)     if (isset($input_error)) {
63)         return (count($input_error) > 0);
64)     } else {
65)         return 0;
66)     }
bernd Erste Version des vmail-Modul

bernd authored 17 years ago

67) }
68) 
69) 
bernd Umstellung auf Theme-Suppor...

bernd authored 14 years ago

70) function get_messages()
bernd webinterface => /webinterface

bernd authored 17 years ago

71) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

72)     $messages = '';
73)     global $input_error;
74)     if (isset($input_error)) {
75)         $messages .= '<div class="error">
bernd webinterface => /webinterface

bernd authored 17 years ago

76)     <h3>Fehler</h3>
77)     <p>Folgende Fehler wurden festgestellt: </p>
78)     <ul>
79)     ';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

80)         foreach ($input_error as $error) {
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 5 years ago

81)             $messages .= '<li>'.nl2br(filter_output_html($error))."</li>\n";
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

82)         }
83)         $messages .= '</ul>
bernd webinterface => /webinterface

bernd authored 17 years ago

84)     </div>';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

85)     }
86)     if (isset($_SESSION['warning'])) {
Bernd Wurst Warnungen nicht wie Fehler...

Bernd Wurst authored 5 years ago

87)         $messages .= '<div class="warning">
bernd webinterface => /webinterface

bernd authored 17 years ago

88)     <ul>
89)     ';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

90)         foreach ($_SESSION['warning'] as $msg) {
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 5 years ago

91)             $messages .= '<li>'.nl2br(filter_output_html($msg))."</li>\n";
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

92)         }
93)         $messages .= '</ul>
bernd webinterface => /webinterface

bernd authored 17 years ago

94)     </div>';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

95)         unset($_SESSION['warning']);
96)     }
97)     if (isset($_SESSION['success_msg'])) {
98)         $messages .= '<div class="success">
bernd webinterface => /webinterface

bernd authored 17 years ago

99)     <ul>
100)     ';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

101)         foreach ($_SESSION['success_msg'] as $msg) {
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 5 years ago

102)             $messages .= '<li>'.nl2br(filter_output_html($msg))."</li>\n";
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

103)         }
104)         $messages .= '</ul>
bernd webinterface => /webinterface

bernd authored 17 years ago

105)     </div>';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

106)         unset($_SESSION['success_msg']);
107)     }
108)     return $messages;
bernd webinterface => /webinterface

bernd authored 17 years ago

109) }
110) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

111) function show_messages()
bernd Umstellung auf Theme-Suppor...

bernd authored 14 years ago

112) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

113)     echo get_messages();
bernd Umstellung auf Theme-Suppor...

bernd authored 14 years ago

114) }
bernd webinterface => /webinterface

bernd authored 17 years ago

115) 
116) function require_role($roles)
117) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

118)     if (! is_array($roles)) {
119)         $roles = array($roles);
Bernd Wurst Blende Aktionen aus, wenn d...

Bernd Wurst authored 6 years ago

120)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

121)     $allow = false;
122)     foreach ($roles as $role) {
123)         if ($role & $_SESSION['role']) {
124)             $allow = true;
125)         }
126)     }
127)     if (! $allow) {
128)         if ($_SESSION['role'] == ROLE_ANONYMOUS) {
129)             login_screen();
130)         } else {
131)             $backtrace = debug_backtrace();
132)             DEBUG($backtrace[0]['file'].':'.$backtrace[0]['line'].': Current user does not have any of the required roles: '.implode(",", $roles));
133)             login_screen("Diese Seite können Sie mit Ihren aktuellen Zugriffsrechten nicht benutzen, bitte melden Sie sich mit den benötigten Zugriffsrechten an!");
134)         }
Bernd Wurst Blende Aktionen aus, wenn d...

Bernd Wurst authored 6 years ago

135)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

136) }
137) 
138) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

139) function login_screen($why = null)
bernd webinterface => /webinterface

bernd authored 17 years ago

140) {
Bernd Wurst add brute force protection...

Bernd Wurst authored 5 years ago

141)     $failed = count_failed_logins();
142)     if ($failed > 5) {
143)         global $title;
144)         $title = '';
145)         system_failure("Zu viele fehlgeschlagenen Login-Versuche! Bitte warten Sie einige Minuten bis zum nächsten Versuch!");
146)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

147)     if (! $why) {
148)         if (isset($_COOKIE['CLIENTCERT_AUTOLOGIN']) && $_COOKIE['CLIENTCERT_AUTOLOGIN'] == '1') {
149)             redirect("/certlogin/index.php?destination=".urlencode($_SERVER['REQUEST_URI']));
150)         }
151)     }
152)     require_once('inc/theme.php');
153)     if ($why) {
154)         warning($why);
155)     }
156)     show_page('login');
157)     die();