Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]proszę o opinię na temat klasy przeciwdziałającej sql injection
omxd
post
Post #1





Grupa: Zarejestrowani
Postów: 135
Pomógł: 0
Dołączył: 18.05.2010

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


Witam serdecznie,
przeczytałem setki opinii na temat sql injection i wiem ,że nie ma idealnego rozwiązania.Postanowiłem ,że dla pewności usunę wszystkie słowa i znaki które mogą zaszkodzić (użytkownik nie potrzebuje tych znaków).Proszę o wyrażenie opinii i ew.luk chciałbym mieć jako taką pewność ,że nikt mi tego za moment nie rozsypie.Z góry dziękuję.
  1. <?php
  2.  
  3. class Lib_Validation_Sql {
  4.  
  5. public $liste = array('\'', 'declare', 'char', 'set', 'cast', 'convert', 'drop', 'exec', 'meta', 'script', 'select', 'truncate', 'insert', 'delete', 'union', 'update', 'create', 'where', 'join', 'information_schema', 'table_schema', 'into');
  6. private $specialfind = array('"', '-', '*', '=');
  7. private $specialreplace = array('"', '-', '*', '=');
  8.  
  9. public function checkInteger($int) {
  10. if (is_numeric($int)) {
  11. return true;
  12. }
  13. }
  14.  
  15. public function checkString($string) {
  16.  
  17. foreach ($this->liste as $commands) {
  18. $string = str_replace($commands, " ", $string);
  19. }
  20.  
  21. $counted_el = count($this->specialfind);
  22. for ($i = 0; $i <= 10; $i++) {
  23. $string = str_replace($this->specialfind[$i], $this->specialreplace[$i], $string);
  24. }
  25.  
  26. if ((is_string($string)) and (false !== strpos($string, "\\"))) {
  27. $string = str_replace( array("\\"), '', $string);
  28. }
  29. if ((is_string($string)) and (false !== strpos($string, "/"))) {
  30. $string = str_replace( array("/"), '', $string);
  31. }
  32.  
  33. return $string;
  34. }
  35.  
  36. }
  37.  
  38. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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 - 22:52