4278a08ceb247fb934bc0217da9704d96935b51b
bernd input-filtering

bernd authored 16 years ago

1) <?php
2) 
3) 
bernd * Passwörter mit cracklib p...

bernd authored 16 years ago

4) function strong_password($password)
5) {
6)   include("config.php");
7)   DEBUG("Öffne Wörterbuch: {$config['cracklib_dict']}");
8)   if (! ($dict = crack_opendict($config['cracklib_dict'])))
9)   {
10)     logger("inc/security.php", "cracklib", "could not open cracklib-dictionary »{$config['cracklib_dict']}«");
11)     system_failure("Kann Crack-Lib-Wörterbuch nicht öffnen: {$config['cracklib_dict']}");
12)   }
13)   // Führe eine Überprüfung des Passworts durch
14)   $check = crack_check($dict, $password);
15) 
16)   $message = crack_getlastmessage();
17)   crack_closedict($dict);
18) 
19)   if ($check === True)
20)   {
21)     DEBUG("Passwort ok");
22)     return true;
23)   }
24)   else
25)   {
26)     DEBUG("Passwort nicht ok: {$message}");
27)     return $message;
28)   }
29) }
30) 
31) 
bernd input-filtering

bernd authored 16 years ago

32) function filter_input_general( $input )
33) {
34)         return htmlspecialchars(iconv('UTF-8', 'UTF-8', $input), ENT_QUOTES, 'UTF-8');
35) }
36) 
37) 
38) function filter_input_username( $input )
39) {
40)         return ereg_replace("[^[:alnum:]\_\.\+\-]", "", $input );
41) }
42) 
bernd Im Passwort dürfen auch kei...

bernd authored 16 years ago

43) function filter_quotes( $input )
44) {
45)         return ereg_replace('["\'`]', '', $input );
46) }
47) 
bernd Diverse shell-kritische zei...

bernd authored 16 years ago

48) function filter_shell( $input )
49) {
bernd shell-escaping braucht whit...

bernd authored 16 years ago

50)         return ereg_replace('[^-[:alnum:]\_\.\+ßäöüÄÖÜ/%§=]', '', $input );
bernd Diverse shell-kritische zei...

bernd authored 16 years ago

51) }
bernd input-filtering

bernd authored 16 years ago

52) 
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

53) function check_path( $input )
54) {
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

55)   DEBUG("checking {$input} for valid path name");
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

56)   if ($input != filter_input_general($input))
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

57)   {
58)     DEBUG("HTML-Krams im Pfad");
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

59)     return False;
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

60)   }
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

61)   $components = explode("/", $input);
62)   foreach ($components AS $item)
63)   {
64)     if ($item == '..')
65)     {
66)       return False;
67)     }
68)   }
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

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

bernd authored 16 years ago

70) }
71) 
72) 
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

73) function check_emailaddr( $input )
74) {
75)         return (preg_match("/^[a-z]+[a-z0-9]*[\.|\-|_]?[a-z0-9]+@([a-z0-9]*[\.|\-]?[a-z0-9]+){1,4}\.[a-z]{2,4}$/i", $input ) == 1);
76) }
77)