39 lines
829 B
PHP
39 lines
829 B
PHP
<?php
|
|
$relativePath = "../";
|
|
require_once $relativePath . 'classes/dao.php';
|
|
|
|
$rest_json = file_get_contents("php://input");
|
|
$_POST = json_decode($rest_json, true);
|
|
|
|
|
|
//var_dump($_POST);
|
|
$result = -1;
|
|
$status = 0;
|
|
$message = "Success";
|
|
|
|
$dao = new Dao();
|
|
|
|
if ($_POST["function"] == "create_category")
|
|
$result = $dao->create_category($_POST["data"]);
|
|
else if ($_POST["function"] == "update_category") {
|
|
$result = $dao->update_category($_POST["data"]);
|
|
} else if ($_POST["function"] == "remove_category")
|
|
$result = $dao->remove_category($_POST["data"]);
|
|
else {
|
|
$status = 1;
|
|
$message = "Error: Unknown function";
|
|
}
|
|
|
|
if ($result < 0) {
|
|
$status = 2;
|
|
$message = "Error: SQL error";
|
|
}
|
|
|
|
$array = array(
|
|
"status" => $status,
|
|
"message" => $message,
|
|
"data" => $result,
|
|
);
|
|
|
|
echo json_encode($array);
|
|
|