login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Overige scripts > Map uitlezen

Map uitlezen

Auteur: D@rk - 16 juli 2005 - 15:14 - Gekeurd door: Joel - Hits: 7770 - Aantal punten: 3.00 (3 stemmen)



Dit script kan worden gebruik voor het uilezen van een directory als er al bevoorbeeld een index.php bestand is.

Alles kan worden ingesteld op de eerste lijntjes.



Code:
index.php

  1. <?php
  2. /*
  3.   Config variabelen
  4. */
  5. $cfg['plugins']='plugins/'; //plugins directory
  6. $cfg['root']='/public_html'; // De begin directory
  7. $cfg['dir_t']='';
  8. $cfg['dir']=$cfg['root'];
  9. $cfg['notshow']=array();
  10. $cfg['length_file']=40; //De uitleg van een bestand word afgekapt achter
  11. /*
  12.   Plugins laden
  13. */
  14. $plugins=scandir($cfg['plugins']);
  15. $c_plugins=count($plugins);
  16. for($a=0;$a<$c_plugins;$a++){
  17. if($plugins[$a] != '.' && $plugins[$a] != '..' && is_file($cfg['plugins'].$plugins[$a])){
  18. include($cfg['plugins'].$plugins[$a]);
  19. }
  20. }
  21. /*
  22.   ?dir behandelen
  23. */
  24. If(isset($_GET['dir'])){
  25. $parts=explode('.', $_GET['dir']);
  26. $ext=strtolower($parts[count($parts)-1]);
  27. if(is_dir($cfg['root'].'/'.$_GET['dir']) && substr_count($_GET['dir'], '../') == 0 ){
  28. $cfg['dir']=$cfg['root'].'/'.$_GET['dir'];
  29. $cfg['dir']=str_replace('//', '/', $cfg['dir']);
  30. $cfg['dir_t']=$_GET['dir'];
  31. $cfg['dir_t']=str_replace('//', '/', $cfg['dir_t']);
  32. }
  33. elseif(is_file($cfg['root'].'/'.$_GET['dir']) && substr_count($_GET['dir'], '../') == 0){
  34. header('Location: /'.$_GET['dir']);
  35. }
  36. else{
  37. $canthandle=$_GET['dir'];
  38. }
  39. }
  40. /*
  41.   Directory ophalen
  42. */
  43. $files=scandir($cfg['dir']);
  44. $count=count($files);
  45. $b=0;
  46. if($count == 2){
  47. unset($files);
  48. $files[]='..';
  49. $files[]='';
  50. $count = 2;
  51. }
  52. for($a=0;$a<$count;$a++){
  53. if($files[$a] == '..'){
  54. $higher_level=TRUE;
  55. }
  56. elseif($files[$a] != '.' && !in_array($cfg['dir'].'/'.$files[$a], $cfg['notshow'])){
  57. $files_g[]=$files[$a];
  58. $b++;
  59. }
  60. }
  61. natcasesort($files_g);
  62. unset($files);
  63. foreach($files_g as $file){
  64. if($file != ''){
  65. if(is_dir($cfg['dir'].'/'.$file)){
  66. $dirs[]=array($file, handlesize($cfg['dir'].'/'.$file), 'Map', date('d/m/Y H:i', filemtime($cfg['dir'].'/'.$file)));
  67. }
  68. else{
  69. $files[]=array($file, handlesize($cfg['dir'].'/'.$file, 1), handlelength(handledescriptrion($file), $cfg['length_file']), date('d/m/Y H:i', filemtime($cfg['dir'].'/'.$file)));
  70. }
  71. }
  72. }
  73. /*
  74.   Html headers
  75. */
  76. ?>
  77. <html>
  78. <head>
  79. <title><?=$cfg['dir_t'];?></title>
  80. <style type="text/css">
  81. body{
  82. background: #F7F7F7;
  83. }
  84. body,td{
  85. color: #000000;
  86. margin: 0px;
  87. font-family: Tahoma;
  88. font-size: 11px;
  89. }
  90. A:link {
  91. color : #000000;
  92. text-decoration: none;
  93. }
  94. A:visited {
  95. color : #000000;
  96. text-decoration: none;
  97. }
  98. A:hover {
  99. color : #000000;
  100. text-decoration: none;
  101. }
  102. A:active {
  103. color : #000000;
  104. text-decoration: none;
  105. }
  106. img{
  107. border: 0px;
  108. }
  109. td.title{
  110. border: 1px solid #F7F7F7;
  111. }
  112. </style>
  113. </head>
  114. <body>


  1. <table width="100%" cellspacing="0" cellpadding="0">
  2. <tr><td bgcolor="#F3F3F3" style="height: 40px;padding-left: 5px;" valign="middle">
  3. <a href="javascript:history.back()" title="Vorige"><img src="img/vorige.png" alt="Vorige"></a>&nbsp;&nbsp;&nbsp;&nbsp
  4. <a href="javascript:history.next()" title="Volgende"><img src="img/volgende.png" alt="Volgende"></a>&nbsp;&nbsp;&nbsp;&nbsp
  5. <?php
  6. if(isset($higher_level)){
  7. $parts=explode('/', $cfg['dir']);
  8. $to='';
  9. for($a=0;$a<count($parts)-1;$a++){
  10. $to.='/'.$parts[$a];
  11. }
  12. $to=str_replace('//', '/', $to);
  13. $to=str_replace($cfg['root'].'/', '', $to);
  14. if(empty($_GET['dir']))$_GET['dir']='';
  15. if($to != '/' && $_GET['dir'] != '' && $to != ''){
  16. if($to == $cfg['root']){
  17. $to='';
  18. }
  19. echo '<a href="?dir='.$to.'" title="omhoog"><img src="img/omhoog.png" alt="omhoog"></a>';
  20. }
  21. else{
  22. echo '<img src="img/omhoog_dark.png" alt="omhoog">';
  23. }
  24. }
  25. else{
  26. echo '<img src="img/omhoog_dark.png" alt="omhoog">';
  27. }
  28. if(isset($canthandle)){
  29. echo '<br>Er is een fout opgetreden bij het openen van '.$canthandle;
  30. }
  31. ?>
  32. </td></tr>
  33. </table>
  34. <?php
  35. /*
  36.   Directory echoen
  37. */
  38. $files=array_merge((isset($dirs))?$dirs:array(), (isset($files))?$files:array());
  39. $count=count($files);
  40. for($a=0;$a<$count;$a++){
  41. echo handlefile($files[$a], $a, $count);
  42. }
  43.  
  44. /*
  45.   Einde van html
  46. */
  47. ?>
  48. </body>
  49. </html>


