diff --git a/app/sip_profiles/sip_profile_edit.php b/app/sip_profiles/sip_profile_edit.php index 7d4cc01e49..9d9dbfdeea 100644 --- a/app/sip_profiles/sip_profile_edit.php +++ b/app/sip_profiles/sip_profile_edit.php @@ -161,6 +161,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //redirect the browser $_SESSION["message"] = $text['message-update']; header("Location: sip_profiles.php"); + + //save the sip profile xml + save_sip_profile_xml(); + //apply settings reminder + $_SESSION["reload_xml"] = true; + return; } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) diff --git a/resources/switch.php b/resources/switch.php index 2c6b46d89d..43bc154e20 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -2546,12 +2546,15 @@ if (!function_exists('save_sip_profile_xml')) { return; } + // make profile dir if needed + $profile_dir = $_SESSION['switch']['conf']['dir']."/sip_profiles"; + if (!is_readable($profile_dir)) { mkdir($profile_dir,0775,true); } + //get the global variables global $db, $domain_uuid; //get the sip profiles from the database - $sql = "select * from v_sip_profiles "; - $sql .= "where sip_profile_enabled = 'true' "; + $sql = "select * from v_sip_profiles"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); @@ -2559,8 +2562,17 @@ if (!function_exists('save_sip_profile_xml')) { unset ($prep_statement, $sql); if ($result_count > 0) { foreach($result as $row) { - $sip_profile_uuid = $row['sip_profile_uuid']; - $sip_profile_name = $row['sip_profile_name']; + $sip_profile_uuid = $row['sip_profile_uuid']; + $sip_profile_name = $row['sip_profile_name']; + $sip_profile_enabled = $row['sip_profile_enabled']; + + if ($sip_profile_enabled == 'false') { + $fout = fopen($profile_dir.'/'.$sip_profile_name.".xml","w"); + if ($fout) { + fclose($fout); + } + continue; + } //get the xml sip profile template if ($sip_profile_name == "internal" || $sip_profile_name == "external" || $sip_profile_name == "internal-ipv6") { @@ -2588,14 +2600,14 @@ if (!function_exists('save_sip_profile_xml')) { $file_contents = str_replace("{v_sip_profile_settings}", $sip_profile_settings, $file_contents); //write the XML config file - if (is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/")) { - $fout = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name.".xml","w"); + if (is_readable($profile_dir.'/')) { + $fout = fopen($profile_dir.'/'.$sip_profile_name.".xml","w"); fwrite($fout, $file_contents); fclose($fout); } //if the directory does not exist then create it - if (!is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name)) { mkdir($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name,0775,true); } + if (!is_readable($profile_dir.'/'.$sip_profile_name)) { mkdir($profile_dir.'/'.$sip_profile_name,0775,true); } } //end foreach unset($sql, $result, $row_count);