function sync_package_v_settings() { global $config; $v_settings_array = v_settings(); foreach ($v_settings_array as $name => $value) { ${$name} = $value; } global $db, $v_id, $host; $sql = ""; $sql .= "select * from v_settings "; $sql .= "where v_id = '{$v_id}' "; $prepstatement = $db->prepare(check_sql($sql)); $prepstatement->execute(); $result = $prepstatement->fetchAll(); foreach ($result as &$row) { //$v_id = $row["v_id"]; //$numbering_plan = $row["numbering_plan"]; //$default_gateway = $row["default_gateway"]; //$default_area_code = $row["default_area_code"]; //$event_socket_ip_address = $row["event_socket_ip_address"]; //$event_socket_port = $row["event_socket_port"]; //$event_socket_password = $row["event_socket_password"]; //$xml_rpc_http_port = $row["xml_rpc_http_port"]; //$xml_rpc_auth_realm = $row["xml_rpc_auth_realm"]; //$xml_rpc_auth_user = $row["xml_rpc_auth_user"]; //$xml_rpc_auth_pass = $row["xml_rpc_auth_pass"]; //$admin_pin = $row["admin_pin"]; //$smtphost = $row["smtphost"]; //$smtpsecure = $row["smtpsecure"]; //$smtpauth = $row["smtpauth"]; //$smtpusername = $row["smtpusername"]; //$smtppassword = $row["smtppassword"]; //$smtpfrom = $row["smtpfrom"]; //$smtpfromname = $row["smtpfromname"]; //$mod_shout_decoder = $row["mod_shout_decoder"]; //$mod_shout_volume = $row["mod_shout_volume"]; $fout = fopen($v_secure . "/v_config_cli.php", "w"); $tmpxml = "<?php\n"; $tmpxml .= "\n"; $tmpxml .= "error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED ); //hide notices and warnings\n"; $tmpxml .= "\n"; //$tmpxml .= "\$v_web_dir= \"".$row["v_web_dir"]."\";\n"; $tmpxml .= "\$v_smtphost = \"" . $row["smtphost"] . "\";\n"; if ($row["smtpsecure"] == "none") { $tmpxml .= "\$v_smtpsecure = \"\";\n"; } else { $tmpxml .= "\$v_smtpsecure = \"" . $row["smtpsecure"] . "\";\n"; } $tmpxml .= "\$v_smtpauth = \"" . $row["smtpauth"] . "\";\n"; $tmpxml .= "\$v_smtpusername = \"" . $row["smtpusername"] . "\";\n"; $tmpxml .= "\$v_smtppassword = \"" . $row["smtppassword"] . "\";\n"; $tmpxml .= "\$v_smtpfrom = \"" . $row["smtpfrom"] . "\";\n"; $tmpxml .= "\$v_smtpfromname= \"" . $row["smtpfromname"] . "\";\n"; $tmpxml .= "\n"; $tmpxml .= "?>"; fwrite($fout, $tmpxml); unset($tmpxml); fclose($fout); $fout = fopen($v_conf_dir . "/directory/default/default.xml", "w"); $tmpxml = "<include>\n"; $tmpxml .= " <user id=\"default\"> <!--if id is numeric mailbox param is not necessary-->\n"; $tmpxml .= " <variables>\n"; $tmpxml .= " <!--all variables here will be set on all inbound calls that originate from this user -->\n"; $tmpxml .= " <!-- set these to take advantage of a dialplan localized to this user -->\n"; $tmpxml .= " <variable name=\"numbering_plan\" value=\"" . $row['numbering_plan'] . "\"/>\n"; $tmpxml .= " <variable name=\"default_gateway\" value=\"" . $row['default_gateway'] . "\"/>\n"; $tmpxml .= " <variable name=\"default_area_code\" value=\"" . $row['default_area_code'] . "\"/>\n"; $tmpxml .= " </variables>\n"; $tmpxml .= " </user>\n"; $tmpxml .= "</include>\n"; fwrite($fout, $tmpxml); unset($tmpxml); fclose($fout); $event_socket_ip_address = $row['event_socket_ip_address']; if (strlen($event_socket_ip_address) == 0) { $event_socket_ip_address = '127.0.0.1'; } $fout = fopen($v_conf_dir . "/autoload_configs/event_socket.conf.xml", "w"); $tmpxml = "<configuration name=\"event_socket.conf\" description=\"Socket Client\">\n"; $tmpxml .= " <settings>\n"; $tmpxml .= " <param name=\"listen-ip\" value=\"" . $event_socket_ip_address . "\"/>\n"; $tmpxml .= " <param name=\"listen-port\" value=\"" . $row['event_socket_port'] . "\"/>\n"; $tmpxml .= " <param name=\"password\" value=\"" . $row['event_socket_password'] . "\"/>\n"; $tmpxml .= " <!--<param name=\"apply-inbound-acl\" value=\"lan\"/>-->\n"; $tmpxml .= " </settings>\n"; $tmpxml .= "</configuration>"; fwrite($fout, $tmpxml); unset($tmpxml, $event_socket_password); fclose($fout); $fout = fopen($v_conf_dir . "/autoload_configs/xml_rpc.conf.xml", "w"); $tmpxml = "<configuration name=\"xml_rpc.conf\" description=\"XML RPC\">\n"; $tmpxml .= " <settings>\n"; $tmpxml .= " <!-- The port where you want to run the http service (default 8080) -->\n"; $tmpxml .= " <param name=\"http-port\" value=\"" . $row['xml_rpc_http_port'] . "\"/>\n"; $tmpxml .= " <!-- if all 3 of the following params exist all http traffic will require auth -->\n"; $tmpxml .= " <param name=\"auth-realm\" value=\"" . $row['xml_rpc_auth_realm'] . "\"/>\n"; $tmpxml .= " <param name=\"auth-user\" value=\"" . $row['xml_rpc_auth_user'] . "\"/>\n"; $tmpxml .= " <param name=\"auth-pass\" value=\"" . $row['xml_rpc_auth_pass'] . "\"/>\n"; $tmpxml .= " </settings>\n"; $tmpxml .= "</configuration>\n"; fwrite($fout, $tmpxml); unset($tmpxml); fclose($fout); //write the recording.js and recording.lua script recording_js(); recording_lua(); //shout.conf.xml $fout = fopen($v_conf_dir . "/autoload_configs/shout.conf.xml", "w"); $tmpxml = "<configuration name=\"shout.conf\" description=\"mod shout config\">\n"; $tmpxml .= " <settings>\n"; $tmpxml .= " <!-- Don't change these unless you are insane -->\n"; $tmpxml .= " <param name=\"decoder\" value=\"" . $row['mod_shout_decoder'] . "\"/>\n"; $tmpxml .= " <param name=\"volume\" value=\"" . $row['mod_shout_volume'] . "\"/>\n"; $tmpxml .= " <!--<param name=\"outscale\" value=\"8192\"/>-->\n"; $tmpxml .= " </settings>\n"; $tmpxml .= "</configuration>"; fwrite($fout, $tmpxml); unset($tmpxml); fclose($fout); //config.lua $fout = fopen($v_scripts_dir . "/config.lua", "w"); $tmp = "--lua include\n\n"; $tmp .= "admin_pin = \"" . $row["admin_pin"] . "\";\n"; $tmp .= "sounds_dir = \"" . $v_sounds_dir . "\";\n"; $tmp .= "recordings_dir = \"" . $v_recordings_dir . "\";\n"; $tmp .= "tmp_dir = \"" . $tmp_dir . "\";\n"; fwrite($fout, $tmp); unset($tmp); fclose($fout); //config.js $fout = fopen($v_scripts_dir . "/config.js", "w"); $tmp = "//javascript include\n\n"; $tmp .= "var admin_pin = \"" . $row["admin_pin"] . "\";\n"; $tmp .= "var sounds_dir = \"" . $v_sounds_dir . "\";\n"; $tmp .= "var recordings_dir = \"" . $v_recordings_dir . "\";\n"; $tmp .= "var tmp_dir = \"" . $tmp_dir . "\";\n"; fwrite($fout, $tmp); unset($tmp); fclose($fout); break; //limit to 1 row } unset($prepstatement); $cmd = "api reloadxml"; //event_socket_request_cmd($cmd); unset($cmd); }
Contributor(s): Mark J Crane <*****@*****.**> */ include "root.php"; require_once "includes/config.php"; require_once "includes/checkauth.php"; if (ifgroup("admin") || ifgroup("superadmin")) { //access granted } else { echo "access denied"; exit; } require_once "includes/paging.php"; require_once "includes/v_dialplan_entry_exists.php"; recording_js(); $dir_music_on_hold_8000 = $v_sounds_dir . '/music/8000'; ini_set(max_execution_time, 7200); $orderby = $_GET["orderby"]; $order = $_GET["order"]; if ($_GET['a'] == "download") { session_cache_limiter('public'); if ($_GET['type'] = "rec") { if (file_exists($v_recordings_dir . '/' . base64_decode($_GET['filename']))) { $fd = fopen($v_recordings_dir . '/' . base64_decode($_GET['filename']), "rb"); if ($_GET['t'] == "bin") { header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header('Content-Disposition: attachment; filename="' . base64_decode($_GET['filename']) . '"');