function save_switch_xml() { if (is_readable($_SESSION['switch']['dialplan']['dir'])) { save_dialplan_xml(); } if (is_readable($_SESSION['switch']['extensions']['dir'])) { if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/extensions/resources/classes/extension.php")) { require_once $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "app/extensions/resources/classes/extension.php"; $extension = new extension(); $extension->xml(); } } if (is_readable($_SESSION['switch']['conf']['dir'])) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/settings/app_config.php")) { save_setting_xml(); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/modules/app_config.php")) { save_module_xml(); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/vars/app_config.php")) { save_var_xml(); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/call_center/app_config.php")) { save_call_center_xml(); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/gateways/app_config.php")) { save_gateway_xml(); } //if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/ivr_menu/app_config.php")) { // save_ivr_menu_xml(); //} if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/sip_profiles/app_config.php")) { save_sip_profile_xml(); } } }
if ($enabled == 'true') { $_SESSION['gateways'][$gateway_uuid] = $gateway; } else { unset($_SESSION['gateways'][$gateway_uuid]); } } //if ($action == "update") //remove xml file (if any) if not enabled if ($enabled != 'true' && $_SESSION['switch']['sip_profiles']['dir'] != '') { $gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir'] . "/" . $profile . "/v_" . $gateway_uuid . ".xml"; if (file_exists($gateway_xml_file)) { unlink($gateway_xml_file); } } //syncrhonize configuration save_gateway_xml(); //delete the sip profiles from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $hostname = trim(event_socket_request($fp, 'api switchname')); $switch_cmd = "memcache delete configuration:sofia.conf:" . $hostname; $switch_result = event_socket_request($fp, 'api ' . $switch_cmd); } //rescan the external profile to look for new or stopped gateways //create the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $tmp_cmd = 'api sofia profile external rescan'; $response = event_socket_request($fp, $tmp_cmd); unset($tmp_cmd); usleep(1000); //close the connection