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()))); } }
/** * Check all the tld domain extensions * * @param string $name * @param array $exluded (exclude a tld extension) */ private function chktlds($name, $exluded = "") { $result = array(); $currency = Shineisp_Registry::getInstance()->Zend_Currency; $translator = Shineisp_Registry::getInstance()->Zend_Translate; $tlds = DomainsTlds::getAll(); foreach ($tlds as $tld) { if (!in_array($tld['tld_id'], $exluded)) { $available = Domains::check_availability($name, $tld['tld_id']); // Create the domain name $domain = $name . "." . $tld['DomainsTldsData'][0]['name']; // Domain Price $price = $available ? $tld['registration_price'] : $tld['transfer_price']; $taxpercent = $tld['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!"); $result[] = array('available' => $available, 'name' => $name, 'tld' => $tld['tld_id'], 'price' => $strprice, 'domain' => $domain, 'mex' => $mex); } } return $result; }