mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-08-17 21:25:47 +02:00
Since version 7.7.0, we recommend yours update python to 3.12. [+] Using nginx technology to load static files improves access speed [+] Refactor homepage, website, FTP, and database using vue3 [+] Table loading changed to skeleton screen [+] Add Website statistics-v2 professional plug-in [+] Add Home page - top 5 resource occupancy [+] Add protection for Files management (requires Tamper-proof for Enterprise 3.7) [+] Website, FTP, Databases page add program status [+] Add FTP log analysis (only supports Centos) [+] Add password-free login to phpMyAdmin [+] Add Proxy Project in Website (Supported when web service uses Nginx) [+] Add WP Toolkit (Pro version only) [+] Redesigned Docker module [+] Add WP Toolkit Protection [+] Add WP Toolkit Backup and Restore [+] Add WP Toolkit Migrated [+] Add WP Toolkit Clone site (supports new domain and subdomain) [+] Add WP Toolkit Create site from backup of other panel [+] Add WP Toolkit support for Cron automatic backup (only save Local disk) [+] Add WP Toolkit operation log [+] Add Integrity check for WP Toolkit [+] Add WP Toolkit plug-in management and themes management [*] Optimize phpMyAdmin formula access method [*] Optimize Home page PHP display problem [*] Optimize jump to the login interface after the login expires [*] Optimize automatic renewal of SSL at some times [*] Optimize Let's Encrypt to increase application success rate [-] Fix Logs Audit cannot be opened [-] Fix apache URL rewrite issue [-] Fix phpmyadmin installation problem [-] Fix the problem that some servers cannot install software [-] Fix upload file error [-] Fix left menu hiding problem [-] Fix aaPanel Mobile QR code display problem [-] Fix problem that third-party plug-ins are not displayed in the App Store [-] Fix issue where the menu bar is blank when opening new tabs [-] Fixed panel not being accessible in some cases [-] Fix the issue where Curl warning caused the inability to apply for SSL [-] Fix Quota issues for Website, FTP, Databases [-] Fix file interface display problem on mobile terminal
97 lines
3.0 KiB
Python
97 lines
3.0 KiB
Python
#coding: utf-8
|
|
#-------------------------------------------------------------------
|
|
# aaPanel
|
|
#-------------------------------------------------------------------
|
|
# Copyright (c) 2015-2099 aaPanel(www.aapanel.com) All rights reserved.
|
|
#-------------------------------------------------------------------
|
|
# Author: cjxin <cjxin@aapanel.com>
|
|
#-------------------------------------------------------------------
|
|
|
|
# 免费IP库
|
|
#------------------------------
|
|
import os,re,json,time
|
|
from safeModel.base import safeBase
|
|
import public
|
|
|
|
|
|
class main(safeBase):
|
|
_sfile = '{}/data/free_ip_area.json'.format(public.get_panel_path())
|
|
|
|
def __init__(self):
|
|
try:
|
|
self.user_info = public.get_user_info()
|
|
except:
|
|
self.user_info = None
|
|
|
|
def get_ip_area(self,get):
|
|
"""
|
|
@获取IP地址所在地
|
|
@param get: dict/array
|
|
"""
|
|
ips = get['ips']
|
|
arrs,result = [],{}
|
|
for ip in ips:arrs.append(ip)
|
|
if len(arrs) > 0:
|
|
data = self.__get_cloud_ip_info(arrs)
|
|
for ip in data:
|
|
result[ip] = data[ip]
|
|
return result
|
|
|
|
|
|
def __get_cloud_ip_info(self,ips):
|
|
"""
|
|
@获取IP地址所在地
|
|
@得判断是否是我们的用户
|
|
@param ips:
|
|
"""
|
|
result = {}
|
|
try:
|
|
'''
|
|
@从云端获取IP地址所在地
|
|
@param data 是否是宝塔用户,如果不是则不返回
|
|
@param ips: IP地址
|
|
'''
|
|
data = {}
|
|
data['ip'] = ','.join(ips)
|
|
data['uid'] = self.user_info['uid']
|
|
data["serverid"]=self.user_info["serverid"]
|
|
#如果不是我们的用户,那么不返回数据
|
|
res = public.httpPost('https://www.bt.cn/api/ip/info',data)
|
|
res = json.loads(res)
|
|
data = self.get_ip_area_cache()
|
|
for key in res:
|
|
info = res[key]
|
|
if public.is_local_ip(key):
|
|
res[key]['city']="Intranet"
|
|
if not res[key]['city']: continue
|
|
if not res[key]['city'].strip() and not res[key]['continent'].strip():
|
|
info = {'info':'Unknown IP'}
|
|
else:
|
|
info['info'] = '{} {} {} {}'.format(info['carrier'],info['country'],info['province'],info['city']).strip()
|
|
data[key] = info
|
|
result[key] = info
|
|
self.set_ip_area_cache(data)
|
|
except:
|
|
pass
|
|
return result
|
|
|
|
|
|
def get_ip_area_cache(self):
|
|
"""
|
|
@获取IP地址所在地
|
|
@param get:
|
|
"""
|
|
data = {}
|
|
try:
|
|
data = json.loads(public.readFile(self._sfile))
|
|
except:
|
|
public.writeFile(self._sfile,json.dumps({}))
|
|
return data
|
|
|
|
def set_ip_area_cache(self,data):
|
|
"""
|
|
@设置IP地址所在地
|
|
@param data:
|
|
"""
|
|
public.writeFile(self._sfile,json.dumps(data))
|
|
return True |