Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Pobieranie z katalogu
Forum PHP.pl > Forum > PHP
MacPain
  1. <?
  2. $str = $_GET["str"];
  3. if ($str=="") $str="index2";
  4. if (preg_match("/^[a-z0-9]+$/",$str) and file_exists("$str.inc.txt"))
  5. {
  6. include("$str.inc.txt");
  7. } else {
  8. echo "<p>Taka strona nie istnieje!</p>";
  9. }
  10. ?>

Ten skrypt wyswietla strony z katalogu macierzystego jak mozna go przerobic by wyswietlal strony z gatalogu macierzystego i glebszego.Za odp z gory wielkie THX
Master Miko
rozumiem że masz określony plik (używasz wyrażenia regularnego...)

Spórbuj readdir" title="Zobacz w manualu php" target="_manual - i zrób z tego funkcję rekurencyjną.
MacPain
Miales racje dzieki smiga bez problemu wyglada tak
  1. <html>
  2. <body>
  3.  
  4.  
  5. <?
  6. $str=$_GET["str"];
  7. if ($str=="") $str="index2";
  8. $str2="$str.inc.txt";
  9. $dir="alfabet";
  10. if ($handle = opendir($dir)) {
  11. while (false !== ($file = readdir($handle))) { 
  12. if ($file != "." && $file != "..") { 
  13. if($file==$str2){
  14. include("$dir/$str2");
  15. }
  16. } 
  17. }
  18. closedir($handle); 
  19. }
  20. if ($handle = opendir('.')) {
  21. while (false !== ($file = readdir($handle))) { 
  22. if ($file != "." && $file != "..") { 
  23. if($file==$str2){
  24. include("$str2");
  25. }
  26. } 
  27. }
  28. closedir($handle); 
  29. }
  30. ?>
  31.  
  32. <a href="?str=a">aaaaaaaaaaaa</a>
  33. <br>
  34. <a href="?str=b">bbbbbbbbbbb</a>
  35. <a href="?str=seek">ssssssssss</a></body>
  36. </html>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.