/** * */ public function actionCharge($ip) { $model = Charge::find()->where(['ip' => $ip])->one(); $ipModel = Ip::find()->where(['ip' => $ip])->one(); if (!$model) { $model = new Charge(); $model->ip = $ip; } if ($model->load(Yii::$app->request->post())) { if ($model->state != 'state_normal') { $telnet = new Telnet(); $telnet->signin(); $telnet->rebind($ip, $ipModel->mac); $telnet->close(); $model->state = "state_normal"; } $model->save(); return $this->redirect(['index']); } else { return $this->render('charge', ['model' => $model]); } }