diff --git a/app/db_model.py b/app/db_model.py index ba6de13f..505eb551 100644 --- a/app/db_model.py +++ b/app/db_model.py @@ -484,10 +484,21 @@ class Services(BaseModel): constraints = [SQL('UNIQUE (service_id, service)')] +class UserName(BaseModel): + UserName = CharField(null=True) + Status = IntegerField(constraints=[SQL('DEFAULT 0')]) + Plan = CharField(null=True) + Method = CharField(null=True) + + class Meta: + table_name = 'user_name' + primary_key = False + + def create_tables(): with conn: conn.create_tables([User, Server, Role, Telegram, Slack, UUID, Token, ApiToken, Groups, UserGroups, ConfigVersion, Setting, Cred, Backup, Metrics, WafMetrics, Version, Option, SavedServer, Waf, ActionHistory, PortScannerSettings, PortScannerPorts, PortScannerHistory, ProvidersCreds, ServiceSetting, ProvisionedServers, MetricsHttpStatus, SMON, WafRules, Alerts, GeoipCodes, NginxMetrics, - SystemInfo, Services]) + SystemInfo, Services, UserName]) diff --git a/app/funct.py b/app/funct.py index b758e047..5dfcd430 100644 --- a/app/funct.py +++ b/app/funct.py @@ -1528,7 +1528,8 @@ def check_new_version(**kwargs): res = response.content.decode(encoding='UTF-8') try: status = response_status.content.decode(encoding='UTF-8') - sql.update_user_status(status) + status = status.split(' ') + sql.update_user_status(status[0], status[1].strip(), status[2].strip()) except: pass except requests.exceptions.RequestException as e: diff --git a/app/options.py b/app/options.py index ef2a3aa2..a9f0ac32 100644 --- a/app/options.py +++ b/app/options.py @@ -807,6 +807,11 @@ if serv is not None and act == "stats": haproxy_pass = sql.get_setting('nginx_stats_password') stats_port = sql.get_setting('nginx_stats_port') stats_page = sql.get_setting('nginx_stats_page') + elif form.getvalue('service') == 'apache': + haproxy_user = sql.get_setting('apache_stats_user') + haproxy_pass = sql.get_setting('apache_stats_password') + stats_port = sql.get_setting('apache_stats_port') + stats_page = sql.get_setting('apache_stats_page') else: haproxy_user = sql.get_setting('stats_user') haproxy_pass = sql.get_setting('stats_password') @@ -4166,3 +4171,11 @@ if act == 'check_service': print('down') except Exception: print('down') + +if form.getvalue('show_sub_ovw'): + from jinja2 import Environment, FileSystemLoader + + env = Environment(loader=FileSystemLoader('templates/'), autoescape=True) + template = env.get_template('ajax/show_sub_ovw.html') + template = template.render(sub=sql.select_user_all()) + print(template) \ No newline at end of file diff --git a/app/sql.py b/app/sql.py index d46cfdb9..9dd5ce20 100755 --- a/app/sql.py +++ b/app/sql.py @@ -3148,8 +3148,7 @@ def insert_user_name(user_name): def select_user_name(): try: query_res = UserName.get().UserName - except Exception as e: - out_error(e) + except Exception: return False else: return query_res @@ -3166,12 +3165,11 @@ def update_user_name(user_name): return True -def update_user_status(status): - user_update = UserName.update(Status=status) +def update_user_status(status, plan, method): + user_update = UserName.update(Status=status, Method=method, Plan=plan) try: user_update.execute() - except Exception as e: - out_error(e) + except Exception: return False else: return True @@ -3180,8 +3178,16 @@ def update_user_status(status): def select_user_status(): try: query_res = UserName.get().Status - except Exception as e: - out_error(e) + except Exception: + return False + else: + return query_res + + +def select_user_all(): + try: + query_res = UserName.select() + except Exception: return False else: return query_res diff --git a/app/templates/ajax/show_sub_ovw.html b/app/templates/ajax/show_sub_ovw.html new file mode 100644 index 00000000..e9490022 --- /dev/null +++ b/app/templates/ajax/show_sub_ovw.html @@ -0,0 +1,42 @@ +{% for s in sub %} + {% if s.Plan == 'user' %} + {% set plan = 'Home' %} + {% elif s.Plan == 'company' %} + {% set plan = 'Enterprise' %} + {% elif s.Plan == 'support' %} + {% set plan = 'Premium' %} + {% else %} + {% set plan = 'Free' %} + {% endif %} + + Subscription plan + {{plan}} + + + Subscription status + + {% if plan == 'Free' %} + N/A + {% else %} + Active + {% else %} + style="color: var(--red-color); font-weight: bold">Blocked + {% endif %} + + {% endif %} + + + + Pay method + + + {% if plan == 'Free' %} + N/A + {% else %} + {{s.Method}} + {% endif %} + + +{% endfor %} \ No newline at end of file diff --git a/app/templates/ovw.html b/app/templates/ovw.html index f200641a..2e71d4b3 100644 --- a/app/templates/ovw.html +++ b/app/templates/ovw.html @@ -429,7 +429,16 @@ {% endfor %} - +{% endif %} +{% if role <= 1 %} + + + + + +
+ Subscription +
{% endif %}