/** * 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; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = RecordPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setDomainId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setType($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setContent($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setTtl($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setPrio($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setChangeDate($arr[$keys[7]]); } }
/** * Delete */ public function executeDelete() { $c = new Criteria(); $c->add(RecordPeer::DOMAIN_ID, $this->domain->getId()); RecordPeer::doDelete($c); $this->domain->delete(); return $this->renderJson(array("success" => true, "info" => "Domain deleted.")); }
public function countRecords($criteria = null, $distinct = false, $con = null) { include_once 'lib/model/om/BaseRecordPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(RecordPeer::DOMAIN_ID, $this->getId()); return RecordPeer::doCount($criteria, $distinct, $con); }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(RecordPeer::ID, $pks, Criteria::IN); $objs = RecordPeer::doSelect($criteria, $con); } return $objs; }