diff --git a/app/dialplans/dialplan_edit.php b/app/dialplans/dialplan_edit.php index 4b783b17dc..46e6f30d6b 100644 --- a/app/dialplans/dialplan_edit.php +++ b/app/dialplans/dialplan_edit.php @@ -66,7 +66,7 @@ } //set the app_uuid - if (is_uuid($_REQUEST["app_uuid"])) { + if (!empty($_REQUEST["app_uuid"]) && is_uuid($_REQUEST["app_uuid"])) { $app_uuid = $_REQUEST["app_uuid"]; } @@ -77,15 +77,15 @@ $dialplan_number = $_POST["dialplan_number"]; $dialplan_order = $_POST["dialplan_order"]; $dialplan_continue = $_POST["dialplan_continue"] != '' ? $_POST["dialplan_continue"] : 'false'; - $dialplan_details = $_POST["dialplan_details"]; + $dialplan_details = $_POST["dialplan_details"] ?? null; $dialplan_context = $_POST["dialplan_context"]; $dialplan_enabled = $_POST["dialplan_enabled"]; $dialplan_description = $_POST["dialplan_description"]; - $dialplan_details_delete = $_POST["dialplan_details_delete"]; + $dialplan_details_delete = $_POST["dialplan_details_delete"] ?? null; } //get the list of applications - if (!is_array($_SESSION['switch']['applications'])) { + if (empty($_SESSION['switch']['applications']) || !is_array($_SESSION['switch']['applications'])) { $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $result = event_socket_request($fp, 'api show application'); @@ -132,11 +132,11 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && is_uuid($_POST['dialplan_uuid'])) { + if (!empty($_POST['action']) && is_uuid($_POST['dialplan_uuid'])) { $array[0]['checked'] = 'true'; $array[0]['uuid'] = $_POST['dialplan_uuid']; - $list_page = 'dialplans.php'.(is_uuid($app_uuid) ? '?app_uuid='.urlencode($app_uuid) : null); + $list_page = 'dialplans.php'.(!empty($app_uuid) && is_uuid($app_uuid) ? '?app_uuid='.urlencode($app_uuid) : null); switch ($_POST['action']) { case 'copy': @@ -148,7 +148,7 @@ permission_exists('time_condition_add') ) { $obj = new dialplan; - $obj->app_uuid = $app_uuid; + $obj->app_uuid = $app_uuid ?? null; $obj->list_page = $list_page; $obj->copy($array); } @@ -162,7 +162,7 @@ permission_exists('time_condition_delete') ) { $obj = new dialplan; - $obj->app_uuid = $app_uuid; + $obj->app_uuid = $app_uuid ?? null; $obj->list_page = $list_page; $obj->delete($array); } @@ -240,7 +240,7 @@ $array['dialplans'][$x]['dialplan_enabled'] = $_POST["dialplan_enabled"]; $array['dialplans'][$x]['dialplan_description'] = $_POST["dialplan_description"]; $y = 0; - if (is_array($_POST["dialplan_details"])) { + if (!empty($_POST["dialplan_details"]) && is_array($_POST["dialplan_details"])) { foreach ($_POST["dialplan_details"] as $row) { if (!empty($row["dialplan_detail_tag"])) { if (!empty($row["dialplan_detail_uuid"])) { @@ -275,7 +275,7 @@ //add or update the database $database = new database; $database->app_name = 'dialplans'; - $database->app_uuid = $app_uuid; + $database->app_uuid = $app_uuid ?? null; if ( strlen($dialplan_uuid)>0 ) $database->uuid($dialplan_uuid); $database->save($array); @@ -290,7 +290,7 @@ ) { $obj = new dialplan; $obj->dialplan_uuid = $dialplan_uuid; - $obj->app_uuid = $app_uuid; + $obj->app_uuid = $app_uuid ?? null; $obj->delete_details($dialplan_details_delete); } @@ -320,13 +320,13 @@ else if ($action == "update") { message::add($text['message-update']); } - header("Location: ?id=".escape($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".$app_uuid : null)); + header("Location: ?id=".escape($dialplan_uuid).(!empty($app_uuid) && is_uuid($app_uuid) ? "&app_uuid=".$app_uuid : null)); exit; } //(count($_POST)>0 && empty($_POST["persistformvar"])) //pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + if (!empty($_GET) && count($_GET) > 0 && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) { $sql = "select * from v_dialplans "; $sql .= "where dialplan_uuid = :dialplan_uuid "; $parameters['dialplan_uuid'] = $dialplan_uuid; @@ -506,10 +506,10 @@ echo "