g DdZddlZddlZddlmZmZGddZdS)u  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.  If not, see . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see N)PIPE check_outputceZdZdZdZdZeddedefdZedZ ed Z ed Z ed Z ed Z d S)PleskSdkzPHP wrapper for Plesk SDK)pleskphpz-rzf require_once("sdk.php"); pm_Context::init("revisium-antivirus"); {}; Trreturnc |j|}dt dd|D}|rt jdd|}|S)zW Append a piece of code to the header and make it a single-line string Nc3>K|]}|VdS)N)strip).0lines S/opt/imunify360/venv/lib/python3.11/site-packages/imav/migration_utils/plesk_sdk.py z!PleskSdk._join../s*!M!M4$**,,!M!M!M!M!M!Mz(\W)\s+|\s+(\W)z\1\2)_phpformatr joinfilter splitlinesresub)clsrstrip_whitespacescoders r_joinzPleskSdk._join)st xsyy{{++ GGF4!M!M4??;L;L!M!M!MNN O O  7)7A66Arcrg|j|||R}t|tdS)NT)stderrtext)_cmdrrr)rrargscmds rexecz PleskSdk.exec4s:00#))C..0400C48888rc,|dS)Nzecho pm_Context::getVarDir())r%)rs rcontext__get_var_dirzPleskSdk.context__get_var_dir9sxx6777rcT|d|tj|S)Nz)echo pm_Settings::get($argv[1], $argv[2]))r%jsondumps)rkeydefaults r settings__getzPleskSdk.settings__get=s+xx 7  Jw     rc`d}tj||}|r|niS)NaK echo json_encode( array_map( function ($domain) { $props = [ "id" => "getId", "name" => "getName", "document_root" => "getDocumentRoot", "owner" => "getSysUserLogin" ]; $result = (object)[]; foreach ($props as $property => $method) { try { $result->{$property} = $domain->{$method}(); } catch (Throwable $ignored) {} } return $result; }, pm_Domain::getAllDomains() ) ); r)loadsr%)rrdomainss rdomain__get_all_domainsz PleskSdk.domain__get_all_domainsEs5,*SXXc]]++")wwr)rc^d||fz}tj||S)zz For getting permissions status for domain e.g: domain__has_permission('1', 'ra_cleanup_allowed') zy $domain = pm_Domain::getByDomainId(%s); echo json_encode($domain->hasPermission("%s")); r/)r domain_id permissionrs rdomain__has_permissionzPleskSdk.domain__has_permissionbs7      z#((3--(((rN)T)__name__ __module__ __qualname____doc__r"r classmethodstrrr%r'r-r2r6rrrrs## D  D [99[988[8  [ **[*8 ) )[ ) ) )rr)r:r)r subprocessrrrr=rrr?sw* ))))))))T)T)T)T)T)T)T)T)T)T)r