m`c d dl Z d dlZd dlZd dlmc mc mZ d dl m Z d dlmZ d dl mZ d dlmZmZ d dlmZmZmZ e e ZeegZ G d d Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"dS ) N) getLogger)config) update_config)update_users_protection MyImunify)MU_PLUGIN_INSTALLATIONADVICE_EMAIL_NOTIFICATIONWordPressMuPluginc " e Zd ZdZdZd Zd ZdS ) WhmcsConfz read/write data passed by whmcs Internal use, for commands called from whcms only it saves ALL data came from whcms w/o any validation deliberately in order to simplify compatability with current installed whmcs plugin z/var/imunify360/whmcs_data.jsonc t j | j si S t | j d 5 }| }d d d n# 1 swxY w Y nA# t $ r4}t dt | i cY d }~S d }~ww xY w t j | }n9# t j t f$ r t d| i cY S w xY w|S )Nrz"Failed to read whmcs data file: %sz"Malformed file with whmcs data: %s) ospathexistsopenreadIOErrorloggererrorstrjsonloadsJSONDecodeError ValueError)selffraw_dataedatas P/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/whmcs.pyr zWhmcsConf.read! s= w~~di(( I di%% $6688 $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ LL=s1vvFFFIIIIII :h''DD$j1 LL=xHHHIII sR A* AA* A""A* %A"&A* * B(4)B#B(#B(,C 3C76C7c d | }| | t | j d 5 }t j ||d ddd dS # 1 swxY w Y dS # t $ r3}t dt | Y d}~dS d}~ww xY w)z Saves ALL data passed by WHMCS it should not have any validations deliberately to be as compatible as possible with current installed WHMCS plugin w )indentNz&Failed to write whmcs data to file: %s) r updater r r dumpr r r r )r r current_datafiler s r! savezWhmcsConf.save4 s yy{{D!!! Kdi%% 8 ,Q7777 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 K K KLLA3q66JJJJJJJJJ Ks; A2 A%A2 %A))A2 ,A)-A2 2 B/<(B**B/N)__name__ __module____qualname____doc__r r r* r! r r sH -D &K K K K Kr0 r c p K | t j }t | | d {V S N)getr MY_IMUNIFY_KEY mi_update)sinkr my_imunify_updatess r! sync_billing_datar8 E s> &"7884!3444444444r0 c j | dk r dddd| fS | dk r dddd| fS | dk rd |fS | |fS ) zf Convert several keys to config key, otherwise just return same key any key is acceptable statusenableTF)activeinactive protection)enableddisabledmu_plugin_installationsmart_advice_allowedr/ keyvalues r! convert_to_config_key_valuerF J s h! ! ( ( (%u,,:r0 c V | dk rd|rdndfS | dk rd|rdndfS | dk rd |fS | |fS ) zk Convert several keys from config format, otherwise just return same key any key is acceptable r; r: r<