Streams: Database class integration.
This commit is contained in:
parent
605861b7f8
commit
889306af83
|
|
@ -39,25 +39,30 @@
|
|||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//delete the message
|
||||
message::add($text['message-delete']);
|
||||
//get id
|
||||
$stream_uuid = $_GET["id"];
|
||||
|
||||
//delete the data
|
||||
if (isset($_GET["id"]) && is_uuid($_GET["id"])) {
|
||||
if (is_uuid($stream_uuid)) {
|
||||
|
||||
//get the id
|
||||
$id = check_str($_GET["id"]);
|
||||
//build array
|
||||
$array['streams'][0]['stream_uuid'] = $stream_uuid;
|
||||
$array['streams'][0]['domain_uuid'] = $domain_uuid;
|
||||
|
||||
//delete stream
|
||||
$sql = "delete from v_streams ";
|
||||
$sql .= "where stream_uuid = '$id' ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'streams';
|
||||
$database->app_uuid = 'ffde6287-aa18-41fc-9a38-076d292e0a38';
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
|
||||
//redirect the user
|
||||
header('Location: streams.php');
|
||||
}
|
||||
|
||||
?>
|
||||
//redirect
|
||||
header('Location: streams.php');
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
|
@ -40,10 +40,10 @@
|
|||
$text = $language->get();
|
||||
|
||||
//action add or update
|
||||
if (isset($_REQUEST["id"])) {
|
||||
if (is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
$stream_uuid = check_str($_REQUEST["id"]);
|
||||
$id = check_str($_REQUEST["id"]);
|
||||
$stream_uuid = $_REQUEST["id"];
|
||||
$id = $_REQUEST["id"];
|
||||
}
|
||||
else {
|
||||
$action = "add";
|
||||
|
|
@ -51,11 +51,11 @@
|
|||
|
||||
//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"]);
|
||||
$stream_uuid = $_POST["stream_uuid"];
|
||||
$stream_name = $_POST["stream_name"];
|
||||
$stream_location = $_POST["stream_location"];
|
||||
$stream_enabled = $_POST["stream_enabled"];
|
||||
$stream_description = $_POST["stream_description"];
|
||||
}
|
||||
|
||||
//process the user data and save it to the database
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
//get the uuid from the POST
|
||||
if ($action == "update") {
|
||||
$stream_uuid = check_str($_POST["stream_uuid"]);
|
||||
$stream_uuid = $_POST["stream_uuid"];
|
||||
}
|
||||
|
||||
//check for all required data
|
||||
|
|
@ -103,19 +103,10 @@
|
|||
//save to the data
|
||||
$database = new database;
|
||||
$database->app_name = 'streams';
|
||||
$database->app_uuid = null;
|
||||
if (strlen($stream_uuid) > 0) {
|
||||
$database->uuid($stream_uuid);
|
||||
}
|
||||
$database->app_uuid = 'ffde6287-aa18-41fc-9a38-076d292e0a38';
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
|
||||
//debug info
|
||||
//echo "<pre>";
|
||||
//print_r($message);
|
||||
//echo "</pre>";
|
||||
//exit;
|
||||
|
||||
//redirect the user
|
||||
if (isset($action)) {
|
||||
if ($action == "add") {
|
||||
|
|
@ -127,24 +118,24 @@
|
|||
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"]);
|
||||
$stream_uuid = $_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) {
|
||||
$sql .= "where stream_uuid = :stream_uuid ";
|
||||
$parameters['stream_uuid'] = $stream_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$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);
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//show the header
|
||||
|
|
@ -190,7 +181,6 @@
|
|||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <select class='formfld' name='stream_enabled'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($stream_enabled == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
|
|
@ -259,4 +249,4 @@
|
|||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
@ -58,23 +58,27 @@
|
|||
$obj->delete($streams);
|
||||
//delete message
|
||||
message::add($text['message-delete']);
|
||||
//redirect
|
||||
header('Location: streams.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//get variables used to control the order
|
||||
$order_by = check_str($_GET["order_by"]);
|
||||
$order = check_str($_GET["order"]);
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
|
||||
//add the search term
|
||||
$search = strtolower(check_str($_GET["search"]));
|
||||
$search = strtolower($_GET["search"]);
|
||||
if (strlen($search) > 0) {
|
||||
$sql_search = " (";
|
||||
$sql_search .= "lower(stream_name) like '%".$search."%' ";
|
||||
$sql_search .= "or lower(stream_location) like '%".$search."%' ";
|
||||
$sql_search .= "or lower(stream_enabled) like '%".$search."%' ";
|
||||
$sql_search .= "or lower(domain_uuid) like '%".$search."%' ";
|
||||
$sql_search .= "or lower(stream_description) like '%".$search."%' ";
|
||||
$sql_search = "and (";
|
||||
$sql_search .= "lower(stream_name) like :search ";
|
||||
$sql_search .= "or lower(stream_location) like :search ";
|
||||
$sql_search .= "or lower(stream_enabled) like :search ";
|
||||
$sql_search .= "or lower(domain_uuid) like :search ";
|
||||
$sql_search .= "or lower(stream_description) like :search ";
|
||||
$sql_search .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
|
||||
//additional includes
|
||||
|
|
@ -82,29 +86,15 @@
|
|||
require_once "resources/paging.php";
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(stream_uuid) as num_rows from v_streams ";
|
||||
if ($_GET['show'] == "all" && permission_exists('stream_all')) {
|
||||
if (isset($sql_search)) {
|
||||
$sql .= "where ".$sql_search;
|
||||
}
|
||||
} else {
|
||||
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
|
||||
if (isset($sql_search)) {
|
||||
$sql .= "and ".$sql_search;
|
||||
}
|
||||
}
|
||||
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
$num_rows = $row['num_rows'];
|
||||
}
|
||||
else {
|
||||
$num_rows = '0';
|
||||
}
|
||||
$sql = "select count(*) from v_streams ";
|
||||
$sql .= "where true ";
|
||||
$sql .= $sql_search;
|
||||
if (!($_GET['show'] == "all" && permission_exists('stream_all'))) {
|
||||
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
}
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, (is_array($parameters) && @sizeof($parameters) != 0 ? $parameters : null), 'column');
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
|
|
@ -118,29 +108,27 @@
|
|||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list
|
||||
$sql = "select * from v_streams ";
|
||||
if ($_GET['show'] == "all" && permission_exists('stream_all')) {
|
||||
if (isset($sql_search)) {
|
||||
$sql .= "where ".$sql_search;
|
||||
}
|
||||
} else {
|
||||
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
|
||||
if (isset($sql_search)) {
|
||||
$sql .= "and ".$sql_search;
|
||||
}
|
||||
}
|
||||
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; }
|
||||
$sql .= "limit $rows_per_page offset $offset ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$streams = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset ($prep_statement, $sql);
|
||||
$sql = str_replace('count(*)', '*', $sql);
|
||||
$sql .= order_by($order_by, $order);
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$streams = $database->select($sql, (is_array($parameters) && @sizeof($parameters) != 0 ? $parameters : null), 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//alternate the row style
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
//audio control styles
|
||||
echo "<style>\n";
|
||||
echo " audio {\n";
|
||||
echo " margin-bottom: -5px;\n";
|
||||
echo " width: 100%;\n";
|
||||
echo " height: 35px;\n";
|
||||
echo " }\n";
|
||||
echo "</style>\n";
|
||||
|
||||
//define the checkbox_toggle function
|
||||
echo "<script type=\"text/javascript\">\n";
|
||||
echo " function checkbox_toggle(item) {\n";
|
||||
|
|
@ -228,23 +216,23 @@
|
|||
else {
|
||||
$domain = $text['label-global'];
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$domain."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='width: 15%; white-space: nowrap;'>".$domain."</td>\n";
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['stream_name'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='width: 15%; white-space: nowrap;'>".escape($row['stream_name'])." </td>\n";
|
||||
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='white-space: nowrap; padding: 0;'>\n";
|
||||
if (strlen($row['stream_location']) > 0) {
|
||||
$location_parts = explode('://',$row['stream_location']);
|
||||
if ($location_parts[0] == "shout") {
|
||||
echo "<audio src=\"http://".$location_parts[1]."\" controls=\"controls\"/>\n";
|
||||
echo "<audio src=\"http://".$location_parts[1]."\" controls=\"controls\" />\n";
|
||||
}
|
||||
}
|
||||
echo " </td>\n";
|
||||
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['stream_location'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['stream_enabled'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='white-space: nowrap;'>".($row['stream_enabled'] == 'true' ? $text['label-true'] : $text['label-false'])."</td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['domain_uuid'])." </td>\n";
|
||||
echo " <td valign='top' class='row_stylebg'>".escape($row['stream_description'])." </td>\n";
|
||||
echo " <td valign='top' class='row_stylebg' style='width: 20%; white-space: nowrap;'>".escape($row['stream_description'])." </td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
if (permission_exists('stream_edit')) {
|
||||
echo "<a href='stream_edit.php?id=".$row['stream_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
|
|
@ -255,10 +243,10 @@
|
|||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
$x++;
|
||||
if ($c==0) { $c=1; } else { $c=0; }
|
||||
} //end foreach
|
||||
unset($sql, $streams, $row_count);
|
||||
} //end if results
|
||||
$c = $c ? 0 : 1;
|
||||
}
|
||||
}
|
||||
unset($streams, $row);
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='7' align='left'>\n";
|
||||
|
|
@ -285,4 +273,4 @@
|
|||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
Loading…
Reference in New Issue