Welcome Guest, Not a member yet? Register   Sign In
specific controllers allowing query strings
#11

[eluser]drewbee[/eluser]
urlencode() and urldecode() should get rid of all those weird characters and all you to pass in the uri (may have to add additional allowable characters)
#12

[eluser]Yorkshire Pudding[/eluser]
thanks i seem to be getting somewhere now. Just an additional thought is there any way you could use the .htaccess file to grab the get variable using reg expression and rewrite the url.

not sure if this would be an easier solution or not?
#13

[eluser]drewbee[/eluser]
Yeah you can.

Maybe something like this?

Code:
RewriteRule ^processor.php\?crypt=(.+)/?$ controller/method/processor/$1 [L]

You may also have to use RewriteCond %{QUERY_STRING}. I havn't used the RewriteCondition before so I have no idea how to carry it to the rule below.

Edit: make sure this rule is above all the other rules
#14

[eluser]xwero[/eluser]
If you want the code of the second solution
Code:
// constants.php
define('GET_HACK',$_SERVER['QUERY_STRING']);
// config.php
$config['enable_hooks'] = TRUE;
// hooks.php
$hook['pre_controller'] = array(
                                'function' => 'const_to_get',
                                'filename' => 'get_hack.php',
                                'filepath' => 'hooks',
                                );
// get_hack.php
function const_to_get()
{
   parse_str(GET_HACK,$_GET);
}
#15

[eluser]Yorkshire Pudding[/eluser]
thanks xwero, trying to use your solution but I'm still struggling to implement it. Read the docs on hooks and still can't get it.

have set everything the following

Code:
// constants.php
define('GET_HACK',$_SERVER['QUERY_STRING']);
// config.php
$config['enable_hooks'] = TRUE;
// hooks.php
$hook['pre_controller'] = array(
                                'function' => 'const_to_get',
                                'filename' => 'get_hack.php',
                                'filepath' => 'hooks',
                                );
// get_hack.php
function const_to_get()
{
   parse_str(GET_HACK,$_GET);
}

so the payment gateway posts back to home/order_success
Code:
home/order_success?crypt=DycAHF1HGiA1WRU9VFFGAGBkOChhYTYREgsKYV4mR3NhdFlVCwR2HVt1RG8vSUdzHQNDPnd2dmAwDjVpKFwySH8RGhlGQD1lOX1XCx0FBUAqBgsMU1wiZUYGQWhJXlFhMSdOOUdBJjcEXwI5HQ0eW3k1DwsSZjs7FVMCKw8RHRt/FhY5R0EmFhkLRWlQU0cNb2QvLmF2GGpLcjAMKEQ/eg1iLTB3dgUdMhAwPA0WFEYqEAsLR1k6ZTh5JQg7Kyd8HQcqXmJaPSw1WRU9OwECQDU2UzZ9YR4KOWA4HCwgV3YPcDwdQUAiLEt4Pgw5Nj5jEAYrPBRyJz4Cdxg8VFRXBh0RCxtHRysLAlcFLRpZP3oNASY9cX4LHFB3HDccCgUIaHVASAI=

Obviously the first thing that I get is a 404. How does the solution that you provided strip the query string out so i don't get the 404?

Thanks
#16

[eluser]xwero[/eluser]
That is something i didn't think of so you would have to create a route like this one
Code:
$route['(home)/(order_success)(.+)'] = '$1/$2';
#17

[eluser]Yorkshire Pudding[/eluser]
still getting a 404 using a route

tried
Code:
$route['home/(^order_success)'] = "home/order_success";
$route['home/^order_success'] = "home/order_success";
$route['home/order_success'] = "home/order_success";

the url i want to redirect is:
Code:
http://localhost/mysite/index.php/home/order_success?crypt=DycAHF1HGiA1WRU9VFFGA2tkOChhYTYREgsKGyogQAQbdFpVAgd8HFsEMGlRSUBxbnRDOgIMDWswd0lpWlJJSH8RGhlGQD1lOX1XCx0FBUAqBgsMU1wiZUYGQWhJXlFhMSdOOUdBJjcEXwI5HQ0eW3k1DwsSZjs7FVMCKw8RHRt/FhY5R0EmFhkLRWlQU0kDb2QvLmF2GGpLcjAMKEQ/eg1iLTB3dgUdMhAwPA0WFEYqEAsLR1k6ZTh5JQg7Kyd8HQcqXmJaPSw1WRU9OwECQDU2UzZ9YR4KOWA4HCwgV3YPcDwdQUAiLEt4Pgw5Nj5jEAYrPBRyJz4Cdxg8VFRXBh0RCxtHRysLAlcFLRpZP3oNASY9cX4LHFB3HDccCgUIaHdASAI=

thanks
#18

[eluser]drewbee[/eluser]
Im not quite sure how you would deal with the question mark though...

Code:
$route['home/order_success(.*)] = 'home/order_success/' . str_replace('?crypt=', '', $1);

Edit: That is probobly all kinds of wrong. Big Grin
#19

[eluser]Yorkshire Pudding[/eluser]
If i use $hook['pre_system'] instead of $hook['pre_controller'] i shouldn't need to deal with the query string? I just want to strip it out and redirect them to 'home/order_success'.

I should then be able to call the constant from within my controller?
#20

[eluser]Yorkshire Pudding[/eluser]
tried $route['home/order_success(.*)'] = "home/order_success" and still got a CI 404 btw




Theme © iAndrew 2016 - Forum software by © MyBB