This commit is contained in:
cutemeli
2025-12-22 10:35:30 +00:00
parent 0bfc6c8425
commit 5ce7ca2c5d
38927 changed files with 0 additions and 4594700 deletions

View File

@@ -1,25 +0,0 @@
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitPleskExtFirewall::getLoader();

View File

@@ -1,585 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var ?string */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
private $apcuPrefix;
/**
* @var self[]
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return string[]
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return string[] Array of classname => path
* @psalm-return array<string, string>
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View File

@@ -1,352 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*
* @final
*/
class InstalledVersions
{
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool|null
*/
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static $installedByVendor = array();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
*/
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
$installed[] = self::$installed;
return $installed;
}
}

View File

@@ -1,21 +0,0 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -1,10 +0,0 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname(dirname($vendorDir)));
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
);

View File

@@ -1,9 +0,0 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname(dirname($vendorDir)));
return array(
);

View File

@@ -1,11 +0,0 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname(dirname($vendorDir)));
return array(
'PleskX\\' => array($vendorDir . '/plesk/api-php-lib/src'),
'PleskExt\\Firewall\\' => array($baseDir . '/modules/firewall/library', $baseDir . '/src/plib/library'),
);

View File

@@ -1,38 +0,0 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitPleskExtFirewall
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitPleskExtFirewall', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitPleskExtFirewall', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitPleskExtFirewall::getInitializer($loader));
$loader->register(true);
return $loader;
}
}

View File

@@ -1,42 +0,0 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitPleskExtFirewall
{
public static $prefixLengthsPsr4 = array (
'P' =>
array (
'PleskX\\' => 7,
'PleskExt\\Firewall\\' => 18,
),
);
public static $prefixDirsPsr4 = array (
'PleskX\\' =>
array (
0 => __DIR__ . '/..' . '/plesk/api-php-lib/src',
),
'PleskExt\\Firewall\\' =>
array (
0 => __DIR__ . '/../../../..' . '/modules/firewall/library',
1 => __DIR__ . '/../../../..' . '/src/plib/library',
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitPleskExtFirewall::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitPleskExtFirewall::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitPleskExtFirewall::$classMap;
}, null, ClassLoader::class);
}
}

View File

@@ -1,68 +0,0 @@
{
"packages": [
{
"name": "plesk/api-php-lib",
"version": "v2.2.1",
"version_normalized": "2.2.1.0",
"source": {
"type": "git",
"url": "https://github.com/plesk/api-php-lib.git",
"reference": "2ceece815106b8997319bcc62fe79d5fe095c65f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/plesk/api-php-lib/zipball/2ceece815106b8997319bcc62fe79d5fe095c65f",
"reference": "2ceece815106b8997319bcc62fe79d5fe095c65f",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-dom": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9",
"spatie/phpunit-watcher": "^1.22",
"squizlabs/php_codesniffer": "^3.6",
"vimeo/psalm": "^4.10 || ^5.0"
},
"time": "2025-04-04T10:05:51+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"PleskX\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Alexei Yuzhakov",
"email": "sibprogrammer@gmail.com"
},
{
"name": "WebPros International GmbH.",
"email": "plesk-dev-leads@plesk.com"
}
],
"description": "PHP object-oriented library for Plesk XML-RPC API",
"support": {
"issues": "https://github.com/plesk/api-php-lib/issues",
"source": "https://github.com/plesk/api-php-lib/tree/v2.2.1"
},
"install-path": "../plesk/api-php-lib"
}
],
"dev": false,
"dev-package-names": []
}

View File

@@ -1,32 +0,0 @@
<?php return array(
'root' => array(
'name' => 'plesk/ext-firewall',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '688f3d526257bf1f5f42c1cca826e03849fb1bec',
'type' => 'library',
'install_path' => __DIR__ . '/../../../../',
'aliases' => array(),
'dev' => false,
),
'versions' => array(
'plesk/api-php-lib' => array(
'pretty_version' => 'v2.2.1',
'version' => '2.2.1.0',
'reference' => '2ceece815106b8997319bcc62fe79d5fe095c65f',
'type' => 'library',
'install_path' => __DIR__ . '/../plesk/api-php-lib',
'aliases' => array(),
'dev_requirement' => false,
),
'plesk/ext-firewall' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '688f3d526257bf1f5f42c1cca826e03849fb1bec',
'type' => 'library',
'install_path' => __DIR__ . '/../../../../',
'aliases' => array(),
'dev_requirement' => false,
),
),
);

View File

@@ -1,26 +0,0 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 80000)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

View File

@@ -1,9 +0,0 @@
FROM php:8.2-cli
RUN apt-get update \
&& apt-get install -y unzip \
&& docker-php-ext-install pcntl \
&& pecl install xdebug \
&& echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

View File

