public function storeSlave(Request $request)
 {
     $name = $request->input('data.name', null);
     if ($name != null) {
         $dominio = Domain::where('name', '=', $name)->first();
         if ($dominio != null) {
             return response()->json(['error' => 'zoneSlave_exists'], 409);
         }
         $slave = new Domain();
         $slave->name = $request->input('data.name');
         $slave->master = $request->input('data.nameserver');
         $slave->type = 'SLAVE';
         $slave->save();
         $id = $slave->id;
         $zones = new Zone();
         $zones->domain_id = $id;
         $zones->owner = '1';
         $zones->comment = '';
         $zones->zone_templ_id = '0';
         $zones->save();
         return response()->json(['success' => 'zoneSlave_created'], 200);
     } else {
         return response()->json(['error' => 'zoneSlave_error'], 400);
     }
 }
Exemple #2
0
 static function createIfNew($name, $lat, $lng, $address = null)
 {
     $dom = self::find()->where(['name' => $name])->one();
     if (!$dom) {
         $dom = new Domain();
         $dom->name = $name;
         $dom->lat = $lat;
         $dom->lng = $lng;
         $dom->address = $address;
         $dom->save();
     }
 }
 /**
  * Execute the console command
  */
 public function handle()
 {
     $this->initCommand();
     // open the site list
     $siteList = fopen($this->directories['list'], 'w');
     $domains = Domain::all();
     foreach ($domains as $domain) {
         // clear the site information string
         unset($siteInformation, $databaseName);
         // clear database username and password values
         $databaseName = $databaseUsername = $databasePassword = '';
         // check for WP and pull the proper template
         if ($domain->is_word_press) {
             // generate the database username and password
             $databaseName = substr(str_replace('.', '', $domain->name), 0, 6) . date('ynj') . '_wp';
             $databaseUsername = substr(str_replace('.', '', $domain->name), 0, 6) . date('ynj') . '_wp';
             $databasePassword = '' . str_random(24);
         }
         $databaseHost = env('WP_DB_HOST');
         // build the site information string
         //  format: domain name:username:password:is WP
         //  should be: domain.com:domauser:d0m4inP4$s!:true
         $siteInformation = '' . $domain->name . ':' . (int) $domain->is_word_press . ':' . $databaseName . ':' . $databaseUsername . ':' . $databasePassword . ':' . $databaseHost . ":\n";
         fwrite($siteList, $siteInformation);
         // soft-delete domain
         $domain->delete();
     }
     fclose($siteList);
 }
Exemple #4
0
 static function findLocation($domainName, $deviceName)
 {
     $dev = self::find()->where(['domain' => $domainName, 'node' => $deviceName])->asArray()->one();
     if (!$dev) {
         $dom = Domain::find()->where(['name' => $domainName])->asArray()->one();
         return $dom;
     }
     return $dev;
 }
 public function edit($id)
 {
     $param['pageNo'] = 1;
     $result = DomainModel::find($id);
     $param['domain'] = $result;
     $param['language'] = LanguageModel::all();
     $param['template'] = TemplateModel::all();
     return View::make('domains.edit')->with($param);
 }
 /**
  * get Home.
  *
  * @param Business $business Business to display
  *
  * @return Response Rendered view for desired Business
  */
 public function getHome($slug)
 {
     logger()->info(__METHOD__);
     logger()->info(sprintf('slug:%s', $slug));
     if ($domain = Domain::where('slug', $slug)->first()) {
         return $this->getDomain($domain);
     }
     $business = Business::where('slug', $slug)->first();
     return view('guest.businesses.show', compact('business'));
 }
 public function destroy($id)
 {
     $domain = Domain::find($id);
     if ($domain = null) {
         return response()->json(['error' => 'domain_does_not_existe'], 400);
     }
     $domain_id = $id;
     $zones = Zone::where('domain_id', '=', $domain_id)->delete();
     $records = Record::where('domain_id', '=', $domain_id)->delete();
     $domain = Domain::where('id', '=', $id)->delete();
     return response()->json(['success'], 200);
 }
Exemple #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Domain::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     //        if (!$this->validate()) {
     //            // uncomment the following line if you do not want to return any records when validation fails
     //            // $query->where('0=1');
     //            return $dataProvider;
     //        }
     $query->andFilterWhere(['domain_id' => $this->domain_id, 'notify_when_down' => $this->notify_when_down, 'notify_when_up' => $this->notify_when_up, 'account_id' => $this->account_id, 'date_added' => $this->date_added, 'date_updated' => $this->date_updated, 'watch_mx' => $this->watch_mx, 'watch_dns' => $this->watch_dns, 'watch_ip' => $this->watch_ip]);
     $query->andFilterWhere(['like', 'domain', $this->domain])->andFilterWhere(['like', 'added_ip', $this->added_ip])->andFilterWhere(['like', 'updated_ip', $this->updated_ip]);
     return $dataProvider;
 }
 /**
  * Store a record
  *
  * @param Request $request
  *
  * @return mixed
  */
 public function store(Request $request)
 {
     $this->validate($request, ['domain_name' => 'required|unique:name|min:4|max:255']);
     $input = $request->only(['domain_name', 'is_word_press']);
     $password = str_random(12);
     try {
         Domain::create(['name' => $input['domain_name'], 'is_word_press' => $input['is_word_press'], 'username' => $input['domain_name'], 'password' => $password, 'user_id' => Auth::user()->id]);
         $request->session()->flash('success', $input['domain_name'] . ' has been created!');
         Artisan::call('install-site');
     } catch (Exception $e) {
         $request->session()->flash('danger', $input['domain_name'] . ' was not created, please try again.');
     }
     return redirect()->route('domain.index');
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->model('contact', Contact::class);
     $router->model('service', Service::class);
     $router->model('appointment', Appointment::class);
     $router->bind('business', function ($businessSlug) {
         return Business::where('slug', $businessSlug)->first();
     });
     $router->bind('domain', function ($domainSlug) {
         return Domain::where('slug', $domainSlug)->first();
     });
 }
 public function form($form)
 {
     $class = 'app\\forms\\' . $form;
     $form = new $class($this, array('user' => models\User::first('1 ORDER BY RAND()'), 'domain' => models\Domain::first('1 ORDER BY RAND()')));
     $content = '';
     if ($this->POST) {
         $content .= '<pre>VALIDATION: ' . ($form->validate($_POST) ? 'OK' : 'FAIL') . '</pre>';
         $content .= '<pre>' . print_r($form->errors(), 1) . '</pre>';
     }
     $content .= $form->render();
     $content .= '<pre>$_POST: ' . print_r($_POST, 1) . '</pre>';
     $content .= '<pre>&output: ' . print_r($form->output, 1) . '</pre>';
     $content .= '<pre>$form: ' . print_r($form, 1) . '</pre>';
     return $this->tpl->display(false, array('content' => $content));
 }
Exemple #12
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDomain()
 {
     return $this->hasOne(Domain::className(), ['domain_id' => 'domain_id']);
 }
 protected function elements($defaults)
 {
     return array('password' => array('type' => 'password', 'description' => Output::translate('Admin password to prove you\'re one of the hims/hers.'), 'required' => true, 'minlength' => 4), 'prefs' => array('type' => 'grid', 'subtype' => 'checkbox', 'reverse' => true, 'title' => Output::translate('Choose categories'), 'horizontal' => array(Output::translate('Domain'), models\Domain::all('domain_id >= ?', $this->options->domain ? $this->options->domain->domain_id : 0)), 'vertical' => array(Output::translate('User'), models\User::all('user_id >= ?', $this->options->user ? $this->options->user->user_id : 0)), 'description' => Output::translate('One category per user / domain combination'), 'name' => 'options'), 'cat' => array('type' => 'options', 'options' => models\Category::all()));
 }
Exemple #14
0
 public function IPCheck($domain)
 {
     // lookup NS records
     $dns = \dns_get_record($domain, DNS_A);
     //grab domain id
     $domain_id = \app\models\Domain::findOne(['domain' => $domain])->domain_id;
     // retrieve last stored records
     $prev_record = (new \yii\db\Query())->select(['record_value'])->from(['domain_record'])->where(['domain_id' => $domain_id, 'record_type' => 'IP'])->all();
     $prev = [];
     foreach ($prev_record as $re) {
         $prev[] = $re['record_value'];
     }
     // prepare dns records array
     $record = [];
     foreach ($dns as $ns) {
         $record[] = $ns['ip'];
     }
     //detect record differences
     $diff = array_diff($record, $prev);
     if (!empty($diff)) {
         $q = new \app\models\MailQueue();
         $q->domain_id = $domain_id;
         $q->message = '';
         $q->save();
     }
     // clear old record
     \app\models\DomainRecord::deleteAll(['domain_id' => $domain_id, 'record_type' => 'IP']);
     // Insert new records
     foreach ($record as $key => $value) {
         $model = new \app\models\DomainRecord();
         $model->domain_id = $domain_id;
         $model->record_type = 'IP';
         $model->record_value = $value;
         $model->last_checked = new \yii\db\Expression('now()');
         $model->save();
     }
 }
Exemple #15
0
 function parseProviders()
 {
     $this->xpath->registerNamespace('x', 'http://schemas.ogf.org/nsi/2014/02/discovery/nsa');
     $nsaNodes = $this->xpath->query("//x:nsa");
     foreach ($nsaNodes as $nsaNode) {
         $idString = $nsaNode->getAttribute('id');
         $id = explode(":", $idString);
         $domainName = $id[3];
         $longitudeNode = $this->xpath->query(".//longitude", $nsaNode);
         $latitudeNode = $this->xpath->query(".//latitude", $nsaNode);
         $lat = null;
         $lng = null;
         if ($longitudeNode->item(0)) {
             $lat = $latitudeNode->item(0)->nodeValue;
             $lng = $longitudeNode->item(0)->nodeValue;
             Domain::createIfNew($domainName, $lat, $lng);
         }
     }
 }
 /**
  * Finds the Domain model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Domain the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Domain::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #17
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDomains()
 {
     return $this->hasMany(Domain::className(), ['account_id' => 'account_id']);
 }