Submit
Path:
~
/
/
proc
/
self
/
root
/
opt
/
psa
/
admin
/
plib
/
modules
/
wp-toolkit
/
resources
/
softaculous
/
File Content:
wp-toolkit.php
<?php // Copyright 1999-2025. WebPros International GmbH. All rights reserved. // This code was automatically generated by WP Toolkit. class WpToolkitExecutor { const UAPI_COMMAND = 'uapi WpToolkitCli execute_command command'; const COMMAND_REGISTER = 'register'; const COMMAND_DETACH = 'detach'; /** * @param string $command * @param array $args * @return void */ public function exec($command, $args) { $this->execute($this->buildCommand($command, $args)); } /** * @param string $command * @param array $args * @return void */ public function execAsync($command, $args) { $this->execute($this->buildCommandAsync($command, $args)); } /** * @param string[] $fileParts * @return bool */ public function hasFile($fileParts) { return file_exists(implode(DIRECTORY_SEPARATOR, $fileParts)); } /** * @param string[] $dirParts * @return bool */ public function hasDir($dirParts) { return is_dir(implode(DIRECTORY_SEPARATOR, $dirParts)); } /** * @param string $command * @return void */ private function execute($command) { try { if ($this->isFuncAvailable('exec')) { exec($command); } } catch (Throwable $e) { return; } } /** * @param string $command * @param array $args * @return string */ private function buildCommand($command, $args) { $command = self::UAPI_COMMAND . ' ' . $command; $commandParamArgs = []; foreach ($args as $key => $arg) { $commandParamArgs[] = escapeshellarg("command-param-$key=$arg"); } return escapeshellcmd($command) . ' ' . implode(' ', $commandParamArgs); } /** * @param string $command * @param array $args * @return string */ private function buildCommandAsync($command, $args) { return 'nohup ' . $this->buildCommand($command, $args) . ' > /dev/null 2>&1 &'; } /** * @return bool */ private function isFuncAvailable($functionName) { if (function_exists($functionName)) { $disabledFunctions = array_map( 'trim', explode(',', ini_get('disable_functions') ?: '') ); return !in_array($functionName, $disabledFunctions); } return false; } } class SoftaculousInstallationData { private $softpanel; private $installation; private $scripts; public function __construct($softpanel, $installation, $scripts) { if (empty($softpanel) || empty($installation) || empty($scripts)) { throw new Exception('Unable to get data'); } $this->softpanel = $softpanel; $this->installation = $installation; $this->scripts = $scripts; } /** * @return bool * @throws Exception */ public function isWordpress() { $softId = $this->getSoftId(); if (empty($this->scripts[$softId])) { throw new Exception('Unable to determine installation soft'); } return $this->scripts[$softId]['sid'] == 26 || $this->scripts[$softId]['parent'] == 26; } /** * @return int * @throws Exception */ public function getSoftId() { if (empty($this->installation['sid']) || (int)$this->installation['sid'] === 0) { throw new Exception('Unable to get soft id'); } return (int)$this->installation['sid']; } /** * @return string * @throws Exception */ public function getAccountName() { if (!isset($this->softpanel->user) || empty($this->softpanel->user['name']) || !is_string($this->softpanel->user['name'])) { throw new Exception('Unable to get cPanel account name'); } return $this->softpanel->user['name']; } /** * @return string * @throws Exception */ public function getDomainName() { if (empty($this->installation['softdomain']) || !is_string($this->installation['softdomain'])) { throw new Exception('Unable to get cPanel domain name'); } return $this->installation['softdomain']; } /** * @return string * @throws Exception */ public function getDomainRootPath() { $domain = $this->getDomainName(); if ( !isset($this->softpanel->domainroots) || empty($this->softpanel->domainroots[$domain]) || !is_string($this->softpanel->domainroots[$domain]) ) { throw new Exception('Unable to get cPanel domain root path'); } return $this->softpanel->domainroots[$domain]; } /** * @return string * @throws Exception */ public function getSitePath() { if (empty($this->installation['softpath']) || !is_string($this->installation['softpath'])) { throw new Exception('Unable to get softaculous site path'); } return $this->installation['softpath']; } /** * @return string * @throws Exception */ public function getRelativeSitePath() { return str_replace($this->getDomainRootPath(), '', $this->getSitePath()); } } insert_filter('post_install', 'wp_toolkit_register_instance', 1, 1); function wp_toolkit_register_instance($installation) { global $softpanel, $scripts; try { $installationData = new SoftaculousInstallationData($softpanel, $installation, $scripts); if (!$installationData->isWordpress()) { return $installation; } $executor = new WpToolkitExecutor(); $executor->execAsync(WpToolkitExecutor::COMMAND_REGISTER, [ '-account-name', $installationData->getAccountName(), '-domain-name', $installationData->getDomainName(), '-path', $installationData->getRelativeSitePath(), '-instance-source', 'softaculous' ]); } catch (Throwable $e) {} return $installation; } insert_filter('post_remove', 'wp_toolkit_detach_instance', 1, 1); function wp_toolkit_detach_instance($installation) { global $softpanel, $scripts; try { $installationData = new SoftaculousInstallationData($softpanel, $installation, $scripts); if (!$installationData->isWordpress()) { return $installation; } $executor = new WpToolkitExecutor(); $installationExists = $executor->hasDir([$installationData->getSitePath(), 'wp-includes']) && $executor->hasDir([$installationData->getSitePath(), 'wp-content']) && ( $executor->hasFile([$installationData->getSitePath(), 'wp-config.php']) || ( $executor->hasFile([$installationData->getSitePath(), '..', 'wp-config.php']) && !$executor->hasDir([$installationData->getSitePath(), '..', 'wp-includes']) ) ); if ($installationExists) { return $installation; } $executor->execAsync(WpToolkitExecutor::COMMAND_DETACH, [ '-account-name', $installationData->getAccountName(), '-domain-name', $installationData->getDomainName(), '-path', $installationData->getRelativeSitePath() ]); } catch (Throwable $e) {} return $installation; }
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
wp-toolkit.php
7639 bytes
0644
N4ST4R_ID | Naxtarrr