-
Notifications
You must be signed in to change notification settings - Fork 0
/
shareview.php
131 lines (116 loc) · 3.91 KB
/
shareview.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
<?php
ob_start();
session_start();
/* checks if the user is ogged in or not */
if (!isset($_SESSION['userid']) || !isset($_SESSION['usernaam'])) {
$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php?err=noaccess';
header('Location: ' . $home_url);
}
?>
<html>
<head>
<title>
Cloudhub :: ShareView
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- links to the required style files are made here -->
<link rel="stylesheet" href="./css/bootstrap.css" />
<link rel="stylesheet" href="./css/basic.css" />
<link rel="stylesheet" href="./css/shareview.css" />
</head>
<body>
<a href="home.php"><button class="btn btn-success" id="backtodash">Back to Dashboard</button></a>
<h1>ShareView</h1>
<?php
require_once('connectvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$myid=$_SESSION['userid'];
if(isset($_GET['id']) && $_GET['id']!='') // grabs the user id
{
$theirid = $_GET['id'];
}
else {
$theirid=$myid;
}
$query = "SELECT * FROM users WHERE id='$theirid' LIMIT 1";
$data = mysqli_query($dbc, $query);
if (mysqli_num_rows($data)!=0)
{
while ($row=mysqli_fetch_array($data))
{
$sharebuddy = $row['naam'];
$sharenick = $row['nickname'];
}
}
else {
$theirid=$myid;
$sharebuddy = $_SESSION['usernaam'];
$sharenick = $_SESSION['usernick'];
}
$_SESSION['buddyid']=$theirid;
?>
<a href="home.php"><img src="./img/logo_main.png" id="logo_main" /></a><br />
<div id="content">
<h4><?php echo '<big>'.$_SESSION['usernaam'] . ' and ' . $sharebuddy.'</big><br /><small>'.$_SESSION['usernick'] . ' and '.$sharenick.'</small>'; ?></h4><br />
<div id="page1" class="page">
All your files
<ul id="files">
<?php
/* code to display the files that you have shared */
$query = "SELECT * FROM files WHERE shareid='$theirid' AND userid='$myid'"; // query to grab the differebt files
$data = mysqli_query($dbc, $query);
if (mysqli_num_rows($data)==0)
{
// echo '<li>No files shared</li>';
}
while ($row=mysqli_fetch_array($data)) {
echo '<li data-share="yes" data-value="' . $row['id'] . '" id="./server/php/files/' . $row['directory'] . '/' . $row['filename'] . '" class="'.$row['filetype'].'">' . $row['filename'] . '</li>';
}
$printed = mysqli_num_rows($data);
$query = "SELECT * FROM files WHERE userid='$myid' AND shareid != '$theirid'";
$data = mysqli_query($dbc, $query);
if (($printed+mysqli_num_rows($data))==0)
{
echo '<li>No files available</li>';
}
while ($row=mysqli_fetch_array($data)) {
echo '<li data-share="no" data-whose="mine" data-value="' . $row['id'] . '" id="./server/php/files/' . $row['directory'] . '/' . $row['filename'] . '" class="'.$row['filetype'].'">' . $row['filename'] . '</li>';
}
?>
</ul>
</div>
<div id="page2" class="page">
Files that <?php echo $sharebuddy; ?> shares with you
<ul id="files">
<?php
/* code to display the files that your frind has shared with you */
$query = "SELECT * FROM sharedfiles WHERE shareid = '$myid' AND userid = '$theirid'"; // query to grab the different files that your friend shared with you
$data = mysqli_query($dbc, $query);
if (mysqli_num_rows($data)==0)
{
echo '<li>No files shared</li>';
}
while ($row2=mysqli_fetch_array($data)) {
$fileid=$row2['fileid'];
$query2 = "SELECT * FROM files WHERE id='$fileid'";
$data2 = mysqli_query($dbc, $query2);
while ($row=mysqli_fetch_array($data2)) {
echo '<li data-whose="their" id="./server/php/files/' . $row['directory'] . '/' . $row['filename'] . '" class="' . $row['filetype'] . '">' . $row['filename'] . '</li>';
}
}
?>
</ul>
</div>
<div id="menubar">
</div>
</div>
<!-- method for instaneous video and audio play when the user places the mouse pointer over the file -->
<div id="preview">
<video id="prevplayer">
<source id="music" src="music2.mp3"></source>
</video>
</div>
<script src="./js/jquery.js"></script>
<script src="./js/shareview.js"></script>
</body>
</html>