当前位置: 首页>>代码示例>>PHP>>正文


PHP abort函数代码示例

本文整理汇总了PHP中abort函数的典型用法代码示例。如果您正苦于以下问题:PHP abort函数的具体用法?PHP abort怎么用?PHP abort使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了abort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure|\Closure $next
  * @param $permissions
  * @return mixed
  * @internal param $roles
  * @internal param null|string $guard
  */
 public function handle(Request $request, Closure $next, $permissions)
 {
     if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
         abort(403);
     }
     return $next($request);
 }
开发者ID:Matth--,项目名称:privileges,代码行数:17,代码来源:PrivilegesPermissionMiddleware.php

示例2: __costruct

 public function __costruct()
 {
     $auth = auth()->guard('admin');
     if (!$auth->check()) {
         abort(403, "Anda tidak memiliki hak akses ke halaman ini");
     }
 }
开发者ID:jamalapriadi,项目名称:lv5.2,代码行数:7,代码来源:AdminController.php

示例3: getCallback

 public function getCallback()
 {
     $fb = App::make('SammyK\\LaravelFacebookSdk\\LaravelFacebookSdk');
     // Obtain an access token.
     try {
         $token = $fb->getAccessTokenFromRedirect();
     } catch (Facebook\Exceptions\FacebookSDKException $e) {
         dd($e->getMessage());
     }
     // Access token will be null if the user denied the request
     // or if someone just hit this URL outside of the OAuth flow.
     if (!$token) {
         // Get the redirect helper
         $helper = $fb->getRedirectLoginHelper();
         if (!$helper->getError()) {
             abort(403, 'Unauthorized action.');
         }
         // User denied the request
         dd($helper->getError(), $helper->getErrorCode(), $helper->getErrorReason(), $helper->getErrorDescription());
     }
     if (!$token->isLongLived()) {
         // OAuth 2.0 client handler
         $oauth_client = $fb->getOAuth2Client();
         // Extend the access token.
         try {
             $token = $oauth_client->getLongLivedAccessToken($token);
         } catch (Facebook\Exceptions\FacebookSDKException $e) {
             dd($e->getMessage());
         }
     }
     $fb->setDefaultAccessToken($token);
     // Save for later
     Session::put('fb_user_access_token', (string) $token);
     // Get basic info on the user from Facebook.
     try {
         $response = $fb->get('/me?fields=id,name,email,picture.type(large)');
     } catch (Facebook\Exceptions\FacebookSDKException $e) {
         dd($e->getMessage());
     }
     // Convert the response to a `Facebook/GraphNodes/GraphUser` collection
     $facebook_user = $response->getGraphUser();
     // Create the user if it does not exist or update the existing entry.
     // This will only work if you've added the SyncableGraphNodeTrait to your User model.
     $user = User::createOrUpdateGraphNode($facebook_user);
     $arrContextOptions = array("ssl" => array("verify_peer" => false, "verify_peer_name" => false));
     $img = ImageIntervention::make(file_get_contents($user->url, false, stream_context_create($arrContextOptions)));
     $img->fit(100);
     $img->save(base_path() . '/public/images/profilePhotos/thumb_100_' . md5($user->id) . '.jpg', 100);
     $img = ImageIntervention::make(file_get_contents($user->url, false, stream_context_create($arrContextOptions)));
     $img->fit(50);
     $img->save(base_path() . '/public/images/profilePhotos/thumb_50_' . md5($user->id) . '.jpg', 100);
     // Log the user into Laravel
     Auth::login($user);
     //maybe this need to redirect back to the originating page
     if (Session::has('profileId')) {
         return redirect('/profile/index/' . Session::get('profileId'));
     } else {
         return redirect('/register');
     }
 }
开发者ID:ElasticOrange,项目名称:canon-orasul-respira-foto,代码行数:60,代码来源:FacebookController.php

