From 994ee685c3955390c462d0e6008d9e03611f3681 Mon Sep 17 00:00:00 2001 From: bakcay Date: Thu, 9 Jan 2025 16:19:09 +0300 Subject: [PATCH] =?UTF-8?q?BUG-5274:=20WISECP=20s=C3=BCr=C3=BCm=20g=C3=BCn?= =?UTF-8?q?celleme=20sorunu=20-=203682601?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DomainNameAPI/DomainNameAPI.php | 9 +- .../modules/Registrars/DomainNameAPI/api.php | 537 +++++++++++------- .../Registrars/DomainNameAPI/config.php | 4 +- .../Registrars/DomainNameAPI/lang/ar.php | 1 + .../Registrars/DomainNameAPI/lang/de.php | 2 +- .../Registrars/DomainNameAPI/lang/en.php | 2 +- .../Registrars/DomainNameAPI/lang/fr.php | 2 +- .../Registrars/DomainNameAPI/lang/nl.php | 2 +- .../Registrars/DomainNameAPI/lang/tr.php | 3 +- .../DomainNameAPI/pages/settings.php | 28 +- 10 files changed, 352 insertions(+), 238 deletions(-) diff --git a/coremio/modules/Registrars/DomainNameAPI/DomainNameAPI.php b/coremio/modules/Registrars/DomainNameAPI/DomainNameAPI.php index 31e168b..1544c81 100644 --- a/coremio/modules/Registrars/DomainNameAPI/DomainNameAPI.php +++ b/coremio/modules/Registrars/DomainNameAPI/DomainNameAPI.php @@ -5,7 +5,7 @@ /** * DomainNameAPI Registrar Module * @package coremio/modules/Registrars/DomainNameAPI - * @version 1.17.6 + * @version 1.17.7 * @since File available since Release 7.0.0 * @license MIT License https://opensource.org/licenses/MIT * @link https://visecp.com/ @@ -14,6 +14,9 @@ */ class DomainNameAPI { + + public $version = "1.17.7"; + /** @var bool|DomainNameAPI_PHPLibrary */ public $api = false; public $config = []; @@ -77,7 +80,7 @@ private function set_credentials() if ($this->api instanceof DomainNameAPI_PHPLibrary) { return $this->api; } - $this->api = new DomainNameAPI_PHPLibrary($this->username, $this->password); + $this->api = new DomainNameAPI_PHPLibrary($this->username, $this->password,DomainNameAPI_PHPLibrary::APPLICATION_WISECP); } @@ -95,7 +98,7 @@ private function setConfig($username, $password, $tmode) { $this->config["settings"]["password"] = $password; //$this->config["settings"]["test-mode"] = $tmode; - $this->api = new DomainNameAPI_PHPLibrary($username, $password); + $this->api = new DomainNameAPI_PHPLibrary($username, $password,DomainNameAPI_PHPLibrary::APPLICATION_WISECP); } /** diff --git a/coremio/modules/Registrars/DomainNameAPI/api.php b/coremio/modules/Registrars/DomainNameAPI/api.php index a73781e..f74524b 100644 --- a/coremio/modules/Registrars/DomainNameAPI/api.php +++ b/coremio/modules/Registrars/DomainNameAPI/api.php @@ -10,8 +10,9 @@ /** * Class DomainNameAPI_PHPLibrary * @package DomainNameApi - * @version 2.1.3 -*/ + * @version 2.1.4 + */ + namespace DomainNameApi; @@ -25,7 +26,7 @@ class DomainNameAPI_PHPLibrary /** * Version of the library */ - const VERSION = '2.1.3'; + const VERSION = '2.1.4'; const DEFAULT_NAMESERVERS = [ 'ns1.domainnameapi.com', @@ -35,13 +36,38 @@ class DomainNameAPI_PHPLibrary const DEFAULT_IGNORED_ERRORS=[ 'Domain not found', 'ERR_DOMAIN_NOT_FOUND', - 'Reseller not found' + 'Reseller not found', + 'Domain is not in updateable status. It must be active', + 'balance is not sufficient', + 'Price definition not found', ]; const DEFAULT_CACHE_TTL = 512; const DEFAULT_TIMEOUT = 20; const DEFAULT_REASON = 'Owner request'; + const APPLICATION_WHMCS = 'WHMCS'; + const APPLICATION_WISECP = 'WISECP'; + const APPLICATION_HOSTBILL = 'HOSTBILL'; + const APPLICATION_BLESTA = 'BLESTA'; + const APPLICATION_ISPBILLMANAGER = 'ISPBILLMANAGER'; + const APPLICATION_CLIENTEXEC = 'CLIENTEXEC'; + const APPLICATION_HOSTFACT = 'HOSTFACT'; + const APPLICATION_CORE = 'CORE'; + const APPLICATION_NONE = 'NONE'; + + const APPLICATIONS=[ + self::APPLICATION_WHMCS, + self::APPLICATION_WISECP, + self::APPLICATION_HOSTBILL, + self::APPLICATION_BLESTA, + self::APPLICATION_ISPBILLMANAGER, + self::APPLICATION_CLIENTEXEC, + self::APPLICATION_HOSTFACT, + self::APPLICATION_CORE, + self::APPLICATION_NONE, + ]; + /** * Error reporting enabled */ @@ -52,6 +78,7 @@ class DomainNameAPI_PHPLibrary * @var string $errorReportingDsn */ private string $errorReportingDsn = 'https://0ea94fed70c09f95c17dfa211d43ac66@sentry.atakdomain.com/2'; + private string $errorReportingPath = ''; /** * Api Username @@ -71,12 +98,13 @@ class DomainNameAPI_PHPLibrary * @var string $serviceUrl */ private string $serviceUrl = "https://whmcs.domainnameapi.com/DomainApi.svc"; + private string $application = "CORE"; public array $lastRequest = []; public array $lastResponse = []; public array $lastParsedResponse = []; public string $lastFunction = ''; private SoapClient $service; - private $startAt; + private $startAt; /** @@ -86,11 +114,11 @@ class DomainNameAPI_PHPLibrary * @param bool $testMode * @throws Exception | SoapFault */ - public function __construct($userName = "ownername", $password = "ownerpass", $testMode = false) + public function __construct($userName = "ownername", $password = "ownerpass", $application='CORE') { $this->startAt = microtime(true); self::setCredentials($userName, $password); - self::useTestMode($testMode); + self::setApplication($application); $context = stream_context_create( [ @@ -107,7 +135,7 @@ public function __construct($userName = "ownername", $password = "ownerpass", $t "encoding" => "UTF-8", 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'exceptions' => true, - 'connection_timeout' => 20, + 'connection_timeout' => self::DEFAULT_TIMEOUT, 'stream_context' => $context ]); } catch (SoapFault $e) { @@ -119,6 +147,55 @@ public function __construct($userName = "ownername", $password = "ownerpass", $t } } + private function setApplication($application) + { + $this->application = $application; + + if(!in_array( $this->application,self::APPLICATIONS)){ + $this->application = 'CORE'; + } + switch ( $this->application) { + case self::APPLICATION_WHMCS: + $this->errorReportingDsn = "https://cbaee35fa4d2836942641e10c2109cb6@sentry.atakdomain.com/9"; + $this->errorReportingPath='/modules/registrars/domainnameapi/'; + break; + + case self::APPLICATION_WISECP: + $this->errorReportingDsn = "https://16578e3378f7d6c329ff95d9573bc6fa@sentry.atakdomain.com/8"; + $this->errorReportingPath='/coremio/modules/Registrars/DomainNameAPI/'; + break; + + case self::APPLICATION_HOSTBILL: + $this->errorReportingDsn = "https://be47804b215cb479dbfc44db5c662549@sentry.atakdomain.com/11"; + $this->errorReportingPath='/includes/modules/Domain/domainnameapi/'; + break; + + case self::APPLICATION_BLESTA: + $this->errorReportingDsn = "https://8f8ed6f84abaa93ff49b56f15d3c1f38@sentry.atakdomain.com/10"; + $this->errorReportingPath='/components/modules/domainnameapi/'; + break; + + case self::APPLICATION_CORE: + $this->errorReportingDsn = "https://0ea94fed70c09f95c17dfa211d43ac66@sentry.atakdomain.com/2"; + break; + + case self::APPLICATION_ISPBILLMANAGER: + $this->errorReportingDsn = "https://dace28deb069996acecf619c9e397b15@sentry.atakdomain.com/12"; + break; + + case self::APPLICATION_CLIENTEXEC: + $this->errorReportingDsn = "https://033791219211d863fdb9c08b328ba058@sentry.atakdomain.com/13"; + break; + + case self::APPLICATION_HOSTFACT: + $this->errorReportingDsn = "https://58fe0a01a6704d9f1c2dbbc1a316f233@sentry.atakdomain.com/14"; + break; + case self::APPLICATION_NONE: + $this->errorReportingEnabled = false; + break; + } + + } /** * Deprecated @@ -233,161 +310,7 @@ public function setServiceUrl($url) } - /** - * This method sends anonymous error data to the Sentry server, if error reporting is enabled - * - * @return void - */ - private function sendErrorToSentryAsync(Exception $e) - { - if (!$this->errorReportingEnabled) { - return; - } - - $skipped_errors = self::DEFAULT_IGNORED_ERRORS; - - foreach ($skipped_errors as $ek => $ev) { - if(strpos($e->getMessage(),$ev) !== false){ - return ; - } - } - - $elapsed_time = microtime(true) - $this->startAt; - $parsed_dsn = parse_url($this->errorReportingDsn); - - // API URL'si - $host = $parsed_dsn['host']; - $project_id = ltrim($parsed_dsn['path'], '/'); - $public_key = $parsed_dsn['user']; - $secret_key = $parsed_dsn['pass'] ?? null; - $api_url = "https://$host/api/$project_id/store/"; - - $external_ip = $this->getServerIp(); - - - - // Hata verisi - $errorData = [ - 'event_id' => bin2hex(random_bytes(16)), - 'timestamp' => gmdate('Y-m-d\TH:i:s\Z'), - 'level' => 'error', - 'logger' => 'php', - 'platform' => 'php', - 'culprit' => __FILE__, - 'message' => [ - 'formatted' => $e->getMessage() - ], - 'exception' => [ - 'values' => [ - [ - 'type' => str_replace(['DomainNameApi\DomainNameAPI_PHPLibrary'],['DNALib Exception'],self::class), - 'value' => $e->getMessage(), - 'stacktrace' => [ - 'frames' => [ - [ - 'filename' => $e->getFile(), - 'lineno' => $e->getLine(), - 'function' => str_replace([dirname(__DIR__),'DomainNameApi\DomainNameAPI_PHPLibrary'],['.','Lib'],$e->getTraceAsString()), - ] - ] - ] - ] - ] - ], - 'tags' => [ - 'handled' => 'yes', - 'level' => 'error', - 'release' => self::VERSION, - 'environment' => 'production', - 'url' => $_SERVER['REQUEST_URI'] ?? 'unknown', - 'transaction' => $_SERVER['REQUEST_METHOD'] ?? 'unknown', - 'status_code' => http_response_code(), - 'trace_id' => bin2hex(random_bytes(8)), // Trace ID örneği - 'runtime_name' => 'PHP', - 'runtime_version' => phpversion(), - 'ip_address' => $external_ip, - 'elapsed_time' => number_format($elapsed_time, 4), - - ], - 'extra' => [ - 'request_data' => $this->getRequestData(), - 'response_data' => $this->getResponseData(), - ] - ]; - - // Sentry başlığı - $sentry_auth = [ - 'sentry_version=7', - 'sentry_client=wisecp-php/' . self::VERSION, - "sentry_key=$public_key" - ]; - if ($secret_key) { - $sentry_auth[] = "sentry_secret=$secret_key"; - } - $sentry_auth_header = 'X-Sentry-Auth: Sentry ' . implode(', ', $sentry_auth); - - if(function_exists('escapeshellarg') && function_exists('exec')){ - $cmd = 'curl -X POST ' . escapeshellarg($api_url) . ' -H ' . escapeshellarg('Content-Type: application/json') . ' -H ' . escapeshellarg($sentry_auth_header) . ' -d ' . escapeshellarg(json_encode($errorData)) . ' > /dev/null 2>&1 &'; - exec($cmd); - }else{ - $jsonData = json_encode($errorData); - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $api_url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); - curl_setopt($ch, CURLOPT_TIMEOUT, 2); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Content-Type: application/json', - $sentry_auth_header - ]); - curl_exec($ch); - curl_close($ch); - } - } - - private function getServerIp() - { - $cache_ttl = 512; // Cache süresi 512 saniye - $cache_key = 'external_ip'; - $cache_file = __DIR__ . '/ip_addr.cache'; - $current_time = time(); - - if (function_exists('apcu_fetch')) { - // APCu ile cache kontrolü - $external_ip = apcu_fetch($cache_key); - if ($external_ip !== false) { - return $external_ip; - } - } elseif (file_exists($cache_file) && ($current_time - filemtime($cache_file) < $cache_ttl)) { - // Dosya ile cache kontrolü - return file_get_contents($cache_file); - } - - // IP adresini alma ve cacheleme - try { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, "http://ipecho.net/plain"); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 2); - $external_ip = curl_exec($ch); - curl_close($ch); - - if ($external_ip !== false) { - // APCu ile cachele - if (function_exists('apcu_store')) { - apcu_store($cache_key, $external_ip, $cache_ttl); - } - // Dosya ile cachele - file_put_contents($cache_file, $external_ip); - } - return $external_ip; - } catch (Exception $e) { - return 'unknown'; - } - } /** @@ -432,8 +355,7 @@ public function GetResellerDetails() $resp['balances'] = $balances; } else { $resp['result'] = 'ERROR'; - $resp['error'] = $this->setError("INVALID_CREDINENTIALS", "Invalid response received from server!", - "invalid username and password"); + $resp['error'] = $this->setError("INVALID_CREDINENTIALS", "Invalid response received from server!", "invalid username and password"); } @@ -444,7 +366,6 @@ public function GetResellerDetails() return $response; } - /** * Get Current primary Balance for your account */ @@ -523,6 +444,7 @@ public function CheckAvailability($domains, $extensions, $period, $Command) ]; } + foreach ($data["DomainAvailabilityInfoList"]['DomainAvailabilityInfo'] as $name => $value) { $available[] = [ "TLD" => $value["Tld"], @@ -546,7 +468,6 @@ public function CheckAvailability($domains, $extensions, $period, $Command) return $response; } - /** * Hesabınızdaki alan adlarının listesini getirir * @@ -626,7 +547,6 @@ public function GetList($extra_parameters = []) return $response; } - /** * Retrieves TLD list and pricing matrix required for price and TLD synchronization * @@ -717,7 +637,6 @@ public function GetTldList($count = 20) return $result; } - /** * Retrieves detailed information for a specific domain * @@ -1001,7 +920,7 @@ public function DeleteChildNameServer($domainName, $nameServer) } - /** + /** * Modifies IP address of a child nameserver for a domain * * @param string $domainName The domain name that owns the child nameserver @@ -1050,7 +969,7 @@ public function ModifyChildNameServer($domainName, $nameServer, $ipAddress) // CONTACT MANAGEMENT - /** + /** * Retrieves all contact information for a domain (Administrative, Billing, Technical, Registrant) * * @param string $domainName The domain name to get contacts for @@ -1146,7 +1065,7 @@ public function GetContacts($domainName) } - /** + /** * Saves or updates contact information for all contact types of a domain * * @param string $domainName The domain name to update contacts for @@ -1311,7 +1230,7 @@ public function Transfer($domainName, $eppCode, $period) } - /** + /** * Cancels a pending incoming transfer request for a domain * * @param string $domainName The domain name to cancel transfer for @@ -1354,7 +1273,7 @@ public function CancelTransfer($domainName) } - /** + /** * Approves a pending outgoing transfer request for a domain * * @param string $domainName The domain name to approve transfer for @@ -1396,8 +1315,7 @@ public function ApproveTransfer($domainName) return $response; } - - /** + /** * Rejects a pending outgoing transfer request for a domain * * @param string $domainName The domain name to reject transfer for @@ -1440,7 +1358,7 @@ public function RejectTransfer($domainName) } - /** + /** * Renews a domain registration for specified period * * @param string $domainName The domain name to renew @@ -1493,7 +1411,7 @@ public function Renew($domainName, $period) } - /** + /** * Registers a new domain with complete contact information * * @param string $domainName The domain name to register @@ -1643,7 +1561,7 @@ public function ModifyPrivacyProtectionStatus($domainName, $status, $reason = se { $parameters = [ "request" => [ - "DomainName" => $domainName, + "DomainName" => $domainName, "ProtectPrivacy" => $status, "Reason" => trim($reason) ?: self::DEFAULT_REASON ] @@ -1651,7 +1569,7 @@ public function ModifyPrivacyProtectionStatus($domainName, $status, $reason = se return self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { return [ - 'data' => [ + 'data' => [ 'PrivacyProtectionStatus' => $parameters["request"]["ProtectPrivacy"] ], 'result' => 'OK' @@ -1660,7 +1578,7 @@ public function ModifyPrivacyProtectionStatus($domainName, $status, $reason = se } - /** + /** * Synchronizes domain information with the registry * * @param string $domainName The domain name to synchronize @@ -1708,7 +1626,7 @@ public function SyncFromRegistry($domainName) ]; return self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - $data = $response[key($response)]; + $data = $response[key($response)]; // If DomainInfo a valid array if (isset($data["DomainInfo"]) && is_array($data["DomainInfo"])) { @@ -1744,7 +1662,7 @@ private function objectToArray($_obj) } // Get error if exists - private function parseError($response, $trace = true) + private function parseError($response,$trace=true) { $result = false; @@ -1804,6 +1722,7 @@ private function parseError($response, $trace = true) "Code" => '', "Message" => 'Failed', "Details" => '', + ]; if (isset($response[key($response)]["OperationMessage"])) { @@ -1820,7 +1739,7 @@ private function parseError($response, $trace = true) } } - if (isset($result["Code"]) && $trace === true) { + if (isset($result["Code"]) && $trace===true) { $this->sendErrorToSentryAsync(new Exception("API_ERROR: " . $result["Code"] . " - " . $result["Message"] . " - " . $result["Details"])); } @@ -2040,6 +1959,8 @@ private function parseDomainInfo($data) return $result; } + + /* Parses contact information from the provided data array. * * @param array $data The data array containing contact information. @@ -2072,50 +1993,49 @@ private function parseDomainInfo($data) */ private function parseContactInfo($data) { - $result = [ - "ID" => isset($data["Id"]) && is_numeric($data["Id"]) ? $data["Id"] : "", - "Status" => $data["Status"] ?? "", - "AuthCode" => $data["Auth"] ?? "", - "FirstName" => $data["FirstName"] ?? "", - "LastName" => $data["LastName"] ?? "", - "Company" => $data["Company"] ?? "", - "EMail" => $data["EMail"] ?? "", - "Type" => $data["Type"] ?? "", - "Address" => [ - "Line1" => $data["AddressLine1"] ?? "", - "Line2" => $data["AddressLine2"] ?? "", - "Line3" => $data["AddressLine3"] ?? "", - "State" => $data["State"] ?? "", - "City" => $data["City"] ?? "", - "Country" => $data["Country"] ?? "", - "ZipCode" => $data["ZipCode"] ?? "", - ], - "Phone" => [ - "Phone" => [ - "Number" => $data["Phone"] ?? "", - "CountryCode" => $data["PhoneCountryCode"] ?? "", + $result = [ + "ID" => isset($data["Id"]) && is_numeric($data["Id"]) ? $data["Id"] : "", + "Status" => $data["Status"] ?? "", + "AuthCode" => $data["Auth"] ?? "", + "FirstName" => $data["FirstName"] ?? "", + "LastName" => $data["LastName"] ?? "", + "Company" => $data["Company"] ?? "", + "EMail" => $data["EMail"] ?? "", + "Type" => $data["Type"] ?? "", + "Address" => [ + "Line1" => $data["AddressLine1"] ?? "", + "Line2" => $data["AddressLine2"] ?? "", + "Line3" => $data["AddressLine3"] ?? "", + "State" => $data["State"] ?? "", + "City" => $data["City"] ?? "", + "Country" => $data["Country"] ?? "", + "ZipCode" => $data["ZipCode"] ?? "", ], - "Fax" => [ - "Number" => $data["Fax"] ?? "", - "CountryCode" => $data["FaxCountryCode"] ?? "", + "Phone" => [ + "Phone" => [ + "Number" => $data["Phone"] ?? "", + "CountryCode" => $data["PhoneCountryCode"] ?? "", + ], + "Fax" => [ + "Number" => $data["Fax"] ?? "", + "CountryCode" => $data["FaxCountryCode"] ?? "", + ], ], - ], - "Additional" => [], - ]; + "Additional" => [], + ]; - // AdditionalAttributes kontrolü - if (isset($data["AdditionalAttributes"]["KeyValueOfstringstring"]) && is_array($data["AdditionalAttributes"]["KeyValueOfstringstring"])) { - foreach ($data["AdditionalAttributes"]["KeyValueOfstringstring"] as $attribute) { - if (isset($attribute["Key"]) && isset($attribute["Value"])) { - $result["Additional"][$attribute["Key"]] = $attribute["Value"]; - } - } - } + // AdditionalAttributes kontrolü + if (isset($data["AdditionalAttributes"]["KeyValueOfstringstring"]) && is_array($data["AdditionalAttributes"]["KeyValueOfstringstring"])) { + foreach ($data["AdditionalAttributes"]["KeyValueOfstringstring"] as $attribute) { + if (isset($attribute["Key"]) && isset($attribute["Value"])) { + $result["Additional"][$attribute["Key"]] = $attribute["Value"]; + } + } + } return $result; } - private function parseCall($fn, $parameters, $_callback) { $result = [ @@ -2147,7 +2067,6 @@ private function parseCall($fn, $parameters, $_callback) $result["result"] = "ERROR"; $result["error"] = $this->parseError($_response); } - } catch (SoapFault $ex) { $result["result"] = "ERROR"; $result["error"] = $this->setError('INVALID_RESPONSE', 'Invalid response occurred', $ex->getMessage()); @@ -2166,6 +2085,7 @@ private function parseCall($fn, $parameters, $_callback) } + /** * Domain is TR type * @param $domain @@ -2180,5 +2100,180 @@ public function isTrTLD($domain) return isset($result[0]); } + /** + * This method sends anonymous error data to the Sentry server, if error reporting is enabled + * + * @return void + */ + private function sendErrorToSentryAsync(Exception $e) + { + if (!$this->errorReportingEnabled) { + return; + } + + $skipped_errors = self::DEFAULT_IGNORED_ERRORS; + + foreach ($skipped_errors as $ek => $ev) { + if(strpos($e->getMessage(),$ev) !== false){ + return ; + } + } + + $elapsed_time = microtime(true) - $this->startAt; + $parsed_dsn = parse_url($this->errorReportingDsn); + + // API URL'si + $host = $parsed_dsn['host']; + $project_id = ltrim($parsed_dsn['path'], '/'); + $public_key = $parsed_dsn['user']; + $secret_key = $parsed_dsn['pass'] ?? null; + $api_url = "https://$host/api/$project_id/store/"; + + $external_ip = $this->getServerIp(); + + + $knownPath = __FILE__; + $errFile=$e->getFile(); + $vhostUser = ''; + + + if (preg_match('/\/home\/([^\/]+)\//', $knownPath, $matches)) { + $vhostUser = $matches[1]; + } + if($vhostUser==''){ + $vhostUser = get_current_user(); + } + + if (strlen($this->errorReportingPath)>0) { + if (strpos($knownPath, $this->errorReportingPath) !== false) { + $knownPath = substr($knownPath, strpos($knownPath, $this->errorReportingPath) + strlen($this->errorReportingPath)); + $errFile = substr($errFile, strpos($errFile, $this->errorReportingPath) + strlen($this->errorReportingPath)); + } + } + + // Hata verisi + $errorData = [ + 'event_id' => bin2hex(random_bytes(16)), + 'timestamp' => gmdate('Y-m-d\TH:i:s\Z'), + 'level' => 'error', + 'logger' => 'php', + 'platform' => 'php', + 'culprit' => $knownPath, + 'message' => [ + 'formatted' => $e->getMessage() + ], + 'exception' => [ + 'values' => [ + [ + 'type' => str_replace(['DomainNameApi\DomainNameAPI_PHPLibrary'],[$this->application.' Exception'],self::class), + 'value' => $e->getMessage(), + 'stacktrace' => [ + 'frames' => [ + [ + 'filename' => $errFile, + 'lineno' => $e->getLine(), + 'function' => str_replace([dirname(__DIR__),'DomainNameApi\DomainNameAPI_PHPLibrary'],['.','Lib'],$e->getTraceAsString()), + ] + ] + ] + ] + ] + ], + 'tags' => [ + 'handled' => 'yes', + 'level' => 'error', + 'release' => self::VERSION, + 'environment' => 'production', + 'url' => $_SERVER['REQUEST_URI'] ?? 'unknown', + 'transaction' => $_SERVER['REQUEST_METHOD'] ?? 'unknown', + 'status_code' => http_response_code(), + 'trace_id' => bin2hex(random_bytes(8)), // Trace ID örneği + 'runtime_name' => 'PHP', + 'runtime_version' => phpversion(), + 'ip_address' => $external_ip, + 'elapsed_time' => number_format($elapsed_time,4), + 'vhost_user' => $vhostUser, + 'application' => $this->application, + + ], + 'extra' => [ + 'request_data' => $this->getRequestData(), + 'response_data' => $this->getResponseData(), + ] + ]; + + // Sentry başlığı + $sentry_auth = [ + 'sentry_version=7', + 'sentry_client=phplib-php/' . self::VERSION, + "sentry_key=$public_key" + ]; + if ($secret_key) { + $sentry_auth[] = "sentry_secret=$secret_key"; + } + $sentry_auth_header = 'X-Sentry-Auth: Sentry ' . implode(', ', $sentry_auth); + + if(function_exists('escapeshellarg') && function_exists('exec')){ + $cmd = 'curl -X POST ' . escapeshellarg($api_url) . ' -H ' . escapeshellarg('Content-Type: application/json') . ' -H ' . escapeshellarg($sentry_auth_header) . ' -d ' . escapeshellarg(json_encode($errorData)) . ' > /dev/null 2>&1 &'; + exec($cmd); + }else{ + $jsonData = json_encode($errorData); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $api_url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); + curl_setopt($ch, CURLOPT_TIMEOUT, 2); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json', + $sentry_auth_header + ]); + curl_exec($ch); + curl_close($ch); + } + } + + private function getServerIp() + { + $cache_ttl = self::DEFAULT_CACHE_TTL; + $cache_key = 'external_ip'; + $cache_file = __DIR__ . '/ip_addr.cache'; + $current_time = time(); + + if (function_exists('apcu_fetch')) { + // APCu ile cache kontrolü + $external_ip = apcu_fetch($cache_key); + if ($external_ip !== false) { + return $external_ip; + } + } elseif (file_exists($cache_file) && ($current_time - filemtime($cache_file) < $cache_ttl)) { + // Dosya ile cache kontrolü + return file_get_contents($cache_file); + } + + // IP adresini alma ve cacheleme + try { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "http://ipecho.net/plain"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, 2); + $external_ip = curl_exec($ch); + curl_close($ch); + + if ($external_ip !== false) { + // APCu ile cachele + if (function_exists('apcu_store')) { + apcu_store($cache_key, $external_ip, $cache_ttl); + } + // Dosya ile cachele + file_put_contents($cache_file, $external_ip); + } + + return $external_ip; + } catch (Exception $e) { + return 'unknown'; + } + } } diff --git a/coremio/modules/Registrars/DomainNameAPI/config.php b/coremio/modules/Registrars/DomainNameAPI/config.php index 23f2a80..f8dbcbd 100644 --- a/coremio/modules/Registrars/DomainNameAPI/config.php +++ b/coremio/modules/Registrars/DomainNameAPI/config.php @@ -3,12 +3,12 @@ return [ 'meta' => [ 'name' => 'DomainNameAPI', - 'version' => '1.17.6', + 'version' => '1.17.7', 'logo' => 'logo.png', ], 'settings' => [ 'whois-types' => true, - 'username' => 'user', + 'username' => 'user.domainnameapi', 'password' => '********', 'test-mode' => 0, 'whidden-amount' => 0, diff --git a/coremio/modules/Registrars/DomainNameAPI/lang/ar.php b/coremio/modules/Registrars/DomainNameAPI/lang/ar.php index 8190ce9..1bdaae0 100644 --- a/coremio/modules/Registrars/DomainNameAPI/lang/ar.php +++ b/coremio/modules/Registrars/DomainNameAPI/lang/ar.php @@ -76,4 +76,5 @@ 'numofTLDNotSynced' => 'خطأ', 'numofTLDNotSyncedTxt' => 'حدث خطأ. يرجى المحاولة مرة أخرى.', 'stillProcessing' => 'العملية مستمرة...', + 'eplasedTime' => 'استغرقت اتصال API :time: ثانية', ]; diff --git a/coremio/modules/Registrars/DomainNameAPI/lang/de.php b/coremio/modules/Registrars/DomainNameAPI/lang/de.php index 529777e..fea22d8 100644 --- a/coremio/modules/Registrars/DomainNameAPI/lang/de.php +++ b/coremio/modules/Registrars/DomainNameAPI/lang/de.php @@ -77,5 +77,5 @@ 'numofTLDNotSynced' => 'Fehler', 'numofTLDNotSyncedTxt' => 'Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.', 'stillProcessing' => 'Der Vorgang läuft noch...', - + 'eplasedTime' => 'Die API-Verbindung dauerte :time: Sekunden', ]; diff --git a/coremio/modules/Registrars/DomainNameAPI/lang/en.php b/coremio/modules/Registrars/DomainNameAPI/lang/en.php index 754e142..b054692 100644 --- a/coremio/modules/Registrars/DomainNameAPI/lang/en.php +++ b/coremio/modules/Registrars/DomainNameAPI/lang/en.php @@ -77,5 +77,5 @@ 'numofTLDNotSynced' => 'Error', 'numofTLDNotSyncedTxt' => 'An error occurred. Please try again.', 'stillProcessing' => 'Process is still ongoing...', - + 'eplasedTime' => 'API connection took :time: seconds', ]; diff --git a/coremio/modules/Registrars/DomainNameAPI/lang/fr.php b/coremio/modules/Registrars/DomainNameAPI/lang/fr.php index 0206757..65cb315 100644 --- a/coremio/modules/Registrars/DomainNameAPI/lang/fr.php +++ b/coremio/modules/Registrars/DomainNameAPI/lang/fr.php @@ -77,5 +77,5 @@ 'numofTLDNotSynced' => 'Erreur', 'numofTLDNotSyncedTxt' => 'Une erreur s\'est produite. Veuillez réessayer.', 'stillProcessing' => 'Le processus est toujours en cours...', - + 'eplasedTime' => 'La connexion API a pris :time: secondes', ]; \ No newline at end of file diff --git a/coremio/modules/Registrars/DomainNameAPI/lang/nl.php b/coremio/modules/Registrars/DomainNameAPI/lang/nl.php index 6b65cdb..233b447 100644 --- a/coremio/modules/Registrars/DomainNameAPI/lang/nl.php +++ b/coremio/modules/Registrars/DomainNameAPI/lang/nl.php @@ -77,5 +77,5 @@ 'numofTLDNotSynced' => 'Fout', 'numofTLDNotSyncedTxt' => 'Er is een fout opgetreden. Probeer het opnieuw.', 'stillProcessing' => 'Proces is nog steeds aan de gang...', - + 'eplasedTime' => 'API-verbinding duurde :time: seconden', ]; diff --git a/coremio/modules/Registrars/DomainNameAPI/lang/tr.php b/coremio/modules/Registrars/DomainNameAPI/lang/tr.php index 6f3873a..cae8e4f 100644 --- a/coremio/modules/Registrars/DomainNameAPI/lang/tr.php +++ b/coremio/modules/Registrars/DomainNameAPI/lang/tr.php @@ -77,6 +77,5 @@ 'numofTLDNotSynced' => 'Hata', 'numofTLDNotSyncedTxt' => 'Bir hata oluştu. Lütfen tekrar deneyin.', 'stillProcessing' => 'İşlem devam ediyor...', - - + 'eplasedTime' => 'Api bağlantısı :time: saniye sürdü', ]; diff --git a/coremio/modules/Registrars/DomainNameAPI/pages/settings.php b/coremio/modules/Registrars/DomainNameAPI/pages/settings.php index 9040e5e..3d44813 100644 --- a/coremio/modules/Registrars/DomainNameAPI/pages/settings.php +++ b/coremio/modules/Registrars/DomainNameAPI/pages/settings.php @@ -130,6 +130,12 @@ +
+
+
+
+
+
@@ -458,11 +464,12 @@ function DomainNameAPI_import_handler(result) { const numofTLDNotSyncedTxtMessage = ""; const stillProcessingMessage = ""; const expectedProfitRate = ; - const currentVersion = 'config['meta']['version']; ?>'; + const currentVersion = 'version; ?>'; const txtVersion1 = ''; const txtVersion2 = ''; const txtVersion3 = ''; const txtVersion4 = ''; + const eplasedTime = ''; let queueTable; let tldTable; @@ -887,14 +894,24 @@ function getBalanceInfo() { $('.js-balance').html('
'); + const startTime = performance.now(); + $.post(requestUrl, userInfoRequest, function(response) { + const endTime = performance.now(); + const responseTime = ((endTime - startTime) / 1000).toFixed(2); - let style_attr = response.loggedin === true ? 'color: #4CAF50;font-weight:bold' : 'color: #F44336;font-weight:bold'; - let icon = response.loggedin === true ? '' : ''; + let style_attr = response.loggedin === true + ? 'color: #4CAF50;font-weight:bold' + : 'color: #F44336;font-weight:bold'; + let icon = response.loggedin === true + ? '' + : ''; $('.js-balance').attr('style', style_attr); - $('.js-balance').html(''+icon+' '+response.message+''); + $('.js-balance').html('' + icon + ' ' + response.message + ''); + let timeColor = responseTime < 1 ? 'green' : responseTime < 3 ? 'orange' : 'red'; + $('.connection-time').html('' + eplasedTime.replace(':time:', responseTime) + ''); }, 'json'); } @@ -954,7 +971,6 @@ function DNAOpenTab(elem, tabName) { initializeImportTab(); } else if (tabName === 'tlds') { initializeTldImportTab(); - //tldTable.columns.adjust().draw(); } } @@ -1026,7 +1042,7 @@ function checkModuleVersion() { if ('V' + currentVersion !== latestVersion) { versionText = `

${txtVersion1} V${currentVersion}. -
Sunucudaki son versiyon: ${latestVersion}${txtVersion2}

+
Sunucudaki son versiyon: ${latestVersion} ${txtVersion2}

${txtVersion3}`; } else { versionText = `