public function getList(Request $request, $table = '')
 {
     if (!$table) {
         App::abort(404);
     }
     \Session::put('backlink', $request->fullUrl());
     $orderBy = $request->get('by', 'id');
     $orderType = $request->get('type', 'ASC');
     $take = $request->has('take') ? $request->get('take') : Config::get('scaffenger.config.rpp');
     $filter = $request->has('filter') ? $request->get('filter') : null;
     $config = Config::get('scaffenger.tables.' . $table);
     $model = $config['model'];
     $objects = new $model();
     if ($filter) {
         //TODO: Search in related tables also
         $search_in = [];
         foreach ($config['columns'] as $column => $search_field) {
             if (in_array($search_field['type'], ['slug', 'text', 'textarea', 'wysiwyg', 'email', 'select'])) {
                 $search_in[$column] = $search_field;
             }
         }
         $objects = $objects->where(function ($query) use($search_in, $filter) {
             foreach ($search_in as $search_field => $field_data) {
                 $query->orWhere($search_field, 'LIKE', '%' . $filter . '%');
             }
         });
     }
     $objects = $objects->orderBy($orderBy, $orderType)->paginate($take);
     $objects->setPath(Config::get('app.url') . '/admin/list/' . $table);
     return view('scaffenger::list')->with('table', $table)->with('model', $model)->with('config', $config)->with('objects', $objects);
 }
Example #2
1
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::user() && !Auth::user()->profile && $request->fullUrl() != action('SettingsProfileController@getIndex', [Auth::user()->username]) && $request->fullUrl() != action('SettingsProfileController@putUpdateProfile', [Auth::user()->username])) {
         return redirect()->action('SettingsProfileController@getIndex', [Auth::user()->username]);
     }
     return $next($request);
 }
 /**
  * Get the request formatted as meta data.
  *
  * @return array
  */
 public function getMetaData()
 {
     $data = [];
     $data['url'] = $this->request->fullUrl();
     $data['httpMethod'] = $this->request->getMethod();
     $data['params'] = $this->request->input();
     $data['clientIp'] = $this->request->getClientIp();
     if ($agent = $this->request->header('User-Agent')) {
         $data['userAgent'] = $agent;
     }
     if ($headers = $this->request->headers->all()) {
         $data['headers'] = $headers;
     }
     return ['request' => $data];
 }
Example #4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is("sitemap") && $request->fullUrl() != '' && $this->auth->guest()) {
         $aSiteMap = \Cache::get('sitemap', []);
         $changefreq = 'always';
         if (!empty($aSiteMap[$request->fullUrl()]['added'])) {
             $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff(Carbon::now());
             if ($aDateDiff->y > 0) {
                 $changefreq = 'yearly';
             } else {
                 if ($aDateDiff->m > 0) {
                     $changefreq = 'monthly';
                 } else {
                     if ($aDateDiff->d > 6) {
                         $changefreq = 'weekly';
                     } else {
                         if ($aDateDiff->d > 0 && $aDateDiff->d < 7) {
                             $changefreq = 'daily';
                         } else {
                             if ($aDateDiff->h > 0) {
                                 $changefreq = 'hourly';
                             } else {
                                 $changefreq = 'always';
                             }
                         }
                     }
                 }
             }
         }
         $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => Carbon::now()->toIso8601String(), 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => $changefreq];
         \Cache::put('sitemap', $aSiteMap, 2880);
     }
     return $next($request);
 }
Example #5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->isMethod('get') && !$request->has('PageSpeed') && !$request->is(config('site.admin_path') . '*') && !$request->is('avatar/*') && !$request->is('my/*') && !$request->is('*/login') && !$request->is('*/authorize') && !in_array($request->path(), ['sitemap.xml', 'logout', 'login'])) {
         $aSiteMap = Cache::get('sitemap', []);
         $changefreq = 'always';
         if (!empty($aSiteMap[$request->fullUrl()]['added'])) {
             $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff(Carbon::now());
             if ($aDateDiff->y > 0) {
                 $changefreq = 'yearly';
             } else {
                 if ($aDateDiff->m > 0) {
                     $changefreq = 'monthly';
                 } else {
                     if ($aDateDiff->d > 6) {
                         $changefreq = 'weekly';
                     } else {
                         if ($aDateDiff->d > 0 && $aDateDiff->d < 7) {
                             $changefreq = 'daily';
                         } else {
                             if ($aDateDiff->h > 0) {
                                 $changefreq = 'hourly';
                             } else {
                                 $changefreq = 'always';
                             }
                         }
                     }
                 }
             }
         }
         $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => Carbon::now()->format('Y-m-d\\TH:i:sP'), 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => $changefreq];
         Cache::forever('sitemap', $aSiteMap);
     }
     return $next($request);
 }
