Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [inne][PHP] Brak jednego z $_GET[''] w skrypcie...
sloenthran
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 2
Dołączył: 26.06.2013

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


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?

Ten post edytował sloenhtran 10.07.2014, 07:42:12
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




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: \.
Go to the top of the page
+Quote Post
Sephirus
post
Post #3





Grupa: Zarejestrowani
Postów: 1 527
Pomógł: 438
Dołączył: 28.06.2011
Skąd: Warszawa

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


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

Go to the top of the page
+Quote Post
sloenthran
post
Post #4





Grupa: Zarejestrowani
Postów: 16
Pomógł: 2
Dołączył: 26.06.2013

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


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 (IMG:style_emoticons/default/wink.gif)

~Do zamknięcia
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: 22.08.2025 - 20:59