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-01-2010

[eluser]skunkbad[/eluser]
[quote author="pbreit" date="1280665638"]The article seems to indicate that this solutions supports mixing segments and querystrings?[/quote]

It did work for me on my development server, but due to the nature of servers being configured differently, and the fact that a good amount of people who commented said it didn't work for them, I don't think it's a reliable solution.

I know you were the one that started this thread, but you might go back and read through all of the messages. Some point to problems that make this solution unreliable.


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

[eluser]WanWizard[/eluser]
All my proposed solution does is to avoid having $_GET erased. It doesn't interfere with CI's internal working, and should work in any setup.


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

[eluser]amosmos[/eluser]
Hey WanWizard, your solution didn't work for me and I suspect the reason is that I'm using the REQUEST_URI URI protocol and not AUTO (REQUEST_URI is the only protocol that works with GoDaddy hosting).

I looked over the code and tried to see how to fix it with REQUEST_URI and just didn't understand where it ignores the "?" character and everything that follows it. I also tried to see how you solved it in the AUTO protocol and couldn't really understand. I suspect that that when using AUTO and, after you fix, not entering the first "if" makes the _fetch_uri_string method ignore the "?" character, but I;m not sure.

Anyway, after fighting with this for a while, I just used dhorrigan's hook (http://github.com/dhorrigan/codeigniter-query-string) which worked instantly.

But I would still would like to change the code of the core so it would work for me without using hooks, so if you can please see if you can assist, that would be really great.

Thank,
Amos


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

[eluser]Clooner[/eluser]
Why not simply rebuild the get parameters when you need them?
Code:
Pros
-  only a few lines of code
-  it will coexists with any app
-  it wont be an ugly hack
-  you can enable it whenever you need it
-  segments and get will both work
Cons
-  (not really a con) it is not enabled by default and you will have to write a few lines of code yourself



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

[eluser]amosmos[/eluser]
[quote author="clooner" date="1280764888"]Why not simply rebuild the get parameters when you need them?
Code:
Pros
-  only a few lines of code
-  it will coexists with any app
-  it wont be an ugly hack
-  you can enable it whenever you need it
-  segments and get will both work
Cons
-  (not really a con) it is not enabled by default and you will have to write a few lines of code yourself
[/quote]

How is that possible? I can't even load the page... i get an "The URI you submitted has disallowed characters" error because of the "?" and the "=" characters. And if I allow them in the config file I just get a 404 error because CI thinks the query string is part of the controller (or method) name.


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

[eluser]Clooner[/eluser]
[quote author="amosmos" date="1280765183"]
How is that possible? I can't even load the page... i get an "The URI you submitted has disallowed characters" error because of the "?" and the "=" characters. And if I allow them in the config file I just get a 404 error because CI thinks the query string is part of the controller (or method) name.[/quote]

I usually don't change anything in the config file.
then simply use
Code:
$_SERVER['REQUEST_URI']
to get the Get parameters. One line of code Tongue


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

[eluser]Clooner[/eluser]
Actually the easiest way is to use query_string.
Code:
parse_str($_SERVER['QUERY_STRING'],$_GET);

and within this one line your $_GET is rebuild Big Grin


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

[eluser]amosmos[/eluser]
[quote author="clooner" date="1280765876"][quote author="amosmos" date="1280765183"]
How is that possible? I can't even load the page... i get an "The URI you submitted has disallowed characters" error because of the "?" and the "=" characters. And if I allow them in the config file I just get a 404 error because CI thinks the query string is part of the controller (or method) name.[/quote]

I usually don't change anything in the config file.
then simply use
Code:
$_SERVER['REQUEST_URI']
to get the Get parameters. One line of code Tongue[/quote]

Well then your advise is not good to me, I have to change the "uri_protocol" to "REQUEST_URI" because that's the only way it can work on GoDaddy hosting. By doing this, I can no longer use any query string variable at all, or else I get the "The URI you submitted has disallowed characters" error.

So again, WanWizard, can you help me out? I want to understand how I should make CI ignore the "?" character and what follows it, so that I can use your solution...

Thanks,
Amos


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

[eluser]Clooner[/eluser]
[quote author="amosmos" date="1280766672"]
Well then your advise is not good to me, I have to change the "uri_protocol" to "REQUEST_URI" because that's the only way it can work on GoDaddy hosting. By doing this, I can no longer use any query string variable at all, or else I get the "The URI you submitted has disallowed characters" error.

So again, WanWizard, can you help me out? I want to understand how I should make CI ignore the "?" character and what follows it, so that I can use your solution...

Thanks,
Amos[/quote]

What are you talking about? Simply change the config uri protocol to REQUEST_URI and add to the allowed characters ?=& which you will have to do now because you use request_uri and I am sure it will work that way.

config
Code:
// for this difficult host :P
$config['uri_protocol']    = "REQUEST_URI";
// add allowed types
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?=&';
// leave it at disabled
$config['enable_query_strings'] = FALSE;

controller
Code:
//rebuild the get
parse_str($_SERVER['QUERY_STRING'],$_GET);

When I said that you don't need to change the config file I meant that it usually works out of the box Big Grin

This is the way to go! no ugly code changes or hooks and again usually this works by default!


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

[eluser]amosmos[/eluser]
[quote author="clooner" date="1280767148"][quote author="amosmos" date="1280766672"]
Well then your advise is not good to me, I have to change the "uri_protocol" to "REQUEST_URI" because that's the only way it can work on GoDaddy hosting. By doing this, I can no longer use any query string variable at all, or else I get the "The URI you submitted has disallowed characters" error.

So again, WanWizard, can you help me out? I want to understand how I should make CI ignore the "?" character and what follows it, so that I can use your solution...

Thanks,
Amos[/quote]

What are you talking about? Simply change the config uri protocol to REQUEST_URI and add to the allowed characters ?=& which you will have to do now because you use request_uri and I am sure it will work that way.

config
Code:
// for this difficult host :P
$config['uri_protocol']    = "REQUEST_URI";
// add allowed types
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?=&';
// leave it at disabled
$config['enable_query_strings'] = FALSE;

controller
Code:
//rebuild the get
parse_str($_SERVER['QUERY_STRING'],$_GET);

When I said that you don't need to change the config file I meant that it usually works out of the box Big Grin

This is the way to go! no ugly code changes or hooks and again usually this works by default![/quote]

I don't think you are fully reading the posts, which is OK because there are so many of them now and it can get a bit confusing.

1. CI doesn't work out of the box for me and I *have* to change the protocol to "REQUEST_URI". So the first step you are telling me to do I already do because I have to.

2. Now you say to add the "?=&" characters to the allowed characters. Well like I wrote before, I tried that but then if I do it this way CI thinks the entire thing is the controller (or method) name and don't understand it needs to ignore the "?" character and everything that follows it. That's why in this case I get a "404" error (and not the "The URI you submitted has disallowed characters" error).

So, like I said, I don't even get the page loaded at all.

WanWizard, hope I could hear your input on this...

Thanks