File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 168168 `key` varchar(40) NOT NULL,
169169 `level` int(2) NOT NULL,
170170 `ignore_limits` tinyint(1) NOT NULL DEFAULT '0',
171+ `is_private_key` tinyint(1) NOT NULL DEFAULT '0',
172+ `ip_addresses` TEXT NULL DEFAULT NULL,
171173 `date_created` int(11) NOT NULL,
172174 PRIMARY KEY (`id`)
173175 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Original file line number Diff line number Diff line change @@ -432,7 +432,7 @@ public function response($data = array(), $http_code = null)
432432 */
433433 protected function _detect_ssl ()
434434 {
435- return (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] == "on " )) ;
435+ return (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] == "on " );
436436 }
437437
438438
@@ -608,6 +608,38 @@ protected function _detect_api_key()
608608 isset ($ row ->user_id ) AND $ this ->rest ->user_id = $ row ->user_id ;
609609 isset ($ row ->level ) AND $ this ->rest ->level = $ row ->level ;
610610 isset ($ row ->ignore_limits ) AND $ this ->rest ->ignore_limits = $ row ->ignore_limits ;
611+
612+ /*
613+ * If "is private key" is enabled, compare the ip address with the list
614+ * of valid ip addresses stored in the database.
615+ */
616+ if (!empty ($ row ->is_private_key ))
617+ {
618+ // Check for a list of valid ip addresses
619+ if (isset ($ row ->ip_addresses ))
620+ {
621+ // multiple ip addresses must be separated using a comma, explode and loop
622+ $ list_ip_addresses = explode (", " , $ row ->ip_addresses );
623+ $ found_address = FALSE ;
624+
625+ foreach ($ list_ip_addresses as $ ip_address )
626+ {
627+ if ($ this ->input ->ip_address () == trim ($ ip_address ))
628+ {
629+ // there is a match, set the the value to true and break out of the loop
630+ $ found_address = TRUE ;
631+ break ;
632+ }
633+ }
634+
635+ return $ found_address ;
636+ }
637+ else
638+ {
639+ // There should be at least one IP address for this private key.
640+ return FALSE ;
641+ }
642+ }
611643
612644 return $ this ->client ;
613645 }
You can’t perform that action at this time.
0 commit comments