-
Notifications
You must be signed in to change notification settings - Fork 10
/
stat.php
107 lines (105 loc) · 3.74 KB
/
stat.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
<!DOCTYPE html>
<html>
<meta name="theme-color" content="#111">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<title>FileServer</title>
<link rel="stylesheet" href="src/css/stat.css">
<script type="text/javascript" src="src/script/script.js"></script>
</head>
<body>
<body id="body">
<div class='main'>
<a href="index.php" class="whiteLink"><div id="uploadLaunchButton" class="shadowLight">Back</div></a>
<div class="leftPart">
<div class="matterHolder shadow">
<font class="title-in">FileServer</font><br><br>
<?php
function folderSize ($dir){
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
return $size;
}
$dirSize = (folderSize("uploads/")/1024)/1024;
if($dirSize<1024){
$precision = 2;
$dirSize = substr(number_format($dirSize, $precision+1, '.', ''), 0, -1);
$dirSize= $dirSize." MB";
}
else{
$precision = 2;
$dirSize = $dirSize/1024;
$dirSize = substr(number_format($dirSize, $precision+1, '.', ''), 0, -1);
$dirSize= $dirSize." GB";
}
echo "Total file size on disk : ".$dirSize. "<br/<br/>";
//echo "<br />Server IP : $ip";
echo "
<br>
<font size='3'>Set a storage cap :</font>
<br><br>
<form action='src/set/setCap.php' method='GET'>
<input type='text' id='cap' name='cap' class='textInp shadowLight' placeholder='Enter limit in GB'>
<input type='submit' class='setButton shadowLight' value='Set limit'>
</form>
";
$ip=$_SERVER['REMOTE_ADDR'];
if($ip=="127.0.0.1" || $ip=="::1"){
$capFile = fopen("src/set/disableDel.dat", "r") or die("Unable to open file!");
$delStat = fread($capFile,filesize("src/set/disableDel.dat"));
fclose($capFile);
if($delStat==0){
echo "
</div>
<div class='deleteOption shadow'>
<form action='src/set/disableDel.php' method='GET'>
<b>Disable file delete option : </b><br><br>
<input type='checkbox' name='able' value='disable'>Disable
<br /><br />
<input type='submit' class='setRuleBtn disable shadow' value='Set rule'>
</form>
</div>
<div class='deleteOption shadow' style='background:#fff;'>";
}
elseif($delStat==1){
echo "
</div>
<div class='deleteOption shadow'>
<form action='src/set/enableDel.php' method='GET'>
<b>Enable file delete option : </b>
<br /><br />
<input type='checkbox' name='enable' value='enable'>Enable
<br /><br />
<input type='submit' class='setRuleBtn enable shadow' value='Set rule'>
</form>
</div>
<div class='deleteOption shadow' style='background:#fff;'>
";
}
}
else{
echo "
<br />
Your device IP : $ip <br><Br>
";
}
echo "
<a style='color:#777;font-size:15px;' href='changelog.html'>View Changelogs</a>
";
?>
</div>
</div>
<div class="rightPart">
<div class='deleteOption shadow' style="background:url('src/img/update.gif') center/cover;padding:0px;">
<div class="inRightPart"></div>
</div>
<div class="deleteOption shadow">
Software Version : V2.0<br>
<a style="line-height:1.6;" href="https://github.com/RonaldPM/FileServer">Check for Updates on GitHub</a>
</div
</div>
</div>
</body>
</html>