예제 #1
0
 /**
  * Commits changes (increases serial by 1)
  * 
  * @return Array on success, string on error
  */
 public static function commit()
 {
     // do some checks first
     $pdns_version = trim(shell_exec("sudo /usr/bin/pdns_control version 2>&1"));
     if (!preg_match('/^[0-9,\\.]+$/', $pdns_version)) {
         if (preg_match('/\\[sudo\\] password/', $pdns_version)) {
             return "Unable to run 'sudo /usr/bin/pdns_control'. Is it defined in sudoers file?";
         } else {
             return $pdns_version;
         }
     }
     $commited = array();
     $c = new Criteria();
     $c->add(AuditPeer::OBJECT, 'Record');
     $c->addGroupByColumn(AuditPeer::DOMAIN_ID);
     $c->add(AuditPeer::CREATED_AT, date("Y-m-d H:i:s", MyTools::getLastCommit()), Criteria::GREATER_THAN);
     foreach (AuditPeer::doSelect($c) as $audit) {
         $domain = DomainPeer::retrieveByPK($audit->getDomainId());
         $commited[] = $domain->getName();
         // get SOA record
         $c = new Criteria();
         $c->add(RecordPeer::DOMAIN_ID, $domain->getId());
         $c->add(RecordPeer::TYPE, 'SOA');
         $SOA = RecordPeer::doSelectOne($c);
         $temp = explode(" ", $SOA->getContent());
         $serial = $temp[2];
         $date = substr($serial, 0, 8);
         $id = substr($serial, 8);
         // today ?
         if ($date == date("Ymd")) {
             $id++;
             if (strlen($id) == 1) {
                 $id = "0" . $id;
             }
             $serial = $date . $id;
         } else {
             $serial = date("Ymd") . "01";
         }
         if ($serial >= 4294967295) {
             continue;
         }
         // don't allow >= 32bit unsigned
         $SOA->setContent(implode(" ", array($temp[0], $temp[1], $serial)));
         $SOA->save();
     }
     if ($commited) {
         SettingPeer::setValue('last_commit', time());
         sleep(2);
         if ($also_notify = sfConfig::get('app_default_also-notify')) {
             foreach ($commited as $domain) {
                 foreach ($also_notify as $host) {
                     exec("sudo /usr/bin/pdns_control notify-host {$domain} {$host}");
                 }
             }
         }
     }
     return $commited;
 }
예제 #2
0
 /**
  * Record Type
  */
 public function executeRecordtype()
 {
     if (!$this->isPOST()) {
         $output = array();
         if (!($record_type = SettingPeer::getValue('record_type'))) {
             return $this->renderJson(array("success" => false));
         }
         foreach (unserialize($record_type) as $type => $state) {
             $output[] = array("id" => $type, "state" => $state);
         }
         return $this->renderStore("RecordType", $output);
     } else {
         $record_type = array();
         foreach ($this->getRequestParameter('record_type') as $type => $state) {
             if ($state) {
                 $record_type[$type] = 1;
             } else {
                 $record_type[$type] = 0;
             }
         }
         SettingPeer::setValue('record_type', serialize($record_type));
         return $this->renderJson(array("success" => true, "info" => "Record types updated."));
     }
 }
예제 #3
0
        echo "Table {$table} - changing engine to InnoDB...\n";
        $sql = "ALTER TABLE `{$db_name}`.`{$table}` ENGINE = InnoDB";
        try {
            $statement = $connection->prepareStatement($sql);
            $statement->executeQuery();
        } catch (Exception $e) {
            innoDBError($sql, $e);
            break;
        }
        $upgraded = true;
    }
}
// set record_type setting
if (!SettingPeer::getValue('record_type')) {
    echo "Settings->record_type missing, updating...\n";
    $types = array("A" => 1, "AAAA" => 0, "AFSDB" => 0, "CERT" => 0, "CNAME" => 1, "DNSKEY" => 0, "DS" => 0, "HINFO" => 0, "KEY" => 0, "LOC" => 0, "MX" => 1, "NAPTR" => 1, "NS" => 1, "NSEC" => 0, "PTR" => 1, "RP" => 0, "RRSIG" => 0, "SOA" => 1, "SPF" => 1, "SSHFP" => 0, "SRV" => 1, "TXT" => 1);
    SettingPeer::setValue('record_type', serialize($types));
    $upgraded = true;
}
if ($upgraded) {
    echo "Clearing cache...\n";
    passthru(SF_ROOT_DIR . "/symfony cc");
    echo "Done.\n";
} else {
    echo "Your Power DNS GUI is up to date. Nothing to upgrade.\n";
}
function innoDBError($sql, $e)
{
    echo $e->getMessage() . "\n\n";
    echo "Please make sure 'records' and 'domain' tables engine is set to InnoDB\n\n";
}