@@ -1,13 +0,0 @@
Copyright 1999-2025. WebPros International GmbH.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,67 +0,0 @@
## PHP library for Plesk XML-RPC API
[![Test Status](https://github.com/plesk/api-php-lib/actions/workflows/test.yml/badge.svg)](https://github.com/plesk/api-php-lib/actions/workflows/test.yml)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/plesk/api-php-lib/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/plesk/api-php-lib/?branch=master)
[![codecov](https://codecov.io/gh/plesk/api-php-lib/branch/master/graph/badge.svg?token=5Kwbddpdeb)](https://codecov.io/gh/plesk/api-php-lib)
PHP object-oriented library for Plesk XML-RPC API.
## Install Via Composer
[Composer](https://getcomposer.org/) is a preferable way to install the library:
`composer require plesk/api-php-lib`
## Usage Examples
Here is an example on how to use the library and create a customer with desired properties:
```php
$client = new \PleskX\Api\Client($host);
$client->setCredentials($login, $password);
$client->customer()->create([
'cname' => 'Plesk',
'pname' => 'John Smith',
'login' => 'john',
'passwd' => 'secret',
'email' => 'john@smith.com',
]);
```
It is possible to use a secret key instead of password for authentication.
```php
$client = new \PleskX\Api\Client($host);
$client->setSecretKey($secretKey)
```
In case of Plesk extension creation one can use an internal mechanism to access XML-RPC API. It does not require to pass authentication because the extension works in the context of Plesk.
```php
$client = new \PleskX\Api\InternalClient();
$protocols = $client->server()->getProtos();
```
For additional examples see tests/ directory.
## How to Run Unit Tests
One the possible ways to become familiar with the library is to check the unit tests.
To run the unit tests use the following command:
`REMOTE_HOST=your-plesk-host.dom REMOTE_PASSWORD=password composer test`
To use custom port one can provide a URL (e.g. for Docker container):
`REMOTE_URL=https://your-plesk-host.dom:port REMOTE_PASSWORD=password composer test`
One more way to run tests is to use Docker:
`docker-compose run tests`
## Continuous Testing
During active development it could be more convenient to run tests in continuous manner. Here is the way how to achieve it:
`REMOTE_URL=https://your-plesk-host.dom:port REMOTE_PASSWORD=password composer test:watch`

View File

@@ -1,58 +0,0 @@
{
"name": "plesk/api-php-lib",
"type": "library",
"description": "PHP object-oriented library for Plesk XML-RPC API",
"license": "Apache-2.0",
"authors": [
{
"name": "Alexei Yuzhakov",
"email": "sibprogrammer@gmail.com"
},
{
"name": "WebPros International GmbH.",
"email": "plesk-dev-leads@plesk.com"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-curl": "*",
"ext-xml": "*",
"ext-simplexml": "*",
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "^9",
"spatie/phpunit-watcher": "^1.22",
"vimeo/psalm": "^4.10 || ^5.0",
"squizlabs/php_codesniffer": "^3.6"
},
"config": {
"process-timeout": 0,
"platform": {
"php": "7.4.27"
}
},
"scripts": {
"test": "phpunit",
"test:watch": "phpunit-watcher watch",
"lint": [
"psalm",
"phpcs"
]
},
"autoload": {
"psr-4": {
"PleskX\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PleskXTest\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +0,0 @@
# Copyright 1999-2025. WebPros International GmbH.
version: '3'
services:
plesk:
image: plesk/plesk:latest
logging:
driver: none
ports:
["8443:8443"]
tmpfs:
- /tmp
- /run
- /run/lock
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup
cgroup: host
tests:
build: .
environment:
REMOTE_URL: https://plesk:8443
REMOTE_PASSWORD: changeme1Q**
command: >
bash -c "cd /opt/api-php-lib
&& composer install
&& ./wait-for-plesk.sh
&& composer lint
&& composer test -- --testdox"
depends_on:
- plesk
links:
- plesk
volumes:
- .:/opt/api-php-lib

View File

@@ -1,28 +0,0 @@
<?xml version="1.0"?>
<!-- Copyright 1999-2025. WebPros International GmbH. -->
<ruleset name="PHP library for Plesk XML-RPC API">
<file>src</file>
<file>tests</file>
<rule ref="Generic">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
<exclude name="Generic.Files.EndFileNoNewline"/>
<exclude name="Generic.Files.LowercasedFilename.NotFound"/>
<exclude name="Generic.PHP.RequireStrictTypes"/>
<exclude name="Generic.PHP.ClosingPHPTag"/>
<exclude name="Generic.PHP.UpperCaseConstant"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="Generic.Classes.OpeningBraceSameLine"/>
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<exclude name="Generic.Formatting.MultipleStatementAlignment"/>
<exclude name="Generic.Formatting.NoSpaceAfterCast"/>
<exclude name="Generic.Formatting.SpaceBeforeCast"/>
<exclude name="Generic.Formatting.SpaceAfterNot"/>
<exclude name="Generic.Commenting.DocComment"/>
<exclude name="Generic.ControlStructures.DisallowYodaConditions"/>
</rule>
<rule ref="PSR1"/>
<rule ref="PSR2"/>
<rule ref="PSR12">
<exclude name="PSR12.Files.FileHeader"/>
</rule>
</ruleset>

View File

@@ -1,4 +0,0 @@
# Copyright 1999-2025. WebPros International GmbH.
phpunit:
arguments: '--stop-on-failure'
timeout: 0

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 1999-2025. WebPros International GmbH. -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" verbose="true" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<clover outputFile="coverage.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="E2E">
<directory>./tests</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="-1"/>
<env name="REMOTE_URL" value=""/>
<env name="REMOTE_PASSWORD" value=""/>
</php>
<logging/>
</phpunit>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0"?>
<!-- Copyright 1999-2025. WebPros International GmbH. -->
<psalm
errorLevel="3"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<PropertyNotSetInConstructor errorLevel="suppress" />
<UndefinedPropertyFetch errorLevel="suppress" />
</issueHandlers>
</psalm>

View File

@@ -1,76 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
abstract class AbstractStruct
{
/**
* @param string $property
* @param mixed $value
*
* @throws \Exception
*/
public function __set(string $property, $value)
{
throw new \Exception("Try to set an undeclared property '$property' to a value: $value.");
}
/**
* Initialize list of scalar properties by response.
*
* @param \SimpleXMLElement $apiResponse
* @param array $properties
*
* @throws \Exception
*/
protected function initScalarProperties(\SimpleXMLElement $apiResponse, array $properties): void
{
foreach ($properties as $property) {
if (is_array($property)) {
$classPropertyName = current($property);
$value = $apiResponse->{key($property)};
} else {
/** @psalm-suppress PossiblyInvalidArgument */
$classPropertyName = $this->underToCamel(str_replace('-', '_', $property));
$value = $apiResponse->$property;
}
$reflectionProperty = new \ReflectionProperty($this, $classPropertyName);
$propertyType = $reflectionProperty->getType();
if (is_null($propertyType)) {
$docBlock = $reflectionProperty->getDocComment();
$propertyType = preg_replace('/^.+ @var ([a-z]+) .+$/', '\1', $docBlock);
} else {
/** @psalm-suppress UndefinedMethod */
$propertyType = $propertyType->getName();
}
if ('string' == $propertyType) {
$value = (string) $value;
} elseif ('int' == $propertyType) {
$value = (int) $value;
} elseif ('bool' == $propertyType) {
$value = in_array((string) $value, ['true', 'on', 'enabled']);
} else {
throw new \Exception("Unknown property type '$propertyType'.");
}
$this->$classPropertyName = $value;
}
}
/**
* Convert underscore separated words into camel case.
*
* @param string $under
*
* @return string
*/
private function underToCamel(string $under): string
{
$under = '_' . str_replace('_', ' ', strtolower($under));
return ltrim(str_replace(' ', '', ucwords($under)), '_');
}
}

View File

@@ -1,577 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
use DOMDocument;
use SimpleXMLElement;
/**
* Client for Plesk XML-RPC API.
*/
class Client
{
public const RESPONSE_SHORT = 1;
public const RESPONSE_FULL = 2;
private string $host;
private int $port;
private string $protocol;
protected string $login = '';
private string $password = '';
private string $proxy = '';
private string $secretKey = '';
private string $version = '';
protected array $operatorsCache = [];
/**
* @var callable|null
*/
protected $verifyResponseCallback;
/**
* Create client.
*
* @param string $host
* @param int $port
* @param string $protocol
*/
public function __construct(string $host, int $port = 8443, string $protocol = 'https')
{
$this->host = $host;
$this->port = $port;
$this->protocol = $protocol;
}
/**
* Setup credentials for authentication.
*
* @param string $login
* @param string $password
*/
public function setCredentials(string $login, string $password): void
{
$this->login = $login;
$this->password = $password;
}
/**
* Define secret key for alternative authentication.
*
* @param string $secretKey
*/
public function setSecretKey(string $secretKey): void
{
$this->secretKey = $secretKey;
}
/**
* Set proxy server for requests.
*
* @param string $proxy
*/
public function setProxy(string $proxy): void
{
$this->proxy = $proxy;
}
/**
* Set default version for requests.
*
* @param string $version
*/
public function setVersion(string $version): void
{
$this->version = $version;
}
/**
* Set custom function to verify response of API call according your own needs.
* Default verifying will be used if it is not specified.
*
* @param callable|null $function
*/
public function setVerifyResponse(?callable $function = null): void
{
$this->verifyResponseCallback = $function;
}
/**
* Retrieve host used for communication.
*
* @return string
*/
public function getHost(): string
{
return $this->host;
}
/**
* Retrieve port used for communication.
*
* @return int
*/
public function getPort(): int
{
return $this->port;
}
/**
* Retrieve name of the protocol (http or https) used for communication.
*
* @return string
*/
public function getProtocol(): string
{
return $this->protocol;
}
/**
* Retrieve XML template for packet.
*
* @param string|null $version
*
* @return SimpleXMLElement
*/
public function getPacket($version = null): SimpleXMLElement
{
$protocolVersion = !is_null($version) ? $version : $this->version;
$content = "<?xml version='1.0' encoding='UTF-8' ?>";
$content .= '<packet' . ('' === $protocolVersion ? '' : " version='$protocolVersion'") . '/>';
return new SimpleXMLElement($content);
}
/**
* Perform API request.
*
* @param string|array|SimpleXMLElement $request
* @param int $mode
*
* @return XmlResponse
* @throws \Exception
*/
public function request($request, int $mode = self::RESPONSE_SHORT): XmlResponse
{
if ($request instanceof SimpleXMLElement) {
$request = $request->asXml();
} else {
$xml = $this->getPacket();
if (is_array($request)) {
$request = $this->arrayToXml($request, $xml)->asXML();
} elseif (preg_match('/^[a-z]/', $request)) {
$request = $this->expandRequestShortSyntax($request, $xml);
}
}
if ('sdk' == $this->protocol) {
$xml = $this->performSdkCall((string) $request);
} else {
$xml = $this->performHttpRequest((string) $request);
}
$this->verifyResponseCallback
? call_user_func($this->verifyResponseCallback, $xml)
: $this->verifyResponse($xml);
$result = (self::RESPONSE_FULL === $mode)
? $xml
: ($xml->xpath('//result') ?: [null])[0];
return new XmlResponse($result ? (string) $result->asXML() : '');
}
private function performSdkCall(string $request): XmlResponse
{
$version = ('' == $this->version) ? null : $this->version;
$requestXml = new SimpleXMLElement($request);
$innerNodes = $requestXml->children();
$innerXml = $innerNodes && count($innerNodes) > 0 && $innerNodes[0] ? $innerNodes[0]->asXml() : '';
/** @psalm-suppress UndefinedClass */
$result = \pm_ApiRpc::getService($version)->call($innerXml, $this->login);
return new XmlResponse($result ? (string) $result->asXML() : '');
}
/**
* Perform HTTP request to end-point.
*
* @param string $request
*
* @throws Client\Exception
*
* @return XmlResponse
*/
private function performHttpRequest($request)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "$this->protocol://$this->host:$this->port/enterprise/control/agent.php");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->getHeaders());
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
if ('' !== $this->proxy) {
curl_setopt($curl, CURLOPT_PROXY, $this->proxy);
}
$result = curl_exec($curl);
if (false === $result) {
throw new Client\Exception(curl_error($curl), curl_errno($curl));
}
curl_close($curl);
return new XmlResponse((string) $result);
}
/**
* Perform multiple API requests using single HTTP request.
*
* @param array $requests
* @param int $mode
*
* @throws Client\Exception
*
* @return array
*/
public function multiRequest(array $requests, int $mode = self::RESPONSE_SHORT): array
{
$requestXml = $this->getPacket();
foreach ($requests as $request) {
if ($request instanceof SimpleXMLElement) {
throw new Client\Exception('SimpleXML type of request is not supported for multi requests.');
} else {
if (is_array($request)) {
$request = $this->arrayToXml($request, $requestXml)->asXML();
if (!$request) {
throw new Client\Exception('Failed to create an XML string for request');
}
} elseif (preg_match('/^[a-z]/', $request)) {
$this->expandRequestShortSyntax($request, $requestXml);
}
}
}
if ('sdk' == $this->protocol) {
throw new Client\Exception('Multi requests are not supported via SDK.');
} else {
$xmlString = $requestXml->asXML();
if (!$xmlString) {
throw new Client\Exception('Failed to create an XML string for request');
}
$responseXml = $this->performHttpRequest($xmlString);
}
return $this->splitResponseToArray($responseXml, $mode);
}
private function splitResponseToArray(XmlResponse $responseXml, $mode = self::RESPONSE_SHORT): array
{
$responses = [];
$nodes = $responseXml->children();
if (!$nodes) {
return [];
}
foreach ($nodes as $childNode) {
$dom = $this->getDomDocument($this->getPacket());
if (!$dom) {
continue;
}
$childDomNode = dom_import_simplexml($childNode);
if (!is_null($childDomNode)) {
$childDomNode = $dom->importNode($childDomNode, true);
$dom->documentElement->appendChild($childDomNode);
}
$response = simplexml_load_string($dom->saveXML());
if (!$response) {
return [];
}
$responses[] = (self::RESPONSE_FULL == $mode)
? $response
: ($response->xpath('//result') ?: [null])[0];
}
return $responses;
}
private function getDomDocument(SimpleXMLElement $xml): ?DOMDocument
{
$dom = dom_import_simplexml($xml);
if (is_null($dom)) {
return null;
}
return $dom->ownerDocument;
}
/**
* Retrieve list of headers needed for request.
*
* @return array
*/
private function getHeaders()
{
$headers = [
'Content-Type: text/xml',
'HTTP_PRETTY_PRINT: TRUE',
];
if ($this->secretKey) {
$headers[] = "KEY: $this->secretKey";
} else {
$headers[] = "HTTP_AUTH_LOGIN: $this->login";
$headers[] = "HTTP_AUTH_PASSWD: $this->password";
}
return $headers;
}
/**
* Verify that response does not contain errors.
*
* @param XmlResponse $xml
*
* @throws Exception
*/
private function verifyResponse($xml): void
{
if ($xml->system && $xml->system->status && 'error' == (string) $xml->system->status) {
throw new Exception((string) $xml->system->errtext, (int) $xml->system->errcode);
}
if ($xml->xpath('//status[text()="error"]') && $xml->xpath('//errcode') && $xml->xpath('//errtext')) {
$errorCode = (int) ($xml->xpath('//errcode') ?: [null])[0];
$errorMessage = (string) ($xml->xpath('//errtext') ?: [null])[0];
throw new Exception($errorMessage, $errorCode);
}
}
/**
* Expand short syntax (some.method.call) into full XML representation.
*
* @param string $request
* @param SimpleXMLElement $xml
*
* @return false|string
*/
private function expandRequestShortSyntax($request, SimpleXMLElement $xml)
{
$parts = explode('.', $request);
$node = $xml;
$lastParts = end($parts);
foreach ($parts as $part) {
// phpcs:ignore
@list($name, $value) = explode('=', $part);
if ($part !== $lastParts) {
$node = $node->addChild($name);
} else {
$node->{$name} = (string) $value;
}
}
return $xml->asXML();
}
/**
* Convert array to XML representation.
*
* @param array $array
* @param SimpleXMLElement $xml
* @param string $parentEl
*
* @return SimpleXMLElement
*/
private function arrayToXml(array $array, SimpleXMLElement $xml, $parentEl = null)
{
foreach ($array as $key => $value) {
$el = is_int($key) && $parentEl ? $parentEl : $key;
if (is_array($value)) {
$this->arrayToXml($value, $this->isAssocArray($value) ? $xml->addChild($el) : $xml, $el);
} elseif (!isset($xml->{$el})) {
$xml->{$el} = (string) $value;
} else {
$xml->{$el}[] = (string) $value;
}
}
return $xml;
}
/**
* @param array $array
*
* @return bool
*/
private function isAssocArray(array $array)
{
return $array && array_keys($array) !== range(0, count($array) - 1);
}
/**
* @param string $name
*
* @return mixed
*/
private function getOperator(string $name)
{
if (!isset($this->operatorsCache[$name])) {
$className = '\\PleskX\\Api\\Operator\\' . $name;
/** @psalm-suppress InvalidStringClass */
$this->operatorsCache[$name] = new $className($this);
}
return $this->operatorsCache[$name];
}
public function server(): Operator\Server
{
return $this->getOperator('Server');
}
public function customer(): Operator\Customer
{
return $this->getOperator('Customer');
}
public function webspace(): Operator\Webspace
{
return $this->getOperator('Webspace');
}
public function subdomain(): Operator\Subdomain
{
return $this->getOperator('Subdomain');
}
public function dns(): Operator\Dns
{
return $this->getOperator('Dns');
}
public function dnsTemplate(): Operator\DnsTemplate
{
return $this->getOperator('DnsTemplate');
}
public function databaseServer(): Operator\DatabaseServer
{
return $this->getOperator('DatabaseServer');
}
public function mail(): Operator\Mail
{
return $this->getOperator('Mail');
}
public function certificate(): Operator\Certificate
{
return $this->getOperator('Certificate');
}
public function siteAlias(): Operator\SiteAlias
{
return $this->getOperator('SiteAlias');
}
public function ip(): Operator\Ip
{
return $this->getOperator('Ip');
}
public function eventLog(): Operator\EventLog
{
return $this->getOperator('EventLog');
}
public function secretKey(): Operator\SecretKey
{
return $this->getOperator('SecretKey');
}
public function ui(): Operator\Ui
{
return $this->getOperator('Ui');
}
public function servicePlan(): Operator\ServicePlan
{
return $this->getOperator('ServicePlan');
}
public function virtualDirectory(): Operator\VirtualDirectory
{
return $this->getOperator('VirtualDirectory');
}
public function database(): Operator\Database
{
return $this->getOperator('Database');
}
public function session(): Operator\Session
{
return $this->getOperator('Session');
}
public function locale(): Operator\Locale
{
return $this->getOperator('Locale');
}
public function logRotation(): Operator\LogRotation
{
return $this->getOperator('LogRotation');
}
public function protectedDirectory(): Operator\ProtectedDirectory
{
return $this->getOperator('ProtectedDirectory');
}
public function reseller(): Operator\Reseller
{
return $this->getOperator('Reseller');
}
public function resellerPlan(): Operator\ResellerPlan
{
return $this->getOperator('ResellerPlan');
}
public function aps(): Operator\Aps
{
return $this->getOperator('Aps');
}
public function servicePlanAddon(): Operator\ServicePlanAddon
{
return $this->getOperator('ServicePlanAddon');
}
public function site(): Operator\Site
{
return $this->getOperator('Site');
}
public function phpHandler(): Operator\PhpHandler
{
return $this->getOperator('PhpHandler');
}
}

View File

@@ -1,11 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Client;
/**
* Transport layer exception.
*/
class Exception extends \Exception
{
}

View File

@@ -1,11 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
/**
* Exceptions for XML-RPC API client.
*/
class Exception extends \Exception
{
}

View File

@@ -1,25 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
/**
* Internal client for Plesk XML-RPC API (via SDK).
*/
class InternalClient extends Client
{
public function __construct()
{
parent::__construct('localhost', 0, 'sdk');
}
/**
* Setup login to execute requests under certain user.
*
* @param string $login
*/
public function setLogin(string $login): void
{
$this->login = $login;
}
}

View File

@@ -1,106 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api;
class Operator
{
protected string $wrapperTag = '';
protected Client $client;
public function __construct(Client $client)
{
$this->client = $client;
if ('' === $this->wrapperTag) {
$classNameParts = explode('\\', get_class($this));
$this->wrapperTag = end($classNameParts);
$this->wrapperTag = strtolower(preg_replace('/([a-z])([A-Z])/', '\1-\2', $this->wrapperTag));
}
}
/**
* Perform plain API request.
*
* @param string|array $request
* @param int $mode
*
* @return XmlResponse
*/
public function request($request, $mode = Client::RESPONSE_SHORT): XmlResponse
{
$wrapperTag = $this->wrapperTag;
if (is_array($request)) {
$request = [$wrapperTag => $request];
} elseif (preg_match('/^[a-z]/', $request)) {
$request = "$wrapperTag.$request";
} else {
$request = "<$wrapperTag>$request</$wrapperTag>";
}
return $this->client->request($request, $mode);
}
/**
* @param string $field
* @param int|string $value
* @param string $deleteMethodName
*
* @return bool
*/
protected function deleteBy(string $field, $value, string $deleteMethodName = 'del'): bool
{
$response = $this->request([
$deleteMethodName => [
'filter' => [
$field => $value,
],
],
]);
return 'ok' === (string) $response->status;
}
/**
* @param string $structClass
* @param string $infoTag
* @param string|null $field
* @param int|string|null $value
* @param callable|null $filter
*
* @return array
*/
protected function getItems($structClass, $infoTag, $field = null, $value = null, ?callable $filter = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$getTag->addChild('dataset')->addChild($infoTag);
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || !isset($xmlResult->data) || !isset($xmlResult->data->$infoTag)) {
continue;
}
if (!is_null($filter) && !$filter($xmlResult->data->$infoTag)) {
continue;
}
/** @psalm-suppress InvalidStringClass */
$item = new $structClass($xmlResult->data->$infoTag);
if (isset($xmlResult->id) && property_exists($item, 'id')) {
$item->id = (int) $xmlResult->id;
}
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,8 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class Aps extends \PleskX\Api\Operator
{
}

View File

@@ -1,87 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Certificate as Struct;
class Certificate extends \PleskX\Api\Operator
{
public function generate(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('generate')->addChild('info');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param array $properties
* @param string|Struct\Info $certificate
* @param string|null $privateKey
*/
public function install(array $properties, $certificate, ?string $privateKey = null): bool
{
return $this->callApi('install', $properties, $certificate, $privateKey);
}
/**
* @param array $properties
* @param Struct\Info $certificate
*/
public function update(array $properties, Struct\Info $certificate): bool
{
return $this->callApi('update', $properties, $certificate);
}
/**
* @param string $method
* @param array $properties
* @param string|Struct\Info $certificate
* @param string|null $privateKey
*/
private function callApi(string $method, array $properties, $certificate, ?string $privateKey = null): bool
{
$packet = $this->client->getPacket();
$installTag = $packet->addChild($this->wrapperTag)->addChild($method);
foreach ($properties as $name => $value) {
$installTag->{$name} = $value;
}
$contentTag = $installTag->addChild('content');
if (is_string($certificate)) {
$contentTag->addChild('csr', $certificate);
$contentTag->addChild('pvt', $privateKey);
} elseif ($certificate instanceof \PleskX\Api\Struct\Certificate\Info) {
foreach ($certificate->getMapping() as $name => $value) {
$contentTag->{$name} = $value;
}
}
$result = $this->client->request($packet);
return 'ok' == (string) $result->status;
}
public function delete(string $name, array $properties): bool
{
$packet = $this->client->getPacket();
$removeTag = $packet->addChild($this->wrapperTag)->addChild('remove');
$removeTag->addChild('filter')->addChild('name', $name);
foreach ($properties as $name => $value) {
$removeTag->{$name} = $value;
}
$result = $this->client->request($packet);
return 'ok' == (string) $result->status;
}
}

View File

@@ -1,99 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Customer as Struct;
class Customer extends \PleskX\Api\Operator
{
public function create(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add')->addChild('gen_info');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value): Struct\GeneralInfo
{
$items = $this->getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
return reset($items);
}
/**
* @return Struct\GeneralInfo[]
*/
public function getAll(): array
{
return $this->getItems(Struct\GeneralInfo::class, 'gen_info');
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function enable(string $field, $value): bool
{
return $this->setProperties($field, $value, ['status' => 0]);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function disable(string $field, $value): bool
{
return $this->setProperties($field, $value, ['status' => 16]);
}
/**
* @param string $field
* @param int|string $value
* @param array $properties
*
* @return bool
*/
public function setProperties(string $field, $value, array $properties): bool
{
$packet = $this->client->getPacket();
$setTag = $packet->addChild($this->wrapperTag)->addChild('set');
$setTag->addChild('filter')->addChild($field, (string) $value);
$genInfoTag = $setTag->addChild('values')->addChild('gen_info');
foreach ($properties as $property => $propertyValue) {
$genInfoTag->addChild($property, (string) $propertyValue);
}
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,149 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Database as Struct;
use PleskX\Api\XmlResponse;
class Database extends \PleskX\Api\Operator
{
public function create(array $properties): Struct\Info
{
return new Struct\Info($this->process('add-db', $properties));
}
public function createUser(array $properties): Struct\UserInfo
{
return new Struct\UserInfo($this->process('add-db-user', $properties));
}
private function process(string $command, array $properties): XmlResponse
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild($command);
foreach ($properties as $name => $value) {
if (false !== strpos($value, '&')) {
$info->$name = $value;
continue;
}
$info->{$name} = $value;
}
return $this->client->request($packet);
}
public function updateUser(array $properties): bool
{
$response = $this->process('set-db-user', $properties);
return 'ok' === (string) $response->status;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value): Struct\Info
{
$items = $this->getAll($field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\UserInfo
*/
public function getUser(string $field, $value): Struct\UserInfo
{
$items = $this->getAllUsers($field, $value);
return reset($items);
}
/**
* @param string|null $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll(?string $field, $value): array
{
$response = $this->getBy('get-db', $field, $value);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = new Struct\Info($xmlResult);
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\UserInfo[]
*/
public function getAllUsers(string $field, $value): array
{
$response = $this->getBy('get-db-users', $field, $value);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = new Struct\UserInfo($xmlResult);
}
}
return $items;
}
/**
* @param string $command
* @param string|null $field
* @param int|string $value
*
* @return XmlResponse
*/
private function getBy(string $command, ?string $field, $value): XmlResponse
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild($command);
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->{$field} = (string) $value;
}
return $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value, 'del-db');
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function deleteUser(string $field, $value): bool
{
return $this->deleteBy($field, $value, 'del-db-user');
}
}

View File

@@ -1,85 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\DatabaseServer as Struct;
class DatabaseServer extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'db_server';
public function getSupportedTypes(): array
{
$response = $this->request('get-supported-types');
return (array) $response->type;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value): Struct\Info
{
$items = $this->getBy($field, $value);
return reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll(): array
{
return $this->getBy();
}
public function getDefault(string $type): Struct\Info
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get-default');
$filterTag = $getTag->addChild('filter');
/** @psalm-suppress UndefinedPropertyAssignment */
$filterTag->type = $type;
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Struct\Info[]
*/
private function getBy($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}
return $items;
}
}

View File

@@ -1,132 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Dns as Struct;
class Dns extends \PleskX\Api\Operator
{
public function create(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add_rec');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
return new Struct\Info($this->client->request($packet));
}
/**
* Send multiply records by one request.
*
* @param array $records
*
* @return \SimpleXMLElement[]
*/
public function bulkCreate(array $records): array
{
$packet = $this->client->getPacket();
foreach ($records as $properties) {
$info = $packet->addChild($this->wrapperTag)->addChild('add_rec');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = $xmlResult;
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value): Struct\Info
{
$items = $this->getAll($field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll(string $field, $value): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_rec');
$filterTag = $getTag->addChild('filter');
$filterTag->addChild($field, (string) $value);
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value, 'del_rec');
}
/**
* Delete multiply records by one request.
*
* @param array $recordIds
*
* @return \SimpleXMLElement[]
*/
public function bulkDelete(array $recordIds): array
{
$packet = $this->client->getPacket();
foreach ($recordIds as $recordId) {
$packet->addChild($this->wrapperTag)->addChild('del_rec')
->addChild('filter')->addChild('id', $recordId);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
$items[] = $xmlResult;
}
}
return $items;
}
}

View File

@@ -1,93 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Dns as Struct;
class DnsTemplate extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'dns';
/**
* @param array $properties
*
* @return Struct\Info
*/
public function create(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add_rec');
unset($properties['site-id'], $properties['site-alias-id']);
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
return new Struct\Info($this->client->request($packet));
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value): Struct\Info
{
$items = $this->getAll($field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_rec');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$getTag->addChild('template');
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}
return $items;
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
$packet = $this->client->getPacket();
$delTag = $packet->addChild($this->wrapperTag)->addChild('del_rec');
$delTag->addChild('filter')->addChild($field, (string) $value);
$delTag->addChild('template');
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,46 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\EventLog as Struct;
class EventLog extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'event_log';
/**
* @return Struct\Event[]
*/
public function get(): array
{
$records = [];
$response = $this->request('get');
foreach ($response->event ?? [] as $eventInfo) {
$records[] = new Struct\Event($eventInfo);
}
return $records;
}
/**
* @return Struct\DetailedEvent[]
*/
public function getDetailedLog(): array
{
$records = [];
$response = $this->request('get_events');
foreach ($response->event ?? [] as $eventInfo) {
$records[] = new Struct\DetailedEvent($eventInfo);
}
return $records;
}
public function getLastId(): int
{
return (int) $this->request('get-last-id')->getValue('id');
}
}

View File

@@ -1,26 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Ip as Struct;
class Ip extends \PleskX\Api\Operator
{
/**
* @return Struct\Info[]
*/
public function get(): array
{
$ips = [];
$packet = $this->client->getPacket();
$packet->addChild($this->wrapperTag)->addChild('get');
$response = $this->client->request($packet);
foreach ($response->addresses->ip_info ?? [] as $ipInfo) {
$ips[] = new Struct\Info($ipInfo);
}
return $ips;
}
}

View File

@@ -1,35 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Locale as Struct;
class Locale extends \PleskX\Api\Operator
{
/**
* @param string|null $id
*
* @return Struct\Info|Struct\Info[]
*/
public function get($id = null)
{
$locales = [];
$packet = $this->client->getPacket();
$filter = $packet->addChild($this->wrapperTag)->addChild('get')->addChild('filter');
if (!is_null($id)) {
$filter->addChild('id', $id);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
foreach ($response->locale->get->result ?? [] as $localeInfo) {
if (!is_null($localeInfo->info)) {
$locales[(string) $localeInfo->info->id] = new Struct\Info($localeInfo->info);
}
}
return !is_null($id) ? reset($locales) : $locales;
}
}

View File

@@ -1,8 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class LogRotation extends \PleskX\Api\Operator
{
}

View File

@@ -1,91 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Client;
use PleskX\Api\Operator;
use PleskX\Api\Struct\Mail as Struct;
class Mail extends Operator
{
public function create(string $name, int $siteId, bool $mailbox = false, string $password = ''): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('create');
$filter = $info->addChild('filter');
$filter->addChild('site-id', (string) $siteId);
$mailname = $filter->addChild('mailname');
$mailname->addChild('name', $name);
if ($mailbox) {
$mailname->addChild('mailbox')->addChild('enabled', 'true');
}
if (!empty($password)) {
/** @psalm-suppress UndefinedPropertyAssignment */
$mailname->addChild('password')->value = $password;
}
$response = $this->client->request($packet);
/** @psalm-suppress PossiblyNullArgument */
return new Struct\Info($response->mailname);
}
/**
* @param string $field
* @param int|string $value
* @param int $siteId
*
* @return bool
*/
public function delete(string $field, $value, int $siteId): bool
{
$packet = $this->client->getPacket();
$filter = $packet->addChild($this->wrapperTag)->addChild('remove')->addChild('filter');
$filter->addChild('site-id', (string) $siteId);
$filter->{$field} = (string) $value;
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
public function get(string $name, int $siteId): Struct\GeneralInfo
{
$items = $this->getAll($siteId, $name);
return reset($items);
}
/**
* @param int $siteId
* @param string|null $name
*
* @return Struct\GeneralInfo[]
*/
public function getAll(int $siteId, $name = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_info');
$filterTag = $getTag->addChild('filter');
$filterTag->addChild('site-id', (string) $siteId);
if (!is_null($name)) {
$filterTag->addChild('name', $name);
}
$response = $this->client->request($packet, Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || !isset($xmlResult->mailname)) {
continue;
}
$item = new Struct\GeneralInfo($xmlResult->mailname);
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,62 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Client;
use PleskX\Api\Operator;
use PleskX\Api\Struct\PhpHandler\Info;
class PhpHandler extends Operator
{
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Info
*/
public function get($field = null, $value = null): ?Info
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, Client::RESPONSE_FULL);
$xmlResult = ($response->xpath('//result') ?: [null])[0];
return $xmlResult ? new Info($xmlResult) : null;
}
/**
* @param string|null $field
* @param int|string $value
*
* @return Info[]
*/
public function getAll($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$item = new Info($xmlResult);
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,118 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Client;
use PleskX\Api\Operator;
use PleskX\Api\Struct\ProtectedDirectory as Struct;
class ProtectedDirectory extends Operator
{
protected string $wrapperTag = 'protected-dir';
public function add(string $name, int $siteId, string $header = ''): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
$info->addChild('site-id', (string) $siteId);
$info->addChild('name', $name);
$info->addChild('header', $header);
return new Struct\Info($this->client->request($packet));
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value, 'delete');
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\DataInfo
*/
public function get(string $field, $value): Struct\DataInfo
{
$items = $this->getAll($field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\DataInfo[]
*/
public function getAll(string $field, $value): array
{
$response = $this->getBy('get', $field, $value);
$items = [];
foreach ((array) $response->xpath('//result/data') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$items[] = new Struct\DataInfo($xmlResult);
}
return $items;
}
/**
* @param Struct\Info $protectedDirectory
* @param string $login
* @param string $password
*
* @return Struct\UserInfo
* @psalm-suppress UndefinedPropertyAssignment
*/
public function addUser($protectedDirectory, $login, $password)
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add-user');
$info->{'pd-id'} = (string) $protectedDirectory->id;
$info->login = $login;
$info->password = $password;
return new Struct\UserInfo($this->client->request($packet));
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function deleteUser($field, $value)
{
return $this->deleteBy($field, $value, 'delete-user');
}
/**
* @param string $command
* @param string $field
* @param int|string $value
*
* @return \PleskX\Api\XmlResponse
*/
private function getBy(string $command, string $field, $value)
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild($command);
$filterTag = $getTag->addChild('filter');
$filterTag->{$field} = (string) $value;
return $this->client->request($packet, Client::RESPONSE_FULL);
}
}

View File

@@ -1,83 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Reseller as Struct;
class Reseller extends \PleskX\Api\Operator
{
public function create(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add')->addChild('gen-info');
foreach ($properties as $name => $value) {
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value): Struct\GeneralInfo
{
$items = $this->getAll($field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo[]
*/
public function getAll($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$datasetTag = $getTag->addChild('dataset');
$datasetTag->addChild('gen-info');
$datasetTag->addChild('permissions');
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || !$xmlResult->data) {
continue;
}
$item = new Struct\GeneralInfo($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,8 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class ResellerPlan extends \PleskX\Api\Operator
{
}

View File

@@ -1,77 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\SecretKey as Struct;
class SecretKey extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'secret_key';
public function create(string $ipAddress = '', string $description = ''): string
{
$packet = $this->client->getPacket();
$createTag = $packet->addChild($this->wrapperTag)->addChild('create');
if ('' !== $ipAddress) {
$createTag->addChild('ip_address', $ipAddress);
}
if ('' !== $description) {
$createTag->addChild('description', $description);
}
$response = $this->client->request($packet);
return (string) $response->key;
}
public function delete(string $keyId): bool
{
return $this->deleteBy('key', $keyId, 'delete');
}
public function get(string $keyId): Struct\Info
{
$items = $this->getBy($keyId);
return reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll(): array
{
return $this->getBy();
}
/**
* @param string|null $keyId
*
* @return Struct\Info[]
*/
public function getBy($keyId = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get_info');
$filterTag = $getTag->addChild('filter');
if (!is_null($keyId)) {
$filterTag->addChild('key', $keyId);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result/key_info') as $keyInfo) {
if (!$keyInfo) {
continue;
}
$items[] = new Struct\Info($keyInfo);
}
return $items;
}
}

View File

@@ -1,143 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Server as Struct;
use PleskX\Api\XmlResponse;
class Server extends \PleskX\Api\Operator
{
public function getProtos(): array
{
$packet = $this->client->getPacket();
$packet->addChild($this->wrapperTag)->addChild('get_protos');
$response = $this->client->request($packet);
/** @psalm-suppress PossiblyNullPropertyFetch */
return (array) $response->protos->proto;
}
public function getGeneralInfo(): Struct\GeneralInfo
{
return new Struct\GeneralInfo($this->getInfo('gen_info'));
}
public function getPreferences(): Struct\Preferences
{
return new Struct\Preferences($this->getInfo('prefs'));
}
public function getAdmin(): Struct\Admin
{
return new Struct\Admin($this->getInfo('admin'));
}
public function getKeyInfo(): array
{
$keyInfo = [];
$keyInfoXml = $this->getInfo('key');
foreach ($keyInfoXml->property ?? [] as $property) {
$keyInfo[(string) $property->name] = (string) $property->value;
}
return $keyInfo;
}
public function getComponents(): array
{
$components = [];
$componentsXml = $this->getInfo('components');
foreach ($componentsXml->component ?? [] as $component) {
$components[(string) $component->name] = (string) $component->version;
}
return $components;
}
public function getServiceStates(): array
{
$states = [];
$statesXml = $this->getInfo('services_state');
foreach ($statesXml->srv ?? [] as $service) {
$states[(string) $service->id] = [
'id' => (string) $service->id,
'title' => (string) $service->title,
'state' => (string) $service->state,
];
}
return $states;
}
public function getSessionPreferences(): Struct\SessionPreferences
{
return new Struct\SessionPreferences($this->getInfo('session_setup'));
}
public function getShells(): array
{
$shells = [];
$shellsXml = $this->getInfo('shells');
foreach ($shellsXml->shell ?? [] as $shell) {
$shells[(string) $shell->name] = (string) $shell->path;
}
return $shells;
}
public function getNetworkInterfaces(): array
{
$interfacesXml = $this->getInfo('interfaces');
return (array) $interfacesXml->interface;
}
public function getStatistics(): Struct\Statistics
{
return new Struct\Statistics($this->getInfo('stat'));
}
public function getSiteIsolationConfig(): array
{
$config = [];
$configXml = $this->getInfo('site-isolation-config');
foreach ($configXml->property ?? [] as $property) {
$config[(string) $property->name] = (string) $property->value;
}
return $config;
}
public function getUpdatesInfo(): Struct\UpdatesInfo
{
return new Struct\UpdatesInfo($this->getInfo('updates'));
}
public function createSession(string $login, string $clientIp): string
{
$packet = $this->client->getPacket();
$sessionNode = $packet->addChild($this->wrapperTag)->addChild('create_session');
$sessionNode->addChild('login', $login);
$dataNode = $sessionNode->addChild('data');
$dataNode->addChild('user_ip', base64_encode($clientIp));
$dataNode->addChild('source_server');
$response = $this->client->request($packet);
return (string) $response->id;
}
private function getInfo(string $operation): XmlResponse
{
$packet = $this->client->getPacket();
$packet->addChild($this->wrapperTag)->addChild('get')->addChild($operation);
$response = $this->client->request($packet);
return $response->$operation;
}
}

View File

@@ -1,77 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\ServicePlan as Struct;
class ServicePlan extends \PleskX\Api\Operator
{
public function create(array $properties): Struct\Info
{
$response = $this->request(['add' => $properties]);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value): Struct\Info
{
$items = $this->getBy($field, $value);
return reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll(): array
{
return $this->getBy();
}
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Struct\Info[]
*/
private function getBy($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$items[] = new Struct\Info($xmlResult);
}
return $items;
}
}

View File

@@ -1,77 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\ServicePlanAddon as Struct;
class ServicePlanAddon extends \PleskX\Api\Operator
{
public function create(array $properties): Struct\Info
{
$response = $this->request(['add' => $properties]);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value): Struct\Info
{
$items = $this->getBy($field, $value);
return reset($items);
}
/**
* @return Struct\Info[]
*/
public function getAll(): array
{
return $this->getBy();
}
/**
* @param string|null $field
* @param int|string|null $value
*
* @return Struct\Info[]
*/
private function getBy($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
$items[] = new Struct\Info($xmlResult);
}
return $items;
}
}

View File

@@ -1,47 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Session as Struct;
class Session extends \PleskX\Api\Operator
{
public function create(string $username, string $userIp): string
{
$packet = $this->client->getPacket();
$creator = $packet->addChild('server')->addChild('create_session');
$creator->addChild('login', $username);
$loginData = $creator->addChild('data');
$loginData->addChild('user_ip', base64_encode($userIp));
$loginData->addChild('source_server', '');
$response = $this->client->request($packet);
return (string) $response->id;
}
/**
* @return Struct\Info[]
*/
public function get(): array
{
$sessions = [];
$response = $this->request('get');
foreach ($response->session ?? [] as $sessionInfo) {
$sessions[(string) $sessionInfo->id] = new Struct\Info($sessionInfo);
}
return $sessions;
}
public function terminate(string $sessionId): bool
{
$response = $this->request("terminate.session-id=$sessionId");
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,94 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Site as Struct;
class Site extends \PleskX\Api\Operator
{
public const PROPERTIES_HOSTING = 'hosting';
public function create(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
$infoGeneral = $info->addChild('gen_setup');
foreach ($properties as $name => $value) {
if (!is_scalar($value)) {
continue;
}
$infoGeneral->{$name} = (string) $value;
}
// set hosting properties
if (isset($properties[static::PROPERTIES_HOSTING]) && is_array($properties[static::PROPERTIES_HOSTING])) {
$hostingNode = $info->addChild('hosting')->addChild('vrt_hst');
foreach ($properties[static::PROPERTIES_HOSTING] as $name => $value) {
$propertyNode = $hostingNode->addChild('property');
/** @psalm-suppress UndefinedPropertyAssignment */
$propertyNode->name = $name;
/** @psalm-suppress UndefinedPropertyAssignment */
$propertyNode->value = $value;
}
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return ?Struct\GeneralInfo
*/
public function get(string $field, $value): ?Struct\GeneralInfo
{
$items = $this->getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
return reset($items) ?: null;
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\HostingInfo|null
*/
public function getHosting(string $field, $value): ?Struct\HostingInfo
{
$items = $this->getItems(
Struct\HostingInfo::class,
'hosting',
$field,
$value,
function (\SimpleXMLElement $node) {
return isset($node->vrt_hst);
}
);
return empty($items) ? null : reset($items);
}
/**
* @return Struct\GeneralInfo[]
*/
public function getAll(): array
{
return $this->getItems(Struct\GeneralInfo::class, 'gen_info');
}
}

View File

@@ -1,85 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\SiteAlias as Struct;
class SiteAlias extends \PleskX\Api\Operator
{
public function create(array $properties, array $preferences = []): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('create');
if (count($preferences) > 0) {
$prefs = $info->addChild('pref');
foreach ($preferences as $key => $value) {
$prefs->addChild($key, is_bool($value) ? ($value ? '1' : '0') : $value);
}
}
$info->addChild('site-id', $properties['site-id']);
$info->addChild('name', $properties['name']);
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value, 'delete');
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value): Struct\GeneralInfo
{
$items = $this->getAll($field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo[]
*/
public function getAll($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->{$field} = (string) $value;
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult) {
continue;
}
if (!is_null($xmlResult->info)) {
$item = new Struct\GeneralInfo($xmlResult->info);
$items[] = $item;
}
}
return $items;
}
}

View File

@@ -1,88 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Subdomain as Struct;
class Subdomain extends \PleskX\Api\Operator
{
public function create(array $properties): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
foreach ($properties as $name => $value) {
if (is_array($value)) {
foreach ($value as $propertyName => $propertyValue) {
$property = $info->addChild($name);
/** @psalm-suppress UndefinedPropertyAssignment */
$property->name = $propertyName;
/** @psalm-suppress UndefinedPropertyAssignment */
$property->value = $propertyValue;
}
continue;
}
$info->{$name} = $value;
}
$response = $this->client->request($packet);
return new Struct\Info($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info
*/
public function get(string $field, $value): Struct\Info
{
$items = $this->getAll($field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Info[]
*/
public function getAll($field = null, $value = null): array
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$filterTag = $getTag->addChild('filter');
if (!is_null($field)) {
$filterTag->addChild($field, (string) $value);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if (!$xmlResult || empty($xmlResult->data)) {
continue;
}
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
return $items;
}
}

View File

@@ -1,45 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Ui as Struct;
class Ui extends \PleskX\Api\Operator
{
public function getNavigation(): array
{
$response = $this->request('get-navigation');
/** @psalm-suppress ImplicitToStringCast, PossiblyNullArgument */
return unserialize(base64_decode($response->navigation));
}
public function createCustomButton(string $owner, array $properties): int
{
$packet = $this->client->getPacket();
$buttonNode = $packet->addChild($this->wrapperTag)->addChild('create-custombutton');
$buttonNode->addChild('owner')->addChild($owner);
$propertiesNode = $buttonNode->addChild('properties');
foreach ($properties as $name => $value) {
$propertiesNode->{$name} = $value;
}
$response = $this->client->request($packet);
return (int) $response->id;
}
public function getCustomButton(int $id): Struct\CustomButton
{
$response = $this->request("get-custombutton.filter.custombutton-id=$id");
return new Struct\CustomButton($response);
}
public function deleteCustomButton(int $id): bool
{
return $this->deleteBy('custombutton-id', $id, 'delete-custombutton');
}
}

View File

@@ -1,9 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
class VirtualDirectory extends \PleskX\Api\Operator
{
protected string $wrapperTag = 'virtdir';
}

View File

@@ -1,199 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Operator;
use PleskX\Api\Struct\Webspace as Struct;
class Webspace extends Operator
{
public function getPermissionDescriptor(): Struct\PermissionDescriptor
{
$response = $this->request('get-permission-descriptor.filter');
return new Struct\PermissionDescriptor($response);
}
public function getLimitDescriptor(): Struct\LimitDescriptor
{
$response = $this->request('get-limit-descriptor.filter');
return new Struct\LimitDescriptor($response);
}
public function getPhysicalHostingDescriptor(): Struct\PhysicalHostingDescriptor
{
$response = $this->request('get-physical-hosting-descriptor.filter');
return new Struct\PhysicalHostingDescriptor($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\PhpSettings
*/
public function getPhpSettings(string $field, $value): Struct\PhpSettings
{
$packet = $this->client->getPacket();
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
$getTag->addChild('filter')->addChild($field, (string) $value);
$getTag->addChild('dataset')->addChild('php-settings');
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
return new Struct\PhpSettings($response);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\Limits
*/
public function getLimits(string $field, $value): Struct\Limits
{
$items = $this->getItems(Struct\Limits::class, 'limits', $field, $value);
return reset($items);
}
/**
* @param array $properties
* @param array|null $hostingProperties
* @param string $planName
*
* @return Struct\Info
*/
public function create(array $properties, ?array $hostingProperties = null, string $planName = ''): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
$infoGeneral = $info->addChild('gen_setup');
foreach ($properties as $name => $value) {
if (is_array($value)) {
continue;
} else {
$infoGeneral->addChild($name, (string) $value);
}
}
if ($hostingProperties) {
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst');
foreach ($hostingProperties as $name => $value) {
$property = $infoHosting->addChild('property');
/** @psalm-suppress UndefinedPropertyAssignment */
$property->name = $name;
/** @psalm-suppress UndefinedPropertyAssignment */
$property->value = $value;
}
if (isset($properties['ip_address'])) {
foreach ((array) $properties['ip_address'] as $ipAddress) {
$infoHosting->addChild('ip_address', $ipAddress);
}
}
}
if ('' !== $planName) {
$info->addChild('plan-name', $planName);
}
$response = $this->client->request($packet);
return new Struct\Info($response, $properties['name'] ?? '');
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function delete(string $field, $value): bool
{
return $this->deleteBy($field, $value);
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\GeneralInfo
*/
public function get(string $field, $value): Struct\GeneralInfo
{
$items = $this->getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
return reset($items);
}
/**
* @return Struct\GeneralInfo[]
*/
public function getAll(): array
{
return $this->getItems(Struct\GeneralInfo::class, 'gen_info');
}
/**
* @param string $field
* @param int|string $value
*
* @return Struct\DiskUsage
*/
public function getDiskUsage(string $field, $value): Struct\DiskUsage
{
$items = $this->getItems(Struct\DiskUsage::class, 'disk_usage', $field, $value);
return reset($items);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function enable(string $field, $value): bool
{
return $this->setProperties($field, $value, ['status' => 0]);
}
/**
* @param string $field
* @param int|string $value
*
* @return bool
*/
public function disable(string $field, $value): bool
{
return $this->setProperties($field, $value, ['status' => 16]);
}
/**
* @param string $field
* @param int|string $value
* @param array $properties
*
* @return bool
*/
public function setProperties(string $field, $value, array $properties): bool
{
$packet = $this->client->getPacket();
$setTag = $packet->addChild($this->wrapperTag)->addChild('set');
$setTag->addChild('filter')->addChild($field, (string) $value);
$genInfoTag = $setTag->addChild('values')->addChild('gen_setup');
foreach ($properties as $property => $propertyValue) {
$genInfoTag->addChild($property, (string) $propertyValue);
}
$response = $this->client->request($packet);
return 'ok' === (string) $response->status;
}
}

View File

@@ -1,38 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Certificate;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public ?string $request = null;
public ?string $privateKey = null;
public ?string $publicKey = null;
public ?string $publicKeyCA = null;
public function __construct($input)
{
if ($input instanceof \SimpleXMLElement) {
$this->initScalarProperties($input, [
['csr' => 'request'],
['pvt' => 'privateKey'],
]);
} else {
foreach ($input as $name => $value) {
$this->$name = $value;
}
}
}
public function getMapping(): array
{
return array_filter([
'csr' => $this->request,
'pvt' => $this->privateKey,
'cert' => $this->publicKey,
'ca' => $this->publicKeyCA,
]);
}
}

View File

@@ -1,48 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Customer;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $company;
public string $personalName;
public string $login;
public string $guid;
public string $email;
public string $phone;
public string $fax;
public string $address;
public string $postalCode;
public string $city;
public string $state;
public string $country;
public string $description;
public string $externalId;
public bool $enabled;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
['cname' => 'company'],
['pname' => 'personalName'],
'login',
'guid',
'email',
'phone',
'fax',
'address',
['pcode' => 'postalCode'],
'city',
'state',
'country',
'external-id',
'description',
]);
$this->enabled = '0' === (string) $apiResponse->status;
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Customer;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $guid;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'guid',
]);
}
}

View File

@@ -1,28 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Database;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public string $type;
public int $webspaceId;
public int $dbServerId;
public int $defaultUserId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'name',
'type',
'webspace-id',
'db-server-id',
'default-user-id',
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Database;
use PleskX\Api\AbstractStruct;
class UserInfo extends AbstractStruct
{
public int $id;
public string $login;
public int $dbId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'login',
'db-id',
]);
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\DatabaseServer;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $host;
public int $port;
public string $type;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'host',
'port',
'type',
]);
}
}

View File

@@ -1,30 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Dns;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public int $siteId;
public int $siteAliasId;
public string $type;
public string $host;
public string $value;
public string $opt;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'site-id',
'site-alias-id',
'type',
'host',
'value',
'opt',
]);
}
}

View File

@@ -1,30 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\EventLog;
use PleskX\Api\AbstractStruct;
class DetailedEvent extends AbstractStruct
{
public int $id;
public string $type;
public int $time;
public string $class;
public string $objectId;
public string $user;
public string $host;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'type',
'time',
'class',
['obj_id' => 'objectId'],
'user',
'host',
]);
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\EventLog;
use PleskX\Api\AbstractStruct;
class Event extends AbstractStruct
{
public string $type;
public int $time;
public string $class;
public string $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'type',
'time',
'class',
'id',
]);
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Ip;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $ipAddress;
public string $netmask;
public string $type;
public string $interface;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'ip_address',
'netmask',
'type',
'interface',
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Locale;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $id;
public string $language;
public string $country;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
['lang' => 'language'],
'country',
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Mail;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $name;
public string $description;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'name',
'description',
]);
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Mail;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'name',
]);
}
}

View File

@@ -1,36 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\PhpHandler;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $id;
public string $displayName;
public string $fullVersion;
public string $version;
public string $type;
public string $path;
public string $clipath;
public string $phpini;
public string $custom;
public string $handlerStatus;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'display-name',
'full-version',
'version',
'type',
'path',
'clipath',
'phpini',
'custom',
'handler-status',
]);
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ProtectedDirectory;
use PleskX\Api\AbstractStruct;
class DataInfo extends AbstractStruct
{
public string $name;
public string $header;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'name',
'header',
]);
}
}

