root/tags/omega-1.0.0-rc3/gui/include/ispcp-config.php

Revision 962, 8.2 KB (checked in by joximu, 12 months ago)

reverted the pma theme thing, added a checker goodie

Line 
1<?php
2/**
3 *  ispCP ω (OMEGA) a Virtual Hosting Control Panel
4 *
5 *  @copyright     2001-2006 by moleSoftware GmbH
6 *  @copyright     2006-2007 by ispCP | http://isp-control.net
7 *  @link         http://isp-control.net
8 *  @author        ispCP Team (2007)
9 *
10 *  @license
11 *  This program is free software; you can redistribute it and/or modify it under
12 *  the terms of the MPL General Public License as published by the Free Software
13 *  Foundation; either version 1.1 of the License, or (at your option) any later
14 *  version.
15 *  You should have received a copy of the MPL Mozilla Public License along with
16 *  this program; if not, write to the Open Source Initiative (OSI)
17 *  http://opensource.org | osi@opensource.org
18 *
19 **/
20
21
22$cfg_obj = new Config('/etc/ispcp/ispcp.conf');
23
24/* Status not ok -> Try to get the error and display a message */
25if ($cfg_obj->status != 'ok') {
26
27    if ($cfg_obj->status == 'err') {
28    /* cannot open ispcp.conf file - we must show warning */
29        print "<center><b><font color=red>Cannot open the ispcp.conf config file !<br><br>Please contact your system administrator</font></b></center>";
30    die();
31    }
32
33    if (substr($cfg_obj->status, 0, 24) == 'missing config variable:') {
34        /* cannot open ispcp.conf file - we must show warning */
35    print "<center><b><font color=red>config variable ".substr($cfg_obj->status, 25)." is missing!<br><br>Please contact your system administrator</font></b></center>";
36    die();
37    }
38}
39
40$cfg = $cfg_obj->getValues();
41
42class Config {
43    /*
44    this class will parse config file and get all variables avaible in PHP */
45    var $config_file;       /* config filename */
46
47/* IMPORTANT: any adding & removing of variables in /etc/ispcp/ispcp.conf should also be made here! */
48    var $cfg_values = array( /* array with all options from config file - predefined with null */
49'BuildDate' => null,
50'Version' => null,
51'VersionH' => null,
52'DEFAULT_ADMIN_ADDRESS' => null,
53'SERVER_HOSTNAME' => null,
54'BASE_SERVER_IP' => null,
55'BASE_SERVER_VHOST' => null,
56'MR_LOCK_FILE' => null,
57'CMD_AWK' => null,
58'CMD_BZCAT' => null,
59'CMD_BZIP' => null,
60'CMD_CHOWN' => null,
61'CMD_CAT' => null,
62'CMD_CHMOD' => null,
63'CMD_CP' => null,
64'CMD_DIFF' => null,
65'CMD_DU' => null,
66'CMD_ECHO' => null,
67'CMD_GZCAT' => null,
68'CMD_GZIP' => null,
69'CMD_GREP' => null,
70'CMD_GROUPADD' => null,
71'CMD_GROUPDEL' => null,
72'CMD_HOSTNAME' => null,
73'CMD_IFCONFIG' => null,
74'CMD_IPTABLES' => null,
75'CMD_LN' => null,
76'CMD_MYSQL' => null,
77'CMD_MV' => null,
78'CMD_PS' => null,
79'CMD_RM' => null,
80'CMD_SHELL' => null,
81'CMD_TAR' => null,
82'CMD_TOUCH' => null,
83'CMD_USERADD' => null,
84'CMD_USERDEL' => null,
85'CMD_WC' => null,
86'PEAR_DIR' => null,
87'DATABASE_TYPE' => null,
88'DATABASE_HOST' => null,
89'DATABASE_NAME' => null,
90'DATABASE_PASSWORD' => null,
91'DATABASE_USER' => null,
92'DATABASE_DIR' => null,
93'CMD_MYSQLDUMP' => null,
94'CONF_DIR' => null,
95'LOG_DIR' => null,
96'PHP_STARTER_DIR' => null,
97'ROOT_DIR' => null,
98'GUI_ROOT_DIR' => null,
99'APACHE_WWW_DIR' => null,
100'SCOREBOARDS_DIR' => null,
101'ZIP' => null,
102'PHP4_FASTCGI_BIN' => null,
103'PHP5_FASTCGI_BIN' => null,
104'PHP_VERSION' => null,
105'FTPD_CONF_FILE' => null,
106'BIND_CONF_FILE' => null,
107'BIND_DB_DIR' => null,
108'SECONDARY_DNS' => null,
109'AWSTATS_ACTIVE' => null,
110'AWSTATS_MODE' => null,
111'AWSTATS_CACHE_DIR' => null,
112'AWSTATS_CONFIG_DIR' => null,
113'AWSTATS_ENGINE_DIR' => null,
114'AWSTATS_WEB_DIR' => null,
115'AWSTATS_ROOT_DIR' => null,
116'APACHE_NAME' => null,
117'APACHE_RESTART_TRY' => null,
118'APACHE_CONF_DIR' => null,
119'APACHE_CMD' => null,
120'APACHE_LOG_DIR' => null,
121'APACHE_BACKUP_LOG_DIR' => null,
122'APACHE_USERS_LOG_DIR' => null,
123'APACHE_MODS_DIR' => null,
124'APACHE_SITES_DIR' => null,
125'APACHE_CUSTOM_SITES_CONFIG_DIR' => null,
126'APACHE_SUEXEC_USER_PREF' => null,
127'APACHE_SUEXEC_MIN_GID' => null,
128'APACHE_SUEXEC_MIN_UID' => null,
129'APACHE_USER' => null,
130'APACHE_GROUP' => null,
131'POSTFIX_CONF_FILE' => null,
132'POSTFIX_MASTER_CONF_FILE' => null,
133'MTA_LOCAL_MAIL_DIR' => null,
134'MTA_VIRTUAL_MAIL_DIR' => null,
135'MTA_LOCAL_ALIAS_HASH' => null,
136'MTA_VIRTUAL_CONF_DIR' => null,
137'MTA_VIRTUAL_ALIAS_HASH' => null,
138'MTA_VIRTUAL_DMN_HASH' => null,
139'MTA_VIRTUAL_MAILBOX_HASH' => null,
140'MTA_TRANSPORT_HASH' => null,
141'MTA_SENDER_ACCESS_HASH' => null,
142'MTA_MAILBOX_MIN_UID' => null,
143'MTA_MAILBOX_UID' => null,
144'MTA_MAILBOX_UID_NAME' => null,
145'MTA_MAILBOX_GID' => null,
146'MTA_MAILBOX_GID_NAME' => null,
147'MTA_SASLDB_FILE' => null,
148'ETC_SASLDB_FILE' => null,
149'CMD_SASLDB_LISTUSERS2' => null,
150'CMD_SASLDB_PASSWD2' => null,
151'CMD_POSTMAP' => null,
152'CMD_NEWALIASES' => null,
153'COURIER_CONF_DIR' => null,
154'AUTHLIB_CONF_DIR' => null,
155'CMD_MAKEUSERDB' => null,
156'BACKUP_HOUR' => null,
157'BACKUP_MINUTE' => null,
158'BACKUP_ISPCP' => null,
159'BACKUP_DOMAINS' => null,
160'BACKUP_ROOT_DIR' => null,
161'CMD_CRONTAB' => null,
162'CMD_AMAVIS' => null,
163'CMD_AUTHD' => null,
164'CMD_FTPD' => null,
165'CMD_HTTPD' => null,
166'CMD_IMAP' => null,
167'CMD_IMAP_SSL' => null,
168'CMD_MTA' => null,
169'CMD_NAMED' => null,
170'CMD_POP' => null,
171'CMD_POP_SSL' => null,
172'CMD_ISPCPD' => null,
173'CMD_ISPCPN' => null,
174'CMD_PFLOGSUM' => null,
175'TRAFF_LOG_DIR' => null,
176'FTP_TRAFF_LOG' => null,
177'MAIL_TRAFF_LOG' => null,
178'PREV_TRAFF_LOG_MAX_SIZE' => null,
179'TRAFF_ROOT_DIR' => null,
180'TOOLS_ROOT_DIR' => null,
181'QUOTA_ROOT_DIR' => null,
182'MAIL_LOG_INC_AMAVIS' => null,
183'USER_INITIAL_THEME' => null,
184'ISPCP_LICENSE' => null,
185'FTP_USERNAME_SEPARATOR' => null,
186'FTP_HOMEDIR' => null,
187'FTP_SHELL' => null,
188'IPS_LOGO_PATH' => null,
189'ISPCP_SUPPORT_SYSTEM_PATH' => null,
190'ISPCP_SUPPORT_SYSTEM_TARGET' => null,
191'MYSQL_PREFIX' => null,
192'MYSQL_PREFIX_TYPE' => null,
193'WEBMAIL_PATH' => null,
194'WEBMAIL_TARGET' => null,
195'PMA_PATH' => null,
196'PMA_TARGET' => null,
197'FILEMANAGER_PATH' => null,
198'FILEMANAGER_TARGET' => null,
199'DATE_FORMAT' => null,
200'RKHUNTER_LOG' => null,
201'CHKROOTKIT_LOG' => null,
202'OTHER_ROOTKIT_LOG' => null,
203'HTACCESS_USERS_FILE_NAME' => null,
204'HTACCESS_GROUPS_FILE_NAME' => null,
205'HTPASSWD_CMD' => null,
206'BACKUP_FILE_DIR' => null,
207'DEBUG' => null,
208);
209    var $status;
210
211    function Config($cfg = "/etc/ispcp/ispcp.conf") {
212        $this -> config_file = $cfg;
213        $this -> status = "ok";
214        if ($this->parseFile() == FALSE) {
215#            $this->status = 'err';
216            return FALSE;
217        }
218        else {
219            return TRUE;
220        }
221    }
222
223    function parseFile(){
224        /* open file ... parse it and put it in $cfg_values */
225        @$fd = fopen($this->config_file,'r');
226        if ($fd == FALSE) {
227            /* ooops error */
228            $this->status = 'err';
229            return FALSE;
230        }
231
232        while(!feof($fd)){
233            $buffer = fgets($fd,4096);
234            /* remove spaces  */
235            $buffer = ltrim($buffer);
236            if (strlen($buffer) < 3) {
237                /* empty */
238            }
239            else if ($buffer[0] == '#' || $buffer[0] == ';') {
240                /* this is comment */
241            }
242            else if (strpos($buffer,'=') === false) {
243                /* have no = :( */
244            }
245            else {
246                $pair = explode('=',$buffer,2);
247
248                $pair[0] = ltrim($pair[0]);
249                $pair[0] = rtrim($pair[0]);
250
251                $pair[1] = ltrim($pair[1]);
252                $pair[1] = rtrim($pair[1]);
253
254                /* ok we have it :) */
255                $this->cfg_values[$pair[0]]=$pair[1];
256            }
257        }
258
259        fclose($fd);
260    foreach ($this->cfg_values as $k=>$v) {
261        if ($v === null) {
262            $this->status = "missing config variable: '$k'";
263        return FALSE;
264        }
265    }
266
267        return TRUE;
268    }
269
270    function getValues() {
271        return $this->cfg_values;
272    }
273}
274
275function decrypt_db_password ($db_pass) {
276    global $ispcp_db_pass_key, $ispcp_db_pass_iv;
277
278    if ($db_pass == '')
279        return '';
280
281    if (extension_loaded('mcrypt') || @dl('mcrypt.'.PHP_SHLIB_SUFFIX)) {
282
283        $text = @base64_decode($db_pass."\n");
284
285        /* Open the cipher */
286        $td = @mcrypt_module_open ('blowfish', '', 'cbc', '');
287
288        /* Create key */
289        $key = $ispcp_db_pass_key;
290
291        /* Create the IV and determine the keysize length */
292        $iv = $ispcp_db_pass_iv;
293
294        /* Intialize encryption */
295        @mcrypt_generic_init ($td, $key, $iv);
296
297        /* Decrypt encrypted string */
298        $decrypted = @mdecrypt_generic ($td, $text);
299
300        @mcrypt_module_close ($td);
301
302        /* Show string */
303        return trim($decrypted);
304
305    } else {
306
307        system_message("ERROR: The php-extension 'mcrypt' not loaded !");
308
309        die();
310
311    }
312
313}
314
315?>
Note: See TracBrowser for help on using the browser.