-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaylist.php
115 lines (95 loc) · 3.27 KB
/
playlist.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
<?php
session_start();
include_once "include/functions.inc.php";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="stylesheet" href="app.css" type="text/css">
<link rel="stylesheet" href="header.css" type="text/css">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Playlist</title>
<script src="Scripts/AC_ActiveX.js" type="text/javascript"></script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body class="App">
<div class="App-header">
<a class="home" href="browse.php">MeTube</a>
<?php
if( isset($_SESSION['username'])){
$username = $_SESSION['username'];
echo '<a class="upload" href="user.php">'.$username.'</a>';
}
else {
echo "<a class='upload' href='index.php'>Log In</a>";
}
?>
</div>
<div class="baseroot2">
<?php
if(isset($_GET['id'])) {
$query = "SELECT * FROM playlists WHERE playlist_id='".$_GET['id']."'";
$result = queryResults( $query );
$result_row = mysqli_fetch_assoc($result);
$title=$result_row["title"];
$user_id = $result_row["user_id"];
$playlist_id = $_GET['id'];
//PLAYLIST QUERY WITH MEDIA
$query = "SELECT Media.media_id, Media.title, Media.file_ulr FROM Media INNER JOIN playlist_items ON playlist_items.media_id = Media.media_id WHERE playlist_items.playlist_id = ".$playlist_id.";";
$result = queryResults( $query );
if( isset($_SESSION['username'])){
$userValidate = "SELECT user_id FROM users WHERE username='".$username."';";
$userResult = queryResults( $userValidate );
$userRow = mysqli_fetch_row( $userResult );
if( $userRow[0] == $user_id){
?>
<div class="Playlist-header" style="margin-top: 10px;">
<?php
echo '<form method="post" action="deletePlaylist.php?id='.$_GET['id'].'" >';
?>
<input class="newPlaylist" name="DeletePlay" type="submit" value="Delete Playlist">
</form>
</div>
<?php
}
}
?>
<br/>
<div style="display: table;">
<div class="mediaText" style="background:#339900;color:#FFFFFF; width:200px; height: 40px; display: table-cell; font-size: x-large; "><?php echo $title; ?> </div>
</div>
<table width="50%" cellpadding="0" cellspacing="0">
<?php
$html = '';
$totalItemPerLine = 3;
$i = 0;
while ($result_row = mysqli_fetch_row($result))
{
if( $i % $totalItemPerLine == 0 ){
$html .= '<div class="row">'; // New Row
}
$html .= '<div class="col"> <div class="media"> <div class="mediaText" > <a href="media.php?id='.$result_row[0].'" >'.$result_row[1].'</a><br><a href="'.$result_row[2].'" target="_blank" onclick="javascript:saveDownload('.$result_row[2].');">Download</a>';
if( isset($_SESSION['username']) && $userRow[0] == $user_id){
$html.= '<br/><br/><a href="deleteFromPlaylist.php?id='.$_GET['id'].'&media='.$result_row[0].'">Remove From Playlist</a>';
}
$html .= '</div></div></div>';
if($i % $totalItemPerLine == ($totalItemPerLine-1))
{
$html .= '</div>'; // End Row
}
$i += 1;
?>
<?php
}
if($i % $totalItemPerLine != ($totalItemPerLine-1)){
$html .= '</div>';
}
echo $html;
?>
</table>
</div>
</div>
<?php
}
?>
</body>
</html>