Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if( file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'errorHandler.php') )
- {
- require_once __DIR__ . DIRECTORY_SEPARATOR . 'errorHandler.php';
- }
- else
- {
- echo "some required components are missing";
- }
- class whmApi
- {
- protected $username;
- protected $user;
- protected $password;
- protected $domain;
- protected $contactemail;
- protected $reason;
- public function __construct($datatable)
- {
- $this->setData('username', $datatable['username']);
- $this->setData('user', $datatable['user']);
- $this->setData('password', $datatable['password']);
- $this->setData('domain', $datatable['domain']);
- $this->setData('contactemail', $datatable['email']);
- $this->setData('reason', $datatable['reason']);
- }
- function setData($field, $value)
- {
- $this->$field = $value ? $value : null;
- }
- public static function execute($action, $user, $serverDetails)
- {
- $query = $action . "?api.version=1&" . http_build_query($user, '', '&');
- $whmusername = $serverDetails['username'];
- $whmpassword = $serverDetails['password'];
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($curl, CURLOPT_HEADER, 0);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- $header[0] = "Authorization: Basic " . base64_encode($whmusername . ":" . $whmpassword) . "\n\r";
- curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
- $query = "https://" . $serverDetails['ip'] . ":2087/json-api/" . $query;
- curl_setopt($curl, CURLOPT_URL, $query);
- $result = curl_exec($curl);
- $errorHandler = new errorHandler($curl, $result);
- $result = $errorHandler->getDecodedResult();
- curl_close($curl);
- return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement