当前位置: 首页>>代码示例>>PHP>>正文


PHP Host::model方法代码示例

本文整理汇总了PHP中Host::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Host::model方法的具体用法?PHP Host::model怎么用?PHP Host::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Host的用法示例。


在下文中一共展示了Host::model方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getConverted_name

 public function getConverted_name()
 {
     switch ($this->ctype) {
         case 'host':
             $host = Host::model()->findByPk($this->name);
             return $host !== null && $host->short ? $host->short : $host->fqdn;
         default:
             return $this->name;
     }
 }
开发者ID:proditis,项目名称:echofish,代码行数:10,代码来源:ArchiveCounters.php

示例2: searchResult

 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function searchResult()
 {
     $result = array();
     $hosts = Host::model()->findAllByAttributes(array('id' => $this->hosts));
     switch ($this->type) {
         case "camtable_mac":
             $search_table = 'camtable';
             $search_field = 'mac';
             break;
         case "camtable_vlan":
             $search_table = 'camtable';
             $search_field = 'vlan_tag';
             break;
     }
     if (count($hosts) && $search_table == 'camtable') {
         foreach ($hosts as $host) {
             $host->loadCamTable();
             foreach ($host->cam_table as $row) {
                 if ($this->exact_match) {
                     $found = $row[$search_field] == $this->query;
                 } else {
                     $found = strpos($row[$search_field], $this->query) !== FALSE;
                 }
                 if ($found) {
                     $hostDst = $host->getHostOnPort($row['port']);
                     if ($this->exclude_link_ports && !empty($hostDst)) {
                         continue;
                     }
                     $row['host'] = $host;
                     $row['hostDst'] = $hostDst;
                     $row['vlan'] = Vlan::model()->findByAttributes(array('tag' => $row['vlan_tag']));
                     $result[] = $row;
                 }
             }
         }
     }
     return $result;
 }
开发者ID:romero1989,项目名称:phpnetmap,代码行数:42,代码来源:SearchForm.php

示例3: setHostFaceOnHosts

 protected function setHostFaceOnHosts($model, $host_ids)
 {
     /* unset old hosts */
     foreach ($model->hosts as $host) {
         if ($host instanceof Host) {
             $host->host_face_id = null;
             $host->save();
         }
     }
     /* set new hosts */
     $hosts = Host::model()->findAllByPk($host_ids);
     foreach ($hosts as $host) {
         if ($host instanceof Host) {
             $host->host_face_id = $model->id;
             $host->save();
         }
     }
 }
开发者ID:romero1989,项目名称:phpnetmap,代码行数:18,代码来源:HostFaceController.php

示例4: array

echo $form->labelEx($model, 'svg');
?>
		<?php 
echo $form->textArea($model, 'svg', array('rows' => 6, 'cols' => 50));
?>
		<?php 
echo $form->error($model, 'svg');
?>
	</div>
        
	<div class="row">
		<?php 
echo $form->labelEx($model, 'hosts');
?>
                <?php 
echo $form->dropDownList($model, 'hosts', CHtml::listData(Host::model()->findAll(), 'id', 'name', 'type'), array('empty' => '', 'multiple' => 'multiple', 'size' => 15));
?>
		<?php 
echo $form->error($model, 'hosts');
?>
	</div>

	<div class="row buttons">
		<?php 
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
?>
	</div>

<?php 
$this->endWidget();
?>
开发者ID:romero1989,项目名称:phpnetmap,代码行数:31,代码来源:_form.php

示例5: actionPassword

 public function actionPassword()
 {
     $model = new HostChangePassword();
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['HostChangePassword'])) {
         $model->attributes = $_POST['HostChangePassword'];
         if ($model->validate()) {
             $new_password = Host::model()->findbyPk($this->_user['hostId']);
             $new_password->password = $model->password;
             $new_password->verifyPassword = $model->password;
             $new_password->save();
             Yii::app()->user->setFlash('msg', '保存成功');
         }
     }
     $this->render('password', array('model' => $model));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:20,代码来源:DefaultController.php

