/** * Detect the active module and setup our * environment with it. */ public function handle() { /** * In order to detect we MUST have a route * and we MUST have a namespace in the * streams::addon action parameter. * * @var Route $route */ $route = $this->request->route(); /* @var Module $module */ if ($route && ($module = $this->modules->get(array_get($route->getAction(), 'streams::addon')))) { $module->setActive(true); } if (!$module && $this->request->segment(1) == 'admin' && ($module = $this->modules->findBySlug($this->request->segment(2)))) { $module->setActive(true); } if (!$module) { return; } $this->container->make('view')->addNamespace('module', $module->getPath('resources/views')); $this->container->make('translator')->addNamespace('module', $module->getPath('resources/lang')); $this->asset->addPath('module', $module->getPath('resources')); $this->image->addPath('module', $module->getPath('resources')); }
/** * Map the redirect routes. * * @param UrlGenerator $url * @param Router $router * @param Request $request * @param RedirectRepositoryInterface $redirects * @internal param Filesystem $files * @internal param Application $application */ public function map(UrlGenerator $url, Router $router, Request $request, RedirectRepositoryInterface $redirects) { if ($request->segment(1) == 'admin') { return; } /* @var RedirectInterface $redirect */ foreach ($redirects->sorted() as $redirect) { if (!starts_with($parsed = $redirect->getFrom(), ['http://', 'https://', '//'])) { $parsed = $url->to($redirect->getFrom()); } $parsed = parse_url(preg_replace_callback("/\\{[a-z]+\\?\\}/", function ($matches) { return str_replace('?', '!', $matches[0]); }, $parsed)); if (isset($parsed['host']) && $parsed['host'] == $request->getHost()) { /** * Route a domain redirect in a domain group. */ $router->group(['domain' => $parsed['host']], function () use($parsed, $router, $redirect) { $path = ltrim(preg_replace_callback("/\\{[a-z]+\\!\\}/", function ($matches) { return str_replace('!', '?', $matches[0]); }, $parsed['path']), '/'); $router->any($path ?: '/', ['uses' => 'Anomaly\\RedirectsModule\\Http\\Controller\\RedirectsController@handle', 'redirect' => $redirect->getId()])->where(['any' => '(.*)', 'path' => '(.*)']); }); } else { /** * Route a standard redirect. */ $router->any($redirect->getFrom(), ['uses' => 'Anomaly\\RedirectsModule\\Http\\Controller\\RedirectsController@handle', 'redirect' => $redirect->getId()])->where(['any' => '(.*)', 'path' => '(.*)']); } } }
/** * Determine if the request has a URI that should pass through CSRF verification. * * @param \Illuminate\Http\Request $request * @return bool */ protected function shouldPassThrough($request) { if ($request->segment(1) == trim(config('trungtnm.backend.uri'), '/') && $request->isXmlHttpRequest() && Sentinel::check()) { return true; } return false; }
/** * Get the input view. * * @return string */ public function getInputView() { if ($this->request->segment(1) == 'admin') { return 'anomaly.field_type.decimal::admin/input'; } return 'anomaly.field_type.decimal::input'; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // $this->makeIlogicalCan(); switch ($request->method()) { case 'GET': if ($request->segment(3) == 'create') { $this->makeAuthentization('create', 'posts'); // dd($request->segment(3)); } elseif ($request->segment(4) == 'edit') { $id = $request->segment(3); $this->makeAuthentization('edit', 'posts', (int) $id); } break; case 'POST': $this->makeAuthentization('create', 'posts'); break; case 'PUT': $id = $request->segment(3); $this->makeAuthentization('edit', 'posts', (int) $id); break; case 'DELETE': $id = $request->segment(3); $this->makeAuthentization('delete', 'posts', (int) $id); break; } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { $modelIndex = Application::context(Application::CXT_API) ? 3 : 2; $idIndex = Application::context(Application::CXT_API) ? $modelIndex + 1 : $modelIndex + 2; // Check for the model slug. Throw 404 if not found. $modelSegment = $request->segment($modelIndex); $idSegment = $request->segment($idIndex); $blueprint = ModelBlueprint::slug($modelSegment); if (!$blueprint) { $message = "Class for '{$modelSegment}' does not exist"; return Application::context(Application::CXT_API) ? RESTResponse::failed($message, 404) : response($message, 404); } $class = $blueprint->getClass(); // Check if the model ID was given. if ($idSegment) { $model = $class::find($idSegment); if (!$model) { $message = "Model '{$modelSegment}/{$idSegment}' does not exist"; return Application::context(Application::CXT_API) ? RESTResponse::failed($message, 404) : response($message, 404); } $request->Model = $model; return $next($request); } // Otherwise, return the static model class. $request->Model = new $class(); return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { return redirect($request->segment(1) . '/' . $request->segment(2)); } return $next($request); }
/** * Try to get a locale by it's request slug * * @return bool */ protected function tryUrl() { if ($slug = $this->request->segment(1, false)) { return $this->isValidLanguage($slug); } return false; }
/** * Resolve locale * * @return mixed */ public function resolve() { if ($locale = $this->request->segment(config('localizer.request.segment', 1))) { return $locale; } return $this->resolveHeader(); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { // we expect a url in the form /groups/{group_id} if ($request->segment(1) == 'groups') { if ($this->auth->guest()) { $group = \App\Group::findOrFail($request->segment(2)); if ($group->isPublic()) { return $next($request); } else { return redirect()->back()->with('message', trans('messages.not_allowed')); } } else { $group = \App\Group::findOrFail($request->segment(2)); if ($group->isPublic()) { return $next($request); } elseif ($group->isMember()) { return $next($request); } elseif ($request->user()->isAdmin()) { return $next($request); // user is admin, and sees everything, fine (at least in sync with current policies for admins) } else { return redirect()->back()->with('message', trans('messages.not_allowed')); } } } else { return redirect()->back()->with('message', 'Are you in a group at all !? (url doesnt start with group/something). This is a bug'); } }
/** * Get locale for uri. * * @return string */ public function getUriLocale() { $segment = $this->request->segment(1); if ($this->isValidLocale($segment)) { return $segment; } return $this->getDefaultLocale(); }
/** * Show the application dashboard to the user. * * @return Response */ public function index(Request $request) { if (CNF_FRONT == 'false' && $request->segment(1) == '') { return Redirect::to('dashboard'); } $page = $request->segment(1); if ($page != '') { $content = \DB::table('tb_pages')->where('alias', '=', $page)->where('status', '=', 'enable')->get(); //print_r($content); //return ''; if (count($content) >= 1) { $row = $content[0]; $this->data['pageTitle'] = $row->title; $this->data['pageNote'] = $row->note; $this->data['pageMetakey'] = $row->metakey != '' ? $row->metakey : CNF_METAKEY; $this->data['pageMetadesc'] = $row->metadesc != '' ? $row->metadesc : CNF_METADESC; $this->data['breadcrumb'] = 'active'; if ($row->access != '') { $access = json_decode($row->access, true); } else { $access = array(); } // If guest not allowed if ($row->allow_guest != 1) { $group_id = \Session::get('gid'); $isValid = isset($access[$group_id]) && $access[$group_id] == 1 ? 1 : 0; if ($isValid == 0) { return Redirect::to('')->with('message', \SiteHelpers::alert('error', Lang::get('core.note_restric'))); } } if ($row->template == 'backend') { $page = 'pages.' . $row->filename; } else { $page = 'layouts.' . CNF_THEME . '.index'; } //print_r($this->data);exit; $filename = base_path() . "/resources/views/pages/" . $row->filename . ".blade.php"; if (file_exists($filename)) { $this->data['pages'] = 'pages.' . $row->filename; // print_r($this->data);exit; return view($page, $this->data); } else { return Redirect::to('')->with('message', \SiteHelpers::alert('error', \Lang::get('core.note_noexists'))); } } else { return Redirect::to('')->with('message', \SiteHelpers::alert('error', \Lang::get('core.note_noexists'))); } } else { $this->data['pageTitle'] = 'Home'; $this->data['pageNote'] = 'Welcome To Our Site'; $this->data['breadcrumb'] = 'inactive'; $this->data['pageMetakey'] = CNF_METAKEY; $this->data['pageMetadesc'] = CNF_METADESC; $this->data['pages'] = 'pages.home'; $page = 'layouts.' . CNF_THEME . '.index'; return view($page, $this->data); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, \Closure $next) { $locale = $this->request->segment(1) ?: App::getLocale(); $item = $this->menuItem->findByUriInLanguage($this->request->segment(2), $locale); if ($this->isOffline($item)) { App::abort(404); } return $next($request); }
/** * Get the current category based on the URL * * @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ protected function getCategory() { $path = $this->request->segment(1); $this->category = Category::findPublicCategory($path); if (!$this->category) { throw new NotFoundHttpException('Category not found.'); } return $this->category; }
public function exportRefereeTwo(Request $request) { $profile = Applications::where('reference_two_id', $request->segment(4))->first(); $ref = References::where('id', '=', $request->segment(4))->first(); $settings = Fields::where('references_id', '=', $request->segment(4))->first(); $pdf = PDF::loadView('pdf.refereetwo', compact('profile', 'ref', 'settings', 'custom')); $name = $profile->first_name . '-' . $profile->surname . '-references-'; $pdfFilename = urlencode(strtolower($name . '-' . date('d-m-Y') . '.pdf')); return $pdf->download($pdfFilename); }
/** * Handle the event. */ public function handle() { if (in_array($this->request->path(), ['admin/logout'])) { return; } if ($this->request->segment(1) !== 'admin') { return; } $this->template->put('cp', $this->controlPanel->build()); }
/** * Build documentation URL. * * @param array $documentation * * @return array */ protected function buildDocumentationUrl(array $documentation) { $current = $this->request->segment(2); foreach ($documentation as $doc) { $code = $doc->getCode(); if ($code !== $current && $this->foundation->is('app::docs*')) { $doc->setURL(strtr($this->urlGenerator->current(), [$current => $code])); } } return $documentation; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest($request->segment(1) . '/' . $request->segment(2) . '/auth/login'); } } return $next($request); }
/** * Handle the command. * * @param Application $app * @param Repository $config * @param Request $request * @param PreferenceRepositoryInterface $preferences */ function handle(Application $app, Repository $config, Request $request, PreferenceRepositoryInterface $preferences) { // Set using admin locale if in admin. if ($request->segment(1) === 'admin' && ($locale = $preferences->get('streams::admin_locale'))) { $app->setLocale($locale->getValue()); $config->set('app.locale', $locale->getValue()); } // Set using public locale if NOT in admin. if (!defined('LOCALE') && $request->segment(1) !== 'admin' && ($locale = $preferences->get('streams::public_locale'))) { $app->setLocale($locale->getValue()); $config->set('app.locale', $locale->getValue()); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $url = $request->segment(1) . "/" . $request->segment(2); if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { //return redirect()->guest('auth/login'); //return redirect()->guest('admin'); if ($url == 'student/dashboard') { return redirect()->guest('student/index'); } else { if ($url == 'teacher/dashboard') { return redirect()->guest('teacher/index'); } else { if ($url == 'admin/dashboard') { return redirect()->guest('student/index'); } else { return redirect()->guest('student/index'); } } } } } $segment = $request->segment(1); $type = $request->user()['type']; if ($segment == 'admin') { if ($type == 'ADMIN') { return $next($request); } else { return redirect()->guest('admin/login'); } } else { if ($segment == 'student') { if ($type == 'STUDENT') { return $next($request); } else { return redirect()->guest('admin/login'); } } else { if ($segment == 'teacher') { if ($type == 'TEACHER') { return $next($request); } else { return redirect()->guest('admin/login'); } } } } }
public function store($object, Request $request) { $comment = new Comment($request->all()); $comment->user_id = Auth::user()->id; $object->comments()->save($comment); // Save on the correct model if ($request->segment(1) === 'answers') { $redirectId = $object->question->id; } else { if ($request->segment(1) === 'questions') { $redirectId = $object->id; } } return redirect(url('questions', $redirectId)); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (\Auth::user()->connections()->where('connection_id', '=', $request->segment(3))->count() == 0) { return $next($request); } return redirect()->back()->withErrors(['Already Connected', 'You can not connect with this person cause the connection already exists.']); }
public function index(Request $request) { session()->flash('backUrl', request()->fullUrl()); $trash = $request->segment(3) == 'trash' ? true : false; $query = Banner::sort(); $trash ? $query->onlyTrashed() : ''; $search = []; $search['status'] = $request->input('status', ''); $search['star'] = $request->input('star', ''); $search['name'] = $request->input('name', ''); $search['place'] = $request->input('place', ''); $search['status'] ? $query->where('status', $search['status']) : ''; $search['star'] ? $query->where('star', $search['star']) : ''; $search['name'] ? $query->where('name', 'LIKE', '%' . $search['name'] . '%') : ''; $search['place'] ? $query->where('place', $search['place']) : ''; $banners = $query->paginate(50); $vPlaces = []; $places = config('mbanners.places'); foreach ($places as $slug => $place) { $vPlaces[$slug] = $place['name']; } $view['trash'] = $trash; $view['search'] = $search; $view['vPlaces'] = $vPlaces; $view['places'] = $places; $view['banners'] = $banners; return view('mixdinternet/banners::admin.index', $view); }
/** * Set and return current locale * * @param string $locale Locale to set the App to (optional) * * @return string Returns locale (if route has any) or null (if route does not have a locale) */ public function setLocale($locale = null) { if (empty($locale) || !is_string($locale)) { // If the locale has not been passed through the function // it tries to get it from the first segment of the url $locale = $this->request->segment(1); } if (!empty($this->supportedLocales[$locale])) { $this->currentLocale = $locale; } else { // if the first segment/locale passed is not valid // the system would ask which locale have to take // it could be taken by the browser // depending on your configuration $locale = null; $this->currentLocale = $this->getCurrentLocale(); } // Set application locale app()->setLocale($this->currentLocale); // Regional locale such as de_DE, so formatLocalized works in Carbon if ($regional = $this->getCurrentLocaleRegional()) { setlocale(LC_TIME, $regional . '.utf8'); } return $locale; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param $model * * @return mixed */ public function handle($request, Closure $next, $model) { // gather info $model = '\\AbuseIO\\Models\\' . $model; $account = Auth::user()->account; // try to retrieve the id of the model (by getting it out the request segment or out the input) $model_id = $request->segment(self::IDSEGMENT); if (empty($model_id)) { $model_id = $request->input('id'); } // sanity checks on the model_id if (!empty($model_id) and preg_match('/\\d+/', $model_id)) { // only check if the checkAccountAccess exists if (method_exists($model, 'checkAccountAccess')) { if (!$model::checkAccountAccess($model_id, $account)) { // if the checkAccountAccess() fails return to the last page return back()->with('message', 'Account [' . $account->name . '] is not allowed to access this object'); } } else { Log::notice("CheckAccount Middleware is called for {$model}, which doesn't have a checkAccountAccess method"); } } else { Log::notice("CheckAccount Middleware is called, with model_id [{$model_id}] for {$model}, which doesn't match the model_id format"); } return $next($request); }
/** * @param AuthenticateUser $authenticateUser * @param Request $request */ public function __construct(AuthenticateUser $authenticateUser, Request $request) { $this->middleware('guest', ['except' => 'getLogout', 'getActivate']); $this->auth = $authenticateUser; $this->request = $request; $this->backend = eq($request->segment(1), 'backend') ? true : false; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!systemAccess(9)) { return redirect()->guest($request->segment(1) . '/admin/'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Article::whereSlug($request->segment(3))->get()->isEmpty()) { return response()->json(['error' => 'Article not found!'], 404); } return $next($request); }
/** * Return the output path. * * @param $collection * @return string */ public function outputPath($collection) { /** * If the path is already public * then just use it as it is. */ if (str_contains($collection, public_path())) { return str_replace(public_path(), '', $collection); } /** * Get the real path relative to our installation. */ $path = str_replace(base_path(), '', $this->realPath($collection)); /** * Build out path parts. */ $directory = ltrim(dirname($path), '/\\') . '/'; $application = $this->application->getReference(); $filename = basename($path, $this->extension($path)) . $this->hint($path); if (starts_with($directory, 'vendor/')) { $directory = substr($directory, 7); } if (starts_with($directory, './')) { $directory = in_array($this->request->segment(1), ['admin', 'installer']) ? 'admin/' : 'public/'; } return "/app/{$application}/assets/{$directory}{$filename}"; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (User::where('id', '=', $request->segment(3))->get()->isEmpty()) { return response()->json(['error' => 'User not found!'], 404); } return $next($request); }