View File

@@ -1,18 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ProtectedDirectory;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
]);
}
}

View File

@@ -1,18 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ProtectedDirectory;
use PleskX\Api\AbstractStruct;
class UserInfo extends AbstractStruct
{
public int $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
]);
}
}

View File

@@ -1,29 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Reseller;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $personalName;
public string $login;
public array $permissions;
public function __construct(\SimpleXMLElement $apiResponse)
{
if (!is_null($apiResponse->{'gen-info'})) {
$this->initScalarProperties($apiResponse->{'gen-info'}, [
['pname' => 'personalName'],
'login',
]);
}
$this->permissions = [];
foreach ($apiResponse->permissions->permission ?? [] as $permissionInfo) {
$this->permissions[(string) $permissionInfo->name] = (string) $permissionInfo->value;
}
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Reseller;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $guid;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'guid',
]);
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\SecretKey;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $key;
public string $ipAddress;
public string $description;
public string $login;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'key',
'ip_address',
'description',
'login',
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class Admin extends AbstractStruct
{
public string $companyName;
public string $name;
public string $email;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
['admin_cname' => 'companyName'],
['admin_pname' => 'name'],
['admin_email' => 'email'],
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public string $serverName;
public string $serverGuid;
public string $mode;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'server_name',
'server_guid',
'mode',
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class Preferences extends AbstractStruct
{
public int $statTtl;
public int $trafficAccounting;
public int $restartApacheInterval;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'stat_ttl',
'traffic_accounting',
'restart_apache_interval',
]);
}
}

