@@ -154,10 +154,10 @@ public function __construct()
154154
155155 // let's learn about the request
156156 $ this ->request = new stdClass ();
157-
157+
158158 // Is it over SSL?
159159 $ this ->request ->ssl = $ this ->_detect_ssl ();
160-
160+
161161 // How is this request being made? POST, DELETE, GET, PUT?
162162 $ this ->request ->method = $ this ->_detect_method ();
163163
@@ -265,9 +265,9 @@ public function _remap($object_called, $arguments)
265265 // Should we answer if not over SSL?
266266 if (config_item ('force_https ' ) AND !$ this ->_detect_ssl ())
267267 {
268- $ this ->response (array ('status ' => false , 'error ' => 'Unsupported protocol ' ), 403 );
268+ $ this ->response (array ('status ' => false , 'error ' => 'Unsupported protocol ' ), 403 );
269269 }
270-
270+
271271 $ pattern = '/^(.*)\.( ' .implode ('| ' , array_keys ($ this ->_supported_formats )).')$/ ' ;
272272 if (preg_match ($ pattern , $ object_called , $ matches ))
273273 {
@@ -440,8 +440,8 @@ protected function _detect_ssl()
440440 {
441441 return (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] == "on " );
442442 }
443-
444-
443+
444+
445445 /*
446446 * Detect input format
447447 *
@@ -614,7 +614,7 @@ protected function _detect_api_key()
614614 isset ($ row ->user_id ) AND $ this ->rest ->user_id = $ row ->user_id ;
615615 isset ($ row ->level ) AND $ this ->rest ->level = $ row ->level ;
616616 isset ($ row ->ignore_limits ) AND $ this ->rest ->ignore_limits = $ row ->ignore_limits ;
617-
617+
618618 /*
619619 * If "is private key" is enabled, compare the ip address with the list
620620 * of valid ip addresses stored in the database.
@@ -627,7 +627,7 @@ protected function _detect_api_key()
627627 // multiple ip addresses must be separated using a comma, explode and loop
628628 $ list_ip_addresses = explode (", " , $ row ->ip_addresses );
629629 $ found_address = FALSE ;
630-
630+
631631 foreach ($ list_ip_addresses as $ ip_address )
632632 {
633633 if ($ this ->input ->ip_address () == trim ($ ip_address ))
@@ -637,7 +637,7 @@ protected function _detect_api_key()
637637 break ;
638638 }
639639 }
640-
640+
641641 return $ found_address ;
642642 }
643643 else
@@ -646,7 +646,7 @@ protected function _detect_api_key()
646646 return FALSE ;
647647 }
648648 }
649-
649+
650650 return $ row ;
651651 }
652652
@@ -702,7 +702,7 @@ protected function _log_request($authorized = FALSE)
702702 return $ this ->rest ->db ->insert (config_item ('rest_logs_table ' ), array (
703703 'uri ' => $ this ->uri ->uri_string (),
704704 'method ' => $ this ->request ->method ,
705- 'params ' => $ this ->_args ? serialize ($ this ->_args ) : null ,
705+ 'params ' => $ this ->_args ? ( config_item ( ' rest_logs_json_params ' ) ? json_encode ( $ this -> _args ) : serialize ($ this ->_args ) ) : null ,
706706 'api_key ' => isset ($ this ->rest ->key ) ? $ this ->rest ->key : '' ,
707707 'ip_address ' => $ this ->input ->ip_address (),
708708 'time ' => function_exists ('now ' ) ? now () : time (),
0 commit comments