<?php
function DirStat($directory) {
global $FolderCount, $FileCount, $FolderSize, $UrlList;
chdir($directory);
$directory = getcwd();
if($open = opendir($directory)) {
while($file = readdir($open)) {
if($file == '..' || $file == '.') continue;
if(is_file($file)) {
$FileCount++;
AccessFile($file);
$FolderSize += filesize($file);
} elseif(is_dir($file)) {
$FolderCount++;
}
}
if($FolderCount > 0) {
$open2 = opendir($directory);
while($folders = readdir($open2)) {
$folder = $directory.'/'.$folders;
if($folders == '..' || $folders == '.') continue;
if(is_dir($folder)) {
DirStat($folder);
}
}
closedir($open2);
}
closedir($open);
}
}
function AccessFile($file) {
//<SCRIPT LANGUAGE="Javascript" SRC="http://x.x.com/cgi-local/page?c=my%20page%20now&o=yes&n=3"></SCRIPT>
//i'm trying to collect all of these from all files http://x.x.com/cgi-local/page?c=my%20page%20now&o=yes&n=3
$html = file_get_contents($file);
preg_match("/(http:\/\/)?([\/]+)/i",$html, $matches);
$host = $matches[2];
// get last two segments of host name
preg_match("/[.\/]+.[.\/]+$/", $host, $matches);
echo "$matches[0] - $matches[1] - $matches[2]";
//$UrlList.=$matches[0] . "<br>";
}
function ByteSize($bytes) {
$size = $bytes / 1024;
if($size < 1024){
$size = number_format($size, 2);
$size .= 'kb';
} else {
if($size / 1024 < 1024) {
$size = number_format($size / 1024, 2);
$size .= 'mb';
} elseif($size / 1024 / 1024 < 1024) {
$size = number_format($size / 1024 / 1024, 2);
$size .= 'gb';
} else {
$size = number_format($size / 1024 / 1024 / 1024, 2);
$size .= 'tb';
}
}
return $size;
}
$folder = '.';
$dir = getcwd();
DirStat($folder, 0);
chdir($dir);
$FolderSize = ByteSize($FolderSize);
echo '<b>Folder Name:</b> '.$folder.'<br />'.chr(10);
echo '<b>File Count:</b> '.$FileCount.'<br />'.chr(10);
echo '<b>Folder Size:</b>'.$FolderSize.'<br />'.chr(10);
?>
I DON'T KNOW WHTAS GOING WRONG. it outputs the code the code you see above