added display of active series on dashboard
This commit is contained in:
parent
a81e438a56
commit
40a2903319
56
add.php
Normal file
56
add.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (!isset($_SESSION["username"])) {
|
||||||
|
header("Location: /"); // Redirect to the login page if not logged in
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$username = $_SESSION["username"];
|
||||||
|
|
||||||
|
$env = parse_ini_file(".env");
|
||||||
|
|
||||||
|
// Connect to db
|
||||||
|
$conn = new mysqli($env["HOST"], $env["DBUSER"], $env["DBPASS"], $env["TABLE"]);
|
||||||
|
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_id = $conn->query("SELECT * FROM users WHERE username = '$username'")->fetch_assoc()["id"];
|
||||||
|
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
|
||||||
|
// start http client
|
||||||
|
$client = new GuzzleHttp\Client();
|
||||||
|
|
||||||
|
$query = urlencode($_POST["title"]);
|
||||||
|
|
||||||
|
$response = $client->request('GET', 'https://api.themoviedb.org/3/search/multi?query=' . $query . '&include_adult=true&language=en-US', [
|
||||||
|
'headers' => [
|
||||||
|
'Authorization' => 'Bearer ' . $env["ACCESS_TOKEN"],
|
||||||
|
'accept' => 'application/json',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$json = json_decode($response->getBody(), true)["results"][0];
|
||||||
|
|
||||||
|
$season = $_POST["season"];
|
||||||
|
$episode = $_POST["episode"];
|
||||||
|
$name = $_POST["title"];
|
||||||
|
$overview = $json["overview"];
|
||||||
|
$poster = $json["poster_path"];
|
||||||
|
|
||||||
|
$table_name = "user" . $user_id;
|
||||||
|
|
||||||
|
$result = $conn->query("INSERT INTO $table_name (name, season, episode, overview, poster) VALUES ('$name', $season, $episode, '$overview', '$poster') ON DUPLICATE KEY UPDATE season = VALUES(season), episode = VALUES(episode), overview = VALUES(overview), poster = VALUES(poster);");
|
||||||
|
|
||||||
|
if($result) {
|
||||||
|
$conn->close();
|
||||||
|
header("Location: /dashboard.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$conn->close();
|
||||||
|
echo "Error inserting value into database";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -16,16 +16,31 @@ $conn = new mysqli($env["HOST"], $env["DBUSER"], $env["DBPASS"], $env["TABLE"]);
|
|||||||
if($conn->connect_error) {
|
if($conn->connect_error) {
|
||||||
die("Database connection failed: " . $conn->connect_error);
|
die("Database connection failed: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user_id = $conn->query("SELECT * FROM users WHERE username = '$username'")->fetch_assoc()["id"];
|
||||||
|
|
||||||
|
$table = $conn->query("SELECT * FROM user" . $user_id . " ORDER BY name;");
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Dashboard - CineTrack</title>
|
<title>Dashboard - CineTrack</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<style>
|
||||||
|
.left_container {
|
||||||
|
width: 12rem;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.right_container {
|
||||||
|
float: right;
|
||||||
|
height: 100%;
|
||||||
|
width: calc(50rem - 12rem);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>CineTrack</h1>
|
<h1>CineTrack</h1>
|
||||||
<h2>Willkommen, <?php echo $username; ?>!</h2>
|
<h2>Welcome, <?php echo $username; ?>!</h2>
|
||||||
<a href="logout.php">Logout</a>
|
<a href="logout.php">Logout</a>
|
||||||
<br>
|
<br>
|
||||||
<h3>Search Movies, Shows and more...</h3>
|
<h3>Search Movies, Shows and more...</h3>
|
||||||
@ -34,7 +49,28 @@ if($conn->connect_error) {
|
|||||||
<input value="Search" type="submit">
|
<input value="Search" type="submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Output the HTML table
|
||||||
|
if ($table->num_rows > 0) {
|
||||||
|
while($row = $table->fetch_assoc()) {
|
||||||
|
echo "<div style='width:50rem;height:25rem;'>";
|
||||||
|
|
||||||
<?php $conn->close(); ?>
|
echo "<div class='left_container'><img src='https://image.tmdb.org/t/p/original" . $row["poster"] . "' style='width:12rem;'></div>";
|
||||||
|
echo "<div class='right_container'>";
|
||||||
|
echo $row["overview"];
|
||||||
|
echo "<br>";
|
||||||
|
|
||||||
|
echo "<div style='text-align:center;'>";
|
||||||
|
echo "<form method='post' action='add.php'>";
|
||||||
|
echo "<input value='" . $row["name"] . "' style='width:0;height:0;border:none;padding:0 !important;' name='title' required>";
|
||||||
|
echo "<input type='number' name='season' value='" . $row["season"] . "' min='1' style='width:5ch' required>";
|
||||||
|
echo "<input type='number' name='episode' value='" . $row["episode"] . "' min='1' style='width:5ch' required>";
|
||||||
|
echo "<input type='submit' value='Update'>";
|
||||||
|
echo "</form>";
|
||||||
|
echo "</div></div></div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
<?php $conn->close(); ?>
|
||||||
|
23
search.php
23
search.php
@ -1,4 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (!isset($_SESSION["username"])) {
|
||||||
|
header("Location: /"); // Redirect to the login page if not logged in
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$username = $_SESSION["username"];
|
||||||
require_once 'vendor/autoload.php';
|
require_once 'vendor/autoload.php';
|
||||||
|
|
||||||
$env = parse_ini_file(".env");
|
$env = parse_ini_file(".env");
|
||||||
@ -16,9 +24,6 @@ $response = $client->request('GET', 'https://api.themoviedb.org/3/search/multi?q
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$json = json_decode($response->getBody(), true)["results"];
|
$json = json_decode($response->getBody(), true)["results"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -34,7 +39,6 @@ $json = json_decode($response->getBody(), true)["results"];
|
|||||||
<table style="border: thin solid black;border-collapse: collapse;">
|
<table style="border: thin solid black;border-collapse: collapse;">
|
||||||
<tr>
|
<tr>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
foreach($json as $data) {
|
foreach($json as $data) {
|
||||||
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
|
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
|
||||||
echo "<td style='border: thin solid black;'><img src='https://image.tmdb.org/t/p/original";
|
echo "<td style='border: thin solid black;'><img src='https://image.tmdb.org/t/p/original";
|
||||||
@ -62,11 +66,12 @@ $json = json_decode($response->getBody(), true)["results"];
|
|||||||
foreach($json as $data) {
|
foreach($json as $data) {
|
||||||
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
|
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
|
||||||
echo "<td style='border: thin solid black;'>";
|
echo "<td style='border: thin solid black;'>";
|
||||||
echo "<form>";
|
echo "<form method='post' action='add.php'>";
|
||||||
echo "<input type='number' name='season' id='season' value='1' min='1' style='width:5ch' required>";
|
echo "<label>S</label>";
|
||||||
echo "<input type='number' name='episode' id='episode' value='1' min='1' style='width:5ch' required>";
|
echo "<label>Ep</label><br>";
|
||||||
echo "<label for='season'>S</label>";
|
echo "<input value='" . $data["name"] . $data["title"] . "' style='width:0;height:0;border:none;padding:0 !important;' name='title' required>";
|
||||||
echo "<label for='episode'>Ep</label><br>";
|
echo "<input type='number' name='season' value='1' min='1' style='width:5ch' required>";
|
||||||
|
echo "<input type='number' name='episode' value='1' min='1' style='width:5ch' required>";
|
||||||
echo "<input type='submit' value='Add/Change'><br>";
|
echo "<input type='submit' value='Add/Change'><br>";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user