Update high
This commit is contained in:
38
TeaSpeak/servers/teamspeak/hooks.php
Normal file
38
TeaSpeak/servers/teamspeak/hooks.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/lib/Requests.php";
|
||||
require_once __DIR__ . "/lib/TSDNS.php";
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
function hook_check_subdomain(array $params)
|
||||
{
|
||||
try {
|
||||
$settings = Capsule::table('modwhmcs_teamspeak_settings')->select('enabletsdns', 'domaintsdns', 'urlapi', 'keyapi')->first();
|
||||
|
||||
if ($settings->enabletsdns) {
|
||||
|
||||
$tsdnsClient = new TSDNS($settings->urlapi, $settings->keyapi);
|
||||
|
||||
if (!$tsdnsClient) {
|
||||
throw new Exception('The subdomains availability could not be checked. Contact support.');
|
||||
}
|
||||
|
||||
$id = Capsule::table('tblcustomfields')->where('fieldname', 'Subdomain')->value('id');
|
||||
|
||||
$request = $tsdnsClient->getZone($params['customfield'][$id] . '.' . $settings->domaintsdns);
|
||||
|
||||
$zone = json_decode($request->body);
|
||||
|
||||
if (count($zone->message)) {
|
||||
throw new Exception('Subdomain is already in use');
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$errors = array();
|
||||
$errors[] = $e->getMessage();
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
add_hook("ShoppingCartValidateProductUpdate", 1, "hook_check_subdomain");
|
||||
Reference in New Issue
Block a user