-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
executable file
·123 lines (119 loc) · 3.29 KB
/
admin.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
<?php
require( './secure.php' );
require_once( './lib/settings.php' );
// Delete file and redirect
if ( isset( $_GET['delete'] ) ) {
deleteFile( $_GET['delete'] );
header( "location:/admin" );
}
?>
<html>
<head>
<meta charset="utf-8">
<title>File Sharing</title>
<script src="./lib/dropzone.js"></script>
<script src="./lib/jq.js"></script>
<link rel="stylesheet" href="./lib/styles.css"/>
</head>
<body>
<div id="admincontent">
<div id="changepwbox">
<form action="/secure?changepw" method="post">
<input name="oldpass" type="password" required="required" placeholder="Old Password"><br/>
<input name="newpass" type="password" required="required" placeholder="New Password"><br/>
<input name="newpass2" type="password" required="required" placeholder="Again New Password"><br/>
<input type="submit">
</form>
</div>
<h2>Storage used:</h2>
<?php
echo "The " . UPLOAD_FOLDER . " folder contains " . nicedirsize( UPLOAD_FOLDER ) . " of files.";
?>
<h2>Files without id:</h2>
<?php
$fileswithnoid = filesWithNoId();
if ( $fileswithnoid ) {
foreach ( $fileswithnoid as $file ) {
echo '<li>' . $file . '</li>';
}
} else {
echo "No files without id.";
}
?>
<h2>Orphans:</h2>
<?php
$allOrphans = showOrphaned();
if ( $allOrphans ) {
echo '<ul class="orphans">';
foreach ( $allOrphans as $orphan ) {
echo '<li>
<span class="trash">
<a href="/admin?delete=' . $orphan->downloadId . '">
<img src="/img/trash.png" />
</a>
</span>';
echo $orphan->downloadId . "<br />";
echo $orphan->filename;
echo "</li>";
}
echo '</ul>';
} else {
echo "No database orphanes.";
}
?>
<h2>All Files:</h2>
<table class="allfiles" cellspacing="0">
<tr>
<th>Filename</th>
<th>IP</th>
<th>Times</th>
<th>Uploaded</th>
<th>Last downloaded</th>
<th>Delete</th>
</tr>
<?php
foreach ( getAllFiles() as $file ) {
$lastdownloaded = ( $file->lastdownloaded == 0 ) ? "never" : $file->lastdownloaded;
echo "<tr>";
echo '<td><a href="/download?' . $file->downloadId . '">' . $file->filename . '</a></td>';
echo "<td>" . $file->ip . "</td>";
echo "<td>" . $file->downloaded . "</td>";
echo "<td>" . $file->uploadtime . "</td>";
echo "<td>" . $lastdownloaded . "</td>";
echo "<td>" . '<span class="trash"><a href="/admin?delete=' . $file->downloadId . '"><img src="/img/trash.png" /></a></span>' . "</td>";
echo "</tr>";
}
?>
</table>
<h2>All Users:</h2>
<?php
$allUsers = getAllUsers();
if ( $allUsers ) {
echo '<ul class="orphans">';
foreach ( $allUsers as $user ) {
echo '<li>
<span class="trash">
<a href="/admin?deleteuser=' . $user->username . '">
<img src="/img/trash.png" />
</a>
</span>';
echo $user->username;
echo "<br /><br /></li>";
}
echo '</ul>';
} else {
echo "No Users";
}
?>
</div>
<div id="adminfooter"><a class="changepw" href="/secure?changepw">Change PW</a> | <a href="/secure?logout">Logout</a></div>
<script>
$(document).ready(function () {
$('.changepw').click(function (e) {
e.preventDefault();
$('#changepwbox').show();
});
});
</script>
</body>
</html>