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('stream_add') || permission_exists('stream_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";
$stream_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)) {
$stream_uuid = check_str($_POST["stream_uuid"]);
$stream_name = check_str($_POST["stream_name"]);
$stream_location = check_str($_POST["stream_location"]);
$stream_enabled = check_str($_POST["stream_enabled"]);
$stream_description = check_str($_POST["stream_description"]);
}
//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") {
$stream_uuid = check_str($_POST["stream_uuid"]);
}
//check for all required data
$msg = '';
if (strlen($stream_name) == 0) { $msg .= $text['message-required']." ".$text['label-stream_name']."
\n"; }
if (strlen($stream_location) == 0) { $msg .= $text['message-required']." ".$text['label-stream_location']."
\n"; }
if (strlen($stream_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-stream_enabled']."
\n"; }
//if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; }
//if (strlen($stream_description) == 0) { $msg .= $text['message-required']." ".$text['label-stream_description']."
\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "
| \n";
echo $msg." "; 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: stream_edit.php?id='.$stream_uuid); return; } } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { $stream_uuid = check_str($_GET["id"]); $sql = "select * from v_streams "; $sql .= "where stream_uuid = '".$stream_uuid."' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $domain_uuid = $row["domain_uuid"]; $stream_name = $row["stream_name"]; $stream_location = $row["stream_location"]; $stream_enabled = $row["stream_enabled"]; $stream_description = $row["stream_description"]; } unset ($prep_statement); } //show the header require_once "resources/header.php"; //show the content echo ""; echo "