Tech-Today
Allowing url query string in codeigniter
As we all know codeigniter uses segment-based as url, example:
Just like these:
classname/methodname/parameter1/paramenter2,
index.php/index/login/user/password
Unfortunately, I was developing a web application that would accept payments via paypal. And I've use the NVP (Name Value Pair) API. This API returns to your page by calling a query base url which has the authentication token. Of course the codeigniter will pop out a url error message.
Solution:
1.) I've found out that the codeigniter system can be overridden using the hook class.
2.) So first enable hooks in application/config.php
$config['enable_hooks'] = TRUE;
3.) In the hooks documentation codeigniter/general/hooks.html, there are several hook points, we will use the pre_system, because we need to get the $_GET variables before it is read.
4.) In application/config/hooks.php, add the following line:
$hook['pre_system'] = array(
'class' => 'Paypal', //classname
'function' => 'override_get',
'filename' => 'override_get.php',
'filepath' => 'hooks',
'params' => array()
);
5.) Create a file inside, application/hooks named: override_get.php and create the following function:
function override_get() {
if (strlen($_SERVER['QUERY_STRING']) > 0) {
$temp = @array();
parse_str($_SERVER['QUERY_STRING'], $temp);
if (array_key_exists('your_get_variable', $temp)) {
$_POST['your_post_variable'] = $temp['your_get_variable'];
$_SERVER['QUERY_STRING'] = "";
$_SERVER['REDIRECT_QUERY_STRING'] = "";
$_GET = @array();
$url = strpos($_SERVER['REQUEST_URI'], '?');
if ($url > -1) {
$_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $url);
}
}
}
}
-
Web Development
WordpressConfigure Custom Wordpress PermalinkZencartHow to add a customize product admin fields in zencart by editing/adding extra codesJoomlaHow to install/setup/configure joomla to run in a xampp setup. This avoids the technical detail of manually installing...
-
Using In Like Operator In Entity Framework
Entity Framework is a great advancement to sql unfortunately some old keywords are not supported. But reading the documentation and google you will find a lot of work arounds. Like for example in the case of IN operator. Old select * from table where...
-
Flexigrid's On Row Click - How To Implement Rowclick Action Of Flexigrid Using Codeigniter's Library
The objective of this writing is to update the flexigrid library so that it can handle the rowClick event. To do this we need to download the latest version of flexigrid's library here: http://flexigrid.eyeviewdesign.com/, extract and setup accordingly...
-
This Article Explains How To Compare 2 Date Objects In Javascript
The best way to compare 2 Date objects using javascript is to get its long equivalent. For example we have a date in this format: mm-dd-yyyy and we want to compare them. We will declare the javascript function this way: function compareDate(a, b) { var...
-
How To Integrate Securimage Captcha To Codeigniter
Heres how: 1.) Download the open source securimage library from: http://www.phpcaptcha.org/. 2.) Copy the library in your codeigniter's application/library folder. 3.) Create a function in your codeigniter's controller's class (example index)...
Tech-Today