本文整理汇总了PHP中r::secure方法的典型用法代码示例。如果您正苦于以下问题:PHP r::secure方法的具体用法?PHP r::secure怎么用?PHP r::secure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r
的用法示例。
在下文中一共展示了r::secure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
/**
* Starts a new session
*
* <code>
*
* s::start();
* // do whatever you want with the session now
*
* </code>
*
*/
public static function start()
{
if (session_status() === PHP_SESSION_ACTIVE) {
return true;
}
// store the session name
static::$cookie += array('lifetime' => 0, 'path' => ini_get('session.cookie_path'), 'domain' => ini_get('session.cookie_domain'), 'secure' => r::secure(), 'httponly' => true);
// set the custom session name
session_name(static::$name);
// make sure to use cookies only
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
// try to start the session
if (!session_start()) {
return false;
}
if (!setcookie(static::$name, session_id(), cookie::lifetime(static::$cookie['lifetime']), static::$cookie['path'], static::$cookie['domain'], static::$cookie['secure'], static::$cookie['httponly'])) {
return false;
}
// mark it as started
static::$started = true;
// check if the session is still valid
if (!static::check()) {
return static::destroy();
}
return true;
}
示例2: __construct
public function __construct($kirby, $root)
{
// check requirements
$this->requirements();
// store the instance as a singleton
static::$instance = $this;
$this->kirby = $kirby;
$this->roots = new \Kirby\Panel\Roots($this, $root);
$this->urls = new \Kirby\Panel\Urls($this, $root);
// add the panel default options
$this->kirby->options = array_merge($this->defaults(), $this->kirby->options);
// setup the blueprints roots
UserBlueprint::$root = $this->kirby->roots()->blueprints() . DS . 'users';
PageBlueprint::$root = $this->kirby->roots()->blueprints();
// load the site object
$this->site = $this->site();
// setup the session
$this->session();
// setup the multilang site stuff
$this->multilang();
// load all Kirby extensions (methods, tags, smartypants)
$this->kirby->extensions();
$this->kirby->plugins();
// setup the form plugin
form::$root = array('default' => $this->roots->fields, 'custom' => $this->kirby->roots()->fields());
// force ssl if set in config
if ($this->kirby->option('ssl') and !r::secure()) {
// rebuild the current url with https
go(url::build(array('scheme' => 'https')));
}
// load all available routes
$this->routes = array_merge($this->routes, require $this->roots->config . DS . 'routes.php');
// start the router
$this->router = new Router($this->routes);
// register router filters
$this->router->filter('auth', function () use($kirby) {
try {
$user = panel()->user();
} catch (Exception $e) {
panel()->redirect('login');
}
});
// check for a completed installation
$this->router->filter('isInstalled', function () use($kirby) {
$installer = new Installer();
if (!$installer->isCompleted()) {
panel()->redirect('install');
}
});
// check for valid csrf tokens. Can be used for get requests
// since all post requests are blocked anyway
$this->router->filter('csrf', function () {
panel()->csrfCheck();
});
// csrf protection for every post request
if (r::is('post')) {
$this->csrfCheck();
}
}
示例3: launch
/**
* Starts the router, renders the page and returns the response
*
* @return mixed
*/
public function launch()
{
// this will trigger the configuration
$site = $this->site();
// force secure connections if enabled
if ($this->option('ssl') and !r::secure()) {
// rebuild the current url with https
go(url::build(array('scheme' => 'https')));
}
// set the timezone for all date functions
date_default_timezone_set($this->options['timezone']);
// load all extensions
$this->extensions();
// load all plugins
$this->plugins();
// load all models
$this->models();
// start the router
$this->router = new Router($this->routes());
$this->route = $this->router->run($this->path());
// check for a valid route
if (is_null($this->route)) {
header::status('500');
header::type('json');
die(json_encode(array('status' => 'error', 'message' => 'Invalid route or request method')));
}
// call the router action with all arguments from the pattern
$response = call($this->route->action(), $this->route->arguments());
// load all language variables
// this can only be loaded once the router action has been called
// otherwise the current language is not yet available
$this->localize();
// build the response
$this->response = $this->component('response')->make($response);
// store the current language in the session
if ($this->site()->multilang() && ($language = $this->site()->language())) {
s::set('language', $language->code());
}
return $this->response;
}
示例4: testSsl
public function testSsl()
{
$this->assertFalse(r::ssl());
$this->assertFalse(r::secure());
}