-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewall.php
127 lines (113 loc) · 3.85 KB
/
viewall.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
<?php
ob_start(); session_start();
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 :: All your files
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./css/bootstrap.css" />
<link rel="stylesheet" href="./css/basic.css" />
<link rel="stylesheet" href="./css/viewall.css" />
</head>
<body>
<h1>All Your Files</h1>
<a href="./home.php"><img src="./img/logo_main.png" id="logo_main" /></a>
<a href="./home.php"><button class="btn btn-success" id="backtodash">Back to Dashboard</button></a>
<div id="sresults">
<p class="s"><input type="search" id="search" name="search" onclick="this.value=''" value="Search" /></span> <!-- this is for the search box -->
<div id="res"></div>
</div>
<br />
<div id="content">
<div id="page1" class="page">
<ul id="files">
<?php
require_once('connectvars.php');
/* code to grab the files uploaded by the user */
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$myid=$_SESSION['userid'];
$query = "SELECT * FROM files WHERE userid = '$myid' ORDER BY filename DESC"; // makes query to get all the files
$data = mysqli_query($dbc, $query);
while ($row=mysqli_fetch_array($data)) {
$sizethis=$row['filesize'];
if ($sizethis>1) // calculates file size and displays the file size in user friendly format
{
$sizethis=$sizethis/1024;
if ($sizethis>1)
{
$sizethis=$sizethis/1024;
$sizethis = round($sizethis, 2) . ' MB';
}
else {
$sizethis = round($sizethis, 2) . " KB";
}
}
else {
$sizethis = round($sizethis, 2) . " bytes";
}
echo '<li id="./server/php/files/' . $_SESSION['userid'] . '/' . $row['filename'] . '"><a href="./server/php/files/' . $row['directory'] . '/' . $row['filename'] . '"><button class="dwn"></button></a><big>' . $row['filename'] . '</big> | ' . $sizethis . '</li>';
}
?>
</files>
</div>
<div id="page2" class="page">
<ul id="files">
<?php
require_once('connectvars.php');
/* code to grab the files shared with the user */
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$myid=$_SESSION['userid'];
$query = "SELECT * FROM sharedfiles WHERE shareid = '$myid' ORDER BY id DESC"; // query to get all the files
$data = mysqli_query($dbc, $query);
while ($row2=mysqli_fetch_array($data)) {
$fileid = $row2['fileid'];
$query2 = "SELECT * FROM files WHERE id = '$fileid'"; // makes query to get all the files
$data2 = mysqli_query($dbc, $query2);
while ($row=mysqli_fetch_array($data2)) {
$sizethis=$row['filesize'];
if ($sizethis>1) // calculates the file size and displays the file size in user friendly format
{
$sizethis=$sizethis/1024;
if ($sizethis>1)
{
$sizethis=$sizethis/1024;
$sizethis = round($sizethis, 2) . " MB";
}
else {
$sizethis = round($sizethis, 2) . " KB";
}
}
else {
$sizethis = round($sizethis, 2) . " bytes";
}
echo '<li id="./server/php/files/' . $row['directory'] . '/' . $row['filename'] . '"><a href="./server/php/files/' . $row['directory'] . '/' . $row['filename'] . '"><button class="dwn"></button></a>' . $row['filename'] . ' | ' . $sizethis . '</li>';
}
}
if (mysqli_num_rows($data)==0)
{
echo '<li>You have no files shared with you.</li>';
}
?>
</ul>
</div>
<div id="menubar">
<button onclick="move()" id="shift">Switch to Shared Files view</button>
</div>
</div>
<div id="vid"></div>
<!-- an instantaneous way to play files as soon as the user places the mouse over that particular 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/viewall.js"></script>
</body>
</html>