-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfiles.php
More file actions
executable file
·118 lines (108 loc) · 3.63 KB
/
files.php
File metadata and controls
executable file
·118 lines (108 loc) · 3.63 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
<html>
<head>
<style>
body{
background-color:#005399;
font-family: sans-serif;
}
h3{
text-align:left;
}
.pheader{
color:#F0B010;
text-decoration: underline;
width: 100%;
font-weight: bold;
font-size: 175%;
}
.pitems{
color: #F0B010;
font-size: 100%;
}
.middleBox{
margin: 0 0;
background-color:rgb(0, 47, 86);
}
.textBackground{
background-color:rgb(0, 47, 86);
}
.container{
overflow: hidden;
text-align: center;
}
.banner{
float: right;
width: auto;
height: 50px;
}
</style>
</head>
</html>
<?php
function printFiles($parentPath){
$directory = array_diff(scandir($parentPath), array('..', '.'));
$leftNode[] = NULL;
global $dirList;
echo("<div class='textBackground'>");
echo("<form action='download.php' method='post' class='form'>");
$hasFiles=0;
foreach($directory as $child){
if(!is_dir($parentPath . $child)){
if(auth('file', $_SESSION['user'], $parentPath . $child )){
if(!$hasFiles) echo("<p class='pheader'>" . basename($parentPath) . "</p>");
echo("<p class='pitems'>" . $child . "<input type='radio' name='file' value='" . hash('sha256', $parentPath . $child) . "'>" . "</p>");
$hasFiles=1;
}
}else{
array_push($leftNode, $child);
}
}
if($hasFiles) echo("<input type='submit' value='Download''>");
echo("</form>");
echo("</div>");
foreach($leftNode as $dir){
if($dir!=NULL){
array_push($dirList, $parentPath . $dir . '/');
printFiles($parentPath . $dir . '/');
}
}
}
function printUpload($dirArray){
echo("<h4>Upload</h4>");
echo("<form action='upload.php' method='post' enctype='multipart/form-data'> ");
echo("<select name='dir'> ");
foreach($dirArray as $dir){
if(auth('dir', $_SESSION['user'], $dir)){
echo("<option value='" . hash('sha256', $dir) . "'> " . basename($dir) . "</option>");
}
}
echo("</select><br>");
echo("<input type='file' name='uploadFile'><br>");
echo("<input type='submit' value='Upload'>");
echo("</form>");
}
session_start();
include 'config.php';
include 'auth.php';
$fileStorage = $fileStorageDirectory;
if(isset($_SESSION['time']) && (time() - $_SESSION['time'] > $maxSessionTime )){
header('Location: /logout.php');
exit;
}
if(isset($_SESSION['user'])){
echo("<html>");
#echo("You are Logged In!" . "<br>");
#echo("<br> Available Files:");
$dirList[] = NULL;
echo("<div class='container'>");
echo("<img class='banner'src='/kwood.jpg'></img>");
echo('<h3>Welcome ' . ucfirst($_SESSION['user']) . ", to the Team3 File Server!</h3>");
echo("<div class='middleBox'>");
printFiles($fileStorage);
printUpload($dirList);
echo("<br><a href=logout.php>Logout</a>");
echo("</div></div></hmtl>");
}else{
header('Location: /index.php');
}
?>