Ash_
Senior Member
Posts: 638 Reputation: 31
35 / / –
Joined: Aug 2004
|
O.P. RE: Another PHP Help Thread (Getting size of folders)
yes , it is a different function here ill upload the script.
code: <?php
include("cssboxes.func.php");
$news = "| <b>C</b>urrent <b>N</b>ews | Plans for Assembler Trainer is proceding, Static offsets for Gold in Baldurs gate have been found.";
$Mtr = "./view/images/tr.png";
$Mtl = "./view/images/tl.png";
$Mbl = "./view/images/bl.png";
$Mbr = "./view/images/br.png";
$string = '';
$folders = '';
$temp = " <img src='view/images/dossier.gif'>Folders<br><hr>";
$temp2 = "<table width='100%' border=0><tr><td nowrap width='70%' class = 'text1'> <img src='view/images/script.gif'><font color='white'>File Name</font></td><td nowrap width='30%' class=' text1'><font color='White'>Size</font></td></tr></table><hr>";
$Mcol = "#178AFF";
$Str = "./view/images/tr.png";
$Stl = "./view/images/tl.png";
$Sbl = "./view/images/bl.png";
$Sbr = "./view/images/br.png";
$ck = "3dt";
$Scol = "#178AFF";
$textcol = "#fff";
$tab = "  ";
$text = "<p><center><b>A</b>sh_'s <a href='index.php'><font color='White'>Web Server</font></a></center></p></marquee>";
cssbox ($text,400,10,200,"absolute",$Scol,$textcol,$Str,$Sbr,$Sbl,$Stl,"",1);
$page = 'index.php';
$folder = $_GET['fol'];
$main = './';
if ($folder == "")
{
$folder = $main;
}
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
if($file !='.' && $file !=''){
if (is_dir($folder.'/'.$file)){
$foldersize = foldersize($file);
$temp = $temp ."<table width='100%' border=0><tr><td nowrap class='text1'>$tab</td>";
$temp = $temp ."<td width='70%' class='text1'>";
$temp = $temp ."<img src='view/images/dossier.gif' width='23' height='16' align='absbottom'>";
$temp = $temp ."<a href='$page?fol=$folder/$file' class='text1'><font color='White'>$file</font></a>";
$temp = $temp ."</td><td width='30%' class=' text1'>$foldersize</td></tr></table>";
}
else
{
$file_extension = strtolower(substr(strrchr($file, '.'), 1));
$temp2 = $temp2 ."<table width='100%' border=0> <tr><td nowrap class='text1'>$tab</td>";
$temp2 = $temp2 ."<td nowrap width='60%' class='text1'>";
$temp2 = $temp2 ."<img src='view/images/script.gif' width='23' height='16' align='absbottom'> ";
$temp2 = $temp2 ."<a href='$folder/$file' class='text1'><font color='White'>$file</font></a>";
$temp2 = $temp2 ."</td><td width='30%' class=' text1'>". truesize(filesize($main.$folder."/".$file))."</td>";
if ($file_extension == "php" or $file_extension == "js" or $file_extension == "css"){
$temp2 = $temp2 ."<td width='10%' class=' text1'> <a href=tester.php?file=$file&&noload=1><font color='White'>Edit</font></a></tr></table>";
}
}
}
}
closedir($handle);
clearstatcache();
}
cssbox ($temp,150,100,300,"absolute",$Scol,$textcol,$Str,$Sbr,$Sbl,$Stl,"",1);
cssbox ($temp2,550,100,300,"absolute",$Scol,$textcol,$Str,$Sbr,$Sbl,$Stl,"",1);
?>
<?
function foldersize ($folder){
$handle = opendir($folder);
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
if($file !='.' && $file !='' && $file != '../'){
if (is_dir($folder.'/'.$file)){
//$temp2 = $temp2 . "$folder/$file";
//echo foldersize("$folder/$file");
}else{
$temp = $temp . "<b>File</b>: $folder/$file<br>";
$foldersize = $foldersize + filesize("$folder/$file");
}
}
}
}
closedir($handle);
clearstatcache();
$foldersize = truesize($foldersize);
//echo $temp;
//echo "$temp2 <br>";
return $foldersize;
}
?>
<?
function truesize ($size){
$size = $size / 1024;
if ($size / 1024>1024){
return Round($size /1024 /1024 , 2) . " GB";
}else{
if ($size>1024){
return Round($size / 1024 , 2) . " MB";
}else{
if ($size<1024){
return Round($size ,2). " KB";
}
}
}
}
?>
you'll also need teh css.box function coded by -dt-,
Attachment: cssboxes.func.php (1.37 KB)
This file has been downloaded 118 time(s).
|
|