Your IP: 38.107.179.219 

How to read your all sites file and directory

Posted by: Asif D. Khalyani

You can read your file and directory for whole sites.

<?php
$path    =    $_SERVER['DOCUMENT_ROOT']."/";
$extensions = array(".JPG",".jpg", ".jpeg");

$dir_not = array();
$lcount=0;$scount=0;
$dir_name_globle = "thumbnails";
function dir_recursion($path, $dir_name, $static_name="")
{
    global $dir_not,$extensions,$lcount,$scount,$dir_name_globle;
    if($static_name==$dir_name_globle || $dir_name==$dir_name_globle)
    {
        if ($handle1 = opendir($path))
        {
            while (false !== ($file1 = readdir($handle1)))
            {
                if (in_array((strrchr(strtolower($file1), '.')),$extensions) && !is_dir($path.$file1) && $file1!="." && $file1!="..") //Checks that the extension is on the list
                {
                    $lcount++;
                }
                if(is_dir($path.$file1) && $file1!="." && $file1!="..")
                {
                    dir_recursion($path.$file1."/",$file1,$dir_name_globle);
                }
            }
        }
    }
    else
    {
        if ($handle1 = opendir($path))
        {
            while (false !== ($file1 = readdir($handle1)))
            {
                if(is_dir($path.$file1) && $file1!="." && $file1!="..")
                {
                    dir_recursion($path.$file1."/",$file1);
                }
            }
        }
    }
}

if ($handle = opendir($path))
{
   echo "Directory handle: $handle\n";
   echo "Files:<br><br>";

   while ($file = readdir($handle))
   {
           if(is_dir($path.$file) && !in_array($file,$dir_not))
        {
            dir_recursion($path.$file."/",$file,$file);
        }
   }
   closedir($handle);
}
echo "<br>".$lcount."===";
echo "<br>".$scount;
echo "Complete";
?>

Back to Index Page