I have the following method: (Codeigniter model)
/**
* Get an Ad based on its hash
*
* @param $hash
* @return bool
*/
public function getAdbyHash($hash)
{
$this->db->select('category.id as category_id, category.subcat as category_name, provinces.id as provinces_id, provinces.prov_name, users.id as users_id, users.*, ads.*');
$this->db->where('ads.hash', $hash);
$this->db->join('category', 'category.id = ads.subcat_id');
$this->db->join('provinces', 'provinces.id = ads.province_id');
$this->db->join('users', 'users.id = ads.user_id', 'left');
$r = $this->db->get('ads');
//echo $this->db->last_query();
if ($r->num_rows() == 1) {
$ad = $r->result()[0];
return $ad;
}
return FALSE;
}
And it's works fine. but today I try to hack myself introducing a similar hash in the URL, and its work too, but that's not the desired behavior.
So this hash: edit/zIpM41NkS8igFXaC must NO be the same as edit/zIpM41NkS8igFXac
Note the last char (C/c) How do I query with case sensitive?
My approach was to use a specific method of Codeigniter and not using a direct SQL sentence. But works anyway.