Browse Source

feat: add chinese support

pull/1/head
Dnomd343 3 years ago
parent
commit
2b6662d7e2
  1. BIN
      backend/country.db
  2. 26
      backend/getCountry.php
  3. 3
      backend/getInfo.php

BIN
backend/country.db

Binary file not shown.

26
backend/getCountry.php

@ -0,0 +1,26 @@
<?php
$db_path = 'country.db';
$db = new SQLiteDB;
class SQLiteDB extends SQLite3 {
function __construct() {
global $db_path;
$this->open($db_path);
}
}
function get_country($code) {
global $db;
if ($code == null) {
return null;
}
$dat = $db->query('SELECT * FROM main WHERE alpha_2="'.$code.'";')->fetchArray(SQLITE3_ASSOC);
if ($dat) {
$name_dat['en'] = $code." - ".$dat['name_en'];
$name_dat['cn'] = $dat['name_cn'];//."(".$dat['location'].")";
} else {
$name_dat['en'] = $code." - Unknow";
$name_dat['cn'] = null;
}
return $name_dat;
}

3
backend/getInfo.php

@ -1,5 +1,7 @@
<?php
include("getCountry.php");
function getIPInfo($ip, $is_cli) {
$specialIpInfo = getSpecialIpInfo($ip);
if (is_string($specialIpInfo)) {
@ -22,6 +24,7 @@ function getIPInfo($ip, $is_cli) {
$info['timezone'] = $rawIspInfo['timezone'];
$info['loc'] = $rawIspInfo['loc'];
$info['isp'] = getIsp($rawIspInfo);
$info['country'] .= "(".get_country($rawIspInfo['country'])['cn'].")";
}
if ($is_cli == true) {

Loading…
Cancel
Save