コード例 #1
0
 public function actionIndex()
 {
     $ips = array('95.110.192.200', '95.110.193.249', '95.110.204.16', '95.110.204.20', '69.175.126.90', '69.175.126.94', '46.4.96.70', '46.4.96.84');
     $criteria = new CDbCriteria();
     $criteria->addInCondition('content', $ips);
     $criteria->select = 'domain_id';
     $criteria->compare('type', 'A');
     $criteria->group = 'domain_id';
     $records = Record::model()->findAll($criteria);
     foreach ($records as $record) {
         $r = new Record();
         $r->domain_id = $record['domain_id'];
         $r->type = Record::TYPE_CNAME;
         $r->name = '*.' . $record->domain->name;
         $r->content = $record->domain->name;
         $r->ttl = '86400';
         if (!$r->save()) {
             echo "\nCannot save duplicate record to domain " . $r->domain->name;
         } else {
             echo "\nRecord * added to domain " . $r->domain->name;
             $record->domain->updateSOA();
         }
     }
     echo "\n";
 }
コード例 #2
0
ファイル: ClientController.php プロジェクト: dailos/heimdal
 public function actionDisplayOperation($id = null)
 {
     $model = Record::model()->findAllByAttributes(array('operation_id' => $id));
     $values = CHtml::listData($model, 'port_id', 'value', 'timestamp');
     $jsonarray = array();
     foreach ($values as $date => $value) {
         $jsonarray[] = array_merge(array($date), $value);
     }
     $model = Operation::model()->with('iface')->findByPK($id);
     $model->nextPrev();
     $this->render('displayOperation', array('values' => $jsonarray, 'operation' => $model));
 }
コード例 #3
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return UserProfile the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
コード例 #4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Record the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Record::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #5
0
 public function actionEnableDomain($domain, $_output = true)
 {
     $result = true;
     $error = array('code' => 0, 'message' => '');
     $dd = DisabledDomain::model()->findByAttributes(array('domain' => $domain));
     if (!isset($dd)) {
         $result = false;
         $error['code'] = self::ERROR_DOMAIN_NOT_FOUND;
         $error['message'] = 'Domain not found';
     } else {
         $records = @unserialize($dd->records);
         if (!is_array($records)) {
             $result = false;
             $error['code'] = self::ERROR_RECORD_NOT_FOUND;
             $error['message'] = 'Cannot recover records';
         } else {
             // Remove fallback records
             $domain = Domain::model()->findByAttributes(array('name' => $dd->domain));
             Record::model()->deleteAllByAttributes(array('domain_id' => $domain->id));
             $resp = $this->actionEditBulkRecords($dd->domain, json_encode($records), true, false);
             if ($resp['result'] === true) {
                 $dd->delete();
             } else {
                 $error['code'] = $resp['error_code'];
                 $error['message'] = $resp['error_message'];
                 $result = $resp['result'];
             }
         }
     }
     $var = array('error_code' => $error['code'], 'error_message' => $error['message'], 'result' => $result);
     if ($_output) {
         $this->renderText(CJSON::encode($var));
     }
     return $var;
 }
コード例 #6
0
 private function addSOA()
 {
     $domain = $this;
     // check if SOA already exists
     if (Record::model()->countByAttributes(array('domain_id' => $domain->id, 'type' => Record::TYPE_SOA)) == 0) {
         $recordSoa = new Record();
         $recordSoa->name = $domain->name;
         $recordSoa->type = Record::TYPE_SOA;
         $recordSoa->domain_id = $domain->id;
         $recordSoa->content = Domain::soaArrayToContent(array('name_server' => Yii::app()->params['soa_defaults']['name_server'], 'email_address' => Yii::app()->params['soa_defaults']['email_address'], 'serial_number' => '1', 'refresh_time' => Yii::app()->params['soa_defaults']['refresh_time'], 'retry_time' => Yii::app()->params['soa_defaults']['retry_time'], 'expiry_time' => Yii::app()->params['soa_defaults']['expiry_time'], 'nx_time' => Yii::app()->params['soa_defaults']['nx_time']));
         $recordSoa->ttl = Yii::app()->params['soa_defaults']['expiry_time'];
         $recordSoa->prio = 0;
         if (!$recordSoa->save()) {
             Yii::log('Cannot add SOA: ' . print_r($recordSoa->getErrors(), true), CLogger::LEVEL_ERROR);
             return false;
         }
     } else {
         Yii::log('SOA record already existing', CLogger::LEVEL_ERROR);
         return false;
     }
     return true;
 }