I'm currently working with 3dCart advanced API, which uses SOAP requests and SQL in order to query the database.
I am worried about security. What are some options for making a remote query secure?
Here is some sample code:
class Data {
private $db;
public function __construct(){
$this->db = new soapclient('http://api.3dcart.com/cart_advanced.asmx?WSDL',array('trace'=>1,'soap_version'=>SOAP_1_1));
}
public function query($sql = "SELECT TOP 20 * FROM category"){
$param = array(
'storeUrl'=>"example.com",
'userKey'=>"supersecretcode",
'sqlStatement'=>$sql
);
$result = $this->db->runQuery($param);
$match = $result->runQueryResult->any;
$sxe = new SimpleXMLElement($match);
return $sxe->runQueryRecord;
}
}
I run queries like this:
$db = new Data()
$query = $db->query("SELECT id, category_name FROM category WHERE category_name LIKE '%".$search_term."%' AND isFilter = 0 AND hide = 0");
//WORK WITH QUERY DATA HERE
How do I secure this? Since I'm not directly connected to the sql server is there any way to prevent sql injection?