Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> wyswietlanie zawartości katalogu, Skrypt PHP
India_Webmasterk...
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 11.01.2005

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


Poszukuje skrypt php, który wyświelałby zawartość katalogu i tworzył linki do znalezionych plików html i tylko do nich bez linków do innych katalogów. Jak sie da to prosze o pomoc
Go to the top of the page
+Quote Post
crash
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

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


  1. <?php
  2. if($d = opendir('./'))
  3. {
  4. while($f = readdir($d))
  5. {
  6. if(substr($f, -4) == 'html')
  7. {
  8. echo '<a href=\"./'.$f.'\">'.$f.'</a><br/>';
  9. }
  10. }
  11. closedir($d);
  12. }
  13. ?>
Go to the top of the page
+Quote Post
India_Webmasterk...
post
Post #3





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 11.01.2005

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


Bardzo dziekuje za pomoc. to jest to o co mi chodzilo (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) Jescze jedno - czy mozna ukryc rozszerze aby e linku ni pokazywało się html (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Serdeczne dzięki za malutką zmianę jeśli to możliwe
Go to the top of the page
+Quote Post
pusiek.org
post
Post #4





Grupa: Zarejestrowani
Postów: 56
Pomógł: 0
Dołączył: 1.11.2004
Skąd: Nowogard

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


  1. <?php
  2. if($d = opendir('./'))
  3. {
  4. while($f = readdir($d))
  5. {
  6. if(substr($f, -4) == 'html')
  7. {
  8. $str = array(&#092;".htm\", \".html\");
  9. $g = str_replace($str, &#092;"\", $f);
  10. echo '<a href=\"./'.$f.'\">'.$g.'</a><br/>';
  11. }
  12. }
  13. closedir($d);
  14. }
  15. ?>

Ja bym dodal do tego dwie linijki, zmienil jedna i chyba bedzie dzialac (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował pusiek.org 11.01.2005, 18:30:04
Go to the top of the page
+Quote Post
India_Webmasterk...
post
Post #5





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 11.01.2005

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


Działa tak ja tego oczekiwałam bardzo dziękuje za pomoc (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
mike
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


Wiem, że problem jest banalny i już dawno rozwiązany, ale chciałem zwrócić waszą uwagą na nowe możliwości PHP5.
  1. <?php
  2.  
  3. class ExtensionFilter extends FilterIterator
  4. {
  5.     protected $strExtension = '';
  6.  
  7.     public function __construct( Iterator $objIterator, $strExtension )
  8.     {
  9.         parent::__construct( $objIterator );
  10.         $this->strExtension = $strExtension;
  11.     }
  12.  
  13.     public function accept()
  14.     {
  15.         return ( strtolower( end( explode( '.', $this->current() ) ) ) === $this->strExtension );
  16.     }
  17. }
  18.  
  19. ?>
  20.  
  21. <pre>
  22.  
  23. <?php
  24.  
  25. foreach( new ExtensionFilter( new DirectoryIterator( './' ), 'html' ) as $objFile )
  26. {
  27.     echo '<a href=\"' . $objFile->GetPathname() . '\">' . $objFile . '</a><br>';
  28. }
  29.  
  30. ?>
  31.  
  32. </pre>


Ten post edytował mike_mech 13.01.2005, 21:18:05
Go to the top of the page
+Quote Post

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: 17.09.2025 - 13:05