Good afternoon,
I have some doubts about security in CodeIgniter, first:
I have a controller: news.php, and in it I have a method called view
Example:
class News extends CI_Controller{ public function view( $id ) { $this->load->model('news_model'); $this->news_model->get_by_id( $id );
Is this form of work safe? no risk of SQL injection at url? whereas this page is available, therefore mywebpage / news / number_id. Would it be interesting to filter through intval () or unnecessary?
My second question is:
By default, the CodeIgniter xss filter can publish and receive, but an unknown way to filter HTML using CodeIgniter, I created a helper in CodeIgniter, is there some way similar to that in native CodeIgniter?
function remove_xss_html($string){ if( is_array( $string ) ){ $return_array = array(); foreach( $string as $item ) { if(!get_magic_quotes_gpc()) { $return_array[] = addslashes( htmlspecialchars( strip_tags( $item ) ) ); } else { $return_array[] = htmlspecialchars( strip_tags( $item ) ); } } return $return_array; } else { return htmlspecialchars( strip_tags( $string ) ); } }
and the third and last question:
If I send the variable $ this-> input-> post ('my_var') directly to the database without a filter, do I run the risk of sql injection? CodeIgniter or filters so safe?
IMPORTANT: my English is not very good, I used Google translation and fixed everything I could.
Thanks everyone ...
source share