1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Written by Mark Peters <skeeter@phpgroupware.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 | while (list ($key, $value) = each ($algos)) |
---|
27 | { |
---|
28 | $found = True; |
---|
29 | /* Only show each once - seems this is a problem in some installs */ |
---|
30 | if(!in_array($value,$listed)) |
---|
31 | { |
---|
32 | if ($config['mcrypt_algo'] == $value) |
---|
33 | { |
---|
34 | $selected = ' selected'; |
---|
35 | } |
---|
36 | else |
---|
37 | { |
---|
38 | $selected = ''; |
---|
39 | } |
---|
40 | $descr = strtoupper($value); |
---|
41 | |
---|
42 | $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
---|
43 | $listed[] = $value; |
---|
44 | } |
---|
45 | } |
---|
46 | if(!$found) |
---|
47 | { |
---|
48 | /* Something is wrong with their mcrypt install or php.ini */ |
---|
49 | $out = '<option value="">' . lang('no algorithms available') . '</option>' . "\n";; |
---|
50 | } |
---|
51 | } |
---|
52 | else |
---|
53 | { |
---|
54 | $out = '<option value="tripledes">TRIPLEDES</option>' . "\n";; |
---|
55 | } |
---|
56 | return $out; |
---|
57 | } |
---|
58 | |
---|
59 | function encryptmode($config) |
---|
60 | { |
---|
61 | if(@function_exists('mcrypt_list_modes')) |
---|
62 | { |
---|
63 | $listed = array(); |
---|
64 | if(!isset($config['mcrypt_mode'])) |
---|
65 | { |
---|
66 | $config['mcrypt_mode'] = 'cbc'; /* MCRYPT_MODE_CBC */ |
---|
67 | } |
---|
68 | $modes = @mcrypt_list_modes(); |
---|
69 | $found = False; |
---|
70 | |
---|
71 | while (list ($key, $value) = each ($modes)) |
---|
72 | { |
---|
73 | $found = True; |
---|
74 | /* Only show each once - seems this is a problem in some installs */ |
---|
75 | if(!in_array($value,$listed)) |
---|
76 | { |
---|
77 | if ($config['mcrypt_mode'] == $value) |
---|
78 | { |
---|
79 | $selected = ' selected'; |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | $selected = ''; |
---|
84 | } |
---|
85 | $descr = strtoupper($value); |
---|
86 | |
---|
87 | $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
---|
88 | $listed[] = $value; |
---|
89 | } |
---|
90 | } |
---|
91 | if(!$found) |
---|
92 | { |
---|
93 | /* Something is wrong with their mcrypt install or php.ini */ |
---|
94 | $out = '<option value="" selected>' . lang('no modes available') . '</option>' . "\n"; |
---|
95 | } |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | $out = '<option value="cbc" selected>CBC</option>' . "\n"; |
---|
100 | } |
---|
101 | return $out; |
---|
102 | } |
---|
103 | ?> |
---|