Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Zabezpieczenie $_POST i $_GET
patryk9200
post
Post #1





Grupa: Zarejestrowani
Postów: 319
Pomógł: 4
Dołączył: 7.02.2009
Skąd: pless

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


Cześć,
Da może się zrobić tak żeby każdą tablicę w skrypcie bez wyjątku $_GET lub $_POST był "oczyszczony" z wszelakiego kodu PHP i zapytań MySQL ?
Tylko zależy mi na tym żeby $_POST html można było przesyłać...
Jak takie coś zrobić?

Ten post edytował patryk9200 24.07.2009, 19:09:03
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tomekpl
post
Post #2





Grupa: Zarejestrowani
Postów: 134
Pomógł: 5
Dołączył: 9.08.2008
Skąd: Szczecin

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


  1. <?php
  2. $arrArguments = array();
  3.  
  4.    $intArgumentIndex = 0;
  5.  
  6.    function parseArgument($arrMatches) {
  7.  
  8.        global $arrArguments, $intArgumentIndex;
  9.  
  10.        $strMatch = $arrMatches[0];
  11.  
  12.        $strArgument = @$arrArguments[$intArgumentIndex++];
  13.  
  14.        switch ($strMatch) {
  15.  
  16.            case '%d': return (int)$strArgument;
  17.  
  18.            case '%s': return '"'.
  19.  
  20.              mysql_real_escape_string($strArgument).'"';
  21.  
  22.            case '%b': return (int)((bool)$strArgument);
  23.  
  24.        }    
  25.  
  26.    }
  27.  
  28.    function SQL($strSql) {
  29.  
  30.        global $arrArguments, $intArgumentIndex;
  31.  
  32.        $arrArgs = func_get_args();
  33.  
  34.        array_shift($arrArgs);
  35.  
  36.        $arrArguments = $arrArgs;
  37.  
  38.        $intArgumentIndex = 0;
  39.  
  40.        return preg_replace_callback('/(%[dsb])/', 'parseArgument',
  41.  
  42.          $strSql);    
  43.  
  44.    }
  45. ?>



(IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
A jak masz GET to prawie zawsze przesyłasz tam jakieś wartości liczbowe
$zmienna=intval($_GET['jakasget'])

przepusci tylko liczby
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: 16.10.2025 - 14:04