Пример #1
0
 /**
  * Resolve the post.
  *
  * @return PostInterface|null
  */
 public function resolve()
 {
     $url = $this->request->url();
     $tmp = explode('/', $url);
     $last_seg = end($tmp);
     return $this->repository->findBySlug($last_seg);
 }
 public function email(Request $request)
 {
     $data = [];
     // @todo: place the validation logics somewhere else
     if ($request->isMethod('post')) {
         // Require only first row
         $validator = \Validator::make($request->all(), ['invite.email.0' => 'required', 'invite.name.0' => 'required']);
         // Validate the inputs
         $validator->each('invite.email', ['email']);
         $validator->each('invite.name', ['max:50', 'min:5']);
         $validator->setCustomMessages(['invite.email.0.required' => 'First row email required', 'invite.name.0.required' => 'First row name required']);
         if ($validator->fails()) {
             return redirect($request->url())->withInput()->withErrors($validator->errors());
         }
         foreach ($request->input('invite.email') as $key => $email) {
             $name = $request->input('invite.name.' . $key, strstr($email, '@', true));
             // Sometimes exception is thrown even though mail is sent successfully
             try {
                 \Mail::send('emails.invitation', compact('name', 'email'), function ($mail) use($email, $name) {
                     $mail->from('*****@*****.**', 'Footies Report')->to($email, $name)->subject('Invitation to join Footies Report!');
                 });
             } catch (\Exception $e) {
                 // Do nothing
             }
         }
         return redirect($request->url())->with('success', 'Processed successfully');
     }
     return view('admin.invite.email', $data);
 }
Пример #3
0
 private function generateMenu()
 {
     $currentUrl = $this->request->url();
     $user = $this->request->user();
     if (empty($user)) {
         return array();
     }
     return array(array('prefix' => 'Добрый день,', 'href' => route('admin.user.show', $this->request->user()->id), 'link' => $this->getUserName(), 'active' => $currentUrl == route('admin.user.show', $user->id) || $currentUrl == route('admin.user.edit', $user->id)), array('prefix' => '', 'href' => route('admin.user.index'), 'link' => 'Управление пользователями', 'active' => $currentUrl == route('admin.user.index')), array('prefix' => '', 'href' => route('admin.index'), 'link' => 'Рабочий стол', 'active' => $currentUrl == route('admin.index')), array('prefix' => '', 'href' => route('admin.logout'), 'link' => 'Выход'));
 }
Пример #4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //check for user's role
     $has_role = false;
     if (!$this->auth->guest() && $this->auth->user() != null) {
         $required_role = $request->route()->getAction()['role'];
         if ($required_role == '*') {
             $has_role = true;
         } else {
             $roles = $this->auth->user()->roles;
             foreach ($roles as $role) {
                 if ($role->id_role == 'admin' || $role->id_role == $required_role) {
                     $has_role = true;
                     break;
                 }
             }
         }
     }
     if ($this->auth->guest() || !$has_role) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect(route('admin-login') . '?return_url=' . urlencode($request->url()));
         }
     }
     return $next($request);
 }
Пример #5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (($this->isMobile() || $this->isTablet()) && !strstr($request->url(), 'sorry')) {
         return redirect('sorry');
     }
     return $next($request);
 }
Пример #6
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!\App\Gini\Gapper\Client::getUserName() && !in_array($request->url(), [route('root'), route('login')])) {
         return redirect()->to(route('root'));
     }
     return $next($request);
 }
 private function paginate($items, $perPage, Request $request)
 {
     $page = Input::get('page', 1);
     // get current page or default to 1
     $offset = $page * $perPage - $perPage;
     return new LengthAwarePaginator(array_slice($items, $offset, $perPage, false), count($items), $perPage, $page, ['path' => $request->url(), 'query' => $request->query()]);
 }
