本文整理汇总了PHP中Host::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Host::save方法的具体用法?PHP Host::save怎么用?PHP Host::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hosts_new
function hosts_new()
{
if ($_POST) {
$h = new Host();
$h->save($_POST);
update_scan_script();
render('show', $h->id);
}
render();
}
示例2: save
function save($id = FALSE)
{
if ($_POST) {
$host = new Host($id);
$host->from_array($_POST);
$host->save();
set_notify('success', lang('save_data_complete'));
}
redirect('hosts');
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Host();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Host'])) {
$model->attributes = $_POST['Host'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例4: actionCreate
/**
* 录入
*
*/
public function actionCreate()
{
parent::_acl();
$model = new Host();
if (isset($_POST['Host'])) {
$acl = $this->_gets->getPost('acl');
$model->attributes = $_POST['Host'];
if ($model->save()) {
AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id));
$this->redirect(array('index'));
}
}
$this->render('host_create', array('model' => $model));
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
if (Session::token() != Input::get('_token') || !Request::ajax()) {
App::abort(401, 'You are not authorized or using wrong request type or csrf token not provided.');
}
// store
$host = new Host();
$host->name = Input::get('name');
$host->host = Input::get('host');
$host->parent = Input::get('parent');
$host->type = Input::get('type');
$host->storage = Input::get('path');
$host->source = Input::get('source');
$host->ssh_login = Input::get('ssh_login');
$host->ssh_pwd = Input::get('ssh_pwd');
$host->db_name = Input::get('db_name');
$host->db_user = Input::get('db_user');
$host->db_pwd = Input::get('db_pwd');
$host->cron = Input::get('cron');
$host->save();
return "Host saved!";
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($name = null, $ip = null, $mac = null)
{
$model = new Host();
/* Set attributes by _GET */
if (!is_null($name) && !isset($_POST['Host'])) {
$model->name = (string) trim($name);
}
if (!is_null($ip) && !isset($_POST['Host'])) {
$model->ip = (string) trim($ip);
}
if (!is_null($mac) && !isset($_POST['Host'])) {
$model->mac = (string) trim($mac);
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Host'])) {
$model->attributes = $_POST['Host'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例7: import_post
/** import_post()
Actually imports the post.
*/
public function import_post()
{
try {
// Error checking
if ($_FILES["file"]["error"] > 0) {
throw new Exception(sprintf('Error: ' . (is_array($_FILES["file"]["error"]) ? implode(', ', $_FILES["file"]["error"]) : $_FILES["file"]["error"])));
}
if (!file_exists($_FILES["file"]["tmp_name"])) {
throw new Exception('Could not find tmp filename');
}
$numSuccess = $numFailed = $numAlreadyExist = 0;
$handle = fopen($_FILES["file"]["tmp_name"], "r");
// Get all the service id's so they can be enabled.
$ModuleIDs = $this->getClass('ModuleManager')->find('', '', '', '', '', '', '', 'id');
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
// Ignore header data if left in CSV
if (preg_match('#ie#', $data[0])) {
continue;
}
$totalRows++;
if (count($data) < 7 && count($data) >= 2) {
try {
// Error checking
$MACs = $this->parseMacList($data[0]);
$Host = $this->getClass('HostManager')->getHostByMacAddresses($MACs);
if ($Host && $Host->isValid()) {
throw new Exception('A Host with any or one of these MACs already exists');
}
if ($this->getClass('HostManager')->exists($data[1])) {
throw new Exception('A host with this name already exists');
}
$Host = new Host(array('name' => $data[1], 'description' => $data[3] . ' Uploaded by batch import on', 'ip' => $data[2], 'imageID' => $data[4], 'createdTime' => $this->nice_date()->format('Y-m-d H:i:s'), 'createdBy' => $this->FOGUser->get('name')));
$Host->addModule($ModuleIDs);
$Host->addPriMAC($MACs[0]);
array_shift($MACs);
$Host->addAddMAC($MACs);
if ($Host->save()) {
$this->HookManager->processEvent('HOST_IMPORT', array('data' => &$data, 'Host' => &$Host));
$numSuccess++;
} else {
$numFailed++;
}
} catch (Exception $e) {
$numFailed++;
$uploadErrors .= sprintf('%s #%s: %s<br />', _('Row'), $totalRows, $e->getMessage());
}
} else {
$numFailed++;
$uploadErrors .= sprintf('%s #%s: %s<br />', _('Row'), $totalRows, _('Invalid number of cells'));
}
}
fclose($handle);
} catch (Exception $e) {
$error = $e->getMessage();
}
// Title
$this->title = _('Import Host Results');
unset($this->headerData);
$this->attributes = array(array(), array());
$this->templates = array('${field}', '${input}');
$fields = array(_('Total Rows') => $totalRows, _('Successful Hosts') => $numSuccess, _('Failed Hosts') => $numFailed, _('Errors') => $uploadErrors);
foreach ((array) $fields as $field => $input) {
$this->data[] = array('field' => $field, 'input' => $input);
}
// Hook
$this->HookManager->processEvent('HOST_IMPORT_FIELDS', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes));
// Output
$this->render();
}
示例8: Host
if ($Host->createImagePackage(1, 'AutoRegTask')) {
print _('Done, with imaging!');
} else {
print _('Done, but unable to create task!');
}
} else {
print _('Done!');
}
} else {
$realhost = $macsimple;
if (!$Host || !$Host->isValid()) {
$Host = new Host(array('name' => $realhost, 'description' => sprintf('%s %s', _('Created by FOG Reg on'), date('F j, Y, g:i a')), 'createdTime' => $FOGCore->formatTime('now', 'Y-m-d H:i:s'), 'createdBy' => 'FOGREG'));
$Host->addPriMAC($PriMAC);
$Host->addAddMAC($MACs);
$Host->addModule($ids);
if (!$Host->save()) {
throw new Exception(_('Failed to save new Host!'));
}
print _('Done');
} else {
print _('Already registered as') . ': ' . $Host->get('name');
}
}
} else {
print _('Already registered as') . ': ' . $Host->get('name');
}
}
} catch (Exception $e) {
print $e->getMessage();
}
}
示例9: 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'];
if ($teacherModel->validate() && $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);
if ($studentModel->validate() && $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'];
//echo CActiveForm::validate($hostModel);
if ($hostModel->validate() && $hostModel->save()) {
parent::_stateWrite(array('hostId' => $hostModel->id, 'name' => $hostModel->name), array('prefix' => '_host'));
if ($hostModel->name == '') {
$hostModel->name = '场地主';
}
$cookie = new CHttpCookie('userName', $hostModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->_cookiesSet('userId', $hostModel->id);
$this->_cookiesSet('userType', 'host');
$this->redirect(array('/host'));
}
}
}
}
}
$this->render('index', array('teacherModel' => $teacherModel, 'studentModel' => $studentModel, 'hostModel' => $hostModel));
}
示例10: 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', '同意条款未勾选');
}
//.........这里部分代码省略.........