Example #6
0
 public function test(Request $request)
 {
     $access_token = \Wechat::getWebAuthAccessToken();
     $timestamp = Carbon::now()->getTimestamp();
     $addr_sign = ['accesstoken=' . $access_token, 'appid=' . \Wechat::getAppId(), 'noncestr=123456', 'timestamp=' . $timestamp, 'url=' . $request->fullUrl()];
     sort($addr_sign);
     $addr_sign = implode('&', $addr_sign);
     return view('shop.test')->with(['appId' => env('WX_APPID'), 'timestamp' => $timestamp, 'addrSign' => sha1($addr_sign), 'url' => $request->fullUrl(), 'js' => \Wechat::getJssdkConfig(['checkJsApi', 'editAddress', 'openAddress', 'chooseWXPay', 'getLatestAddress', 'openCard', 'getLocation'])]);
     //        return view('backend.article.customer_index')->with([
     //            'items' => Article::paginate(10)
     //        ]);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $currentLocale = app('laravellocalization')->getCurrentLocale();
     $defaultLocale = app('laravellocalization')->getDefaultLocale();
     $params = explode('/', $request->path());
     if (count($params) > 0) {
         $localeCode = $params[0];
         $locales = app('laravellocalization')->getSupportedLocales();
         $hideDefaultLocale = app('laravellocalization')->hideDefaultLocaleInURL();
         $redirection = false;
         if (!empty($locales[$localeCode])) {
             if ($localeCode === $defaultLocale && $hideDefaultLocale) {
                 $redirection = app('laravellocalization')->getNonLocalizedURL();
             }
         } else {
             if ($currentLocale !== $defaultLocale || !$hideDefaultLocale) {
                 // If the current url does not contain any locale
                 // The system redirect the user to the very same url "localized"
                 // we use the current locale to redirect him
                 $redirection = app('laravellocalization')->getLocalizedURL(session('locale'), $request->fullUrl());
             }
         }
         if ($redirection) {
             // Save any flashed data for redirect
             app('session')->reflash();
             return new RedirectResponse($redirection, 302, ['Vary' => 'Accept-Language']);
         }
     }
     return $next($request);
 }
 /**
  * Dispatch different pay method.
  *
  * @param Request $request
  */
 public function paymentMethod(Request $request)
 {
     /*
      * Switch the paymentMethod from the request, if it match any of
      * known methods, it will bind the service interface
      * to the concrete service, and controller
      * will excute that concrete service
      */
     $paymentMethod = null;
     if ($request->has('paymentMethod')) {
         $paymentMethod = $request->paymentMethod;
     } elseif (str_contains($request->fullUrl(), 'alipay')) {
         // Here handle the notify_url and return_url
         $paymentMethod = 'alipay';
     }
     if ($paymentMethod != null) {
         switch ($paymentMethod) {
             case 'alipay':
                 $this->app->bind('App\\Services\\Payment\\PaymentServiceInterface', 'App\\Services\\Payment\\AlipayService');
                 break;
             default:
                 // FIXME: For default situation, should not bind alipay
                 $this->app->bind('App\\Services\\Payment\\PaymentServiceInterface', 'App\\Services\\Payment\\AlipayService');
                 break;
         }
     }
 }
 /**
  * Get full uri but remove switch_locale_to if it's present.
  *
  * @param  string  $uri
  * @return string
  */
 protected function getFullUri()
 {
     if (!$this->request->switch_locale_to) {
         return $this->request->fullUrl();
     }
     return preg_replace('/(\\?|&)switch_locale_to=.+?(?:(?!&).)/', '', $this->request->fullUrl());
 }
