From 90b10e432d64aa77f5473bebe384452032d20555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BCnyamin=20AK=C3=87AY?= Date: Thu, 18 May 2023 02:51:51 +0300 Subject: [PATCH] =?UTF-8?q?Dil=20ayarlamalar=C4=B1=20,=20ince=20ayarlar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dnaextended/app/handlers/settings.php | 3 + .../app/lib/DomainNameAPI_PHPLibrary.php | 148 ++++++------------ modules/addons/dnaextended/app/module.php | 40 +++++ .../dnaextended/app/view/admin/layout.tpl | 1 + .../dnaextended/app/view/admin/settings.tpl | 2 +- .../dnaextended/assets/module.domains.js | 4 +- modules/addons/dnaextended/dnaextended.php | 1 + 7 files changed, 98 insertions(+), 101 deletions(-) diff --git a/modules/addons/dnaextended/app/handlers/settings.php b/modules/addons/dnaextended/app/handlers/settings.php index aa6ed11..08f9a38 100644 --- a/modules/addons/dnaextended/app/handlers/settings.php +++ b/modules/addons/dnaextended/app/handlers/settings.php @@ -13,6 +13,9 @@ ->first(); + + +$controlleroutput['cronbinary']=$module->getPreferredCliBinary(); $controlleroutput['cronfile']=realpath(dirname(__DIR__.'/../../../')).'/cron.php'; $controlleroutput['latestcron']=$lastcronrun->updated_at; $controlleroutput['settings']=$dnasettings; diff --git a/modules/addons/dnaextended/app/lib/DomainNameAPI_PHPLibrary.php b/modules/addons/dnaextended/app/lib/DomainNameAPI_PHPLibrary.php index afa9a91..27103f1 100644 --- a/modules/addons/dnaextended/app/lib/DomainNameAPI_PHPLibrary.php +++ b/modules/addons/dnaextended/app/lib/DomainNameAPI_PHPLibrary.php @@ -10,7 +10,12 @@ /** * Class DomainNameAPI_PHPLibrary * @package DomainNameApi - * @version 2.0.9 + * @version 2.0.10 + */ + +/* + * This library was written really long before the PSR-7 standards and was not structured according to most coding disciplines. It has only optimized from legacy version. + * The code inherited from the 1st version has been revamped to create the 2nd version, and a complete overhaul is planned for the 3rd version. */ namespace DomainNameApi; @@ -45,8 +50,12 @@ public function __construct($UserName = "ownername", $Password = "ownerpass", $T // METHODS - // USE TEST PLATFORM OR REAL PLATFORM - // if value equals false, use real platform, otherwise use test platform + + /** + * USE TEST PLATFORM OR REAL PLATFORM + * if value equals false, use real platform, otherwise use test platform + * @param bool $value + */ private function useTestMode($value = true) { if ($value === true || $value=='on') { $this->_USERDATA_USERNAME = 'test1.dna@apiname.com'; @@ -54,21 +63,47 @@ private function useTestMode($value = true) { } } - // SET Username and Password + + /** + * SET Username and Password + * @param $UserName + * @param $Password + * @return void + */ private function setCredentials($UserName, $Password) { $this->_USERDATA_USERNAME = $UserName; $this->_USERDATA_PASSWORD = $Password; } + + /** + * This method returns the last request sent to the API + * @return array|mixed + */ public function getRequestData(){ return $this->__REQUEST; } + + /** + * This method sets the last request sent to the API + * @return array|mixed + */ public function setRequestData($request){ $this->__REQUEST = $request; } + + /** + * This method returns the last response from the API + * @return array|mixed + */ public function getResponseData(){ return $this->__RESPONSE; } + + /** + * This method sets the last response from the API + * @return array|mixed + */ public function setResponseData($response){ $this->__RESPONSE = $response; } @@ -82,15 +117,12 @@ public function GetResellerDetails() { "request" => [ "Password" => $this->_USERDATA_PASSWORD, "UserName" => $this->_USERDATA_USERNAME, - 'CurrencyId'=>2 + 'CurrencyId'=>2 // 1: TRY, 2: USD ] ]; - //self::setRequestData($parameters); - $response = self::parseCall(__FUNCTION__, $parameters, function ($response) { - //self::setResponseData($response); $data = $response[key($response)]; $resp = []; @@ -127,18 +159,12 @@ public function GetResellerDetails() { } - - return $resp; }); - // Log last request and response - //self::setRequestData($parameters); - - return $response; } @@ -155,20 +181,15 @@ public function GetCurrentBalance() { ]; - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) { - //self::setResponseData($response); - return $response['GetCurrentBalanceResult']; }); - // Log last request and response - //self::setRequestData($parameters); return $response; } @@ -195,12 +216,8 @@ public function CheckAvailability($Domains, $TLDs, $Period, $Command) { ]; - - //self::setRequestData($parameters); - $response = self::parseCall(__FUNCTION__, $parameters, function ($response) { - //self::setResponseData($response); //return $response; @@ -260,15 +277,9 @@ public function GetList($extra_parameters=[]) { $parameters['request'][$k] = $v; } - - - //self::setRequestData($parameters); - $response = self::parseCall(__FUNCTION__, $parameters, function ($response) { - //self::setResponseData($response); - $data = $response[key($response)]; @@ -322,13 +333,9 @@ public function GetTldList($count = 20) { ]; - //self::setRequestData($parameters); - - $result = self::parseCall(__FUNCTION__,$parameters, function ($response) { - //self::setResponseData($response); $data = $response[key($response)]; @@ -399,14 +406,9 @@ public function GetDetails($DomainName) { ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) { - //self::setResponseData($response); - - $data = $response[key($response)]; // If DomainInfo a valid array @@ -442,16 +444,14 @@ public function ModifyNameServer($DomainName, $NameServers) { "Password" => $this->_USERDATA_PASSWORD, "UserName" => $this->_USERDATA_USERNAME, "DomainName" => $DomainName, - "NameServerList" => $NameServers + "NameServerList" => array_values($NameServers) ] ]; - // Log last request and response - //self::setRequestData($parameters); + $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($parameters); $data = $response[key($response)]; @@ -482,13 +482,8 @@ public function EnableTheftProtectionLock($DomainName) { ] ]; - - // Log last request and response - //self::setRequestData($parameters); - $response = self::parseCall(__FUNCTION__, $parameters, function ($response) { - //self::setResponseData($response); return [ 'data' => [ @@ -521,11 +516,8 @@ public function DisableTheftProtectionLock($DomainName) { ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) { - //self::setResponseData($response); return [ 'data' => [ @@ -560,11 +552,8 @@ public function AddChildNameServer($DomainName, $NameServer, $IPAdresses) { ]; - // Log last request and response - //self::setRequestData($parameters); - $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use($parameters) { - //self::setResponseData($response); + return [ 'data' => [ 'NameServer' => $parameters["request"]["ChildNameServer"], @@ -594,12 +583,9 @@ public function DeleteChildNameServer($DomainName, $NameServer) { ] ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use($parameters) { - //self::setResponseData($response); return [ 'data' => [ @@ -634,11 +620,8 @@ public function ModifyChildNameServer($DomainName, $NameServer, $IPAdresses) { ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use($parameters) { - //self::setResponseData($response); return [ 'data' => [ @@ -671,11 +654,10 @@ public function GetContacts($DomainName) { ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); + + $data = $response[key($response)]; $result = []; @@ -732,11 +714,8 @@ public function SaveContacts($DomainName, $Contacts) { ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); $data = $response[key($response)]; @@ -789,10 +768,8 @@ public function Transfer($DomainName, $AuthCode, $Period) { ] ]; - // Log last request and response - //self::setRequestData($parameters); + $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); $result = []; $data = $response[key($response)]; @@ -835,15 +812,11 @@ public function CancelTransfer($DomainName) { ] ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); - $data = $response[key($response)]; return [ @@ -872,14 +845,9 @@ public function ApproveTransfer($DomainName) { ] ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - - //self::setResponseData($response); - $data = $response[key($response)]; return [ @@ -906,15 +874,10 @@ public function RejectTransfer($DomainName) { ] ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - - //self::setResponseData($response); - $data = $response[key($response)]; return [ @@ -945,12 +908,8 @@ public function Renew($DomainName, $Period) { ] ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); - $data = $response[key($response)]; return [ @@ -1002,10 +961,7 @@ public function RegisterWithContactInfo($DomainName, $Period, $Contacts, $NameSe } - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); $result = []; $data = $response[key($response)]; @@ -1061,10 +1017,8 @@ public function ModifyPrivacyProtectionStatus($DomainName, $Status, $Reason = "O ] ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); + return [ 'data'=>[ 'PrivacyProtectionStatus'=>$parameters["request"]["ProtectPrivacy"] @@ -1093,10 +1047,7 @@ public function SyncFromRegistry($DomainName) { ] ]; - // Log last request and response - //self::setRequestData($parameters); $response = self::parseCall(__FUNCTION__, $parameters, function ($response) use ($parameters) { - //self::setResponseData($response); $result = []; $data = $response[key($response)]; @@ -1130,7 +1081,7 @@ public function SyncFromRegistry($DomainName) { private function objectToArray($_obj) { try { $_obj = json_decode(json_encode($_obj), true); - } catch (\DomainNameApi\Exception $ex) { + } catch (\Exception $ex) { } return $_obj; } @@ -1654,6 +1605,7 @@ private function parseCall($fn,$parameters, $_callback){ try { + // SOAP method which is same as current function name called $_response = $this->service->__soapCall($fn, [$parameters]); @@ -1684,7 +1636,7 @@ private function parseCall($fn,$parameters, $_callback){ } catch (\SoapFault $ex) { $result["result"] = "ERROR"; $result["error"] = $this->setError('INVALID_RESPONSE','Invalid Response occured',$ex->getMessage()); - } catch (Exception $ex) { + } catch (\Exception $ex) { $result["result"] = "ERROR"; $result["error"] = $this->parseError($this->objectToArray($ex)); } diff --git a/modules/addons/dnaextended/app/module.php b/modules/addons/dnaextended/app/module.php index 6f83a67..5900692 100755 --- a/modules/addons/dnaextended/app/module.php +++ b/modules/addons/dnaextended/app/module.php @@ -18,6 +18,46 @@ class module { + public static function functionEnabled($function) + { + $disabledFunctions = preg_split("/\\s*\\,\\s*/", trim(ini_get("disable_functions"))); + return (bool) ($function !== "" && !in_array(strtolower($function), $disabledFunctions)); + } + public function isFunctionAvailable($function) + { + return function_exists($function) && self::functionEnabled($function); + } + + + public function getPreferredCliBinary() { + try { + if (static::isFunctionAvailable("php_ini_loaded_file")) { + $iniPath = php_ini_loaded_file(); + if (strpos($iniPath, "/opt/cpanel/") === 0) { + $phpBinary = preg_replace("/etc\\/php.ini\$/", "usr/bin/php", $iniPath); + if (file_exists($phpBinary)) { + return $phpBinary; + } + } + } + } catch (\Error $e) { + } catch (\Exception $e) { + } + + $potentialPhpBinaries = array( + "/usr/bin/php-cli", + "/usr/local/bin/php-cli", + "/usr/bin/php", + "/usr/local/bin/php" + ); + foreach ($potentialPhpBinaries as $phpBinary) { + if (file_exists($phpBinary)) { + return $phpBinary; + } + } + return "php"; + } + public function makeSync(){ diff --git a/modules/addons/dnaextended/app/view/admin/layout.tpl b/modules/addons/dnaextended/app/view/admin/layout.tpl index de30e27..c2036b1 100755 --- a/modules/addons/dnaextended/app/view/admin/layout.tpl +++ b/modules/addons/dnaextended/app/view/admin/layout.tpl @@ -79,6 +79,7 @@ text_search_client : '{$_lang.text_search_client}', syncinfo : '{$_lang.syncinfo}', loading : '{$_lang.loading}', + btn_import : '{$_lang.btn_import}', btn_sync : '{$_lang.btn_sync}', btn_contact : '{$_lang.btn_contact}', btn_ns : '{$_lang.btn_ns}', diff --git a/modules/addons/dnaextended/app/view/admin/settings.tpl b/modules/addons/dnaextended/app/view/admin/settings.tpl index a501f89..f4f81a9 100644 --- a/modules/addons/dnaextended/app/view/admin/settings.tpl +++ b/modules/addons/dnaextended/app/view/admin/settings.tpl @@ -15,7 +15,7 @@ {$_lang.cron_settings} - */10 * * * * {$cronfile} + */10 * * * * {$cronbinary} -q {$cronfile} diff --git a/modules/addons/dnaextended/assets/module.domains.js b/modules/addons/dnaextended/assets/module.domains.js index d06101a..9da9e23 100644 --- a/modules/addons/dnaextended/assets/module.domains.js +++ b/modules/addons/dnaextended/assets/module.domains.js @@ -150,7 +150,7 @@ $(document).on('event.domains', function() { }); _buttons.push({ id : 'rejectoutbtn', - text : window._lang.btm_reject, + text : window._lang.btn_reject, icon : 'fa-arrow-circle-right', classes : 'btn-outline-danger btn-outline', onlydefault: false, @@ -204,7 +204,7 @@ $(document).on('event.domains', function() { selection_buttons += ' '+window._lang.btn_ns+' '; selection_buttons += ' '+window._lang.btn_lock+' '; selection_buttons += ' '+window._lang.btn_approve+' '; - selection_buttons += ' '+window._lang.btm_reject+' '; + selection_buttons += ' '+window._lang.btn_reject+' '; selection_buttons += ' '+window._lang.btn_cancel+' '; $('.actionbuttons').html(selection_buttons); diff --git a/modules/addons/dnaextended/dnaextended.php b/modules/addons/dnaextended/dnaextended.php index a51963a..6a70a15 100755 --- a/modules/addons/dnaextended/dnaextended.php +++ b/modules/addons/dnaextended/dnaextended.php @@ -93,6 +93,7 @@ function dnaextended_output($vars) { $parameters = $vars; + require_once __DIR__ . '/app/module.php'; $module = new \DNA_Extended\module();