CodeIgniter Forums
Please consider querystring support in 2.x - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Please consider querystring support in 2.x (/showthread.php?tid=31698)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Please consider querystring support in 2.x - El Forum - 08-23-2010

[eluser]wesblake[/eluser]
I just confirmed it's something to do with the url being encoded. If I replace the , &, and ='s with space, & and =, the page works and I can get the $_GET variables! However, the fax service won't make exceptions for 1 customer, so I need to figure out a way for this mod to work with encoded url's, any ideas? Thanks again.

EDIT - In case you have encoded url's, I got it to work by adding Schaftenaar's line into MY_Input, so it's like this. Please let me know if there's a better solution. Thanks.
Code:
<?php
/**
* This extension ensures GET data is not erased
*/
class MY_Input extends CI_Input{
    function _sanitize_globals(){
        $this->allow_get_array = TRUE;
        parse_str(urldecode($_SERVER['QUERY_STRING']), $_GET);
        parent::_sanitize_globals();
    }
}



Please consider querystring support in 2.x - El Forum - 08-24-2010

[eluser]pbreit[/eluser]
Is this necessary?
Code:
parse_str(urldecode($_SERVER['QUERY_STRING']), $_GET);



Please consider querystring support in 2.x - El Forum - 08-24-2010

[eluser]WanWizard[/eluser]
No. $_GET does already contain the query string.


Please consider querystring support in 2.x - El Forum - 08-25-2010

[eluser]sqwk[/eluser]
I am using the solution as described in post 52: http://ellislab.com/forums/viewthread/159382/P45/#781086

Using $this->input->get('foo'); does not produce any output. Has this solution changed? Or will I also have to update another file? Does the .htaccess file have to change?


Please consider querystring support in 2.x - El Forum - 08-25-2010

[eluser]pbreit[/eluser]
WanWizard's solution only includes the MY_Input.php change:
http://ellislab.com/forums/viewthread/159382/P75/#781919

I'm not sure if the MY_URI.hp change is necessary.


Please consider querystring support in 2.x - El Forum - 08-26-2010

[eluser]WanWizard[/eluser]
No, to get this working, the only thing you need is the _sanitize_globals() extension.

I my original contribution I described the solution that needs to be incorporated into the core code (to solve it properly using a second config value), which does require a change to the URI class, to use the config value names consistently.

Not relevant when you're just overloading the core code.


Please consider querystring support in 2.x - El Forum - 08-26-2010

[eluser]sqwk[/eluser]
@WanWizard: So I only need the MY_Input library and nothing else? Not that adding the MY_URI library seems to make a difference: No query stings either way.

I would like to keep everything separate, so changing the core files is not an option for me.

Interestingly, when I toggle the URI Protocol to REQUEST_URI instead of AUTO, I get an error saying that there are invalid characters in the URl, otherwise I don't (Must be the ?—I only use ?test=foo)

Is there anything in the server environment that I have to watch out for? I am running on localhost under Snow Leopard for development purposes.

EDIT: I now grabbed the modified files directly from Wan's exitecms repository—if I have to replace the core files, so be it. Strangely it still doesn't work.

Code:
// Vardump of $_get:
array(1) { ["/segment1/segment2/"]=> string(0) "" }


// vardump of $this->input->get('test'):
bool(false)

I am little startled why the segments are showing up in the Get array though… I thought CI doesn't use get for routing.


Please consider querystring support in 2.x - El Forum - 08-26-2010

[eluser]kungfun[/eluser]
Hi,

Great thread and i'd love to see a great solution for this. The issue i'm having is in respect to different server configurations.

Most of the methods work as long as you can use PATH_INFO, however the production server we're on doesn't have it. Its php as cgi.

We've tried
http://github.com/dhorrigan/codeigniter-query-string
the My_Input sanitize globals
and a couple others that require PATH_INFO, so not really an option

All work great on the dev servers.

So we've tried setting AccepthPathInfo to On, cgi.fix_pathinfo to 1. but neither seemed to affect anything.

Our rewrite rule therefore needs to be

RewriteRule ^(.*)$ index.php?/$1 [L]

Since it does not accept urls like index.php/controller/method only index.php?/controller/method

So if we try to add a querystring to the end we end up with index.php?/controller/method?test=test, and this ends up 404 page.

Has anyone gotten querystring + segment support, if they're still using the same rewrite rule as above?

Or anyone know a rewrite rule that will just remove the querystring before we do the final rewrite?

Need a workaround at the very least.

Thanks.


Please consider querystring support in 2.x - El Forum - 08-26-2010

[eluser]WanWizard[/eluser]
What is the config value for 'enable_query_strings' in config/config.php. This should be FALSE!

What is the exact URL you're trying to test? because you now have some URI segments as key in your $_GET array, which should never be after the question mark in the URL, and can therefore not be part of the query string.

All the modification in MY_Input does is to prevent _sanitize_globals() from erasing the contents of the $_GET array. This array is initialized by PHP when it starts from the query string passed by the webserver.
If the contents is wrong, your URL is wrong, or the webserver makes a mess of things (not likely).

Can you post a var_dump($_SERVER) of the request you're trying to test (send via PM if you don't want the info public)?


Please consider querystring support in 2.x - El Forum - 08-26-2010

[eluser]kungfun[/eluser]
Thanks WanWizard,

Yes, enabled_query_strings is set to false.

For the URLs
If this is my rewrite rule
RewriteRule ^(.*)$ index.php?/$1 [L]

and i access rootfolder/asdf/123/

it will rewrite as index.php?/asdf/123/ right? so the ? is added because this type of url is invalid on the prod server index.php/asdf/123/

if i access rootfolder/asdf/123/?test=test if i var dump $_GET i see array(1) { ["/asdf/123"]=> string(0) "" }

i have $config['uri_protocol'] = "AUTO";

the other issue seems to be if i just do rootfolder/?test=test i would think it should route to the default controller so index.php?/welcome, but i seem to get only a 404 page not found error.