One Hat Cyber Team
Your IP :
216.73.217.126
Server IP :
185.33.55.30
Server :
Linux cl30.webspacecontrol.com 5.14.0-611.38.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 10 17:21:28 EDT 2026 x86_64
Server Software :
Apache
PHP Version :
8.1.34
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
opt
/
cxs2
/
app
/
libs
/
CXS
/
Edit File:
DirectAdmin.php
<?php /** * DirectAdmin * * @copyright Copyright (c) 2007 DotRoll Kft. (http://www.dotroll.com) * @author Zoltán Istvanovszki <zoltan.istvanovszki@dotroll.com> * @since 2023-01-18 * @package CXS_2.0 */ namespace CXS; class DirectAdmin extends CommonComponent { /** * * @var string Username */ protected $username; /** * * @var string Password */ protected $password; /** * Set last querys var * * @var mixed */ public $result, $resultHeader, $resultBody, $resultStatusCode, $lastTransferSpeed, $headers; /** * Init DirectAdmin */ public function onConstruct() { $this->setCredentials(); } /** * Set credentials * * @return $this \CXS\DirectAdmin */ public function setCredentials(): \CXS\DirectAdmin { $rootAuthUrl = \parse_url(\exec('/usr/local/directadmin/directadmin --root-auth-url')); $this->username = $rootAuthUrl['user']; $this->password = $rootAuthUrl['pass']; return $this; } /** * Get DirectAdmin API result * * @param string $cmd DirectAdmin API command * @param array $values Post/form values * @param string|null $method Api method * @return array */ public function query(string $cmd, array $values = [], ?string $method = null): array { if ($method === null && empty($values)) { $method = 'GET'; } elseif ($method === null) { $method = 'POST'; } $values['json'] = 'yes'; $this->resultStatusCode = null; if (!empty($values)) { $pairs = []; foreach ($values as $key => $value) { $pairs[] = "$key=" . \urlencode($value); } $values = \join('&', $pairs); unset($pairs); } $arrayHeaders = [ 'Host' => $this->getHostname() . ':2222', 'Accept' => '*/*', 'Connection' => 'Close' ]; $curl = 'https://' . $this->getHostname() . ':2222/' . (\substr($cmd, 0, 4) == 'CMD_' ? '' : 'CMD_API_') . $cmd; if ($method == 'GET') { $curl .= "?$values"; } $socket = \curl_init($curl); \curl_setopt($socket, \CURLOPT_SSL_VERIFYHOST, false); \curl_setopt($socket, \CURLOPT_SSL_VERIFYPEER, false); \curl_setopt($socket, \CURLOPT_RETURNTRANSFER, true); \curl_setopt($socket, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1); \curl_setopt($socket, \CURLOPT_USERAGENT, "WHMCS"); \curl_setopt($socket, \CURLOPT_FORBID_REUSE, true); \curl_setopt($socket, \CURLOPT_TIMEOUT, 100); \curl_setopt($socket, \CURLOPT_CONNECTTIMEOUT, 10); \curl_setopt($socket, \CURLOPT_HEADER, true); \curl_setopt($socket, \CURLOPT_LOW_SPEED_LIMIT, 512); \curl_setopt($socket, \CURLOPT_LOW_SPEED_TIME, 120); \curl_setopt($socket, \CURLOPT_USERPWD, "{$this->username}:{$this->password}"); // \curl_setopt($socket, \CURLOPT_INTERFACE, $_SERVER['SERVER_ADDR']); // for DA skins: if $this->remote_passwd is NULL, try to use the login key system // if (isset($this->remote_uname) && $this->remote_passwd == null) { // curl_setopt($socket, CURLOPT_COOKIE, "session={$_SERVER['SESSION_ID']}; key={$_SERVER['SESSION_KEY']}"); // } // if method is POST, add content length & type headers if ($method == 'POST') { \curl_setopt($socket, \CURLOPT_POST, true); \curl_setopt($socket, \CURLOPT_POSTFIELDS, $values); $arrayHeaders['Content-length'] = \strlen($values); } \curl_setopt($socket, \CURLOPT_HTTPHEADER, $arrayHeaders); if (!($this->result = \curl_exec($socket))) { $this->push("DA curl threw error \"" . \curl_error($socket) . "\" for $curl"); return []; } $headerSize = \curl_getinfo($socket, \CURLINFO_HEADER_SIZE); $this->resultHeader = \substr($this->result, 0, $headerSize); $this->resultBody = \substr($this->result, $headerSize); $this->resultStatusCode = \curl_getinfo($socket, \CURLINFO_HTTP_CODE); $this->lastTransferSpeed = \curl_getinfo($socket, \CURLINFO_SPEED_DOWNLOAD) / 1024; \curl_close($socket); $this->headers = $this->fetchHeader(); $return = \json_decode($this->resultBody, true); if (!empty($return['success']) && $return['success'] == 'no') { $this->push('DA threw error "' . \str_replace('=', ': ', \http_build_query($return, null, ', ')) . "\" for $curl"); return []; } return $return; } /** * Return the header of result (stuff before body). * * @return array result header */ private function fetchHeader() { $arrayHeaders = \preg_split("/\r\n/", $this->resultHeader); $arrayReturn = array(0 => $arrayHeaders[0]); unset($arrayHeaders[0]); foreach ($arrayHeaders as $pair) { if ($pair == '' || $pair == "\r\n") { continue; } list($key, $value) = \preg_split("/: /", $pair, 2); $arrayReturn[\strtolower($key)] = $value; } return $arrayReturn; } /** * Get All Users */ public function getAllUsers() { $this->dispatcher->setParam('jobResponse', \json_encode(\array_map('trim', \file('/usr/local/directadmin/data/users/admin/users.list')))); } /** * Get directadmin version */ public function getVersion() { $this->dispatcher->setParam('jobResponse', \str_replace('v.', '', \explode(' ', \exec('/usr/local/directadmin/directadmin version'))[1])); } /** * Get virtual domains */ public function getVirtualDomains() { $this->dispatcher->setParam('jobResponse', \json_encode(\array_map('trim', \file('/etc/virtual/domains')), \JSON_INVALID_UTF8_IGNORE)); } /** * List packages */ public function listPackages() { $packages = []; foreach (\array_map('trim', \file('/usr/local/directadmin/data/users/admin/packages.list')) as $package) { $packages[$package] = \parse_ini_file("/usr/local/directadmin/data/users/admin/packages/$package.pkg"); } $this->dispatcher->setParam('jobResponse', \json_encode($packages)); } /** * Get user config * * @param string $hash Username */ public function getUserConfig(string $hash) { if ($this->checkHash($hash) === false) { return; } if (!\is_file("/usr/local/directadmin/data/users/$hash/user.conf")) { $this->push("/usr/local/directadmin/data/users/$hash/user.conf doesn't exist"); return; } if (!\is_file("/usr/local/directadmin/data/users/$hash/user_ip.list")) { $this->push("/usr/local/directadmin/data/users/$hash/user_ip.list doesn't exist"); return; } if (!\is_file("/usr/local/directadmin/data/users/$hash/user.usage")) { $this->push("/usr/local/directadmin/data/users/$hash/user.usage doesn't exist"); return; } if (!\is_file("/usr/local/directadmin/data/users/$hash/domains.list")) { $this->push("/usr/local/directadmin/data/users/$hash/domains.list doesn't exist"); return; } $conf = \parse_ini_file("/usr/local/directadmin/data/users/$hash/user.conf"); $conf['ips'] = \array_map('trim', \file("/usr/local/directadmin/data/users/$hash/user_ip.list")); $conf['stats'] = \parse_ini_file("/usr/local/directadmin/data/users/$hash/user.usage"); $conf['domains'] = []; foreach (\array_map('trim', \file("/usr/local/directadmin/data/users/$hash/domains.list")) as $domain) { if (!\is_file("/usr/local/directadmin/data/users/$hash/domains/$domain.conf")) { continue; } $data = \parse_ini_file("/usr/local/directadmin/data/users/$hash/domains/$domain.conf"); if (\is_file("/usr/local/directadmin/data/users/$hash/domains/$domain.pointers")) { $data['pointers'] = \parse_ini_file("/usr/local/directadmin/data/users/$hash/domains/$domain.pointers", false, \INI_SCANNER_RAW); foreach ($data['pointers'] as &$pointer) { $pointer = \parse_ini_string($pointer); } } else { $data['pointers'] = []; } if (\is_file("/usr/local/directadmin/data/users/$hash/domains/$domain.subdomains")) { $data['subdomains'] = \array_map('trim', \file("/usr/local/directadmin/data/users/$hash/domains/$domain.subdomains")); } else { $data['subdomains'] = []; } $conf['domains'][] = $data; } if (\is_file("/usr/local/directadmin/data/users/$hash/DocumentRoot.cache.json")) { $conf['docroots'] = \json_decode(\file_get_contents("/usr/local/directadmin/data/users/$hash/DocumentRoot.cache.json"), true); } if (!isset($conf['suspended'])) { $conf['suspended'] = 0; } $this->dispatcher->setParam('jobResponse', \json_encode($conf)); } }
Simpan