Replace $tmp_xml variable with $xml and write the extension xml files only if the session extension directory variable is set.
This commit is contained in:
parent
757efa5394
commit
82ec06357c
|
|
@ -1535,93 +1535,93 @@ function save_setting_xml() {
|
|||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($result as &$row) {
|
||||
$fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/v_config_cli.php","w");
|
||||
$tmp_xml = "<?php\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= "error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED ); //hide notices and warnings\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= "//set the email variables\n";
|
||||
$tmp_xml .= " \$v_smtp_host = \"".$row["smtp_host"]."\";\n";
|
||||
$xml = "<?php\n";
|
||||
$xml .= "\n";
|
||||
$xml .= "error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED ); //hide notices and warnings\n";
|
||||
$xml .= "\n";
|
||||
$xml .= "//set the email variables\n";
|
||||
$xml .= " \$v_smtp_host = \"".$row["smtp_host"]."\";\n";
|
||||
if ($row["smtp_secure"] == "none") {
|
||||
$tmp_xml .= " \$v_smtp_secure = \"\";\n";
|
||||
$xml .= " \$v_smtp_secure = \"\";\n";
|
||||
}
|
||||
else {
|
||||
$tmp_xml .= " \$v_smtp_secure = \"".$row["smtp_secure"]."\";\n";
|
||||
$xml .= " \$v_smtp_secure = \"".$row["smtp_secure"]."\";\n";
|
||||
}
|
||||
$tmp_xml .= " \$v_smtp_auth = \"".$row["smtp_auth"]."\";\n";
|
||||
$tmp_xml .= " \$v_smtp_username = \"".$row["smtp_username"]."\";\n";
|
||||
$tmp_xml .= " \$v_smtp_password = \"".$row["smtp_password"]."\";\n";
|
||||
$tmp_xml .= " \$v_smtp_from = \"".$row["smtp_from"]."\";\n";
|
||||
$tmp_xml .= " \$v_smtp_from_name = \"".$row["smtp_from_name"]."\";\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= "//set system dir variables\n";
|
||||
$tmp_xml .= " \$switch_storage_dir = \"".$_SESSION['switch']['storage']['dir']."\";\n";
|
||||
$tmp_xml .= " \$tmp_dir = \"".$tmp_dir."\";\n";
|
||||
$tmp_xml .= " \$v_secure = \"".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure"."\";\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= "?>";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
$xml .= " \$v_smtp_auth = \"".$row["smtp_auth"]."\";\n";
|
||||
$xml .= " \$v_smtp_username = \"".$row["smtp_username"]."\";\n";
|
||||
$xml .= " \$v_smtp_password = \"".$row["smtp_password"]."\";\n";
|
||||
$xml .= " \$v_smtp_from = \"".$row["smtp_from"]."\";\n";
|
||||
$xml .= " \$v_smtp_from_name = \"".$row["smtp_from_name"]."\";\n";
|
||||
$xml .= "\n";
|
||||
$xml .= "//set system dir variables\n";
|
||||
$xml .= " \$switch_storage_dir = \"".$_SESSION['switch']['storage']['dir']."\";\n";
|
||||
$xml .= " \$tmp_dir = \"".$tmp_dir."\";\n";
|
||||
$xml .= " \$v_secure = \"".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure"."\";\n";
|
||||
$xml .= "\n";
|
||||
$xml .= "?>";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
|
||||
$fout = fopen($_SESSION['switch']['conf']['dir']."/directory/default/default.xml","w");
|
||||
$tmp_xml = "<include>\n";
|
||||
$tmp_xml .= " <user id=\"default\"> <!--if id is numeric mailbox param is not necessary-->\n";
|
||||
$tmp_xml .= " <variables>\n";
|
||||
$tmp_xml .= " <!--all variables here will be set on all inbound calls that originate from this user -->\n";
|
||||
$tmp_xml .= " <!-- set these to take advantage of a dialplan localized to this user -->\n";
|
||||
$tmp_xml .= " <variable name=\"numbering_plan\" value=\"" . $row['numbering_plan'] . "\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"default_gateway\" value=\"" . $row['default_gateway'] . "\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"default_area_code\" value=\"" . $row['default_area_code'] . "\"/>\n";
|
||||
$tmp_xml .= " </variables>\n";
|
||||
$tmp_xml .= " </user>\n";
|
||||
$tmp_xml .= "</include>\n";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
$xml = "<include>\n";
|
||||
$xml .= " <user id=\"default\"> <!--if id is numeric mailbox param is not necessary-->\n";
|
||||
$xml .= " <variables>\n";
|
||||
$xml .= " <!--all variables here will be set on all inbound calls that originate from this user -->\n";
|
||||
$xml .= " <!-- set these to take advantage of a dialplan localized to this user -->\n";
|
||||
$xml .= " <variable name=\"numbering_plan\" value=\"" . $row['numbering_plan'] . "\"/>\n";
|
||||
$xml .= " <variable name=\"default_gateway\" value=\"" . $row['default_gateway'] . "\"/>\n";
|
||||
$xml .= " <variable name=\"default_area_code\" value=\"" . $row['default_area_code'] . "\"/>\n";
|
||||
$xml .= " </variables>\n";
|
||||
$xml .= " </user>\n";
|
||||
$xml .= "</include>\n";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
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($_SESSION['switch']['conf']['dir']."/autoload_configs/event_socket.conf.xml","w");
|
||||
$tmp_xml = "<configuration name=\"event_socket.conf\" description=\"Socket Client\">\n";
|
||||
$tmp_xml .= " <settings>\n";
|
||||
$tmp_xml .= " <param name=\"listen-ip\" value=\"" . $event_socket_ip_address . "\"/>\n";
|
||||
$tmp_xml .= " <param name=\"listen-port\" value=\"" . $row['event_socket_port'] . "\"/>\n";
|
||||
$tmp_xml .= " <param name=\"password\" value=\"" . $row['event_socket_password'] . "\"/>\n";
|
||||
$tmp_xml .= " <!--<param name=\"apply-inbound-acl\" value=\"lan\"/>-->\n";
|
||||
$tmp_xml .= " </settings>\n";
|
||||
$tmp_xml .= "</configuration>";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml, $event_socket_password);
|
||||
$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";
|
||||
$xml .= " <!--<param name=\"apply-inbound-acl\" value=\"lan\"/>-->\n";
|
||||
$xml .= " </settings>\n";
|
||||
$xml .= "</configuration>";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml, $event_socket_password);
|
||||
fclose($fout);
|
||||
|
||||
$fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_rpc.conf.xml","w");
|
||||
$tmp_xml = "<configuration name=\"xml_rpc.conf\" description=\"XML RPC\">\n";
|
||||
$tmp_xml .= " <settings>\n";
|
||||
$tmp_xml .= " <!-- The port where you want to run the http service (default 8080) -->\n";
|
||||
$tmp_xml .= " <param name=\"http-port\" value=\"" . $row['xml_rpc_http_port'] . "\"/>\n";
|
||||
$tmp_xml .= " <!-- if all 3 of the following params exist all http traffic will require auth -->\n";
|
||||
$tmp_xml .= " <param name=\"auth-realm\" value=\"" . $row['xml_rpc_auth_realm'] . "\"/>\n";
|
||||
$tmp_xml .= " <param name=\"auth-user\" value=\"" . $row['xml_rpc_auth_user'] . "\"/>\n";
|
||||
$tmp_xml .= " <param name=\"auth-pass\" value=\"" . $row['xml_rpc_auth_pass'] . "\"/>\n";
|
||||
$tmp_xml .= " </settings>\n";
|
||||
$tmp_xml .= "</configuration>\n";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
$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");
|
||||
$tmp_xml = "<configuration name=\"shout.conf\" description=\"mod shout config\">\n";
|
||||
$tmp_xml .= " <settings>\n";
|
||||
$tmp_xml .= " <!-- Don't change these unless you are insane -->\n";
|
||||
$tmp_xml .= " <param name=\"decoder\" value=\"" . $row['mod_shout_decoder'] . "\"/>\n";
|
||||
$tmp_xml .= " <param name=\"volume\" value=\"" . $row['mod_shout_volume'] . "\"/>\n";
|
||||
$tmp_xml .= " <!--<param name=\"outscale\" value=\"8192\"/>-->\n";
|
||||
$tmp_xml .= " </settings>\n";
|
||||
$tmp_xml .= "</configuration>";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
$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);
|
||||
|
||||
break; //limit to 1 row
|
||||
|
|
@ -1638,304 +1638,306 @@ function save_setting_xml() {
|
|||
}
|
||||
|
||||
function save_extension_xml() {
|
||||
//declare global variables
|
||||
global $config, $db, $domain_uuid;
|
||||
if (isset($_SESSION['switch']['extensions']['dir'])) {
|
||||
//declare global variables
|
||||
global $config, $db, $domain_uuid;
|
||||
|
||||
//get the context based from the domain_uuid
|
||||
if (count($_SESSION['domains']) == 1) {
|
||||
$user_context = "default";
|
||||
}
|
||||
else {
|
||||
$user_context = $_SESSION['domains'][$domain_uuid]['domain_name'];
|
||||
}
|
||||
//get the context based from the domain_uuid
|
||||
if (count($_SESSION['domains']) == 1) {
|
||||
$user_context = "default";
|
||||
}
|
||||
else {
|
||||
$user_context = $_SESSION['domains'][$domain_uuid]['domain_name'];
|
||||
}
|
||||
|
||||
//delete all old extensions to prepare for new ones
|
||||
$dialplan_list = glob($_SESSION['switch']['extensions']['dir']."/".$user_context."/v_*.xml");
|
||||
foreach($dialplan_list as $name => $value) {
|
||||
unlink($value);
|
||||
}
|
||||
//delete all old extensions to prepare for new ones
|
||||
$dialplan_list = glob($_SESSION['switch']['extensions']['dir']."/".$user_context."/v_*.xml");
|
||||
foreach($dialplan_list as $name => $value) {
|
||||
unlink($value);
|
||||
}
|
||||
|
||||
//write the xml files
|
||||
$sql = "select * from v_extensions ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "order by call_group asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$i = 0;
|
||||
$extension_xml_condensed = false;
|
||||
//write the xml files
|
||||
$sql = "select * from v_extensions ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "order by call_group asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$i = 0;
|
||||
$extension_xml_condensed = false;
|
||||
|
||||
while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
|
||||
$call_group = $row['call_group'];
|
||||
$call_group = str_replace(";", ",", $call_group);
|
||||
$tmp_array = explode(",", $call_group);
|
||||
foreach ($tmp_array as &$tmp_call_group) {
|
||||
$tmp_call_group = trim($tmp_call_group);
|
||||
if (strlen($tmp_call_group) > 0) {
|
||||
if (strlen($call_group_array[$tmp_call_group]) == 0) {
|
||||
$call_group_array[$tmp_call_group] = $row['extension'];
|
||||
while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
|
||||
$call_group = $row['call_group'];
|
||||
$call_group = str_replace(";", ",", $call_group);
|
||||
$tmp_array = explode(",", $call_group);
|
||||
foreach ($tmp_array as &$tmp_call_group) {
|
||||
$tmp_call_group = trim($tmp_call_group);
|
||||
if (strlen($tmp_call_group) > 0) {
|
||||
if (strlen($call_group_array[$tmp_call_group]) == 0) {
|
||||
$call_group_array[$tmp_call_group] = $row['extension'];
|
||||
}
|
||||
else {
|
||||
$call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension'];
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$user_context = $row['user_context'];
|
||||
$vm_password = $row['vm_password'];
|
||||
$vm_password = str_replace("#", "", $vm_password); //preserves leading zeros
|
||||
|
||||
//echo "enabled: ".$row['enabled'];
|
||||
if ($row['enabled'] != "false") {
|
||||
//remove invalid characters from the file names
|
||||
$extension = $row['extension'];
|
||||
$extension = str_replace(" ", "_", $extension);
|
||||
$extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension);
|
||||
$dial_string = $row['dial_string'];
|
||||
if (strlen($dial_string) == 0) {
|
||||
$dial_string = "{sip_invite_domain=\${domain_name},presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}";
|
||||
}
|
||||
|
||||
$xml .= "<include>\n";
|
||||
$cidr = '';
|
||||
if (strlen($row['cidr']) > 0) {
|
||||
$cidr = " cidr=\"" . $row['cidr'] . "\"";
|
||||
}
|
||||
$number_alias = '';
|
||||
if (strlen($row['number_alias']) > 0) {
|
||||
$number_alias = " number-alias=\"".$row['number_alias']."\"";
|
||||
}
|
||||
$xml .= " <user id=\"".$row['extension']."\"".$cidr."".$number_alias.">\n";
|
||||
$xml .= " <params>\n";
|
||||
$xml .= " <param name=\"password\" value=\"" . $row['password'] . "\"/>\n";
|
||||
$xml .= " <param name=\"vm-password\" value=\"" . $vm_password . "\"/>\n";
|
||||
switch ($row['vm_enabled']) {
|
||||
case "true":
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
}
|
||||
if (strlen($row['vm_mailto']) > 0) {
|
||||
$xml .= " <param name=\"vm-email-all-messages\" value=\"true\"/>\n";
|
||||
|
||||
switch ($row['vm_attach_file']) {
|
||||
case "true":
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
|
||||
}
|
||||
switch ($row['vm_keep_local_after_email']) {
|
||||
case "true":
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
}
|
||||
$xml .= " <param name=\"vm-mailto\" value=\"" . $row['vm_mailto'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['mwi_account']) > 0) {
|
||||
$xml .= " <param name=\"MWI-Account\" value=\"" . $row['mwi_account'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['auth_acl']) > 0) {
|
||||
$xml .= " <param name=\"auth-acl\" value=\"" . $row['auth_acl'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_exten_visible']) > 0) {
|
||||
$xml .= " <param name=\"directory-exten-visible\" value=\"" . $row['directory_exten_visible'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <param name=\"dial-string\" value=\"" . $dial_string . "\"/>\n";
|
||||
$xml .= " </params>\n";
|
||||
$xml .= " <variables>\n";
|
||||
if (strlen($row['call_group']) > 0) {
|
||||
$xml .= " <variable name=\"call_group\" value=\"" . $row['call_group'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['hold_music']) > 0) {
|
||||
$xml .= " <variable name=\"hold_music\" value=\"" . $row['hold_music'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <variable name=\"toll_allow\" value=\"" . $row['toll_allow'] . "\"/>\n";
|
||||
if (strlen($switch_account_code) > 0) {
|
||||
$xml .= " <variable name=\"accountcode\" value=\"" . $switch_account_code . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension'];
|
||||
$xml .= " <variable name=\"accountcode\" value=\"" . $row['accountcode'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <variable name=\"user_context\" value=\"" . $row['user_context'] . "\"/>\n";
|
||||
if (strlen($row['effective_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"effective_caller_id_name\" value=\"" . $row['effective_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['effective_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"effective_caller_id_number\" value=\"" . $row['effective_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_name\" value=\"" . $row['outbound_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_number\" value=\"" . $row['outbound_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['emergency_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"emergency_caller_id_number\" value=\"" . $row['emergency_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_full_name']) > 0) {
|
||||
$xml .= " <variable name=\"directory_full_name\" value=\"" . $row['directory_full_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_visible']) > 0) {
|
||||
$xml .= " <variable name=\"directory-visible\" value=\"" . $row['directory_visible'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['limit_max']) > 0) {
|
||||
$xml .= " <variable name=\"limit_max\" value=\"" . $row['limit_max'] . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$xml .= " <variable name=\"limit_max\" value=\"5\"/>\n";
|
||||
}
|
||||
if (strlen($row['limit_destination']) > 0) {
|
||||
$xml .= " <variable name=\"limit_destination\" value=\"" . $row['limit_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_force_contact']) > 0) {
|
||||
$xml .= " <variable name=\"sip-force-contact\" value=\"" . $row['sip_force_contact'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_force_expires']) > 0) {
|
||||
$xml .= " <variable name=\"sip-force-expires\" value=\"" . $row['sip_force_expires'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['nibble_account']) > 0) {
|
||||
$xml .= " <variable name=\"nibble_account\" value=\"" . $row['nibble_account'] . "\"/>\n";
|
||||
}
|
||||
switch ($row['sip_bypass_media']) {
|
||||
case "bypass-media":
|
||||
$xml .= " <variable name=\"bypass_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "bypass-media-after-bridge":
|
||||
$xml .= " <variable name=\"bypass_media_after_bridge\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "proxy-media":
|
||||
$xml .= " <variable name=\"proxy_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
$xml .= " </variables>\n";
|
||||
$xml .= " </user>\n";
|
||||
|
||||
if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) {
|
||||
mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context'],0755,true);
|
||||
}
|
||||
if (strlen($extension) > 0) {
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w");
|
||||
}
|
||||
$xml .= "</include>\n";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$user_context = $row['user_context'];
|
||||
$vm_password = $row['vm_password'];
|
||||
$vm_password = str_replace("#", "", $vm_password); //preserves leading zeros
|
||||
unset ($prep_statement);
|
||||
|
||||
//echo "enabled: ".$row['enabled'];
|
||||
if ($row['enabled'] != "false") {
|
||||
//remove invalid characters from the file names
|
||||
$extension = $row['extension'];
|
||||
$extension = str_replace(" ", "_", $extension);
|
||||
$extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension);
|
||||
$dial_string = $row['dial_string'];
|
||||
if (strlen($dial_string) == 0) {
|
||||
$dial_string = "{sip_invite_domain=\${domain_name},presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}";
|
||||
}
|
||||
//prepare extension
|
||||
$extension_dir_path = realpath($_SESSION['switch']['extensions']['dir']);
|
||||
$user_context = str_replace(" ", "_", $user_context);
|
||||
$user_context = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $user_context);
|
||||
|
||||
$tmp_xml .= "<include>\n";
|
||||
$cidr = '';
|
||||
if (strlen($row['cidr']) > 0) {
|
||||
$cidr = " cidr=\"" . $row['cidr'] . "\"";
|
||||
}
|
||||
$number_alias = '';
|
||||
if (strlen($row['number_alias']) > 0) {
|
||||
$number_alias = " number-alias=\"".$row['number_alias']."\"";
|
||||
}
|
||||
$tmp_xml .= " <user id=\"".$row['extension']."\"".$cidr."".$number_alias.">\n";
|
||||
$tmp_xml .= " <params>\n";
|
||||
$tmp_xml .= " <param name=\"password\" value=\"" . $row['password'] . "\"/>\n";
|
||||
$tmp_xml .= " <param name=\"vm-password\" value=\"" . $vm_password . "\"/>\n";
|
||||
switch ($row['vm_enabled']) {
|
||||
case "true":
|
||||
$tmp_xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$tmp_xml .= " <param name=\"vm-enabled\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$tmp_xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
}
|
||||
if (strlen($row['vm_mailto']) > 0) {
|
||||
$tmp_xml .= " <param name=\"vm-email-all-messages\" value=\"true\"/>\n";
|
||||
|
||||
switch ($row['vm_attach_file']) {
|
||||
case "true":
|
||||
$tmp_xml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$tmp_xml .= " <param name=\"vm-attach-file\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$tmp_xml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
|
||||
//define the group members
|
||||
$xml = "<!--\n";
|
||||
$xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " FreeSWITCH works off the concept of users and domains just like email.\n";
|
||||
$xml .= " You have users that are in domains for example 1000@domain.com.\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " When freeswitch gets a register packet it looks for the user in the directory\n";
|
||||
$xml .= " based on the from or to domain in the packet depending on how your sofia profile\n";
|
||||
$xml .= " is configured. Out of the box the default domain will be the IP address of the\n";
|
||||
$xml .= " machine running FreeSWITCH. This IP can be found by typing \"sofia status\" at the\n";
|
||||
$xml .= " CLI. You will register your phones to the IP and not the hostname by default.\n";
|
||||
$xml .= " If you wish to register using the domain please open vars.xml in the root conf\n";
|
||||
$xml .= " directory and set the default domain to the hostname you desire. Then you would\n";
|
||||
$xml .= " use the domain name in the client instead of the IP address to register\n";
|
||||
$xml .= " with FreeSWITCH.\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$xml .= "-->\n";
|
||||
$xml .= "\n";
|
||||
$xml .= "<include>\n";
|
||||
$xml .= " <!--the domain or ip (the right hand side of the @ in the addr-->\n";
|
||||
if ($user_context == "default") {
|
||||
$xml .= " <domain name=\"\$\${domain}\">\n";
|
||||
}
|
||||
else {
|
||||
$xml .= " <domain name=\"".$user_context."\">\n";
|
||||
}
|
||||
$xml .= " <params>\n";
|
||||
//$xml .= " <param name=\"dial-string\" value=\"{sip_invite_domain=\${domain_name},presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}\"/>\n";
|
||||
$xml .= " </params>\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " <variables>\n";
|
||||
$xml .= " <variable name=\"record_stereo\" value=\"true\"/>\n";
|
||||
$xml .= " <variable name=\"default_gateway\" value=\"\$\${default_provider}\"/>\n";
|
||||
$xml .= " <variable name=\"default_areacode\" value=\"\$\${default_areacode}\"/>\n";
|
||||
$xml .= " <variable name=\"transfer_fallback_extension\" value=\"operator\"/>\n";
|
||||
$xml .= " <variable name=\"export_vars\" value=\"domain_name\"/>\n";
|
||||
$xml .= " </variables>\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " <groups>\n";
|
||||
$xml .= " <group name=\"".$user_context."\">\n";
|
||||
$xml .= " <users>\n";
|
||||
$xml .= " <X-PRE-PROCESS cmd=\"include\" data=\"".$user_context."/*.xml\"/>\n";
|
||||
$xml .= " </users>\n";
|
||||
$xml .= " </group>\n";
|
||||
$xml .= "\n";
|
||||
$previous_call_group = "";
|
||||
foreach ($call_group_array as $key => $value) {
|
||||
$call_group = trim($key);
|
||||
$extension_list = trim($value);
|
||||
if (strlen($call_group) > 0) {
|
||||
if ($previous_call_group != $call_group) {
|
||||
$xml .= " <group name=\"$call_group\">\n";
|
||||
$xml .= " <users>\n";
|
||||
$xml .= " <!--\n";
|
||||
$xml .= " type=\"pointer\" is a pointer so you can have the\n";
|
||||
$xml .= " same user in multiple groups. It basically means\n";
|
||||
$xml .= " to keep searching for the user in the directory.\n";
|
||||
$xml .= " -->\n";
|
||||
$extension_array = explode(",", $extension_list);
|
||||
foreach ($extension_array as &$tmp_extension) {
|
||||
$xml .= " <user id=\"$tmp_extension\" type=\"pointer\"/>\n";
|
||||
}
|
||||
$xml .= " </users>\n";
|
||||
$xml .= " </group>\n";
|
||||
$xml .= "\n";
|
||||
}
|
||||
switch ($row['vm_keep_local_after_email']) {
|
||||
case "true":
|
||||
$tmp_xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$tmp_xml .= " <param name=\"vm-keep-local-after-email\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$tmp_xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " <param name=\"vm-mailto\" value=\"" . $row['vm_mailto'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['mwi_account']) > 0) {
|
||||
$tmp_xml .= " <param name=\"MWI-Account\" value=\"" . $row['mwi_account'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['auth_acl']) > 0) {
|
||||
$tmp_xml .= " <param name=\"auth-acl\" value=\"" . $row['auth_acl'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_exten_visible']) > 0) {
|
||||
$tmp_xml .= " <param name=\"directory-exten-visible\" value=\"" . $row['directory_exten_visible'] . "\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " <param name=\"dial-string\" value=\"" . $dial_string . "\"/>\n";
|
||||
$tmp_xml .= " </params>\n";
|
||||
$tmp_xml .= " <variables>\n";
|
||||
if (strlen($row['call_group']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"call_group\" value=\"" . $row['call_group'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['hold_music']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"hold_music\" value=\"" . $row['hold_music'] . "\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " <variable name=\"toll_allow\" value=\"" . $row['toll_allow'] . "\"/>\n";
|
||||
if (strlen($switch_account_code) > 0) {
|
||||
$tmp_xml .= " <variable name=\"accountcode\" value=\"" . $switch_account_code . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$tmp_xml .= " <variable name=\"accountcode\" value=\"" . $row['accountcode'] . "\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " <variable name=\"user_context\" value=\"" . $row['user_context'] . "\"/>\n";
|
||||
if (strlen($row['effective_caller_id_name']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"effective_caller_id_name\" value=\"" . $row['effective_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['effective_caller_id_number']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"effective_caller_id_number\" value=\"" . $row['effective_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_name']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"outbound_caller_id_name\" value=\"" . $row['outbound_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_number']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"outbound_caller_id_number\" value=\"" . $row['outbound_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['emergency_caller_id_number']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"emergency_caller_id_number\" value=\"" . $row['emergency_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_full_name']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"directory_full_name\" value=\"" . $row['directory_full_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_visible']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"directory-visible\" value=\"" . $row['directory_visible'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['limit_max']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"limit_max\" value=\"" . $row['limit_max'] . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$tmp_xml .= " <variable name=\"limit_max\" value=\"5\"/>\n";
|
||||
}
|
||||
if (strlen($row['limit_destination']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"limit_destination\" value=\"" . $row['limit_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_force_contact']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"sip-force-contact\" value=\"" . $row['sip_force_contact'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_force_expires']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"sip-force-expires\" value=\"" . $row['sip_force_expires'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['nibble_account']) > 0) {
|
||||
$tmp_xml .= " <variable name=\"nibble_account\" value=\"" . $row['nibble_account'] . "\"/>\n";
|
||||
}
|
||||
switch ($row['sip_bypass_media']) {
|
||||
case "bypass-media":
|
||||
$tmp_xml .= " <variable name=\"bypass_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "bypass-media-after-bridge":
|
||||
$tmp_xml .= " <variable name=\"bypass_media_after_bridge\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "proxy-media":
|
||||
$tmp_xml .= " <variable name=\"proxy_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
$previous_call_group = $call_group;
|
||||
}
|
||||
unset($call_group);
|
||||
}
|
||||
$xml .= " </groups>\n";
|
||||
$xml .= "\n";
|
||||
$xml .= " </domain>\n";
|
||||
$xml .= "</include>";
|
||||
|
||||
$tmp_xml .= " </variables>\n";
|
||||
$tmp_xml .= " </user>\n";
|
||||
|
||||
if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) {
|
||||
mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context'],0755,true);
|
||||
}
|
||||
if (strlen($extension) > 0) {
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w");
|
||||
}
|
||||
$tmp_xml .= "</include>\n";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
//write the xml file
|
||||
if (is_readable($extension_dir_path) && strlen($extension_dir_path) > 0) {
|
||||
$fout = fopen($extension_dir_path."/".$user_context.".xml","w");
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//prepare extension
|
||||
$extension_dir_path = realpath($_SESSION['switch']['extensions']['dir']);
|
||||
$user_context = str_replace(" ", "_", $user_context);
|
||||
$user_context = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $user_context);
|
||||
//syncrhonize the phone directory
|
||||
sync_directory();
|
||||
|
||||
//define the group members
|
||||
$tmp_xml = "<!--\n";
|
||||
$tmp_xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " FreeSWITCH works off the concept of users and domains just like email.\n";
|
||||
$tmp_xml .= " You have users that are in domains for example 1000@domain.com.\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " When freeswitch gets a register packet it looks for the user in the directory\n";
|
||||
$tmp_xml .= " based on the from or to domain in the packet depending on how your sofia profile\n";
|
||||
$tmp_xml .= " is configured. Out of the box the default domain will be the IP address of the\n";
|
||||
$tmp_xml .= " machine running FreeSWITCH. This IP can be found by typing \"sofia status\" at the\n";
|
||||
$tmp_xml .= " CLI. You will register your phones to the IP and not the hostname by default.\n";
|
||||
$tmp_xml .= " If you wish to register using the domain please open vars.xml in the root conf\n";
|
||||
$tmp_xml .= " directory and set the default domain to the hostname you desire. Then you would\n";
|
||||
$tmp_xml .= " use the domain name in the client instead of the IP address to register\n";
|
||||
$tmp_xml .= " with FreeSWITCH.\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$tmp_xml .= "-->\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= "<include>\n";
|
||||
$tmp_xml .= " <!--the domain or ip (the right hand side of the @ in the addr-->\n";
|
||||
if ($user_context == "default") {
|
||||
$tmp_xml .= " <domain name=\"\$\${domain}\">\n";
|
||||
}
|
||||
else {
|
||||
$tmp_xml .= " <domain name=\"".$user_context."\">\n";
|
||||
}
|
||||
$tmp_xml .= " <params>\n";
|
||||
//$tmp_xml .= " <param name=\"dial-string\" value=\"{sip_invite_domain=\${domain_name},presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}\"/>\n";
|
||||
$tmp_xml .= " </params>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " <variables>\n";
|
||||
$tmp_xml .= " <variable name=\"record_stereo\" value=\"true\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"default_gateway\" value=\"\$\${default_provider}\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"default_areacode\" value=\"\$\${default_areacode}\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"transfer_fallback_extension\" value=\"operator\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"export_vars\" value=\"domain_name\"/>\n";
|
||||
$tmp_xml .= " </variables>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " <groups>\n";
|
||||
$tmp_xml .= " <group name=\"".$user_context."\">\n";
|
||||
$tmp_xml .= " <users>\n";
|
||||
$tmp_xml .= " <X-PRE-PROCESS cmd=\"include\" data=\"".$user_context."/*.xml\"/>\n";
|
||||
$tmp_xml .= " </users>\n";
|
||||
$tmp_xml .= " </group>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$previous_call_group = "";
|
||||
foreach ($call_group_array as $key => $value) {
|
||||
$call_group = trim($key);
|
||||
$extension_list = trim($value);
|
||||
if (strlen($call_group) > 0) {
|
||||
if ($previous_call_group != $call_group) {
|
||||
$tmp_xml .= " <group name=\"$call_group\">\n";
|
||||
$tmp_xml .= " <users>\n";
|
||||
$tmp_xml .= " <!--\n";
|
||||
$tmp_xml .= " type=\"pointer\" is a pointer so you can have the\n";
|
||||
$tmp_xml .= " same user in multiple groups. It basically means\n";
|
||||
$tmp_xml .= " to keep searching for the user in the directory.\n";
|
||||
$tmp_xml .= " -->\n";
|
||||
$extension_array = explode(",", $extension_list);
|
||||
foreach ($extension_array as &$tmp_extension) {
|
||||
$tmp_xml .= " <user id=\"$tmp_extension\" type=\"pointer\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " </users>\n";
|
||||
$tmp_xml .= " </group>\n";
|
||||
$tmp_xml .= "\n";
|
||||
}
|
||||
$previous_call_group = $call_group;
|
||||
}
|
||||
unset($call_group);
|
||||
}
|
||||
$tmp_xml .= " </groups>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " </domain>\n";
|
||||
$tmp_xml .= "</include>";
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//write the xml file
|
||||
if (is_readable($extension_dir_path) && strlen($extension_dir_path) > 0) {
|
||||
$fout = fopen($extension_dir_path."/".$user_context.".xml","w");
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
fclose($fout);
|
||||
}
|
||||
|
||||
//syncrhonize the phone directory
|
||||
sync_directory();
|
||||
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//$cmd = "api reloadxml";
|
||||
//event_socket_request_cmd($cmd);
|
||||
//unset($cmd);
|
||||
//$cmd = "api reloadxml";
|
||||
//event_socket_request_cmd($cmd);
|
||||
//unset($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
function filename_safe($filename) {
|
||||
|
|
@ -1993,104 +1995,104 @@ function save_gateway_xml() {
|
|||
}
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$fout = fopen($_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$_SESSION['domain_name'].'-'.$gateway.".xml","w");
|
||||
$tmp_xml .= "<include>\n";
|
||||
$tmp_xml .= " <gateway name=\"". $_SESSION['domain_name'] .'-'. $gateway . "\">\n";
|
||||
$xml .= "<include>\n";
|
||||
$xml .= " <gateway name=\"". $_SESSION['domain_name'] .'-'. $gateway . "\">\n";
|
||||
}
|
||||
else {
|
||||
$fout = fopen($_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$gateway.".xml","w");
|
||||
$tmp_xml .= "<include>\n";
|
||||
$tmp_xml .= " <gateway name=\"" . $gateway . "\">\n";
|
||||
$xml .= "<include>\n";
|
||||
$xml .= " <gateway name=\"" . $gateway . "\">\n";
|
||||
}
|
||||
if (strlen($row['username']) > 0) {
|
||||
$tmp_xml .= " <param name=\"username\" value=\"" . $row['username'] . "\"/>\n";
|
||||
$xml .= " <param name=\"username\" value=\"" . $row['username'] . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$tmp_xml .= " <param name=\"username\" value=\"register:false\"/>\n";
|
||||
$xml .= " <param name=\"username\" value=\"register:false\"/>\n";
|
||||
}
|
||||
if (strlen($row['distinct_to']) > 0) {
|
||||
$tmp_xml .= " <param name=\"distinct-to\" value=\"" . $row['distinct_to'] . "\"/>\n";
|
||||
$xml .= " <param name=\"distinct-to\" value=\"" . $row['distinct_to'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['auth_username']) > 0) {
|
||||
$tmp_xml .= " <param name=\"auth-username\" value=\"" . $row['auth_username'] . "\"/>\n";
|
||||
$xml .= " <param name=\"auth-username\" value=\"" . $row['auth_username'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['password']) > 0) {
|
||||
$tmp_xml .= " <param name=\"password\" value=\"" . $row['password'] . "\"/>\n";
|
||||
$xml .= " <param name=\"password\" value=\"" . $row['password'] . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$tmp_xml .= " <param name=\"password\" value=\"register:false\"/>\n";
|
||||
$xml .= " <param name=\"password\" value=\"register:false\"/>\n";
|
||||
}
|
||||
if (strlen($row['realm']) > 0) {
|
||||
$tmp_xml .= " <param name=\"realm\" value=\"" . $row['realm'] . "\"/>\n";
|
||||
$xml .= " <param name=\"realm\" value=\"" . $row['realm'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['from_user']) > 0) {
|
||||
$tmp_xml .= " <param name=\"from-user\" value=\"" . $row['from_user'] . "\"/>\n";
|
||||
$xml .= " <param name=\"from-user\" value=\"" . $row['from_user'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['from_domain']) > 0) {
|
||||
$tmp_xml .= " <param name=\"from-domain\" value=\"" . $row['from_domain'] . "\"/>\n";
|
||||
$xml .= " <param name=\"from-domain\" value=\"" . $row['from_domain'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['proxy']) > 0) {
|
||||
$tmp_xml .= " <param name=\"proxy\" value=\"" . $row['proxy'] . "\"/>\n";
|
||||
$xml .= " <param name=\"proxy\" value=\"" . $row['proxy'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['register_proxy']) > 0) {
|
||||
$tmp_xml .= " <param name=\"register-proxy\" value=\"" . $row['register_proxy'] . "\"/>\n";
|
||||
$xml .= " <param name=\"register-proxy\" value=\"" . $row['register_proxy'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_proxy']) > 0) {
|
||||
$tmp_xml .= " <param name=\"outbound-proxy\" value=\"" . $row['outbound_proxy'] . "\"/>\n";
|
||||
$xml .= " <param name=\"outbound-proxy\" value=\"" . $row['outbound_proxy'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['expire_seconds']) > 0) {
|
||||
$tmp_xml .= " <param name=\"expire-seconds\" value=\"" . $row['expire_seconds'] . "\"/>\n";
|
||||
$xml .= " <param name=\"expire-seconds\" value=\"" . $row['expire_seconds'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['register']) > 0) {
|
||||
$tmp_xml .= " <param name=\"register\" value=\"" . $row['register'] . "\"/>\n";
|
||||
$xml .= " <param name=\"register\" value=\"" . $row['register'] . "\"/>\n";
|
||||
}
|
||||
|
||||
if (strlen($row['register_transport']) > 0) {
|
||||
switch ($row['register_transport']) {
|
||||
case "udp":
|
||||
$tmp_xml .= " <param name=\"register-transport\" value=\"udp\"/>\n";
|
||||
$xml .= " <param name=\"register-transport\" value=\"udp\"/>\n";
|
||||
break;
|
||||
case "tcp":
|
||||
$tmp_xml .= " <param name=\"register-transport\" value=\"tcp\"/>\n";
|
||||
$xml .= " <param name=\"register-transport\" value=\"tcp\"/>\n";
|
||||
break;
|
||||
case "tls":
|
||||
$tmp_xml .= " <param name=\"register-transport\" value=\"tls\"/>\n";
|
||||
$tmp_xml .= " <param name=\"contact-params\" value=\"transport=tls\"/>\n";
|
||||
$xml .= " <param name=\"register-transport\" value=\"tls\"/>\n";
|
||||
$xml .= " <param name=\"contact-params\" value=\"transport=tls\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$tmp_xml .= " <param name=\"register-transport\" value=\"" . $row['register_transport'] . "\"/>\n";
|
||||
$xml .= " <param name=\"register-transport\" value=\"" . $row['register_transport'] . "\"/>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($row['retry_seconds']) > 0) {
|
||||
$tmp_xml .= " <param name=\"retry-seconds\" value=\"" . $row['retry_seconds'] . "\"/>\n";
|
||||
$xml .= " <param name=\"retry-seconds\" value=\"" . $row['retry_seconds'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['extension']) > 0) {
|
||||
$tmp_xml .= " <param name=\"extension\" value=\"" . $row['extension'] . "\"/>\n";
|
||||
$xml .= " <param name=\"extension\" value=\"" . $row['extension'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['ping']) > 0) {
|
||||
$tmp_xml .= " <param name=\"ping\" value=\"" . $row['ping'] . "\"/>\n";
|
||||
$xml .= " <param name=\"ping\" value=\"" . $row['ping'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['context']) > 0) {
|
||||
$tmp_xml .= " <param name=\"context\" value=\"" . $row['context'] . "\"/>\n";
|
||||
$xml .= " <param name=\"context\" value=\"" . $row['context'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['caller_id_in_from']) > 0) {
|
||||
$tmp_xml .= " <param name=\"caller-id-in-from\" value=\"" . $row['caller_id_in_from'] . "\"/>\n";
|
||||
$xml .= " <param name=\"caller-id-in-from\" value=\"" . $row['caller_id_in_from'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['supress_cng']) > 0) {
|
||||
$tmp_xml .= " <param name=\"supress-cng\" value=\"" . $row['supress_cng'] . "\"/>\n";
|
||||
$xml .= " <param name=\"supress-cng\" value=\"" . $row['supress_cng'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_cid_type']) > 0) {
|
||||
$tmp_xml .= " <param name=\"sip_cid_type\" value=\"" . $row['sip_cid_type'] . "\"/>\n";
|
||||
$xml .= " <param name=\"sip_cid_type\" value=\"" . $row['sip_cid_type'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['extension_in_contact']) > 0) {
|
||||
$tmp_xml .= " <param name=\"extension-in-contact\" value=\"" . $row['extension_in_contact'] . "\"/>\n";
|
||||
$xml .= " <param name=\"extension-in-contact\" value=\"" . $row['extension_in_contact'] . "\"/>\n";
|
||||
}
|
||||
|
||||
$tmp_xml .= " </gateway>\n";
|
||||
$tmp_xml .= "</include>";
|
||||
$xml .= " </gateway>\n";
|
||||
$xml .= "</include>";
|
||||
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue