Till Brehm
2014-08-14 e14a82779bd6451ea33f1c25a293743a38161caf
commit | author | age
e22f1e 1 <?php
436ed8 2
e22f1e 3 /*
436ed8 4 Copyright (c) 2007, Till Brehm, projektfarm Gmbh
e22f1e 5 All rights reserved.
T 6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 class getconf {
32
d84050 33     private $config;
7fe908 34
d84050 35     public function get_server_config($server_id, $section = '') {
e22f1e 36         global $app;
12fcb2 37
a8b07f 38         if(!isset($this->config[$server_id])) {
e22f1e 39             $app->uses('ini_parser');
65ea2e 40             $server_id = $app->functions->intval($server_id);
12fcb2 41             $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id);
J 42             $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config']));
e22f1e 43         }
d84050 44         return ($section == '') ? $this->config[$server_id] : $this->config[$server_id][$section];
e22f1e 45     }
7fe908 46
db5aa6 47     public function get_global_config($section = '') {
T 48         global $app;
7fe908 49
961677 50         if(!isset($this->config['global'])) {
db5aa6 51             $app->uses('ini_parser');
12fcb2 52             $tmp = $app->db->queryOneRecord('SELECT config FROM sys_ini WHERE sysini_id = 1');
J 53             $this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp['config']));
db5aa6 54         }
T 55         return ($section == '') ? $this->config['global'] : $this->config['global'][$section];
e22f1e 56     }
9edea9 57     
TB 58     public function get_security_config($section = '') {
59         global $app;
60
61         $app->uses('ini_parser');
e14a82 62         $security_config_path = '/usr/local/ispconfig/security/security_settings.ini';
TB 63         if(!is_file($security_config_path)) $security_config_path = realpath(ISPC_ROOT_PATH.'/../security/security_settings.ini');
64         $security_config = $app->ini_parser->parse_ini_string(file_get_contents($security_config_path));
9edea9 65
TB 66         return ($section == '') ? $security_config : $security_config[$section];
67     }
7fe908 68
e22f1e 69 }
T 70
12fcb2 71 ?>