Example #10
0
 /**
  * Gets the view hash
  *
  * @return string
  */
 protected function getCurrentHash()
 {
     if ($this->currentHash === null) {
         $this->currentHash = md5($this->request->fullUrl() . $this->request->method() . $this->request->getClientIp());
     }
     return $this->currentHash;
 }
Example #11
0
 /**
  * Generate and render the HTML metadata tags.
  *
  * @return string
  */
 public function generate()
 {
     $title = $this->getTitle();
     $description = $this->getDescription();
     $keywords = $this->getKeywords();
     $miscellaneous = $this->getMiscellaneous();
     $canonical = $this->getCanonical();
     $html[] = '<title>' . $title . '</title>' . PHP_EOL;
     if (!is_null($description)) {
         $html[] = '<meta name="description" content="' . $description . '">';
     }
     if (!is_null($keywords)) {
         $html[] = '<meta name="keywords" content="' . $keywords . '">';
     }
     if (!is_null($miscellaneous)) {
         foreach ($miscellaneous as $name => $content) {
             $html[] = '<meta name="' . $name . '" content="' . $content . '">';
         }
     }
     if (!is_null($canonical)) {
         $currentUrl = $this->request->fullUrl();
         if ($canonical != $currentUrl) {
             $html[] = PHP_EOL . '<link rel="canonical" href="' . $canonical . '">';
         }
     }
     return implode(PHP_EOL, $html);
 }
Example #12
0
 public function index(Request $request)
 {
     $widgetClasses = WidgetsFacade::all();
     asort($widgetClasses);
     $widgets = [];
     foreach ($widgetClasses as $widgetClass) {
         $widget = new $widgetClass();
         $widgets[$widget->getName()] = $widget->getDisplayName();
     }
     $placeholders = HomeThemeFacade::placeholders();
     asort($placeholders);
     $placeholderNames = array_keys($placeholders);
     $themeWidgets = ThemeWidget::whereIn('placeholder', $placeholderNames)->orderBy('order', 'asc')->orderBy('created_at', 'asc')->get();
     $themePlaceholders = [];
     foreach ($placeholderNames as $placeholderName) {
         $themePlaceholders[$placeholderName] = [];
     }
     foreach ($themeWidgets as $themeWidget) {
         $placeholderName = $themeWidget->placeholder;
         $themePlaceholders[$placeholderName][] = $themeWidget;
     }
     $this->theme->title(trans('pages.admin_widgets_title'));
     $this->theme->description(trans('pages.admin_widgets_desc'));
     return $this->_list(['widgets' => $widgets, 'placeholders' => $placeholders, 'placeholderNames' => $placeholderNames, 'themePlaceholders' => $themePlaceholders, 'rdr_param' => rdrQueryParam($request->fullUrl())]);
 }
Example #13
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     Logger::middlewareInfo('@ExampleMiddle begin, request:', ['headers' => $request->headers, 'url' => $request->fullUrl(), 'params' => $request->all()]);
     $response = $next($request);
     Logger::middlewareInfo('@ExampleMiddle end, response:', ['code' => $response->getStatusCode(), 'content' => $response->getContent()]);
     return $response;
 }
 /**
  * Handle the command.
  *
  * @param Request $request
  */
 public function handle(Request $request)
 {
     $active = null;
     /**
      * If the route does not exist,
      * i.e. a 404 or 500 handling page.
      * Then we don't have anything to do.
      */
     if (!($route = $request->route())) {
         return;
     }
     $compiled = $route->getCompiled();
     $staticPrefix = $compiled->getStaticPrefix();
     $exact = $request->fullUrl();
     $partial = $request->getUriForPath($staticPrefix);
     /* @var LinkInterface $link */
     foreach ($this->links as $link) {
         if ($link->getUrl() == $exact) {
             $active = $link;
         } elseif ($link->getUrl() == $partial) {
             $active = $link;
         }
     }
     /**
      * If we have an current link determined
      * then mark it as such.
      *
      * @var LinkInterface $active
      */
     if ($active) {
         $active->setActive(true);
     }
 }
Example #15
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof TokenMismatchException && $request->path() == 'admin/login') {
         Message::warning(pick_trans('login_csrf_token_failed'));
         return redirect($request->fullUrl());
     }
     return parent::render($request, $e);
 }
