The administration panel and web client for ParEdu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

119 lines
3.9 KiB

<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Pragma: no-cache");
header('Content-Type: application/json');
$servername = "localhost";
$username = "paredu";
$password = "d5X5\$cN$9G";
$dbname = "paredu";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
header('Content-Type: application/json');
echo json_encode(array('response' => "Database connection error (".$conn->connect_error.")"));
exit;
}
if(isset($_GET["type"])){
$type = $_GET["type"];
}else{
$type = null;
}
if($type == null){
echo json_encode(array('response' => "No type specified"));
}else{
switch($type){
case "schools":
$list = array();
if ($result = $conn->query("SELECT * FROM `schools`")) {
while($row = $result->fetch_assoc()) {
$list[] = $row;
}
echo json_encode($list);
}
$result->close();
$conn->close();
break;
case "events":
echo json_encode(array('events' => "Linamar"));
break;
case "image":
if(isset($_GET["subtype"])){
$subtype = $_GET["subtype"];
}else{
echo json_encode(array('response' => "No subtype specified"));
}
switch($subtype){
case "school":
header('Content-Type: image/png');
$file = "../images/school/".$_GET["id"].".png";
if(file_exists($file)){
include $file;
}else{
include "../images/default.png";
}
break;
case "user":
header('Content-Type: image/png');
$file = "../images/user/".$_GET["id"].".png";
if(file_exists($file)){
include $file;
}else{
include "../images/user/default.png";
}
break;
default:
echo json_encode(array('response' => "Invalid subtype specified"));
break;
}
break;
case "string":
if(isset($_GET["subtype"])){
$subtype = $_GET["subtype"];
}else{
echo json_encode(array('response' => "No subtype specified"));
}
//if(isset($_GET["lang"])){
// $lang = $_GET["lang"];
//}else{
// echo json_encode(array('response' => "No language specified"));
//}
switch($subtype){
case "school":
$list = array();
if ($result = $conn->query("SELECT * FROM `schooltypes`")) {
while($row = $result->fetch_assoc()) {
$list[] = $row;
}
echo json_encode($list);
}
$result->close();
$conn->close();
break;
case "user":
$list = array();
if ($result = $conn->query("SELECT * FROM `acctypes`")) {
while($row = $result->fetch_assoc()) {
$list[] = $row;
}
echo json_encode($list);
}
$result->close();
$conn->close();
break;
default:
break;
}
break;
default:
echo json_encode(array('response' => "Invalid type specified"));
break;
}
}
?>