src/Controller/DefaultController.php line 372

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. //use App\Config;
  4. //use App\Controller\MongoClient;
  5. //use App\Entity\AffiliateInfo;
  6. //use App\Entity\AffiliateOfferBlock;
  7. //use App\Entity\Alerts;
  8. //use App\Entity\AppInfo;
  9. //use App\Entity\AppsflyerWatcher;
  10. //use App\Entity\Employees;
  11. //use App\Entity\HoAffiliateMmpPartnerMapping;
  12. //use App\Entity\HyperAffiliateData;
  13. //use App\Entity\MmpAdvertisers;
  14. //use App\Entity\MmpMobileApps;
  15. //use App\Entity\MmpNotifications;
  16. //use App\Entity\MmpOffers;
  17. //use App\Entity\MmpPartnerRules;
  18. //use App\Entity\MmpPartners;
  19. //use App\Entity\MmpReports;
  20. //use App\Entity\OfferInfo;
  21. //use App\Entity\OfferTagRelationship;
  22. //use App\Entity\PayoutControl;
  23. //use App\Entity\PayoutControlAffiliateHyperData;
  24. //use App\Entity\PayoutTotal;
  25. //use App\Entity\RevenueControl;
  26. //use App\Entity\RevenueControlAdvertiserHyperData;
  27. //use App\Entity\RevenueTotal;
  28. //use App\Entity\SkadNetworkPostbackLogs;
  29. //use App\Entity\OfferScheduledChangesLogs;
  30. //use App\Entity\UsersHierarchy;
  31. use App\Config;
  32. use App\Entity\AdvertiserInfo;
  33. use App\Entity\AffiliateInfo;
  34. use App\Entity\AffiliateRating;
  35. use App\Entity\AppInfo;
  36. use App\Entity\AppsflyerDatalocker;
  37. use App\Entity\Employees;
  38. use App\Entity\HyperClientInfo;
  39. use App\Entity\MafoAdvertisers;
  40. use App\Entity\MafoAdvertisersMapping;
  41. use App\Entity\MafoAffiliatesMapping;
  42. use App\Entity\MmpFraudReports;
  43. use App\Entity\MmpMobileApps;
  44. use App\Entity\MmpReports;
  45. use App\Entity\ObjectMappingWithTuneWebAccount;
  46. use App\Entity\OfferInfo;
  47. use App\Entity\OfferTagRelationship;
  48. use App\Entity\RecommendationsByObject;
  49. use App\Entity\Tag;
  50. use App\Entity\UsersHierarchy;
  51. use App\Entity\HoAffiliateMmpPartnerMapping;
  52. use App\Entity\MafoAffiliateMmpPartnerMapping;
  53. use App\Services\AdjustAPI;
  54. use App\Services\AffiliateHasofferAPI;
  55. use App\Services\Alerts;
  56. use App\Services\AppsflyerAPI;
  57. use App\Services\Aws\ElasticCache;
  58. use App\Services\Aws\S3;
  59. use App\Services\BrandHasofferAPI;
  60. use App\Services\Common;
  61. use App\Services\FinancialToolsComponents;
  62. use App\Services\HyperApis;
  63. use App\Services\ImpressionsApis;
  64. use App\Services\Integrations\CjAPI;
  65. use App\Services\Mailer;
  66. use App\Services\Metrics24APICalls;
  67. use App\Services\MmpComponents;
  68. use App\Services\MysqlQueries;
  69. use App\Services\Scraper;
  70. use App\Services\UsersComponents;
  71. use Doctrine\Persistence\ManagerRegistry;
  72. use Exception;
  73. use Mmoreram\GearmanBundle\Service\GearmanClientInterface;
  74. use MongoClient;
  75. use MongoDB\Client as Mongo;
  76. use Ramsey\Uuid\Uuid;
  77. use Symfony\Component\HttpKernel\KernelInterface;
  78. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  79. use Symfony\Component\Mailer\Header\MetadataHeader;
  80. use Symfony\Component\Mailer\MailerInterface;
  81. use Symfony\Component\Mercure\Authorization;
  82. use Symfony\Component\Mercure\Discovery;
  83. use Symfony\Component\Mercure\HubInterface;
  84. use Symfony\Component\Mercure\Publisher;
  85. use Symfony\Component\Mercure\Update;
  86. use Symfony\Component\Mime\Email;
  87. use Symfony\Component\Mime\Part\DataPart;
  88. use Symfony\Component\Mime\Part\File;
  89. use Symfony\Component\Routing\Annotation\Route;
  90. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  91. use Symfony\Component\HttpFoundation\JsonResponse;
  92. use Symfony\Component\HttpFoundation\Request;
  93. use Symfony\Component\HttpFoundation\Response;
  94. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  95. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  96. use App\Services\NewAdjustAPI;
  97. use Symfony\Contracts\HttpClient\HttpClientInterface;
  98. use Twig\Environment;
  99. //use Ramsey\Uuid\Uuid;
  100. class DefaultController extends AbstractController
  101. {
  102.     private $commonCalls;
  103.     private $doctrine;
  104.     private $brandHasofferApi;
  105.     private $tuneApi;
  106.     private $projectDir;
  107.     private $mmpComponents;
  108.     private $financialToolsComponents;
  109.     private $gearmanClientInterface;
  110.     private $alerts;
  111.     private $rootPath;
  112.     private $afApi;
  113.     private $s3;
  114.     private AdjustAPI $adjustApi;
  115.     public function __construct(GearmanClientInterface $gearmanClientInterfaceCommon $commonCallsManagerRegistry $doctrineBrandHasofferApi $brandHasofferApistring $projectDirMmpComponents $mmpComponentsAlerts $alertsParameterBagInterface $paramsAppsflyerAPI $afApiAdjustAPI $adjustApiFinancialToolsComponents $financialToolsComponentsS3 $s3)
  116.     {
  117.         $this->commonCalls $commonCalls;
  118.         $this->doctrine $doctrine;
  119.         $this->brandHasofferApi $brandHasofferApi;
  120.         $this->tuneApi $brandHasofferApi;
  121.         $this->projectDir $projectDir;
  122.         $this->mmpComponents $mmpComponents;
  123.         $this->financialToolsComponents $financialToolsComponents;
  124.         $this->gearmanClientInterface $gearmanClientInterface;
  125.         $this->alerts $alerts;
  126.         $this->rootPath $params->get('kernel.project_dir');
  127.         $this->afApi $afApi;
  128.         $this->s3 $s3;
  129.         $this->adjustApi $adjustApi;
  130.     }
  131.     /**
  132.      * @Route("/", name="agent_homepage", host="%agents_subdomain%")
  133.      */
  134.     public function indexAgentAction(Request $request)
  135.     {
  136.         return $this->render('base_agent.html.twig', [
  137.             'template' => '/templates/dashboard.html.twig',
  138.         ]);
  139.     }
  140.     /**
  141.      * @Route("/", name="mafo_publisher_homepage", host="%publishers_subdomain%")
  142.      */
  143.     public function indexPublisherAction(Request $request)
  144.     {
  145.         return $this->render('base_mafo_publisher_cabinet.html.twig', [
  146.             'template' => '/base_mafo_publisher_cabinet.html.twig',
  147.         ]);
  148.     }
  149.     /**
  150.      * @Route("/", name="mafo_advertiser_homepage", host="%advertisers_subdomain%")
  151.      */
  152.     public function indexAdvertiserAction(Request $request)
  153.     {
  154.         return $this->render('base_mafo_advertiser_cabinet.html.twig', [
  155.             'template' => '/base_mafo_advertiser_cabinet.html.twig',
  156.         ]);
  157.     }
  158.     /**
  159.      * @Route("/", name="homepage")
  160.      */
  161.     public function indexAction(Request $request)
  162.     {
  163.  
  164.         return $this->render('base.html.twig', [
  165.             'template' => '/templates/dashboard.html.twig',
  166.         ]);
  167.     }
  168.     /**
  169.      * @Route("/login", name="mafo_form_login")
  170.      */
  171.     public function mafoFormLoginAction(AuthenticationUtils $authenticationUtilsRequest $request)
  172.     {
  173.         //        $authenticationUtils = $authenticationUtils->get('security.authentication_utils');
  174.         // get the login error if there is one
  175.         $error $authenticationUtils->getLastAuthenticationError();
  176.         // last username entered by the user
  177.         $lastUsername $authenticationUtils->getLastUsername();
  178.         return $this->render('/form_login.html.twig', [
  179.             'last_username' => $lastUsername,
  180.             'error' => $error,
  181.             'errorFromParam' => $request->query->get('error')
  182.         ]);
  183.     }
  184.     /**
  185.      * @Route("/test", name="test_")
  186.      * @throws TransportExceptionInterface
  187.      */
  188.     public function testAction(Request $requestHyperApis $hyper)
  189.     {
  190.         
  191.         $bulk = new \MongoDB\Driver\BulkWrite();
  192.         $query = new \MongoDB\Driver\Manager($this->getParameter('mongodb_server'));
  193.         $bulk->insert([
  194.             'varnit' => 'saini'
  195.         ]);
  196.         $writeConcern = new \MongoDB\Driver\WriteConcern(\MongoDB\Driver\WriteConcern::MAJORITY100);
  197.         // var_dump($writeConcern);
  198.         // die;
  199.         
  200.         // echo 1;/*  */
  201.         $result $query->executeBulkWrite('mafo_logs.varnit'$bulk, [
  202.             'w' => 'majority',
  203.             'wtimeout' => 10000
  204.         ]);
  205.         echo 2;
  206.         die;
  207.     }
  208.     private function migrateMmpMobileAppsAdvertiserId()
  209.     {
  210.         $mmpMobileApps $this->doctrine->getRepository(MmpMobileApps::class)->getMmpMobileAppsForAdvertiserMigration();
  211.         foreach ($mmpMobileApps as $mmpMobileApp) {
  212.             if ($mmpMobileApp['advertiserId']) {
  213.                 $checkMafoAdvertiserMappingExists $this->doctrine->getRepository(MafoAdvertisersMapping::class)->findOneBy([
  214.                     'systemIdentifier' => Config::MAFO_SYSTEM_IDENTIFIER_TUNE_MOBILE,
  215.                     'systemIdentifierId' => $mmpMobileApp['advertiserId']
  216.                 ]);
  217.                 if($checkMafoAdvertiserMappingExists) {
  218.                     $this->doctrine->getRepository(MmpMobileApps::class)->updateMmpMobileAppsById($mmpMobileApp['id'], [
  219.                         'mafoAdvertiserId' => $checkMafoAdvertiserMappingExists->getMafoAdvertiserId()->getId()
  220.                     ]);
  221.                 }
  222.             }
  223.         }
  224.     }
  225.     private function processCohortCsv()
  226.     {
  227.         ini_set('memory_limit''256M');
  228.         $fileDirectory $this->rootPath '/public/temp';
  229.         $files scandir($fileDirectory);
  230.         foreach ($files as $file) {
  231.             if (!$this->commonCalls->checkForString($file'cohort')) {
  232.                 continue;
  233.             }
  234.             $filePath $fileDirectory '/' $file;
  235.             //            $fileData = file_get_contents($filePath);
  236.             $file fopen($filePath'r');
  237.             $data = [];
  238.             while (($line fgetcsv($file)) !== FALSE) {
  239.                 //$line is an array of the csv elements
  240.                 $data[] = $line;
  241.                 if (sizeof($data) > 100) {
  242.                     break;
  243.                 }
  244.             }
  245.             fclose($file);
  246.             $dataHeaders $data[0];
  247.             unset($data[0]);
  248.             echo json_encode($data);
  249.             die;
  250.         }
  251.     }
  252.     /**
  253.      * @Route("/advertiser-list", name="advertiser_list")
  254.      */
  255.     public
  256.     function getAdvertiserListAction(Request $request)
  257.     {
  258.         $advertiserData $this->commonCalls->getAdvertisersListByStatusWithKeys();
  259.         $response = [];
  260.         foreach ($advertiserData as $key => $value) {
  261.             $response[$value['id']] = [
  262.                 'value' => $value['id'],
  263.                 'label' => $value['id'] . ' - ' $value['name']
  264.             ];
  265.         }
  266.         ksort($response);
  267.         header('Access-Control-Allow-Origin: *');
  268.         return new JsonResponse(array_values($response));
  269.     }
  270.     /**
  271.      * @Route("/affiliate-list", name="affiliate_list")
  272.      */
  273.     public
  274.     function getAffiliateListAction(Request $request)
  275.     {
  276.         $advertiserData $this->commonCalls->getAffiliateListByStatusWithKeys();
  277.         $response = [];
  278.         foreach ($advertiserData as $key => $value) {
  279.             $response[$value['id']] = [
  280.                 'value' => $value['id'],
  281.                 'label' => $value['id'] . ' - ' $value['name']
  282.             ];
  283.         }
  284.         ksort($response);
  285.         header('Access-Control-Allow-Origin: *');
  286.         return new JsonResponse(array_values($response));
  287.     }
  288.     /**
  289.      * @Route("/oauth", name="oauth")
  290.      */
  291.     public
  292.     function oauthAction()
  293.     {
  294.         return new JsonResponse(true);
  295.     }
  296.     /**
  297.      * @Route("/appsflyer/skadnetwork", name="appsflyer_skadnetwork")
  298.      */
  299.     public
  300.     function appsflyerSkadnetworkAction(Request $request)
  301.     {
  302.         if ($_SERVER['REQUEST_METHOD'] === Config::HTTP_METHOD_POST) {
  303.             $payload json_decode($request->getContent(), true);
  304.         } else if ($_SERVER['REQUEST_METHOD'] === Config::HTTP_METHOD_GET) {
  305.             $payload['transaction-id'] = $request->query->get('transaction-id');
  306.         }
  307.         if (isset($payload['transaction-id'])) {
  308.             $data $this->doctrine->getRepository(SkadNetworkPostbackLogs::class)->findOneBy([
  309.                 'transactionId' => $payload['transaction-id']
  310.             ]);
  311.             if ($data) {
  312.                 $this->doctrine->getRepository(SkadNetworkPostbackLogs::class)->updateSkadNetworkPostbackLogs($data->getId(), [
  313.                     'isPostbackAcknowledgedFromAppsflyer' => true
  314.                 ]);
  315.             }
  316.         }
  317.         return new JsonResponse(true);
  318.     }
  319.     /**
  320.      * Serve the SPA for any front-end route so React Router can handle it client-side
  321.      * This should be placed LAST in your routing to act as a catch-all
  322.      *
  323.      * @Route("/{reactRouting}", name="spa_catch_all", requirements={"reactRouting"="^(?!api|admin|_wdt|_profiler).*"}, methods={"GET"}, priority=-1)
  324.      */
  325.     public function spaCatchAll(): Response
  326.     {
  327.         return $this->render('base.html.twig', [
  328.             'template' => '/templates/dashboard.html.twig',
  329.         ]);
  330.     }
  331. }