Exemplo n.º 1
0
 public function store(SubmitFlagRequest $request)
 {
     $startd = DB::table('Games')->select('start')->first();
     $endd = DB::table('Games')->select('stop')->first();
     if ($startd->start > Carbon::now()) {
         return view("pages.countdown");
     } elseif ($endd->stop < Carbon::now()) {
         return view('pages.closed');
     }
     $request = $request->all();
     $flags = Flag::where('flag', $request['flag'])->first();
     if (!empty($flags)) {
         $previously = Submitted_flag::select('user_id')->where('text', $request['flag'])->where('user_id', Auth::user()->id)->get();
         $previously = $previously->toArray();
         var_dump($previously);
         if (empty($previously)) {
             $flags = $flags->toArray();
             $submission['created_at'] = Carbon::now()->toDateTimeString();
             $submission['updated_at'] = Carbon::now()->toDateTimeString();
             $submission['user_id'] = Auth::user()->id;
             $submission['challenge_id'] = $flags['challenge_id'];
             //to do yo
             $submission['text'] = $request['flag'];
             Submitted_flag::create($submission);
             return redirect('flags/submit')->with('message', 'Correct!');
         }
         $message = 'You have previously submitted this flag!';
         return redirect('flags/submit')->with('message', $message);
     }
     $filename = "../storage/failed.csv";
     $content = Auth::user()->name . "," . $request['flag'] . "\n\r";
     $bytesWritten = File::append($filename, $content);
     if ($bytesWritten === false) {
         die("Couldn't write to the file.");
     }
     return redirect('flags/submit')->with('message', 'Incorrect, sorry try again!');
 }
Exemplo n.º 2
0
 public function store(SubmitFlagRequest $request)
 {
     $request = $request->all();
     $flags = Flag::where('flag', $request['flag'])->first();
     if (!empty($flags)) {
         $previously = Submitted_flag::select('user_id')->where('text', $request['flag'])->where('user_id', Auth::user()->id)->get();
         $previously = $previously->toArray();
         var_dump($previously);
         if (empty($previously)) {
             $flags = $flags->toArray();
             $submission['created_at'] = Carbon::now()->toDateTimeString();
             $submission['updated_at'] = Carbon::now()->toDateTimeString();
             $submission['user_id'] = Auth::user()->id;
             $submission['challenge_id'] = $flags['challenge_id'];
             //to do yo
             $submission['text'] = $request['flag'];
             Submitted_flag::create($submission);
             return redirect('flags/submit')->with('message', 'Correct!');
         }
         $message = 'You have previously submitted this flag!';
         return redirect('flags/submit')->with('message', $message);
     }
     return redirect('flags/submit')->with('message', 'Incorrect, sorry try again!');
 }