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);
    }
}
function stregistry_Sync($params)
{
    // init connection
    if (($status = __initConnectionAndAuthorize($params)) !== true) {
        return __errorArray($status);
    }
    // fetch domain
    $json = STRegistry::Domains()->query($params['domain']);
    if (!ResponseHelper::isSuccess($json)) {
        $response = ResponseHelper::fromJSON($json);
        if ($response->code == 2303 || $response->code == 2203) {
            // domain does not already exists or not own by current registarar
            __markWHMCSDomainCancelled($params['domainid']);
            return array('active' => false, 'expired' => false);
        } else {
            return __errorArray($response->message);
        }
    }
    $domain = Domain::fromJSON($json);
    if ($domain->getDateExpire() < time()) {
        return array('expired' => true);
    }
    return array('active' => true, 'expired' => false, 'expirydate' => $domain->getDateExpire('Y-m-d'));
}