-
Notifications
You must be signed in to change notification settings - Fork 3
/
subs.php
483 lines (424 loc) · 14 KB
/
subs.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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
session_start();
$uname=$_SESSION['username'];
include_once "function.php";
ob_start();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My subscriptions</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
body {background-color: #2d2d30;
color:white;
}
</style>
<script type="text/javascript" src="js/jquery-latest.pack.js"></script>
<script type="text/javascript">
function saveDownload(id)
{
$.post("media_download_process.php",
{
id: id,
},
function(message)
{ }
);
}
</script>
</head>
<body>
<!--<div align = "center">
<div align = "center">
<div><br/><b><h2>Welcome <?php echo $_SESSION['username'];?></h2></b>
<div align="right">
<ul class="nav navbar-nav navbar-right">
<li><a href="login.php">Login</a></li>
<li><a href="register.php">Register</a></li>
</ul></div>
</div> <br><br>-->
<div align = "center">
<div align = "center">
<div class="container-fluid">
<div class="navbar-header">
<br> <b><h2>Welcome <?php echo $_SESSION['username'];?></h2></b>
</div>
<div class="collapse navbar-collapse" id="myNavbar"><br>
<ul class="nav navbar-nav navbar-right">
<li><a href='media_upload.php' style="color:#FF9900;">Upload File</a></li>
<li><a href="browse.php" style="color:#FF9900;">Home</a></li>
<li><a href="update.php" style="color:#FF9900;">Profile</a></li>
<li><a href="allmedia.php" style="color:#FF9900;">All media</a></li>
<li><a href="contacts.php" style="color:#FF9900;">Contacts</a></li>
<li><a href="mychannel.php" style="color:#FF9900;">My channel</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
MORE
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="browse_list.php">Browse by Category</a><br>
<a class="dropdown-item" href="blocklist.php">Block List</a><br>
<a class="dropdown-item" href="playlist.php">Playlist</a><br>
<a class="dropdown-item" href="most_viewed.php">Media Recommendation</a><br>
<a class="dropdown-item" href="most_recent.php">Recently uploaded</a><br>
<a class="dropdown-item" href="favlist.php">Favlist</a><br>
</div>
</li>
<li><a href="index.php" style="color:#FF9900;">Signout</a></li>
</ul>
</div>
</div></div>
<!--<a href='media_upload.php' style="color:#FF9900;">Upload File</a>-->
<div id='upload_result'>
<?php
if(isset($_REQUEST['result']) && $_REQUEST['result']!=0)
{
echo upload_error($_REQUEST['result']);
}
?>
</div>
<br/><br/>
<?php
$query = "SELECT * from media order by username";
$result = mysql_query( $query );
if (!$result){
die ("Could not query the media table in the database: <br />". mysql_error());
}
?>
<table width="50%" cellpadding="0" cellspacing="0" align="right">
<?php
$i=1;
while ($result_row = mysql_fetch_row($result)) //filename, username, type, mediaid, path
{
$mediaid[$i] = $result_row[3];
//echo "$mediaid[$i]";
$filename [$i]= $result_row[0];
$filenpath [$i]= $result_row[4];
$ufname [$i]= $result_row [5];
$desc [$i]= $result_row[7];
$username [$i]= $result_row[1];
$category[$i]= $result_row[6];
$path[$i]=$result_row[2];
$comment[$i]=$result_row[11];
$rat[$i]=$result_row[12];
$count[$i]=$result_row[9];
$i++;
?>
<?php
}
?>
<?php for($y=1;$y<=$i-1;$y++){
$bs="select mediaid from block where mediaid='$mediaid[$y]' and username='$uname'";
$out= mysql_query($bs);
$b1 = mysql_fetch_assoc($out);
$blist=$b1['mediaid'];
$ps="select mediaid from playlist where mediaid='$mediaid[$y]' and username='$uname'";
$out= mysql_query($ps);
$p1 = mysql_fetch_assoc($out);
$plist=$p1['mediaid'];
$fs="select mediaid from favlist where mediaid='$mediaid[$y]' and username='$uname'";
$out= mysql_query($fs);
$f1 = mysql_fetch_assoc($out);
$flist=$f1['mediaid'];
$ss="select cname from subscription where cname='$username[$y]' and username='$uname'";
$out=$out= mysql_query($ss);
$s1 = mysql_fetch_assoc($out);
$slist=$s1['cname'];
$friendname=[];
$query7="select * from shared where mid='$mediaid[$y]'";
$oi=mysql_query($query7);
$m=1;
$shared=0;
while($rw=mysql_fetch_row($oi))
{
$mid[$m]=$rw[0];
$friendname[$m] = $rw[1];
//echo $friendname[$m];
//echo $mid[$m];
if($mid[$m]==$mediaid[$y])
{
$shared=1;
if($friendname[$m]==$uname)
{
$shared=0;
break;
//echo "shared inside if".$shared;
}
}
$m++;
}
?><tr valign="top" >
<form method='get' action=''><?php
if ($y==1&&$username[$y]==$slist) {?>
<th><?php echo $username[$y];?></th><td></td><td></td><td></td><td></td>
<td>
<?php if ($username[$y]==$slist){ ?>
<button class="btn btn-success" name=" 'sub'<?php echo$y;?>" type="submit" value="submit">unsubscribe</button>
<?php
}
?>
</td>
<?php }
else if ($y>1&&$username[$y]!=$username[$y-1]&&$username[$y]==$slist)
{
?>
<th><?php echo $username[$y]?></th><td></td><td></td><td></td><td></td>
<td>
<?php if ($username[$y]==$slist){ ?>
<button class="btn btn-success" name=" 'sub'<?php echo$y;?>" type="submit" value="submit" >unsubscribe</button>
<?php
}
?>
</td>
<tr></tr>
</form></tr>
<?php }
if($username[$y]==$slist) {
if ($mediaid[$y]==$blist||$shared==1){ ?>
<?php
}
else {?>
<tr >
<td>
<a href="<?php echo $filenpath[$y];?>" download><?php echo $ufname[$y];?> </a>
</td>
<form method='get' action=''>
<td>
<button class="btn btn-success" name=" 'submit'<?php echo$y;?>" type="submit" value="submit">VIEW</button>
</td>
<td>
<button class="btn btn-success" name=" 'block'<?php echo$y;?>" type="submit" value="submit">BLOCK</button>
</td>
<td>
<?php if ($mediaid[$y]==$plist){ ?>
<button class="btn btn-success" name=" 'Playlist'<?php echo$y;?>" type="submit" value="submit" disabled>Added playlist</button>
<?php
}
else {?>
<button class="btn btn-success" name=" 'Playlist'<?php echo$y;?>" type="submit" value="submit">Add playlist</button>
<?php } ?>
</td>
<td>
<?php if ($mediaid[$y]==$flist){ ?>
<button class="btn btn-success" name=" 'favlist'<?php echo$y;?>" type="submit" value="submit" disabled>Added favlist</button>
<?php
}
else {?>
<button class="btn btn-success" name=" 'favlist'<?php echo$y;?>" type="submit" value="submit">add favlist</button>
<?php } ?>
</td>
</form></tr>
<?php } }?>
<?php } ?>
</table>
</div>
<?php
for ($z=1;$z<=$y;$z++){
if(isset($_GET["'submit'$z"]))
{
$insert = "insert into view(mediaid, username)".
"values('$mediaid[$z]','$uname')";
$output1 = mysql_query( $insert);
$c=$count[$z];
$c++;
$update = "update media set vcount='$c' where mediaid='$mediaid[$z]'";
$output7= mysql_query ($update);
?>
<h3><?php echo $ufname[$z];?></h3>
<?php if(substr($path[$z],0,5)=="video"){ ?>
<video width="500" height="300" align="left" overflow="hidden" controls>
<source src="<?php echo $filenpath[$z];?>" type="<? echo $path[$z];?>">
</video>
<?php }else if(substr($path[$z],0,5)=="audio"){?>
<audio width="500" height="300" align="left" overflow="hidden" controls>
<source src="<?php echo $filenpath[$z];?>" type="<? echo $path[$z];?>">
</audio>
<?php }else{ ?>
<a href="<?php echo $filenpath[$z];?>" download>
<img src="<?php echo $filenpath[$z];?>" alt="W3Schools" width="500" height="300" align="left">
</a>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<?php } ?>
<br>
<p> uploaded by: <?php echo $username[$z]; ?></p><br>
<p> description: <?php echo $desc[$z]; ?></p>
<?php
$query = "SELECT * from comment where mediaid='$mediaid[$z]'";
$result = mysql_query( $query );
if (!$result){
die ("Could not query the media table in the database: <br />". mysql_error());
}
$qquery = "SELECT avg(rating) from rating where mediaid='$mediaid[$z]'";
$rresult = mysql_query( $qquery );
$dresult = mysql_fetch_row($rresult);
$rating = $dresult[0];
?>
<table width="50%" cellpadding="0" cellspacing="0" align="left">
<?php if($rat[$z]==0){ ?>
<form method='post' action=''>
<tr valign="top" >
<th> Average rating: <?php echo"$rating"?></th>
</tr><tr valign="top" >
<th>Rate this :
<input type="radio" name="rating" value="1" checked> 1
<input type="radio" name="rating" value="d"> 2
<input type="radio" name="rating" value="3"> 3
<input type="radio" name="rating" value="4"> 4
<input type="radio" name="rating" value="5"> 5
<button class="btn btn-success" name="'rate'<?php echo$z;?>" type="submit" value="rate" class="myButton">RATE</button>
</th>
</tr>
</form>
<?php } if($comment[$z]==0){?>
<tr valign="top" >
<th>comments:</th>
</tr>
<?php
$i=1;
while ($result_row = mysql_fetch_row($result)) //filename, username, type, mediaid, path
{
$mediaid[$i] = $result_row[1];
//echo "$mediaid[$i]";
$cid [$i]= $result_row[0];
$comment [$i]= $result_row[2];
$ucname [$i]= $result_row [3];
$i++;
?>
<?php
}
?>
<?php for($y=1;$y<=$i-1;$y++){ ?>
<tr >
<td>
<p><?php echo $ucname[$y];?> : <?php echo $comment[$y];?> </p>
</td>
<form method='post' action=''>
<?php
if($ucname[$y]==$uname){
$com=$comment[$z];
?>
<td>
<button class="btn btn-success" name="'dc'<?php echo$y;?>" type="submit" value="xyz" class="myButton">Delete</button>
</form>
</td>
<?php }?>
</tr>
<?php } //}?>
<form method='post' action=''>
<tr><th>Write your comment</th></tr>
<tr><td>
<textarea name="comment" rows="3" cols="80" style="color:black"></textarea>
</td><td>
<button class="btn btn-success" name="'xyz'<?php echo$z;?>" type="submit" value="xyz" class="myButton">Comment</button>
</td></tr>
</form>
<?php } //}?>
</table>
<?php
}
if(isset($_GET["'block'$z"]))
{
$insert1 = "insert into block(mediaid, username)".
"values('$mediaid[$z]','$uname')";
$output2 = mysql_query( $insert1);
$delete1="delete from playlist where mediaid='$mediaid[$z]' and username='$uname'";
$delete2="delete from favlist where mediaid='$mediaid[$z]' and username='$uname'";
$out= mysql_query($delete1);
$out1= mysql_query($delete2);
if($out && $out1){
header("Location: subs.php");
}
else{
die ("Could not insert into the table : <br />". mysql_error());
}
}
}
for ($w=1;$w<=$y;$w++){
if(isset($_GET["'Playlist'$w"]))
{
$insert2 = "insert into playlist(mediaid, username)".
"values('$mediaid[$w]','$uname')";
$output3 = mysql_query( $insert2);
if($output3){
header("Location: subs.php");
}
else{
die ("Could not insert into the table : <br />". mysql_error());
}
}
if(isset($_GET["'favlist'$w"]))
{
$insert3 = "insert into favlist(mediaid, username)".
"values('$mediaid[$w]','$uname')";
$output4 = mysql_query( $insert3);
if($output4){
header("Location: subs.php");
}
else{
die ("Could not insert into the table : <br />". mysql_error());
}
}
if(isset($_GET["'sub'$w"]))
{
$delete7 = "delete from subscription where cname='$username[$w]' and username='$uname'";
$output7 = mysql_query( $delete7);
if($output7){
header("Location: subs.php");
}
else{
die ("Could not insert into the table : <br />". mysql_error());
}
}
}
for ($s=1;$s<=$z;$s++){
if(isset($_POST["'xyz'$s"])){
//echo "hi";
$comment=$_POST["comment"];
$query15="insert into comment(mediaid,comment,username) values ('$mediaid[$s]','$comment','$uname')";
$insert15 = mysql_query($query15);
if($insert15){
header("Refresh:0");
}
else{
die ("Could not insert into the table : <br />". mysql_error());
}
}
}
for ($k=1;$k<=$z;$k++){
if(isset($_POST["'rate'$k"])){
//echo "hi";
$rating=$_POST["rating"];
$query16="insert into rating(rid,mediaid,rating) values (NULL,'$mediaid[$k]','$rating')";
$insert17 = mysql_query($query16);
if($insert17){
header("Refresh:0");
}
else{
die ("Could not insert into the table : <br />". mysql_error());
}
}
}
for ($m=1;$m<=$y;$m++){
if(isset($_POST["'dc'$m"])){
// echo "try";
//echo $com;
$query20="delete from comment where mediaid='$mediaid[$m]'and comment='$comment[$m]'and username='$uname'";
$delete20 = mysql_query($query20);
if($delete20){
header("Refresh:0");
}
else{
die ("Could not Delete from the table : <br />". mysql_error());
}
}
}
ob_end_flush();
?>
</body>
</html>