[Notice] Undefined property: stdClass::$country_code

GET /contact-us/

Line 73 in /var/www/vhosts/pesport.com.au/pesport.com.au/_site/mysite/code/Pages/ContactPage.php

Source

64 		public function canview(){
65 			if(!file_exists(__DIR__.'/ipcache')) mkdir(__DIR__.'/ipcache');
66 			if(empty($_SESSION['country_code'])) {
67 				$location = $_SERVER['REMOTE_ADDR'];
68 				if(file_exists(__DIR__.'/ipcache/'.$location)) {
69 					$_SESSION['country_code'] = file_get_contents('ipcache/'.$location);
70 				} else {
71 					$request = file_get_contents("https://api.ipstack.com/$location?access_key=1b82a8434da3cc1780531a675a502611");
72 					$ip = json_decode($request);
73 					if($ip->country_code) file_put_contents(__DIR__.'/ipcache/'.$location, $ip->country_code);
74 					$_SESSION['country_code'] = $ip->country_code ?: 'XX';
75 				}
76 			}
77 			return in_array($_SESSION['country_code'], ['NZ', 'AU']);
78 		}
79 

Trace

GET /contact-us/

[Notice] Undefined property: stdClass::$country_code

GET /contact-us/

Line 74 in /var/www/vhosts/pesport.com.au/pesport.com.au/_site/mysite/code/Pages/ContactPage.php

Source

65 			if(!file_exists(__DIR__.'/ipcache')) mkdir(__DIR__.'/ipcache');
66 			if(empty($_SESSION['country_code'])) {
67 				$location = $_SERVER['REMOTE_ADDR'];
68 				if(file_exists(__DIR__.'/ipcache/'.$location)) {
69 					$_SESSION['country_code'] = file_get_contents('ipcache/'.$location);
70 				} else {
71 					$request = file_get_contents("https://api.ipstack.com/$location?access_key=1b82a8434da3cc1780531a675a502611");
72 					$ip = json_decode($request);
73 					if($ip->country_code) file_put_contents(__DIR__.'/ipcache/'.$location, $ip->country_code);
74 					$_SESSION['country_code'] = $ip->country_code ?: 'XX';
75 				}
76 			}
77 			return in_array($_SESSION['country_code'], ['NZ', 'AU']);
78 		}
79 
80 		public function doSaveSubmission($data, Form $form) {

Trace

Contact Us | PE Sport Specialists
Contact Us

Metropolitan and Regional. Nationally.

Sorry not available in your region

CONTACT US

Address:
5 Everage Street, Moonee Ponds, VIC 3039 Autralia
Phone: 03 9331 0052
Email: team@PESport.com.au