Beispiel #1
0
 /**
  * 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;
 }
Beispiel #2
0
 /**
  * Check the dns of the active domains
  * @return array
  */
 public static function bulk_check_dns($items)
 {
     $external_domains = array();
     $internal_domains = array();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $mex = "";
     // Get all the active domains
     $domains = self::get_domains($items, "d.domain_id, CONCAT(d.domain, '.', ws.tld) as name");
     // Get the webserver information
     $webserver = Servers::getWebserver();
     // For each domain do ...
     foreach ($domains as $domain) {
         // Get the DNS information about the domain
         $records = dns_get_record($domain['name'], DNS_A + DNS_NS);
         // For each DNS records found
         foreach ($records as $record) {
             if (!empty($record['type']) && $record['type'] == "A") {
                 if ($record['ip'] != $webserver['ip']) {
                     $external_domains[] = $translator->_('The domain %s redirects the requests at this IP address: %s. read more here (%s)', $domain['name'], $record['ip'], "<a href=\"/admin/domains/edit/id/" . $domain['domain_id'] . "\">" . $domain['name'] . "</a>");
                 } else {
                     $internal_domains[] = $translator->_('The domain %s located in our servers.', $domain['name']);
                 }
             }
         }
     }
     if (!empty($external_domains)) {
         $mex = "<ul class=\"list-unstyled\"><li><span class=\"label label-danger\">" . $translator->translate('Warning') . "</span> " . implode('</li><li><span class="label label-danger">' . $translator->translate('Warning') . '</span> ', $external_domains) . "</li></ul>";
     }
     if (!empty($internal_domains)) {
         $mex .= "<ul class=\"list-unstyled\"><li><span class=\"label label-success\">" . $translator->translate('Success') . "</span> " . implode('</li><li><span class="label label-success">' . $translator->translate('Success') . '</span> ', $internal_domains) . "</li></ul>";
     }
     die(json_encode(array('mex' => $mex, 'autoreload_disabled' => true)));
 }