public function actionImpression($email = false) { if (!$email) { throw new Exception('There is no parametr email.'); } Yii::$app->response->format = Response::FORMAT_RAW; $headers = Yii::$app->response->headers; $headers->add('Content-type', 'image/gif'); $headers->add('Content-Length', '42'); $headers->add('Cache-Control', 'private, no-cache, no-cache=Set-Cookie, proxy-revalidate'); $headers->add('Expires', 'Wed, 11 Jan 2000 12:59:00 GMT'); $headers->add('Last-Modified', 'Wed, 11 Jan 2006 12:59:00 GMT'); $headers->add('Pragma', 'no-cache'); echo sprintf('%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%', 71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 255, 0, 192, 192, 192, 0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59); $model = new Impression(); $model->time = (new DateTime('now'))->format('Y-m-d H:i:s'); $model->ip = ip2long(Yii::$app->request->userIP); $user = User::findOne(['email' => $email]); if ($user !== null) { $model->user_id = $user->id; } $model->save(); }