Türkiye'nin En Eski Webmaster Forumu İyinet'e Hoşgeldiniz!

Post verilerini filtreleme

LvntAyn

0
Onaylı Üye
Üye
Katılım
2 Şubat 2011
Mesajlar
10
Açılan Konu
3
Tepki puanı
0
Konum
Ordu
Merhaba arkadaşlar güvenlik için post verilerini filtrelemem gerek şöyle bir kod buldum r10'da ama uygulayamadım. Yardımcı olurmusunuz.

PHP:
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "lisanssız";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "lisanssız";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "lisanssız";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "lisanssız";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 

eL_Master

0
Onaylı Üye
Üye
Katılım
2 Aralık 2010
Mesajlar
100
Açılan Konu
14
Tepki puanı
0
biraz kasmışlar sanki
strip_tags addslashes htmlspecialchars bunları kullan.
eğer ?id= gibi değerse ve mysql sorgusu yapacaksan mesela
$id=$_GET['id'];
if((gettype($id)=='integer'){
işlemler gibi
 
Üst