plugins/handlefile.php

  1. <?php
  2. function handlefile($file, $a, $count){
  3. global $cfg;
  4. $return='';
  5. if($a == 0){
  6. $return.='<table cellspacing="0" cellpadding="0" align="left" width="100%">'."\n";
  7. $return.='<tr><td colspan="2" width="40%" bgcolor="#EBEADB" class="title">Naam</td><td bgcolor="#EBEADB" class="title" width="15%">Grootte</td><td bgcolor="#EBEADB" class="title" width="20%">Type</td><td bgcolor="#EBEADB" class="title" width="25%">Gewijzigd op</td></tr>'."\n";
  8. }
  9. if($file == ''){
  10. echo '';
  11. }
  12. else{
  13. $return.='<tr><td width="1%" bgcolor="#F7F7F7"><a href="?dir='.$cfg['dir_t'].'/'.$file[0].'"><img src="'.handleicon($cfg['dir'].'/'.$file[0]).'"></a></td><td bgcolor="#F7F7F7">&nbsp;<a href="?dir='.$cfg['dir_t'].'/'.$file[0].'">'.$file[0].'</a></td><td bgcolor="#FFFFFF">'.remake($file[1]).'</td><td bgcolor="#FFFFFF">'.$file[2].'</td><td bgcolor="#FFFFFF">'.$file[3].'</td></tr>'."\n";
  14. }
  15. if($a == $count-1){
  16. $return.='</table>'."\n";
  17. }
  18. return $return;
  19. }
  20. ?>


