Portions created by the Initial Developer are Copyright (C) 2018 the Initial Developer. All Rights Reserved. */ //includes require_once "root.php"; require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('bridge_add') || permission_exists('bridge_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $bridge_uuid = check_str($_REQUEST["id"]); $id = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (is_array($_POST)) { $bridge_uuid = check_str($_POST["bridge_uuid"]); $bridge_name = check_str($_POST["bridge_name"]); $bridge_destination = check_str($_POST["bridge_destination"]); $bridge_enabled = check_str($_POST["bridge_enabled"]); } //process the user data and save it to the database if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //get the uuid from the POST if ($action == "update") { $bridge_uuid = check_str($_POST["bridge_uuid"]); } //check for all required data $msg = ''; if (strlen($bridge_name) == 0) { $msg .= $text['message-required']." ".$text['label-bridge_name']."
\n"; } if (strlen($bridge_destination) == 0) { $msg .= $text['message-required']." ".$text['label-bridge_destination']."
\n"; } if (strlen($bridge_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-bridge_enabled']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //set the domain_uuid $_POST["domain_uuid"] = $_SESSION["domain_uuid"]; //add the bridge_uuid if (strlen($_POST["bridge_uuid"]) == 0) { $bridge_uuid = uuid(); $_POST["bridge_uuid"] = $bridge_uuid; } //prepare the array $array['bridges'][0] = $_POST; //save to the data $database = new database; $database->app_name = 'bridges'; $database->app_uuid = null; if (strlen($bridge_uuid) > 0) { $database->uuid($bridge_uuid); } $database->save($array); $message = $database->message; //debug info //echo "
";
			//print_r($message);
			//echo "
"; //exit; //redirect the user if (isset($action)) { if ($action == "add") { $_SESSION["message"] = $text['message-add']; } if ($action == "update") { $_SESSION["message"] = $text['message-update']; } header('Location: bridge_edit.php?id='.$bridge_uuid); return; } } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { $bridge_uuid = check_str($_GET["id"]); $sql = "select * from v_bridges "; $sql .= "where bridge_uuid = '$bridge_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $bridge_name = $row["bridge_name"]; $bridge_destination = $row["bridge_destination"]; $bridge_enabled = $row["bridge_enabled"]; } unset ($prep_statement); } //show the header require_once "resources/header.php"; //show the content echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
".$text['title-bridge']."

\n"; echo " "; echo " "; echo "
\n"; echo " ".$text['label-bridge_name']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-bridge_name']."\n"; echo "
\n"; echo " ".$text['label-bridge_destination']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-bridge_destination']."\n"; echo "
\n"; echo " ".$text['label-bridge_enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-bridge_enabled']."\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
"; echo "
"; echo "

"; //include the footer require_once "resources/footer.php"; ?>