<?php

include('config.backup.php');

//Sort files by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)


$date = date(LOG_DATE);

//sort our files 
if($_GET['sort']=="date") { 
    @ksort($dirs, SORT_NUMERIC); 
    @ksort($files, SORT_NUMERIC); 
} 
elseif($_GET['sort']=="size") { 
    @natcasesort($dirs);  
    @ksort($files, SORT_NUMERIC); 
} 
else { 
    @krsort($dirs, SORT_NUMERIC); 
    @krsort($files, SORT_NUMERIC); 
//    @natcasesort($dirs);  
//    @natcasesort($files); 
}

function SortByDate(&$File)
{
 
}

function showContent($path){



   if ($handle = opendir($path))
   {
       $up = substr($path, 0, (strrpos(dirname($path."/."),"/")));
      

       while (false !== ($file = readdir($handle)))
       {
           if ($file != "." && $file != "..")
           {
               SortByDate($Files);
               $fName = $file;
               $file = $path.'/'.$file;
               if(is_file($file)) {
                   echo "<tr><td><img src='style/file2.gif' width='16' height='16' alt='file'/> 
                   
                   
                   <a href='".$file."'>".$fName."</a>
                   
                   
                   </td>"
                            ."<td align='right'>".date ('d-m-Y H:i:s', filemtime($file))."</td>"
                            ."<td align='right'>".filesize($file)." bytes</td></tr>";
               } elseif (is_dir($file)) {
                   print "<tr><td colspan='2'><img src='style/dir2.gif' width='16' height='16' alt='dir'/> 
                   
                   <a href='".$_SERVER['PHP_SELF']."?path=$file'>$fName</a>
                   
                   
                   </td></tr>";
               }
           }
       }

       closedir($handle);
   }	

}



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title></title>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>

    <div id="main"> 
     <div class="caption">BACK UP FILE BROWSER</div>
      <div id="icon">&nbsp;</div>    
    <div id="result">
     <table width="100%">
<?php
			showContent($dir_to_browse );        
?>
        </table>
        <?php 
   echo"</br><center><a href=../index.php><font color='red'><b>Go Back</b></a></font></center>"; 
?>    
     </div>
     
	
    </div>
</body>   