示例4: processCreateForm

 /**
  * {@inheritdoc}
  */
 static function processCreateForm($request, $video)
 {
     $mmc = new MediamosaConnector();
     $user = Auth::user();
     $response = $mmc->createAsset($user->id);
     if (empty($response['data']['items']['item'][0]['asset_id'])) {
         abort(500, 'Mediamosa: Failed creating asset');
     }
     $asset_id = $response['data']['items']['item'][0]['asset_id'];
     $data = array('isprivate' => 'true');
     $response = $mmc->updateAsset($asset_id, $user->id, $data);
     if (empty($response)) {
         abort(500, 'Mediamosa: Failed updating asset');
     }
     $response = $mmc->createMediafile($asset_id, $user->id);
     if (empty($response['data']['items']['item'][0]['mediafile_id'])) {
         abort(500, 'Mediamosa: Failed creating mediafile');
     }
     $mediafile_id = $response['data']['items']['item'][0]['mediafile_id'];
     $response = $mmc->createUploadTicket($mediafile_id, $user->id, $_SERVER['HTTP_REFERER']);
     if (empty($response['data']['items']['item'][0]['action'])) {
         abort(500, 'Mediamosa: Failed creating upload ticket');
     }
     $action = $response['data']['items']['item'][0]['action'];
     $uploadprogress_url = $response['data']['items']['item'][0]['uploadprogress_url'];
     $ticket_id = $response['data']['items']['item'][0]['ticket_id'];
     $progress_id = $response['data']['items']['item'][0]['progress_id'];
     if (!empty($_SERVER['HTTPS'])) {
         $uploadprogress_url = str_replace("http://", "https://", $uploadprogress_url);
         $action = str_replace("http://", "https://", $action);
     }
     $random_id = $mmc->generateRandomString(8);
     $video->data = array('status' => 'uploadticket', 'asset_id' => $asset_id, 'mediafile_id' => $mediafile_id, 'uploadticket_data' => array('action' => $action, 'uploadprogress_url' => $uploadprogress_url, 'ticket_id' => $ticket_id, 'progress_id' => $progress_id, 'random_id' => $random_id));
 }
开发者ID:flyapen,项目名称:v-observer,代码行数:37,代码来源:Mediamosa.php

示例5: show

 /**
  * Show a documentation page.
  *
  * @param  string $version
  * @param  string|null $page
  * @return Response
  */
 public function show($version, $page = null)
 {
     if (!$this->isVersion($version)) {
         return redirect('docs/' . DEFAULT_VERSION . '/' . $version, 301);
     }
     if (!defined('CURRENT_VERSION')) {
         define('CURRENT_VERSION', $version);
     }
     $sectionPage = $page ?: 'installation';
     $content = $this->docs->get($version, $sectionPage);
     if (is_null($content)) {
         abort(404);
     }
     $title = (new Crawler($content))->filterXPath('//h1');
     $section = '';
     if ($this->docs->sectionExists($version, $page)) {
         $section .= '/' . $page;
     } elseif (!is_null($page)) {
         return redirect('/docs/' . $version);
     }
     $canonical = null;
     if ($this->docs->sectionExists(DEFAULT_VERSION, $sectionPage)) {
         $canonical = 'docs/' . DEFAULT_VERSION . '/' . $sectionPage;
     }
     return view('docs', ['title' => count($title) ? $title->text() : null, 'index' => $this->docs->getIndex($version), 'content' => $content, 'currentVersion' => $version, 'versions' => Documentation::getDocVersions(), 'currentSection' => $section, 'canonical' => $canonical]);
 }
开发者ID:matriphe,项目名称:laravel.com,代码行数:33,代码来源:DocsController.php

示例6: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (!Auth::check()) {
         return redirect('home')->with('message', "Veuillez d'abord vous connecter");
     }
     $question = Question::find($id);
     if (is_null($question)) {
         abort(404);
     }
     $total_questions = Question::count();
     $user = Auth::user();
     $total_questions_replied = $user->questionsReplied()->count();
     $total_questions_replied_percent = round($total_questions_replied / $total_questions * 100);
     // Get the current user that will be the origin of our operations
     // Get ID of a User whose autoincremented ID is less than the current user, but because some entries might have been deleted we need to get the max available ID of all entries whose ID is less than current user's
     $previousQuestionID = Question::where('id', '<', $question->id)->max('id');
     // Same for the next user's id as previous user's but in the other direction
     $nextQuestionID = Question::where('id', '>', $question->id)->min('id');
     $replies = $question->getChoices();
     // if user already replied to this particular question
     if ($question->getAnswer()) {
         $replies[$question->getAnswer()]['checked'] = true;
         $question->replied = true;
     }
     return view('questions.show', compact('question', 'previousQuestionID', 'nextQuestionID', 'replies', 'total_questions', 'total_questions_replied', 'total_questions_replied_percent'));
 }