示例6: actionArpTable

 /**
  * Displays connections of Host.
  */
 public function actionArpTable()
 {
     try {
         if (isset($_GET['id'])) {
             $model = $this->loadModel((int) $_GET['id']);
         } else {
             if (isset($_GET['name'])) {
                 $model = $this->loadModelByName((string) $_GET['name']);
             }
         }
         $model->loadArpTable();
         foreach ($model->arp_table as $mac => $ip) {
             $atItem['mac'] = $mac;
             $atItem['ip'] = $ip;
             $atItem['host'] = $mac ? Host::model()->findByAttributes(array('mac' => $mac)) : null;
             $arp_table[] = $atItem;
         }
         $this->render('arpTable', array('model' => $model, 'arp_table' => $arp_table));
     } catch (CHttpException $e) {
         if (isset($_GET['name'])) {
             $name = (string) trim($_GET['name']);
             $this->render('addHostNotFound', array('name' => $name));
         } else {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
 }
开发者ID:romero1989,项目名称:phpnetmap,代码行数:30,代码来源:HostController.php

示例7: actionListHosts

 public function actionListHosts()
 {
     $this->layout = '//layouts/json';
     try {
         if (isset($_GET['hostId'])) {
             $hostId = (int) $_GET['hostId'];
             // get root host
             //
             $rootHost = $hosts[] = Host::model()->findbyPk($hostId);
             // get connections
             $hostConnections = $rootHost->getConnections();
             // get host from connections
             foreach ($hostConnections as $hosts_conn) {
                 array_push($hosts, $hosts_conn->hostDst);
             }
             // in switches, get hosts by CAM table
             if ($rootHost->type == Host::TYPE_SWITCH) {
                 $rootHost->loadCamTable();
                 // TODO: associar roteadores aos switches para pegar a
                 // tabela ARP dos gateways da rede
                 //
                 $gateway = Host::model()->findByPk(Yii::app()->params['hostGatewayId']);
                 //                    $arpTable = array();
                 foreach ($rootHost->cam_table as $k => $camHost) {
                     // se existir conexao cadastrada para a porta, ignore o host
                     // TODO: usar tipo do link==backbone
                     $hostOnPort = $rootHost->getHostOnPort($camHost['port']);
                     if ($hostOnPort instanceof Host && $hostOnPort->type != Host::TYPE_UNKNOWN) {
                         continue;
                     }
                     // havendo 2 ou + hosts numa porta sem conexao cadastrada, criar 'hub virtual'
                     $port = $camHost['port'];
                     $portLabelPrefix = 'port_';
                     if ($port == $rootHost->cam_table[$k + 1]['port'] || $sourcePort == $portLabelPrefix . $port) {
                         $sourcePort = $portLabelPrefix . $port;
                         if (!isset($virtualHost[$sourcePort])) {
                             $virtualHost[$sourcePort] = new Host();
                             $virtualHost[$sourcePort]->name = $sourcePort;
                             $virtualHost[$sourcePort]->type = Host::TYPE_SUPPOSED_HUB;
                             array_push($hosts, $virtualHost[$sourcePort]);
                             $virtualConn[$sourcePort] = new Connection();
                             $virtualConn[$sourcePort]->hostSrc = $rootHost;
                             $virtualConn[$sourcePort]->hostDst = $virtualHost[$sourcePort];
                             $virtualConn[$sourcePort]->host_src_port = $camHost['port'];
                             $virtualConn[$sourcePort]->type = Connection::TYPE_SUPPOSED_LINK;
                             // TODO: especificar tipo do link
                             array_push($hostConnections, $virtualConn[$sourcePort]);
                         }
                     } else {
                         unset($sourcePort);
                     }
                     // host
                     $host = Host::model()->findByAttributes(array('mac' => $camHost['mac']));
                     if ($host instanceof Host) {
                         $h = $host;
                     } else {
                         $h = new Host();
                         $h->mac = $camHost['mac'];
                         $h->ip = $gateway instanceof Host ? $gateway->getIpInArpTable($camHost['mac']) : null;
                         $h->name = $h->ip ? $h->ip : $h->mac;
                         $h->setTypeByMAC();
                     }
                     array_push($hosts, $h);
                     // connection
                     $c = new Connection();
                     $c->hostSrc = $virtualHost[$sourcePort] ? $virtualHost[$sourcePort] : $rootHost;
                     $c->hostDst = $h;
                     $c->host_src_port = $camHost['port'];
                     $c->type = Connection::TYPE_UNKNOWN;
                     // vlan
                     $c->vlan = Vlan::model()->findByAttributes(array('tag' => $camHost['vlan_tag']));
                     if (!$c->vlan instanceof Vlan) {
                         $c->vlan = new Vlan();
                         $c->vlan->tag = $camHost['vlan_tag'];
                     }
                     array_push($hostConnections, $c);
                 }
             }
         } else {
             $hosts = Host::model()->findAll(array('order' => 'id'));
             $hostConnections = Connection::model()->findAll();
         }
         $this->render('listHosts', array('hosts' => $hosts, 'hostConnections' => $hostConnections));
     } catch (Exception $exc) {
         $this->render('error', array('error' => "listHosts error:" . $exc->getMessage()));
     }
 }
开发者ID:romero1989,项目名称:phpnetmap,代码行数:87,代码来源:MapController.php

示例8: loadModel

 /**
  * 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 the ID of the model to be loaded
  *          
  */
 public function loadModel($id)
 {
     $model = Host::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:proditis,项目名称:echofish,代码行数:16,代码来源:HostController.php

示例9: verifyOldPassword

 /**
  * Verify Old Password
  */
 public function verifyOldPassword($attribute, $params)
 {
     if (Host::model()->findByPk(Yii::app()->controller->_user['hostId'])->password != $this->hashPassword($this->{$attribute})) {
         $this->addError($attribute, "原密码不正确.");
     }
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:9,代码来源:HostChangePassword.php

示例10: array

<?php

return array('elements' => array('adminEmail' => array('type' => 'text'), 'translateCamTable' => array('type' => 'checkbox'), 'hostGatewayId' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Host::model()->findAll(), 'id', 'name', 'type')), 'cache' => array('type' => 'checkbox'), 'cacheTtlCam' => array('type' => 'text'), 'cacheTtlArp' => array('type' => 'text'), 'cacheTtlGetSnmp' => array('type' => 'text'), 'cacheTtlDefault' => array('type' => 'text')), 'buttons' => array('submit' => array('type' => 'submit', 'value' => Yii::t('default', 'Save'))));
开发者ID:romero1989,项目名称:phpnetmap,代码行数:3,代码来源:form.php

示例11: actionReview

 public function actionReview()
 {
     $message = false;
     $place = Place::model()->findByPk($_GET['id']);
     $host = Host::model()->findByPk($place['host_id']);
     $model = PlaceReview::model()->findByAttributes(array('place_id' => $_GET['id'], 'teacher_id' => $this->_user['masterId']));
     if (!count($model)) {
         $model = new PlaceReview();
     }
     if (isset($_POST['PlaceReview'])) {
         $model->attributes = $_POST['PlaceReview'];
         $model->place_id = $_GET['id'];
         $model->teacher_id = $this->_user['masterId'];
         if ($model->save()) {
             $message = true;
         }
     }
     $this->render('review', array('place' => $place, 'host' => $host, 'message' => $message, 'model' => $model));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:19,代码来源:DefaultController.php

示例12: actionIndex

 /**
  * 首页
  */
 public function actionIndex()
 {
     $teacherModel = new Teacher();
     $studentModel = new Student();
     $hostModel = new Host();
     if (XUtils::method() == 'POST') {
         /*switch($_POST){
         				case isset($_POST['Teacher']): $nowModel = new Teacher; $nowAttributes = $_POST['Teacher']; $nowRedirect = '/master';  break;
         				case isset($_POST['Student']): $nowModel = new Student; $nowAttributes = $_POST['Student']; $nowRedirect = '/student/info/sinfo'; break;
         				case isset($_POST['Host']): $nowModel = new Host; $nowAttributes = $_POST['Host']; $nowRedirect = '/host/default/Info'; break;
         				default: $nowModel = 0;
         			}
         			if($nowModel){
         				$nowModel->attributes = $nowAttributes;
         
         
                         if ($nowModel->validate() && $nowModel->save()) {
         
                             parent::_stateWrite(
                                     array(
                                 'masterId' => $nowModel->id,
         						
                                 'name' => $nowModel->name,
                                     ), array('prefix' => '_master')
                             );
         
                             $cookie = new CHttpCookie('userName', $nowModel->name);
                             Yii::app()->request->cookies['userName'] = $cookie;
                             $this->redirect(array($nowRedirect));
                         }
         			}*/
         if (isset($_POST['Teacher'])) {
             $teacherModel->attributes = $_POST['Teacher'];
             $studentUser = Student::model()->countByAttributes(array('user' => $teacherModel->user));
             $hostUser = Host::model()->countByAttributes(array('user' => $teacherModel->user));
             //echo CActiveForm::validate($hostModel);
             //判断账号与其他角色账号是否相同
             if ($studentUser != 0 || $hostUser != 0) {
                 Yii::app()->user->setFlash('TeacherUserError', '您的手机号已在其他角色注册');
             }
             $tAgree = Yii::app()->request->getPost('teacherAgree');
             if ($tAgree === NULL) {
                 Yii::app()->user->setFlash('teacherAgreeMessage', '同意条款未勾选');
             }
             if ($teacherModel->validate() && $studentUser == 0 && $hostUser == 0 && $tAgree === 'on' && $teacherModel->save()) {
                 parent::_stateWrite(array('masterId' => $teacherModel->id, 'name' => $teacherModel->name), array('prefix' => '_master'));
                 if ($teacherModel->name == '') {
                     $teacherModel->name = '导师';
                 }
                 $cookie = new CHttpCookie('userName', $teacherModel->name);
                 Yii::app()->request->cookies['userName'] = $cookie;
                 $this->_cookiesSet('userId', $teacherModel->id);
                 $this->_cookiesSet('userType', 'student');
                 Yii::app()->user->setFlash('TSSuccess', '注册成功!请完善个人信息并提交身份认证即可发布课程');
                 $this->redirect(array('/master'));
             }
         } else {
             if (isset($_POST['Student'])) {
                 $studentModel->attributes = $_POST['Student'];
                 //echo CActiveForm::validate($studentModel);
                 $teacherUser = Teacher::model()->countByAttributes(array('user' => $studentModel->user));
                 $hostUser = Host::model()->countByAttributes(array('user' => $studentModel->user));
                 //echo CActiveForm::validate($hostModel);
                 //判断账号与其他角色账号是否相同
                 if ($teacherUser != 0 || $hostUser != 0) {
                     Yii::app()->user->setFlash('StudentUserError', '您的手机号已在其他角色注册');
                 }
                 $sAgree = Yii::app()->request->getPost('studentAgree');
                 if ($sAgree === NULL) {
                     Yii::app()->user->setFlash('studentAgreeMessage', '同意条款未勾选');
                 }
                 $studentModel->register_time = date('Y-m-d H:m:s', time());
                 if ($studentModel->validate() && $teacherUser == 0 && $hostUser == 0 && $sAgree === 'on' && $studentModel->save()) {
                     parent::_stateWrite(array('studentId' => $studentModel->id, 'name' => $studentModel->name), array('prefix' => '_student'));
                     if ($studentModel->name == '') {
                         $studentModel->name = '学员';
                     }
                     $cookie = new CHttpCookie('userName', $studentModel->name);
                     Yii::app()->request->cookies['userName'] = $cookie;
                     $this->_cookiesSet('userId', $studentModel->id);
                     $this->_cookiesSet('userType', 'student');
                     $this->redirect(array('/student/info/sinfo'));
                 }
             } else {
                 if (isset($_POST['Host'])) {
                     $hostModel->attributes = $_POST['Host'];
                     $teacherUser = Teacher::model()->countByAttributes(array('user' => $hostModel->user));
                     $studentUser = Student::model()->countByAttributes(array('user' => $hostModel->user));
                     //echo CActiveForm::validate($hostModel);
                     //判断账号与其他角色账号是否相同
                     if ($studentUser != 0 || $teacherUser != 0) {
                         Yii::app()->user->setFlash('HostUserError', '您的手机号已在其他角色注册');
                     }
                     $hAgree = Yii::app()->request->getPost('hostAgree');
                     if ($hAgree === NULL) {
                         Yii::app()->user->setFlash('hostAgreeMessage', '同意条款未勾选');
                     }
//.........这里部分代码省略.........
开发者ID:tecshuttle,项目名称:51qsk,代码行数:101,代码来源:RegisterController.php


注:本文中的Host::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。