Ejemplo n.º 1
0
 public function checkdomainAction()
 {
     $currency = Shineisp_Registry::getInstance()->Zend_Currency;
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $request = $this->getRequest();
     try {
         if ($request->getPost()) {
             $params = $request->getPost();
             $available = Domains::check_availability($params['name'], $params['tld']);
             $data = DomainsTlds::getAllInfo($params['tld']);
             $tldName = $data['WhoisServers']['tld'];
             // Create the domain name
             $domain = $params['name'] . "." . $tldName;
             if ($available) {
                 $price = $data['registration_price'];
                 // Get the price of the product
             } else {
                 $price = $data['transfer_price'];
             }
             if (!empty($data['Taxes']['percentage']) && is_numeric($data['Taxes']['percentage'])) {
                 $formatPrice = $currency->toCurrency($price * ($data['Taxes']['percentage'] + 100) / 100, array('currency' => Settings::findbyParam('currency')));
             } else {
                 $formatPrice = $currency->toCurrency($price, array('currency' => Settings::findbyParam('currency')));
             }
             // Format the price number
             $strprice = $translator->translate('just') . " {$formatPrice}!";
             // Create the message
             $mex = $available ? $translator->translate('The domain is available for registration') : $translator->translate("The domain is unavailable for registration, but if you are the domain owner, you can transfer it!");
             // Reply with JSON code
             die(json_encode(array('available' => $available, 'name' => $params['name'], 'tld' => $params['tld'], 'price' => $strprice, 'domain' => $domain, 'mex' => $mex)));
         }
     } catch (Exception $e) {
         die(json_encode(array('mex' => $e->getMessage())));
     }
 }
Ejemplo n.º 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!'));
 }
Ejemplo n.º 3
0
 public function checkdomainAction()
 {
     try {
         $session = new Zend_Session_Namespace('Default');
         // Get all the params sent by the customer
         $params = $this->getRequest()->getParams();
         // redirect the customer to the contact form
         if (!empty($params['mode']) && $params['mode'] == "nothing") {
             $this->_helper->redirector('contacts');
             return true;
         }
         if (empty($params['domain']) || empty($params['tlds'])) {
             $this->_helper->redirector('domain', 'cart', 'default', array('mex' => 'The domain is a mandatory field. Choose a domain name.', 'status' => 'danger'));
         }
         // Get the product (tld) selected by the customer
         $tldInfo = DomainsTlds::getAllInfo($params['tlds']);
         // Check if the parameter exists in our database
         if (isset($tldInfo['tld_id'])) {
             // If the owner of the domain wants to transfer the domain ...
             if (!empty($params['mode']) && $params['mode'] == "link") {
                 if (!empty($tldInfo)) {
                     // create the domain name
                     $domain = trim(strtolower($params['domain'])) . "." . $tldInfo['DomainsTldsData'][0]['name'];
                     // get the hosting item added in the cart
                     $hostingItem = $session->cart->getHostingItem();
                     // attach the domain name to the hosting plan
                     if ($hostingItem) {
                         $session->cart->attachDomain($hostingItem, $domain, $tldInfo['tld_id'], "transferDomain");
                     }
                     // redirect the customer to the contact form
                     $this->_helper->redirector('contacts');
                 }
             } else {
                 // If the domain is still free and the customer needs to register it then ...
                 $strDomain = $params['domain'] . "." . $tldInfo['DomainsTldsData'][0]['name'];
                 // Check if the domain is still free
                 $result = Domains::isAvailable($params['domain'] . "." . $tldInfo['DomainsTldsData'][0]['name']);
                 if ($result) {
                     // If it is free
                     // create the domain name
                     $domain = trim(strtolower($params['domain'])) . "." . $tldInfo['DomainsTldsData'][0]['name'];
                     // get the hosting item added in the cart
                     $hostingItem = $session->cart->getHostingItem();
                     // attach the domain name to the hosting plan
                     if ($hostingItem) {
                         $session->cart->attachDomain($hostingItem, $domain, $tldInfo['tld_id'], "registerDomain");
                     }
                     // Redirect the user to the
                     $this->_helper->redirector('contacts', 'cart', 'default', array('mex' => 'The domain is available for registration', 'status' => 'success'));
                 } else {
                     // If not redirect the customer to choose another name
                     $this->_helper->redirector('domain', 'cart', 'default', array('mex' => 'The domain is not available for registration. Choose another domain name.', 'status' => 'danger'));
                 }
             }
         }
         $this->_helper->redirector('domain', 'cart', 'default', array('mex' => 'The domain is available for registration', 'status' => 'success'));
     } catch (Exception $e) {
         $this->_helper->redirector('index', 'index', 'default', array('mex' => $e->getMessage()));
     }
 }
Ejemplo n.º 4
0
 /**
  *  Check the domain availability
  */
 public function checkAction()
 {
     $currency = Shineisp_Registry::getInstance()->Zend_Currency;
     $form = new Default_Form_DomainsinglecheckerForm(array('action' => '/domainschk/check', 'method' => 'post'));
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $request = $this->getRequest();
     try {
         if ($request->getPost()) {
             $params = $request->getPost();
             // Delete spaces, symbols, dots, commas, spaces, etc...
             $params['name'] = Shineisp_Commons_UrlRewrites::format($params['name']);
             $available = Domains::check_availability($params['name'], $params['tld']);
             $data = DomainsTlds::getAllInfo($params['tld']);
             $tldName = $data['DomainsTldsData'][0]['name'];
             // Create the domain name
             $domain = $params['name'] . "." . $tldName;
             // Domain Price
             $price = $available ? $data['registration_price'] : $data['transfer_price'];
             $taxpercent = $data['Taxes']['percentage'];
             // Format the price number
             $strprice = $currency->toCurrency($price * ($taxpercent + 100) / 100, array('currency' => Settings::findbyParam('currency')));
             // Create the message
             $mex = $available ? $translator->translate('The domain is available for registration') : $translator->translate("The domain is unavailable for registration, but if you are the domain owner, you can transfer it!");
             $this->view->form = $form;
             $this->view->results = array('available' => $available, 'name' => $params['name'], 'tld' => $params['tld'], 'price' => $strprice, 'domain' => $domain, 'mex' => $mex);
             $this->view->suggestions = $this->chktlds($params['name'], array($params['tld']));
         }
     } catch (Exception $e) {
         $this->_helper->redirector('index', 'domainschk', 'default', array('mex' => $e->getMessage(), 'status' => 'danger'));
     }
     $this->_helper->viewRenderer('result');
 }