/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Ipaddress();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Ipaddress'])) {
         $model->attributes = $_POST['Ipaddress'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = new Ipaddress('search');
     $formModel = new Ipaddress();
     $model->unsetAttributes();
     if (isset($_GET['pageSize'])) {
         Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']);
         unset($_GET['pageSize']);
     }
     if (isset($_GET['Ipaddress'])) {
         $model->attributes = $_GET['Ipaddress'];
     }
     if (isset($_POST['Ipaddress']) && isset($_POST['createNewIP'])) {
         $formModel->attributes = $_POST['Ipaddress'];
         if ($formModel->save()) {
             $formModel->unsetAttributes();
             Yii::app()->user->setFlash("success", "<strong>Success : </strong> {$model->ip_address} new IP address added. ");
         }
     } else {
         $formModel->ip_address = Yii::app()->request->getUserHostAddress();
     }
     $datasource = $model->search();
     $this->render('index', compact('datasource', 'model', 'formModel'));
 }