Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Lista plików
kyku
post 28.04.2010, 22:52:59
Post #1





Grupa: Zarejestrowani
Postów: 116
Pomógł: 8
Dołączył: 21.11.2008

Ostrzeżenie: (0%)
-----


Witam. Posiada ktos funkcje ktora by pobrala liste wszystkich plikow na FTP?
Znalazlem pelno funkcji lecz wszystkie pobieraly tylko z jednego folderu
np taka
Kod
function e_dir($dir_url, $rozszerzenia)
{
if ($dir =@opendir($dir_url)) {
  while ($file = readdir($dir)) {

   $t_file=explode(".", "$file");
   $roz=$t_file[count($t_file)-1];
  
   if((!is_dir($dir_url."/".$file))&&($file != '.')&&($file != '..')&&(in_array($roz, $rozszerzenia))) {
    $pliki[] = $file;
  
   }
  }
  closedir($dir);
}
return $pliki;
}

z góry dziękuje za pomoc

Ten post edytował thek 29.04.2010, 00:08:42
Powód edycji: [thek]: Proszę o właściwy BBCode


--------------------
eArena.pl - hosting serwerów gier multiplayer
Go to the top of the page
+Quote Post
Neo
post 28.04.2010, 23:09:08
Post #2





Grupa: Zarejestrowani
Postów: 43
Pomógł: 9
Dołączył: 8.08.2009
Skąd: Olsztyn

Ostrzeżenie: (0%)
-----


http://www.php.net/manual/en/function.readdir.php#82529

Po drobnej modyfikacji wyśweitla pliki

  1. <?php
  2. function ReadDirs($dir,$em){
  3. if ($handle = opendir($dir)) {
  4. while (false !== ($file = readdir($handle))) {
  5. if ($file != "." && $file != ".." && $file != "Thumb.db") {
  6. if(is_dir($dir.$file)){
  7. echo $em."? ".$file.'<br>';
  8. ReadDirs($dir.$file."/",$em."  ");
  9. }
  10. else {
  11. echo $em."? ".$file.'<br>';
  12. }
  13. }
  14. }
  15. closedir($handle);
  16. }
  17. }
  18.  
  19. ReadDirs('./', '');
  20. ?>


Ten post edytował Neo 28.04.2010, 23:11:30
Go to the top of the page
+Quote Post
AndyPSV
post 28.04.2010, 23:09:59
Post #3





Grupa: Zarejestrowani
Postów: 393
Pomógł: 5
Dołączył: 6.02.2003
Skąd: The.Luciferian.Doctrine.p
df

Ostrzeżenie: (30%)
XX---


  1. function list_dir($pth) {
  2. loadLib('time');
  3. $x = '
  4. <div id=\'idx\'>
  5. <table>
  6. <tr>
  7. <td class=\'b\'>&nbsp;#</td>
  8. <td class=\'b w12_\'>Filename</td>
  9. <td class=\'b\'>Modified</td>
  10. </tr>
  11.  
  12. <tr>
  13. <td colspan=\'3\'></td>
  14. </tr>
  15. '; $path[0] = URL.'v/'.$this->u['id'].'/'; $_name = _PATH.'v/'.$this->u['id'].'/';
  16.  
  17.  
  18. $i = 0; if($h = opendir($pth)) {
  19. while(false !== ($f = readdir($h))) {
  20. if($f <> '.' and $f <> '..' and substr($f,0,4) <> IMG_TH and substr($f,0,8) <> IMG_AV)
  21. if(is_readable($pth.$f))
  22. if(!is_dir($pth.$f)) {
  23. $stat = stat($pth.$f);
  24. $item['size'] = sprintf("%.2f",$stat['size']/1000); if($this->u['status'] == 'admin') $_acc = 1; else $_acc = 0;
  25. $q = q('SELECT * FROM `'.PRFX.'imgs` WHERE id_u = "'.$this->u['id'].'" AND t = "'.$f.'" LIMIT 1'); if(n_r($q) == 0) q('INSERT INTO `'.PRFX.'imgs` (id,id_u,t,date,acc) VALUES (NULL,'.$this->u['id'].',"'.$f.'","'.DATETIME.'","'.$_acc.'");'); else $f_ = f($q);
  26. if($f_['acc'] == 1) $acc = ''; else { $acc = 'n'; $acc_ = 'image waiting for acceptation'; }
  27.  
  28. $x .= '<tr class=\'v\''; if($this->u['avatar'] == $f) $x .= 'style=\'background-color:#ccc\' '; $x .= 'onclick=\'java script:_get("pic","'.$f.'");\'>
  29. <td valign=\'top\' id=\'acc\' title=\''.$acc_.'\'><img src=\''.TPL.'img/dir/'.$acc.'file.gif\' /></td>
  30. <td valign=\'top\'><div class=\'fl\'><a href=\'#\' onclick=\'java script:_get("pic","'.$f.'");\'>'.$f.'</a><div class=\'clearfix\' id=\''.$i.'\' style=\'display:none;\'>Do you want to delete picture?&nbsp;&nbsp;&nbsp;&nbsp;<a href=\''.URL.'profile/photo/d/'.$f.'\'>Yes</a>&nbsp;&nbsp;<a href=\''.URL.'profile/photo/\'>No</a></div></div><div class=\'fr\'>'.$item['size'].'kb&nbsp;&nbsp;&nbsp;&nbsp;</div></div class=\'fix\'></div></td>
  31. <td valign=\'top\'>'._ago($stat['mtime']).' ago</td>
  32. <td valign=\'top\' class=\'sp4\'><!--<img src=\''.TPL.'img/ico/del2.gif\' class=\'pointer\' id=\'pp'.$i.'\' alt=\'delete picture\' />--> <a href=\''.URL.$f_['id'].'\'>&rarr;</a></td>
  33. </tr>
  34. <script type=\'text/javascript\'>$(document).ready(function(){$("#pp'.$i.'").click(function(){$("#'.$i.'").toggle("slow")})});</script>';
  35. $i++;/*$this->u['id'].'/p/'.substr($f,0,-4).'*/
  36.  
  37. if(!file_exists($_name.IMG_TH.$f)) {
  38. $x .= "<img src=\"".URL.DIR_LIB.'thumb/'.INX.PHP.'?f='.$path[0].$f.'&w='.IMG_X.'&h='.IMG_Y.'&id='.$this->u['id'].'&t='.$f.'&pre=th" width="1" height="1" alt="" />';
  39. # CREATES AVATAR AUTO. $x .= "<img src=\"".URL.DIR_LIB.'thumb/'.INX.PHP.'?f='.$path[0].$f.'&w='.IMG_X.'&h='.IMG_Y.'&id='.$this->u['id'].'&t='.$f.'&pre=avatar" width="1" height="1" alt="" />';
  40. }
  41. }
  42. } closedir($h);
  43. } $x .= '</table></div>'; return $x;
  44. }
  45.  
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 23.06.2025 - 18:35