Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Pytanie odn. kodu.
Salur
post
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 28.12.2014

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


Witam, chciałbym poprosić kogoś doświadczonego o pomoc w optymalizacji i zabezpieczeniu kodu wczytywania strony.

  1. <?PHP
  2. $includeDir = ".".DIRECTORY_SEPARATOR."pages".DIRECTORY_SEPARATOR;
  3. $includeDefault = $includeDir."home.php";
  4.  
  5. if(isset($_GET['s']) && !empty($_GET['s']))
  6. {
  7.  
  8. $_GET['s'] = str_replace("\0", '', $_GET['s']);
  9. $includeFile = basename(realpath($includeDir.$_GET['s'].".php"));
  10. $includePath = $includeDir.$includeFile;
  11.  
  12. if(!empty($includeFile) && file_exists($includePath))
  13. {
  14. include($includePath);
  15. }
  16. else
  17. {
  18. include($includeDefault);
  19. }
  20.  
  21. }
  22. else
  23. {
  24. include($includeDefault);
  25. }
  26. ?>
Go to the top of the page
+Quote Post

Posty w temacie
- Salur   [PHP]Pytanie odn. kodu.   23.08.2015, 16:57:02
- - KsaR   Cytat(Salur @ 23.08.2015, 17:57:02 ) ...   23.08.2015, 17:29:41
- - Salur   // rozwiązanie. Funkcja basename była winowajcom.   23.08.2015, 17:32:18


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: 23.08.2025 - 04:46