[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: dashboard_counts.php
<?php // api/dashboard_counts.php header('Content-Type: application/json'); include("functions.php"); $s_code = $_GET['s_code'] ?? ''; if ($s_code === '') { http_response_code(400); echo json_encode(['error' => 'Missing s_code']); exit; } // Helper to run a single-row COUNTs query safely function row_or_zeros(mysqli $new, string $sql, array $params, array $keys) { $stmt = $new->prepare($sql); if (!$stmt) { return array_fill_keys($keys, 0); } // bind all params as strings $types = str_repeat('s', count($params)); $stmt->bind_param($types, ...$params); $stmt->execute(); $res = $stmt->get_result(); $row = $res ? $res->fetch_assoc() : null; $stmt->close(); if (!$row) { $row = []; } foreach ($keys as $k) { if (!isset($row[$k])) { $row[$k] = 0; } } // cast to int foreach ($row as $k => $v) { $row[$k] = (int)$v; } return $row; } // CARD 1: Placed by CSSPS (enrol_generic by s_code) $card1 = row_or_zeros( $new, "SELECT COUNT(*) AS total, SUM(CASE WHEN LOWER(gender)='male' THEN 1 ELSE 0 END) AS male, SUM(CASE WHEN LOWER(gender)='female' THEN 1 ELSE 0 END) AS female, SUM(CASE WHEN LOWER(status)='boarding' THEN 1 ELSE 0 END) AS boarding, SUM(CASE WHEN LOWER(status)='day' THEN 1 ELSE 0 END) AS day FROM enrol_generic WHERE s_code=?", [$s_code], ['total','male','female','boarding','day'] ); // CARD 2: Completed online Admission $card2 = row_or_zeros( $new, "SELECT COUNT(DISTINCT ed.index_no) AS total, SUM(CASE WHEN LOWER(eg.gender)='male' THEN 1 ELSE 0 END) AS male, SUM(CASE WHEN LOWER(eg.gender)='female' THEN 1 ELSE 0 END) AS female, SUM(CASE WHEN LOWER(eg.status)='boarding' THEN 1 ELSE 0 END) AS boarding, SUM(CASE WHEN LOWER(eg.status)='day' THEN 1 ELSE 0 END) AS day FROM enrol_details ed JOIN enrol_generic eg ON ed.index_no = eg.indexNo WHERE ed.s_code=? AND ed.raw_score IS NOT NULL", [$s_code], ['total','male','female','boarding','day'] ); // CARD 3: Yet to perform Online Admission $card3 = row_or_zeros( $new, "SELECT COUNT(DISTINCT eg.indexNo) AS total, SUM(CASE WHEN LOWER(eg.gender)='male' THEN 1 ELSE 0 END) AS male, SUM(CASE WHEN LOWER(eg.gender)='female' THEN 1 ELSE 0 END) AS female, SUM(CASE WHEN LOWER(eg.status)='boarding' THEN 1 ELSE 0 END) AS boarding, SUM(CASE WHEN LOWER(eg.status)='day' THEN 1 ELSE 0 END) AS day FROM enrol_generic eg LEFT JOIN enrol_details ed ON ed.index_no = eg.indexNo AND ed.s_code = ? WHERE eg.s_code=? AND ed.index_no IS NULL", [$s_code, $s_code], ['total','male','female','boarding','day'] ); echo json_encode(['card1'=>$card1,'card2'=>$card2,'card3'=>$card3]);
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: 60.07 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