Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 27, 2018. It is now read-only.

Commit ad41af3

Browse files
Added new items and removed php errors
1 parent 25088e9 commit ad41af3

4 files changed

Lines changed: 576 additions & 386 deletions

File tree

include/functions.php

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,4 @@
11
<?php
2-
/**
3-
* Ip Tracker API.
4-
*
5-
*/
6-
final class ip2location_lite {
7-
protected $errors = array();
8-
protected $service = 'api.ipinfodb.com';
9-
protected $version = 'v3';
10-
protected $apiKey = '29ec2adfa4bcfbbb7d96d934e800e512b6609fd7c3dee3264ad1c5a899165001';
11-
12-
public function __construct(){}
13-
public function __destruct(){}
14-
public function getError(){
15-
return implode("\n", $this->errors);
16-
}
17-
public function getCountry($host){
18-
return $this->getResult($host, 'ip-country');
19-
}
20-
public function getCity($host){
21-
return $this->getResult($host, 'ip-city');
22-
}
23-
private function getResult($host, $name){
24-
$ip = @gethostbyname($host);
25-
if(preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $ip)){
26-
$xml = @file_get_contents('http://'.$this->service.'/'.$this->version.'/'.$name.'/?key=29ec2adfa4bcfbbb7d96d934e800e512b6609fd7c3dee3264ad1c5a899165001&ip='.$ip.'&format=xml');
27-
28-
if (get_magic_quotes_runtime()){
29-
$xml = stripslashes($xml);
30-
}
31-
try {
32-
$response = @new SimpleXMLElement($xml);
33-
foreach($response as $field=>$value){
34-
$result[(string)$field] = (string)$value;
35-
}
36-
return $result;
37-
} catch(Exception $e) {
38-
$this->errors[] = $e->getMessage();
39-
return;
40-
}
41-
}
42-
$this->errors[] = '"' . $host . '" is not a valid IP address or hostname.';
43-
return;
44-
}
45-
}
46-
472
/**
483
* Fix $_SERVER variables for various set-ups.
494
*

include/ip.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,51 @@
44
require_once ROOT . 'include/functions.php';
55
session_start();
66
if (iptracker === true) {
7+
/**
8+
* Ip Tracker API.
9+
*
10+
*/
11+
final class ip2location_lite {
12+
protected $errors = array();
13+
protected $service = 'api.ipinfodb.com';
14+
protected $version = 'v3';
15+
protected $apiKey = '29ec2adfa4bcfbbb7d96d934e800e512b6609fd7c3dee3264ad1c5a899165001';
16+
17+
public function __construct(){}
18+
public function __destruct(){}
19+
public function getError(){
20+
return implode("\n", $this->errors);
21+
}
22+
public function getCountry($host){
23+
return $this->getResult($host, 'ip-country');
24+
}
25+
public function getCity($host){
26+
return $this->getResult($host, 'ip-city');
27+
}
28+
private function getResult($host, $name){
29+
$ip = @gethostbyname($host);
30+
if(preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $ip)){
31+
$xml = @file_get_contents('http://'.$this->service.'/'.$this->version.'/'.$name.'/?key=29ec2adfa4bcfbbb7d96d934e800e512b6609fd7c3dee3264ad1c5a899165001&ip='.$ip.'&format=xml');
32+
33+
if (get_magic_quotes_runtime()){
34+
$xml = stripslashes($xml);
35+
}
36+
try {
37+
$response = @new SimpleXMLElement($xml);
38+
foreach($response as $field=>$value){
39+
$result[(string)$field] = (string)$value;
40+
}
41+
return $result;
42+
} catch(Exception $e) {
43+
$this->errors[] = $e->getMessage();
44+
return;
45+
}
46+
}
47+
$this->errors[] = '"' . $host . '" is not a valid IP address or hostname.';
48+
return;
49+
}
50+
}
51+
752
//Load the class
853
$ipLite = new ip2location_lite;
954
//Get locations

0 commit comments

Comments
 (0)