Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [inne][PHP] Brak jednego z $_GET[''] w skrypcie...
Forum PHP.pl > Forum > Przedszkole
sloenthran
index.php

  1. <?php
  2.  
  3. error_reporting(E_ALL ^ E_NOTICE & ~E_DEPRECATED);
  4.  
  5.  
  6.  
  7. require_once('./function/ClassLoader.php');
  8.  
  9. $Core = new Core();
  10.  
  11. $Pages = $Core->ClearText($_GET['pages']);
  12. $Pages = strip_tags($Pages);
  13.  
  14. $Controller = $Core->ClearText($_GET['controller']);
  15. $Controller = strip_tags($Controller);
  16.  
  17. if(!$Pages || $Pages == '') { $Pages = 'home'; }
  18. if(!$Controller || $Controller = '') { $Controller = 'other'; }
  19.  
  20. if(file_exists('./pages/'.$Controller.'/'.$Pages.'.php'))
  21. {
  22.  
  23. require_once("./pages/default/header.php");
  24.  
  25. require_once('./pages/'.$Controller.'/'.$Pages.'.php');
  26.  
  27. require_once("./pages/default/footer.php");
  28.  
  29. }
  30.  
  31. else
  32. {
  33.  
  34. header("Location: errors-404.html");
  35.  
  36. }
  37.  
  38.  
  39. ?>


.htacess

Kod
RewriteEngine on

RewriteRule ^([^-]*)-([^-]*).html$ index.php?controller=$1&page=$2 [L]


Funkcja ClearText

  1. function ClearText($Text)
  2. {
  3.  
  4. {
  5.  
  6. $Text = stripslashes($Text);
  7.  
  8. }
  9.  
  10. $Text = trim($Text);
  11. //$Text = mysql_real_escape_string($Text);
  12. $Text = htmlspecialchars($Text);
  13. $Text = htmlentities($Text);
  14.  
  15. return $Text;
  16.  
  17. }


Problem jest następujący a mianowicie czego bym nie zrobił to skrypt wcale nie widzi zmiennej controller. Jakieś pomysły?
nospor
1) A patrzyles w ogole co idzie GETem?
print_r($_GET);

2) A link w ogole masz poprawny, pasujace do wzorca w .htaccess? Pokaz ten link

3) Kropka to znak specjalny wiec ma byc tak: \.
Sephirus
Po pierwsze primo:

  1. if(!$Controller || $Controller = '') { $Controller = 'other'; } // w IF masz "=" a nie "=="


Po drugie primo:

  1. $Text = htmlspecialchars($Text);
  2. $Text = htmlentities($Text);


Serio? Przemyśl tą funkcję ClearText - poczytaj o tym czy coś.

sloenthran
Cytat(Sephirus @ 10.07.2014, 08:46:09 ) *
Po pierwsze primo:

  1. if(!$Controller || $Controller = '') { $Controller = 'other'; } // w IF masz "=" a nie "=="


Po drugie primo:

  1. $Text = htmlspecialchars($Text);
  2. $Text = htmlentities($Text);


Serio? Przemyśl tą funkcję ClearText - poczytaj o tym czy coś.


Nie zwróciłem uwagi na = dzięki wink.gif

~Do zamknięcia
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.