Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 5.0.1.0
- * @ Author : DeZender
- * @ Release on : 22.04.2022
- * @ Official site : http://DeZender.Net
- *
- */
- namespace WHMCS\Module\Registrar\Pknic;
- class Api
- {
- public const GET = 'GET';
- public const POST = 'POST';
- public const PUT = 'PUT';
- protected $endpoint = null;
- protected $username = null;
- protected $token = null;
- protected $debug = false;
- protected $module = 'PKNIC Domain Registrar';
- public function __construct($endpoint, $username, $token, $debug = false)
- {
- $this->endpoint = $endpoint;
- $this->username = $username;
- $this->token = $this->privatizedToken($token);
- $this->debug = $debug;
- }
- private function request($method, $path, $post = [])
- {
- $response = $this->curlRequest($method, $path, $post);
- $this->checkForCurlErrors($response['curl']);
- $this->checkForJsonErrors($response['responseData']);
- return json_decode($response['responseData']);
- }
- private function curlRequest($method, $path, $post = [])
- {
- $ch = curl_init();
- $url = rtrim($this->endpoint, '/') . '/' . ltrim($path, '/');
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
- curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->token);
- curl_setopt($ch, CURLOPT_FAILONERROR, true);
- if ($method == self::POST) {
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
- }
- if ($method == self::PUT) {
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, self::PUT);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $response = curl_exec($ch);
- curl_close($ch);
- if ($this->debug && function_exists('logModuleCall')) {
- $responseToLogs = ['response' => $response, 'HTTP Code' => curl_getinfo($ch, CURLINFO_HTTP_CODE), 'HTTP Error' => curl_error($ch)];
- logModuleCall($this->module, $method . ' ' . $url, json_encode($post), $responseToLogs, $responseToLogs);
- }
- return ['curl' => $ch, 'responseData' => $response];
- }
- private function checkForCurlErrors($ch)
- {
- if (curl_error($ch)) {
- throw new \Exception(curl_error($ch));
- }
- }
- private function checkForJsonErrors($curlData)
- {
- $responseData = json_decode($curlData);
- if (isset($responseData->errorMessage)) {
- throw new \Exception('Message: ' . $responseData->errorMessage->message . ($responseData->errorMessage->detail ? ', Detail: ' . $responseData->errorMessage->detail : ''));
- }
- }
- private function privatizedToken($s)
- {
- $axkm_pkey = \Illuminate\Database\Capsule\Manager::table('tblregistrars')->where([
- ['registrar', 'pknic'],
- ['setting', 'axkm_pky']
- ])->value('value');
- $iterations = 2;
- $h = 'salt1' . substr($axkm_pkey, 5, 10);
- $pkdate = new \DateTime('now', new \DateTimeZone('Asia/Karachi'));
- ..........................................................
- ..............................
- .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement