HomeMediacenter/php/movie.php

57 lines
1.7 KiB
PHP
Raw Normal View History

2020-03-31 09:44:52 +00:00
<?php
2020-03-31 17:22:08 +00:00
$servername = "192.168.0.177";
$username = "myuser";
$password = "1qayxsw2";
2020-04-01 19:53:36 +00:00
$dbname = "test";
2020-03-31 17:22:08 +00:00
// Create connection
2020-04-01 19:53:36 +00:00
$conn = new mysqli($servername, $username, $password, $dbname);
2020-03-31 17:22:08 +00:00
// Check connection
2020-04-01 19:53:36 +00:00
if ($conn->connect_error) {
echo('{"data":"error"}');
return;
}
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":
$query = "SELECT table_schema AS \"Database\",
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();
echo '{"data":"'.$row["Size"].'"}';
}
break;
case "storePic":
// Select file type
$imageFileType = strtolower(pathinfo("./lukas.png",PATHINFO_EXTENSION));
// Convert to base64
$image_base64 = base64_encode(file_get_contents("./lukas.png") );
$image = 'data:image/'.$imageFileType.';base64,'.$image_base64;
// Insert record
$query = "insert into temppic(data) values('".$image."')";
if ($conn->query($query) === TRUE) {
echo('{"data":"successfully created entry"}');
} else {
echo('{"data":"'.$conn->error.'"}');
}
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-01 19:53:36 +00:00
$conn->close();