/** * Set domain hosts (records) for a domain name. * * Executes the '...' command on Registrar's servers, to set domain hosts (records) * for a domain name that is active and belongs to your Ascio account. * * @param integer $domainID Domain code identifier * @return bool True if succeed and False if failed. * @access public * @see getDomainHosts */ function setDomainHosts($domainID) { $zonesrows = ""; $nserver = ""; // Connection to the SOAP system $soap = $this->Connect(); if (empty($this->session)) { throw new Exception('SOAP connection system error'); } // Get the domain information $domain = Domains::find($domainID); if (!empty($domain[0])) { $domain_name = $domain[0]['domain'] . "." . $domain[0]['DomainsTlds']['WhoisServers']['tld']; $customer = Customers::find($domain[0]['customer_id']); } else { throw new Exception('Domain information has not found.'); } // Get the customer dns set in his control panel $NS = Dns_Zones::getCustomNameServers($domainID); // Get the default domain set $NSDefault = $soap->domainInfo($this->session['id'], $domain_name); // START NAMESERVER MANAGEMENT if (!empty($NS)) { // Get the client nameserver set in the shineisp control panel foreach ($NS as $ns) { $nameservers[] = $ns['target']; } } else { // Get the domain nameservers set in Ascio if (!empty($NSDefault->dns[0]) && !empty($NSDefault->dns[1])) { $nameservers[] = $NSDefault->dns[0]->name . "."; $nameservers[] = $NSDefault->dns[1]->name . "."; } else { // Get the common domain dns zones information set in shineisp preferences $NSDefault = Servers::getDnsserver(); foreach ($NSDefault as $ns) { $nameservers[] = $ns['host'] . "." . $ns['domain'] . "."; } } } // Create the NS records foreach ($nameservers as $ns) { $nameserver = array(); $nameserver[] = ""; $nameserver[] = " IN "; $nameserver[] = " NS "; $nameserver[] = $ns; $nserver .= implode("\t", $nameserver) . "\n"; } // END NAMESERVER MANAGEMENT if (!empty($nameservers[0])) { $zoneTemplate = "\$TTL 86400\n@ IN SOA " . $nameservers[0] . " tech.ascio.net. (2011022503 86400 3600 3600000 86400)\n"; // Get the domain dns zones information $dnsZones = Dns_Zones::getZones($domainID); // Create the DNS Zones records if (!empty($dnsZones)) { foreach ($dnsZones as $zone) { if ($zone['fieldtype'] != "NS") { // Exclude the NS because already included above $zones = array(); $zones[] = $zone['subdomain']; $zones[] = " IN "; $zones[] = $zone['fieldtype']; $zones[] = $zone['target']; $zonesrows .= implode("\t", $zones) . "\n"; } } $zones = array(); $zone = $zoneTemplate . $nserver . $zonesrows; } else { $webservers = Servers::getWebserver(); $mailservers = Servers::getMailserver(); // Set Web server zone $zones[] = "www\tIN\tCNAME\t" . $domain_name . "."; if (!empty($webservers['ip'])) { $zones[] = "\tIN\tA\t" . $webservers['ip']; } // Set mail zone $zones[] = "\tIN\tMX 1\tmail." . $domain_name . "."; if (isset($mailservers)) { $zones[] = "mail\tIN\tA\t" . $mailservers['ip']; } else { $zones[] = "mail\tIN\tA\t" . $webservers['ip']; } $zonesrows = implode("\n", $zones) . "\n"; $zone = $zoneTemplate . $nserver . $zonesrows; } // Reset of the Zone dns $soap->dnsReset($this->session['id'], $domain_name, 'REDIRECT', true); // Import the DNS Custom Zone $soap->zoneImport($this->session['id'], $domain_name, $zone); return true; } return false; }
/** * editAction * Get a record and populate the application form * @return unknown_type */ public function editAction() { $form = $this->getForm('/domains/process'); $id = $this->getRequest()->getParam('id'); if (!empty($id) && is_numeric($id)) { if (!empty($this->customer['customer_id']) && is_numeric($this->customer['customer_id'])) { $customer_id = $this->customer['customer_id']; } // Get these fields before editing the form // the field autorenew has been aliased in order to create a flat array and not a multidimentional array as proposed by the Doctrine engine $fields = "domain_id, registrars_id, CONCAT('http://www.', d.domain, '.', ws.tld) as Domain, d.authinfocode as authinfocode, \n\t\t\tp.product_id as product_id, d.domain as domainame, ws.tld as tld, d.autorenew as autorenew, \n\t\t\tDATE_FORMAT(d.creation_date, '%d/%m/%Y') as Starting, (DATEDIFF(expiring_date, CURRENT_DATE)) as Days, \n\t\t\tDATE_FORMAT(d.expiring_date, '%d/%m/%Y') as Termination, s.status as Status"; $rs = $this->domains->getAllInfo($id, $customer_id, $fields, true); if (empty($rs)) { $this->_helper->redirector('index', 'domains', 'default', array('mex' => 'forbidden', 'status' => 'danger')); } $form->populate($rs[0]); if ($rs[0]['autorenew']) { $this->view->autorenew = true; } else { $this->view->autorenew = false; } // Some useful values $this->view->name = $rs[0]['domainame'] . "." . $rs[0]['tld']; $this->view->days = $rs[0]['Days']; $this->view->domain_id = $id; $this->view->productid = $rs[0]['product_id']; // Show the list of the messages attached to this domain $this->view->messages = Messages::getbyDomainId($id); $this->view->tags = Tags::findConnectionbyDomainID($id); $this->view->is_maintained = $rs[0]['registrars_id']; $this->view->customerid = $customer_id; $this->view->authinfocode = $rs[0]['authinfocode']; $this->view->id = $id; $this->view->orders = array('records' => domains::Orders($id), 'edit' => array('controller' => 'orders', 'action' => 'edit')); $this->view->services = array('records' => domains::Services($id), 'edit' => array('controller' => 'services', 'action' => 'edit')); $this->view->tasks = array('records' => DomainsTasks::getTasksbyDomainID($id)); // Hide these fields and values inside the vertical grid object unset($rs[0]['autorenew']); unset($rs[0]['authinfocode']); unset($rs[0]['note']); unset($rs[0]['domainame']); unset($rs[0]['tld']); // Sent the data to the datagrid $this->view->datagrid = array('records' => $rs); $this->view->dnsgrid = array('records' => Dns_Zones::getZones($id, true), 'delete' => array('controller' => 'domains', 'action' => 'deletednszone')); } $this->view->mex = $this->getRequest()->getParam('mex'); $this->view->mexstatus = $this->getRequest()->getParam('status'); $this->view->title = $this->translator->translate("Domain"); $this->view->description = $this->translator->translate("Here you can edit your own domain parameters."); $this->view->form = $form; $this->_helper->viewRenderer('customform'); }