Post by straightlight » Wed Oct 18, 2017 10:11 am

For Opencart v3.0.2.0 release, I have integrated a little addon which was originally found from WeChat in:

- system/storage/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Tools.php file in order to filter the IP address . The most relevant location to where these types of verifications should be made would be on the:

- catalog/controller/api/login.php file.

Find:

Code: Select all

if (!in_array($this->request->server['REMOTE_ADDR'], $ip_data)) {
replace with:

Code: Select all

if (!in_array($this->getIpAddress(), $ip_data)) {
Then, find the last:

Code: Select all

}
at the end of the file. Then, add above - not below:

Code: Select all

protected function getIpAddress() {
        foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP', 'REMOTE_ADDR') as $header) {
            if (!isset($this->request->server[$header]) || ($spoof = $this->request->server[$header]) === NULL) {
                continue;
            }
			
            sscanf($spoof, '%[^,]', $spoof);
			
            if (!filter_var($spoof, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
                $spoof = NULL;
            } else {
                return $spoof;
            }
        }
		
        return '0.0.0.0';
    }

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 7 guests