-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch.php
322 lines (279 loc) · 10.3 KB
/
search.php
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<?php
session_start();
// Check if the user is logged in (session is set)
$isLoggedIn = isset($_SESSION['username']);
include 'func.php';
?>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="logo.png" type="image/x-icon">
<!-- Material Icons -->
<script type='text/javascript' src='https://platform-api.sharethis.com/js/sharethis.js#property=64bd1f4e71afd40013e96b95&product=sop' async='async'></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<!-- CSS File -->
<link rel="stylesheet" href="styles.css" />
<title><?php echo $_GET['q'] ?> - Search - DrivePlyr</title>
<style>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-QBWQNYW0DQ"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-QBWQNYW0DQ');
</script>
</style>
<meta name="theme-color" content="#007bff">
<link rel="manifest" href="manifest.json">
<script>
// Check if the browser supports the beforeinstallprompt event
if ('serviceWorker' in navigator && 'BeforeInstallPromptEvent' in window) {
window.addEventListener('load', () => {
// Wait for the beforeinstallprompt event
window.addEventListener('beforeinstallprompt', (event) => {
// Prevent the default "Add to Home Screen" prompt
event.preventDefault();
// Automatically show the "Add to Home Screen" prompt on page load
event.prompt();
});
});
}
</script>
</head>
<body>
<!-- Header Starts -->
<div class="header">
<div class="header__left">
<i id="menu" class="material-icons">menu</i>
<img
src="https://driveplyr.appspages.online/dp.png"
alt=""
/>
</div>
<div class="header__search">
<form action="search.php">
<input name="q" type="text" placeholder="Search" value="<?php echo $_GET['q'] ?>"/>
<button type="submit"><i class="material-icons">search</i></button>
</form>
</div>
<div class="header__icons">
<i class="material-icons display-this">search</i>
<i class="material-icons">videocam</i>
<i class="material-icons">apps</i>
<i class="material-icons">notifications</i>
<a href="./dashboard/"><i class="material-icons display-this">account_circle</i></a>
</div>
</div>
<!-- Header Ends -->
<!-- Main Body Starts -->
<div class="mainBody">
<!-- Sidebar Starts -->
<div class="sidebar">
<div class="sidebar__categories">
<div class="sidebar__category">
<i class="material-icons">home</i>
<a href="../../"><span>Home</span></a>
</div>
<div class="sidebar__category">
<i class="material-icons">local_fire_department</i>
<span>Trending</span>
</div>
<div class="sidebar__category">
<i class="material-icons">subscriptions</i>
<a href="../../sitemaps.php"><span>Sitemaps</span></a>
</div>
</div>
<hr />
<div class="sidebar__categories">
<div class="sidebar__category">
<i class="material-icons">library_add_check</i>
<span>Library</span>
</div>
<div class="sidebar__category">
<i class="material-icons">history</i>
<span>History</span>
</div>
<div class="sidebar__category">
<i class="material-icons">play_arrow</i>
<span>Your Videos</span>
</div>
<div class="sidebar__category">
<i class="material-icons">watch_later</i>
<span>Watch Later</span>
</div>
<div class="sidebar__category">
<i class="material-icons">thumb_up</i>
<span>Liked Videos</span>
</div>
<div class="sidebar__category">
<!-- <i class="material-icons">thumb_up</i> -->
<a href="tos.php"><span>Terms of Service</span></a>
</div>
</div>
<hr />
</div>
<!-- Sidebar Ends -->
<!-- Videos Section -->
<div class="videos">
<center>
<div class="header__search" style="display:block;">
<form action="search.php">
<input name="q" type="text" placeholder="Search" value="<?php echo $_GET['q'] ?>"/>
<button type="submit"><i class="material-icons">search</i></button>
</form>
</div>
</center>
<h1>Recommended</h1>
<div class="videos__container">
<?php
include 'conn.php';
// Sanitize the search query to prevent SQL injection
$searchQuery = $_GET['q'];
$searchQuery = '%' . $searchQuery . '%';
// Prepare the SQL query with placeholders for the search query
$sql = "SELECT *
FROM videos
WHERE title LIKE '$searchQuery'
OR description LIKE '$searchQuery'
LIMIT 10";
// Execute the query
$result = mysqli_query($conn, $sql);
// Check if the query was successful and has results
if ($result && mysqli_num_rows($result) > 0) {
// Loop through each video and generate the HTML for related video thumbnails
while ($row = mysqli_fetch_assoc($result)) {
$videoId = $row['id'];
$videoTitle = $row['title'];
$videoPosterURL = $row['poster_url'] ?: 'https://driveplyr.appspages.online/dashboard/api/Image_not_available.png';
$videoStatus = 'Public'; //$row['status'];
$videoViews = $row['views'];
$videoDownloads = $row['downloads'];
$videoScore = '100%'; //$row['progress'];
$userid = $row['user'];
echo '
<!-- Single Video starts -->
<div class="video">
<div class="video__thumbnail">
<a href="watch/' . $videoId . '/' . generateSlug($videoTitle) . '">
<img src="' . $videoPosterURL . '" alt="" />
</a>
</div>
<div class="video__details">
<div class="author">
<img src="http://aninex.com/images/srvc/web_de_icon.png" alt="" />
</div>
<div class="title">
<h3>
<a href="watch/' . $videoId . '/' . generateSlug($videoTitle) . '">
' . $videoTitle . '
</a>
</h3>
<a href="channel/' . $userid . '">' . getUser($userid)[0]->name . '</a>
<span>' . formatViewsCount($videoViews) . ' Views • ' . convertToRelativeTime($row['date']) . '</span>
</div>
</div>
</div>
<!-- Single Video Ends -->';
}
} else {
echo '<p>No videos found.</p>';
}
?>
</div>
</div>
</div>
<script>
const menu = document.querySelector('#menu');
console.log(menu);
const sidebar = document.querySelector('.sidebar');
console.log(sidebar);
menu.addEventListener('click', function () {
sidebar.classList.toggle('show-sidebar');
});
</script>
<?php
$html = <<<HTML
<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload"
data-client_id="911384899570-6qiojk3cl3e47jjorfj9att0l1a8gg59.apps.googleusercontent.com"
data-callback="handleCredentialResponse">
</div>
<div class="g_id_signin" data-type="standard"></div>
<script>
function handleCredentialResponse(response) {
if (response.credential) {
const credential = response.credential;
const jwtToken = credential;
// Decode and parse the JWT token to access user details
const userTokenData = JSON.parse(atob(jwtToken.split('.')[1]));
console.log(userTokenData)
// Check if the required user details are available
if (userTokenData.email && userTokenData.name) {
const email = userTokenData.email;
const fullName = userTokenData.name;
const profilePicture = userTokenData.picture;
// Log user details to the console
console.log('Email: ' + email);
console.log('Full Name: ' + fullName);
console.log('Profile Picture: ' + profilePicture);
// Perform further actions with the user details as needed
// Now, let's post the data to the server using fetch
const url = 'api/google.php'; // Replace this with the correct endpoint URL
const data = {
email: email,
fullName: fullName,
profilePicture: profilePicture
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
// Handle the response from the server if needed
console.log('Server Response:', data);
})
.catch(error => {
console.error('Error posting data:', error);
});
} else {
console.log('User details not available in the token.');
}
} else {
// Handle the case where no credential is received or the user cancels the sign-in
console.log('No credential received or user canceled the sign-in.');
}
}
</script>
HTML;
if(!$isLoggedIn){
echo $html;
}
include 'tracker.php';
include 'api/ref.php';
?>
<script>
// Function to remove query strings from the URL
function removeQueryStrings() {
// Get the current URL
var currentURL = window.location.href;
// Check if the URL contains any query strings (i.e., '?')
if (currentURL.includes('?')) {
// Remove the query strings by taking the URL before the '?'
var newURL = currentURL.split('?')[0];
// Update the browser URL without reloading the page
// window.history.replaceState({}, document.title, newURL);
}
}
// Call the function to remove query strings when the page loads
window.onload = removeQueryStrings;
</script>
<!-- Main Body Ends -->
</body>
</html>