Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Pobieranie z katalogu
MacPain
post
Post #1





Grupa: Zarejestrowani
Postów: 81
Pomógł: 0
Dołączył: 22.09.2006

Ostrzeżenie: (10%)
X----


  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
Go to the top of the page
+Quote Post
Master Miko
post
Post #2





Grupa: Zarejestrowani
Postów: 530
Pomógł: 0
Dołączył: 15.01.2005
Skąd: Warszawa

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


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ą.

Ten post edytował Master Miko 22.09.2006, 22:29:18
Go to the top of the page
+Quote Post
MacPain
post
Post #3





Grupa: Zarejestrowani
Postów: 81
Pomógł: 0
Dołączył: 22.09.2006

Ostrzeżenie: (10%)
X----


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>


Ten post edytował MacPain 23.09.2006, 01:37:38
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: 19.09.2025 - 01:33