public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'name', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('TLD Name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'description', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Description'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('text', 'tags', array('filters' => array('StringTrim'), 'label' => $translate->_('Tags/Type'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'ishighlighted', array('label' => $translate->_('Is Highlighted'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'isrefundable', array('label' => $translate->_('Is Refundable'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('text', 'resultcontrol', array('filters' => array('StringTrim'), 'label' => $translate->_('Result String Control'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'registration_price', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Registration Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'renewal_price', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Renewal Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'transfer_price', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Transfer Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'server_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('TLD Server'), 'class' => 'form-control')); $this->getElement('server_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(WhoisServers::getList()); $this->addElement('select', 'tax_id', array('label' => $translate->_('Tax'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('tax_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Taxes::getList())->setRequired(true); $this->addElement('text', 'registration_cost', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Registration Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'renewal_cost', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Renewal Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'transfer_cost', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Transfer Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'registrars_id', array('label' => $translate->_('Registrars'), 'decorators' => array('Bootstrap'), 'class' => 'form-control updatechkdomain')); $this->getElement('registrars_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Registrars::getList(false))->setRequired(true); $this->addElement('submit', 'save', array('required' => false, 'label' => $translate->_('Save'), 'decorators' => array('Bootstrap'), 'class' => 'btn')); $this->addElement('hidden', 'tld_id'); }
public function checkDomainAvailability($domain) { $servers = array(); // fix the domain name: $domain = strtolower(trim($domain)); $domain = preg_replace('/^http:\\/\\//i', '', $domain); $domain = preg_replace('/^www\\./i', '', $domain); $domain = explode('/', $domain); $domain = trim($domain[0]); $whois = WhoisServers::getAll(); if (!empty($whois)) { foreach ($whois as $tld) { $servers[$tld['tld']] = $tld['server']; $this->arWhoisServer[$tld['tld']] = array($tld['server'], $tld['response']); } } // split the TLD from domain name $_domain = explode('.', $domain); $lst = count($_domain) - 1; $ext = $_domain[$lst]; if (!isset($servers[$ext])) { return "Error: No matching whois server found for {$ext}!"; } $output = ""; try { if (!empty($servers[$ext])) { // connect to whois server: if ($conn = @fsockopen($servers[$ext], 43)) { fwrite($conn, $domain . "\r\n"); while (!feof($conn)) { $output .= fgets($conn, 128); } fclose($conn); } else { return 'Error: Could not connect to ' . $servers[$ext] . '!'; } return $this->checkResult($domain, $ext, $output); } else { throw new Exception('Whois Server URL has been not found!'); } } catch (Exception $e) { echo $e->getMessage(); } }