Welcome Guest, Not a member yet? Register   Sign In
Segments and GET-data co-existing
#1

[eluser]Burgestrand[/eluser]
As I consider unsetting GET-data as the one shortcoming of CI I tried to fix it.

application/libraries/MY_URI.php
Code:
<?php
    /**
     * This extension ensures a query string is not assumed part of the URI segments.
     */
    class MY_URI extends CI_URI
    {
        function _fetch_uri_string()
        {
            parent::_fetch_uri_string();
            $this->uri_string = preg_replace('#/?\?[^$]*$#u', '', $this->uri_string);
        }
    }
    
/* End of file MY_URI.php */

application/libraries/MY_Input.php
Code:
<?php
    /**
     * This extension ensures GET data is kept unharmed!
     */
    class MY_Input extends CI_Input
    {
        var $get_data;
        
        function _sanitize_globals()
        {
            $this->get_data = $_GET;
            parent::_sanitize_globals();
            $_GET = $this->get_data;
        }
    }
    
/* End of file MY_Input.php */

You’ll also want to change the permitted_uri_chars to something fitting. Personally I added “=?&” to the list, but time might show it needs to be even more liberal.
#2

[eluser]xwero[/eluser]
set the uri_protocol to path_info/path_info_org/request_uri and use
Code:
parse_str($_SERVER['QUERY_STRING'],$_GET);
where you need the get values.

Less changes and no core adjustments.
#3

[eluser]Burgestrand[/eluser]
[quote author="xwero" date="1239991976"]set the uri_protocol to path_info/path_info_org/request_uri and use
Code:
parse_str($_SERVER['QUERY_STRING'],$_GET);
where you need the get values.

Less changes and no core adjustments.[/quote]
Have my babies!

(Thanks)

Edit: It appears as if PATH_INFO and ORIG_PATH_INFO does not work properly on my installation (using REQUEST_URI). Applying a query string to the URL makes it unable to find the correct controller / method. It could have something to do with my rewrite rules (using lighttpd), I suppose.

At least that's one extension less (MY_Input), either way.
#4

[eluser]wiredesignz[/eluser]
htaccess for PHP-CGI hosting (and use segments with query strings)
#5

[eluser]Burgestrand[/eluser]
[quote author="wiredesignz" date="1240047247"]htaccess for PHP-CGI hosting (and use segments with query strings)[/quote]
Thanks!

Unfortunately I run lighttpd and I'm not sure it has the equivalent in rewrite rules (or if it's less trouble than extending the URI library).

Either way, I corrected the code to extend another method instead. Right now it has troubles with the default controller.
#6

[eluser]Dready[/eluser]
HERE you'll find everything you need without having to change the code.




Theme © iAndrew 2016 - Forum software by © MyBB