src/Controller/NavigationController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Repository\ModelRepository;
  7. use App\Repository\PriceRepository;
  8. use App\Service\PdfService;
  9. use App\Entity\Payment;
  10. use App\Entity\Client;
  11. class NavigationController extends AbstractController
  12. {
  13.     #[Route(path'/'name'index')]
  14.     public function index(): Response
  15.     {
  16.         return $this->render('index.html.twig' );
  17.     }
  18.     #[Route(path'/user'name'user_page')]
  19.     public function userPageModelRepository $modelRepositoryPriceRepository $priceRepository): Response
  20.     {
  21.         $models $modelRepository->findAll();
  22.         $price $priceRepository->findActive();
  23.         return $this->render('client/userPage.html.twig' , ["models" => $models"price" => $price]);
  24.     }
  25.     
  26.     #[Route(path'/readPaymentPdf/{id}'name'read_payment_pdf')]
  27.     public function readPaymentPdfPdfService $pdfService Payment $payment): Response
  28.     {
  29.         
  30.         if( ( $this->getUser() != $payment->getClient()->getUser() ) && !$this->isGranted('ROLE_ADMIN') ){
  31.             return new Response(''403);
  32.         }
  33.         $html $this->render('pdf/paymentInvoice.html.twig', ['payment' => $payment]);
  34.         $pdfService->streamPdf($html);
  35.         return new Response(''200, [
  36.             'Content-Type' => 'application/pdf',
  37.           ]);
  38.     }
  39.     
  40.     #[Route(path'/binanceApi'name'binanceApi')]
  41.     public function binanceApi(): Response
  42.     {
  43.         //$connexion = new \PDO("mysql:host=chrisjz9.mysql.db/chrisjz9;dbname=chrisjz9;port=3306", "chrisjz9", "Roinfo91");
  44.         $connexion = new \PDO("mysql:host=127.0.0.1;dbname=mmi;port=3306""root""");
  45.         $requete "SELECT * FROM CLIENT";
  46.         $resultats $connexion->query($requete);
  47.         foreach ($resultats->fetchAll() as $client) {
  48.             var_dump$client['name'] );
  49.         }
  50.         $url "https://whattomine.com/coins/162.json?hr=70&p=0.0&fee=0.0&cost=0.1&cost_currency=USD&hcost=0.0&span_br=&span_d=24";
  51.         $ch curl_init();
  52.         curl_setopt($chCURLOPT_URL$url);
  53.         curl_setopt($chCURLOPT_HEADER0);
  54.         curl_setopt($chCURLOPT_HTTPHEADER, array('Accept: application/json''Content-Type: application/json'));
  55.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  56.         $response curl_exec($ch);
  57.         curl_close($ch);
  58.         
  59.         $data json_decode($responsetrue);
  60.         
  61.         if($data == null){
  62.             return new Response("no response");
  63.         }
  64.         
  65.         return new Responsefloatvalsubstr($data['profit'], 1) ) );
  66.     }
  67.     #[Route(path'/testApi'name'testApi')]
  68.     public function testApi(): Response
  69.     {
  70.         /*
  71.         $today = new \DateTime();
  72.         $text = "";
  73.         $key = "jvIkawn4EeidllU2F14lWz1NJMQJ84CqwFwF5r8eQBrx2EVe3jVoogAfJg84iv81";
  74.         $secret = "rdveQW1Vd06Q2LTGL18cluentqNTQkvV0iOAGBajHLrEaalRbDzuMZrphK45okvN";
  75.         $ch = curl_init();
  76.             
  77.             $url = "https://api.binance.com/api/v3/depth";
  78.             curl_setopt($ch, CURLOPT_URL, $url);
  79.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  80.             curl_setopt($ch, CURLOPT_HTTPHEADER,  array('X-MBX-APIKEY:'.$key));
  81.             $querystring = "symbol=ETH";
  82.             $signature = hash_hmac('SHA256',$querystring ,$secret);
  83.             $post = [
  84.                 'symbol' => 'ETH',
  85.                 'signature' => $signature,
  86.             ];
  87.             curl_setopt($ch, CURLOPT_POST, 1);
  88.             curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  89.             $result = curl_exec($ch);
  90.             curl_close ($ch);
  91.             var_dump($result);
  92.         */
  93.             
  94.         $url "https://api.binance.com/api/v3/depth?symbol=BNBBTC";
  95.         
  96.         $ch curl_init();
  97.         curl_setopt($chCURLOPT_URL$url);
  98.         curl_setopt($chCURLOPT_HEADER0);
  99.         curl_setopt($chCURLOPT_HTTPHEADER, array('Accept: application/json''Content-Type: application/json'));
  100.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  101.         $response curl_exec($ch);
  102.         curl_close($ch);
  103.         var_dump($response);
  104.         return new Response("-----------");
  105.     }
  106. }