View File

@@ -1,18 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class SessionPreferences extends AbstractStruct
{
public int $loginTimeout;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'login_timeout',
]);
}
}

View File

@@ -1,49 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class Statistics extends AbstractStruct
{
/** @var Statistics\Objects */
public $objects;
/** @var Statistics\Version */
public $version;
/** @var Statistics\Other */
public $other;
/** @var Statistics\LoadAverage */
public $loadAverage;
/** @var Statistics\Memory */
public $memory;
/** @var Statistics\Swap */
public $swap;
/** @var Statistics\DiskSpace[] */
public $diskSpace;
/**
* @param \SimpleXMLElement $apiResponse
* @psalm-suppress PossiblyNullArgument
*/
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->objects = new Statistics\Objects($apiResponse->objects);
$this->version = new Statistics\Version($apiResponse->version);
$this->other = new Statistics\Other($apiResponse->other);
$this->loadAverage = new Statistics\LoadAverage($apiResponse->load_avg);
$this->memory = new Statistics\Memory($apiResponse->mem);
$this->swap = new Statistics\Swap($apiResponse->swap);
$this->diskSpace = [];
foreach ($apiResponse->diskspace ?? [] as $disk) {
$this->diskSpace[(string) $disk->device->name] = new Statistics\DiskSpace($disk->device);
}
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class DiskSpace extends AbstractStruct
{
public int $total;
public int $used;
public int $free;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'total',
'used',
'free',
]);
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class LoadAverage extends AbstractStruct
{
public float $load1min;
public float $load5min;
public float $load15min;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->load1min = (float) $apiResponse->l1 / 100.0;
$this->load5min = (float) $apiResponse->l5 / 100.0;
$this->load15min = (float) $apiResponse->l15 / 100.0;
}
}

