1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Written by Miles Lott <milos@groupwhere.org> * |
---|
6 | * ------------------------------------------------------------------------ * |
---|
7 | * This program is free software; you can redistribute it and/or modify it * |
---|
8 | * under the terms of the GNU General Public License as published by the * |
---|
9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
10 | * option) any later version. * |
---|
11 | \**************************************************************************/ |
---|
12 | |
---|
13 | |
---|
14 | function encryptalgo($config) |
---|
15 | { |
---|
16 | if(@function_exists('mcrypt_list_algorithms')) |
---|
17 | { |
---|
18 | $listed = array(); |
---|
19 | if(!isset($config['mcrypt_algo'])) |
---|
20 | { |
---|
21 | $config['mcrypt_algo'] = 'tripledes'; /* MCRYPT_TRIPLEDES */ |
---|
22 | } |
---|
23 | $algos = @mcrypt_list_algorithms(); |
---|
24 | $found = False; |
---|
25 | |
---|
26 | $out = ''; |
---|
27 | while(list($key,$value) = each($algos)) |
---|
28 | { |
---|
29 | $found = True; |
---|
30 | /* Only show each once - seems this is a problem in some installs */ |
---|
31 | if(!in_array($value,$listed)) |
---|
32 | { |
---|
33 | if($config['mcrypt_algo'] == $value) |
---|
34 | { |
---|
35 | $selected = ' selected'; |
---|
36 | } |
---|
37 | else |
---|
38 | { |
---|
39 | $selected = ''; |
---|
40 | } |
---|
41 | $descr = strtoupper($value); |
---|
42 | |
---|
43 | $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
---|
44 | $listed[] = $value; |
---|
45 | } |
---|
46 | } |
---|
47 | if(!$found) |
---|
48 | { |
---|
49 | /* Something is wrong with their mcrypt install or php.ini */ |
---|
50 | $out = '<option value="">' . lang('no algorithms available') . '</option>' . "\n";; |
---|
51 | } |
---|
52 | } |
---|
53 | else |
---|
54 | { |
---|
55 | $out = '<option value="tripledes">TRIPLEDES</option>' . "\n";; |
---|
56 | } |
---|
57 | return $out; |
---|
58 | } |
---|
59 | |
---|
60 | function encryptmode($config) |
---|
61 | { |
---|
62 | if(@function_exists('mcrypt_list_modes')) |
---|
63 | { |
---|
64 | $listed = array(); |
---|
65 | if(!isset($config['mcrypt_mode'])) |
---|
66 | { |
---|
67 | $config['mcrypt_mode'] = 'cbc'; /* MCRYPT_MODE_CBC */ |
---|
68 | } |
---|
69 | $modes = @mcrypt_list_modes(); |
---|
70 | $found = False; |
---|
71 | |
---|
72 | $out = ''; |
---|
73 | while(list($key,$value) = each($modes)) |
---|
74 | { |
---|
75 | $found = True; |
---|
76 | /* Only show each once - seems this is a problem in some installs */ |
---|
77 | if(!in_array($value,$listed)) |
---|
78 | { |
---|
79 | if($config['mcrypt_mode'] == $value) |
---|
80 | { |
---|
81 | $selected = ' selected'; |
---|
82 | } |
---|
83 | else |
---|
84 | { |
---|
85 | $selected = ''; |
---|
86 | } |
---|
87 | $descr = strtoupper($value); |
---|
88 | |
---|
89 | $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
---|
90 | $listed[] = $value; |
---|
91 | } |
---|
92 | } |
---|
93 | if(!$found) |
---|
94 | { |
---|
95 | /* Something is wrong with their mcrypt install or php.ini */ |
---|
96 | $out = '<option value="" selected>' . lang('no modes available') . '</option>' . "\n"; |
---|
97 | } |
---|
98 | } |
---|
99 | else |
---|
100 | { |
---|
101 | $out = '<option value="cbc" selected>CBC</option>' . "\n"; |
---|
102 | } |
---|
103 | return $out; |
---|
104 | } |
---|
105 | |
---|
106 | function passwdhashes($config) |
---|
107 | { |
---|
108 | $hashes = array( |
---|
109 | 'des' => 'des', |
---|
110 | 'md5' => 'md5' |
---|
111 | ); |
---|
112 | if(@function_exists('mhash')) |
---|
113 | { |
---|
114 | $hashes += array( |
---|
115 | 'smd5' => 'smd5', |
---|
116 | 'sha' => 'sha', |
---|
117 | 'ssha' => 'ssha' |
---|
118 | ); |
---|
119 | } |
---|
120 | |
---|
121 | while(list($key, $value) = each($hashes)) |
---|
122 | { |
---|
123 | if($config['ldap_encryption_type'] == $value) |
---|
124 | { |
---|
125 | $selected = ' selected'; |
---|
126 | } |
---|
127 | else |
---|
128 | { |
---|
129 | $selected = ''; |
---|
130 | } |
---|
131 | $descr = strtoupper($value); |
---|
132 | |
---|
133 | $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
---|
134 | } |
---|
135 | return $out; |
---|
136 | } |
---|
137 | |
---|
138 | function sql_passwdhashes($config) |
---|
139 | { |
---|
140 | $hashes = array( |
---|
141 | 'md5' => 'md5' |
---|
142 | ); |
---|
143 | |
---|
144 | /* Check for available crypt methods based on what is defined by php */ |
---|
145 | if(@defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
---|
146 | { |
---|
147 | $hashes['blowish_crypt'] = 'blowish_crypt'; |
---|
148 | } |
---|
149 | if(@defined('CRYPT_MD5') && CRYPT_MD5 == 1) |
---|
150 | { |
---|
151 | $hashes['md5_crypt'] = 'md5_crypt'; |
---|
152 | } |
---|
153 | if(@defined('CRYPT_EXT_DES') && CRYPT_EXT_DES == 1) |
---|
154 | { |
---|
155 | $hashes['ext_crypt'] = 'ext_crypt'; |
---|
156 | } |
---|
157 | if(@defined('CRYPT_STD_DES') && CRYPT_STD_DES == 1) |
---|
158 | { |
---|
159 | $hashes['crypt'] = 'crypt'; |
---|
160 | } |
---|
161 | |
---|
162 | if(@function_exists('mhash')) |
---|
163 | { |
---|
164 | $hashes += array( |
---|
165 | 'smd5' => 'smd5', |
---|
166 | 'sha' => 'sha', |
---|
167 | 'ssha' => 'ssha' |
---|
168 | ); |
---|
169 | } |
---|
170 | |
---|
171 | while(list($key, $value) = each($hashes)) |
---|
172 | { |
---|
173 | if($config['sql_encryption_type'] == $value) |
---|
174 | { |
---|
175 | $selected = ' selected'; |
---|
176 | } |
---|
177 | else |
---|
178 | { |
---|
179 | $selected = ''; |
---|
180 | } |
---|
181 | $descr = strtoupper($value); |
---|
182 | |
---|
183 | $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
---|
184 | } |
---|
185 | return $out; |
---|
186 | } |
---|
187 | ?> |
---|