Example #16
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $this->theme->title(trans('pages.admin_users_title'));
     $this->theme->description(trans('pages.admin_users_desc'));
     $users = User::orderBy('created_at', 'desc')->paginate(AppConfig::DEFAULT_ITEMS_PER_PAGE);
     $users_query = new QueryStringBuilder(['page' => $users->currentPage()], adminUrl('users'));
     return $this->_list(['users' => $users, 'users_query' => $users_query, 'page_helper' => new PaginationHelper($users->lastPage(), $users->currentPage(), $users->perPage()), 'rdr_param' => rdrQueryParam($request->fullUrl())]);
 }
 /**
  * Handle the command.
  *
  * @param SettingRepositoryInterface $settings
  * @param Request                    $request
  * @return Github
  */
 public function handle(SettingRepositoryInterface $settings, Request $request)
 {
     /* @var EncryptedFieldTypePresenter $clientId */
     /* @var EncryptedFieldTypePresenter $clientSecret */
     $clientId = $settings->value('anomaly.extension.github_provider::client_id');
     $clientSecret = $settings->value('anomaly.extension.github_provider::client_secret');
     return new Github(['clientId' => $clientId->decrypted(), 'clientSecret' => $clientSecret->decrypted(), 'redirectUri' => $request->fullUrl()]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $this->theme->title(trans('pages.admin_link_categories_title'));
     $this->theme->description(trans('pages.admin_link_categories_desc'));
     $categories = Category::where('type', Category::LINK)->orderBy('created_at', 'desc')->paginate(AppConfig::DEFAULT_ITEMS_PER_PAGE);
     $query = new QueryStringBuilder(['page' => $categories->currentPage()], adminUrl('link-categories'));
     return $this->_list(['categories' => $categories, 'query' => $query, 'page_helper' => new PaginationHelper($categories->lastPage(), $categories->currentPage(), $categories->perPage()), 'rdr_param' => rdrQueryParam($request->fullUrl())]);
 }
Example #19
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $exception
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $exception)
 {
     // Catch TokenMismatchException to show a friendly error message
     if ($exception instanceof \Illuminate\Session\TokenMismatchException) {
         return redirect($request->fullUrl())->withErrors(trans('app.msg.invalid_token'));
     }
     return parent::render($request, $exception);
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $urlIsSigned = app('url-signer')->validate($request->fullUrl());
     if (!$urlIsSigned) {
         abort(403);
     }
     return $next($request);
 }
 /**
  * Create a new event instance.
  *
  * @param Exception $exception
  * @param Request $request
  * @param int $statusCode
  */
 public function __construct(Exception $exception, Request $request, $statusCode)
 {
     $this->message = $exception->getMessage();
     $this->fullUrl = $request->fullUrl();
     $this->headers = $request->header();
     $this->parentClass = get_class($exception);
     $this->exception = $exception->getTraceAsString();
     $this->statusCode = $statusCode;
 }
