Jump to content

You're browsing the 2004-2023 VATSIM Forums archive. All content is preserved in a read-only fashion.
For the latest forum posts, please visit https://forum.vatsim.net.

Need to find something? Use the Google search below.
PLEASE READ - Webmaster Support Forum
This forum will be retired in the near future. Please direct all queries to our dedicated GitHub support page https://github.com/vatsimnetwork/developer-info/discussions 
Here you can find documentation on our services and we are continuing to migrate pertinent information into the Wiki pages https://github.com/vatsimnetwork/developer-info/wiki

VATBOOK error


Aleksa Eric
 Share

Recommended Posts

Aleksa Eric
Posted
Posted (edited)

Until yesterday afternoon everything worked fine, but at some point, although nothing was changed I started getting this error.

image.png.d556ced8908c5b5faee8307681c9d843.png

This is only on one part of the webiste. Almost same code in other controller works just fine. If anyone knows what could be the issue it would be great. Here's the function:

 
    public function create(Request $request){
 
        $rules = [
            'cid' => 'required|integer',
            'name'=> 'required|regex:/^[a-zA-Z\s]+$/',
            'date'=> 'required|date_format:m/d/Y',
            'start' => 'date_format:H:i',
            'end' => 'date_format:H:i|after:start',
            'position'=>'required|regex:/^[a-zA-Z_\s]+$/'
         ];
        $this->validate($request$rules);
        $date=date_create($request->date);
        $controller = $request->name;
        $callsign = $request->position;
        $start = Carbon::createFromFormat('H:i'$request->start)->setDateFrom($date);
        $end = Carbon::createFromFormat('H:i'$request->end)->setDateFrom($date);
        $cid = $request->cid;
        $localid=floor($cid / (date('z') + 1));
        $training = 0;
        $event = 0;
        $bookingsAll=[];
        $error = 0;
      $events = Event::all();
      $bookings = Booking::all();
      foreach($bookings as $book){
          if($book->position==$callsign && date_create($start)->format('d/m/Y')==date_create($book->start)->format('d/m/Y')){
          if( !(date_create($start)->format('H:i')>date_create($book->start)->format('H:i'))){
              if(!(date_create($end)->format('H:i')<date_create($book->start)->format('H:i')) && !(date_create($end)->format('H:i')<date_create($book->end)->format('H:i'))){
             $error=1;
          }}}    
      }
         foreach($events as $event){
              if($event->isRestricted==1 && $request->type!='event'){
                  $event_start = Carbon::createFromFormat('H:i'$event->start)->setDateFrom($date);
                  $event_start = $event_start->subHours(5);
                  $event_end = Carbon::createFromFormat('H:i'$event->end)->setDateFrom($date);
                  if(date_diff($end,$event_start)->format("%R%a")==0 && $start>=$event_start){
                      $error = 2;                             
                  }elseif(date_diff($end_,$event_start)->format("%R%a")==0 && $end>$event_start){
                      $error=2;                     
                  } 
              }
          }     
        if($error==0){
           $booking = new Booking;
           $booking->cid=$cid;
           if($request->type=='event'){
               $controller = 'VATAdria Events';
           }
           $booking->controller=$controller;
           $booking->position=$callsign;
           $booking->date=$date;
           $booking->start=$start;
           $booking->end=$end;
           $booking->type=0;
           if(in_array('Events'explode(', 'auth()->user()->roles))){
            if($request->type=='event'){
                $booking->type='event';
            }else{
            $booking->type=0;
        }
        }
            else{
                $booking->type=0;
            }
           $booking->local_id=$localid
           $response = file_get_contents(str_replace(' ''%20',"http://vatbook.euroutepro.com/atc/insert.asp?Local_URL=noredir&Local_ID={$localid}&b_day={$date->format('d')}&b_month={$date->format('m')}&b_year={$date->format('Y')}&Controller={$controller}&Position={$callsign}&sTime={$start->format('Hi')}&eTime={$end->format('Hi')}&cid={$cid}&T={$training}&E={$event->name}&voice=1"));
         print_r($response);
         preg_match_all('/EU_ID=(\d+)/'$response$matches);
 
        ifisset$mathces[1][0] )){
            $eu_id = $matches[1][0];
        }else
 
return back()->with('error''There is an error on the network. Try later.');}
 
           $booking->eu_id=$eu_id;
 
           $booking->save();
 
          return redirect()->route('bookings')->with('message''Successfully created booking for '.$date->format('d.m.Y').' from '.$start->format('H:i').'z to '.$end->format('H:i').'z at '.$callsign);
 
        }elseif($error==1){
 
            return back()->with('error''Booking already exists')->withInput();
 
        }else{
 
             return back()->with('error''There is an event, you cannot book a session!')->withInput();
 
        }     
 
        
 
    }

 

image.png

Edited by Aleksa Eric
Link to comment
Share on other sites

 Share