af8c8976d00517b7f243fb1b0cff70dcf8801a65
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) {
55)   if ($input != filter_input_general($input))
56)     return False;
57)   DEBUG("checking {$input} for valid path name");
58)   $components = explode("/", $input);
59)   foreach ($components AS $item)
60)   {
61)     if ($item == '..')
62)     {
63)       return False;
64)     }
65)   }
66)   return (preg_match('/^[a-z0-9.\/_-]*$/',$input) == 1);
67) }
68) 
69) 
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

70) function check_emailaddr( $input )
71) {
72)         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);
73) }
74)