getMessage()); die("Error: " . $errorMsg); }); if (session_status() === PHP_SESSION_NONE) { session_start(); } if ($_SESSION['role'] == "Reseller") { die("Resellers can't access this."); } if (!isset($_SESSION['app'])) { die("Application not selected."); } if (isset($_POST['draw'])) { // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ $draw = intval($_POST['draw']); $row = intval($_POST['start']); $rowperpage = intval($_POST['length']); // Rows display per page $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']) +1; // Column index $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value // whitelist certain column names and sort orders to prevent SQL injection if (!in_array($columnName, array("type"))) { die("Column name is not whitelisted."); } if (!in_array($columnSortOrder, array("desc", "asc"))) { die("Column sort order is not whitelisted."); } if (!is_null($searchValue)) { $query = misc\mysql\query("select * from `bans` WHERE (`ip` like ? or `hwid` like ? or `type` like ? ) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); } else { $query = misc\mysql\query("select * from `bans` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); } $data = array(); while ($row = mysqli_fetch_assoc($query->result)) { $data[] = array( "data" => '' . ($row["hwid"] ?? $row["ip"]) . '', "type" => $row["type"], "actions" => '
', ); } ## Response $response = array( "draw" => intval($draw), "aaData" => $data ); die(json_encode($response)); } die("Request not from datatables, aborted.");