Sort code and display bytes and datetime also

This commit is contained in:
Matt Pass
2015-11-17 09:15:42 +00:00
parent 131392d5fd
commit 811c12d4ec

View File

@@ -5,10 +5,32 @@ include("settings.php");
$file = str_replace("|","/",xssClean($_GET['file'],'html'));
// Get contents
$loadedFile = toUTF8noBOM(file_get_contents("../backups/".$file,false,$context),true);
$encoding=ini_get("default_charset");
if($encoding=="")
$encoding="UTF-8";
// Set content in a textarea
echo '<textarea name="loadedFile" id="loadedFile">'.htmlentities($loadedFile,ENT_COMPAT,$encoding).'</textarea>';
echo "<script>parent.document.getElementById('buttonsContainer').style.display = 'inline-block';parent.editor.setValue(document.getElementById('loadedFile').value)</script>";
?>
// Get bytes for this file
$bytes = filesize("../backups/".$file);
// Change into kilobytes
$outputSize = ($bytes/1024);
$outputUnit = "kb";
// Maybe we should show in megabytes?
if ($outputSize >= 1024) {
$outputSize = ($outputSize/1024);
$outputUnit = "mb";
}
$size = number_format($outputSize, 2, '.', '').$outputUnit." (".number_format($bytes)." bytes)";
// Get date & time of file
$datetime = str_replace("-","<br>",date( "D jS M Y-g:i:sa", filemtime("../backups/".$file)));
?>
<script>
parent.document.getElementById('buttonsContainer').style.display = 'inline-block';
parent.editor.setValue(document.getElementById('loadedFile').value);
parent.document.getElementById('infoContainer').innerHTML = 'Size:<br><?php echo $size;?><br><br>Date & Time:<br><?php echo $datetime;?>';
</script>