523f8e81d72a7fecae675a1dad3e50a18f525672
bernd input-filtering

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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

5) Written 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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

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

Bernd Wurst authored 12 years ago

10) 
11) 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.
12) */
bernd input-filtering

bernd authored 16 years ago

13) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

14) require_once('inc/error.php');
Hanno Böck move crypt password hash ve...

Hanno Böck authored 5 months ago

15) require_once('inc/base.php');
Hanno Böck replace cracklib with zxcvbn

Hanno Böck authored 7 years ago

16) require_once('vendor/autoload.php');
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

17) 
Hanno Böck move crypt password hash ve...

Hanno Böck authored 5 months ago

18) function gen_pw_hash($password)
19) {
20)     $pwhash = crypt($password, '$6$' . random_string(6));
21)     if (strlen($pwhash) < 13) {
22)         /* returns a string shorter than 13 chars on failure */
23)         system_failure("Failed to calculate password hash!");
24)     }
25)     return $pwhash;
26) }
27) 
28) function check_pw_hash($password, $pwhash)
29) {
30)     $checkhash = crypt($password, $pwhash);
31)     if (strlen($checkhash) < 13) {
32)         /* returns a string shorter than 13 chars on failure */
33)         system_failure("Invalid password hash!");
34)     }
35)     return hash_equals($checkhash, $pwhash);
36) }
bernd input-filtering

bernd authored 16 years ago

37) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

38) function strong_password($password, $user = [])
bernd * Passwörter mit cracklib p...

bernd authored 16 years ago

39) {
Bernd Wurst support online check for pa...

Bernd Wurst authored 5 years ago

40)     $pwcheck = config('pwcheck');
41)     $result = null;
42)     if ($pwcheck) {
43)         DEBUG($pwcheck);
Bernd Wurst use POST for password checker

Bernd Wurst authored 5 years ago

44)         $req = curl_init($pwcheck);
Bernd Wurst support online check for pa...

Bernd Wurst authored 5 years ago

45)         curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
46)         curl_setopt($req, CURLOPT_SSL_VERIFYPEER, 1);
47)         curl_setopt($req, CURLOPT_SSL_VERIFYSTATUS, 1);
48)         curl_setopt($req, CURLOPT_CONNECTTIMEOUT, 5);
49)         curl_setopt($req, CURLOPT_TIMEOUT, 5);
50)         curl_setopt($req, CURLOPT_FOLLOWLOCATION, 0);
Bernd Wurst use POST for password checker

Bernd Wurst authored 5 years ago

51)         curl_setopt($req, CURLOPT_POST, 1);
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

52)         curl_setopt($req, CURLOPT_POSTFIELDS, "password=" . urlencode($password));
Bernd Wurst support online check for pa...

Bernd Wurst authored 5 years ago

53)         $result = chop(curl_exec($req));
54)         DEBUG($result);
55)     }
56)     if ($result === 'good') {
57)         return true;
58)     } elseif ($result === 'bad') {
Bernd Wurst better error message for we...

Bernd Wurst authored 5 years ago

59)         return "Unsere Überprüfung hat ergeben, dass dieses Passwort in bisher veröffentlichten Passwortlisten enthalten ist. Es wird daher nicht akzeptiert.";
Bernd Wurst support online check for pa...

Bernd Wurst authored 5 years ago

60)     }
Bernd Wurst use Zxcvbn as fallback in e...

Bernd Wurst authored 5 years ago

61)     // Kein Online-Check eingerichtet oder der request war nicht erfolgreich
62)     DEBUG('using Zxcvbn for password check!');
63)     $passwordchecker = new ZxcvbnPhp\Zxcvbn();
Bernd Wurst PHP 8.0 compatibility

Bernd Wurst authored 3 years ago

64)     if ($user) {
65)         $strength = $passwordchecker->passwordStrength($password, $user);
66)     } else {
67)         $strength = $passwordchecker->passwordStrength($password);
68)     }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

69)     DEBUG('password strength: ' . $strength['score']);
Bernd Wurst use Zxcvbn as fallback in e...

Bernd Wurst authored 5 years ago

70)     if ($strength['score'] < 2) {
71)         return "Das Passwort ist zu einfach!";
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

72)     }
73)     return true;
bernd * Passwörter mit cracklib p...

bernd authored 16 years ago

74) }
75) 
76) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

77) function filter_input_general($input)
bernd input-filtering

bernd authored 16 years ago

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

