public function showImage($album_folder, $image_file) { $album = Album::with('images')->where('folder', $album_folder)->first(); // $image = Image::with('album')->find($image_id); if (!$album) { App::abort(404, 'Album wasn\'t found.'); } $count = $album->images->count(); $success = false; for ($i = 0; $i < $count; $i++) { if ($album->images[$i]->image == $image_file) { $image = $album->images[$i]; // Previous image if ($i == 0) { $image->prev = $album->images[$count - 1]; } else { $image->prev = $album->images[$i - 1]; } // Next image if ($i == $count - 1) { $image->next = $album->images[0]; } else { $image->next = $album->images[$i + 1]; } $success = true; } } if (!$success) { App::abort(404, 'Image wasn\'t found.'); } return View::make('image', compact('image')); }
/** * work end * **/ public function scopeWorkEnd($query, $variable) { if (!is_array($variable)) { \App::abort(404); } return $query->where('hres_works.end', '>=', $variable[0])->where('hres_works.end', '<=', $variable[1]); }
/** * Method to display the view. * * @param string The template file to include * @since 1.5 */ function display($tpl = null) { // This name will be used to get the model $name = $this->getLayout(); // Check that the name is valid - has an associated model. if (!in_array($name, array('confirm', 'complete'))) { $name = 'default'; } if ('default' == $name) { $formname = 'Form'; } else { $formname = ucfirst($this->_name) . ucfirst($name) . 'Form'; } // Get the view data. $this->form = $this->get($formname); $this->state = $this->get('State'); $this->params = $this->state->params; // Check for errors. if (count($errors = $this->get('Errors'))) { App::abort(500, implode('<br />', $errors)); return false; } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->prepareDocument(); $password_rules = \Hubzero\Password\Rule::getRules(); $this->password_rules = array(); foreach ($password_rules as $rule) { if (!empty($rule['description'])) { $this->password_rules[] = $rule['description']; } } parent::display($tpl); }
/** * Parse the URL parameters and map each parameter (in order) to the given array of names * * @param array varNames: Array of names to map the URL parameters to * @return object: Object with properties named after var names mapped to URL parameters */ protected function getParams($varNames) { $i = 0; // Strict processing doesn't allow extra or missing parameters in the URL $strictProcessing = false; $params = false; // check if there are more parameters than needed $extraParameter = Request::getVar('p' . count($varNames), ''); if ($strictProcessing && !empty($extraParameter)) { // too many parameters in the URL //throw new \Exception('Too many parameters'); App::abort(404, Lang::txt('Page Not Found')); } // Go through each var name and assign a sequential URL parameter's value to it foreach ($varNames as $varName) { $value = Request::getVar('p' . $i, ''); if (!empty($value)) { $params->{$varName} = $value; } else { if ($strictProcessing) { // missing parameter in the URL //throw new \Exception('Too few parameters'); App::abort(404, Lang::txt('Page Not Found')); } break; } $i++; } return $params; }
/** * Calculate the link meta-data for paging purposes, return an array with paging information * * @param integer $limit * @param integer $offset * @param integer $total_rows The total amount of objects * * @return array */ public static function calculatePagingHeaders($limit, $offset, $total_rows) { $paging = array(); // Check if limit and offset are integers if (!is_integer((int) $limit) || !is_integer((int) $offset)) { \App::abort(400, "Please make sure limit and offset are integers."); } // Calculate the paging parameters and pass them with the data object if ($offset + $limit < $total_rows) { $paging['next'] = array($limit + $offset, $limit); $last_page = round($total_rows / $limit, 1); $last_full_page = round($total_rows / $limit, 0); if ($last_page - $last_full_page > 0) { $paging['last'] = array($last_full_page * $limit, $limit); } else { $paging['last'] = array(($last_full_page - 1) * $limit, $limit); } } if ($offset > 0 && $total_rows > 0) { $previous = $offset - $limit; if ($previous < 0) { $previous = 0; } $paging['previous'] = array($previous, $limit); } return $paging; }
private function onCheckMenuItem($item) { if (isset($item['submenu'])) { foreach ($item['submenu'] as $key => $subItem) { $this->onCheckMenuItem($subItem); } } else { // FIXME: $isToCheck = false; if (isset($item['pattern'])) { $menuLink = \Config::get('builder::admin.uri') . $item['pattern']; $menuLink = ltrim($menuLink, '/'); $pattern = '~^' . $menuLink . '$~'; $isToCheck = preg_match($pattern, \Request::path()); } else { $menuLink = \URL::to(\Config::get('builder::admin.uri') . $item['link']); $isToCheck = \Request::URL() == $menuLink; } if ($isToCheck) { $isAllowed = $item['check']; if (!$isAllowed()) { \App::abort(404); } } } }
/** * Store a payment notes * * 1. Check transaction * 2. Check input * 3. Store Payment * 4. Check response * 5. Generate view * @param id * @return object view */ public function store($id = null) { //1. Check transaction if (Input::has('transaction_id')) { $saleid = Input::get('transaction_id'); } else { \App::abort(404); } $APISale = new APISale(); $prev_sale = $APISale->getShow($saleid); if ($prev_sale['status'] != 'success') { $this->errors = $prev_sale['message']; return $this->generateRedirectRoute('shop.pay.create'); } $sale = $prev_sale['data']; //2. Check input $inputPayment = Input::only('method', 'destination', 'account_name', 'account_number'); $inputPayment['id'] = ''; $inputPayment['amount'] = $sale['bills']; $inputPayment['ondate'] = date('Y-m-d H:i:s', strtotime(Input::get('ondate'))); $sale['payment'] = $inputPayment; $sale['status'] = 'paid'; //3. Store Payment $result = $APISale->postData($sale); //4. Check response if ($result['status'] != 'success') { $this->errors = $result['message']; } else { $mail = new APISendMail(); $mail->paidorder($result['data'], $this->balininfo()); } //5. Generate view $this->page_attributes->success = ['title' => 'Pesanan sudah divalidasi. ', 'action' => route('report.product.sale.detail', ['id' => $saleid]), 'actionTitle' => 'Klik disini untuk melihat Invoice barang.']; return $this->generateRedirectRoute('admin.dashboard', ['tab' => 'toko']); }
public function readData($source_definition, $rest_parameters = array()) { $uri = $source_definition['uri']; // Keep track of the prefix URI's $this->prefixes = array(); // Check for caching if (Cache::has($uri)) { $data = Cache::get($uri); } else { // Fetch the data $data = @file_get_contents($uri); if (!empty($data)) { Cache::put($uri, $data, $source_definition['cache']); } else { $uri = $source_definition['uri']; \App::abort(500, "Cannot retrieve data from the XML file located on {$uri}."); } } $data_result = new Data(); $data_result->data = $data; $data_result->semantic = $this->prefixes; $data_result->preferred_formats = $this->getPreferredFormats(); if (!empty($source_definition['geo_formatted']) && $source_definition['geo_formatted']) { $data_result->geo_formatted = true; $data_result->preferred_formats = array('geojson', 'map', 'php'); } return $data_result; }
/** * Bootstrap the application services. * * @return void */ public function boot() { // Publish config $configPath = __DIR__ . '/../../config/config.php'; $this->publishes([$configPath => config_path('liebigCron.php')], 'config'); // Build in Cron run route \Route::get('cron.php', function () { // Get security key from config $cronkeyConfig = \Config::get('liebigCron.cronKey'); // If no security key is set in the config, this route is disabled if (empty($cronkeyConfig)) { \Log::error('Cron route call with no configured security key'); \App::abort(404); } // Get security key from request $cronkeyRequest = \Input::get('key'); // Create validator for security key $validator = \Validator::make(array('cronkey' => $cronkeyRequest), array('cronkey' => 'required|alpha_num')); if ($validator->passes()) { if ($cronkeyConfig === $cronkeyRequest) { \Artisan::call('cron:run', array()); } else { // Configured security key is not equals the sent security key \Log::error('Cron route call with wrong security key'); \App::abort(404); } } else { // Validation not passed \Log::error('Cron route call with missing or no alphanumeric security key'); \App::abort(404); } }); }
public function image() { if (!Auth::check()) { Session::flash('redirect', URL::current()); return Redirect::route('login'); } $relativePath = Input::get('path'); $filePath = Input::get('file'); $path = Path::fromRelative($relativePath); if (!$path->exists()) { App::abort(404, 'Archive not found'); } $archive = Archive\Factory::open($path); $imageStream = $archive->getEntryStream($filePath); $imageData = stream_get_contents($imageStream); $response = Response::make($imageData); $ext = pathinfo($filePath, PATHINFO_EXTENSION); switch ($ext) { case 'jpg': case 'jpeg': $response->header('Content-Type', 'image/jpeg'); break; case 'png': $response->header('Content-Type', 'image/png'); break; } $response->header('Last-Modified', gmdate('D, d M Y H:i:s', $path->getMTime()) . ' GMT'); $response->header('Expires', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT'); $response->header('Cache-Control', 'public'); return $response; }
public function postEditRoles() { /* code is a bit messy, lots of repetition, try to refactor later */ $user = User::find(Input::get('id')); if (!$user) { App::abort(404); } if (Input::has('emp_admin') && $user->hasRole('Employee MS Administrator') === false) { $user->roles()->attach(2); } else { if ($user->hasRole('Employee MS Administrator')) { $user->roles()->detach(2); } } if (Input::has('prop_admin') && $user->hasRole('Property MS Administrator') === false) { $user->roles()->attach(3); } else { if ($user->hasRole('Property MS Administrator')) { $user->roles()->detach(3); } } if (Input::has('perf_admin') && $user->hasRole('Performance MS Administrator') === false) { $user->roles()->attach(4); } else { if ($user->hasRole('Performance MS Administrator')) { $user->roles()->detach(4); } } return Redirect::route('profile', $user->id)->with('alert', 'success|This user\'s roles have been updated successfully.'); }
public function show($id) { // init $event = Events::with(array('city', 'eventcategory', 'user'))->where('id', '=', $id)->orderBy('id', 'desc')->first(); $data = array('menu' => $this->_menu, 'title' => 'Event - ' . $event->name, 'description' => '', 'breadcrumb' => array('Event' => route('admin.event'), $event->name => route('admin.event.show', $event->id))); if ($event == null) { return App::abort('404'); } $data['event'] = $event; $social_action = SocialActionEvent::with(array('user', 'socialAction'))->where('event_id', '=', $event['id'])->orderBy('id', 'desc')->get(); // Get category // $data['social_actions'] = $social_action; $sos = array(); if (count($social_action) > 0) { foreach ($social_action as $val) { # code... $sos[] = $val['social_action']; } $data['social_actions'] = $sos; // Get Photos that related with this $data['photos'] = Photo::where('type_name', '=', 'social_actions')->where('type_id', '=', $social_action[0]->id)->orderBy('id', 'desc')->get(); } else { $data['social_actions'] = array(); $data['photos'] = array(); } return View::make('admin.pages.event.show')->with($data); }
/** * Display the password reset view for the given token. * * @param string $token * @return Response */ public function getReset($token = null) { if (is_null($token)) { App::abort(404); } return View::make('sysconfig.account.account_password_reset')->with('token', $token); }
public function getMod($slug) { $table_javascript = route('tdf_name', ['modmodpacks', '0', $slug]); $mod = Mod::where('slug', '=', $slug)->first(); if (!$mod) { $redirect = new URLRedirect(); $do_redirect = $redirect->getRedirect(Request::path()); if ($do_redirect) { return Redirect::to($do_redirect->target, 301); } App::abort(404); } $can_edit = false; if (Auth::check()) { $maintainer = $mod->maintainers()->where('user_id', Auth::id())->first(); if ($maintainer) { $can_edit = true; } } $authors = $mod->authors; $spotlights = $mod->youtubeVideos()->where('category_id', 2)->get(); $tutorials = $mod->youtubeVideos()->where('category_id', 3)->get(); $raw_links = ['website' => $mod->website, 'download_link' => $mod->download_link, 'donate_link' => $mod->donate_link, 'wiki_link' => $mod->wiki_link]; $links = []; foreach ($raw_links as $index => $link) { if ($link != '') { $links["{$index}"] = $link; } } $markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($mod->description)); $mod_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html); $title = $mod->name . ' - Mod - ' . $this->site_name; $meta_description = $mod->deck; return View::make('mods.detail', ['table_javascript' => $table_javascript, 'mod' => $mod, 'mod_description' => $mod_description, 'links' => $links, 'authors' => $authors, 'title' => $title, 'meta_description' => $meta_description, 'sticky_tabs' => true, 'spotlights' => $spotlights, 'tutorials' => $tutorials, 'can_edit' => $can_edit]); }
public function handleRequest() { // TODO create "page not found" page $uri = Request::path(); // Default version of the documentation $page = 'introduction'; $versions = array("4.0", "4.1", "4.2", "4.3", "4.6", "5.0", "5.6", "5.12"); $version = end($versions); // If not the root, then split the uri to find the content $segment1 = Request::segment(1); $segment2 = Request::segment(2); if (!empty($segment1)) { $version = $segment1; if (!empty($segment2)) { $page = $segment2; } } // Show the correct markdown contents $page = __DIR__ . '/docs/' . $version . '/' . $page . '.md'; if (file_exists($page)) { $contents = file_get_contents($page); $sidebar = file_get_contents(__DIR__ . '/docs/' . $version . '/sidebar.md'); // Transform documents $contents_html = Markdown::defaultTransform($contents); $sidebar_html = Markdown::defaultTransform($sidebar); // Replace url variable $sidebar_html = preg_replace('/{url}/mi', URL::to($version), $sidebar_html); return View::make('layouts.master')->with('version', $version)->with('versions', $versions)->with('sidebar', $sidebar_html)->with('content', $contents_html); } else { \App::abort(400, "The page you were looking for could not be found."); } }
/** * Display the password reset view for the given token. * * @param string $token * @return Response */ public function getReset($token = null) { if (is_null($token)) { App::abort(404); } return View::make('admin.login.resetpass')->with('token', $token); }
/** * Display the password reset view for the given token. * * @param string $token * @return Response */ public function getReset($token = null) { if (is_null($token)) { \App::abort(404); } return view('system.auth.passwordreset')->with('token', $token); }
/** * function to cancel order * * @return redirect url */ public function destroy($id = null) { //1. ambil data order detail dari API $APIUser = new APIUser(); $me_order_detail = $APIUser->getMeOrderDetail(['user_id' => Session::get('whoami')['id'], 'order_id' => $id]); if ($me_order_detail['status'] != 'success') { \App::abort(404); } //2. Set status cancel $me_order_detail['data']['status'] = 'canceled'; //3. Store order $order = $APIUser->postMeOrder($me_order_detail['data']); //4. Check order if ($order['status'] != 'success') { $this->errors = $order['message']; } else { $infos = []; foreach ($this->balin['info'] as $key => $value) { $infos[$value['type']] = $value['value']; } $mail = new APISendMail(); $result = $mail->cancelorder($order['data'], $infos); if (isset($result['message'])) { $this->errors = $result['message']; } } //5. Generate view $this->page_attributes->success = "Pesanan Anda sudah dibatalkan."; return $this->generateRedirectRoute('my.balin.profile'); }
/** * * @param string $api * @param int $version * @return APIInterface; */ public static function getInstance($api, $version = 'current') { if ($version == 'current') { $apiConfig = \Config::get('restfulapi::api'); //Check if API resource exists if (isset($apiConfig[$api])) { $version = $apiConfig[$api]['currentVersion']; } else { //Need to throw 404 error \App::abort(404); } $version = $apiConfig[$api]['currentVersion']; } else { $apiConfig = \Config::get('restfulapi::api'); $arr1 = str_split($version); //Check if API resource exists if (isset($apiConfig[$api])) { $arr2 = str_split($apiConfig[$api]['currentVersion']); } else { //Need to throw 404 error \App::abort(404); } if ((int) $arr1[1] > (int) $arr2[1]) { $version = $apiConfig[$api]['currentVersion']; } } $apiClass = self::NS . $api . "\\" . $version . "\\" . $api . 'API'; if (class_exists($apiClass)) { return new $apiClass(); } else { //Need to throw 404 error \App::abort(404); } }
protected function extractColumns($input) { $db_config = array('driver' => 'mysql', 'host' => $input['host'], 'database' => $input['database'], 'username' => $input['username'], 'password' => $input['password'], 'charset' => 'utf8', 'collation' => $input['collation']); // Configure a connection \Config::set('database.connections.testconnection', $db_config); // Make a database connection $db = \DB::connection('testconnection'); // Get the schema builder of the database connection $schema = $db->getSchemaBuilder(); $connection = $schema->getConnection(); $result = $connection->selectOne($input['query']); if (empty($result)) { \App::abort(400, 'The query did not return any results.'); } $db_columns = array_keys((array) $result); $columns_info = @$config['columns']; $pk = @$config['pk']; // Prepare the aliases $aliases = array(); if (!empty($columns_info)) { foreach ($columns_info as $column_info) { $aliases[$column_info['index']] = $column_info['column_name_alias']; } } // Create the columns array $columns = array(); foreach ($db_columns as $index => $column) { array_push($columns, array('index' => $index, 'column_name' => $column, 'column_name_alias' => empty($aliases[$index]) ? $column : $aliases[$index], 'pk' => $pk === $index)); } return $columns; }
public function create($type = 'csv') { try { $export = static::getExportForType($type); } catch (Exception $e) { App::abort(404); } $export->user_id = Auth::user()->id; $export->filename = $export->generateFilename(); $export->path = $export->folderPath(); $export->setLogbooks(Input::get('logbooks')); $save = Input::has('save') ? (bool) Input::get('save') : true; if ($export->run($save)) { if ($save == false) { $res = Response::make($export->content); $res->header('Content-type', $export->getContentType()); return $res; } else { $export->save(); return Response::download($export->fullPath(), $export->filename, ['Content-type' => $export->getContentType()]); } } else { return Redirect::to(action('ExportsController@index'))->with('message', ['content' => 'Er is iets mis gegaan met exporteren.', 'class' => 'danger']); } }
/** * display the form for password reset * * @param string $token * @return View */ public function password_reset($token = null) { if (is_null($token)) { App::abort(404); } return View::make('station::user.password_reset')->with('token', $token); }
/** * Show article * @param string $slug Article abbreviated name * @return response */ public function show($slug) { $article = Article::where('slug', $slug)->where('post_status', 'open')->first(); is_null($article) and App::abort(404); $categories = Category::orderBy('sort_order')->get(); return View::make('article.show')->with(compact('article', 'categories')); }
public function page($page = FALSE) { if ($locale = Cookie::get('locale')) { App::setLocale($locale); } if (!$page) { return Redirect::to(Lang::get('navigation.consumer'), 301); } $nav = array(); foreach (['consumer', 'exporter'] as $item) { $loc = Lang::get('navigation.' . $item); $link = strtolower(str_replace(' ', '-', $loc)); if ($link == $page) { $page = $item; } $nav[$link] = ucfirst($loc); } if (!View::exists('layouts.public.' . $page)) { App::abort(404); } $sub_nav = array(); $view = View::make('layouts.public.' . $page); switch ($page) { case 'exporter': $sub_nav = ['assortment', 'horticulture', 'certification', 'contact']; $picturebox = new Picturebox\PictureboxManager(); $view->with('picturebox', $picturebox); break; } $view->with('sub_nav', $sub_nav); return $view->with('nav', $nav); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($idOrTitle) { if (is_numeric($idOrTitle)) { $note = Note::find($idOrTitle); } else { $note = Note::where('slug', '=', $idOrTitle)->first(); } if (!$note) { App::abort(404); } if ($note->public_or_private == "private") { if (Auth::user()->id != $note->user_id) { Session::flash('errorMessage', 'This note is private and cannot be accessed publicly.'); return Redirect::action('NotesController@index'); } } $comments = []; $allcomments = Notecom::all(); foreach ($allcomments as $comment) { if ($comment->note_id == $note->id) { $commentdata = array('created_at' => $comment->created_at, 'id' => $comment->id, 'comment' => $comment->comment, 'commenter' => $comment->collaborator_name); array_push($comments, $commentdata); } } return View::make('notes.show')->with(['note' => $note, 'hasVoted' => $note->userHasVoted()])->with('comments', $comments); }
public function __construct(GalleryRepository $repo) { if (!m('Gallery')->enabled()) { return \App::abort('404'); } $this->repo = $repo; }
public function login_post() { if (!Request::ajax()) { App::abort('401'); } $data = array('status' => 'success', 'message' => ''); try { // Set login credentials $credentials = array('email' => Input::get('email'), 'password' => Input::get('password')); $remember = Input::get('remember') ? Input::get('remember') : false; // Try to authenticate the user $user = Sentry::authenticate($credentials, $remember); $data['status'] = 'success'; $data['message'] = 'Login Success. Redirecting'; } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { $data['status'] = 'error'; $data['message'] = 'Login field is required.'; } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { $data['status'] = 'error'; $data['message'] = 'Password field is required.'; } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) { $data['status'] = 'error'; $data['message'] = 'Wrong password, try again.'; } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { $data['status'] = 'error'; $data['message'] = 'User was not found.'; } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) { $data['status'] = 'error'; $data['message'] = 'User is not activated.'; } $response = Response::make(json_encode($data), 200); $response->header('Content-Type', 'text/json'); return $response; }
/** * Display the password reset view for the given token. * * @param string $token * @return Response */ public function getReset($token = null) { if (is_null($token)) { App::abort(404); } $this->layout->content = View::make('admin.reset')->with('token', $token); }
public function getReset($token = null) { if (is_null($token)) { App::abort(404); } return View::make('password.reset')->with('token', $token); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); // DATABIDING, permet d'utiliser les objets à tous moment grâce au DATABIDING ex : user $router->model('users', 'App\\Users', function () { App::abort(500); }); $router->model('roles_users', 'App\\Roles_users', function () { App::abort(500); }); $router->model('langues', 'App\\Langues', function () { App::abort(500); }); $router->model('pays', 'App\\Pays', function () { App::abort(500); }); $router->model('ville', 'App\\Villes', function () { App::abort(500); }); $router->model('actu', 'App\\Actu', function () { App::abort(500); }); $router->model('notification', 'App\\NotificationHistory', function () { App::abort(500); }); }