Пример #1
0
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);
    }
}
Пример #2
0
 protected function __construct()
 {
     if (!self::$_inited) {
         ApiRequest::init(array('api' => array('host' => STRegistry::getAPIHost(), 'port' => STRegistry::getAPIPort(), 'ssl' => STRegistry::isSSLEnabled(), 'version' => STRegistry::getAPIVersion(), 'userAgent' => STRegistry::getAPIUserAgent(), 'content-type' => STRegistry::getAPIContentType()), 'debug' => false, 'connector' => 'ApiConnectorCURL'));
         self::$_inited = true;
     }
 }
 /**
  * Initialization
  * 
  * @param str $apiHost REST API host
  * @param int $apiPort REST API port
  * @return void;
  */
 public static function Init($apiHost, $apiPort = 80, $useSSL = false, $apiVersion = '1.0', $apiUserAgent = 'RESTAPI-PHP-WRAPPER', $apiContentType = 'application/json')
 {
     self::$_apiHost = $apiHost;
     self::$_apiPort = $apiPort;
     self::$_apiUseSSL = $useSSL;
     self::$_apiVersion = $apiVersion;
     self::$_apiUserAgent = $apiUserAgent;
     self::$_apiContentType = $apiContentType;
     return;
 }
/**
 * init wrapper and send authorization request
 * 
 * @param array $params module configurations
 * 
 * @return mixed true if authorization was sucessfull, error message in other case
 */
function __initConnectionAndAuthorize($params)
{
    if (!class_exists('STRegistry')) {
        require_once sprintf('%s%2$sclasses%2$swrapper%2$sSTRegistry.php', dirname(__FILE__), DIRECTORY_SEPARATOR);
        require_once sprintf('%s%2$sclasses%2$swrapper%2$sResponseHelper.php', dirname(__FILE__), DIRECTORY_SEPARATOR);
        require_once sprintf('%s%2$sclasses%2$sSTRegistryPrivacyContact.php', dirname(__FILE__), DIRECTORY_SEPARATOR);
    }
    STRegistry::Init($params['apiHost'], $params['apiHost'], $params['apiUseSSL'] === 'on', $params['apiVersion'] ?: '1.0', $params['apiUserAgent']);
    $json = STRegistry::Session()->login($params['apiUsername'], $params['apiPassword']);
    if (!ResponseHelper::isSuccess($json)) {
        return ResponseHelper::fromJSON($json)->message;
    }
    return true;
}
Пример #5
0
 /**
  * Make search over registrar notifications collection
  * 
  * @param SearchCriteria $criteria  Prepared search filters
  * @param int $limit results limit	
  * @param int $offset start rowset from
  * @param array $sort rowset sort rule array('field' => 'asc|desc')
  * 
  * @return str json response
  */
 public function search(SearchCriteria $criteria, $limit = 100, $offset = 0, array $sort = array(), $cltrid = false)
 {
     $get = $criteria->getCriteria();
     $get['do'] = 'search';
     $get['limit'] = $limit;
     $get['offset'] = $offset;
     foreach ($sort as $field => $direction) {
         $get['sort_field'] = $field;
         $get['sort_direction'] = $direction;
         // sorry. just one field
         break;
     }
     $json = APIRequest::GET('/notifications/', $cltrid ?: APIRequest::defaultClientTransactionID(), STRegistry::Session()->getAuthToken(), $get);
     return $json;
 }
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'));
}
 /**
  * Performs remote object validation
  * 
  * @return boolean
  */
 public function validate()
 {
     // clean up errors
     parent::validate();
     $response = ResponseHelper::fromJSON(STRegistry::Contacts()->validate($this));
     if ($response->code != 1000) {
         $this->setValidationErrorCode($response->code)->setValidationErrorMessage($response->message);
         return false;
     }
     return true;
 }
Пример #8
0
 /**
  * Return registrar billing details
  * 
  * @return str json response
  */
 public function billingRecords($cltrid = false)
 {
     $json = APIRequest::GET(sprintf('/billing/%s', STRegistry::Session()->getLogin()), $cltrid ?: APIRequest::defaultClientTransactionID(), STRegistry::Session()->getAuthToken());
     return $json;
 }