Hanno authored 5 years ago

79)     if ($input === null) {
80)         return null;
81)     }
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 4 years ago

82)     $input = (string) $input;
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

83)     $filtered = preg_replace('/[\x00-\x09\x0b-\x0c\x0e-\x1f]/', '', $input);
84)     if ($filtered !== $input) {
85)         system_failure("Ihre Daten enthielten ungültige Zeichen!");
86)         logger(LOG_WARNING, 'inc/security', 'filter_input_general', 'Ungültige Daten!');
87)     }
88)     return $filtered;
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

89) }
90) 
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

91) function filter_input_oneline($input)
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

92) {
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

93)     if ($input === null) {
94)         return null;
95)     }
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 4 years ago

96)     $input = (string) $input;
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

97)     $filtered = preg_replace('/[\x00-\x1f]/', '', $input);
98)     if ($filtered !== $input) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

99)         system_failure("Ihre Daten enthielten ungültige Zeichen!");
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 4 years ago

100)         logger(LOG_WARNING, 'inc/security', 'filter_input_oneline', 'Ungültige Daten!');
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

101)     }
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

102)     return $filtered;
bernd input-filtering

bernd authored 16 years ago

103) }
104) 
105) 
Bernd Wurst New function filter_output_...

Bernd Wurst authored 4 years ago

106) function filter_output_html($data)
107) {
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

108)     if (!$data) {
Bernd Wurst upgrade dependancies

Bernd Wurst authored 2 years ago

109)         return "";
110)     }
Bernd Wurst New function filter_output_...

Bernd Wurst authored 4 years ago

111)     return htmlspecialchars($data, ENT_QUOTES);
112) }
113) 
114) 
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

115) function verify_input_ascii($data)
116) {
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 4 years ago

117)     $data = (string) $data;
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

118)     $filtered = filter_var($data, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
119)     if ($filtered != $data) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

120)         logger(LOG_WARNING, 'inc/security', 'verify_input_ascii', 'Ungültige Daten: ' . $data);
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

121)         system_failure("Ihre Eingabe enthielt ungültige Zeichen");
122)     }
123)     return $filtered;
124) }
125) 
126) 
127) function verify_input_identifier($data)
128) {
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 4 years ago

129)     $data = (string) $data;
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

130)     if ($data === "") {
131)         system_failure("Leerer Bezeichner");
132)     }
133)     $filtered = preg_replace("/[^[:alnum:]\_\.\-]/", "", $data);
134)     if ($filtered !== $data) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

135)         logger(LOG_WARNING, 'inc/security', 'verify_input_identifier', 'Ungültige Daten: ' . $data);
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

136)         system_failure("Ihre Daten enthielten ungültige Zeichen!");
137)     }
138)     return $filtered;
139) }
140) 
Bernd Wurst New function filter_output_...

Bernd Wurst authored 4 years ago

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

Hanno authored 5 years ago

142) function filter_input_username($input)
bernd input-filtering

bernd authored 16 years ago

143) {
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

144)     $username = preg_replace("/[^[:alnum:]\_\.\+\-]/", "", $input);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

145)     if ($username === "") {
146)         system_failure("Leerer Benutzername!");
147)     }
148)     return $username;
hanno Hatte die Kompatibilität ge...

hanno authored 16 years ago

149) }
150) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

151) function verify_input_username($input)
hanno Hatte die Kompatibilität ge...

hanno authored 16 years ago

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

Hanno authored 5 years ago

153)     if (filter_input_username($input) != $input) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

154)         logger(LOG_WARNING, 'inc/security', 'verify_input_username', 'Ungültige Daten: ' . $input);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

155)         system_failure("Ihre Daten enthielten ungültige Zeichen!");
156)     }
bernd input-filtering

bernd authored 16 years ago

157) }
158) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

159) 
160) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 8 months ago

161) function filter_input_hostname($input, $wildcard = false)
bernd check auf hostname

bernd authored 16 years ago

162) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

163)     DEBUG('filter_input_hostname("' . $input . '", $wildcard=' . $wildcard . ')');
Hanno Spezialbehandlung für äöü n...

Hanno authored 5 years ago

164)     $input = strtolower($input);
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

165)     $input = trim($input, "\t\n\r\x00 .");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

166)     if (preg_replace("/[^.]_/", "", $input) != $input) {
167)         system_failure("Der Unterstrich ist nur als erstes Zeichen eines Hostnames erlaubt.");
168)     }
Hanno Spezialbehandlung für äöü n...