View File

@@ -1,28 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Memory extends AbstractStruct
{
public int $total;
public int $used;
public int $free;
public int $shared;
public int $buffer;
public int $cached;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'total',
'used',
'free',
'shared',
'buffer',
'cached',
]);
}
}

View File

@@ -1,38 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Objects extends AbstractStruct
{
public int $clients;
public int $domains;
public int $databases;
public int $activeDomains;
public int $mailBoxes;
public int $mailRedirects;
public int $mailGroups;
public int $mailResponders;
public int $databaseUsers;
public int $problemClients;
public int $problemDomains;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'clients',
'domains',
'databases',
['active_domains' => 'activeDomains'],
['mail_boxes' => 'mailBoxes'],
['mail_redirects' => 'mailRedirects'],
['mail_groups' => 'mailGroups'],
['mail_responders' => 'mailResponders'],
['database_users' => 'databaseUsers'],
['problem_clients' => 'problemClients'],
['problem_domains' => 'problemDomains'],
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Other extends AbstractStruct
{
public string $cpu;
public int $uptime;
public bool $insideVz;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'cpu',
'uptime',
['inside_vz' => 'insideVz'],
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Swap extends AbstractStruct
{
public int $total;
public int $used;
public int $free;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'total',
'used',
'free',
]);
}
}

