/** * Creates a new Ip model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Ip(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Ip model. * 创建一个新的IP绑定,并且将绑定数据存入数据库 * @return mixed */ public function actionCreate() { $model = new Ip(); if ($post = Yii::$app->request->post()) { $model->load(Yii::$app->request->post()); $telnet = new telnet(); $loginMsg = $telnet->signin(); $telnet->bind($model->ip, $model->mac); $telnet->close(); $model->save(); if ($model->type == 3) { return $this->redirect(['charge', 'ip' => $model->ip]); } else { return $this->redirect(['index']); } } else { return $this->render('create', ['model' => $model]); } }