@@ -154,10 +154,10 @@ public function __construct()
154
154
155
155
// let's learn about the request
156
156
$ this ->request = new stdClass ();
157
-
157
+
158
158
// Is it over SSL?
159
159
$ this ->request ->ssl = $ this ->_detect_ssl ();
160
-
160
+
161
161
// How is this request being made? POST, DELETE, GET, PUT?
162
162
$ this ->request ->method = $ this ->_detect_method ();
163
163
@@ -265,9 +265,9 @@ public function _remap($object_called, $arguments)
265
265
// Should we answer if not over SSL?
266
266
if (config_item ('force_https ' ) AND !$ this ->_detect_ssl ())
267
267
{
268
- $ this ->response (array ('status ' => false , 'error ' => 'Unsupported protocol ' ), 403 );
268
+ $ this ->response (array ('status ' => false , 'error ' => 'Unsupported protocol ' ), 403 );
269
269
}
270
-
270
+
271
271
$ pattern = '/^(.*)\.( ' .implode ('| ' , array_keys ($ this ->_supported_formats )).')$/ ' ;
272
272
if (preg_match ($ pattern , $ object_called , $ matches ))
273
273
{
@@ -440,8 +440,8 @@ protected function _detect_ssl()
440
440
{
441
441
return (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] == "on " );
442
442
}
443
-
444
-
443
+
444
+
445
445
/*
446
446
* Detect input format
447
447
*
@@ -614,7 +614,7 @@ protected function _detect_api_key()
614
614
isset ($ row ->user_id ) AND $ this ->rest ->user_id = $ row ->user_id ;
615
615
isset ($ row ->level ) AND $ this ->rest ->level = $ row ->level ;
616
616
isset ($ row ->ignore_limits ) AND $ this ->rest ->ignore_limits = $ row ->ignore_limits ;
617
-
617
+
618
618
/*
619
619
* If "is private key" is enabled, compare the ip address with the list
620
620
* of valid ip addresses stored in the database.
@@ -627,7 +627,7 @@ protected function _detect_api_key()
627
627
// multiple ip addresses must be separated using a comma, explode and loop
628
628
$ list_ip_addresses = explode (", " , $ row ->ip_addresses );
629
629
$ found_address = FALSE ;
630
-
630
+
631
631
foreach ($ list_ip_addresses as $ ip_address )
632
632
{
633
633
if ($ this ->input ->ip_address () == trim ($ ip_address ))
@@ -637,7 +637,7 @@ protected function _detect_api_key()
637
637
break ;
638
638
}
639
639
}
640
-
640
+
641
641
return $ found_address ;
642
642
}
643
643
else
@@ -646,7 +646,7 @@ protected function _detect_api_key()
646
646
return FALSE ;
647
647
}
648
648
}
649
-
649
+
650
650
return $ row ;
651
651
}
652
652
@@ -702,7 +702,7 @@ protected function _log_request($authorized = FALSE)
702
702
return $ this ->rest ->db ->insert (config_item ('rest_logs_table ' ), array (
703
703
'uri ' => $ this ->uri ->uri_string (),
704
704
'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 ,
706
706
'api_key ' => isset ($ this ->rest ->key ) ? $ this ->rest ->key : '' ,
707
707
'ip_address ' => $ this ->input ->ip_address (),
708
708
'time ' => function_exists ('now ' ) ? now () : time (),
0 commit comments