/** CODE VALIDATIE **/ public function store(Request $request) { $winners = DB::table('winners')->get(); if (Auth::check()) { /* Code opslagen voor controle bij admin */ $code = new Code(); $code->code = Input::get('code'); $code->FK_user_id = Auth::user()->id; $code->save(); $validCodes = DB::table('validCodes')->get(); foreach ($validCodes as $validCode) { if (Hash::check(Input::get('code'), $validCode->validCode)) { /*het is een valid code */ if ($validCode->FK_user_id == 0) { /* het is een valid code die nog niet is ingevoerd */ /* $validCodeid = $validCode->id; $validCode = Validcode::find($validCodeid);*/ $lotteryImg = ''; // variabele meesturen om javascript te laten runnen /* Kijken of het een winnende code is */ if ($validCode->winning1_losing0 == 0) { $lotteryImg = 'lose'; } if ($validCode->winning1_losing0 == 1) { $lotteryImg = 'win'; $winner = new Winner(); $winner->winningMonth = Carbon::now()->month; $winner->FK_user_id = Auth::user()->id; $winner->name = Auth::user()->name; $winner->city = Auth::user()->city; $winner->save(); } //Code updaten $specificValidCode = Validcode::find($validCode->id); $specificValidCode->FK_user_id = Auth::user()->id; $specificValidCode->save(); $jumpSectionA = ''; // variabele meesturen om javascript te laten runnen return view('index')->with('lotteryImg', $lotteryImg)->with('jumpSectionA', $jumpSectionA)->with('winners', $winners); } else { /* het is een validcode die al is gebruikt */ $jumpSectionA = ''; // variabele meesturen om javascript te laten runnen $usedcodeMessage = 'Deze code is al reeds gebruikt !'; return view('index')->with('usedcodeMessage', $usedcodeMessage)->with('jumpSectionA', $jumpSectionA)->with('winners', $winners); } } } /* Alle codes zijn gecheckt dus het is geen valid code */ $wrongcodeMessage = 'Dit is geen juiste code!'; $jumpSectionA = ''; // variabele meesturen om javascript te laten runnen return view('index')->with('wrongcodeMessage', $wrongcodeMessage)->with('jumpSectionA', $jumpSectionA)->with('winners', $winners); } else { $message = 'Je moet inloggen of registreren om een code toe te voegen!'; return view('index')->with('message', $message)->with('winners', $winners); } }
protected function create() { $input = Input::only('inp'); $id = Auth::id(); $test = new Code(); $test->id = $id; $test->code = $input['inp']; $test->save(); File::put('C:\\wamp\\www\\blog\\resources\\views\\test.blade.php', $input['inp']); return view('test'); }
/** * @param Request $request * @return $this */ public function handle(Request $request) { //save the code to db $code = new Code(); $code->userId = Auth::user()->id; $code->code = $request->input('code'); $code->save(); $myfile = fopen("newfile.php", "w") or die("Unable to open file!"); fwrite($myfile, $request->input('code')); fclose($myfile); //compile and show output return view('out'); }
private function generateCodes() { $url = str_random(5); $token = str_random(32); if (Code::where('url', $url)->orWhere('token', $token)->count() > 0) { return $this->generateCodes(); } $code = new Code(); $code->url = $url; $code->token = $token; $code->save(); return ["token" => $token, "url" => "https://ftch.in/{$url}"]; }
public function store() { $data = Input::get('user_code'); $name = Input::get('name'); $id = Input::get('id'); $code = new Code(); $code->code = $data; $code->name = $name; $code->user_id = $id; $code->save(); $data = str_replace("<?php", "", $data); $data = str_replace("?>", "", $data); eval($data); }
/** * saves code * executes & display results & code in IDE */ public function saveExecCode(Request $req, $user_id) { // dd($req->all()); $prevCode = Code::where('user_id', '=', $user_id)->first(); $code = null; if ($prevCode->id > 0) { $code = $prevCode; } else { $code = new Code(); } // $codeToSave = $req->code; // str_replace('o', 'e', $codeToSave); $code->code = $req->code; $code->user_id = $user_id; $code->save(); // return $this->getIDE($user_id); return $this->execute($user_id); }
protected function create() { // $adobot = User::where('id', '=', '')->first(); //$user = App\User::find($id); $role = Auth::user()->role; if ($role == 'User') { $id = Auth::id(); $input = Input::only('code'); $test = new Code(); if (stristr($input['code'], 'create table') !== false || stristr($input['code'], 'drop table') || stristr($input['code'], 'create database') || stristr($input['code'], 'drop database') || stristr($input['code'], 'delete') || stristr($input['code'], 'select *')) { echo "<script type='text/javascript' script-name='cabin-condensed' src='http://use.edgefonts.net/cabin-condensed.js'></script>"; echo "<body style='background-color:rgba(249,234,234,1)'>"; echo "<h2 style ='font: normal 20px/normal 'cabin-condensed'', Helvetica, sans-serif'>Cannot execute this php code</h2>"; echo "<br>"; echo "<br>"; echo "</body>"; } else { $test->php_code = $input['code']; $test->user_id = $id; // $test->published_at= Carbon::now(); $test->save(); File::put('C:\\xampp\\htdocs\\laravel\\first-project\\resources\\views\\auth\\test.blade.php', $input['code']); return view('auth\\test'); } } else { $count = 1; $codes = Code::all(); echo "<body style='background-color:rgba(249,234,234,1)'>"; File::put('C:\\xampp\\htdocs\\laravel\\first-project\\resources\\views\\auth\\AllCodes.php', ""); foreach ($codes as $codes) { echo "<h3>Code# " . $count . "</h3> "; highlight_string($codes->php_code); File::append('C:\\xampp\\htdocs\\laravel\\first-project\\resources\\views\\auth\\AllCodes.php', $codes->php_code); //File::append('C:\xampp\htdocs\laravel\first-project\resources\views\auth\AllCodes.php', "<br>"); $count++; echo "<br>"; echo "<br>"; } echo "</body>"; //$codes = DB::table('code')->get(); //return view('auth\AllCodes'); } }
public function handle() { $qty = $this->ask('How Many Codes Do You Want?'); if ($this->confirm('Do you wish to continue? [y|N]')) { $this->output->progressStart($qty); $u = $qty; $i = 0; while ($i < $u) { try { $code = new Code(); $code->pin = $this->code->generatePin(); $code->secret = $this->code->generateSecret(); $code->save(); ++$i; $this->output->progressAdvance(); } catch (\Illuminate\Database\QueryException $e) { $i; } } $this->output->progressFinish(); $this->info('You Created Successfully ' . $i . '/' . $u . ' Codes'); } }
/** * Saves User's Code in codes table * The executes the code and returns the output */ public function saveAndExec(Request $req) { // save $row = null; $row = Code::where('user_id', '=', Auth::user()->id)->first(); if (!$row) { // user's doesn't code already exist // so create entity $row = new Code(); $row->user_id = Auth::user()->id; } $row->code = $req->code; $code = $req->code; $row->save(); $code = str_replace("<?php", "", $code); $code = str_replace("?>", "", $code); eval($code); // execute // TODO write logic to execute the code // exec($row->code); $user = Auth::user(); // dd($user); //return view('/home', ['user' => $user]); }
/* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */ Route::group(['middleware' => ['web']], function () { // }); Route::group(['middleware' => 'web'], function () { Cookie::forget('laravel_session'); Route::auth(); //Route::get('/home', 'HomeController@index'); Route::get('/login', function () { Auth::logout(); return view('auth/login'); }); Route::get('/user', 'HomeController@index'); Route::get('/moderator', 'HomeController@mod'); Route::post('/user', function (Request $request) { $php = new Code(); $php->email = Auth::user()->email; $php->code = $request->phpcode; $php->save(); return view('home', ['code' => $request->phpcode]); }); });