Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
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;
cb1221 34     private $security_config;
7fe908 35
d84050 36     public function get_server_config($server_id, $section = '') {
e22f1e 37         global $app;
12fcb2 38
a8b07f 39         if(!isset($this->config[$server_id])) {
e22f1e 40             $app->uses('ini_parser');
65ea2e 41             $server_id = $app->functions->intval($server_id);
cc7a82 42             $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = ?', $server_id);
12fcb2 43             $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config']));
e22f1e 44         }
d84050 45         return ($section == '') ? $this->config[$server_id] : $this->config[$server_id][$section];
e22f1e 46     }
7fe908 47
db5aa6 48     public function get_global_config($section = '') {
T 49         global $app;
7fe908 50
961677 51         if(!isset($this->config['global'])) {
db5aa6 52             $app->uses('ini_parser');
12fcb2 53             $tmp = $app->db->queryOneRecord('SELECT config FROM sys_ini WHERE sysini_id = 1');
J 54             $this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp['config']));
db5aa6 55         }
T 56         return ($section == '') ? $this->config['global'] : $this->config['global'][$section];
e22f1e 57     }
9edea9 58     
cb1221 59     // Function has been moved to $app->get_security_config($section)
9edea9 60     public function get_security_config($section = '') {
TB 61         global $app;
cb1221 62         
TB 63         if(is_array($this->security_config)) {
64             return ($section == '') ? $this->security_config : $this->security_config[$section];
65         } else {
4f2cc4 66             $app->uses('ini_parser');
cb1221 67             $security_config_path = '/usr/local/ispconfig/security/security_settings.ini';
TB 68             if(!is_file($security_config_path)) $security_config_path = realpath(ISPC_ROOT_PATH.'/../security/security_settings.ini');
4f2cc4 69             $this->security_config = $app->ini_parser->parse_ini_string(file_get_contents($security_config_path));
9edea9 70
cb1221 71             return ($section == '') ? $this->security_config : $this->security_config[$section];
TB 72         }
9edea9 73     }
7fe908 74
e22f1e 75 }
T 76
12fcb2 77 ?>