mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Event Socket settings auto defaults or custom using config.conf
This commit is contained in:
@@ -29,15 +29,7 @@
|
||||
//includes files
|
||||
require_once __DIR__ . "/require.php";
|
||||
|
||||
//get the event socket information
|
||||
if (empty($_SESSION['event_socket_ip_address'])) {
|
||||
$setting = new settings(["category" => "switch"]);
|
||||
$_SESSION['event_socket_ip_address'] = $setting->get('switch', 'event_socket_ip_address');
|
||||
$_SESSION['event_socket_port'] = $setting->get('switch', 'event_socket_port');
|
||||
$_SESSION['event_socket_password'] = $setting->get('switch', 'event_socket_password');
|
||||
}
|
||||
|
||||
function event_socket_create($host, $port, $password) {
|
||||
function event_socket_create($host = null, $port = null, $password = null) {
|
||||
$esl = new event_socket;
|
||||
if ($esl->connect($host, $port, $password)) {
|
||||
return $esl->reset_fp();
|
||||
@@ -53,26 +45,8 @@ function event_socket_request($fp, $cmd) {
|
||||
}
|
||||
|
||||
function event_socket_request_cmd($cmd) {
|
||||
//get the database connection
|
||||
require_once "resources/classes/database.php";
|
||||
$database = new database;
|
||||
$database->connect();
|
||||
$db = $database->db;
|
||||
|
||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/settings/app_config.php")) {
|
||||
$sql = "select * from v_settings ";
|
||||
$database = new database;
|
||||
$row = $database->select($sql, null, 'row');
|
||||
if (!empty($row)) {
|
||||
$event_socket_ip_address = $row["event_socket_ip_address"];
|
||||
$event_socket_port = $row["event_socket_port"];
|
||||
$event_socket_password = $row["event_socket_password"];
|
||||
}
|
||||
unset($sql, $row);
|
||||
}
|
||||
|
||||
$esl = new event_socket;
|
||||
if (!$esl->connect($event_socket_ip_address, $event_socket_port, $event_socket_password)) {
|
||||
if (!$esl->connect()) {
|
||||
return false;
|
||||
}
|
||||
$response = $esl->request($cmd);
|
||||
@@ -110,71 +84,6 @@ function ListFiles($dir) {
|
||||
}
|
||||
}
|
||||
|
||||
function save_setting_xml() {
|
||||
global $domain_uuid, $host, $config;
|
||||
|
||||
$sql = "select * from v_settings ";
|
||||
$database = new database;
|
||||
$row = $database->select($sql, null, 'row');
|
||||
if (!empty($row) && !empty($_SESSION['switch']['conf']['dir'])) {
|
||||
//event_socket.conf.xml
|
||||
$event_socket_ip_address = $row['event_socket_ip_address'];
|
||||
if (empty($event_socket_ip_address)) { $event_socket_ip_address = '127.0.0.1'; }
|
||||
$fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/event_socket.conf.xml","w");
|
||||
$xml = "<configuration name=\"event_socket.conf\" description=\"Socket Client\">\n";
|
||||
$xml .= " <settings>\n";
|
||||
$xml .= " <param name=\"listen-ip\" value=\"" . $event_socket_ip_address . "\"/>\n";
|
||||
$xml .= " <param name=\"listen-port\" value=\"" . $row['event_socket_port'] . "\"/>\n";
|
||||
$xml .= " <param name=\"password\" value=\"" . $row['event_socket_password'] . "\"/>\n";
|
||||
if (!empty($row['event_socket_acl'])) {
|
||||
$xml .= " <param name=\"apply-inbound-acl\" value=\"" . $row['event_socket_acl'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " </settings>\n";
|
||||
$xml .= "</configuration>";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml, $event_socket_password);
|
||||
fclose($fout);
|
||||
|
||||
//xml_rpc.conf.xml
|
||||
$fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_rpc.conf.xml","w");
|
||||
$xml = "<configuration name=\"xml_rpc.conf\" description=\"XML RPC\">\n";
|
||||
$xml .= " <settings>\n";
|
||||
$xml .= " <!-- The port where you want to run the http service (default 8080) -->\n";
|
||||
$xml .= " <param name=\"http-port\" value=\"" . $row['xml_rpc_http_port'] . "\"/>\n";
|
||||
$xml .= " <!-- if all 3 of the following params exist all http traffic will require auth -->\n";
|
||||
$xml .= " <param name=\"auth-realm\" value=\"" . $row['xml_rpc_auth_realm'] . "\"/>\n";
|
||||
$xml .= " <param name=\"auth-user\" value=\"" . $row['xml_rpc_auth_user'] . "\"/>\n";
|
||||
$xml .= " <param name=\"auth-pass\" value=\"" . $row['xml_rpc_auth_pass'] . "\"/>\n";
|
||||
$xml .= " </settings>\n";
|
||||
$xml .= "</configuration>\n";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
|
||||
//shout.conf.xml
|
||||
$fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/shout.conf.xml","w");
|
||||
$xml = "<configuration name=\"shout.conf\" description=\"mod shout config\">\n";
|
||||
$xml .= " <settings>\n";
|
||||
$xml .= " <!-- Don't change these unless you are insane -->\n";
|
||||
$xml .= " <param name=\"decoder\" value=\"" . $row['mod_shout_decoder'] . "\"/>\n";
|
||||
$xml .= " <param name=\"volume\" value=\"" . $row['mod_shout_volume'] . "\"/>\n";
|
||||
$xml .= " <!--<param name=\"outscale\" value=\"8192\"/>-->\n";
|
||||
$xml .= " </settings>\n";
|
||||
$xml .= "</configuration>";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
unset($sql, $row);
|
||||
|
||||
//apply settings
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//$cmd = "api reloadxml";
|
||||
//event_socket_request_cmd($cmd);
|
||||
//unset($cmd);
|
||||
}
|
||||
|
||||
function filename_safe($filename) {
|
||||
//lower case
|
||||
$filename = strtolower($filename);
|
||||
|
||||
Reference in New Issue
Block a user