Esempio n. 1
0
 /**
  * Get DNS.
  *
  * @param string $subdomain
  *
  * @return Dns
  */
 protected function _getDns($subdomain = '')
 {
     $domain = new Domain();
     $domain->setDomain('lampcp.de');
     $dns = new Dns($domain);
     if (!empty($subdomain)) {
         $dns->setSubdomain($subdomain);
     }
     return $dns;
 }
Esempio n. 2
0
 /**
  * Transform resource record to FQDN.
  *
  * @param Dns                    $dns
  * @param AbstractResourceRecord $rr
  *
  * @return string
  */
 public static function getFqdn(Dns $dns, AbstractResourceRecord $rr)
 {
     if (substr($rr->getName(), -1, 1) === '.') {
         $fqdn = substr($rr->getName(), 0, strlen($rr->getName()) - 1);
     } elseif ($rr->getName() == '@') {
         $fqdn = $dns->getOrigin();
     } else {
         $fqdn = $rr->getName() . '.' . $dns->getOrigin();
     }
     return $fqdn;
 }
Esempio n. 3
0
 /**
  * Get resource record by FQDN.
  *
  * @param Dns    $dns
  * @param string $fqdn
  *
  * @return AbstractResourceRecord[]
  */
 protected function _getResourceRecordsByFqdn(Dns $dns, $fqdn)
 {
     $records = array();
     $matRecords = array();
     // Collect records by type
     foreach (self::$_types as $type) {
         $records = array_merge($records, $dns->getZonecollection()->getByType($type));
     }
     // Collect matching records
     foreach ($records as $rr) {
         /** @var $rr AbstractResourceRecord */
         if (FqdnTransformer::getFqdn($dns, $rr) === $fqdn) {
             $matRecords[] = $rr;
         }
     }
     return $matRecords;
 }
Esempio n. 4
0
 /**
  * Update SOA record
  *
  * @Route("/{entity}/updatesoa", name="config_dns_update_soa")
  * @Template()
  */
 public function updateSoaAction(Request $request, Dns $entity)
 {
     $zone = $entity->getZonecollection();
     $soa = $zone->getSoa();
     $editForm = $this->createForm(new DnsSoaType(), $soa);
     $editForm->bind($request);
     if ($editForm->isValid()) {
         $soa->refreshSerial();
         $zone->add($soa);
         $entity->setZonecollection(clone $zone);
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('config_dns_show', array('entity' => $entity->getId())));
     }
     return array('entity' => $entity, 'edit_form' => $editForm->createView());
 }
Esempio n. 5
0
 /**
  * Check for zone definition in config file
  *
  * @param \Jeboehm\Lampcp\CoreBundle\Entity\Dns $zone
  *
  * @return bool
  */
 protected function _checkZoneDefinition(Dns $zone)
 {
     $dbPath = sprintf('%s/%s.%s', $this->_getZoneDirectory(), $zone->getOrigin(), 'db');
     $config = file_get_contents($this->_getZoneDefinitionPath());
     $definition = ZoneDefinition::create($zone->getOrigin(), $dbPath);
     if (strpos($config, $definition) !== false) {
         return true;
     }
     return false;
 }