Welcome Guest, Not a member yet? Register   Sign In
Incoming $_GET request problems
#1

[eluser]pepijn744[/eluser]
Hi,

I'm working on this for two days now and I still don't know how to fix this. My website receives an $_GET request from an external company once in a while. I have no influence whatsoever to change this into CodeIgniter-friendly U/R/Is. I really need to 'redirect' this request to a controller.

I've already looked at certain solutions such as this one: parse_str($_SERVER['QUERY_STRING'],$_GET);, it doesn't work in my situation.

Something to keep in mind: I redirect all www.mysite.com/(:any) to /profile/show/$1 (except for /contact, /register and so on), so in my opinion it is best to use an external file like /request.php?Very=long&get=string and then redirect to /request/receive/very/long/get/string.

It would be so nice if anyone could help me out.
#2

[eluser]JoostV[/eluser]
You could write a hook that stores $_GET vars for later use. You could for instance define them as constants. Hooks can be called before any other libraries, so I am guessing they van also be called before the $_GET array is killed.

http://ellislab.com/codeigniter/user-gui...hooks.html

You would have to call the hook 'pre_system', I think.

Possible hook code (not tested, mind you)
Code:
if (count($_GET) > 0) {
    // define a constant for every $_GET parameter
    foreach ($_GET as $key => $value) {
        define(strtoupper($key), htmlentities(strip_tags($value)));
    }
}
Above code will store ?Very=long&get=string as
Code:
VERY = 'long';
GET = 'string';

The htmlentities(strip_tags($value)) should protect you from most evil xss and injection attacks.

*EDIT*
Alternatively, you could also enable query strings, but then you would have to call controllers through $_GET as well Sad
index.php?c=controller&m=method
See http://ellislab.com/codeigniter/user-gui.../urls.html
#3

[eluser]kgill[/eluser]
What about a non-CI solution, set up a php script outside of CI to receive the data and then relay it on to your CI app either as a CI friendly URL or posted to the right controller/method.
#4

[eluser]pepijn744[/eluser]
@JoostV: already tried that but my .htaccess and routing is preventing the file/?xxx part from being loaded/initialized.

[quote author="kgill" date="1233890220"]What about a non-CI solution, set up a php script outside of CI to receive the data and then relay it on to your CI app either as a CI friendly URL or posted to the right controller/method.[/quote]

That sounds good, have any suggestions? Is there a way that a non-CI file receives the $_GET variables and then posts the data to the CI file? That way the routing also stays clean.

Instead of /request/get/?p=blaba&x=lulul&h=yaya it's just /request/get (with $_POST vars).
#5

[eluser]kgill[/eluser]
Either way going to have to work with cURL, basically just loop through your $_GET to pull out what you want and send it on.
#6

[eluser]pepijn744[/eluser]
[quote author="kgill" date="1233892866"]Either way going to have to work with cURL, basically just loop through your $_GET to pull out what you want and send it on.[/quote]

I'm never used cURL actually. Could you give me an example for my situation? Or is it to much work and will I spend the weekend on it...? Anyway thanks giving me some help!




Theme © iAndrew 2016 - Forum software by © MyBB