本文整理汇总了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);
}
示例2: __costruct
public function __costruct()
{
$auth = auth()->guard('admin');
if (!$auth->check()) {
abort(403, "Anda tidak memiliki hak akses ke halaman ini");
}
}
示例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');
}
}
示例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));
}
示例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]);
}
示例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'));
}
示例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);
}
示例8: show
/**
* Display a user.
*
* @return Response
*/
public function show(User $user)
{
if (Request::ajax()) {
return $user;
}
abort(404);
}
示例9: renderArticle
private function renderArticle($article)
{
if (!$article) {
abort(404);
}
return view('article', compact('article'));
}
示例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();
}
示例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);
}
示例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'));
}
示例13: validate_fields
public function validate_fields()
{
if (!$this->form_validation->run($this->router->class)) {
back_to_top();
abort(validation_errors());
}
}
示例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');
}
示例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);
}