Portions created by the Initial Developer are Copyright (C) 2018-2024
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
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();
//set the defaults
$stream_name = '';
$stream_location = '';
$stream_description = '';
$stream_uuid = '';
//action add or update
if (!empty($_REQUEST["id"])) {
$action = "update";
$stream_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (count($_POST) > 0) {
$domain_uuid = $_POST['domain_uuid'];
$stream_uuid = $_POST["stream_uuid"];
$stream_name = $_POST["stream_name"];
$stream_location = $_POST["stream_location"];
$stream_enabled = $_POST["stream_enabled"] ?? 'false';
$stream_description = $_POST["stream_description"];
}
//process the user data and save it to the database
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//get the uuid from the POST
if ($action == "update") {
$stream_uuid = $_POST["stream_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: streams.php');
exit;
}
//check for all required data
$msg = '';
if (empty($stream_name)) { $msg .= $text['message-required']." ".$text['label-stream_name']."
\n"; }
if (empty($stream_location)) { $msg .= $text['message-required']." ".$text['label-stream_location']."
\n"; }
if (empty($stream_enabled)) { $msg .= $text['message-required']." ".$text['label-stream_enabled']."
\n"; }
//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; }
//if (empty($stream_description)) { $msg .= $text['message-required']." ".$text['label-stream_description']."
\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "
| \n";
echo $msg." "; echo " |