function hook_stregistrar_ClientAreaHeaderOutput($params) { $errors = array(); if ($params['clientareaaction'] == 'domainregisterns') { global $smarty; global $db_host; if (($status = __initConnectionAndAuthorize(__getSTRegistrarModuleConfig())) === false) { return $errors[] = $status; } $filter = new SearchCriteria(); $filter->name->like("%." . $params['domain']); $json = STRegistry::Hosts()->search($filter, 30); if (!ResponseHelper::isSuccess($json)) { return $errors[] = ResponseHelper::fromJSON($json)->message; } $hosts = ResponseHelper::fromJSON($json, 'searchRes')->result; $gluerecords = array(); foreach ($hosts as $host) { if (count($host['addr'])) { foreach ($host['addr'] as $record) { $keys = array_keys($record); $type = array_shift($keys); $addr = array_shift($record); $gluerecords[] = array('hostname' => $host['name'], 'address' => $addr, 'type' => $type == Host::IP_VERSION_4 ? 'IPv4' : 'IPv6'); } } else { $gluerecords[] = array('hostname' => $host['name']); } } $smarty->assign('module', "stregistry"); $smarty->assign('gluerecords', $gluerecords); } }
/** * make request to remove hostname * * @param array $params whmcs data * * @return mixed array containig error message will return if error was ocurred, 'success' string in other case */ function stregistry_DeleteNameserver($params) { global $_LANG; // init connection if (($status = __initConnectionAndAuthorize($params)) !== true) { return __errorArray($status); } // drop host $json = STRegistry::Hosts()->delete($params['nameserver']); if (!ResponseHelper::isSuccess($json)) { $response = ResponseHelper::fromJSON($json); if ($response->code == 2304) { return __errorArray($_LANG['ordererrorserverhostnameinuse']); } else { return __errorArray($response->message); } } return 'success'; }
private function getRequestDataForUpdate(Host $host) { $data = array('add' => array(), 'rem' => array()); $json = STRegistry::Hosts()->query($host->getName()); $currentHost = Host::fromJSON($json); foreach (array_merge($host->getIPv4(), $host->getIPv6()) as $id => $ip) { if (!in_array($ip, array_merge($currentHost->getIPv4(), $currentHost->getIPv6()))) { if (!isset($data['add']['addr'])) { $data['add']['addr'] = array(); } $data['add']['addr'][] = array($id => array('version' => CommonFunctions::detectIPType($ip), 'address' => $ip)); } } foreach (array_merge($currentHost->getIPv4(), $currentHost->getIPv6()) as $id => $ip) { if (!in_array($ip, array_merge($host->getIPv4(), $host->getIPv6()))) { if (!isset($data['rem']['addr'])) { $data['rem']['addr'] = array(); } $data['rem']['addr'][] = array($id => array('version' => CommonFunctions::detectIPType($ip), 'address' => $ip)); } } foreach ($host->getStatuses() as $status) { if (!in_array($status, $currentHost->getStatuses())) { if (!isset($data['add']['status'])) { $data['add']['status'] = array(); } $data['add']['status'][] = $status; } } foreach ($currentHost->getStatuses() as $status) { if (!in_array($status, $host->getStatuses())) { if (!isset($data['rem']['status'])) { $data['rem']['status'] = array(); } $data['rem']['status'][] = $status; } } return $data; }