Example #22
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $array = [];
     /*
           $t = microtime(true);
             $micro = sprintf("%06d",($t - floor($t)) * 1000000);
             $d = new \DateTime( date('Y-m-d H:i:s.'.$micro, $t) );
     */
     $time_now = Carbon::now();
     //$dd = "2016-03-20T18:00:30+0000" ;
     $dd = $time_now->toIso8601String();
     //  $microSeconds = str_replace("+0000","+02:00", $dd);
     if (!$request->is("sitemap") && $request->fullUrl() != '' && $this->auth->guest()) {
         $aSiteMap = \Cache::get('sitemap', []);
         $changefreq = 'always';
         if (!empty($aSiteMap[$request->fullUrl()]['added'])) {
             $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff($time_now);
             if ($aDateDiff->y > 0) {
                 $changefreq = 'yearly';
             } else {
                 if ($aDateDiff->m > 0) {
                     $changefreq = 'monthly';
                 } else {
                     if ($aDateDiff->d > 6) {
                         $changefreq = 'weekly';
                     } else {
                         if ($aDateDiff->d > 0 && $aDateDiff->d < 7) {
                             $changefreq = 'daily';
                         } else {
                             if ($aDateDiff->h > 0) {
                                 $changefreq = 'hourly';
                             } else {
                                 $changefreq = 'always';
                             }
                         }
                     }
                 }
             }
         }
         $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => $dd, 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => 'always'];
         \Cache::put('sitemap', $aSiteMap, 2880);
     }
     return $next($request);
 }
 /**
  * Handle the command.
  *
  * @param SettingRepositoryInterface $settings
  * @param Request                    $request
  * @return GenericProvider
  */
 public function handle(SettingRepositoryInterface $settings, Request $request)
 {
     /* @var EncryptedFieldTypePresenter $clientId */
     /* @var EncryptedFieldTypePresenter $clientSecret */
     /* @var UrlFieldTypePresenter $clientDomain */
     $clientId = $settings->value('anomaly.extension.streams_platform_provider::client_id');
     $clientSecret = $settings->value('anomaly.extension.streams_platform_provider::client_secret');
     $clientDomain = $settings->value('anomaly.extension.streams_platform_provider::client_domain');
     return new GenericProvider(['clientId' => $clientId->decrypted(), 'clientSecret' => $clientSecret->decrypted(), 'redirectUri' => $request->fullUrl(), 'urlAuthorize' => $clientDomain->to('api/authorize'), 'urlAccessToken' => $clientDomain->to('api/token'), 'urlResourceOwnerDetails' => $clientDomain->to('api/owner')]);
 }
Example #24
0
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $visit = new Visit(['http_url' => $request->fullUrl(), 'http_method' => $request->method(), 'http_path' => $request->path(), 'ip' => $request->ip()]);
     if ($user = \Auth::user()) {
         $user->visits()->save($visit);
     } else {
         $visit->save();
     }
     return $next($request);
 }
Example #25
0
 /**
  * Handle the command.
  *
  * @param  Request         $request
  * @param  ResponseFactory $response
  * @throws \Exception
  */
 public function handle(Request $request, ResponseFactory $response)
 {
     if ($this->builder instanceof MultipleTableBuilder) {
         return;
     }
     $this->dispatch(new ExecuteAction($this->builder));
     if (!$this->builder->getTableResponse()) {
         $this->builder->setTableResponse($response->redirectTo($request->fullUrl()));
     }
 }
Example #26
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, Request $request)
 {
     echo $id . "<br>";
     echo $request->url() . "<br>";
     echo $request->fullUrl() . "<br>";
     echo $request->method() . "<br>";
     if ($request->isMethod('get')) {
         echo "yes";
     }
 }
 /**
  * Handle the command.
  *
  * @param ResponseFactory $response
  * @param Request         $request
  */
 public function handle(ResponseFactory $response, Request $request)
 {
     /* @var TableBuilder $builder */
     foreach ($this->builder->getTables() as $builder) {
         $builder->post();
     }
     if (!$this->builder->getTableResponse()) {
         $this->builder->setTableResponse($response->redirectTo($request->fullUrl()));
     }
 }
Example #28
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, Request $request)
 {
     $medication = Medication::findOrFail($id);
     $items = PpoItem::where('medication_id', $medication->id)->paginate(10);
     $lucodes = Lucode::where('medication_id', $medication->id)->get();
     $isAdminView = true;
     //flash a back url
     $request->session()->put('backUrl', $request->fullUrl());
     return view('medications.show', compact('medication', 'items', 'lucodes', 'isAdminView'));
 }
 public function generateToken(Request $request, $clientId)
 {
     $app = App::findByClientId($clientId);
     $token = $this->createToken($app);
     $query = str_replace($request->url(), '', $request->fullUrl());
     if ($query && strlen($query)) {
         $token->query_string = substr($query, 1);
         $token->save();
     }
     return redirect('https://telegram.me/' . env('BOT_NAME') . '?start=' . $token->token);
 }
 /**
  * Handle an incoming request.
  *
  * @param  Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (!session('wechat.oauth_user')) {
         if ($request->has('state') && $request->has('code')) {
             session(['wechat.oauth_user' => app('wechat.oauth')->user()]);
             return redirect()->to(url($request->url(), array_except($request->query(), ['code', 'state'])));
         }
         return app('wechat.oauth')->oauth->redirect($request->fullUrl());
     }
     return $next($request);
 }