Пример #8
0
 public function category(Request $request)
 {
     $lastSegment = preg_split("/\\//", $request->url());
     $categorySlug = array_pop($lastSegment);
     // get the last segment on the current url
     $category = Tag::where('slug', $categorySlug)->first();
     // check if there is no category found.
     if (!$category) {
         return redirect()->route('front.error-404');
     }
     // condition where clause for parent categories or child.
     if ($category->parent_id == 0) {
         $field = 'tags.parent_id';
         $value = $category->id;
     } else {
         $field = 'tags.slug';
         $value = $category->slug;
     }
     // Get posts by PostTag slug or parent_id field
     $properties = Post::join('post_tags', 'posts.id', '=', 'post_tags.post_id')->join('tags', 'post_tags.tag_id', '=', 'tags.id')->where($field, $value)->select('posts.*', 'tags.name as tagName')->paginate(config('front.postPerPage'));
     $pageTitle = 'Category: ' . $category->name;
     if ($category->parent_id == 0) {
         $breadcrumbData = [['url' => url(), 'name' => 'Home'], ['url' => route('front.category') . '/' . $category->slug, 'name' => $category->name]];
     } else {
         $breadcrumbData = [['url' => url(), 'name' => 'Home'], ['url' => route('front.category', $category->parent()->slug), 'name' => $category->parent()->name], ['url' => route('front.category') . '/' . $category->parent()->slug . '/' . $category->slug, 'name' => $category->name]];
     }
     return view('properties', compact('properties', 'pageTitle', 'breadcrumbData'));
 }
Пример #9
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Put in cache all of route which are tag
     $routes = Cache::remember('tags', 120, function () {
         return Route::all();
     });
     $results = [];
     // Check if current route has tags
     foreach ($routes as $route) {
         if (preg_match('%^' . $route->route . '$%', $request->url())) {
             array_push($results, $route->tag_container_id);
         }
     }
     // Get all container tag of the current route and add this to the layout
     $contents = Tag::whereIn('tag_container_id', $results)->get();
     if ($contents) {
         foreach ($contents as $content) {
             // if data content format this to integrate them into the script
             if ($content->data) {
                 $data = explode(',', $content->data);
                 $params = [];
                 foreach ($data as $value) {
                     $params[] = "'+ {$value} +'";
                 }
                 $script = sprintf($content->content, ...$params);
             } else {
                 $script = $content->content;
             }
             // add script to namespace declared in database
             js($content->position . '-tag')->append($script);
         }
     }
     return $next($request);
 }
Пример #10
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct(Request $r)
 {
     date_default_timezone_set("Asia/Jakarta");
     //$this->middleware('auth');
     //echo "<pre>".print_r($_SERVER,1)."</pre>";
     $log = new Logdata();
     $log->idpengguna = Auth::check() ? Auth::user()->id : 0;
     $log->url = $r->url();
     $log->user_agent = $_SERVER['HTTP_USER_AGENT'];
     $log->ip = $_SERVER['REMOTE_ADDR'];
     $log->ip_port = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : "";
     $log->http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "";
     $log->http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
     $log->pathinfo = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : "";
     $log->save();
     // echo Auth::user()->password;
     // if(Auth::check()){
     // 	if(Auth::user()->password==""){
     // 		header("location:".url('notfound'));
     // 		die();
     // 	}
     // }
     //		Session::put("a-".getenv('REMOTE_ADDR')."-3",'x');
     foreach (\App\Popups::all() as $key) {
         $isi = array();
         if ($key->tipe_valid == "by_datetime" or $key->tipe_valid == "by_date") {
             $cek = $this->check_in_range(date_format(date_create($key->date_valid_start . " " . $key->time_valid_start), "Y-m-d H:i:s"), date_format(date_create($key->date_valid_end . " " . $key->time_valid_end), "Y-m-d H:i:s"), date("Y-m-d H:i:s"));
             if ($cek) {
                 if (!Session::has("a-" . getenv('REMOTE_ADDR') . "-" . $key->id)) {
                     Session::put("a-" . getenv('REMOTE_ADDR') . "-" . $key->id, 'x');
                 }
             }
         }
     }
 }
Пример #11
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     //
     echo $request->path(), '<br>';
     echo $request->url();
     //return "this is  Admin";
 }
