Portions created by the Initial Developer are Copyright (C) 2008-2020 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('database_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the http post data if (is_array($_POST['databases'])) { $action = $_POST['action']; $databases = $_POST['databases']; } //process the http post data by action if ($action != '' && is_array($databases) && @sizeof($databases) != 0) { switch ($action) { case 'copy': if (permission_exists('database_add')) { $obj = new databases; $obj->copy($databases); } break; case 'delete': if (permission_exists('database_delete')) { $obj = new databases; $obj->delete($databases); } break; } header('Location: databases.php'); exit; } //get variables used to control the order $order_by = $_GET["order_by"]; $order = $_GET["order"]; //prepare to page the results $sql = "select count(*) from v_databases "; $database = new database; $num_rows = $database->select($sql, null, 'column'); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = ""; $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; //get the list $sql = str_replace('count(*)', '*', $sql); $sql .= order_by($order_by, $order); $sql .= limit_offset($rows_per_page, $offset); $database = new database; $databases = $database->select($sql, null, 'all'); unset($sql); //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //include the header $document['title'] = $text['title-databases']; require_once "resources/header.php"; //show the content echo "
\n"; echo "
".$text['header-databases']." (".$num_rows.")
\n"; echo "
\n"; if (permission_exists('database_add')) { echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'database_edit.php']); } if (permission_exists('database_add') && $databases) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]); } if (permission_exists('database_delete') && $databases) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]); } echo "
\n"; echo "
\n"; echo "
\n"; echo $text['description-databases']."\n"; echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('database_add') || permission_exists('database_delete')) { echo " \n"; } echo th_order_by('database_driver', $text['label-driver'], $order_by, $order); echo th_order_by('database_type', $text['label-type'], $order_by, $order); echo th_order_by('database_host', $text['label-host'], $order_by, $order); echo th_order_by('database_name', $text['label-name'], $order_by, $order); echo th_order_by('database_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'"); if (permission_exists('database_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo " \n"; } echo "\n"; if (is_array($databases) && @sizeof($databases) != 0) { $x = 0; foreach ($databases as $row) { $list_row_url = "database_edit.php?id=".urlencode($row['database_uuid']); echo "\n"; if (permission_exists('database_add') || permission_exists('database_delete')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if (permission_exists('database_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo " \n"; } echo "\n"; $x++; } unset($databases); } echo "
\n"; echo " \n"; echo "  
\n"; echo " \n"; echo " \n"; echo " ".escape($row['database_driver'])." ".escape($row['database_type'])." ".escape($row['database_host'])." "; if (permission_exists('database_edit')) { echo "".escape($row['database_name']).""; } else { echo escape($row['database_name']); } echo " ".escape($row['database_description'])." \n"; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo "
\n"; echo "
\n"; echo "
".$paging_controls."
\n"; echo "\n"; echo "
\n"; //include the footer require_once "resources/footer.php"; ?>