View File

@@ -1,28 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server\Statistics;
use PleskX\Api\AbstractStruct;
class Version extends AbstractStruct
{
public string $internalName;
public string $version;
public string $build;
public string $osName;
public string $osVersion;
public string $osRelease;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
['plesk_name' => 'internalName'],
['plesk_version' => 'version'],
['plesk_build' => 'build'],
['plesk_os' => 'osName'],
['plesk_os_version' => 'osVersion'],
['os_release' => 'osRelease'],
]);
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Server;
use PleskX\Api\AbstractStruct;
class UpdatesInfo extends AbstractStruct
{
public string $lastInstalledUpdate;
public bool $installUpdatesAutomatically;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'last_installed_update',
'install_updates_automatically',
]);
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ServicePlan;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public string $guid;
public string $externalId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'name',
'guid',
'external-id',
]);
}
}

View File

@@ -1,24 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\ServicePlanAddon;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $name;
public string $guid;
public string $externalId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'name',
'guid',
'external-id',
]);
}
}

View File

@@ -1,28 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Session;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $id;
public string $type;
public string $ipAddress;
public string $login;
public string $loginTime;
public string $idle;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'type',
'ip-address',
'login',
'login-time',
'idle',
]);
}
}

View File

@@ -1,40 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Site;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $creationDate;
public string $name;
public string $asciiName;
public string $guid;
public string $status;
public int $realSize;
public array $ipAddresses = [];
public string $description;
public string $webspaceGuid;
public int $webspaceId;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
['cr_date' => 'creationDate'],
'name',
'ascii-name',
'status',
'real_size',
'guid',
'description',
'webspace-guid',
'webspace-id',
]);
foreach ($apiResponse->dns_ip_address ?? [] as $ip) {
$this->ipAddresses[] = (string) $ip;
}
}
}

