2020-03-31 09:44:52 +00:00
|
|
|
<?php
|
2020-04-04 10:21:30 +00:00
|
|
|
require 'Database.php';
|
2020-03-31 17:22:08 +00:00
|
|
|
|
2020-04-04 10:21:30 +00:00
|
|
|
$conn = Database::getInstance()->getConnection();
|
2020-03-31 17:22:08 +00:00
|
|
|
|
|
|
|
if (isset($_POST['action'])) {
|
|
|
|
$action = $_POST['action'];
|
|
|
|
switch ($action) {
|
|
|
|
case "getMovies":
|
|
|
|
echo('{"data":[{"url":"./vid.mp4"}]}');
|
|
|
|
break;
|
2020-04-01 19:53:36 +00:00
|
|
|
case "getDbSize":
|
2020-04-04 10:21:30 +00:00
|
|
|
$query = "SELECT table_schema AS \"Database\",
|
2020-04-01 19:53:36 +00:00
|
|
|
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS \"Size\"
|
|
|
|
FROM information_schema.TABLES
|
|
|
|
WHERE TABLE_SCHEMA='test'
|
|
|
|
GROUP BY table_schema;";
|
|
|
|
$result = $conn->query($query);
|
|
|
|
|
|
|
|
if ($result->num_rows == 1) {
|
|
|
|
$row = $result->fetch_assoc();
|
|
|
|
|
2020-04-04 10:21:30 +00:00
|
|
|
echo '{"data":"' . $row["Size"] . '"}';
|
2020-04-01 19:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "storePic":
|
|
|
|
// Select file type
|
2020-04-04 10:21:30 +00:00
|
|
|
$imageFileType = strtolower(pathinfo("./lukas.png", PATHINFO_EXTENSION));
|
2020-04-01 19:53:36 +00:00
|
|
|
// Convert to base64
|
2020-04-04 10:21:30 +00:00
|
|
|
$image_base64 = base64_encode(file_get_contents("./lukas.png"));
|
|
|
|
$image = 'data:image/' . $imageFileType . ';base64,' . $image_base64;
|
2020-04-01 19:53:36 +00:00
|
|
|
// Insert record
|
2020-04-04 10:21:30 +00:00
|
|
|
$query = "insert into temppic(data) values('" . $image . "')";
|
2020-04-01 19:53:36 +00:00
|
|
|
if ($conn->query($query) === TRUE) {
|
|
|
|
echo('{"data":"successfully created entry"}');
|
|
|
|
} else {
|
2020-04-04 10:21:30 +00:00
|
|
|
echo('{"data":"' . $conn->error . '"}');
|
2020-04-01 19:53:36 +00:00
|
|
|
}
|
2020-04-04 10:21:30 +00:00
|
|
|
break;
|
|
|
|
case "readPic":
|
2020-04-04 17:44:31 +00:00
|
|
|
$query = "SELECT * FROM Movie WHERE movieid='3'";
|
2020-04-04 10:21:30 +00:00
|
|
|
|
|
|
|
$result = $conn->query($query);
|
|
|
|
$row = $result->fetch_assoc();
|
|
|
|
|
2020-04-04 17:44:31 +00:00
|
|
|
echo($row["poster"]);
|
2020-04-04 10:21:30 +00:00
|
|
|
|
2020-04-01 19:53:36 +00:00
|
|
|
break;
|
2020-03-31 17:22:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-04-01 19:53:36 +00:00
|
|
|
echo('{"data":"error"}');
|
2020-03-31 09:44:52 +00:00
|
|
|
}
|
2020-04-04 10:21:30 +00:00
|
|
|
return;
|