<![CDATA[ Secure your SQL - My Forums]]> https://forums.modx.com/thread/?thread=19702 <![CDATA[Re: Secure your SQL]]> https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109456 sottwell May 12, 2006, 11:58 PM https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109456 <![CDATA[Re: Secure your SQL]]> https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109455 Quote from: xwisdom at Feb 09, 2006, 04:12 PM

Thanks for sharing susan.

There’s also safehtml for XSS

http://pixel-apes.com/safehtml/

Great piece of code! I was doing something like this just recently but this is way better, thanks for the link! grin

---Indie]]>
indie May 12, 2006, 07:58 PM https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109455
<![CDATA[Re: Secure your SQL]]> https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109454 rethrash Feb 09, 2006, 10:28 AM https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109454 <![CDATA[Re: Secure your SQL]]> https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109453
There’s also safehtml for XSS

http://pixel-apes.com/safehtml/]]>
xwisdom Feb 09, 2006, 10:12 AM https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109453
<![CDATA[Secure your SQL]]> https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109452
If you are using the MODx DBAPI, remove the part that sets the single quote if not integer, since MODx adds single quotes.

function quote_smart($value)
{
   // Stripslashes
   if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
   }
   // Quote if not integer - remove or comment out if using MODx DBAPI
   if (!is_numeric($value)) {
       $value = "'" . mysql_real_escape_string($value) . "'";
   }

// if using MODx DBAPI uncomment this
//  $value = mysql_real_escape_string($value);

   return $value;
}


Filter all of your incoming data through this:

$val1 = quote_smart($_POST['value1']);
$val2 = quote_smart($_POST['value2']);
$query = "INSERT INTO $dbase.$table (`field1`, `field2`) VALUES ($val1, $val2)";
]]>
sottwell Feb 09, 2006, 06:43 AM https://forums.modx.com/thread/19702/secure-your-sql#dis-post-109452