Files
aaPanel/class/safeModel/base.py
T
Jack ed55fa708d Update to 7.7.0
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
2024-07-19 11:25:10 +08:00

92 lines
3.1 KiB
Python

#coding: utf-8
import public,re,time,sys,os
from datetime import datetime
class safeBase:
__isUfw = False
__isFirewalld = False
_months = {'Jan':'01','Feb':'02','Mar':'03','Apr':'04','May':'05','Jun':'06','Jul':'07','Aug':'08','Sep':'09','Sept':'09','Oct':'10','Nov':'11','Dec':'12'}
def __init__(self):
if os.path.exists('/usr/sbin/firewalld'): self.__isFirewalld = True
if os.path.exists('/usr/sbin/ufw'): self.__isUfw = True
#转换时间格式
def to_date(self,date_str):
tmp = re.split(r'\s+',date_str)
if len(tmp) < 3: return date_str
s_date = str(datetime.now().year) + '-' + self._months.get(tmp[0]) + '-' + tmp[1] + ' ' + tmp[2]
time_array = time.strptime(s_date, "%Y-%m-%d %H:%M:%S")
time_stamp = int(time.mktime(time_array))
return time_stamp
def to_date2(self,date_str):
tmp = date_str.split()
if len(tmp) < 4: return date_str
s_date = str(tmp[-1]) + '-' + self._months.get(tmp[1],tmp[1]) + '-' + tmp[2] + ' ' + tmp[3]
return s_date
def to_date3(self,date_str):
tmp = date_str.split()
if len(tmp) < 4: return date_str
s_date = str(datetime.now().year) + '-' + self._months.get(tmp[1],tmp[1]) + '-' + tmp[2] + ' ' + tmp[3]
return s_date
def to_date4(self,date_str):
tmp = date_str.split()
if len(tmp) < 3: return date_str
s_date = str(datetime.now().year) + '-' + self._months.get(tmp[0],tmp[0]) + '-' + tmp[1] + ' ' + tmp[2]
return s_date
#取防火墙状态
def CheckFirewallStatus(self):
if self.__isUfw:
res = public.ExecShell('ufw status verbose')[0]
if res.find('inactive') != -1: return False
return True
if self.__isFirewalld:
res = public.ExecShell("systemctl status firewalld")[0]
if res.find('active (running)') != -1: return True
if res.find('disabled') != -1: return False
if res.find('inactive (dead)') != -1: return False
else:
res = public.ExecShell("/etc/init.d/iptables status")[0]
if res.find('not running') != -1: return False
return True
return False
def get_ssh_log_files(self,get):
"""
获取ssh日志文件
"""
s_key = 'secure'
if not os.path.exists('/var/log/secure'):
s_key = 'auth.log'
if os.path.exists('/var/log/secure') and os.path.getsize('/var/log/secure') == 0:
s_key = 'auth.log'
res = []
spath = '/var/log/'
for fname in os.listdir(spath):
fpath = '{}{}'.format(spath,fname)
if fname.find(s_key) == -1 or fname == s_key:
continue
#debian解压日志
if fname[-3:] in ['.gz','.xz']:
if os.path.exists(fpath[:-3]):
continue
public.ExecShell("gunzip -c " + fpath + " > " + fpath[:-3])
res.append(fpath[:-3])
else:
res.append(fpath)
res = sorted(res,reverse=True)
res.insert(0,spath + s_key)
return res