View File

@@ -1,25 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Site;
use PleskX\Api\AbstractStruct;
class HostingInfo extends AbstractStruct
{
public array $properties = [];
public string $ipAddress;
public function __construct(\SimpleXMLElement $apiResponse)
{
foreach ($apiResponse->vrt_hst->property ?? [] as $property) {
$this->properties[(string) $property->name] = (string) $property->value;
}
if (!is_null($apiResponse->vrt_hst)) {
$this->initScalarProperties($apiResponse->vrt_hst, [
'ip_address',
]);
}
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Site;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $guid;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'guid',
]);
}
}

View File

@@ -1,22 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\SiteAlias;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public string $name;
public string $asciiName;
public string $status;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'name',
'ascii-name',
'status',
]);
}
}

View File

@@ -1,20 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\SiteAlias;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public string $status;
public int $id;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'id',
'status',
]);
}
}

View File

@@ -1,27 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Subdomain;
use PleskX\Api\AbstractStruct;
class Info extends AbstractStruct
{
public int $id;
public string $parent;
public string $name;
public array $properties;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->properties = [];
$this->initScalarProperties($apiResponse, [
'id',
'parent',
'name',
]);
foreach ($apiResponse->property ?? [] as $propertyInfo) {
$this->properties[(string) $propertyInfo->name] = (string) $propertyInfo->value;
}
}
}

