src/Controller/FrontController.php line 314

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Form\ContactType;
  4. use App\Entity\Stats;
  5. use App\Form\StatsType;
  6. use App\Repository\AdminStatsRepository;
  7. use App\Entity\Upartistik;
  8. use App\Repository\UpartistikRepository;
  9. use App\Entity\MobilierCategories;
  10. use App\Repository\MobilierCategoriesRepository;
  11. use App\Entity\Mobilier;
  12. use App\Repository\MobilierRepository;
  13. use App\Entity\MobilierTechniques;
  14. use App\Repository\MobilierTechniquesRepository;
  15. use App\Entity\MobilierImages;
  16. use App\Repository\MobilierImagesRepository;
  17. use App\Entity\Contact;
  18. use App\Repository\ContactRepository;
  19. use App\Entity\Couv;
  20. use App\Repository\CouvRepository;
  21. use App\Entity\Apropos;
  22. use App\Repository\AproposRepository;
  23. use App\Entity\Accmobilier;
  24. use App\Repository\AccmobilierRepository;
  25. use App\Entity\AccEspPro;
  26. use App\Repository\AccEspProRepository;
  27. use App\Entity\AccContact;
  28. use App\Repository\AccContactRepository;
  29. use App\Entity\ProImages;
  30. use App\Repository\ProImagesRepository;
  31. use App\Entity\ProTexte;
  32. use App\Repository\ProTexteRepository;
  33. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  34. use Symfony\Component\HttpFoundation\Response;
  35. use Symfony\Component\Routing\Annotation\Route;
  36. use Symfony\Component\HttpFoundation\Request;
  37. use Symfony\Component\Mailer\MailerInterface;
  38. use Symfony\Component\Mime\Email;
  39. use Symfony\Component\Mime\Address;
  40. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  41. use Symfony\Component\HttpFoundation\RedirectResponse;
  42. use Webgiciel\RecaptchaBundle\Type\RecaptchaSubmitType;
  43. use Webgiciel\RecaptchaBundle\RecaptchaBundle;
  44. use Webgiciel\RecaptchaBundle\RecaptchaCompilerPass;
  45. use Symfony\Component\HttpFoundation\RequestStack;
  46. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  47. use Doctrine\ORM\EntityManagerInterface;
  48. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  49. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  50. use Symfony\Component\String\Slugger\SluggerInterface;
  51. use Doctrine\Common\Collections\ArrayCollection;
  52. class FrontController extends AbstractController
  53. {
  54.   //
  55.   public $mailAdmin "admin@webgiciel.com";
  56.   public $mailExpe "contact@up-paris.com";
  57.   public $mailContact "contact@up-paris.com";
  58.   private $repUser;
  59.   private $passwordEncoder;
  60.   public function __construct(MobilierImagesRepository $mobImgrepo,ProTexteRepository $protexterepoProImagesRepository $proimagerepoAccContactRepository $acccontactrepoAccEspProRepository $accespaceprorepoAccmobilierRepository $accmobilierrepoAproposRepository $aproposrepoCouvRepository $couvrepoMobilierTechniquesRepository $mobTechContactRepository $contactRepoMobilierRepository $mobAdminStatsRepository $statsEntityManagerInterface $emUserPasswordEncoderInterface $passwordEncoderUpartistikRepository $upartRepoMobilierCategoriesRepository $mobCat)
  61.   {
  62.     $this->stats $stats;
  63.     $this->em $em;
  64.     $this->passwordEncoder $passwordEncoder;
  65.     $this->upartRepo $upartRepo;
  66.     $this->mobCat $mobCat;
  67.     $this->mob $mob;
  68.     $this->contactRepo $contactRepo;
  69.     $this->mobTech $mobTech;
  70.     $this->mobImgrepo $mobImgrepo;
  71.     $this->couvrepo $couvrepo;
  72.     $this->aproposrepo $aproposrepo;
  73.     $this->accmobilierrepo $accmobilierrepo;
  74.     $this->accespaceprorepo $accespaceprorepo;
  75.     $this->acccontactrepo $acccontactrepo;
  76.     $this->proimagerepo $proimagerepo;
  77.     $this->protexterepo $protexterepo;
  78.   }
  79.     /**
  80.      * @Route("/", name="front_index")
  81.      */
  82.     public function index(Request $requestMailerInterface $mailerSessionInterface $session): Response
  83.     {
  84.       $maintenant = new \DateTime("now");
  85.       $time = new \DateTime("2022-06-21 00:00:00");
  86.       // dump($maintenant);
  87.       // dump($time);
  88.       if ($maintenant $time )
  89.       {
  90.         // dump("construction");
  91.         // enregistre un log
  92.         $this->moucheUser("visite""construction_index");
  93.         // dump($this->upartRepo->find(1));
  94.         // recupère les categories
  95.         $allMobCat $this->mobCat->findAllParOrdre();
  96.         return $this->render('front/construction.html.twig', [
  97.           'controller_name' => 'construction_index',
  98.           'upartRepo' => $this->upartRepo->find(1),
  99.           'allMobCat' => $allMobCat,
  100.         ]);
  101.       }
  102.       else{
  103.         // dump("site");
  104.         // enregistre un log
  105.         $this->moucheUser("visite""front_index");
  106.         // dump($this->upartRepo->find(1));
  107.         // recupère les categories
  108.         $allMobCat $this->mobCat->findAllParOrdre();
  109.         // form
  110.         $form $this->createForm(ContactType::class);
  111.         $form->handleRequest($request);
  112.         // captcha
  113.         $name date('Y_m_d_h_i_s');
  114.         if ($form->isSubmitted() && $form->isValid())
  115.         {
  116.           if ( $form['captcha']->getData() == $session->get('captcha') )
  117.           {
  118.             // envoi un mail du contact
  119.             $email = (new TemplatedEmail())
  120.               ->from($this->mailExpe)
  121.               ->to($this->mailAdmin)
  122.               ->subject('Envoi depuis page Contact')
  123.               ->text('Envoi depuis page Contact.')
  124.               ->htmlTemplate('mails/_Mail_Contact.html.twig')
  125.               ->context([
  126.                 'nom' => $form['nom']->getData(),
  127.                 'emailx' => $form['email']->getData(),
  128.                 'message' => $form['message']->getData(),
  129.               ])
  130.             ;
  131.             $errorM1 0;
  132.             try {
  133.               $mailer->send($email);
  134.             } catch (TransportExceptionInterface $e) {
  135.               // some error prevented the email sending; display an
  136.               // error message or try to resend the message
  137.               $this->addFlash('warning''Erreur Message !');
  138.               $errorM1 1;
  139.             }
  140.             if ($errorM1 == 0)
  141.             {
  142.               // dump("ok");
  143.               $this->addFlash('success''Message envoyé !');
  144.             }
  145.             else
  146.             {
  147.               // dump("false");
  148.             }
  149.             //return $this->redirectToRoute('paul_contact');
  150.           }
  151.           else
  152.           {
  153.             $this->addFlash('warning''Erreur de captcha!');
  154.           }
  155.         }
  156.         return $this->render('front/index.html.twig', [
  157.           'controller_name' => 'front_index',
  158.           'upartRepo' => $this->upartRepo->find(1),
  159.           'allMobCat' => $allMobCat,
  160.           'form' => $form->createView(),
  161.           'img' => $this->captcha($name$session),
  162.           'name' => $name,
  163.           'couvs' => $this->couvrepo->findAll(),
  164.           'apropos' => $this->aproposrepo->find(1),
  165.           'accmobiliers' => $this->accmobilierrepo->findByOrdre(),
  166.           'accespacepros' => $this->accespaceprorepo->findByOrdre(),
  167.           'acccontact' => $this->acccontactrepo->findAll(),
  168.         ]);
  169.       }
  170.     }
  171.     /**
  172.      * @Route("/site", name="construction_index")
  173.      */
  174.     public function index2(Request $requestMailerInterface $mailerSessionInterface $session): Response
  175.     {
  176.       // enregistre un log
  177.       $this->moucheUser("visite""front_index");
  178.       // dump($this->upartRepo->find(1));
  179.       // recupère les categories
  180.       $allMobCat $this->mobCat->findAllParOrdre();
  181.       // form
  182.       $form $this->createForm(ContactType::class);
  183.       $form->handleRequest($request);
  184.       // captcha
  185.       $name date('Y_m_d_h_i_s');
  186.       if ($form->isSubmitted() && $form->isValid())
  187.       {
  188.         if ( $form['captcha']->getData() == $session->get('captcha') )
  189.         {
  190.           // envoi un mail du contact
  191.           $email = (new TemplatedEmail())
  192.             ->from($this->mailExpe)
  193.             ->to($this->mailAdmin)
  194.             ->subject('Envoi depuis page Contact')
  195.             ->text('Envoi depuis page Contact.')
  196.             ->htmlTemplate('mails/_Mail_Contact.html.twig')
  197.             ->context([
  198.               'nom' => $form['nom']->getData(),
  199.               'emailx' => $form['email']->getData(),
  200.               'message' => $form['message']->getData(),
  201.             ])
  202.           ;
  203.           $errorM1 0;
  204.           try {
  205.             $mailer->send($email);
  206.           } catch (TransportExceptionInterface $e) {
  207.             // some error prevented the email sending; display an
  208.             // error message or try to resend the message
  209.             $this->addFlash('warning''Erreur Message !');
  210.             $errorM1 1;
  211.           }
  212.           if ($errorM1 == 0)
  213.           {
  214.             // dump("ok");
  215.             $this->addFlash('success''Message envoyé !');
  216.           }
  217.           else
  218.           {
  219.             // dump("false");
  220.           }
  221.           //return $this->redirectToRoute('paul_contact');
  222.         }
  223.         else
  224.         {
  225.           $this->addFlash('warning''Erreur de captcha!');
  226.         }
  227.       }
  228.       return $this->render('front/index.html.twig', [
  229.         'controller_name' => 'front_index',
  230.         'upartRepo' => $this->upartRepo->find(1),
  231.         'allMobCat' => $allMobCat,
  232.         'form' => $form->createView(),
  233.         'img' => $this->captcha($name$session),
  234.         'name' => $name,
  235.         'couvs' => $this->couvrepo->findAll(),
  236.         'apropos' => $this->aproposrepo->find(1),
  237.         'accmobiliers' => $this->accmobilierrepo->findByOrdre(),
  238.         'accespacepros' => $this->accespaceprorepo->findByOrdre(),
  239.         'acccontact' => $this->acccontactrepo->findAll(),
  240.       ]);
  241.     }
  242.     /**
  243.     * @Route("/qui_sommes_nous", name="paul_quisommesnous")
  244.     */
  245.     public function quisommesnous(): Response
  246.     {
  247.       // enregistre un log
  248.       $this->moucheUser("visite""paul_quisommesnous");
  249.       return $this->render('front/quisommesnous.html.twig', [
  250.         'controller_name' => 'paul_quisommesnous',
  251.         'upartRepo' => $this->upartRepo->find(1),
  252.       ]);
  253.     }
  254.     /**
  255.     * @Route("/espacePro", name="paul_espacePro")
  256.     */
  257.     public function espacePro(): Response
  258.     {
  259.       // enregistre un log
  260.       $this->moucheUser("visite""paul_espacePro");
  261.       return $this->render('front/espacePro.html.twig', [
  262.         'controller_name' => 'paul_espacePro',
  263.         'upartRepo' => $this->upartRepo->find(1),
  264.         'accespacepros' => $this->accespaceprorepo->findByOrdre(),
  265.         'proimages' => $this->proimagerepo->findByOrdre(),
  266.         'protexte' => $this->protexterepo->find(1),
  267.       ]);
  268.     }
  269.     /**
  270.     * @Route("/mobilier", name="paul_mobilier")
  271.     */
  272.     public function mobilier(): Response
  273.     {
  274.       // enregistre un log
  275.       $this->moucheUser("visite""paul_mobilier");
  276.       // recupère les categories
  277.       //$allMobCat = $this->mobCat->findAllParOrdre();
  278.       // recupere les mobiliers
  279.       $allMob $this->mob->findAllParOrdre();
  280.       // dump($allMob);
  281.       return $this->render('front/mobilier.html.twig', [
  282.         'controller_name' => 'paul_mobilier',
  283.         'upartRepo' => $this->upartRepo->find(1),
  284.         /* 'allMobCat' => $allMobCat, */
  285.         'allMob' => $allMob,
  286.       ]);
  287.     }
  288.     /**
  289.     * @Route("/mobilier2", name="paul_mobilier2")
  290.     */
  291.     public function mobilier2(): Response
  292.     {
  293.       // enregistre un log
  294.       $this->moucheUser("visite""paul_mobilier2");
  295.       // recupère les categories
  296.       $allMobCat $this->mobCat->findAllParOrdre();
  297.       // recupere les mobiliers
  298.       $allMob $this->mob->findAllParOrdre();
  299.       return $this->render('front/mobilier2.html.twig', [
  300.         'controller_name' => 'paul_mobilier2',
  301.         'upartRepo' => $this->upartRepo->find(1),
  302.         'allMobCat' => $allMobCat,
  303.         'allMob' => $allMob,
  304.       ]);
  305.     }
  306.     /**
  307.     * @Route("/mobilier/{categorie}", name="paul_mobilier_cat")
  308.     */
  309.     public function mobilierListe($categorie): Response
  310.     {
  311.       // enregistre un log
  312.       $this->moucheUser("visite""paul_mobilier_cat ".$categorie);
  313.       // recupère les objets
  314.       $allMob $this->mob->findCatParOrdre($cat[0]->getId());
  315.       // dump($allMob);
  316.       return $this->render('front/mobilierListe.html.twig', [
  317.         'controller_name' => 'paul_mobilier_cat',
  318.         'upartRepo' => $this->upartRepo->find(1),
  319.         'categorie' => $categorie,
  320.         'allMob' => $allMob,
  321.       ]);
  322.     }
  323.     /**
  324.     * @Route("/mobilier/detail/{slug}", name="paul_mobilier_detail")
  325.     */
  326.     public function paul_mobilier_detail($slug): Response
  327.     {
  328.       // recupère la categorie
  329.       // dump($categorie);
  330.       //$cat0 = $this->mobCat->findCat($categorie);
  331.       //$cat = $cat0[0]->getId();
  332.       // // dump($cat);
  333.       // dump($slug);
  334.       // recupère les objets
  335.       $allMob $this->mob->findMobParSlug($slug);
  336.       // dump($allMob[0]);
  337.       // recupere la fiche technique
  338.       $allTech $this->mobTech->findOrderByMob($allMob[0]->getId());
  339.       // dump($allTech);
  340.       // enregistre un log
  341.       $this->moucheUser("visite""paul_mobilier_detail");
  342.       /*
  343.       */
  344.       // affiche
  345.       return $this->render('front/mobilierDetail.html.twig', [
  346.         'controller_name' => 'paul_mobilier_detail',
  347.         'upartRepo' => $this->upartRepo->find(1),
  348.         //'categorie' => $categorie,
  349.         'allMob' => $allMob[0],
  350.         'allTech' => $allTech,
  351.       ]);
  352.     }
  353.     /**
  354.     * @Route("/mobilierC/{categorie}/{slug}", name="paul_mobilier_cat_detail")
  355.     */
  356.     public function mobilierDetail($categorie$slug): Response
  357.     {
  358.       // recupère la categorie
  359.       // // dump($categorie);
  360.       //$cat0 = $this->mobCat->findCat($categorie);
  361.       //$cat = $cat0[0]->getId();
  362.       // // dump($cat);
  363.       // dump($slug);
  364.       // recupère les objets
  365.       $allMob $this->mob->findMobParSlug($slug);
  366.       // dump($allMob);
  367.       // recupere la fiche technique
  368.       $allTech $this->mobTech->findOrderByMob($allMob[0]->getId());
  369.       // dump($allTech);
  370.       // recupere les images
  371.       $allImgs $this->mobImgrepo->findAllImgDuMob($allMob[0]->getId());
  372.       // dump($allImgs);
  373.       // enregistre un log
  374.       $this->moucheUser("visite""paul_mobilier_cat_detail ".$allMob[0]->getTitre());
  375.       // affiche
  376.       return $this->render('front/mobilierDetail.html.twig', [
  377.         'controller_name' => 'paul_mobilier_cat_detail',
  378.         'upartRepo' => $this->upartRepo->find(1),
  379.         //'categorie' => $categorie,
  380.         'allMob' => $allMob[0],
  381.         'allTech' => $allTech,
  382.         'allImgs' => $allImgs,
  383.       ]);
  384.     }
  385.     /**
  386.     * @Route("/up-artistic", name="paul_upArtistic")
  387.     */
  388.     public function upArtistic(): Response
  389.     {
  390.       // enregistre un log
  391.       $this->moucheUser("visite""paul_upArtistic");
  392.       return $this->render('front/upArtistic.html.twig', [
  393.         'controller_name' => 'paul_upArtistic',
  394.         'upartRepo' => $this->upartRepo->find(1),
  395.       ]);
  396.     }
  397.     /**
  398.     * @Route("/contact", name="paul_contact")
  399.     */
  400.     public function contact(Request $requestMailerInterface $mailerSessionInterface $session): Response
  401.     {
  402.       // enregistre un log
  403.       $this->moucheUser("visite""paul_contact");
  404.       $form $this->createForm(ContactType::class);
  405.       $form->handleRequest($request);
  406.       // captcha
  407.       $name date('Y_m_d_h_i_s');
  408.       if ($form->isSubmitted() && $form->isValid())
  409.       {
  410.         if ( $form['captcha']->getData() == $session->get('captcha') )
  411.         {
  412.           // inscrit dans la base de données
  413.           $contactLog = new Contact();
  414.           $contactLog->setIp($_SERVER['REMOTE_ADDR']);
  415.           $contactLog->setNom($form['nom']->getData());
  416.           $contactLog->setEmail($form['email']->getData());
  417.           $contactLog->setMessage($form['message']->getData());
  418.           $contactLog->setDateCrea(new \DateTime());
  419.           $this->em->persist($contactLog);
  420.           $this->em->flush();
  421.           // envoi un mail du contact
  422.           $email = (new TemplatedEmail())
  423.             ->from($this->mailExpe)
  424.             ->to($this->mailContact)
  425.             ->subject('Envoi depuis page Contact')
  426.             ->text('Envoi depuis page Contact.')
  427.             ->htmlTemplate('mails/_Mail_Contact.html.twig')
  428.             ->context([
  429.               'nom' => $form['nom']->getData(),
  430.               'emailx' => $form['email']->getData(),
  431.               'message' => $form['message']->getData(),
  432.             ])
  433.           ;
  434.           $emailTech = (new TemplatedEmail())
  435.             ->from($this->mailExpe)
  436.             ->to($this->mailAdmin)
  437.             ->subject('Envoi depuis page Contact')
  438.             ->text('Envoi depuis page Contact.')
  439.             ->htmlTemplate('mails/_Mail_Contact.html.twig')
  440.             ->context([
  441.               'nom' => $form['nom']->getData(),
  442.               'emailx' => $form['email']->getData(),
  443.               'message' => $form['message']->getData(),
  444.             ])
  445.           ;
  446.           $errorM1 0;
  447.           try
  448.           {
  449.             $mailer->send($email);
  450.             $mailer->send($emailTech);
  451.           }
  452.           catch (TransportExceptionInterface $e)
  453.           {
  454.             // some error prevented the email sending; display an
  455.             // error message or try to resend the message
  456.             $this->addFlash('warning''Erreur Message !');
  457.             $errorM1 1;
  458.           }
  459.           if ($errorM1 == 0)
  460.           {
  461.             // dump("ok");
  462.             $this->addFlash('success''Message envoyé !');
  463.           }
  464.           else
  465.           {
  466.             $this->addFlash('danger''Le message n\'a pas été envoyé !');
  467.             // dump("false");
  468.           }
  469.           //return $this->redirectToRoute('paul_contact');
  470.         }
  471.         else
  472.         {
  473.           $this->addFlash('warning''Erreur de captcha!');
  474.         }
  475.       }
  476.       return $this->render('front/contact.html.twig', [
  477.         'controller_name' => 'paul_contact',
  478.         'upartRepo' => $this->upartRepo->find(1),
  479.         'form' => $form->createView(),
  480.         'img' => $this->captcha($name$session),
  481.         'name' => $name,
  482.       ]);
  483.     }
  484.     /**
  485.     * @Route("/captcha/{name}", name="paul_captcha")
  486.     */
  487.     public function captcha($nameSessionInterface $session): Response
  488.     {
  489.       // Création d'une image vide et ajout d'un texte
  490.       $session->set('captcha'mt_rand(1000099999));
  491.       $im imagecreate(11040);
  492.       $font realpath('fonts/ASMAN.TTF');
  493.       $bg imagecolorallocate($im205215212);
  494.       $textcolor imagecolorallocate($im756080);
  495.       $code $session->get('captcha');
  496.       imagettftext($im2351535$textcolor$font$code);
  497.       // Définir le chemin de sauvegarde de l'image
  498.       $save "captcha/".$name.".jpg";
  499.       // Enregistrer l'image dans un fichier
  500.       imagejpeg($im$save);
  501.       // Libération de la mémoire
  502.       imagedestroy($im);
  503.       // Lire le contenu du fichier image généré
  504.       $imageContent file_get_contents($save);
  505.       // Définir les en-têtes HTTP
  506.       $headers = array(
  507.         'Content-Type' => 'image/jpeg',
  508.         'Content-Disposition' => 'inline; filename="'.$name.'.jpg"'
  509.       );
  510.       // Retourner l'image en réponse HTTP
  511.       return new Response($imageContent200$headers);
  512.       // // Définit le contenu de l'en-tête - dans ce cas, image/jpeg
  513.       // header('Content-Type: image/jpeg');
  514.       // $save = "captcha/".$name.".jpg";
  515.       // // Affichage de l'image
  516.       // imagejpeg($im, $save);
  517.       // // Libération de la mémoire
  518.       // imagedestroy($im);
  519.       // $headers = array(
  520.       //   'Content-Type' => 'image/jpeg',
  521.       //   'Content-Disposition' => 'inline; filename="'.$im.'"'
  522.       // );
  523.       // return new Response($save, 200, $headers);
  524.     }
  525.     /**
  526.     * @Route("/captcha2/{name}", name="paul_captcha2")
  527.     */
  528.     public function captcha2($nameSessionInterface $session): Response
  529.     {
  530.       // Création d'une image vide et ajout d'un texte
  531.       $session->set('captcha'mt_rand(1000099999));
  532.       $im imagecreate(11040);
  533.       $font realpath('fonts/ASMAN.TTF');
  534.       $bg imagecolorallocate($im205215212);
  535.       $textcolor imagecolorallocate($im756080);
  536.       $code $session->get('captcha');
  537.       imagettftext($im2351535$textcolor$font$code);
  538.       // Définit le contenu de l'en-tête - dans ce cas, image/jpeg
  539.       header('Content-Type: image/jpeg');
  540.       $save "captcha/".$name.".jpg";
  541.       // Affichage de l'image
  542.       imagejpeg($im$save);
  543.       // Libération de la mémoire
  544.       imagedestroy($im);
  545.       $headers = array(
  546.         'Content-Type' => 'image/jpeg',
  547.         'Content-Disposition' => 'inline; filename="'.$im.'"'
  548.       );
  549.       return new Response($save200$headers);
  550.     }
  551.     public function moucheUser($action$page){
  552.       // $stat = new Stats();
  553.       // // Get IP address
  554.       // $ip_address = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR');
  555.       // $stat->setIp($ip_address);
  556.       // // Get action
  557.       // $stat->setAction($action);
  558.       // $stat->setPage($page);
  559.       // $stat->setDateCrea(new \DateTime());
  560.       // // Get JSON object
  561.       // $ip_data = unserialize(file_get_contents('http://ip-api.com/php/'.$_SERVER['REMOTE_ADDR'].'?fields=status,message,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,query'));
  562.       // $stat->setPays($ip_data['country']);
  563.       // $stat->setRegion($ip_data['region']);
  564.       // $stat->setVille($ip_data['city']);
  565.       // //$jsondata = file_get_contents("http://timezoneapi.io/api/ip/?" . $ip_address . '&token=aYJMQZkEKzSLtQwhCmzD');
  566.       // // Decode
  567.       // //$data = json_decode($jsondata, true);
  568.       // // Request OK?
  569.       // // if(isset($data['meta']) && $data['meta']['code'] == '200'){
  570.       // //   $stat->setPays($data['data']['country']);
  571.       // //   $stat->setRegion($data['data']['state']);
  572.       // //   $stat->setVille($data['data']['city']);
  573.       // // }
  574.       // $this->em->persist($stat);
  575.       // $this->em->flush();
  576.     }
  577.     public function dessineCourbe(){
  578.       $donnees = array(12,23,9,58,23,26,57,48,12);
  579.       $largeur 250;
  580.       $hauteur 200;
  581.       // Initialisation du graphique
  582.       $graphe = new \Graph($largeur$hauteur);
  583.       // Echelle lineaire ('lin') en ordonnee et pas de valeur en abscisse ('text')
  584.       // Valeurs min et max seront determinees automatiquement
  585.       $graphe->setScale("textlin");
  586.       // Creation de l'histogramme
  587.       $histo = new \BarPlot($donnees);
  588.       // Ajout de l'histogramme au graphique
  589.       $graphe->add($histo);
  590.       // Ajout du titre du graphique
  591.       $graphe->title->set("Histogramme");
  592.       // Affichage du graphique
  593.       $graphe->stroke();
  594.     }
  595. }