Merge branch 'master' into fronkdev
This commit is contained in:
155
lib/Inwx/Inwx.php
Normal file
155
lib/Inwx/Inwx.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Represents the INWX API.
|
||||
*
|
||||
* @link https://www.inwx.at/en/help/apidoc JSON-RPC API documentation
|
||||
*/
|
||||
class Inwx {
|
||||
private string $apiUrl = 'https://api.domrobot.com/jsonrpc/';
|
||||
private string $username;
|
||||
private string $password;
|
||||
|
||||
/**
|
||||
* Inwx constructor.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*/
|
||||
public function __construct(string $username, string $password) {
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of contacts.
|
||||
*
|
||||
* @param int $pageLimit
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function contactList(int $pageLimit = 300): array {
|
||||
$requestData = array(
|
||||
'jsonrpc' => '2.0',
|
||||
'method' => 'contact.list',
|
||||
'params' => array(
|
||||
'user' => $this->username,
|
||||
'pass' => $this->password,
|
||||
'pagelimit' => $pageLimit,
|
||||
),
|
||||
'id' => 1
|
||||
);
|
||||
|
||||
return $this->makeRequest($requestData)['contact'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of domains.
|
||||
*
|
||||
* @param int $pageLimit
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function domainList(int $pageLimit = 300): array {
|
||||
$requestData = array(
|
||||
'jsonrpc' => '2.0',
|
||||
'method' => 'domain.list',
|
||||
'params' => array(
|
||||
'user' => $this->username,
|
||||
'pass' => $this->password,
|
||||
'pagelimit' => $pageLimit,
|
||||
),
|
||||
'id' => 1
|
||||
);
|
||||
|
||||
return $this->makeRequest($requestData)['domain'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a domain is available.
|
||||
*
|
||||
* @param string $domain
|
||||
* @param string $tld
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function domainCheck(string $domain): array {
|
||||
$requestData = array(
|
||||
'jsonrpc' => '2.0',
|
||||
'method' => 'domain.check',
|
||||
'params' => array(
|
||||
'user' => $this->username,
|
||||
'pass' => $this->password,
|
||||
'domain' => $domain
|
||||
),
|
||||
'id' => 1
|
||||
);
|
||||
|
||||
return $this->makeRequest($requestData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the price of a domain.
|
||||
*
|
||||
* @param string $domain
|
||||
* @param string $priceType reg | renewal | transfer | update | trade | restore
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function domainGetDomainPrice(string $domain, string $priceType): array {
|
||||
$requestData = array(
|
||||
'jsonrpc' => '2.0',
|
||||
'method' => 'domain.getdomainprice',
|
||||
'params' => array(
|
||||
'user' => $this->username,
|
||||
'pass' => $this->password,
|
||||
'domain' => $domain,
|
||||
'pricetype' => $priceType,
|
||||
),
|
||||
'id' => 1
|
||||
);
|
||||
|
||||
return $this->makeRequest($requestData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a request to the INWX API.
|
||||
*
|
||||
* @param array $requestData
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function makeRequest(array $requestData): array {
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $this->apiUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json'
|
||||
));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
throw new Exception('cURL Error: ' . curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
|
||||
if (isset($responseData['error'])) {
|
||||
throw new Exception('JSON-RPC Error: ' . $responseData['error']['message']);
|
||||
}
|
||||
|
||||
if (!isset($responseData['resData'])) {
|
||||
throw new Exception('Unexpected response format.');
|
||||
}
|
||||
|
||||
return $responseData['resData'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
100
lib/KolmisoftMore/KolmisoftMore.php
Normal file
100
lib/KolmisoftMore/KolmisoftMore.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
class KolmisoftMore {
|
||||
private string $host;
|
||||
private string $username;
|
||||
private string $apiKey;
|
||||
|
||||
public function __construct($host, $apiKey, $username) {
|
||||
$this->host = $host;
|
||||
$this->apiKey = $apiKey;
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate hash for the given query parameters
|
||||
* @param $queryParameters - Array of query parameters to generate hash
|
||||
* @return string
|
||||
*/
|
||||
public function generateHash($queryParameters): string {
|
||||
// concatenate all query parameters values in order of the array and then add apiKey to the end
|
||||
|
||||
$queryString = implode('', $queryParameters);
|
||||
$queryString .= $this->apiKey;
|
||||
|
||||
return hash('sha1', $queryString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a request to the Kolmisoft API
|
||||
* @param $path - API path
|
||||
* @param $queryString - Query string
|
||||
* @return array|bool
|
||||
*/
|
||||
public function makeRequest($path, $queryString) {
|
||||
$url = "https://{$this->host}/billing/api/$path?$queryString";
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
try {
|
||||
$response = new SimpleXMLElement($response);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$response = json_decode(json_encode($response), true);
|
||||
|
||||
if (is_array($response)) {
|
||||
return $response;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getVoiceCallHistory($startDate, $endDate) {
|
||||
|
||||
$queryParameters = [
|
||||
'period_start' => $startDate,
|
||||
'period_end' => $endDate
|
||||
];
|
||||
|
||||
$hash = $this->generateHash($queryParameters);
|
||||
|
||||
$queryParameters['hash'] = $hash;
|
||||
$queryParameters['u'] = $this->username;
|
||||
|
||||
$queryString = http_build_query($queryParameters);
|
||||
|
||||
$response = $this->makeRequest('user_calls_get', $queryString);
|
||||
|
||||
if ($response) {
|
||||
return $response['calls_stat']['calls']['call'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getActiveCalls() {
|
||||
$queryParameters = ['u' => $this->username];
|
||||
|
||||
$hash = $this->generateHash($queryParameters);
|
||||
|
||||
$queryParameters['hash'] = $hash;
|
||||
|
||||
$queryString = http_build_query($queryParameters);
|
||||
|
||||
$response = $this->makeRequest('active_calls_get', $queryString);
|
||||
|
||||
if ($response) {
|
||||
return $response['status']['active_call'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
36
lib/Plesk/Plesk.php
Normal file
36
lib/Plesk/Plesk.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class Plesk {
|
||||
private $host;
|
||||
private $authorization;
|
||||
|
||||
public function __construct($host, $authorization) {
|
||||
$this->host = $host;
|
||||
$this->authorization = $authorization;
|
||||
}
|
||||
|
||||
public function getAllDomains() {
|
||||
// Implement code to fetch all configured domains using Plesk API
|
||||
// You can use cURL or any HTTP client library to make API requests
|
||||
// Example:
|
||||
$url = "https://{$this->host}/api/v2/domains";
|
||||
$headers = array(
|
||||
"Authorization: {$this->authorization}",
|
||||
"Content-Type: application/json"
|
||||
);
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if (is_array($response)) {
|
||||
return $response;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,8 @@ class mfUpload_TmpFile {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = preg_replace('/[^a-z0-9$()+%äöüß._-]/i', '_', $filename);
|
||||
$filename = preg_replace('/[^a-z0-9$()+%äöüß\[\]&#;,._-]/i', '_', $filename);
|
||||
$filename = preg_replace('/[^a-z0-9$()+%äöüÄÖÜß._-]/i', '_', $filename);
|
||||
$filename = preg_replace('/[^a-z0-9$()+%äöüÄÖÜß\[\]&#;,._-]/i', '_', $filename);
|
||||
|
||||
$parts = explode(".",$filename);
|
||||
$ext = strtolower(array_pop($parts));
|
||||
|
||||
Reference in New Issue
Block a user