3ef995c2108fe77d22c0b556fb9717cb848bc48f
bernd webinterface => /webinterface

bernd authored 18 years ago

1) <?php
Hanno Böck Add newlines before comment...

Hanno Böck authored 1 month ago

2) 
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 13 years ago

3) /*
4) This file belongs to the Webinterface of schokokeks.org Hosting
5) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

6) Written by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 13 years ago

7)   Bernd Wurst <bernd@schokokeks.org>
8)   Hanno Böck <hanno@schokokeks.org>
9) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

10) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 13 years ago

11) 
12) 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.
13) */
bernd webinterface => /webinterface

bernd authored 18 years ago

14) 
bernd XSS/CSRF-Bugs behoben

bernd authored 17 years ago

15) require_once("inc/security.php");
16) 
bernd webinterface => /webinterface

bernd authored 18 years ago

17) function system_failure($reason)
18) {
Hanno Böck Allows calling system_failu...

Hanno Böck authored 4 years ago

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

Hanno authored 6 years ago

22)     input_error($reason);
23)     show_page();
24)     die();
bernd webinterface => /webinterface

bernd authored 18 years ago

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

Hanno authored 6 years ago

30)     global $input_error;
31)     if (!isset($input_error)) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

32)         $input_error = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

33)     }
34)     array_push($input_error, $reason);
bernd webinterface => /webinterface

bernd authored 18 years ago

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

Hanno authored 6 years ago

39)     if (!isset($_SESSION['warning'])) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

40)         $_SESSION['warning'] = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

41)     }
42)     array_push($_SESSION['warning'], $msg);
43)     $backtrace = debug_backtrace();
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

44)     DEBUG('WARNING:<br>' . $backtrace[0]['file'] . ':' . $backtrace[0]['line'] . ': ' . $msg);
bernd webinterface => /webinterface

bernd authored 18 years ago

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

Hanno authored 6 years ago

49)     if (!isset($_SESSION['success_msg'])) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

50)         $_SESSION['success_msg'] = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

51)     }
52)     array_push($_SESSION['success_msg'], $msg);
bernd webinterface => /webinterface

bernd authored 18 years ago

53) }
54) 
55) 
bernd Erste Version des vmail-Modul

bernd authored 17 years ago

56) function we_have_an_error()
57) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 17 years ago

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

Hanno authored 6 years ago

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

bernd authored 17 years ago

65) }
66) 
67) 
bernd Umstellung auf Theme-Suppor...

bernd authored 14 years ago

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

bernd authored 18 years ago

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

Hanno authored 6 years ago

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

bernd authored 18 years ago

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

Hanno authored 6 years ago

78)         foreach ($input_error as $error) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

80)         }
81)         $messages .= '</ul>
bernd webinterface => /webinterface

bernd authored 18 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

bernd authored 18 years ago

86)     <ul>
87)     ';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

88)         foreach ($_SESSION['warning'] as $msg) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

90)         }
91)         $messages .= '</ul>
bernd webinterface => /webinterface

bernd authored 18 years ago

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

Hanno authored 6 years ago

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

bernd authored 18 years ago

97)     <ul>
98)     ';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

99)         foreach ($_SESSION['success_msg'] as $msg) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

101)         }
102)         $messages .= '</ul>
bernd webinterface => /webinterface

bernd authored 18 years ago

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

Hanno authored 6 years ago

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

bernd authored 18 years ago

107) }
108) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 14 years ago

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

Hanno authored 6 years ago

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

bernd authored 14 years ago

112) }
bernd webinterface => /webinterface

bernd authored 18 years ago

113) 
114) function require_role($roles)
115) {
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

116)     if (!is_array($roles)) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

117)         $roles = [$roles];
Bernd Wurst Blende Aktionen aus, wenn d...

Bernd Wurst authored 7 years ago

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

Hanno authored 6 years ago

119)     $allow = false;
120)     foreach ($roles as $role) {
121)         if ($role & $_SESSION['role']) {
122)             $allow = true;
123)         }
124)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

125)     if (!$allow) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

126)         if ($_SESSION['role'] == ROLE_ANONYMOUS) {
127)             login_screen();
128)         } else {
129)             $backtrace = debug_backtrace();
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

130)             DEBUG($backtrace[0]['file'] . ':' . $backtrace[0]['line'] . ': Current user does not have any of the required roles: ' . implode(",", $roles));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

131)             login_screen("Diese Seite können Sie mit Ihren aktuellen Zugriffsrechten nicht benutzen, bitte melden Sie sich mit den benötigten Zugriffsrechten an!");
132)         }
Bernd Wurst Blende Aktionen aus, wenn d...

Bernd Wurst authored 7 years ago

133)     }
bernd webinterface => /webinterface

bernd authored 18 years ago

134) }
135) 
136) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 18 years ago

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

Bernd Wurst authored 6 years ago

139)     $failed = count_failed_logins();
140)     if ($failed > 5) {
141)         global $title;
142)         $title = '';
143)         system_failure("Zu viele fehlgeschlagenen Login-Versuche! Bitte warten Sie einige Minuten bis zum nächsten Versuch!");
144)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

145)     if (!$why) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

146)         if (isset($_COOKIE['CLIENTCERT_AUTOLOGIN']) && $_COOKIE['CLIENTCERT_AUTOLOGIN'] == '1') {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

147)             redirect("/certlogin/index.php?destination=" . urlencode($_SERVER['REQUEST_URI']));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

148)         }
149)     }
150)     require_once('inc/theme.php');
151)     if ($why) {
152)         warning($why);
153)     }
Bernd Wurst merge passkeys feature

Bernd Wurst authored 1 year ago

154)     if (have_module('loginsecurity')) {
155)         require_once('inc/javascript.php');
156)         javascript('passkey_ajax.js', 'loginsecurity');
157)         javascript('passkey_loginpage.js', 'loginsecurity');
158)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

159)     show_page('login');
160)     die();