Pressroom template verwijderd, website naar root van repo

This commit is contained in:
2020-03-22 15:30:52 +01:00
parent 2cb6a77425
commit f3d1c41e91
7620 changed files with 0 additions and 186900 deletions

View File

@@ -0,0 +1,178 @@
<?php
namespace Illuminate\Cookie;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Cookie\QueueingFactory as JarContract;
class CookieJar implements JarContract
{
/**
* The default path (if specified).
*
* @var string
*/
protected $path = '/';
/**
* The default domain (if specified).
*
* @var string
*/
protected $domain;
/**
* The default secure setting (defaults to false).
*
* @var bool
*/
protected $secure = false;
/**
* All of the cookies queued for sending.
*
* @var array
*/
protected $queued = [];
/**
* Create a new cookie instance.
*
* @param string $name
* @param string $value
* @param int $minutes
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
{
list($path, $domain, $secure) = $this->getPathAndDomain($path, $domain, $secure);
$time = ($minutes == 0) ? 0 : Carbon::now()->getTimestamp() + ($minutes * 60);
return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
}
/**
* Create a cookie that lasts "forever" (five years).
*
* @param string $name
* @param string $value
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true)
{
return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly);
}
/**
* Expire the given cookie.
*
* @param string $name
* @param string $path
* @param string $domain
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forget($name, $path = null, $domain = null)
{
return $this->make($name, null, -2628000, $path, $domain);
}
/**
* Determine if a cookie has been queued.
*
* @param string $key
* @return bool
*/
public function hasQueued($key)
{
return ! is_null($this->queued($key));
}
/**
* Get a queued cookie instance.
*
* @param string $key
* @param mixed $default
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function queued($key, $default = null)
{
return Arr::get($this->queued, $key, $default);
}
/**
* Queue a cookie to send with the next response.
*
* @param array $parameters
* @return void
*/
public function queue(...$parameters)
{
if (head($parameters) instanceof Cookie) {
$cookie = head($parameters);
} else {
$cookie = call_user_func_array([$this, 'make'], $parameters);
}
$this->queued[$cookie->getName()] = $cookie;
}
/**
* Remove a cookie from the queue.
*
* @param string $name
* @return void
*/
public function unqueue($name)
{
unset($this->queued[$name]);
}
/**
* Get the path and domain, or the default values.
*
* @param string $path
* @param string $domain
* @param bool $secure
* @return array
*/
protected function getPathAndDomain($path, $domain, $secure = false)
{
return [$path ?: $this->path, $domain ?: $this->domain, $secure ?: $this->secure];
}
/**
* Set the default path and domain for the jar.
*
* @param string $path
* @param string $domain
* @param bool $secure
* @return $this
*/
public function setDefaultPathAndDomain($path, $domain, $secure = false)
{
list($this->path, $this->domain, $this->secure) = [$path, $domain, $secure];
return $this;
}
/**
* Get the cookies which have been queued for the next request.
*
* @return array
*/
public function getQueuedCookies()
{
return $this->queued;
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Illuminate\Cookie;
use Illuminate\Support\ServiceProvider;
class CookieServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('cookie', function ($app) {
$config = $app->make('config')->get('session');
return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain'], $config['secure']);
});
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Illuminate\Cookie\Middleware;
use Closure;
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
class AddQueuedCookiesToResponse
{
/**
* The cookie jar instance.
*
* @var \Illuminate\Contracts\Cookie\QueueingFactory
*/
protected $cookies;
/**
* Create a new CookieQueue instance.
*
* @param \Illuminate\Contracts\Cookie\QueueingFactory $cookies
* @return void
*/
public function __construct(CookieJar $cookies)
{
$this->cookies = $cookies;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
foreach ($this->cookies->getQueuedCookies() as $cookie) {
$response->headers->setCookie($cookie);
}
return $response;
}
}

View File

@@ -0,0 +1,163 @@
<?php
namespace Illuminate\Cookie\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
class EncryptCookies
{
/**
* The encrypter instance.
*
* @var \Illuminate\Contracts\Encryption\Encrypter
*/
protected $encrypter;
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [];
/**
* Create a new CookieGuard instance.
*
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @return void
*/
public function __construct(EncrypterContract $encrypter)
{
$this->encrypter = $encrypter;
}
/**
* Disable encryption for the given cookie name(s).
*
* @param string|array $cookieName
* @return void
*/
public function disableFor($cookieName)
{
$this->except = array_merge($this->except, (array) $cookieName);
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $this->encrypt($next($this->decrypt($request)));
}
/**
* Decrypt the cookies on the request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Request
*/
protected function decrypt(Request $request)
{
foreach ($request->cookies as $key => $c) {
if ($this->isDisabled($key)) {
continue;
}
try {
$request->cookies->set($key, $this->decryptCookie($c));
} catch (DecryptException $e) {
$request->cookies->set($key, null);
}
}
return $request;
}
/**
* Decrypt the given cookie and return the value.
*
* @param string|array $cookie
* @return string|array
*/
protected function decryptCookie($cookie)
{
return is_array($cookie)
? $this->decryptArray($cookie)
: $this->encrypter->decrypt($cookie);
}
/**
* Decrypt an array based cookie.
*
* @param array $cookie
* @return array
*/
protected function decryptArray(array $cookie)
{
$decrypted = [];
foreach ($cookie as $key => $value) {
if (is_string($value)) {
$decrypted[$key] = $this->encrypter->decrypt($value);
}
}
return $decrypted;
}
/**
* Encrypt the cookies on an outgoing response.
*
* @param \Symfony\Component\HttpFoundation\Response $response
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function encrypt(Response $response)
{
foreach ($response->headers->getCookies() as $cookie) {
if ($this->isDisabled($cookie->getName())) {
continue;
}
$response->headers->setCookie($this->duplicate(
$cookie, $this->encrypter->encrypt($cookie->getValue())
));
}
return $response;
}
/**
* Duplicate a cookie with a new value.
*
* @param \Symfony\Component\HttpFoundation\Cookie $c
* @param mixed $value
* @return \Symfony\Component\HttpFoundation\Cookie
*/
protected function duplicate(Cookie $c, $value)
{
return new Cookie(
$c->getName(), $value, $c->getExpiresTime(), $c->getPath(),
$c->getDomain(), $c->isSecure(), $c->isHttpOnly()
);
}
/**
* Determine whether encryption has been disabled for the given cookie.
*
* @param string $name
* @return bool
*/
public function isDisabled($name)
{
return in_array($name, $this->except);
}
}

View File

@@ -0,0 +1,37 @@
{
"name": "illuminate/cookie",
"description": "The Illuminate Cookie package.",
"license": "MIT",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"require": {
"php": ">=5.6.4",
"illuminate/contracts": "5.4.*",
"illuminate/support": "5.4.*",
"symfony/http-foundation": "~3.2",
"symfony/http-kernel": "~3.2"
},
"autoload": {
"psr-4": {
"Illuminate\\Cookie\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "5.4-dev"
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev"
}