• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
undesired $_GET array cleansing

#1
[eluser]ocdcoder[/eluser]
Hey guys,
This is my first post on here, but I've been using CodeIgniter for a few months now (PHP for years). I'm currently trying to make an json/REST api mesh. Anyway, I've been working on trying to get CodeIgniter to recognize auth keys via GET. I'm using REQUEST_URI to determine the path, as well as file extensions to determine return format (this is a custom CI patch). So a desired URL would look like:

http://domain.com/rest/obj/action/uri/to...aF4bV08C1a

Everything is working just fine, except the 'key' $_GET var. When I started looking through the code, my first place was at the CI_Input class where I found the _sanitize_globals function. I do have enable_query_strings set to TRUE, so it runs through the GET vars and sanitizes them.

Here's the weird (to me) thing, when I put in some debug messages I noticed first that _sanitize_globals() was being run/called 3 times, which I am implying that the Input class is being instantiated 3 times because that's the only place its called. The big kicker is that the $_GET array is right the first two times, its the third time when its ran that the $_GET array is empty (meaning = Array(), not null).

I'm going to continue looking at related libraries as their has to be some other library that is manipulating the $_GET array directly, possibly in URI.php, but I haven't found that place yet. Any help would be greatly appreciated! Thanks in advance!

Also, when I find out whats wrong, my plan is to create a mechanism in the session library that would check for a key and load session info based on the key.

#2
[eluser]Colin Williams[/eluser]
Use something like Firebug to see all the calls being made. My guess is that there are three separate HTTP requests happening, and the third simply has no query string (maybe a bad image/js/css path)

#3
[eluser]ocdcoder[/eluser]
I made a discovery, it actually appears to be how I was testing Undecided. When calling the URL from a browser, CI properly handles the $_GET array, its when using PHP's file_get_contents as a GET method that I have issues.

And now I have it fixed. I was sending a Content-type of application/x-www-form-urlencoded (or whatever is the proper name for it). The issue was resolved when I switched to an Accept header instead of a Content-type header. Sorry for the noise :-)

#4
[eluser]ocdcoder[/eluser]
Colin Williams,
As for the multiple Input calls, I was using the same system for the api and the website (I separated them for unexplained valid reasons). It was that that was causing the multiple loads :-) When the variables showed up for the first two, but not the last, was actually the variables showing for the website requests, but not the api request.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.