Portions created by the Initial Developer are Copyright (C) 2018 - 2019 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions if (!permission_exists('bridge_view')) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the action if (is_array($_POST["bridges"])) { $bridges = $_POST["bridges"]; foreach($bridges as $row) { if ($row['action'] == 'delete') { $action = 'delete'; break; } } } //delete the bridges if (permission_exists('bridge_delete')) { if ($action == "delete") { //download $obj = new bridges; $obj->delete($bridges); //delete message message::add($text['message-delete']); } } //get order and order by and sanatize the values $order_by = $_GET["order_by"]; $order = $_GET["order"]; //validate order by if (strlen($order_by) > 0) { $order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by); } //validate the order switch ($order) { case 'asc': break; case 'desc': break; default: $order = ''; } //add the parameters $parameters['domain_uuid'] = $domain_uuid; //add the search term $search = strtolower($_GET["search"]); if (strlen($search) > 0) { $sql_search = " ("; $sql_search .= " lower(bridge_name) like :search "; $sql_search .= " or lower(bridge_destination) like :search "; $sql_search .= " or lower(bridge_enabled) like :search "; $sql_search .= ") "; $parameters['search'] = '%'.$search.'%'; } //prepare to page the results $sql = "select count(bridge_uuid) from v_bridges "; if ($_GET['show'] == "all" && permission_exists('bridge_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; } } $database = new database; $num_rows = $database->select($sql, $parameters, 'column'); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; if ($_GET['show'] == "all" && permission_exists('bridge_all')) { $param .= "&show=all"; } $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; //get the list $sql = "select * from v_bridges "; if ($_GET['show'] == "all" && permission_exists('bridge_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; } } $sql .= order_by($order_by, $order); $sql .= limit_offset($rows_per_page, $offset); $database = new database; $bridges = $database->select($sql, $parameters, 'all'); //$message = $database->message; //print_r($message); //alternate the row style $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //include the header require_once "resources/header.php"; //define the checkbox_toggle function echo "\n"; //show the content echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['title-bridges']."
\n"; if (permission_exists('bridge_all')) { if ($_GET['show'] == 'all') { echo " "; } else { echo " \n"; } } echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['title_description-bridge']."

\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo " \n"; echo th_order_by('bridge_name', $text['label-bridge_name'], $order_by, $order); echo th_order_by('bridge_destination', $text['label-bridge_destination'], $order_by, $order); echo th_order_by('bridge_enabled', $text['label-bridge_enabled'], $order_by, $order); echo " \n"; echo "\n"; if (is_array($bridges)) { $x = 0; foreach($bridges as $row) { if (permission_exists('bridge_edit')) { $tr_link = "href='bridge_edit.php?id=".escape($row['bridge_uuid'])."'"; } echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; $x++; $c = $c == 1 ? 0 : 1; } //end foreach unset($sql, $bridges); } //end if results echo "\n"; echo "
\n"; echo " \n"; echo " "; if (permission_exists('bridge_add')) { echo " $v_link_label_add"; } else { echo " \n"; } echo "
".escape($row['bridge_name'])." ".escape($row['bridge_destination'])." ".escape($row['bridge_enabled'])." "; if (permission_exists('bridge_edit')) { echo "$v_link_label_edit"; } if (permission_exists('bridge_delete')) { echo ""; } echo "
\n"; if (permission_exists('bridge_add')) { echo "
\n"; echo " ".$v_link_label_add.""; echo "
\n"; } echo "
\n"; echo "
".$paging_controls."
\n"; echo "
\n"; //include the footer require_once "resources/footer.php"; ?>