Пример #12
0
 /**
  * post的方式添加一条记录
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //验证参数
     $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
     //验证参数完整性
     if ($validator->fails()) {
         $error = $validator->errors()->all();
         //写入日志
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回错误信息
         return Error::returnError($request_url, 1001);
     }
     //验证token
     //        $user_id=Common::validateToken($request->get('token'));
     //
     //        if($user_id == false){
     //            return Error::returnError($request_url,2002);
     //        }
     $name = $request->get('name');
     //写入操作
     $add = Task::addTask($name);
     $info = Task::getTaskInfo($add);
     //返回对应的结果
     $json_arr = ['request' => $request_url, 'ret' => $info];
     return Common::returnResult($json_arr);
 }
Пример #13
0
 function __construct(Request $request)
 {
     $visitorModel = new VisitorModel();
     $visitorModel->ip = $request->getClientIp();
     $visitorModel->url = $request->url();
     $visitorModel->save();
 }
Пример #14
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 (strpos($request->url(), '/api/') === false) {
         return parent::render($request, $e);
     }
     $response = [];
     // If the app is in debug mode
     if (config('app.debug')) {
         // Add the exception class name, message and stack trace to response
         $response['exception'] = get_class($e);
         // Reflection might be better here
         $response['message'] = $e->getMessage();
         $response['file'] = $e->getFile();
         $response['line'] = $e->getLine();
     }
     // Default response of 400
     $status = 400;
     // If this exception is an instance of HttpException
     if ($this->isHttpException($e)) {
         // Grab the HTTP status code from the Exception
         $status = $e->getStatusCode();
         $response['status'] = $status;
         $response['message'] = self::$statusMessages[$status];
     }
     // Return a JSON response with the response array and status code
     return response()->json($response, $status)->header('Access-Control-Allow-Origin', env('ALLOWED_HOSTS', '*'))->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')->header('Access-Control-Allow-Credentials', 'true')->header('Access-Control-Allow-Headers', 'Content-Type, X-Auth-Token, Origin, Authorization');
 }
Пример #15
0
 /**
  * 用户通过邮箱和密码进行登录操作
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     //获取当前访问的全部的地址
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //验证参数
     $validator = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']);
     //验证参数完整性
     if ($validator->fails()) {
         // var_dump($validator);
         $error = $validator->errors()->all();
         //写入日志
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回错误信息
         return Error::returnError($request_url, 1001);
     }
     $email = $request->get('email');
     $password = $request->get('password');
     //检查有没有
     $user_model = User::checkUserLogin($email, $password);
     if ($user_model == false) {
         return Error::returnError($request_url, 2001);
     }
     //更新token
     $token = User::updateToken($user_model);
     //返回对应的结果
     $json_arr = ['request' => $request_url, 'ret' => User::getUserInfo($user_model->id), 'token' => $token];
     return Common::returnResult($json_arr);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $urlArray = explode('/', $request->url());
     for ($i = 0; $i < count($urlArray); $i++) {
         if ($urlArray[$i] == 'forum') {
             $forum = ForumForum::findOrFail($urlArray[$i + 1]);
             if ($forum->getPermissionModerer() == 1) {
                 return $next($request);
             }
             if (Auth::user() != NULL) {
                 if (Auth::user()->rang()->first()->getId() >= $forum->getPermissionModerer()) {
                     return $next($request);
                 }
             }
         }
         if ($urlArray[$i] == 'topic' && $urlArray[$i + 2] == 'edit') {
             $topic = ForumTopic::findOrFail($urlArray[$i + 1]);
             if (Auth::user() != NULL) {
                 if (Auth::user()->getId() == $topic->createur()->first()->getId()) {
                     return $next($request);
                 }
             }
         }
         if ($urlArray[$i] == 'post' && $urlArray[$i + 2] == 'edit') {
             $post = ForumPost::findOrFail($urlArray[$i + 1]);
             if (Auth::user() != NULL) {
                 if (Auth::user()->getId() == $post->createur()->first()->getId()) {
                     return $next($request);
                 }
             }
         }
     }
     return new RedirectResponse(url('/forum/' . $forum->getId() . '/topic'));
 }
Пример #17
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     // Check if the user is logged in
     if (!$this->auth->check()) {
         // Store the current uri in the session
         $this->session->put('url.intended', $this->request->url());
         // Redirect to the login page
         return $this->redirect->route('login');
     }
     // Check if the user has access to the dashboard page
     if (!$this->auth->hasAccess('dashboard.index')) {
         // Show the insufficient permissions page
         return $this->application->abort(403);
     }
     return $next($request);
 }
Пример #18
0
 /**
  * Handle an incoming request, check to see if we have a redirect in place for the requested URL
  * and then redirect if we do have a match
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Get the full URL that has been requested, minus the protocol
     $full_url = str_replace($request->getScheme() . "://", "", $request->url());
     // Check for any results matching the full domain request
     $results = Redirect::where("type", "domain")->where("from", $full_url)->where("status", "active");
     if ($results->exists()) {
         // Get the first result back
         $redirect = $results->first();
         // Grab the URL before we increment
         $url = $redirect->to;
         // Increment the hit count
         $redirect->increment('hits');
         // Redirect off to where we're going
         return RedirectFacade::to($url);
     }
     // Check for any results matching the path only
     $results = Redirect::where("type", "path")->where("from", "/" . $request->path())->where("status", "active");
     // If a redirect exists for this, process it and redirect
     if ($results->exists()) {
         // Get the first result back
         $redirect = $results->first();
         // Grab the URL before we increment
         $url = $redirect->to;
         // Increment the hit count
         $redirect->increment('hits');
         // Redirect off to where we're going
         return RedirectFacade::to($url, 301);
     }
     // By default, continue afterwards and bail out
     return $next($request);
 }
Пример #19
0
 public function put(Route $route, Request $request, Response $response)
 {
     $key = $this->makeCacheKey($request->url());
     if (!Cache::has($key)) {
         Cache::put($key, $response->getContent(), 10);
     }
 }
Пример #20
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->validAuth($request->session())) {
         $request->session()->set('url.intended', $request->url());
         return redirect('auth/reauthenticate');
     }
     return $next($request);
 }
Пример #21
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->needsReAuth($request->session())) {
         $request->session()->set('url.intended', $request->url());
         return redirect('auth/confirm');
     }
     return $next($request);
 }
Пример #22
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $key = $request->url();
     if (Cache::has($key)) {
         return Cache::get($key);
     }
     return $next($request);
 }
Пример #23
0
 public function getSelecttime(Request $request, $staffer_id, $tote_id, $product_amount)
 {
     $user = $request->user();
     $abodesAndMoments = Staffer::apiAbodeMomentGet($tote_id, $product_amount, $staffer_id);
     $addressLast = Address::apiLast();
     $request->session()->flash('SelecttimeUrl', $request->url());
     return view('auth.staffer.selecttime', ['TITLE' => '选择时间', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => 'auth.staffer.selecttime', 'user' => $user, 'abodesAndMoments' => $abodesAndMoments, 'staffer_id' => $staffer_id, 'tote_id' => $tote_id, 'product_amount' => $product_amount, 'addressLast' => $addressLast]);
 }
Пример #24
0
 public function showServices(Map $map, Request $request, ShortenLink $shortenLink)
 {
     $lat = $map->getLat();
     $lng = $map->getLng();
     $link = $shortenLink->shortenUrl($request->url());
     $shortLink = $link->getShortUrl();
     return view('pages.services', compact('lat', 'lng', 'shortLink'));
 }
Пример #25
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $book = R::dispense("book");
     $book->author = "Santa Claus";
     $book->title = "Secrets of Christmas";
     $id = R::store($book);
     return "Index<br>" . "<br>url: " . $request->url() . "<br>uri: " . $request->path();
 }
Пример #26
0
 protected function prependBreadcrumbs($menu, $isParent = true)
 {
     if (!$isParent) {
         $this->breadcrumbs = '<li class="active">' . $menu['label'] . '</li>' . $this->breadcrumbs;
     } else {
         $url = $menu['url'] ?: $this->request->url() . '#';
         $this->breadcrumbs = '<li><a href="' . $url . '">' . $menu['label'] . '</a></li>' . $this->breadcrumbs;
     }
 }
Пример #27
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $as = $request->input('_as');
     if ($this->authorize() && !is_null($as)) {
         $this->auth->loginUsingId($as);
         return $this->response->redirectTo($request->url());
     }
     return $next($request);
 }
Пример #28
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $user = \Auth::user();
     if (!$user->master) {
         $data = ['type' => 'danger', 'title' => 'Erro - Acesso Mestre', 'message' => 'Usuário sem acesso ao recurso: ' . $request->url()];
         return view('utils.genericError', $data);
     }
     return $next($request);
 }
Пример #29
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $reauth = new ReauthLimiter($request);
     if (!$reauth->check()) {
         $request->session()->set('url.intended', $request->url());
         return $this->invalidated($request);
     }
     return $next($request);
 }
Пример #30
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show(Request $request, $name)
 {
     $project = Project::where('name', $name)->get()->first();
     if (is_null($project)) {
         abort(404);
     }
     $project->webhook_url = $request->url() . "/webhook";
     return view('project.index')->with('project', $project);
 }