* @param string $source */ public function setSource($source) { $this->sourceFile = $source; } /** * Set destination file to be written * @param bool $destination */ public function setDestination($destination) { $this->destinationFile = $destination; } } $flatten = new Flatten(); if (php_sapi_name() == 'cli') { //Client detected! if ($argc > 1) { if ($argc < 2 || $argc > 3) { exit("Missing or too many arguments.\n Please use as follows test.php path/to/source.json /path/to/destination.json \n"); } $flatten->sourceFile = $argv[1]; $flatten->destinationFile = $argv[2]; } } else { if (isset($_POST['sourceContent'])) { //Post detected! if (!isset($_POST['sourceContent']) || strlen($_POST['sourceContent']) < 1) { exit('Please specify the JSON content to flatten!'); }
/** * Execute the console command. * * @return mixed */ public function fire() { Flatten::flushAll(); }
| cross-site request forgery attacks. If this special token in a user | session does not match the one given in this request, we'll bail. | */ Route::filter('csrf', function () { if (Session::token() != Input::get('_token')) { throw new Illuminate\Session\TokenMismatchException(); } }); Route::filter('flatten.flight', function ($route, $request, $response) { $flight = $route->getParameter('flight'); if ($flight->state == 2 && $flight->processed && $flight->pilot->processing == 1) { Flatten::end($response); } }); Route::filter('flatten.atc', function ($route, $request, $response) { $atc = $route->getParameter('atc'); if (!is_null($atc->end) && $atc->processed && $atc->pilot->processing == 1) { Flatten::end($response); } }); Route::filter('admin', function () { if (!Auth::user()->isAdmin()) { $timeline = new Timeline(); $timeline->type = 'unauthorised-access'; $timeline->user_id = Auth::id(); $timeline->activity = array('name' => Auth::user()->name); $timeline->save(); return App::abort(404); } });