-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovie.php
More file actions
executable file
·256 lines (226 loc) · 8.22 KB
/
Copy pathmovie.php
File metadata and controls
executable file
·256 lines (226 loc) · 8.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
session_start(); // Start the session
// Database connection
include('dbconnection.php');
$sql = "Select * from users";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
// Handle logout
if (isset($_GET['logout'])) {
session_destroy();
header("Location: index.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cine Nepal Cineplex</title>
<link rel="stylesheet" href="styles.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
<link rel="stylesheet" href="movie.css" />
</head>
<body class="body">
<section id="header">
<?php
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
echo '
<nav>
<div class="logo">
<a href="index.php">
<img src="Images/logo12.png" alt="" />
</a>
</div>
<ul>
<li class="active"><a href="index.php">Home</a></li>
<li>Movie</li>
<li><a href="ticket.php">Ticket Rate</a></li>
</ul>
<div class="login">
<button><a href="login.php">Login</a></button>
</div>
</nav>';
} else {
echo '
<nav>
<div class="logo">
<a href="index.php">
<img src="Images/logo12.png" alt="" />
</a>
</div>
<ul>
<li ><a href="index.php">Home</a></li>
<li>My Tickets</li>
<li class="active"><a href="booking.php">Booking</a></li>
<li><a href="movie.php">Movie</a></li>
<li><a href="ticket.php">Ticket Rate</a></li>
</ul>
<div class="after">
<ion-icon name="person-circle-outline" class="icon"></ion-icon>
<a href="user.php?uid=' . $row["uid"] . '">
<h2 class="session-user">' . htmlspecialchars($_SESSION["email"]) . '</h2>
</a>
</div>
<div class="logout">
<button><a href="?logout=true">Logout</a></button>
</div>
</nav>';
}
?>
</section>
<div class="tab-titles">
<p class="tab-links active-link" onclick="opentab('trending'); getData()">
Popular
</p>
<p class="tab-links" onclick="opentab('upcoming'); upcoming()">
Upcoming
</p>
</div>
<div class="tab-contents active-tab" id="trending">
<div id="show"></div>
</div>
<div class="tab-contents" id="upcoming">
<div id="upcoming-show"></div>
</div>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<div id="modal-video-container"></div>
</div>
</div>
<script>
let tablinks = document.getElementsByClassName("tab-links");
let tabcontents = document.getElementsByClassName("tab-contents");
let allData = [];
function opentab(tabname) {
for (let tablink of tablinks) {
tablink.classList.remove("active-link");
}
for (let tabcontent of tabcontents) {
tabcontent.classList.remove("active-tab");
}
event.currentTarget.classList.add("active-link");
document.getElementById(tabname).classList.add("active-tab");
}
async function getData() {
let response = await fetch(
"https://api.themoviedb.org/3/movie/popular?api_key=4e44d9029b1270a757cddc766a1bcb63&language=en-US"
);
let data = await response.json();
allData = data.results;
display(data.results);
}
function display(data) {
let content = "";
let showmovie = document.getElementById("show");
data.forEach((element, index) => {
content += `
<div class="movies">
<img src="https://image.tmdb.org/t/p/w500${element.poster_path}">
<p class="title">${element.title}</p>
<p class="duration">Released Date:${element.release_date}</p>
<div class="layer">
<button class="btn trailer" onclick="trailer(event,${index})">Trailer</button>
<button class="btn" onclick="detail(event, ${index})">View Detail</button>
</div>
</div>`;
});
showmovie.innerHTML = content;
}
async function upcoming() {
let response = await fetch(
"https://api.themoviedb.org/3/movie/upcoming?api_key=4e44d9029b1270a757cddc766a1bcb63&language=en-US"
);
let data = await response.json();
allData = data.results;
display1(data.results);
}
function display1(data) {
let content = "";
let showmovie = document.getElementById("upcoming-show");
data.forEach((element, index) => {
content += `
<div class="movies">
<img src="https://image.tmdb.org/t/p/w500${element.poster_path}">
<p class="title">${element.title}</p>
<p class="duration">Released Date:${element.release_date}</p>
<div class="layer">
<button class="btn trailer" onclick="trailer(event,${index})">Trailer</button>
<button class="btn" onclick="detail(event, ${index})">View Detail</button>
</div>
</div>`;
});
showmovie.innerHTML = content;
}
function trailer(event, index) {
let selectedmovie = allData[index];
const apiKey = "4e44d9029b1270a757cddc766a1bcb63";
const movieId = selectedmovie.id;
fetch(
`https://api.themoviedb.org/3/movie/${movieId}/videos?api_key=${apiKey}&language=en-US`
)
.then((response) => response.json())
.then((data) => {
const videoKey = data.results[0]?.key;
if (videoKey) {
displayVideo(videoKey);
} else {
document.getElementById("modal-video-container").innerText =
"No video found.";
}
})
.catch((error) => {
console.error("Error fetching movie data:", error);
document.getElementById("modal-video-container").innerText =
"Error fetching video.";
});
event.preventDefault(); // Prevent default button action
}
function displayVideo(videoKey) {
const videoUrl = `https://www.youtube.com/embed/${videoKey}`;
const iframe = document.createElement("iframe");
iframe.src = videoUrl;
iframe.width = "70%";
iframe.height = "315";
iframe.frameBorder = "0";
iframe.allow =
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
iframe.allowFullscreen = true;
// Clear previous content in modal
const modalVideoContainer = document.getElementById(
"modal-video-container"
);
modalVideoContainer.innerHTML = "";
modalVideoContainer.appendChild(iframe);
// Show modal
document.getElementById("myModal").style.display = "block";
// Add click event to close the modal
document.querySelector(".close").onclick = function() {
document.getElementById("myModal").style.display = "none";
// Remove the iframe to stop the video from playing
modalVideoContainer.innerHTML = "";
};
// Close modal if user clicks outside of modal content
}
function detail(event, index) {
let selectedmovie = allData[index];
localStorage.setItem("selectedMovies", JSON.stringify(selectedmovie));
window.location.href = "moooviedetail.html";
}
getData();
</script>
<script
type="module"
src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<script
nomodule
src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
<script src="index.js"></script>
</body>
</html>