plugins/handleicon.php


  1. <?php
  2. $icons = array();
  3. $icons['php'] = array('php','');
  4. $icons['css'] = array('ini', 'Document met trapsgewijs opmaakmodel');
  5. $icons['jpg'] = array('jpg', 'JPEG-afbeelding');
  6. $icons['jpeg'] = array('jpg', 'JPEG-afbeelding');
  7. $icons['db'] = array('db', '');
  8. $icons['dll'] = array('db', '');
  9. $icons['ttf'] = array('ttf', '');
  10. $icons['txt'] = array('txt', 'Tekstdocument');
  11. $icons['log'] = array('txt', 'Tekstdocument');
  12. $icons['png'] = array('png', 'PNG-afbeelding');
  13. $icons['gif'] = array('png', 'GIF-afbeelding');
  14. $icons['zip'] = array('zip', 'WinZip-bestand');
  15. $icons['wmv'] = array('mpg', 'Audio-/videobestand van Windows Media');
  16. $icons['exe'] = array('exe', 'Toepassing');
  17. $icons['js'] = array('js', 'JScript Script File');
  18. $icons['htm'] = array('html', '');
  19. $icons['html'] = array('html', '');
  20. $icons['htaccess'] = array('ini', '');
  21. $icons['ini'] = array('ini', 'Configuratie-instellingen');
  22. $icons[''] = array('folder', '');
  23. function handledescriptrion($file){
  24. global $icons;
  25. $parts=explode('.', $file);
  26. $ext=strtolower($parts[count($parts)-1]);
  27. if(isset($icons[$ext]) && $icons[$ext][1] != ''){
  28. return $icons[$ext][1];
  29. }
  30. else{
  31. return ucfirst($ext).'-bestand';
  32. }
  33. }
  34. function handleicon($file){
  35. global $icons;
  36. $parts=explode('.', $file);
  37. $ext=strtolower($parts[count($parts)-1]);
  38. if(isset($icons[$ext]) && !is_dir($file)){
  39. return 'img/'.$icons[$ext][0].'.png';
  40. }
  41. elseif(is_dir($file)){
  42. return 'img/folder.png';
  43. }
  44. else{
  45. return 'img/unknow.png';
  46.  
  47. }
  48. }
  49. ?>


plugins/handlelength.php

  1. <?php
  2. function handlelength($string, $length){
  3. if(strlen($string) > $length-3){
  4. return substr($string, 0, $length-1).'...';
  5. }
  6. else{
  7. return $string;
  8. }
  9. }
  10. ?>


plugins/handlesize.php

  1. <?php
  2. function remake($size){
  3. if(is_numeric($size)){
  4. if($size < 1024){
  5. $size=$size.' b';
  6. }
  7. elseif($size < 1048576){
  8. $size=round($size/1024, 1).' Kb';
  9. }
  10. elseif($size < 1073741824){
  11. $size=round($size/1048576, 2).' Mb';
  12. }
  13. elseif($size < 1099511627776){
  14. $size=round($size/1073741824, 3).' Gb';
  15. }
  16. $size=str_replace('.', ',', $size);
  17. }
  18. return $size;
  19. }
  20. function handlesize($file, $isint=0){
  21. if(is_file($file)){
  22. $size=(float) (filesize($file));
  23. }
  24. elseif(is_dir($file)){
  25. $files=scandir($file);
  26. $c_files=0;
  27. $c_dirs=0;
  28. for($a=0;$a<count($files);$a++){
  29. if($files[$a] != '.' && $files[$a] != '..'){
  30. if(is_file($file.'/'.$files[$a])){
  31. $c_files++;
  32. }
  33. else{
  34. $c_dirs++;
  35. }
  36. }
  37. }
  38. $size='('.$c_dirs.' mappen en '.$c_files.' bestanden)';
  39. }
  40. if(is_numeric($size) && $isint==0){
  41. $size=remake($size);
  42. }
  43. return $size;
  44. }
  45. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (4)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.093s