What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Another PHP Help Thread (Getting size of folders)

Another PHP Help Thread (Getting size of folders)
Author: Message:
Ash_
Senior Member
****

Avatar

Posts: 638
Reputation: 31
35 / Male / –
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 = "&nbsp;<img src='view/images/dossier.gif'>Folders<br><hr>";
$temp2 = "<table width='100%' border=0><tr><td nowrap width='70%' class = 'text1'>&nbsp;<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 = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp";

$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'>&nbsp;";
            $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-,

.php File Attachment: cssboxes.func.php (1.37 KB)
This file has been downloaded 112 time(s).
[Image: jeansiger5.jpg]
01-31-2005 06:45 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Another PHP Help Thread (Getting size of folders) - by Ash_ on 01-31-2005 at 06:32 AM
RE: Another PHP Help Thread (Getting size of folders) - by WDZ on 01-31-2005 at 06:41 AM
RE: Another PHP Help Thread (Getting size of folders) - by Ash_ on 01-31-2005 at 06:45 AM
RE: Another PHP Help Thread (Getting size of folders) - by -dt- on 01-31-2005 at 06:48 AM
RE: Another PHP Help Thread (Getting size of folders) - by WDZ on 01-31-2005 at 06:48 AM
RE: Another PHP Help Thread (Getting size of folders) - by L. Coyote on 01-31-2005 at 06:49 AM
RE: Another PHP Help Thread (Getting size of folders) - by WDZ on 01-31-2005 at 06:56 AM
RE: Another PHP Help Thread (Getting size of folders) - by Ash_ on 01-31-2005 at 07:12 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On