Hanno authored 5 years ago

169)     if (preg_replace("/[^[:alnum:]_*\.\-]/u", "", $input) != $input) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

170)         system_failure("Ihre Daten enthielten ungültige Zeichen!");
171)     }
172)     if (preg_match("/^.+\*/", $input)) {
173)         system_failure("Ihre Daten enthielten ungültige Zeichen (Wildcard-Stern muss ganz vorne stehen)!");
174)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

175)     if (!$wildcard && preg_replace("/^\*/", "", $input) != $input) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

176)         system_failure("Ihre Daten enthielten ungültige Zeichen (Keine Wildcards erlaubt)!");
177)     }
178)     if (strstr($input, '..')) {
179)         system_failure("Ungültiger Hostname");
180)     }
181)     return $input;
bernd check auf hostname

bernd authored 16 years ago

182) }
183) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 8 months ago

184) function verify_input_hostname($input, $wildcard = false)
bernd Add IP-address patterns

bernd authored 15 years ago

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

Hanno authored 5 years ago

186)     if (filter_input_hostname($input, $wildcard) != $input) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

187)         logger(LOG_WARNING, 'inc/security', 'verify_input_hostname', 'Ungültige Daten: ' . $input);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

188)         system_failure("Ihre Daten enthielten ungültige Zeichen!");
189)     }
bernd Add IP-address patterns

bernd authored 15 years ago

190) }
191) 
192) 
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

193) function verify_input_hostname_utf8($input)
194) {
195)     $puny = idn_to_ascii($input, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
196)     if ($puny === false) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

197)         system_failure("Ungültiger Hostname! idn " . $input);
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

198)     }
199)     $filter = filter_var($puny, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

200)     if ($filter !== $puny) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

201)         system_failure("Ungültiger Hostname! filter " . $input);
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

202)     }
203) }
204) 
205) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

206) function verify_input_ipv4($input)
bernd Add IP-address patterns

bernd authored 15 years ago

207) {
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

208)     if (!preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $input)) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

209)         system_failure('Keine IP-Adresse');
210)     }
bernd Add IP-address patterns

bernd authored 15 years ago

211) }
212) 
213) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

214) function verify_input_ipv6($input)
bernd Add IP-address patterns

bernd authored 15 years ago

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

Hanno authored 5 years ago

216)     // ripped from Perl module Net-IPv6Addr v0.2
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

217)     if (!preg_match("/^(([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|[0-9a-f]{0,4}::|:(?::[a-f0-9]{1,4}){1,6}|(?:[a-f0-9]{1,4}:){1,6}:|(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,6}|(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,5}|(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,4}|(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}){1,3}|(?:[a-f0-9]{1,4}:){5}(?::[a-f0-9]{1,4}){1,2}|(?:[a-f0-9]{1,4}:){6}(?::[a-f0-9]{1,4}))$/i", $input)) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

218)         system_failure("Ungültige IPv6-Adresse");
219)     }
bernd Add IP-address patterns

bernd authored 15 years ago

220) }
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

Hanno authored 5 years ago

222) function verify_input_recorddata($input)
Hanno Böck Prüfe DNS-Records auf probl...

Hanno Böck authored 7 years ago

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

Hanno authored 5 years ago

224)     if (strstr($input, "\\") || strstr($input, '"')) {
225)         system_failure("Ungültige Zeichen");
226)     }
Hanno Böck Prüfe DNS-Records auf probl...

Hanno Böck authored 7 years ago

227) }
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

Hanno authored 5 years ago

229) function filter_quotes($input)
bernd Im Passwort dürfen auch kei...

bernd authored 16 years ago

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

Hanno authored 5 years ago

231)     return preg_replace('/["\'`]/', '', $input);
bernd Im Passwort dürfen auch kei...

bernd authored 16 years ago

232) }
233) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

234) 
235) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

236) function filter_shell($input)
bernd Diverse shell-kritische zei...

bernd authored 16 years ago

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

Hanno authored 5 years ago

238)     return preg_replace('/[^-[:alnum:]\_\.\+ßäöüÄÖÜ/%§=]/', '', $input);
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

239) }
240) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

241) function verify_shell($input)
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

Hanno authored 5 years ago

243)     if (filter_shell($input) != $input) {
244)         system_failure("Ihre Daten enthielten ungültige Zeichen!");
245)     }
bernd Diverse shell-kritische zei...

