php - Codeigniter Ajax Risk with Get -


what security implications of using method in ajax , methods should adopt counter threats in following example?

in simple implement, i've ajax-codeigniter code following... there no form submissions , database connections.. want output of php function (targetfucntion in code) webpage (at targetdiv div in html) can see webpage, no login needed...

i have read bit insecure opposed post. tried use post method, had issues. couldn't go that. i'm using method. should take precautions input sanitation etc.. please me this! thank you!

controller

class thecontroller extends ci_controller {     function __construct()     {             parent::__construct();             $this->load->helper('url');     }     function idea_generator() {        $this->load->view('myviewfile');    }     function targetfunction() { echo somefunction();    } }  ?> 

view file - "myviewfile"

<html> <head> <title>title</title> <script language="javascript"> var xmlhttprequestobject = false;  if(window.xmlhttprequest) {  xmlhttprequestobject = new xmlhttprequest(); } else if (window.activexobject) {  xmlhttprequestobject = new activexobject("microsoft.xmlhttp"); }  function getdata(datasource,divid) {  if(xmlhttprequestobject) {    var obj = document.getelementbyid(divid);    xmlhttprequestobject.open("get",datasource);     xmlhttprequestobject.onreadystatechange = function()    {    if(xmlhttprequestobject.readystate == 4 && xmlhttprequestobject.status == 200)    {        obj.innerhtml = xmlhttprequestobject.responsetext;    }    }     xmlhttprequestobject.send(null);    }   }  </script> </head> <body> <h1>my cool app</h1> <input type="button" value ="submit!!" onclick="getdata('targetfunction','targetdiv')"> <div id="targetdiv"> <p>the fetched message appear here </p> </div> </body>  </html> 

if there no form submission , codeigniter not accept input via $this->input->get() or $_get (parameters after url, i.e. ?var1=value&var2=value2) in targetfunction() method, there no security holes can think of.

also, codeigniter sanitizes strange characters in requests default also.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -