-
Notifications
You must be signed in to change notification settings - Fork 18
/
fs_configuration.php
97 lines (91 loc) · 2.96 KB
/
fs_configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* @package FS_CURL
* fs_configuration.php
*/
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
header('Location: index.php');
}
/**
* @package FS_CURL
* @license BSD
* @author Raymond Chandler (intralanman) <intralanman@gmail.com>
* @version 0.1
* Class for all module configurations
* @return object
*/
class fs_configuration extends fs_curl {
/**
* Class Instantiation
* This method will instantiate all other objects upon which it relies.
* @return void
*/
public function fs_dialplan()
{
self::__construct();
}
function __construct() {
$this -> fs_curl();
$conf_file = $this->request['key_value'];
$this->debug("RECEIVED REQUEST FOR $conf_file");
$mod_name = sprintf('mod_%s', str_replace('.conf', '', $conf_file));
$this -> comment("module name is $mod_name");
if (!($this -> is_mod_enabled($mod_name))
&& !($this -> is_modless_conf($this -> request['key_value']))) {
$this -> comment('module not enabled and not modless config file');
$this -> file_not_found();
}
$this -> xmlw -> startElement('section');
$this -> xmlw -> writeAttribute('name', 'configuration');
$this -> xmlw -> writeAttribute(
'description', 'FreeSWITCH Configuration'
);
}
/**
* Enabled module checker
* This method will check if a module is enabled before
* returning the XML for the module. If the module's not
* enabled, the file_not_found method will be called.
* @param string $mod_name name of module to check
* @return bool
*/
function is_mod_enabled($mod_name) {
$query = sprintf('%s %s'
, "SELECT * FROM post_load_modules_conf"
, "WHERE module_name='$mod_name' AND load_module=1"
);
$res = $this -> db -> query($query);
if ($this->db->errorCode() !== FS_SQL_SUCCESS) {
$this -> comment($query);
$this -> comment($this->db->errorCode());
return true; //default allow policy
return false; //comment previous line to default deny
} elseif ($res -> rowCount() == 1) {
return true;
} else {
return false;
}
}
/**
* Allow config files that aren't tied to any module
*
* @param string $conf
* @return bool
*/
private function is_modless_conf($conf) {
$this -> comment("conf is $conf");
$query = sprintf(
"SELECT COUNT(*) cnt FROM modless_conf WHERE conf_name = '$conf';"
);
$res = $this -> db -> query($query);
if (FS_PDO::isError($res)) {
$this -> comment($query);
$this -> comment($res -> getMessage());
return true; //default allow policy
return false; //comment previous line to default deny
}
$row = $res -> fetchRow();
//$this -> comment($row['cnt']);
return $row['cnt'];
}
}