One Hat Cyber Team
Your IP :
216.73.217.131
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
/
tasks
/
View File Name :
ChangensTask.php
<?php /** * ChangensTask, Change NS * * @copyright Copyright (c) 2007 DotRoll Kft. (http://www.dotroll.com) * @author Zoltán Istvanovszki <zoltan.istvanovszki@dotroll.com> * @since 2018.07.19. * @package CXS_2.0 */ use Phalcon\Config\Adapter\Ini as IniAdapter; class ChangensTask extends \CommonTask { /** * Enviroment * * @var string */ private $enviroment = 'dotroll'; /** * Just a bootstrap */ public function mainAction(array $params) { if (empty($params[0]) || !\in_array($params[0], ['dotroll', 'microware'])) { $this->help(); return; } $this->enviroment = $params[0]; \array_shift($params); if (empty($params[0])) { $this->help(); return; } $domains = \explode(',', $params[0]); foreach ($domains as $domain) { if (!\filter_var("postmaster@$domain", \FILTER_VALIDATE_EMAIL)) { $this->help(); return; } } \array_shift($params); if (empty($params)) { $this->help(); return; } foreach ($params as $ns) { if (!\filter_var("postmaster@$ns", \FILTER_VALIDATE_EMAIL)) { $this->help(); return; } } if (\count($params) < 2 || \count($params) > 5) { $this->help(); return; } $i = 1; $nameservers = []; foreach ($params as $ns) { $nameservers['ns' . $i++] = $ns; } $this->config->merge(new IniAdapter(\APP_PATH . 'config/' . $this->enviroment . '.ini')); $error = []; foreach ($domains as $domain) { if ($this->changeNs($domain, $nameservers) === false) { $error[] = $domain; } } if (!empty($error)) { $this->openAdminTicket( 'NS csere hiba: ' . \implode(', ', $error), "NS váltás nem történt meg az alábbi domainkre:\n" . \implode(\PHP_EOL, $error) . "\n\nAz kívánt névszerverek:\n" . \implode(\PHP_EOL, $nameservers) . "\n" ); } } /** * Change NS * * @param string $domain Domain name * @param array $nameservers Nameservers * @return bool */ private function changeNs(string $domain, array $nameservers): bool { $result = $this->whmcs(\array_merge([ 'action' => 'DomainUpdateNameservers', 'domain' => \idn_to_utf8(\mb_strtolower(\idn_to_ascii($domain))), ], $nameservers)); if (empty($result['result']) || $result['result'] != 'success') { unset($result['result']); echo "{$result['message']}: $domain\n"; if (!empty($result['error'])) { echo "\t{$result['error']}\n"; } return false; } return true; } /** * Create and ticket for department * * @param string $subject The subject of the support ticket. * @param string $message The message body of the support ticket. * @param int $deptid The department ID to which the ticket belongs. * @param string $priority The priority the ticket should be assigned. Possible values include: Low, Medium & High. Defaults to High when none specified. * @param string $name The name of the user to which the ticket belongs. * @param string $email The email address of the user to which the ticket belongs. * @param int $clientid The Client ID the ticket belongs to. * @param bool $noemail Pass as true to surpress the Support Ticket Opened email being sent to the owner of the ticket. * @return type */ private function openAdminTicket(string $subject, string $message = '', int $deptid = 1, string $priority = 'High', string $name = '', string $email = '', int $clientid = 0, bool $noemail = false) { return $this->whmcs([ 'action' => 'OpenTicket', 'clientid' => $clientid, 'deptid' => empty($deptid) ? $this->config->whmcs->deptid : $deptid, 'name' => empty($name) ? $this->config->sender->name : $name, 'email' => empty($email) ? $this->config->sender->email : $email, 'subject' => $subject, 'message' => empty($message) ? "Kedves Adminisztrátor!\n\n$subject" : $message, 'priority' => $priority, 'noemail' => $noemail ]); } /** * Show a help usages */ private function help() { echo "Usage: /opt/cxs2/loginssl.php changens ENVIROMENT DOMAINS NS1 [NS2, ...]\n"; echo "For e.: /opt/cxs2/loginssl.php changens dotroll domain.hu,domain.com ns1.dotroll.com ns2.dotroll.com\n"; } /** * Call WHMCS API EP * * @param array $postfields API params * @return array */ private function whmcs(array $postfields): array { $ch = \curl_init(); \curl_setopt($ch, \CURLOPT_URL, $this->config->whmcs->url); \curl_setopt($ch, \CURLOPT_POST, true); \curl_setopt($ch, \CURLOPT_TIMEOUT, 100); \curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1); \curl_setopt($ch, \CURLOPT_SSL_VERIFYPEER, false); \curl_setopt($ch, \CURLOPT_SSL_VERIFYHOST, false); \curl_setopt($ch, \CURLOPT_POSTFIELDS, \array_merge($postfields, [ 'username' => $this->config->whmcs->user, 'password' => \md5($this->config->whmcs->password), 'responsetype' => 'json', ])); $data = (array) \json_decode(\curl_exec($ch), true); \curl_close($ch); return $data; } }