Settings > Modules) if (!moduleOn('trips')) { http_response_code(403); echo json_encode(['success' => 'False', 'message' => moduleOffText('trips')]); exit(); } $where = 'trips.trip_archived_at IS NULL' . tripScopeSql(); if (isset($_GET['trip_id'])) { $where .= ' AND trips.trip_id = ' . intval($_GET['trip_id']); } if (isset($_GET['user_id'])) { $where .= ' AND trips.trip_user_id = ' . intval($_GET['user_id']); } foreach (['from' => '>=', 'to' => '<='] as $field => $op) { if (!empty($_GET[$field]) && preg_match('/^\d{4}-\d{2}-\d{2}$/', $_GET[$field])) { $where .= " AND trips.trip_date $op '" . escapeSql($_GET[$field]) . "'"; } } $sql = mysqli_query($mysqli, "SELECT trips.*, driver.user_name AS driver_name, client_name FROM trips " . tripJoinsSql() . " WHERE $where " . apiClientScopeSql('trips.trip_client_id') . " ORDER BY trips.trip_date DESC, trips.trip_id DESC LIMIT $limit OFFSET $offset"); // Output require_once "../read_output.php";