Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.147.51.72
<?php
//This function returns True if login:testuser and password:testpass are provided
//Otherwise it returns False
function CheckAccess()
{
$result = (isset($_SERVER['PHP_AUTH_USER']) &&
$_SERVER['PHP_AUTH_USER'] == 'testuser' &&
$_SERVER['PHP_AUTH_PW'] == 'testpass');
if (!$result) {
header('WWW-Authenticate: Basic realm=“Test restricted area”');
header('HTTP/1.0 401 Unauthorized');
return false;
} else
return true;
}
?>
<html>
<title> Download Files</title>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Download Files
</h2>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>File Name</th>
<th> File Size </th>
<th> Last Modified </th>
<th> Download </th>
</tr>
</thead>
<tbody>
<?php
foreach (array_merge(glob($directory . "*.rar"), glob($directory . "*.exe"),glob($directory . "*.zip"),glob($directory . "*.msi"),glob($directory . "*.ISO")) as $filename) {
?>
<tr>
<td> <?php echo $filename; ?> </td>
<td> <?php echo formatSizeUnits(filesize($filename)); ?> </td>
<td> <?php date_default_timezone_set('Asia/Kolkata');
echo date("d/m/Y h:i:s a", filemtime($filename)); ?> </td>
<td> <a href='<?php echo $filename; ?>'> Download </a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
<?php
// Snippet from PHP Share: http://www.phpshare.org
function formatSizeUnits($bytes)
{
if ($bytes >= 1073741824) {
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
} elseif ($bytes >= 1048576) {
$bytes = number_format($bytes / 1048576, 2) . ' MB';
} elseif ($bytes >= 1024) {
$bytes = number_format($bytes / 1024, 2) . ' KB';
} elseif ($bytes > 1) {
$bytes = $bytes . ' bytes';
} elseif ($bytes == 1) {
$bytes = $bytes . ' byte';
} else {
$bytes = '0 bytes';
}
return $bytes;
}
?>
|