bernd authored 16 years ago

246) }
bernd input-filtering

bernd authored 16 years ago

247) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

248) 
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

249) function filter_ssh_key($key)
250) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

251)     $keyparts = explode(" ", trim($key));
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

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

Hanno authored 5 years ago

253)     if ((count($keyparts) > 3) || (count($keyparts) < 2)) {
254)         system_failure("Ungültiger SSH-Key!");
255)     }
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

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

Hanno authored 5 years ago

257)     if (preg_match("/^[a-z0-9]+-[a-z0-9-]+$/", $keyparts[0]) === 0) {
258)         system_failure("Ungültiger SSH-Key!");
259)     }
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

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

Hanno authored 5 years ago

261)     if (base64_decode($keyparts[1], 1) == false) {
262)         system_failure("Ungültiger SSH-Key!");
263)     }
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

264) 
Hanno Böck fix regular expression (was...

Hanno Böck authored 3 years ago

265)     if ((count($keyparts) === 3) && (preg_match("/^[a-zA-Z0-9@._-]+$/", $keyparts[2]) === 0)) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

266)         system_failure("Ungültige Zeichen im Kommentar des SSH-Keys!");
267)     }
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

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

Hanno authored 5 years ago

269)     if (count($keyparts) === 2) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

270)         return $keyparts[0] . " " . $keyparts[1];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

271)     } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

272)         return $keyparts[0] . " " . $keyparts[1] . " " . $keyparts[2];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

273)     }
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

274) }
275) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

Hanno authored 5 years ago

277) function check_path($input)
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

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

Hanno authored 5 years ago

279)     DEBUG("checking {$input} for valid path name");
Bernd Wurst New function filter_output_...

Bernd Wurst authored 4 years ago

280)     if ($input != filter_output_html($input)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

281)         logger(LOG_WARNING, 'inc/security', 'check_path', 'HTML-Krams im Pfad: ' . $input);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

282)         DEBUG("HTML-Krams im Pfad");
283)         return false;
284)     }
285)     $components = explode("/", $input);
286)     foreach ($components as $item) {
287)         if ($item == '..') {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

288)             logger(LOG_WARNING, 'inc/security', 'check_path', '»..« im Pfad: ' . $input);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

289)             DEBUG("»..« im Pfad");
290)             return false;
291)         }
Hanno prevent breaking kvhostcrea...

Hanno authored 5 years ago

292)         if (strlen($item) > 255) {
293)             return false;
294)         }
295)     }
296)     if (strlen($input) > 2048) {
297)         return false;
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

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

Hanno authored 5 years ago

299)     return (preg_match('/^[ A-Za-z0-9.@\/_-]*$/', $input) == 1);
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

300) }
301) 
302) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

303) function in_homedir($path)
304) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

305)     DEBUG("Prüfe »{$path}«");
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

306)     if (!check_path($path)) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

307)         DEBUG('Kein Pfad');
308)         return false;
309)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

310)     if (!isset($_SESSION['userinfo']['homedir'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

311)         DEBUG("Kann homedir nicht ermitteln");
312)         return false;
313)     }
Bernd Wurst Syntaxfehler

Bernd Wurst authored 5 years ago

314)     return strncmp($_SESSION['userinfo']['homedir'], $path, strlen($_SESSION['userinfo']['homedir'])) == 0;
bernd * alle internen Links sinnv...

bernd authored 15 years ago

315) }
316) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

317) function check_date($input)
Bernd Wurst Erste Version des SEPA-Mand...

Bernd Wurst authored 10 years ago

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

Hanno authored 5 years ago

319)     return (bool) preg_match("/[0-9]{4}-(0?[1-9]|10|11|12)-([012]?[0-9]|30|31)/", $input);
Bernd Wurst Erste Version des SEPA-Mand...

Bernd Wurst authored 10 years ago

320) }
321) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

Hanno authored 5 years ago

323) function check_emailaddr($input)
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

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

Hanno authored 5 years ago

325)     return (bool) filter_var($input, FILTER_VALIDATE_EMAIL) == $input;
bernd don't be too complicated. /...

bernd authored 16 years ago

326) }
327) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

328) function check_domain($input)
bernd don't be too complicated. /...

bernd authored 16 years ago

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

Hanno authored 5 years ago

330)     return (bool) preg_match("/^[a-z0-9\.\-]+\.[a-z\-]{2,63}$/i", $input);
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

331) }