init project
This commit is contained in:
0
src/Controller/.gitignore
vendored
Normal file
0
src/Controller/.gitignore
vendored
Normal file
62
src/Controller/BackendAdmin/ActiverController.php
Normal file
62
src/Controller/BackendAdmin/ActiverController.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\BackendAdmin;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use App\Entity\SoftwareActivation;
|
||||
|
||||
use App\Repository\SoftwareActivationRepository;
|
||||
|
||||
|
||||
#[Route('/admin/activer')]
|
||||
final class ActiverController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $em
|
||||
* @param SoftwareActivationRepository $softwareActivationRepository
|
||||
*/
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private SoftwareActivationRepository $softwareActivationRepository
|
||||
)
|
||||
{
|
||||
$this->softwareActivationRepository = $softwareActivationRepository;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
#[Route('/index', name: 'admin_activer_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('backend/admin/activer/index.html.twig', [
|
||||
'softwareActivations'=>$this->softwareActivationRepository->findBy(['user'=>null], ["id"=>'DESC'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
#[Route('/activation/{id}', name: 'admin_activer_activation')]
|
||||
public function activation(SoftwareActivation $softwareActivation): Response
|
||||
{
|
||||
$softwareActivation->setStatu(1);
|
||||
$softwareActivation->setDateAdd(new \DateTime());
|
||||
$this->em->persist($softwareActivation);
|
||||
$this->em->flush();
|
||||
return $this->redirectToRoute('admin_activer_index');
|
||||
}
|
||||
|
||||
#[Route('/delete/{id}', name: 'admin_activer_delete')]
|
||||
public function delete(SoftwareActivation $softwareActivation): Response
|
||||
{
|
||||
$this->em->remove($softwareActivation);
|
||||
$this->em->flush();
|
||||
return $this->redirectToRoute('admin_activer_index');
|
||||
}
|
||||
}
|
||||
50
src/Controller/BackendAdmin/HomeController.php
Normal file
50
src/Controller/BackendAdmin/HomeController.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\BackendAdmin;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use App\Repository\GeolocationRepository;
|
||||
use App\Repository\SoftDownloaderRepository;
|
||||
|
||||
#[Route('/admin/home')]
|
||||
final class HomeController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param UserRepository $userRepository
|
||||
* @param GeolocationRepository $geolocationRepository
|
||||
* @param SoftDownloaderRepository $softDownloaderRepository
|
||||
*/
|
||||
public function __construct(
|
||||
private UserRepository $userRepository,
|
||||
private GeolocationRepository $geolocationRepository,
|
||||
private SoftDownloaderRepository $softDownloaderRepository
|
||||
)
|
||||
{
|
||||
$this->userRepository = $userRepository;
|
||||
$this->geolocationRepository = $geolocationRepository;
|
||||
$this->softDownloaderRepository = $softDownloaderRepository;
|
||||
}
|
||||
|
||||
#[Route('/index', name: 'admin_home_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('backend/admin/home/index.html.twig', [
|
||||
"dateNow"=> (new \DateTime())->format('d/m/Y'),
|
||||
"nbrUsers"=> $this->userRepository->countUsersNow(),
|
||||
"nbrVisitors"=> $this->geolocationRepository->countGeolocationNow(),
|
||||
"geolocations"=> $this->geolocationRepository->getGeolocationsNow(),
|
||||
"nbrDownloaders"=> $this->softDownloaderRepository->getDownloadersNow()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
26
src/Controller/BackendAdmin/TestController.php
Normal file
26
src/Controller/BackendAdmin/TestController.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\BackendAdmin;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
|
||||
#[Route('/admin/test')]
|
||||
final class TestController extends AbstractController
|
||||
{
|
||||
|
||||
#[Route('/origin', name: 'admin_test_origin')]
|
||||
public function origin(): Response
|
||||
{
|
||||
return $this->render('backend/admin/test/origin_template.html.twig', []);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
93
src/Controller/BackendAdmin/UtilisateurController.php
Normal file
93
src/Controller/BackendAdmin/UtilisateurController.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\BackendAdmin;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Entity\Partner;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use App\Repository\GeolocationRepository;
|
||||
|
||||
#[Route('/admin/utilisateur')]
|
||||
final class UtilisateurController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @param EntityManagerInterface $em
|
||||
* @param UserRepository $userRepository
|
||||
* @param GeolocationRepository $geolocationRepository
|
||||
*/
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private UserRepository $userRepository,
|
||||
private GeolocationRepository $geolocationRepository,
|
||||
)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->userRepository = $userRepository;
|
||||
$this->geolocationRepository = $geolocationRepository;
|
||||
}
|
||||
|
||||
#[Route('/index', name: 'admin_utilisateur_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('backend/admin/utilisateur/index.html.twig', [
|
||||
'users'=>$this->userRepository->findUsersWithoutAdminOrPartner()
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/change/role/partner/{id}', name: 'admin_utilisateur_change_role')]
|
||||
public function change_role_partner(User $user): Response
|
||||
{
|
||||
|
||||
|
||||
$user->addRole("ROLE_PARTNER");
|
||||
$partner = new Partner();
|
||||
$partner->setActive(true);
|
||||
$partner->setDateAdd(new \DateTime());
|
||||
$partner->setUser($user);
|
||||
$this->em->persist($partner);
|
||||
$this->em->persist($user);
|
||||
$this->em->flush();
|
||||
|
||||
return $this->redirectToRoute('admin_utilisateur_index');
|
||||
}
|
||||
|
||||
|
||||
#[Route('/partner', name: 'admin_utilisateur_partner_index')]
|
||||
public function partner_index(): Response
|
||||
{
|
||||
return $this->render('backend/admin/utilisateur/partner.html.twig', [
|
||||
'partners'=>$this->userRepository->findByRoles(["ROLE_PARTNER"])
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/partner/delete/{id}', name: 'admin_utilisateur_partner_delete')]
|
||||
public function partner_delete(Partner $partner): Response
|
||||
{
|
||||
$user = $partner->getUser();
|
||||
$user->removeRole("ROLE_PARTNER");
|
||||
$this->em->persist($user);
|
||||
$this->em->remove($partner);
|
||||
$this->em->flush();
|
||||
return $this->render('backend/admin/utilisateur/partner.html.twig', [
|
||||
'partners'=>$this->userRepository->findByRoles(["ROLE_PARTNER"])
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/visitor', name: 'admin_utilisateur_visitor_index')]
|
||||
public function visitor_index(): Response
|
||||
{
|
||||
return $this->render('backend/admin/utilisateur/visitor.html.twig', [
|
||||
'geolocations'=>$this->geolocationRepository->findAll()
|
||||
]);
|
||||
}
|
||||
}
|
||||
61
src/Controller/BackendPartner/ActiverController.php
Normal file
61
src/Controller/BackendPartner/ActiverController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\BackendPartner;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use App\Entity\SoftwareActivation;
|
||||
|
||||
use App\Repository\SoftwareActivationRepository;
|
||||
|
||||
|
||||
#[Route('/partner/activer')]
|
||||
final class ActiverController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SoftwareActivationRepository $softwareActivationRepository
|
||||
*/
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private SoftwareActivationRepository $softwareActivationRepository
|
||||
)
|
||||
{
|
||||
$this->softwareActivationRepository = $softwareActivationRepository;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
#[Route('/index', name: 'partner_activer_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('backend/partner/activer.html.twig', [
|
||||
'softwareActivations'=>$this->softwareActivationRepository->findBy(['user'=>$this->getUser()], ["id"=>'DESC'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
#[Route('/activation/{id}', name: 'partner_activer_activation')]
|
||||
public function activation(SoftwareActivation $softwareActivation): Response
|
||||
{
|
||||
$softwareActivation->setStatu(1);
|
||||
$softwareActivation->setDateAdd(new \DateTime());
|
||||
$this->em->persist($softwareActivation);
|
||||
$this->em->flush();
|
||||
return $this->redirectToRoute('partner_activer_index');
|
||||
}
|
||||
|
||||
#[Route('/delete/{id}', name: 'partner_activer_delete')]
|
||||
public function delete(SoftwareActivation $softwareActivation): Response
|
||||
{
|
||||
$this->em->remove($softwareActivation);
|
||||
$this->em->flush();
|
||||
return $this->redirectToRoute('partner_activer_index');
|
||||
}
|
||||
}
|
||||
46
src/Controller/BackendPartner/HomeController.php
Normal file
46
src/Controller/BackendPartner/HomeController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\BackendPartner;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use App\Repository\GeolocationRepository;
|
||||
use App\Repository\SoftDownloaderRepository;
|
||||
|
||||
#[Route('/partner/home')]
|
||||
final class HomeController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param UserRepository $userRepository
|
||||
* @param GeolocationRepository $geolocationRepository
|
||||
* @param SoftDownloaderRepository $softDownloaderRepository
|
||||
*/
|
||||
public function __construct(
|
||||
private UserRepository $userRepository,
|
||||
private GeolocationRepository $geolocationRepository,
|
||||
private SoftDownloaderRepository $softDownloaderRepository
|
||||
)
|
||||
{
|
||||
$this->userRepository = $userRepository;
|
||||
$this->geolocationRepository = $geolocationRepository;
|
||||
$this->softDownloaderRepository = $softDownloaderRepository;
|
||||
}
|
||||
|
||||
#[Route('/downloader', name: 'partner_home_downloader')]
|
||||
public function downloader(): Response
|
||||
{
|
||||
return $this->render('backend/partner/downloader.html.twig', [
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
94
src/Controller/Frontend/DemoController.php
Normal file
94
src/Controller/Frontend/DemoController.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Frontend;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Form\ParamDemoType;
|
||||
|
||||
use App\Entity\ParamDemo;
|
||||
use App\Entity\SoftDownloader;
|
||||
|
||||
use App\Repository\ParamDemoRepository;
|
||||
|
||||
|
||||
#[Route('/demo')]
|
||||
final class DemoController extends AbstractController
|
||||
{
|
||||
|
||||
/** @var EntityManagerInterface $em */
|
||||
private $em;
|
||||
|
||||
/** @var ParamDemoRepository $paramDemoRepository */
|
||||
private $paramDemoRepository;
|
||||
|
||||
/**
|
||||
* @param ParamDemoRepository $paramDemoRepository
|
||||
* @param EntityManagerInterface $em
|
||||
* @return $this
|
||||
*/
|
||||
public function __construct(
|
||||
ParamDemoRepository $paramDemoRepository,
|
||||
EntityManagerInterface $em
|
||||
){
|
||||
$this->paramDemoRepository = $paramDemoRepository;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
#[Route('/download', name: 'demo_download')]
|
||||
public function download(Request $request): Response
|
||||
{
|
||||
$paramDemo = $this->paramDemoRepository->findOneBy(['user'=>$this->getUser()]);
|
||||
if(!$paramDemo) $paramDemo = new ParamDemo();
|
||||
|
||||
$disabled = ($this->getUser()) ? false : true ;
|
||||
|
||||
$form = $this->createForm(ParamDemoType::class, $paramDemo, ['disabled'=> $disabled]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if($form->isSubmitted() && $form->isValid())
|
||||
{
|
||||
$paramDemo->setUser($this->getUser());
|
||||
$this->em->persist($paramDemo);
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash('notice', "Modification a été modifié avec succès");
|
||||
}
|
||||
|
||||
return $this->render('frontend/demo/download.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'errors' => $form->getErrors()
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/parametre', name: 'demo_parametre')]
|
||||
public function parametre(Request $request): JsonResponse
|
||||
{
|
||||
$login = $request->get('login');
|
||||
|
||||
if(!$login) return new JsonResponse([]);
|
||||
|
||||
$paramDemo = $this->paramDemoRepository->findOneByLoginPassword($login);
|
||||
|
||||
return new JsonResponse($paramDemo->toArray());
|
||||
}
|
||||
|
||||
#[Route('/save_download', name: 'demo_save_download')]
|
||||
public function save_download(): Response
|
||||
{
|
||||
$softDownloader = new SoftDownloader();
|
||||
|
||||
$this->em->persist($softDownloader);
|
||||
$this->em->flush();
|
||||
|
||||
return new Response($softDownloader->getId());
|
||||
}
|
||||
}
|
||||
131
src/Controller/Frontend/HomeController.php
Normal file
131
src/Controller/Frontend/HomeController.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Frontend;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
|
||||
use App\Form\MailType;
|
||||
|
||||
use App\Repository\GeolocationRepository;
|
||||
|
||||
use ReCaptcha\ReCaptcha;
|
||||
|
||||
final class HomeController extends AbstractController
|
||||
{
|
||||
|
||||
private $session;
|
||||
|
||||
/**
|
||||
* @param GeolocationRepository $geolocationRepository
|
||||
* @param RequestStack $requestStack
|
||||
*/
|
||||
public function __construct(private GeolocationRepository $geolocationRepository,
|
||||
RequestStack $requestStack)
|
||||
{
|
||||
|
||||
$this->geolocationRepository = $geolocationRepository;
|
||||
$this->session = $requestStack->getSession();
|
||||
}
|
||||
|
||||
#[Route('/', name: 'home_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('frontend/home/index.html.twig', [
|
||||
"form"=> $this->createForm(MailType::class),
|
||||
"geoVisitor" => $this->session->get('geoVisitor'),
|
||||
'GOOGLE_RECAPTCHA_SITE_KEY' => $_ENV['GOOGLE_RECAPTCHA_SITE_KEY'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
#[Route('/gallery', name: 'home_gallery')]
|
||||
public function gallery(ParameterBagInterface $params): Response
|
||||
{
|
||||
$directory = $params->get('app.images.screenshot');
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files()->in($directory);
|
||||
|
||||
$fileList = [];
|
||||
foreach ($finder as $file) {
|
||||
$fileList[] = $file->getRelativePathname();
|
||||
}
|
||||
|
||||
sort($fileList);
|
||||
|
||||
return $this->render('frontend/home/gallery.html.twig', [
|
||||
'files'=>$fileList
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/geolocation', name: 'home_geolocation')]
|
||||
public function geolocation(Request $request): Response
|
||||
{
|
||||
$arrResultApi = json_decode($request->get('api'), true);
|
||||
if($arrResultApi)
|
||||
{
|
||||
$this->geolocationRepository->setGeolocation($arrResultApi);
|
||||
$this->session->set('geoVisitor', true);
|
||||
}
|
||||
return new Response('true');
|
||||
}
|
||||
|
||||
|
||||
#[Route('/contact', name: 'home_contact')]
|
||||
public function contact(MailerInterface $mailer, Request $request): Response
|
||||
{
|
||||
$form = $this->createForm(MailType::class);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if($form->isSubmitted() && $form->isValid())
|
||||
{
|
||||
$recaptcha = new ReCaptcha($_ENV['GOOGLE_RECAPTCHA_SECRET']);
|
||||
|
||||
$token = $form->get('recaptcha')->getData();
|
||||
|
||||
$response = $recaptcha->setExpectedAction('submit')
|
||||
->setScoreThreshold(0.5)
|
||||
->verify($token, $request->getClientIp());
|
||||
|
||||
if ($response->isSuccess())
|
||||
{
|
||||
$fullname = $form->get('fullname')->getData();
|
||||
$from = $form->get('email')->getData();
|
||||
$subject = $form->get('subject')->getData();
|
||||
$message = $form->get('message')->getData();
|
||||
|
||||
$email = (new Email())
|
||||
->from($from)
|
||||
->to('contact@powerpme.com')
|
||||
->subject($fullname." ".$subject)
|
||||
->text($message);
|
||||
|
||||
try {
|
||||
$mailer->send($email);
|
||||
$this->addFlash('notice-email', "mail a été envoyé avec succès");
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
$this->addFlash('erreur-email', $e->getMessage());
|
||||
}
|
||||
}else{
|
||||
|
||||
$this->addFlash('erreur-email', 'ReCaptcha invalide');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->redirect("/#contact");
|
||||
}
|
||||
}
|
||||
81
src/Controller/Frontend/SecurityController.php
Normal file
81
src/Controller/Frontend/SecurityController.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Frontend;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface;
|
||||
|
||||
use App\Security\LoginAuthenticator;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\User;
|
||||
|
||||
use App\Form\UserRegistrationType;
|
||||
|
||||
final class SecurityController extends AbstractController
|
||||
{
|
||||
#[Route(path: '/login', name: 'security_login')]
|
||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||
{
|
||||
if ($this->getUser()) {
|
||||
return $this->redirectToRoute('home_index');
|
||||
}
|
||||
|
||||
// get the login error if there is one
|
||||
$error = $authenticationUtils->getLastAuthenticationError();
|
||||
|
||||
// last username entered by the user
|
||||
$lastUsername = $authenticationUtils->getLastUsername();
|
||||
|
||||
return $this->render('frontend/security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error, 'titlePage' => 'Connexion']);
|
||||
}
|
||||
|
||||
#[Route(path: '/logout', name: 'security_logout')]
|
||||
public function logout(Security $security): RedirectResponse
|
||||
{
|
||||
$response = $security->logout(false);
|
||||
|
||||
return $this->redirectToRoute('homepage');
|
||||
}
|
||||
|
||||
#[Route(path: '/registration', name: 'security_registration')]
|
||||
public function registration(Request $request,
|
||||
UserPasswordHasherInterface $userPasswordHasher,
|
||||
UserAuthenticatorInterface $userAuthenticator,
|
||||
LoginAuthenticator $authenticator,
|
||||
EntityManagerInterface $em): Response
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$form = $this->createForm(UserRegistrationType::class, $user);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if($form->isSubmitted() && $form->isValid())
|
||||
{
|
||||
$user->setPassword($userPasswordHasher->hashPassword($user, $form->get('password')->getData()));
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
return $userAuthenticator->authenticateUser($user, $authenticator, $request);
|
||||
}
|
||||
|
||||
return $this->render('frontend/security/register.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'errors' => $form->getErrors(),
|
||||
'titlePage' => 'Inscription',
|
||||
]);
|
||||
}
|
||||
}
|
||||
112
src/Controller/Frontend/SoftwareController.php
Normal file
112
src/Controller/Frontend/SoftwareController.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Frontend;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Service\CryptoService;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use App\Repository\SoftwareActivationRepository;
|
||||
|
||||
|
||||
#[Route('/software')]
|
||||
final class SoftwareController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @param SoftwareActivationRepository $softwareActivationRepository
|
||||
* @param UserRepository $userRepository
|
||||
* @param EntityManagerInterface $em
|
||||
* @return $this
|
||||
*/
|
||||
public function __construct(
|
||||
private UserRepository $userRepository,
|
||||
private SoftwareActivationRepository $softwareActivationRepository,
|
||||
private CryptoService $cryptoService,
|
||||
private EntityManagerInterface $em
|
||||
){
|
||||
$this->em = $em;
|
||||
$this->userRepository = $userRepository;
|
||||
$this->cryptoService = $cryptoService;
|
||||
$this->softwareActivationRepository = $softwareActivationRepository;
|
||||
}
|
||||
|
||||
#[Route('/activation', name: 'software_activation')]
|
||||
public function activation(Request $request): JsonResponse
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$companyName = $request->get('CompanyName');
|
||||
$companyMF = $request->get('CompanyMF');
|
||||
$pcName = $request->get('PCName');
|
||||
$partnerEmail = $request->get('Partner');
|
||||
$disqueNom = $request->get('DisqueNom');
|
||||
$disqueModel = $request->get('DisqueModel');
|
||||
$disqueSerial = $request->get('DisqueSerial');
|
||||
$user = null;
|
||||
$statu = 0;
|
||||
|
||||
/*
|
||||
pour le code
|
||||
0 | null --> n'ai pas encore activer
|
||||
1 --> activer
|
||||
2 --> La demande a été bien envoyer pour activé le logiciel
|
||||
n --> erreur
|
||||
*/
|
||||
if($id){
|
||||
$softwareActivation = $this->softwareActivationRepository->find($id);
|
||||
}else{
|
||||
$softwareActivation = $this->softwareActivationRepository->findOneBy(['disqueNom'=>$disqueNom, 'disqueModel'=>$disqueModel, 'disqueSerial'=>$disqueSerial]);
|
||||
}
|
||||
|
||||
|
||||
if($partnerEmail)
|
||||
{
|
||||
$user = $this->userRepository->findOneBy(['email'=>$partnerEmail]);
|
||||
if(!$user){
|
||||
return new JsonResponse(['code'=>404, 'message'=>'partenaire inconnu', 'body'=>[]]);
|
||||
}else{
|
||||
$partner = $user->getPartner();
|
||||
if($partner){
|
||||
if(!$partner->isActive()){
|
||||
return new JsonResponse(['code'=>403, 'message'=>'Accès refusé au partner', 'body'=>[]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($softwareActivation)
|
||||
{
|
||||
if($softwareActivation->getStatu() == 1)
|
||||
{
|
||||
return new JsonResponse(['code'=>1, 'message'=>'true', 'body'=>[
|
||||
'Id'=>$softwareActivation->getId(),
|
||||
'Date'=>$softwareActivation->getDateAddFormat('Y-m-d H:i:s'),
|
||||
'DisqueNom'=>$this->cryptoService->chiffrer($disqueNom),
|
||||
'DisqueModel'=>$this->cryptoService->chiffrer($disqueModel),
|
||||
'DisqueSerial'=>$this->cryptoService->chiffrer($disqueSerial),
|
||||
]]);
|
||||
}else{
|
||||
return new JsonResponse(['code'=>0, 'message'=>"n'ai pas encore activer", 'body'=>[
|
||||
'Id'=>$softwareActivation->getId(),
|
||||
]]);
|
||||
}
|
||||
|
||||
}else{
|
||||
$softwareActivation = $this->softwareActivationRepository->addSoftwareActivation($companyName, $companyMF, $pcName, $user, $disqueNom, $disqueModel, $disqueSerial, $statu);
|
||||
return new JsonResponse(['code'=>2, 'message'=>'La demande a été bien envoyer pour activé le logiciel', 'body'=>[
|
||||
'Id'=>$softwareActivation->getId(),
|
||||
]]);
|
||||
}
|
||||
|
||||
return new JsonResponse(['code'=>500, 'message'=>"erreur lors d'activation du logiciel", 'body'=>[]]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
0
src/Entity/.gitignore
vendored
Normal file
0
src/Entity/.gitignore
vendored
Normal file
596
src/Entity/Geolocation.php
Normal file
596
src/Entity/Geolocation.php
Normal file
@@ -0,0 +1,596 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\GeolocationRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: GeolocationRepository::class)]
|
||||
class Geolocation
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $ip = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $continent_code = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $continent_name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_code2 = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_code3 = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_name_official = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_capital = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $state_prov = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $state_code = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $district = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $city = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $zipcode = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $latitude = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $longitude = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $is_eu = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $calling_code = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_tld = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $languages = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_flag = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $geoname_id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $isp = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $connection_type = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $organization = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $country_emoji = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $currency_code = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $currency_name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $currency_symbol = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $time_zone_name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $time_zone_offset = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $time_zone_offset_with_dst = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $time_zone_current_time = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $time_zone_current_time_unix = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $time_zone_is_dst = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $time_zone_dst_savings = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $time_zone_dst_exists = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'geolocations')]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $dateAdd = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dateAdd = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getIp(): ?string
|
||||
{
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
public function setIp(string $ip): static
|
||||
{
|
||||
$this->ip = $ip;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContinentCode(): ?string
|
||||
{
|
||||
return $this->continent_code;
|
||||
}
|
||||
|
||||
public function setContinentCode(string $continent_code): static
|
||||
{
|
||||
$this->continent_code = $continent_code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContinentName(): ?string
|
||||
{
|
||||
return $this->continent_name;
|
||||
}
|
||||
|
||||
public function setContinentName(string $continent_name): static
|
||||
{
|
||||
$this->continent_name = $continent_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryCode2(): ?string
|
||||
{
|
||||
return $this->country_code2;
|
||||
}
|
||||
|
||||
public function setCountryCode2(string $country_code2): static
|
||||
{
|
||||
$this->country_code2 = $country_code2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryCode3(): ?string
|
||||
{
|
||||
return $this->country_code3;
|
||||
}
|
||||
|
||||
public function setCountryCode3(?string $country_code3): static
|
||||
{
|
||||
$this->country_code3 = $country_code3;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryName(): ?string
|
||||
{
|
||||
return $this->country_name;
|
||||
}
|
||||
|
||||
public function setCountryName(string $country_name): static
|
||||
{
|
||||
$this->country_name = $country_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryNameOfficial(): ?string
|
||||
{
|
||||
return $this->country_name_official;
|
||||
}
|
||||
|
||||
public function setCountryNameOfficial(string $country_name_official): static
|
||||
{
|
||||
$this->country_name_official = $country_name_official;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryCapital(): ?string
|
||||
{
|
||||
return $this->country_capital;
|
||||
}
|
||||
|
||||
public function setCountryCapital(string $country_capital): static
|
||||
{
|
||||
$this->country_capital = $country_capital;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStateProv(): ?string
|
||||
{
|
||||
return $this->state_prov;
|
||||
}
|
||||
|
||||
public function setStateProv(?string $state_prov): static
|
||||
{
|
||||
$this->state_prov = $state_prov;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStateCode(): ?string
|
||||
{
|
||||
return $this->state_code;
|
||||
}
|
||||
|
||||
public function setStateCode(?string $state_code): static
|
||||
{
|
||||
$this->state_code = $state_code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDistrict(): ?string
|
||||
{
|
||||
return $this->district;
|
||||
}
|
||||
|
||||
public function setDistrict(string $district): static
|
||||
{
|
||||
$this->district = $district;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCity(): ?string
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function setCity(?string $city): static
|
||||
{
|
||||
$this->city = $city;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getZipcode(): ?string
|
||||
{
|
||||
return $this->zipcode;
|
||||
}
|
||||
|
||||
public function setZipcode(string $zipcode): static
|
||||
{
|
||||
$this->zipcode = $zipcode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLatitude(): ?string
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
|
||||
public function setLatitude(string $latitude): static
|
||||
{
|
||||
$this->latitude = $latitude;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLongitude(): ?string
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
|
||||
public function setLongitude(string $longitude): static
|
||||
{
|
||||
$this->longitude = $longitude;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isEu(): ?bool
|
||||
{
|
||||
return $this->is_eu;
|
||||
}
|
||||
|
||||
public function setIsEu(?bool $is_eu): static
|
||||
{
|
||||
$this->is_eu = $is_eu;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCallingCode(): ?string
|
||||
{
|
||||
return $this->calling_code;
|
||||
}
|
||||
|
||||
public function setCallingCode(string $calling_code): static
|
||||
{
|
||||
$this->calling_code = $calling_code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryTld(): ?string
|
||||
{
|
||||
return $this->country_tld;
|
||||
}
|
||||
|
||||
public function setCountryTld(string $country_tld): static
|
||||
{
|
||||
$this->country_tld = $country_tld;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLanguages(): ?string
|
||||
{
|
||||
return $this->languages;
|
||||
}
|
||||
|
||||
public function setLanguages(string $languages): static
|
||||
{
|
||||
$this->languages = $languages;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryFlag(): ?string
|
||||
{
|
||||
return $this->country_flag;
|
||||
}
|
||||
|
||||
public function setCountryFlag(string $country_flag): static
|
||||
{
|
||||
$this->country_flag = $country_flag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGeonameId(): ?int
|
||||
{
|
||||
return $this->geoname_id;
|
||||
}
|
||||
|
||||
public function setGeonameId(?int $geoname_id): static
|
||||
{
|
||||
$this->geoname_id = $geoname_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsp(): ?string
|
||||
{
|
||||
return $this->isp;
|
||||
}
|
||||
|
||||
public function setIsp(string $isp): static
|
||||
{
|
||||
$this->isp = $isp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConnectionType(): ?string
|
||||
{
|
||||
return $this->connection_type;
|
||||
}
|
||||
|
||||
public function setConnectionType(?string $connection_type): static
|
||||
{
|
||||
$this->connection_type = $connection_type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrganization(): ?string
|
||||
{
|
||||
return $this->organization;
|
||||
}
|
||||
|
||||
public function setOrganization(?string $organization): static
|
||||
{
|
||||
$this->organization = $organization;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryEmoji(): ?string
|
||||
{
|
||||
return $this->country_emoji;
|
||||
}
|
||||
|
||||
public function setCountryEmoji(?string $country_emoji): static
|
||||
{
|
||||
$this->country_emoji = $country_emoji;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyCode(): ?string
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode(string $currency_code): static
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyName(): ?string
|
||||
{
|
||||
return $this->currency_name;
|
||||
}
|
||||
|
||||
public function setCurrencyName(string $currency_name): static
|
||||
{
|
||||
$this->currency_name = $currency_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencySymbol(): ?string
|
||||
{
|
||||
return $this->currency_symbol;
|
||||
}
|
||||
|
||||
public function setCurrencySymbol(string $currency_symbol): static
|
||||
{
|
||||
$this->currency_symbol = $currency_symbol;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimeZoneName(): ?string
|
||||
{
|
||||
return $this->time_zone_name;
|
||||
}
|
||||
|
||||
public function setTimeZoneName(string $time_zone_name): static
|
||||
{
|
||||
$this->time_zone_name = $time_zone_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimeZoneOffset(): ?string
|
||||
{
|
||||
return $this->time_zone_offset;
|
||||
}
|
||||
|
||||
public function setTimeZoneOffset(string $time_zone_offset): static
|
||||
{
|
||||
$this->time_zone_offset = $time_zone_offset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimeZoneOffsetWithDst(): ?string
|
||||
{
|
||||
return $this->time_zone_offset_with_dst;
|
||||
}
|
||||
|
||||
public function setTimeZoneOffsetWithDst(string $time_zone_offset_with_dst): static
|
||||
{
|
||||
$this->time_zone_offset_with_dst = $time_zone_offset_with_dst;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimeZoneCurrentTime(): ?string
|
||||
{
|
||||
return $this->time_zone_current_time;
|
||||
}
|
||||
|
||||
public function setTimeZoneCurrentTime(string $time_zone_current_time): static
|
||||
{
|
||||
$this->time_zone_current_time = $time_zone_current_time;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimeZoneCurrentTimeUnix(): ?string
|
||||
{
|
||||
return $this->time_zone_current_time_unix;
|
||||
}
|
||||
|
||||
public function setTimeZoneCurrentTimeUnix(string $time_zone_current_time_unix): static
|
||||
{
|
||||
$this->time_zone_current_time_unix = $time_zone_current_time_unix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isTimeZoneIsDst(): ?bool
|
||||
{
|
||||
return $this->time_zone_is_dst;
|
||||
}
|
||||
|
||||
public function setTimeZoneIsDst(?bool $time_zone_is_dst): static
|
||||
{
|
||||
$this->time_zone_is_dst = $time_zone_is_dst;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimeZoneDstSavings(): ?string
|
||||
{
|
||||
return $this->time_zone_dst_savings;
|
||||
}
|
||||
|
||||
public function setTimeZoneDstSavings(string $time_zone_dst_savings): static
|
||||
{
|
||||
$this->time_zone_dst_savings = $time_zone_dst_savings;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isTimeZoneDstExists(): ?bool
|
||||
{
|
||||
return $this->time_zone_dst_exists;
|
||||
}
|
||||
|
||||
public function setTimeZoneDstExists(?bool $time_zone_dst_exists): static
|
||||
{
|
||||
$this->time_zone_dst_exists = $time_zone_dst_exists;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateAdd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function setDateAdd(\DateTimeInterface $dateAdd): static
|
||||
{
|
||||
$this->dateAdd = $dateAdd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
323
src/Entity/ParamDemo.php
Normal file
323
src/Entity/ParamDemo.php
Normal file
@@ -0,0 +1,323 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ParamDemoRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ParamDemoRepository::class)]
|
||||
class ParamDemo
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyName = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyPlace = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $CompanyAddress = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companySIREN = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyMF = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyIF = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyTele = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyFax = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyMail = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companySite = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?float $timbre = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $currencySign = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $currencyName = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $currencyThousandth = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $bankName = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $bankRIP = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $bankRIB = null;
|
||||
|
||||
#[ORM\OneToOne(inversedBy: 'paramDemo', cascade: ['persist', 'remove'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $user = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCompanyName(): ?string
|
||||
{
|
||||
return $this->companyName;
|
||||
}
|
||||
|
||||
public function setCompanyName(string $companyName): static
|
||||
{
|
||||
$this->companyName = $companyName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyPlace(): ?string
|
||||
{
|
||||
return $this->companyPlace;
|
||||
}
|
||||
|
||||
public function setCompanyPlace(string $companyPlace): static
|
||||
{
|
||||
$this->companyPlace = $companyPlace;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyAddress(): ?string
|
||||
{
|
||||
return $this->CompanyAddress;
|
||||
}
|
||||
|
||||
public function setCompanyAddress(?string $CompanyAddress): static
|
||||
{
|
||||
$this->CompanyAddress = $CompanyAddress;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanySIREN(): ?string
|
||||
{
|
||||
return $this->companySIREN;
|
||||
}
|
||||
|
||||
public function setCompanySIREN(string $companySIREN): static
|
||||
{
|
||||
$this->companySIREN = $companySIREN;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyMF(): ?string
|
||||
{
|
||||
return $this->companyMF;
|
||||
}
|
||||
|
||||
public function setCompanyMF(string $companyMF): static
|
||||
{
|
||||
$this->companyMF = $companyMF;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyIF(): ?string
|
||||
{
|
||||
return $this->companyIF;
|
||||
}
|
||||
|
||||
public function setCompanyIF(string $companyIF): static
|
||||
{
|
||||
$this->companyIF = $companyIF;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyTele(): ?string
|
||||
{
|
||||
return $this->companyTele;
|
||||
}
|
||||
|
||||
public function setCompanyTele(string $companyTele): static
|
||||
{
|
||||
$this->companyTele = $companyTele;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyFax(): ?string
|
||||
{
|
||||
return $this->companyFax;
|
||||
}
|
||||
|
||||
public function setCompanyFax(string $companyFax): static
|
||||
{
|
||||
$this->companyFax = $companyFax;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyMail(): ?string
|
||||
{
|
||||
return $this->companyMail;
|
||||
}
|
||||
|
||||
public function setCompanyMail(string $companyMail): static
|
||||
{
|
||||
$this->companyMail = $companyMail;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanySite(): ?string
|
||||
{
|
||||
return $this->companySite;
|
||||
}
|
||||
|
||||
public function setCompanySite(string $companySite): static
|
||||
{
|
||||
$this->companySite = $companySite;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimbre(): ?float
|
||||
{
|
||||
return $this->timbre;
|
||||
}
|
||||
|
||||
public function setTimbre(float $timbre): static
|
||||
{
|
||||
$this->timbre = $timbre;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencySign(): ?string
|
||||
{
|
||||
return $this->currencySign;
|
||||
}
|
||||
|
||||
public function setCurrencySign(string $currencySign): static
|
||||
{
|
||||
$this->currencySign = $currencySign;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyName(): ?string
|
||||
{
|
||||
return $this->currencyName;
|
||||
}
|
||||
|
||||
public function setCurrencyName(string $currencyName): static
|
||||
{
|
||||
$this->currencyName = $currencyName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyThousandth(): ?string
|
||||
{
|
||||
return $this->currencyThousandth;
|
||||
}
|
||||
|
||||
public function setCurrencyThousandth(string $currencyThousandth): static
|
||||
{
|
||||
$this->currencyThousandth = $currencyThousandth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBankName(): ?string
|
||||
{
|
||||
return $this->bankName;
|
||||
}
|
||||
|
||||
public function setBankName(string $bankName): static
|
||||
{
|
||||
$this->bankName = $bankName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBankRIP(): ?string
|
||||
{
|
||||
return $this->bankRIP;
|
||||
}
|
||||
|
||||
public function setBankRIP(string $bankRIP): static
|
||||
{
|
||||
$this->bankRIP = $bankRIP;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBankRIB(): ?string
|
||||
{
|
||||
return $this->bankRIB;
|
||||
}
|
||||
|
||||
public function setBankRIB(string $bankRIB): static
|
||||
{
|
||||
$this->bankRIB = $bankRIB;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
"CompanyName"=>$this->companyName,
|
||||
"CompanyPlace"=>$this->companyPlace,
|
||||
"CompanyAddress"=>$this->CompanyAddress,
|
||||
"CompanySIREN"=>$this->companySIREN,
|
||||
"CompanyMF"=>$this->companyMF,
|
||||
"CompanyIF"=>$this->companyIF,
|
||||
"CompanyTele"=>$this->companyTele,
|
||||
"CompanyFax"=>$this->companyFax,
|
||||
"CompanyMail"=>$this->companyMail,
|
||||
"CompanySite"=>$this->companySite,
|
||||
"Timbre"=>$this->timbre,
|
||||
"CurrencySign"=>$this->currencySign,
|
||||
"CurrencyName"=>$this->currencyName,
|
||||
"CurrencyThousandth"=>$this->currencyThousandth,
|
||||
"Bank"=>$this->bankName,
|
||||
"RIP"=>$this->bankRIP,
|
||||
"RIB"=>$this->bankRIB,
|
||||
"UserPrenom"=>$this->user->getFirstname(),
|
||||
"UserNom"=>$this->user->getLastname()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
68
src/Entity/Partner.php
Normal file
68
src/Entity/Partner.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PartnerRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PartnerRepository::class)]
|
||||
class Partner
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\OneToOne(inversedBy: 'partner', cascade: ['persist', 'remove'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?bool $active = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $dateAdd = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function isActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): static
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateAdd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function setDateAdd(\DateTimeInterface $dateAdd): static
|
||||
{
|
||||
$this->dateAdd = $dateAdd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
41
src/Entity/SoftDownloader.php
Normal file
41
src/Entity/SoftDownloader.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\SoftDownloaderRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SoftDownloaderRepository::class)]
|
||||
class SoftDownloader
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $dateAdd = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dateAdd = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getDateAdd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function setDateAdd(\DateTimeInterface $dateAdd): static
|
||||
{
|
||||
$this->dateAdd = $dateAdd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
188
src/Entity/SoftwareActivation.php
Normal file
188
src/Entity/SoftwareActivation.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\SoftwareActivationRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use PhpParser\Node\Expr\Cast\String_;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SoftwareActivationRepository::class)]
|
||||
class SoftwareActivation
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $companyName = null;
|
||||
|
||||
#[ORM\Column(length: 400)]
|
||||
private ?string $companyMF = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $PcName = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'softwareActivations')]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $disqueNom = null;
|
||||
|
||||
#[ORM\Column(length: 300)]
|
||||
private ?string $disqueModel = null;
|
||||
|
||||
#[ORM\Column(length: 350)]
|
||||
private ?string $disqueSerial = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $dateAdd = null;
|
||||
|
||||
/*
|
||||
pour le code
|
||||
0 | null --> n'ai pas encore activer
|
||||
1 --> activer
|
||||
2 --> La demande a été bien envoyer pour activé le logiciel
|
||||
n --> erreur
|
||||
*/
|
||||
#[ORM\Column(type: Types::SMALLINT)]
|
||||
private ?int $statu = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dateAdd = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCompanyName(): ?string
|
||||
{
|
||||
return $this->companyName;
|
||||
}
|
||||
|
||||
public function setCompanyName(string $companyName): static
|
||||
{
|
||||
$this->companyName = $companyName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompanyMF(): ?string
|
||||
{
|
||||
return $this->companyMF;
|
||||
}
|
||||
|
||||
public function setCompanyMF(string $companyMF): static
|
||||
{
|
||||
$this->companyMF = $companyMF;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPcName(): ?string
|
||||
{
|
||||
return $this->PcName;
|
||||
}
|
||||
|
||||
public function setPcName(string $PcName): static
|
||||
{
|
||||
$this->PcName = $PcName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDisqueNom(): ?string
|
||||
{
|
||||
return $this->disqueNom;
|
||||
}
|
||||
|
||||
public function setDisqueNom(string $disqueNom): static
|
||||
{
|
||||
$this->disqueNom = $disqueNom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDisqueModel(): ?string
|
||||
{
|
||||
return $this->disqueModel;
|
||||
}
|
||||
|
||||
public function setDisqueModel(string $disqueModel): static
|
||||
{
|
||||
$this->disqueModel = $disqueModel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDisqueSerial(): ?string
|
||||
{
|
||||
return $this->disqueSerial;
|
||||
}
|
||||
|
||||
public function setDisqueSerial(string $disqueSerial): static
|
||||
{
|
||||
$this->disqueSerial = $disqueSerial;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateAdd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function getDateAddFormat($format): ?string
|
||||
{
|
||||
return $this->dateAdd->format($format);
|
||||
}
|
||||
|
||||
public function setDateAdd(\DateTimeInterface $dateAdd): static
|
||||
{
|
||||
$this->dateAdd = $dateAdd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatu(): ?int
|
||||
{
|
||||
return $this->statu;
|
||||
}
|
||||
|
||||
public function setStatu(int $statu): static
|
||||
{
|
||||
$this->statu = $statu;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStatuText(int $statu): ?string
|
||||
{
|
||||
if($this->statu == 0){
|
||||
return "En Attente";
|
||||
}elseif($this->statu == 1){
|
||||
return "Activer";
|
||||
}elseif($this->statu == 2){
|
||||
return "En Attente";
|
||||
}else{
|
||||
return "Erreur";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
362
src/Entity/User.php
Normal file
362
src/Entity/User.php
Normal file
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private int $id;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $firstname = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $lastname = null;
|
||||
|
||||
#[ORM\Column(type: Types::SMALLINT)]
|
||||
private ?int $gender = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $birthdate = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 180, unique: true)]
|
||||
private ?string $email;
|
||||
|
||||
#[ORM\Column(type: 'json')]
|
||||
private array $roles = [];
|
||||
|
||||
#[ORM\Column(type: 'string')]
|
||||
private string $password;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $lastLogin = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $dateAdd = null;
|
||||
|
||||
#[ORM\OneToOne(mappedBy: 'user', cascade: ['persist', 'remove'])]
|
||||
private ?ParamDemo $paramDemo = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Geolocation>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Geolocation::class, mappedBy: 'user')]
|
||||
private Collection $geolocations;
|
||||
|
||||
/**
|
||||
* @var Collection<int, SoftwareActivation>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: SoftwareActivation::class, mappedBy: 'user')]
|
||||
private Collection $softwareActivations;
|
||||
|
||||
#[ORM\OneToOne(mappedBy: 'user', cascade: ['persist', 'remove'])]
|
||||
private ?Partner $partner = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dateAdd = new \DateTime();
|
||||
$this->lastLogin = new \DateTime();
|
||||
$this->geolocations = new ArrayCollection();
|
||||
$this->softwareActivations = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getFirstname(): ?string
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
public function setFirstname(string $firstname): self
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastname(): ?string
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
public function setLastname(string $lastname): self
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function getFullName(): ?string
|
||||
{
|
||||
return $this->firstname." ".$this->lastname;
|
||||
}
|
||||
|
||||
|
||||
public function getGender(): ?int
|
||||
{
|
||||
return $this->gender;
|
||||
}
|
||||
|
||||
public function setGender(int $gender): self
|
||||
{
|
||||
$this->gender = $gender;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBirthdate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->birthdate;
|
||||
}
|
||||
|
||||
public function getBirthdateText($format): ?string
|
||||
{
|
||||
return $this->birthdate->format($format);
|
||||
}
|
||||
|
||||
public function setBirthdate(\DateTimeInterface $birthdate): self
|
||||
{
|
||||
$this->birthdate = $birthdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): self
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The public representation of the user (e.g. a username, an email address, etc.)
|
||||
*
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function getUserIdentifier(): string
|
||||
{
|
||||
return (string) $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function getRoles(): array
|
||||
{
|
||||
$roles = $this->roles;
|
||||
// guarantee every user at least has ROLE_USER
|
||||
$roles[] = 'ROLE_USER';
|
||||
|
||||
return array_unique($roles);
|
||||
}
|
||||
|
||||
public function setRoles(array $roles): self
|
||||
{
|
||||
$this->roles = $roles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasRole(string $role): ?bool
|
||||
{
|
||||
$Indice = array_search($role, $this->roles);
|
||||
if(is_numeric($Indice)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function addRole(string $role): ?bool
|
||||
{
|
||||
if(!$this->hasRole($role)){
|
||||
$this->roles[] = $role;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeRole(string $role)
|
||||
{
|
||||
$Indice = array_search($role, $this->roles);
|
||||
if(is_numeric($Indice)){
|
||||
unset($this->roles[$Indice]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PasswordAuthenticatedUserInterface
|
||||
*/
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password): self
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function eraseCredentials(): void
|
||||
{
|
||||
// If you store any temporary, sensitive data on the user, clear it here
|
||||
// $this->plainPassword = null;
|
||||
}
|
||||
|
||||
public function getLastLogin(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->lastLogin;
|
||||
}
|
||||
|
||||
public function setLastLogin(\DateTimeInterface $lastLogin): self
|
||||
{
|
||||
$this->lastLogin = $lastLogin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateAdd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->dateAdd;
|
||||
}
|
||||
|
||||
public function getDateAddText($format): ?string
|
||||
{
|
||||
return $this->dateAdd->format($format);
|
||||
}
|
||||
|
||||
public function setDateAdd(\DateTimeInterface $dateAdd): self
|
||||
{
|
||||
$this->dateAdd = $dateAdd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParamDemo(): ?ParamDemo
|
||||
{
|
||||
return $this->paramDemo;
|
||||
}
|
||||
|
||||
public function setParamDemo(ParamDemo $paramDemo): static
|
||||
{
|
||||
// set the owning side of the relation if necessary
|
||||
if ($paramDemo->getUser() !== $this) {
|
||||
$paramDemo->setUser($this);
|
||||
}
|
||||
|
||||
$this->paramDemo = $paramDemo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Geolocation>
|
||||
*/
|
||||
public function getGeolocations(): Collection
|
||||
{
|
||||
//$this->geolocations->
|
||||
return $this->geolocations;
|
||||
}
|
||||
|
||||
public function addGeolocation(Geolocation $geolocation): static
|
||||
{
|
||||
if (!$this->geolocations->contains($geolocation)) {
|
||||
$this->geolocations->add($geolocation);
|
||||
$geolocation->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeGeolocation(Geolocation $geolocation): static
|
||||
{
|
||||
if ($this->geolocations->removeElement($geolocation)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($geolocation->getUser() === $this) {
|
||||
$geolocation->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Geolocation
|
||||
*/
|
||||
public function getLastGeolocations(): Geolocation
|
||||
{
|
||||
return $this->geolocations->last();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, SoftwareActivation>
|
||||
*/
|
||||
public function getSoftwareActivations(): Collection
|
||||
{
|
||||
return $this->softwareActivations;
|
||||
}
|
||||
|
||||
public function addSoftwareActivation(SoftwareActivation $softwareActivation): static
|
||||
{
|
||||
if (!$this->softwareActivations->contains($softwareActivation)) {
|
||||
$this->softwareActivations->add($softwareActivation);
|
||||
$softwareActivation->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSoftwareActivation(SoftwareActivation $softwareActivation): static
|
||||
{
|
||||
if ($this->softwareActivations->removeElement($softwareActivation)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($softwareActivation->getUser() === $this) {
|
||||
$softwareActivation->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPartner(): ?Partner
|
||||
{
|
||||
return $this->partner;
|
||||
}
|
||||
|
||||
public function setPartner(Partner $partner): static
|
||||
{
|
||||
// set the owning side of the relation if necessary
|
||||
if ($partner->getUser() !== $this) {
|
||||
$partner->setUser($this);
|
||||
}
|
||||
|
||||
$this->partner = $partner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
36
src/Form/MailType.php
Normal file
36
src/Form/MailType.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
|
||||
class MailType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('fullname', TextType::class, ['required' => true, 'attr' => ['placeholder' => 'Nom Prénom *']])
|
||||
->add('email', EmailType::class, ['required' => true, 'attr' => ['placeholder' => 'Email *']])
|
||||
->add('recaptcha', HiddenType::class, [ 'mapped' => false])
|
||||
->add('subject', TextType::class, ['required' => true, 'attr' => ['placeholder' => 'Sujet *']])
|
||||
->add('message', TextareaType::class, ['required' => true, 'attr' => ['placeholder' => 'Message *']])
|
||||
->add('submit', SubmitType::class, ['label' => 'Envoyer le Message' ])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
// Configure your form options here
|
||||
]);
|
||||
}
|
||||
}
|
||||
48
src/Form/ParamDemoType.php
Normal file
48
src/Form/ParamDemoType.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\ParamDemo;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class ParamDemoType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('companyName', TextType::class, ['label' => "Nom", 'attr' => ['placeholder' => 'Company T']])
|
||||
->add('companyPlace', TextType::class, ['label' => "Payé", 'attr' => ['placeholder' => 'Tunis']])
|
||||
->add('CompanyAddress', TextType::class, ['label' => "Adresse", 'attr' => ['placeholder' => '2 rue elmouez mornaguia']])
|
||||
->add('companySIREN', TextType::class, ['label' => "SIREN", 'attr' => ['placeholder' => '533 459 590 S5447S']])
|
||||
->add('companyMF', TextType::class, ['label' => "Matricule Fiscale", 'attr' => ['placeholder' => 'ZS998 1D4X1Q 22S1X']])
|
||||
->add('companyIF', TextType::class, ['label' => "Identité Fiscale", 'attr' => ['placeholder' => '74XS69Q2 44SX12Q 225S5S1']])
|
||||
->add('companyTele', TextType::class, ['label' => "Tele", 'attr' => ['placeholder' => '52 719 341']])
|
||||
->add('companyFax', TextType::class, ['label' => "Fax", 'attr' => ['placeholder' => '71 547 114']])
|
||||
->add('companyMail', TextType::class, ['label' => "Mail", 'attr' => ['placeholder' => 'contact@powerpme.com']])
|
||||
->add('companySite', TextType::class, ['label' => "Site", 'attr' => ['placeholder' => 'www.powerpme.com']])
|
||||
->add('timbre', TextType::class, ['label' => "timbre", 'attr' => ['placeholder' => '0.600']])
|
||||
->add('currencySign', TextType::class, ['label' => "currencySign", 'attr' => ['placeholder' => 'DT']])
|
||||
->add('currencyName', TextType::class, ['label' => "currencyName", 'attr' => ['placeholder' => 'dinar']])
|
||||
->add('currencyThousandth', TextType::class, ['label' => "currencyThousandth", 'attr' => ['placeholder' => 'millime']])
|
||||
->add('bankName', TextType::class, ['label' => "Banque", 'attr' => ['placeholder' => 'La Poste Tunisienne']])
|
||||
->add('bankRIP', TextType::class, ['label' => "RIB", 'attr' => ['placeholder' => '17 001 000000 2366763 08']])
|
||||
->add('bankRIB', TextType::class, ['label' => "IBAN", 'attr' => ['placeholder' => 'TN59 1700 1000 0002 3667 9587']])
|
||||
->add('submit', SubmitType::class, array(
|
||||
'label' => 'Modifier les Paramétres'
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => ParamDemo::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
75
src/Form/UserRegistrationType.php
Normal file
75
src/Form/UserRegistrationType.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\IsTrue;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
|
||||
class UserRegistrationType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('email', EmailType::class, array(
|
||||
'label' => 'Email'
|
||||
))
|
||||
->add('password', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'invalid_message' => 'The password fields must match.',
|
||||
'options' => ['attr' => ['class' => 'password-field']],
|
||||
'required' => true,
|
||||
'first_options' => ['label' => 'Mot de passe'],
|
||||
'second_options' => ['label' => 'Confirmation mot de passe'],
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'Please enter a password',
|
||||
]),
|
||||
new Length([
|
||||
'min' => 6,
|
||||
'minMessage' => 'Your password should be at least {{ limit }} characters',
|
||||
// max length allowed by Symfony for security reasons
|
||||
'max' => 4096,
|
||||
]),
|
||||
],
|
||||
])
|
||||
->add('firstname', TextType::class, array(
|
||||
'label' => 'Prénom',
|
||||
'required' => true
|
||||
))
|
||||
->add('lastname', TextType::class, array(
|
||||
'label' => 'Nom',
|
||||
'required' => true
|
||||
))
|
||||
->add('birthdate', DateType::class, array(
|
||||
'label' => 'Date de naissance',
|
||||
'required' => true
|
||||
))
|
||||
->add('gender', ChoiceType::class, array(
|
||||
'label' => 'Gender',
|
||||
'choices' => ['Femme' => 0, 'Homme' => 1 ],
|
||||
'required' => true
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
src/Kernel.php
Normal file
11
src/Kernel.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
}
|
||||
0
src/Repository/.gitignore
vendored
Normal file
0
src/Repository/.gitignore
vendored
Normal file
94
src/Repository/GeolocationRepository.php
Normal file
94
src/Repository/GeolocationRepository.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Geolocation;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Geolocation>
|
||||
*/
|
||||
class GeolocationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Geolocation::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arrResultApi
|
||||
* @return int
|
||||
*/
|
||||
public function setGeolocation($arrResultApi): int
|
||||
{
|
||||
$geolocation = new Geolocation();
|
||||
$geolocation->setIp($arrResultApi["ip"]);
|
||||
$geolocation->setContinentCode($arrResultApi["continent_code"]);
|
||||
$geolocation->setContinentName($arrResultApi["continent_name"]);
|
||||
$geolocation->setCountryCode2($arrResultApi["country_code2"]);
|
||||
$geolocation->setCountryCode3($arrResultApi["country_code3"]);
|
||||
$geolocation->setCountryName($arrResultApi["country_name"]);
|
||||
$geolocation->setCountryNameOfficial($arrResultApi["country_name_official"]);
|
||||
$geolocation->setCountryCapital($arrResultApi["country_capital"]);
|
||||
$geolocation->setStateProv($arrResultApi["state_prov"]);
|
||||
$geolocation->setStateCode($arrResultApi["state_code"]);
|
||||
$geolocation->setDistrict($arrResultApi["district"]);
|
||||
$geolocation->setCity($arrResultApi["city"]);
|
||||
$geolocation->setZipcode($arrResultApi["zipcode"]);
|
||||
$geolocation->setLatitude($arrResultApi["latitude"]);
|
||||
$geolocation->setLongitude($arrResultApi["longitude"]);
|
||||
$geolocation->setIsEu($arrResultApi["is_eu"]);
|
||||
$geolocation->setCallingCode($arrResultApi["calling_code"]);
|
||||
$geolocation->setCountryTld($arrResultApi["country_tld"]);
|
||||
$geolocation->setLanguages($arrResultApi["languages"]);
|
||||
$geolocation->setCountryFlag($arrResultApi["country_flag"]);
|
||||
$geolocation->setGeonameId($arrResultApi["geoname_id"]);
|
||||
$geolocation->setIsp($arrResultApi["isp"]);
|
||||
$geolocation->setConnectionType($arrResultApi["connection_type"]);
|
||||
$geolocation->setOrganization($arrResultApi["organization"]);
|
||||
$geolocation->setCountryEmoji($arrResultApi["country_emoji"]);
|
||||
$geolocation->setCurrencyCode($arrResultApi["currency"]["code"]);
|
||||
$geolocation->setCurrencyName($arrResultApi["currency"]["name"]);
|
||||
$geolocation->setCurrencySymbol($arrResultApi["currency"]["symbol"]);
|
||||
$geolocation->setTimeZoneName($arrResultApi["time_zone"]["name"]);
|
||||
$geolocation->setTimeZoneOffset($arrResultApi["time_zone"]["offset"]);
|
||||
$geolocation->setTimeZoneOffsetWithDst($arrResultApi["time_zone"]["offset_with_dst"]);
|
||||
$geolocation->setTimeZoneCurrentTime($arrResultApi["time_zone"]["current_time"]);
|
||||
$geolocation->setTimeZoneCurrentTimeUnix($arrResultApi["time_zone"]["current_time_unix"]);
|
||||
$geolocation->setTimeZoneIsDst($arrResultApi["time_zone"]["is_dst"]);
|
||||
$geolocation->setTimeZoneDstSavings($arrResultApi["time_zone"]["dst_savings"]);
|
||||
$geolocation->setTimeZoneDstExists($arrResultApi["time_zone"]["dst_exists"]);
|
||||
|
||||
$this->getEntityManager()->persist($geolocation);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
return $geolocation->getId();
|
||||
}
|
||||
|
||||
public function countGeolocationNow(): int
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->select('COUNT(u.id) AS nbrVisitor')
|
||||
->andWhere('DATE(u.dateAdd) = :DateAdd')
|
||||
->setParameter('DateAdd', (new \DateTime())->format('Y-m-d'))
|
||||
->getQuery()
|
||||
->getOneOrNullResult()['nbrVisitor']
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Geolocation[] Returns an array of Geolocation objects
|
||||
*/
|
||||
public function getGeolocationsNow(): array
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->andWhere('DATE(u.dateAdd) = :DateAdd')
|
||||
->setParameter('DateAdd', (new \DateTime())->format('Y-m-d'))
|
||||
->orderBy('u.dateAdd', 'DESC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
57
src/Repository/ParamDemoRepository.php
Normal file
57
src/Repository/ParamDemoRepository.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ParamDemo;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<ParamDemo>
|
||||
*/
|
||||
class ParamDemoRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ParamDemo::class);
|
||||
}
|
||||
|
||||
public function findOneByLoginPassword($login): ?ParamDemo
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
|
||||
->innerJoin('p.user', 'u')
|
||||
|
||||
->where('u.email = :Email')
|
||||
->setParameter('Email', $login)
|
||||
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return ParamDemo[] Returns an array of ParamDemo objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('p.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?ParamDemo
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
43
src/Repository/PartnerRepository.php
Normal file
43
src/Repository/PartnerRepository.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Partner;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Partner>
|
||||
*/
|
||||
class PartnerRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Partner::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Partner[] Returns an array of Partner objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('p.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Partner
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
55
src/Repository/SoftDownloaderRepository.php
Normal file
55
src/Repository/SoftDownloaderRepository.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\SoftDownloader;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<SoftDownloader>
|
||||
*/
|
||||
class SoftDownloaderRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, SoftDownloader::class);
|
||||
}
|
||||
|
||||
public function getDownloadersNow(): int
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->select('COUNT(u.id) AS nbrDownloader')
|
||||
->andWhere('DATE(u.dateAdd) = :DateAdd')
|
||||
->setParameter('DateAdd', (new \DateTime())->format('Y-m-d'))
|
||||
->getQuery()
|
||||
->getOneOrNullResult()['nbrDownloader']
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * @return SoftDownloader[] Returns an array of SoftDownloader objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('s.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?SoftDownloader
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
63
src/Repository/SoftwareActivationRepository.php
Normal file
63
src/Repository/SoftwareActivationRepository.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\SoftwareActivation;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<SoftwareActivation>
|
||||
*/
|
||||
class SoftwareActivationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, SoftwareActivation::class);
|
||||
}
|
||||
|
||||
|
||||
public function addSoftwareActivation($companyName, $companyMF, $pcName, $user, $disqueNom, $disqueModel, $disqueSerial, $statu)
|
||||
{
|
||||
$softwareActivation = new SoftwareActivation();
|
||||
|
||||
$softwareActivation->setCompanyName($companyName);
|
||||
$softwareActivation->setCompanyMF($companyMF);
|
||||
$softwareActivation->setPcName($pcName);
|
||||
$softwareActivation->setUser($user);
|
||||
$softwareActivation->setDisqueNom($disqueNom);
|
||||
$softwareActivation->setDisqueModel($disqueModel);
|
||||
$softwareActivation->setDisqueSerial($disqueSerial);
|
||||
$softwareActivation->setStatu($statu);
|
||||
|
||||
$this->getEntityManager()->persist($softwareActivation);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
return $softwareActivation;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return SoftwareActivation[] Returns an array of SoftwareActivation objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('s.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?SoftwareActivation
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
79
src/Repository/UserRepository.php
Normal file
79
src/Repository/UserRepository.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<User>
|
||||
*/
|
||||
class UserRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
|
||||
public function countUsersNow(): int
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->select('COUNT(u.id) AS nbrUser')
|
||||
->andWhere('DATE(u.dateAdd) = :DateAdd')
|
||||
->setParameter('DateAdd', (new \DateTime())->format('Y-m-d'))
|
||||
->getQuery()
|
||||
->getOneOrNullResult()['nbrUser']
|
||||
;
|
||||
}
|
||||
|
||||
public function findByRoles(array $roles): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('u');
|
||||
|
||||
foreach ($roles as $key => $role) {
|
||||
$qb->orWhere('JSON_CONTAINS(u.roles, :role'.$key.') = 1')
|
||||
->setParameter('role'.$key, json_encode($role));
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function findUsersWithoutAdminOrPartner(): array
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->where('JSON_CONTAINS(u.roles, :admin) = 0')
|
||||
->andWhere('JSON_CONTAINS(u.roles, :partner) = 0')
|
||||
->setParameter('admin', json_encode('ROLE_ADMIN'))
|
||||
->setParameter('partner', json_encode('ROLE_PARTNER'))
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return User[] Returns an array of User objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('u')
|
||||
// ->andWhere('u.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('u.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?User
|
||||
// {
|
||||
// return $this->createQueryBuilder('u')
|
||||
// ->andWhere('u.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
77
src/Security/LoginAuthenticator.php
Normal file
77
src/Security/LoginAuthenticator.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Security;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
|
||||
use Symfony\Component\Security\Http\Util\TargetPathTrait;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class LoginAuthenticator extends AbstractLoginFormAuthenticator
|
||||
{
|
||||
use TargetPathTrait;
|
||||
|
||||
public const LOGIN_ROUTE = 'security_login';
|
||||
|
||||
private $em;
|
||||
|
||||
private $authenticationUtils;
|
||||
|
||||
public function __construct(private UrlGeneratorInterface $urlGenerator, EntityManagerInterface $em, AuthenticationUtils $authenticationUtils)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->authenticationUtils = $authenticationUtils;
|
||||
}
|
||||
|
||||
public function authenticate(Request $request): Passport
|
||||
{
|
||||
$email = $request->request->get('email', '');
|
||||
|
||||
$request->getSession()->set($this->authenticationUtils->getLastUsername(), $email);
|
||||
|
||||
return new Passport(
|
||||
new UserBadge($email),
|
||||
new PasswordCredentials($request->request->get('password', '')),
|
||||
[
|
||||
new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),
|
||||
new RememberMeBadge(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
|
||||
{
|
||||
if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
|
||||
return new RedirectResponse($targetPath);
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $token->getUser();
|
||||
$user->setLastLogin(new \DateTime());
|
||||
$this->em->persist($user);
|
||||
$this->em->flush();
|
||||
$this->em->clear();
|
||||
|
||||
if ($user->hasRole('ROLE_ADMIN')){
|
||||
return new RedirectResponse($this->urlGenerator->generate('admin_home_index'));
|
||||
}else{
|
||||
return new RedirectResponse($this->urlGenerator->generate('home_index'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getLoginUrl(Request $request): string
|
||||
{
|
||||
return $this->urlGenerator->generate(self::LOGIN_ROUTE);
|
||||
}
|
||||
}
|
||||
29
src/Service/CryptoService.php
Normal file
29
src/Service/CryptoService.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
class CryptoService
|
||||
{
|
||||
private string $cipher = 'AES-256-CBC';
|
||||
private string $key;
|
||||
private string $iv = 'abcdef9876543210'; // 16 caract<63>res
|
||||
|
||||
public function __construct(private string $keyActivation)
|
||||
{
|
||||
$this->key = $keyActivation; // 32 caract<63>res
|
||||
}
|
||||
|
||||
public function chiffrer(string $data): string
|
||||
{
|
||||
$encrypted = openssl_encrypt($data, $this->cipher, $this->key, OPENSSL_RAW_DATA, $this->iv);
|
||||
return base64_encode($encrypted);
|
||||
}
|
||||
|
||||
public function dechiffrer(string $data): string
|
||||
{
|
||||
$decoded = base64_decode($data);
|
||||
return openssl_decrypt($decoded, $this->cipher, $this->key, OPENSSL_RAW_DATA, $this->iv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user