View File

@@ -1,35 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Ui;
use PleskX\Api\AbstractStruct;
class CustomButton extends AbstractStruct
{
public int $id;
public int $sortKey;
public bool $public;
public bool $internal;
public bool $noFrame;
public string $place;
public string $url;
public string $text;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, ['id']);
if (!is_null($apiResponse->properties)) {
$this->initScalarProperties($apiResponse->properties, [
'sort_key',
'public',
'internal',
['noframe' => 'noFrame'],
'place',
'url',
'text',
]);
}
}
}

View File

@@ -1,38 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class DiskUsage extends AbstractStruct
{
public int $httpdocs;
public int $httpsdocs;
public int $subdomains;
public int $anonftp;
public int $logs;
public int $dbases;
public int $mailboxes;
public int $maillists;
public int $domaindumps;
public int $configs;
public int $chroot;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
'httpdocs',
'httpsdocs',
'subdomains',
'anonftp',
'logs',
'dbases',
'mailboxes',
'maillists',
'domaindumps',
'configs',
'chroot',
]);
}
}

View File

@@ -1,45 +0,0 @@
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Struct\Webspace;
use PleskX\Api\AbstractStruct;
class GeneralInfo extends AbstractStruct
{
public int $id;
public string $creationDate;
public string $name;
public string $asciiName;
public string $status;
public int $realSize;
public int $ownerId;
public array $ipAddresses = [];
public string $guid;
public string $vendorGuid;
public string $description;
public string $adminDescription;
public bool $enabled;
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse, [
['cr_date' => 'creationDate'],
'name',
'ascii-name',
'status',
'real_size',
'owner-id',
'guid',
'vendor-guid',
'description',
'admin-description',
]);
foreach ($apiResponse->dns_ip_address ?? [] as $ip) {
$this->ipAddresses[] = (string) $ip;
}
$this->enabled = '0' === (string) $apiResponse->status;
}
}

Some files were not shown because too many files have changed in this diff Show More