-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
335 lines (308 loc) · 15.8 KB
/
index.php
File metadata and controls
335 lines (308 loc) · 15.8 KB
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
<?php
require_once './function.php';
require_once './config.php';
session_start();
if (!isset($_SESSION['user']) || !isset($_SESSION['name'])) {
header('Location: ./views/login.php');
}else {
$user = $_SESSION['user'];
$name = $_SESSION['name'];
if(isset($_SESSION['account_admin'])){
header('Location: ./adminpage.php');
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Buffalo Drive</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./Content/Styles/bootstrap.min.css">
<script src="./Content/Scripts/jquery.min.js"></script>
<script src="./Content/Scripts/popper.min.js"></script>
<script src="./Content/Scripts/bootstrap.min.js"></script>
<script src="./Content/Scripts/main.js"></script>
<link rel="stylesheet" href="./Content/Styles/main.css">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-light sticky-top" id="navbar">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div>
<a href="./"><img src="./Content/Images/logo.png" alt="Buffalo Drive" class="navbar-brand" width=70px></a>
<a class="navbar-brand" href="./" style="font-family: 'Monoton', cursive;">Buffalo Drive</a>
</div>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<form class="form-inline my-2 my-lg-0 search">
<input class="form-control mr-auto p-3 mr-mb-0" type="search" placeholder="Search" aria-label="Search">
</form>
<div class="infor d-flex flex-row bd-highlight mb-3">
<a href="./views/profile.php"><img src="./Content/Images/avatar.png" alt="<?= $name ?>"></a>
<a href="./views/profile.php"><?= $name ?></a>
<a href="./views/logout.php">Logout</a>
</div>
</div>
</nav>
<?php
$root = $_SERVER['DOCUMENT_ROOT'] . "/BuffaloDrive/Upload/files/" . $_SESSION['user'];
// echo $_SERVER['HTTP_HOST'];
$dirName = filter_input(INPUT_GET, 'dir', FILTER_SANITIZE_STRING);
$create = filter_input(INPUT_POST, 'create', FILTER_SANITIZE_STRING);
$folder = filter_input(INPUT_POST, 'folderName', FILTER_SANITIZE_STRING);
$url = $_SERVER['REQUEST_URI'];
$back = 'http://' . $_SERVER['HTTP_HOST'] . '' . substr($url, 0, strrpos($url, '/'));
if ($dirName) {
$dir_path = $root . '/' . $dirName;
} else {
$dir_path = $root;
}
$mess = '';
if (!file_exists($root) && $user != 'admin') {
mkdir($root);
}
$files = scandir($dir_path);
?>
<div>
<div class="row">
<div class="sticky col-lg-3 col-sm-5 col-6 left" id="left">
<div class="new d-flex" data-toggle="collapse" href="#multiCollapse" role="button" aria-expanded="false" aria-controls="multiCollapse">
<svg class="bi bi-folder-plus" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M9.828 4H2.19a1 1 0 00-.996 1.09l.637 7a1 1 0 00.995.91H9v1H2.826a2 2 0 01-1.991-1.819l-.637-7a1.99 1.99 0 01.342-1.31L.5 3a2 2 0 012-2h3.672a2 2 0 011.414.586l.828.828A2 2 0 009.828 3h3.982a2 2 0 011.992 2.181L15.546 8H14.54l.265-2.91A1 1 0 0013.81 4H9.828zm-2.95-1.707L7.587 3H2.19c-.24 0-.47.042-.684.12L1.5 2.98a1 1 0 011-.98h3.672a1 1 0 01.707.293z" clip-rule="evenodd" />
<path fill-rule="evenodd" d="M13.5 10a.5.5 0 01.5.5v2a.5.5 0 01-.5.5h-2a.5.5 0 010-1H13v-1.5a.5.5 0 01.5-.5z" clip-rule="evenodd" />
<path fill-rule="evenodd" d="M13 12.5a.5.5 0 01.5-.5h2a.5.5 0 010 1H14v1.5a.5.5 0 01-1 0v-2z" clip-rule="evenodd" />
</svg>
<p>New</p>
</div>
<div class="collapse multi-collapse" id='multiCollapse'>
<a class="dropdown-item" href="#" id='newfile'>
<svg class="" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false">
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"></path>
<path d="M8 15.01l1.41 1.41L11 14.84V19h2v-4.16l1.59 1.59L16 15.01 12.01 11z"></path>
</svg>
<span class="icon_newfile">New File</span>
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" id='newfolder'>
<svg class="" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false">
<path d="M12 12h2v-2h2v2h2v2h-2v2h-2v-2h-2v-2zm10-4v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2l.01-12c0-1.1.89-2 1.99-2h6l2 2h8c1.1 0 2 .9 2 2zm-2 0H4v10h16V8z"></path>
</svg>
<span class="icon_newfolder">New Folder</span>
</a>
</div>
<!-- <div class="recent d-flex">
<svg class="a-s-fa-Ha-pa" width="1em" height="1em" viewBox="0 0 24 24" fill="#000000" focusable="false">
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path>
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"></path>
</svg>
<a>Recent</a>
</div> -->
<div class="my-drive d-flex">
<svg class="" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false">
<path d="M19 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 18H5v-1h14v1zm0-3H5V4h14v13zm-9.35-2h5.83l1.39-2.77h-5.81zm7.22-3.47L13.65 6h-2.9L14 11.53zm-5.26-2.04l-1.45-2.52-3.03 5.51L8.6 15z"></path>
</svg>
<a class="mydrive_a" href="./">My Drive</a>
</div>
<div class="trash d-flex">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false" class="undefined ">
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M15 4V3H9v1H4v2h1v13c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6h1V4h-5zm2 15H7V6h10v13z"></path>
<path d="M9 8h2v9H9zm4 0h2v9h-2z"></path>
</svg>
<a class="trash_a" href="./views/trash.php">Trash</a>
</div>
<hr>
<div class="stored d-flex ">
<svg class="a-s-fa-Ha-pa" width="24px" height="24px" viewBox="0 0 24 24" focusable="false" fill="#000000">
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M3 20h18v-4H3v4zm2-3h2v2H5v-2zM3 4v4h18V4H3zm4 3H5V5h2v2zm-4 7h18v-4H3v4zm2-3h2v2H5v-2z"></path>
</svg>
<div>
<p>Storage</p>
<p class="totalSize">0 MB used</p>
</div>
</div>
</div>
<div class="col-lg-9 col-sm-7 col-6 right" id="right">
<?php require_once './views/userpage.php' ?>
</div>
</div>
</div>
<ul class='custom-menu'>
<li class="delete" data-action="Delete">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false" class="undefined">
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M15 4V3H9v1H4v2h1v13c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6h1V4h-5zm2 15H7V6h10v13z"></path>
<path d="M9 8h2v9H9zm4 0h2v9h-2z"></path>
</svg>
Delete
</li>
<li class="rename" data-action="Rename">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false" class="undefined">
<path d="M1,15.25V19h3.75L15.814,7.936l-3.75-3.75L1,15.25z M18.707,5.043c0.391-0.391,0.391-1.023,0-1.414l-2.336-2.336 c-0.391-0.391-1.024-0.391-1.414,0l-1.832,1.832l3.75,3.75L18.707,5.043z"></path>
</svg>
Rename
</li>
<li class="download" data-action="Download">
<a href="#">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false" class="undefined">
<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path>
</svg>
Download
</a>
</li>
<li class="share" data-action="Share">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="#000000" focusable="false" class="undefined">
<path d="M3.9,12c0-1.7,1.4-3.1,3.1-3.1h4V7H7c-2.8,0-5,2.2-5,5s2.2,5,5,5h4v-1.9H7C5.3,15.1,3.9,13.7,3.9,12z M8,13h8v-2H8V13zM17,7h-4v1.9h4c1.7,0,3.1,1.4,3.1,3.1s-1.4,3.1-3.1,3.1h-4V17h4c2.8,0,5-2.2,5-5S19.8,7,17,7z"></path>
</svg>
Share this file
</li>
</ul>
<!-- Rename dialog -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Rename</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>Enter a new name.</p>
<input type="text" id="newname">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success" data-dismiss="modal" id='save'">Save</button>
</div>
</div>
</div>
</div>
<!-- Link share - copy to clipboard -->
<div class="modal fade" id="Modal-sharelink" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Copy link shared to clipboard</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>
<textarea class="js-copytextarea" style="">
<?='http://' . $_SERVER['HTTP_HOST'] . '/BuffaloDrive/Upload/sharepage.php?user=' . $user?>
</textarea>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success js-textareacopybtn" data-dismiss="modal" id='copy-clipboard'">Copy to clipboard</button>
</div>
</div>
</div>
</div>
<!-- scripts for link share - copy to clipboard -->
<script>
var copyTextareaBtn = document.querySelector('.js-textareacopybtn');
copyTextareaBtn.addEventListener('click', function(event) {
var copyTextarea = document.querySelector('.js-copytextarea');
copyTextarea.focus();
copyTextarea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
});
</script>
<!-- Delete dialog -->
<div class=" modal fade" id="myModal1" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Delete</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success" data-dismiss="modal" id='delete'>Delete</button>
</div>
</div>
</div>
</div>
<!-- Add file dialog -->
<div class="modal fade" id="addFile" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">New File</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form method="post" enctype="multipart/form-data" id="uploadFile">
<input type="file" name="fileToUpload[]" id="fileToUpload" multiple>
<input type="hidden" name="path" value="<?= $dir_path . '/' ?>" id='pathfile'>
<input type="hidden" name="totalSize" value=<?= $totalSize ?> id="totalSize">
<p>Drag your files here or click in this area.</p>
<div class="progress mt-3">
<div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">0%</div>
</div>
<p id="status"></p>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<input class='btn btn-success' type="submit" value="Upload" name="submit">
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Add folder dialog -->
<div class="modal fade" id="addFolder" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">New Folder</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form method="post" id='newFolderForm'>
<div class="modal-body">
<input type="text" name="folderName" id='folderName'>
<input type="hidden" name="folderPath" value="<?= $dir_path ?>" id='folderPath'>
</div>
<div class="modal-footer">
<p class="message"></p>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<input class="btn btn-success" type="submit" value="New folder" name="create">
<br>
</div>
</form>
</div>
</div>
</div>
<?php
if ($totalSize > 1000000) {
$totalSize = round($totalSize / 1000000.0, 1) . ' MB';
} else if ($totalSize > 1000) {
$totalSize = round($totalSize / 1000.0, 1) . ' KB';
} else {
$totalSize = $totalSize . ' Bytes';
}
?>
<script>
$(document).ready(function() {
$('.totalSize').text("<?= $totalSize . ' used' ?>");
})
</script>
</body>
</html>