Add analytics
[bus.git] / busui / owa / modules / maxmind_geoip / includes / maxmind-ws / GeoCityLocateIspOrg.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
 
  require_once( "MaxMindWebServices.class.php" );
 
  /**
   * Geo City Locate W/ ISP and Organization information
   *
   * @access    public
   * @author    Nathan White < contact at nathanwhite dot us >
   *
   */
  class GeoCityLocateIspOrg extends MaxMindWebServices {
        
        /**
         * Implements a singleton design pattern
     *
     * when looking for an instance one can pass an IP address to have data populated
     *
     * @access  public
     * @param   string
     * @return  reference to a GeoCityLocateIspOrg object
         */
        function &getInstance($ip = "") {
        static $instance = null;
 
        if ($instance === null) {
            $instance = new GeoCityLocateIspOrg();
        }
 
                if(!empty($ip)){
            $instance->setIP($ip);
                }
 
        return $instance;
    }
 
        /**
         * An array that holds all returned values from a Maxmind request
     *
     * @param   string
     * @access  public
         */
        function setIP($ip){
                $this->data = array();
                $this->ip = $ip;
                $this->_process();
        }
    
        /**
         * Get the IP address that is being processed
     *
     * @return  string
     * @access  public
         */
        function getIP(){
                return $this->ip;
        }
 
        /**
         * Get the return Country Code
     *
     * @return  string
     * @access  public
         */
        function getCountryCode(){
                return $this->data[0];
        }
 
        /**
         * Get the return Region Code
     *
     * @return  string
     * @access  public
         */
        function getRegion(){
                return $this->data[1];
        }
    
        /**
         * Get the return Region Code
     *
     * @return  string
     * @access  public
         */
    function getState(){
      return $this->getRegion();
    }
 
        /**
         * Get the return City
     *
     * @return  string
     * @access  public
         */
        function getCity(){
                return $this->data[2];
        }
 
        /**
         * Get the return Postal
     *
     * @return  string
     * @access  public
         */
        function getPostal(){
                return $this->data[3];
        }
    
        /**
         * Get the return Postal
     *
     * @return  string
     * @access  public
         */
        function getZip(){
                return $this->getPostal();
        }
 
        /**
         * Get the return Latitude
     *
     * @return  string
     * @access  public
         */
        function getLatitude(){
                return $this->data[4];
        }
    
        /**
         * Get the return Latitude
     *
     * @return  string
     * @access  public
         */
        function getLat(){
                return $this->getLatitude();
        }
 
        /**
         * Get the return Longitude
     *
     * @return  string
     * @access  public
         */
        function getLongitude(){
                return $this->data[5];
        }
 
        /**
         * Get the return Longitude
     *
     * @return  string
     * @access  public
         */
        function getLong(){
                return $this->getLongitude();
        }
 
        /**
         * Get the return Metro Code
     *
     * @return  string
     * @access  public
         */
        function getMetroCode(){
                return $this->data[6];
        }
 
        /**
         * Get the return Area Code
     *
     * @return  string
     * @access  public
         */
        function getAreaCode(){
                return $this->data[7];
        }
 
        /**
         * Get the return ISP
     *
     * @return  string
     * @access  public
         */
        function getISP(){
                return $this->data[8];
        }
 
        /**
         * Get the return Organization
     *
     * @return  string
     * @access  public
         */
        function getOrganization(){
                return $this->data[9];
        }
 
        /**
         * Get the return Error
     *
     * @return  string
     * @access  public
         */
        function getError(){
        return $this->data[10];
        
        }
        
        /**
         * Formats the url to submit to Maxmind and returns data in an array
     *
     * @access private
         */
        function _process(){
          $url = "http://maxmind.com:8010/f?l=" . $this->licenceKey . "&i=" . $this->ip;
          $response = $this->_queryMaxMind($url);
          $this->data = $this->csv_split( trim($response) );
        }
    
    
  }
  
?>