示例#1
0
 /**
  *  Check the domain availability
  *  @return template
  */
 public function bulkdomainsAction()
 {
     $request = $this->getRequest();
     $session = new Zend_Session_Namespace('Default');
     $i = 0;
     try {
         $form = new Default_Form_BulkdomainsForm(array('action' => '/common/bulkdomains', 'method' => 'post'));
         if ($request->getPost()) {
             if ($form->isValid($request->getPost())) {
                 $params = $form->getValues();
                 if (!empty($params['domains'])) {
                     $checker = new Shineisp_Commons_DomainChecker();
                     $tlds = $request->getParam('tlds');
                     // Clear the temporary domains of the customer
                     if ($session->customer) {
                         $customerId = $session->customer['customer_id'];
                         DomainsBulk::findbyCustomerID($customerId)->delete();
                     } else {
                         $customerId = null;
                     }
                     $domains = explode("\n", $params['domains']);
                     foreach ($domains as $domain) {
                         foreach ($tlds as $tld) {
                             $tldinfo = DomainsTlds::getAllInfo($tld);
                             $domain = Shineisp_Commons_UrlRewrites::format($domain);
                             $domainame = $domain . "." . $tldinfo['DomainsTldsData'][0]['name'];
                             $isAvailable = $checker->checkDomainAvailability($domainame);
                             DomainsBulk::add_domain($domainame, $tld, $isAvailable, $customerId);
                         }
                     }
                     $this->_helper->redirector('bulkdomainsorder', 'common', 'default');
                 }
             }
         }
     } catch (Exception $e) {
         $this->_helper->redirector('index', 'index', 'default', array('mex' => $e->getMessage(), 'status' => 'danger'));
     }
     $this->view->form = $form;
     $this->getHelper('layout')->setLayout('1column');
 }
示例#2
0
 /**
  * Check the domain availability
  * @param $name
  * @param $tldid
  * @return boolean
  */
 public static function check_availability($name, $tldid)
 {
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $dchecker = new Shineisp_Commons_DomainChecker();
     if (!empty($name)) {
         $record = DomainsTlds::getAllInfo($tldid);
         if (!empty($record)) {
             if (!empty($record['name'])) {
                 $domain = $name . "." . $record['name'];
                 if (Shineisp_Commons_Utilities::is_valid_domain_name($domain)) {
                     if ($dchecker->checkDomainAvailability($domain)) {
                         return true;
                     } else {
                         return false;
                     }
                 }
             } else {
                 throw new Exception($translator->_('TLD name have been not set in the administration panel yet'));
             }
             throw new Exception($translator->_('Domain name is not correct: %s', $domain));
         }
         throw new Exception($translator->translate("TLD {$tldid} has been not found!"));
     }
     throw new Exception($translator->translate('Domain name is empty!'));
 }