@@ -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
{
@@ -434,8 +434,8 @@ protected function _detect_ssl()
434
434
{
435
435
return (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] == "on " );
436
436
}
437
-
438
-
437
+
438
+
439
439
/*
440
440
* Detect input format
441
441
*
@@ -608,7 +608,7 @@ protected function _detect_api_key()
608
608
isset ($ row ->user_id ) AND $ this ->rest ->user_id = $ row ->user_id ;
609
609
isset ($ row ->level ) AND $ this ->rest ->level = $ row ->level ;
610
610
isset ($ row ->ignore_limits ) AND $ this ->rest ->ignore_limits = $ row ->ignore_limits ;
611
-
611
+
612
612
/*
613
613
* If "is private key" is enabled, compare the ip address with the list
614
614
* of valid ip addresses stored in the database.
@@ -621,7 +621,7 @@ protected function _detect_api_key()
621
621
// multiple ip addresses must be separated using a comma, explode and loop
622
622
$ list_ip_addresses = explode (", " , $ row ->ip_addresses );
623
623
$ found_address = FALSE ;
624
-
624
+
625
625
foreach ($ list_ip_addresses as $ ip_address )
626
626
{
627
627
if ($ this ->input ->ip_address () == trim ($ ip_address ))
@@ -631,7 +631,7 @@ protected function _detect_api_key()
631
631
break ;
632
632
}
633
633
}
634
-
634
+
635
635
return $ found_address ;
636
636
}
637
637
else
@@ -640,7 +640,7 @@ protected function _detect_api_key()
640
640
return FALSE ;
641
641
}
642
642
}
643
-
643
+
644
644
return $ row ;
645
645
}
646
646
@@ -696,7 +696,7 @@ protected function _log_request($authorized = FALSE)
696
696
return $ this ->rest ->db ->insert (config_item ('rest_logs_table ' ), array (
697
697
'uri ' => $ this ->uri ->uri_string (),
698
698
'method ' => $ this ->request ->method ,
699
- 'params ' => $ this ->_args ? serialize ($ this ->_args ) : null ,
699
+ 'params ' => $ this ->_args ? ( config_item ( ' rest_logs_json_params ' ) ? json_encode ( $ this -> _args ) : serialize ($ this ->_args ) ) : null ,
700
700
'api_key ' => isset ($ this ->rest ->key ) ? $ this ->rest ->key : '' ,
701
701
'ip_address ' => $ this ->input ->ip_address (),
702
702
'time ' => function_exists ('now ' ) ? now () : time (),
0 commit comments