Пример #1
0
 public function downloadErrorsAction()
 {
     $date = $this->params('date');
     $path = sprintf('data/logs/php_log.%s.xml', $date);
     $response = new Stream();
     $response->setStream(fopen($path, 'r'));
     $response->setCleanup(false);
     $response->setStatusCode(200);
     $headers = $response->getHeaders();
     $headers->addHeaderLine(sprintf('Content-Disposition: attachment; filename="log-%s.csv"', $date));
     $headers->addHeaderLine('Content-Type: text/csv');
     return $response;
 }
Пример #2
0
 public function tfaRenderQrCodeAction()
 {
     $filePath = tempnam('data/tmp/', '2fa-qr-');
     $renderer = new \BaconQrCode\Renderer\Image\Png();
     $renderer->setForegroundColor(new \BaconQrCode\Renderer\Color\Rgb(170, 45, 76));
     $renderer->setHeight(256);
     $renderer->setWidth(256);
     $writer = new \BaconQrCode\Writer($renderer);
     $writer->writeFile('123456', $filePath);
     $response = new Stream();
     $response->setCleanup(true);
     $response->setStream(fopen($filePath, 'rb'));
     $response->setStreamName($filePath);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('Content-Length', filesize($filePath));
     $headers->addHeaderLine('Content-Type', 'image/png');
     return $response;
 }
Пример #3
0
 public function renderQrCodeAction()
 {
     /** @var AccountInterface $account */
     $account = $this->zourceAccount();
     $oneTimePassword = new TOTP($account->getContact()->getFullName(), $this->tfaService->getSecret());
     $oneTimePassword->setIssuer('Zource');
     $oneTimePassword->setIssuerIncludedAsParameter(true);
     $oneTimePassword->setParameter('image', $this->url()->fromRoute('settings/security/tfa-image', [], ['force_canonical' => true]));
     $filePath = tempnam('data/tmp/', '2fa-qr-');
     $renderer = new Png();
     $renderer->setHeight(256);
     $renderer->setWidth(256);
     $writer = new Writer($renderer);
     $writer->writeFile($oneTimePassword->getProvisioningUri(true), $filePath);
     $response = new Stream();
     $response->setCleanup(true);
     $response->setStream(fopen($filePath, 'rb'));
     $response->setStreamName($filePath);
     $headers = $response->getHeaders();
     $headers->addHeaderLine('Content-Length', filesize($filePath));
     $headers->addHeaderLine('Content-Type', 'image/png');
     return $response;
 }