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

[eluser]skunkbad[/eluser]
[quote author="tuffy" date="1280980064"]I have enable_query_string set to true and the following works for me:

Code:
$this->input->get('var');
[/quote]

So what happens if you use "c" or "m" as one of the query string keys? I haven't tested this, but I'm assuming, due to the docs, that now what you thought was working will not work so well.

For instance:
Code:
http://yoursite.com/one/two?c=three&m=four

For this example, you should be routed to the three controller, and to the four method. I know you will probably say, I know this, so I won't name my keys "m" or "c". The problem is if you are accepting a request from a service that uses "m" or "c" as a key in the query string.


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

[eluser]tuffy[/eluser]
[quote author="skunkbad" date="1280984451"][quote author="tuffy" date="1280980064"]I have enable_query_string set to true and the following works for me:

Code:
$this->input->get('var');
[/quote]

So what happens if you use "c" or "m" as one of the query string keys? I haven't tested this, but I'm assuming, due to the docs, that now what you thought was working will not work so well.

For instance:
Code:
http://yoursite.com/one/two?c=three&m=four

For this example, you should be routed to the three controller, and to the four method. I know you will probably say, I know this, so I won't name my keys "m" or "c". The problem is if you are accepting a request from a service that uses "m" or "c" as a key in the query string.[/quote]

In that case, could you not just nullify the triggers?

Code:
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = null;
$config['function_trigger'] = null;

Or just assign them a very random string? (ex: duxhsalxiusdhukkxzkd)


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

[eluser]skunkbad[/eluser]
I don't know. I suppose you could.

I'm seeing that there are a lot of ways that we can use $_GET, and because there are a few ways shown in this thread, nobody should have a problem with $_GET. I don't use $_GET, but if I had to I know it is definitely possible. I think the CI docs should have a section on segments + query string usage. Better yet would be this functionality by default in 2.x. I know EllisLab has more to do than listen to our requests, and I wish they would comment here in this thread about the possibility of a fully supported (by default) segments + query strings. It's something worth considering because it is standard website functionality.


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

[eluser]pbreit[/eluser]
Quote:I don’t use $_GET, but if I had to
This comment bugs me. If you don't use querystrings, that means you do not work at Google, Facebook, Yahoo, Amazon, Ebay, etc. It means your framework is taking away from you a core aspect of HTTP. It means your users can't bookmark or email searches. It means your code doesn't interface with other code. That CodeIgniter users accept this situation is why it remains undelivered.


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

[eluser]skunkbad[/eluser]
[quote author="pbreit" date="1281179068"]
Quote:I don’t use $_GET, but if I had to
This comment bugs me. If you don't use querystrings, that means you do not work at Google, Facebook, Yahoo, Amazon, Ebay, etc. It means your framework is taking away from you a core aspect of HTTP. It means your users can't bookmark or email searches. It means your code doesn't interface with other code. That CodeIgniter users accept this situation is why it remains undelivered.[/quote]

Hey, I'm on your side. No need to get offended. You are right, CodeIgniter users have had to accept that $_GET has been disabled, and either figure out a way to fix it, or use something else. It doesn't make any sense. It's like a horse with 3 legs.


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

[eluser]wesblake[/eluser]
[quote author="skunkbad" date="1280529093"]This is working, and probably the kosher way:

MY_Input.php (as suggested a few posts back)
Code:
<?php
// this allows for $_GET access
...

MY_URI.php
Code:
<?php
// this allows for $_GET access and uri segments to work together
class MY_URI extends CI_URI{
    ...
}
[/quote]

Hi, I still need a bit of help. I created these two classes, protocol is still AUTO, enable_query_strings still FALSE, and I modified my permitted_uri_chars to be:
"a-z 0-9~%.:_\-?=&"
Before adding the MY_... classes, I got the 404 error people are mentioning because CI uses the ?... looking for the function.
After adding the classes, I though it would work, but now I get the text "Disallowed Key Characters." and that's it.
The url I'm trying to hit is:
http://www.mydomain.com/index.php/engine/process_fax_results?result=success&timestamp=08/20/2010 01:07:26 PM &destination=12676017739&pages=1&duration=22&userjobcode=b6cab731-e620-3673-bc89-4c6d72a1870f&greenfaxreferenceid=79264266&cost=0.07

We're using a third party to send faxes and this is the ONLY way they return fax results is by GET. Any ideas what's up? Thanks.


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

[eluser]WanWizard[/eluser]
If I paste that URL here, and do a var_dump() of $_GET, I get:
Code:
array
  'result' => string 'success' (length=7)
  'timestamp' => string '08/20/2010 01:07:26 PM ' (length=23)
  'destination' => string '12676017739' (length=11)
  'pages' => string '1' (length=1)
  'duration' => string '22' (length=2)
  'userjobcode' => string 'b6cab731-e620-3673-bc89-4c6d72a1870f' (length=36)
  'greenfaxreferenceid' => string '79264266' (length=8)
  'cost' => string '0.07' (length=4)

Without any changes to the permitted _uri_characters (which should not be needed, the query string isn't part of the URI).

All you need for this to work is
Code:
class MY_Input extends CI_Input
{
    function _sanitize_globals()
    {
        $this->allow_get_array = TRUE;
        parent::_sanitize_globals();
    }
}



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

[eluser]pbreit[/eluser]
I don't recall WanWizard mentioning that permitted_uri_chars needed to be altered. Could that be the issue? It certainly makes sense that permitted chars would need to be changed. But do they?

ADD: WanWinzard beat me to it! (s)he's good!


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

[eluser]wesblake[/eluser]
Thanks. I put everything in the config back to default. I still get the error.
First of all note that I used the override method, not Wanwizard's patch. I can meld code later, but I will most likely forget! Wink
Second, I found out by searching that this error is what CI says when it finds extra characters like carriage returns at odd places. I've run into that before with PHP, like a space at the end of a controller. However, I've checked all of the code that's changed since I added the 2 override files and everything looks good. Argh!

EDIT - I think I may know what's wrong. I just looked at my first post and the forum put in the url I copied/pasted decoded. What the fax service is actually sending is get parameters urlencoded. Could this be the issue? I'm going to try again to put in the exact url that they are using with a code block:
Code:
http://www.mydomain.com/index.php/engine/process_fax_results?result=success&timestamp=08/20/2010 01:07:26 PM &destination=12676017739&pages=1&duration=22&userjobcode=b6cab731-e620-3673-bc89-4c6d72a1870f&greenfaxreferenceid=79264266&cost=0.07

EDIT again - Ok, won't let me do it, still puts in =, & etc. But you know what I mean, they are sending it encoded with percent sign 3D, etc. Thanks.


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

[eluser]skunkbad[/eluser]
You should make sure your files are UTF-8 WITHOUT the BOM. BOM can cause this error.