forked from D-Big-B/DARP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.php
67 lines (45 loc) · 1.46 KB
/
history.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
<?php
require_once("includes/header.php");
if(!User::isLoggedIn()) {
header("Location: signIn.php");
}
$query = $con->prepare("SELECT history FROM users WHERE username=:username");
$query->bindParam(":username", $usernameLoggedIn);
$query->execute();
$historyList = array();
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
array_push($historyList, $row["history"]);
}
$list_string = implode(",", $historyList);
$list_array = explode(",", $list_string);
$list_array = array_reverse($list_array);
$list_array = array_unique($list_array);
$video_list = array();
$videoString = "";
foreach($list_array as $list_item) {
$video = new Video($con, $list_item, $userLoggedInObj);
$videoId = $video->getId();
if($videoId == '') continue;
$videoString = ",". $videoId . $videoString;
array_push($video_list, $video);
}
$videoString = substr($videoString, 1);
//echo $videoString;
//$video_list = array_slice($video_list, 0, -1);
$query = $con->prepare("UPDATE users SET history=:videoString WHERE username=:username");
$query->bindParam(":username", $usernameLoggedIn);
$query->bindParam(":videoString", $videoString);
$query->execute();
?>
<div class='largeVideoGridContainer'>
<?php
if(!empty($video_list)){
$videoGrid = new VideoGrid($con, $userLoggedInObj, null, true);
echo $videoGrid->createLarge($video_list, "Watch History", false);
}
else {
echo "You have no items in your history";
}?>
</div>
<?php
require_once("includes/footer.php"); ?>