@@ -32,7 +32,7 @@ class Database {
3232 *
3333 * @var string
3434 */
35- const VERSION = '1.0 .0 ' ;
35+ const VERSION = '1.1 .0 ' ;
3636
3737 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3838 // Error field constants ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1147,22 +1147,12 @@ private function binSearch($version, $ipNumber) {
11471147 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11481148
11491149 /**
1150- * Get the database's compilation date as a string of the form 'YYYY-MM-DD'
1151- *
1152- * @access public
1153- * @return string
1154- */
1155- public function getDate () {
1156- return $ this ->date ;
1157- }
1158-
1159- /**
1160- * Get the database's type (1-4)
1150+ * Get the database's package (1-4)
11611151 *
11621152 * @access public
11631153 * @return int
11641154 */
1165- public function getType () {
1155+ public function getPackageVersion () {
11661156 return $ this ->type + 1 ;
11671157 }
11681158
@@ -1203,6 +1193,62 @@ public function getDatabaseVersion() {
12031193 return $ this ->year . '. ' . $ this ->month . '. ' . $ this ->day ;
12041194 }
12051195
1196+ /**
1197+ * Return -1, 0, 1, 2
1198+ */
1199+ public function isProxy ($ ip ) {
1200+ return self ::lookup ($ ip , self ::IS_PROXY );
1201+ }
1202+
1203+ /*
1204+ * Return string
1205+ */
1206+ public function getCountryShort ($ ip ) {
1207+ return self ::lookup ($ ip , self ::COUNTRY_CODE );
1208+ }
1209+
1210+ /*
1211+ * Return string
1212+ */
1213+ public function getCountryLong ($ ip ) {
1214+ return self ::lookup ($ ip , self ::COUNTRY_NAME );
1215+ }
1216+
1217+ /*
1218+ * Return string
1219+ */
1220+ public function getRegion ($ ip ) {
1221+ return self ::lookup ($ ip , self ::REGION_NAME );
1222+ }
1223+
1224+ /*
1225+ * Return string
1226+ */
1227+ public function getCity ($ ip ) {
1228+ return self ::lookup ($ ip , self ::CITY_NAME );
1229+ }
1230+
1231+ /*
1232+ * Return string
1233+ */
1234+ public function getISP ($ ip ) {
1235+ return self ::lookup ($ ip , self ::ISP );
1236+ }
1237+
1238+ /*
1239+ * Return string
1240+ */
1241+ public function getProxyType ($ ip ) {
1242+ return self ::lookup ($ ip , self ::PROXY_TYPE );
1243+ }
1244+
1245+ /*
1246+ * Return array
1247+ */
1248+ public function getAll ($ ip ) {
1249+ return self ::lookup ($ ip , self ::ALL );
1250+ }
1251+
12061252 /**
12071253 * This function will look the given IP address up in the database and return the result(s) asked for
12081254 *
@@ -1211,13 +1257,13 @@ public function getDatabaseVersion() {
12111257 * array whith the returned singular field names as keys and their corresponding
12121258 * values is returned.
12131259 *
1214- * @access public
1260+ * @access protected
12151261 * @param string $ip IP address to look up
12161262 * @param int|array $fields Field(s) to return
12171263 * @param boolean $asNamed Whether to return an associative array instead
12181264 * @return mixed|array|boolean
12191265 */
1220- public function lookup ($ ip , $ fields = null , $ asNamed = true ) {
1266+ protected function lookup ($ ip , $ fields = null , $ asNamed = true ) {
12211267 // extract IP version and number
12221268 list ($ ipVersion , $ ipNumber ) = self ::ipVersionAndNumber ($ ip );
12231269 // perform the binary search proper (if the IP address was invalid, binSearch will return false)
0 commit comments