2020-05-16 18:18:32 +00:00
|
|
|
<?php
|
2020-05-23 21:47:15 +00:00
|
|
|
require 'Database.php';
|
|
|
|
|
|
|
|
$conn = Database::getInstance()->getConnection();
|
2020-05-16 18:18:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['action'])) {
|
2020-05-23 21:47:15 +00:00
|
|
|
$action = $_POST['action'];
|
|
|
|
switch ($action) {
|
|
|
|
case "getMovies":
|
|
|
|
$query = "SELECT movie_id,movie_name FROM videos ORDER BY likes DESC,movie_name ASC";
|
|
|
|
$result = $conn->query($query);
|
|
|
|
$rows = array();
|
|
|
|
while ($r = mysqli_fetch_assoc($result)) {
|
2020-05-24 09:49:37 +00:00
|
|
|
array_push($rows, $r);
|
2020-05-23 21:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo(json_encode($rows));
|
|
|
|
break;
|
|
|
|
case "loadVideo":
|
|
|
|
$query = "SELECT movie_url,thumbnail FROM videos WHERE movie_id='" . $_POST['movieid'] . "'";
|
|
|
|
|
|
|
|
$result = $conn->query($query);
|
|
|
|
$row = $result->fetch_assoc();
|
|
|
|
|
|
|
|
$arr = array();
|
|
|
|
$arr["thumbnail"] = $row["thumbnail"];
|
|
|
|
$arr["movie_url"] = $row["movie_url"];
|
|
|
|
echo(json_encode($arr));
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "getDbSize":
|
|
|
|
$query = "SELECT table_schema AS \"Database\",
|
|
|
|
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS \"Size\"
|
|
|
|
FROM information_schema.TABLES
|
2020-05-24 09:49:37 +00:00
|
|
|
WHERE TABLE_SCHEMA='hub'
|
2020-05-23 21:47:15 +00:00
|
|
|
GROUP BY table_schema;";
|
|
|
|
$result = $conn->query($query);
|
|
|
|
|
|
|
|
if ($result->num_rows == 1) {
|
|
|
|
$row = $result->fetch_assoc();
|
2020-05-16 18:18:32 +00:00
|
|
|
|
2020-05-24 09:49:37 +00:00
|
|
|
echo '{"data":"' . $row["Size"] . 'MB"}';
|
2020-05-23 21:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "readThumbnail":
|
|
|
|
$query = "SELECT thumbnail FROM videos WHERE movie_id='" . $_POST['movieid'] . "'";
|
|
|
|
|
|
|
|
$result = $conn->query($query);
|
|
|
|
$row = $result->fetch_assoc();
|
|
|
|
|
|
|
|
echo($row["thumbnail"]);
|
|
|
|
|
2020-05-24 09:49:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "getTags":
|
|
|
|
$query = "SELECT * FROM video_tags INNER JOIN tags t on video_tags.tag_id = t.tag_id WHERE video_id='" . $_POST['movieid'] . "'";
|
|
|
|
#$query = "SELECT thumbnail FROM videos WHERE movie_id='" . $_POST['movieid'] . "'";
|
|
|
|
|
|
|
|
$result = $conn->query($query);
|
|
|
|
$row = $result->fetch_assoc();
|
|
|
|
|
|
|
|
echo($row["thumbnail"]);
|
|
|
|
|
2020-05-23 21:47:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo('{"data":"error"}');
|
2020-05-16 18:18:32 +00:00
|
|
|
}
|
2020-05-23 21:47:15 +00:00
|
|
|
return;
|
|
|
|
|