开发者ID:philippejadin,项目名称:mooc,代码行数:32,代码来源:QuestionsController.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (strtolower(Auth::staff()->get()->role->id) != 1 and strtolower(Auth::staff()->get()->role->id) != 2) {
         abort('404');
     }
     return $next($request);
 }
开发者ID:thomasdola,项目名称:afrouteWeb,代码行数:14,代码来源:AdminCheck.php

示例8: show

 /**
  * Display a user.
  *
  * @return Response
  */
 public function show(User $user)
 {
     if (Request::ajax()) {
         return $user;
     }
     abort(404);
 }
开发者ID:zedx,项目名称:core,代码行数:12,代码来源:UserController.php

示例9: renderArticle

 private function renderArticle($article)
 {
     if (!$article) {
         abort(404);
     }
     return view('article', compact('article'));
 }
开发者ID:sebastiandedeyne,项目名称:sebastiandedeyne.com,代码行数:7,代码来源:ArticleController.php

示例10: __construct

 /**
  * Abort if request is not ajax
  * @param Request $request
  */
 public function __construct(Request $request)
 {
     if (!$request->ajax() || !Datatable::shouldHandle()) {
         abort(403, 'Forbidden');
     }
     parent::__construct();
 }
开发者ID:santoshpawar,项目名称:laravel-5-simple-cms,代码行数:11,代码来源:DataTableController.php

示例11: handle

 /**
  * Ensure the app is running in the enviorment provided as parameter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string
  * @return mixed
  */
 public function handle($request, Closure $next, $enviorment)
 {
     if (app()->environment($enviorment)) {
         return $next($request);
     }
     return abort(404);
 }
开发者ID:nerea91,项目名称:laravel,代码行数:15,代码来源:Environment.php

示例12: detail

 function detail($imgtitle, $id)
 {
     // get single image
     $image = DB::table('wallpaper')->find($id);
     // find the title, if not match return 404
     if ($imgtitle !== $image->wallslug) {
         abort(404);
     }
     $short_title = str_slug($this->shortTitle($image->walltitle), '-');
     $vav = DB::table('wallpaper')->orderByRaw("RAND()")->take(mt_rand(3, 5))->get();
     // get related images (abal2)
     $relateds1 = DB::table('wallpaper')->orderBy('id', 'DESC')->skip(1)->take(3)->get();
     $relateds2 = DB::table('wallpaper')->orderBy('id', 'DESC')->skip(4)->take(3)->get();
     $relateds3 = DB::table('wallpaper')->orderBy('id', 'DESC')->skip(7)->take(3)->get();
     $recents = DB::table('wallpaper')->orderBy('id', 'DESC')->take(5)->get();
     $randimg = DB::table('wallpaper')->orderByRaw("RAND()")->take(3)->get();
     $randimg1 = DB::table('wallpaper')->orderByRaw("RAND()")->take(3)->skip(3)->get();
     $images = DB::table('wallpaper')->orderBy('wallview', 'DESC')->take(7)->get();
     $tags = DB::table('wallpaper')->orderByRaw("RAND()")->take(mt_rand(7, 11))->get();
     $alp = range('A', 'Z');
     $num = range(0, 9);
     // get categories
     $categories = $this->getCategory();
     return view('arkitekt.detail', compact('image', 'vav', 'vavsqq', 'short_title', 'short_title1', 'relateds1', 'relateds2', 'relateds3', 'recents', 'randimg', 'randimg1', 'images', 'tags', 'categories', 'alp', 'num'));
 }
开发者ID:kholidfu,项目名称:gludhag,代码行数:25,代码来源:PageController.php

示例13: validate_fields

 public function validate_fields()
 {
     if (!$this->form_validation->run($this->router->class)) {
         back_to_top();
         abort(validation_errors());
     }
 }
开发者ID:rogerioleal1,项目名称:ci_base,代码行数:7,代码来源:MY_Model.php

示例14: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     if (Gate::denies('addClient', new Client())) {
         abort(403, 'Not allowed');
     }
     return View::make('client.create');
 }
开发者ID:shirishmore,项目名称:timesheet,代码行数:12,代码来源:ClientController.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::admin()->check()) {
         return $next($request);
     }
     abort(404);
 }
开发者ID:bluecipherz,项目名称:gl-ct,代码行数:14,代码来源:AdminMiddleware.php


注:本文中的abort函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。