if (empty($downloads[$request])) { return Xysti::error(404, 'Download ' . $request . ' is not in config'); } $download = $downloads[$request]; // Run authentication etc on the download $before = Xysti::before($download); if (!is_null($before)) { return $before; } $path = Config::get('xysti.resources.downloads') . $download['uri']; if (!file_exists($path)) { return Xysti::error(404, 'Download ' . $request . ' could not be found at ' . $path); } return Response::make(File::get($path), 200, array('Content-Type' => File::mime(File::extension($path)))); }); } } // Catch all routes // ------------------------------------------------ /** * Handle remaining GET requests */ Route::get('(.*)', function () { return Xysti::make(); }); /** * Handle remaining POST requests */ Route::post('(.*)', function () { return Xysti::error(500, 'No post route.'); });
/** * Perform input validation * * Checks wether a page variable is set in the sitemap and returns it * @return string */ public static function validate() { $rules = Xysti::page('post_rules'); if (is_array($rules)) { $validation = Validator::make(Input::all(), $rules); } else { return Xysti::error(500, 'Expecting post rules array.'); } // If validation has failed if ($validation->fails()) { Session::flash('warning', 'Could not submit. Validation errors were found.'); // @todo remove Former dependance Former::withErrors($validation); // Make the page without any more routes return Xysti::make(); // @todo some mechanism to redirect on failure if that's prefered. //return Redirect::to(URI::current())->with_errors($validation); } }