Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Listowanie katalogów z serwera
amii
post
Post #1





Grupa: Zarejestrowani
Postów: 728
Pomógł: 76
Dołączył: 12.06.2009

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


Chcę wypisać wszystkie katalogi po połączeniu z serwerem za pomocą FTP. Mam takie coś ale nie działa tzn. $dir nie jest rozpoznawany jako katalog.
Kiedy loguję się przez klienta FTP to dostaje taką strukturę: w domains są podkatalogi, które chcę wylistować
.installatron
Maildir
backups
domains
public_html
.bash_logout
.bash_profile
.shadow
reminder.php

  1. function directory() {
  2. echo 'Jestem w directory'; //wyświetla
  3. $dir = "/domains/";
  4.  
  5.  
  6. // Open a known directory, and proceed to read its contents
  7. if (is_dir($dir)) {
  8. echo 'Jestem w directory_2'; //nie wyświetla
  9. if ($dh = opendir($dir)) {
  10. while (($file = readdir($dh)) !== false) {
  11. if ($file != '.' && $file != '..') echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
  12. }
  13. closedir($dh);
  14. }
  15. }
  16. }
  17.  
  18.  
  19.  
  20. function ftp($ftp_server, $ftp_user_name, $ftp_user_pass) {
  21. $conn_id = ftp_connect($ftp_server);
  22. if (!$conn_id) {
  23. echo 'Nie mogę się połączyć z serwerem FTP<br>';
  24. return FALSE;
  25. }
  26.  
  27. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  28. if (!$login_result) {
  29. echo 'Nie mogę się zalogować na serwer<strong>' .$ftp_server. '</strong>, użytkownik:<strong>' .$ftp_user_name. ' hasło: ' .$ftp_user_pass. '<br>';
  30. return FALSE;
  31. }
  32.  
  33. directory();
  34.  
  35. // close the connection
  36. ftp_close($conn_id);
  37. return TRUE;
  38. }
  39.  
  40.  
  41.  
  42. ftp($ftp_server, $ftp_user_name, $ftp_user_pass);
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 25.12.2025 - 06:13