Exemplo n.º 1
0
 /**
  * @param $code
  * @return \yii\web\Response
  * @throws \yii\web\HttpException
  * @throws \yii\web\NotAcceptableHttpException
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionForward($code)
 {
     $model_info = new NixUserInfo();
     $url = NixShortUrls::validateShortCode($code);
     $url->updateCounters(['counter' => 1]);
     $model_info->setAttributes(['short_url_id' => $url['id'], 'user_agent' => Yii::$app->request->userAgent, 'user_refer' => Yii::$app->request->referrer, 'user_ip' => Yii::$app->request->userIP, 'date' => date('Y-m-d')]);
     $model_info->save();
     return $this->redirect($url['long_url']);
 }