1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * Expresso - Expresso Messenger * |
---|
4 | * - Alexandre Correia / Rodrigo Souza * |
---|
5 | * - JETI - http://jeti-im.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 | class fileDefine |
---|
14 | { |
---|
15 | public final function ldapExternal($pConfLdap) |
---|
16 | { |
---|
17 | $file = "confLDAPExternal.php"; |
---|
18 | $writeFile = "<?php $"."LDAP_EXTERNAL="."\"".base64_encode(serialize($pConfLdap))."\""." ?>"; |
---|
19 | |
---|
20 | return $this->writeFile($writeFile, $file); |
---|
21 | } |
---|
22 | |
---|
23 | public final function ldapInternal($pParam) |
---|
24 | { |
---|
25 | $array_values = explode("\n", $pParam['val']); |
---|
26 | $file = "confLDAPInternal.php"; |
---|
27 | $infoServer = array(); |
---|
28 | |
---|
29 | foreach($array_values as $tmp ) |
---|
30 | { |
---|
31 | $nvalue = explode(";", $tmp); |
---|
32 | |
---|
33 | switch(trim($nvalue[0])) |
---|
34 | { |
---|
35 | case "JETTI_NAME_JABBERIT" : |
---|
36 | $infoServer['jabberName'] = $nvalue[1]; |
---|
37 | break; |
---|
38 | |
---|
39 | case "JETTI_SERVER_LDAP_JABBERIT" : |
---|
40 | $infoServer['serverLdap'] = $nvalue[1]; |
---|
41 | break; |
---|
42 | |
---|
43 | case "JETTI_CONTEXT_LDAP_JABBERIT" : |
---|
44 | $infoServer['contextLdap'] = $nvalue[1]; |
---|
45 | break; |
---|
46 | |
---|
47 | case "JETTI_USER_LDAP_JABBERIT" : |
---|
48 | $infoServer['user'] = $nvalue[1]; |
---|
49 | break; |
---|
50 | |
---|
51 | case "JETTI_PASSWORD_LDAP_JABBERIT" : |
---|
52 | $infoServer['password'] = $nvalue[1]; |
---|
53 | break; |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | $writeFile = "<?php $"."LDAP_INTERNAL="."\"".base64_encode(serialize($infoServer))."\""." ?>"; |
---|
58 | |
---|
59 | return $this->writeFile( $writeFile, $file ); |
---|
60 | } |
---|
61 | |
---|
62 | private final function writeFile($pContent, $pfile) |
---|
63 | { |
---|
64 | $filename = dirname(__FILE__).'/'.$pfile; |
---|
65 | $content = $pContent; |
---|
66 | |
---|
67 | if ( !$handle = fopen($filename, 'w+') ) |
---|
68 | return false; |
---|
69 | |
---|
70 | if (fwrite($handle, $content) === FALSE) |
---|
71 | return false; |
---|
72 | |
---|
73 | fclose($handle); |
---|
74 | |
---|
75 | return true; |
---|
76 | } |
---|
77 | } |
---|
78 | ?> |
---|