コード例 #1
0
ファイル: Main.php プロジェクト: kokkez/shineisp
 /**
  * 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;
 }
コード例 #2
0
ファイル: Base.php プロジェクト: kokkez/shineisp
 /**
  * Get the DNS Servers configured for the Active ISP
  * 
  * @return     array       Dns Servers
  * @access     private
  */
 public function getDnsServers()
 {
     $items = array();
     $dns = Servers::getDnsserver();
     foreach ($dns as $item) {
         $items[] = $item['host'] . "." . $item['domain'];
     }
     return $items;
 }