src/Module/Firewall/Controller/GlobalURL/GetGlobalURLFileController.php line 12

  1. <?php
  2. namespace App\Module\Firewall\Controller\GlobalURL;
  3. use App\Module\Firewall\Entity\GlobalURL;
  4. use App\Module\Symfony\Controller\SageController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. #[Route("/getAPIlink")]
  8. class GetGlobalURLFileController extends SageController
  9. {
  10. #[Route("/{globalURL}")]
  11.     public function __invoke(
  12.         GlobalURL $globalURL)
  13.     {
  14.         // Generate response
  15.         $response = new Response();
  16.         $content "; Created by Sage Link monitor API on " .date('d-m-Y-Hi'). "  \r\n";
  17.         $content .="; Hello there Boy Cracky! \r\n" ;
  18.         $content .=$globalURL->getIpAddressList();
  19. //        // Create the TEMP File
  20. //        $file = fopen('php://memory', 'rw+');
  21. //
  22. //        // Need to add CR LF to end of line (Windows only ??)
  23. //        // Wont matter anyway, just be a blank line
  24. //
  25. //        //Headings
  26. //        fputs( $file , "; Created by Sage Link monitor API on " .date('d-m-Y-Hi'). "  \r\n");
  27. //        fputs( $file , "; Hello there Boy Cracky! \r\n" );
  28. //        // The list of IPs
  29. //        fputs($file, $globalURL->getIpAddressList());
  30. //
  31. //        rewind($file);
  32. //        $content = stream_get_contents($file);
  33.         // Set headers
  34.         $response->headers->set('Cache-Control''private');
  35.         $response->headers->set('Content-type''text/plain' );
  36.         $response->headers->set('Content-Disposition''attachment; filename="drop.txt";');
  37.         $response->headers->set('Content-length',  strlen($content));
  38.         $response->setcontent$content );
  39.         return $response;
  40.     }
  41. }