public function validateSignedURL($actual_url, $signed_url, $substitions)
 {
     $current_route = Request::route();
     $current_route_name = $current_route->getName();
     if (isset($substitions[$current_route_name])) {
         $substition = $substitions[$current_route_name];
         // make sure the host of the signed URL matches the host of the substitution URL
         if (isset($substition['host'])) {
             $signed_host = $this->getHostFromURL($signed_url);
             $allowed_host = $substition['host'];
             if ($signed_host != $allowed_host) {
                 Log::debug("HOST MISMATCH: \$signed_host={$signed_host} \$allowed_host={$allowed_host}");
                 // no host match - return false
                 return false;
             }
         }
         // check the route
         $substitute_route = new Route($current_route->getMethods(), $substition['route'], []);
         $signed_request = \Illuminate\Http\Request::create($signed_url, Request::method());
         if ($substitute_route->matches($signed_request)) {
             // the allowed substitute route matches the signed request
             return true;
         }
         Log::debug("ROUTE MISMATCH: pathinfo=" . json_encode(Request::getFacadeRoot()->getPathInfo()) . " allowed route={$substition['route']}");
     }
     // this signed URL was not valid
     return false;
 }
Exemple #2
0
 function show()
 {
     //        dd(Page::all()->toArray());
     $page = Page::orWhere(function ($query) {
         $query->where('url', '=', Request::path());
     })->orWhere(function ($query) {
         $query->where('url', '=', '/' . Request::path());
     })->orWhere(function ($query) {
         $query->where('url', '=', Request::url());
     })->orWhere(function ($query) {
         $query->where('url', '=', Request::route()->getPath());
     })->orWhere(function ($query) {
         $query->where('url', '=', '/' . Request::route()->getPath());
     })->get()->first();
     $ps = Post::where('page_id', '=', $page->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get();
     $posts = [];
     foreach ($page->template()->first()->sections() as $sec) {
         $posts[$sec->name] = [];
     }
     foreach ($ps as $p) {
         $posts[$p->section()->first()->name][] = $p;
     }
     $pages = [];
     foreach (Page::all() as $pi) {
         $pages[$pi->name] = $pi;
     }
     $fn = str_replace('.blade.php', '', $page->template()->first()->filename);
     return View::make("aui/templates/" . $fn)->with('posts', $posts)->with('pages', $pages)->with('page', $page);
 }
 function post()
 {
     $att = Attachment::find(Request::route('id3'));
     $pageId = Request::route('id1');
     $att->delete();
     return Redirect::to("/admin/manage-pages/{$pageId}/content");
 }
 function post()
 {
     $pageId = Request::route('id1');
     $sectionId = Request::route('id2');
     $section = Section::find($sectionId);
     $inputs = $this->inputs();
     $post = new Post();
     $post->page_id = $pageId;
     $post->section_id = $sectionId;
     $post->name = $section->name;
     $post->description = $section->description;
     $post->save();
     foreach ($inputs as $input) {
         $item = Item::find($input->id);
         $content = null;
         if (isset($content) === false) {
             $content = new Content();
             $content->item_id = $item->id;
             $content->post_id = $post->id;
             $input->insert($content, Input::get("{$item->id}"));
         }
         //            else {
         //                $input->update($content, Input::get("$item->id"));
         //            }
         $content->save();
     }
     return Redirect::to("/admin/manage-pages/{$pageId}/content");
 }
Exemple #5
0
 /**
  * Bind data to the view.
  *
  * @param View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $locale = app()->getLocale();
     $filename = Request::route()->getName() . '.md';
     $filepath = 'userhelp' . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $filename;
     $help = Storage::exists($filepath) ? Markdown::convertToHtml(Storage::get($filepath)) : '';
     $view->with('help', $help);
 }
Exemple #6
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $wechatId = Request::route('wechatId');
     if (Request::route('wechat')) {
         $wechatId = Request::route('wechat');
     }
     $view->with('wechatId', $wechatId);
 }
 /**
  * Class constructor
  */
 public function __construct()
 {
     // Setting role based access
     $permissions = ['role' => [config('larbac.role')]];
     if (is_object(Request::route())) {
         Request::route()->setParameter('larbac', $permissions);
         $this->middleware('larbac');
     }
 }
 /**
  * Handles exceptions with redirect.
  *
  * @param Exception $exception
  * @return Illuminate\Routing\Redirector
  */
 public function handleException(Exception $exception)
 {
     // Get redirect
     $referer = Request::header('referer');
     $url = empty($referer) ? route('users.signin') : $referer;
     // Add the fragment if defined on the route
     $options = Request::route()->getAction();
     $fragment = array_get($options, 'fragment');
     $url = $fragment ? $url . '#' . $fragment : $url;
     // Send redirect
     return Redirect::to($url)->with('message', $exception->getMessage())->with('code', $exception->getCode())->withErrors($exception->getBag())->withInput();
 }
Exemple #9
0
 public function apply(Builder $builder, Model $model)
 {
     // Determine if there's a route to be had
     if (!$model->getRoute() && Request::route() && Request::route()->getName()) {
         // Set the route for the model
         $model->setRoute(Request::route()->getName());
     }
     // Get the scope on the current route
     $scope = Check::getRole()->scope($model->getRoute());
     // Check if the model has the necessary scope
     if ($scope && Base::getModelMethod('restrict', $scope, $model)) {
         return $model->{Base::getModelMethod('restrict', $scope)}($builder);
     }
     return $builder;
 }
Exemple #10
0
 /**
  * Send output or error.
  *
  * @param $output
  * @param $code
  * @return mixed
  */
 public static function response($output, $code)
 {
     if (Request::isMethod('get') && strpos(Request::route()->getName(), 'index') !== false) {
         return Response::json($output, $code);
     }
     if (empty($output) || collect($output)->isEmpty()) {
         if ($code === 304) {
             return Response::json($output, $code);
         }
         return Response::json(self::error(64), 404);
     }
     if ($output === false or $output === 0) {
         return Response::json(self::error(64), 404);
     }
     return Response::json($output, $code);
 }
 /**
  * @param array $parameters
  * @return string
  */
 public static function link(array $parameters)
 {
     if (count($parameters) === 1) {
         $parameters[1] = ucfirst($parameters[0]);
     }
     $col = $parameters[0];
     $title = $parameters[1];
     $icon = Config::get('columnsortable.sortable_icon');
     foreach (Config::get('columnsortable.columns') as $key => $value) {
         if (in_array($col, $value['rows'])) {
             $icon = $value['class'];
         }
     }
     if (Input::get('sort') == $col && in_array(Input::get('order'), ['asc', 'desc'])) {
         $icon = $icon . '-' . Input::get('order');
     } else {
         $icon = Config::get('columnsortable.sortable_icon');
     }
     $parameters = ['sort' => $col, 'order' => Input::get('order') === 'asc' ? 'desc' : 'asc'];
     $query_string = http_build_query(array_merge(Request::route()->parameters(), $parameters));
     return '<a href="' . url(Request::path() . '?' . $query_string) . '"' . '>' . htmlentities($title) . '</a>' . ' ' . '<i class="' . $icon . '"></i>';
 }
Exemple #12
0
 function show()
 {
     $page = Page::find(Request::route('id1'));
     $views = [];
     $views[] = (new HeadingItem())->label($page->name)->views([(new ButtonItem())->target('_blank')->label("Open Page")->defaultValue($page->url)]);
     foreach ($page->template()->first()->sections()->get() as $sec) {
         $secViews = [];
         $header = "{$sec->name}";
         $secButtons = [];
         $icon = null;
         foreach ($page->posts()->where('section_id', '=', $sec->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get() as $post) {
             $buttons = [];
             $buttons[] = ["label" => 'Edit', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/edit"];
             $buttons[] = ["label" => 'Delete', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/delete"];
             if ($sec->single == 0) {
                 $secViews[] = ViewUtils::box($post->name_formatted, (new PageSummaryPostsForm())->postViews($post->id), null, null, true, $buttons, 'fa-angle-double-right');
             } else {
                 $header = $post->section()->first()->name;
                 //$post->name_formatted." - ".
                 $secViews[] = ViewUtils::plain((new PageSummaryPostsForm())->postViews($post->id));
                 $secButtons[] = ["label" => 'Edit', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/edit"];
                 //                    $secButtons[] = ["label"=>'Delete', "href"=>"/admin/manage-pages/".$page->id."/posts/".$post->id."/delete"];
                 $icon = 'fa-angle-double-right';
             }
         }
         if ($sec->single == 0) {
             $secButtons[] = ["label" => 'Add Post', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/add-post"];
             $secButtons[] = ["label" => 'Sort', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/sort"];
             $icon = 'fa-bars';
         } else {
             if (count($secViews) === 0) {
                 $secButtons[] = ["label" => 'Create', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/add-post"];
             }
         }
         $views[] = ViewUtils::box($header, $secViews, null, null, false, $secButtons, $icon);
     }
     //        dd($page->posts()->first()->name);
     return ViewUtils::page($views);
 }
 protected function instantiateView()
 {
     $route = \Illuminate\Support\Facades\Request::route()->getAction()['controller'];
     $parts = explode('@', $route);
     $controllerParts = explode('\\', $parts[0]);
     $controllerName = array_pop($controllerParts);
     $controller = str_slug(snake_case(substr($controllerName, 0, -strlen('Controller'))));
     $action = str_slug(snake_case($parts[1]));
     // Set up the view based on the module, controller, and action names.
     $viewFile = "{$controller}.{$action}";
     foreach (\Module::slugs() as $mod) {
         if (view_exists("{$mod}::{$viewFile}")) {
             $this->view = view("{$mod}::{$viewFile}");
         }
     }
     if (!$this->view && view_exists($viewFile)) {
         $this->view = view($viewFile);
     } elseif (!$this->view) {
         $this->view = view('base');
     }
     // Set up some more view variables.
     $this->view->controller = $controller;
     $this->view->action = $action;
     $this->view->app_env = env('APP_ENV');
     $this->view->app_version = config('app.version');
     $this->view->app_title = config('app.title');
     $this->view->site_name = config('app.site_name');
     $this->view->scripts = [];
     $this->view->return_to = substr(\Request::url(), strlen(url('')));
     $this->user = Auth::user();
     $this->view->user = $this->user;
     $this->view->tab = 'schedule';
     $this->view->alerts = \Session::get('alerts', array());
     $this->view->modules = \Module::slugs();
     $this->view->bing_key = env('BING_KEY');
 }
Exemple #14
0
 /**
  * Bind data to the view.
  *
  * @param View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $view->with('business', session()->get('selected.business'));
     $view->with('route', Request::route()->getName());
 }
Exemple #15
0
function check_is_module($namedroute)
{
    return \Illuminate\Support\Facades\Request::route()->getName() == $namedroute ? 'active' : '';
}
 public function compose(View $view)
 {
     $route = Request::route();
     $view->with('active_section', $route->getUri());
 }
Exemple #17
0
 function openPage()
 {
     $url = Feed::find(Request::route("id{$this->level}"))->url;
     return Redirect::to($url);
 }
 function post()
 {
     $post = Post::find(Request::route('id2'));
     $pageId = Request::route('id1');
     $sectionId = $post->section()->first()->id;
     $inputs = $this->inputs(Post::find(Request::route('id2')));
     foreach ($inputs as $input) {
         $item = Item::find($input->id);
         $content = $item->content()->where('post_id', '=', $post->id)->get()->first();
         if (isset($content) === false) {
             $content = new Content();
             $content->item_id = $item->id;
             $content->post_id = $post->id;
             $input->insert($content, Input::get("{$item->id}"));
         } else {
             $input->update($content, Input::get("{$item->id}"));
         }
         $content->save();
     }
     return Redirect::to("/admin/manage-pages/{$pageId}/content");
 }
 function post()
 {
     $att = $this->currentAttachment();
     if (!isset($att)) {
         $att = new Attachment();
     }
     //        $post = $this->currentPost();
     $pageId = Request::route('id1');
     $this->processInputs($att);
     $att->save();
     return Redirect::to("/admin/manage-pages/{$pageId}/content");
 }