本文整理汇总了PHP中server::get方法的典型用法代码示例。如果您正苦于以下问题:PHP server::get方法的具体用法?PHP server::get怎么用?PHP server::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server
的用法示例。
在下文中一共展示了server::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
s::start();
c::set('home.keepurl', true);
// auto-detect the url if it is not set
if (!c::get('url')) {
c::set('url', c::get('scheme') . server::get('http_host'));
}
// setup the thumb plugin
c::set('thumb.cache.root', c::get('root') . '/thumbs');
c::set('thumb.cache.url', c::get('url') . '/thumbs');
c::set('url', c::get('url') . '/' . c::get('panel.folder'));
// remove the panel folder name from the uri
c::set('subfolder', ltrim(c::get('subfolder') . '/' . c::get('panel.folder'), '/'));
// attach the uri after caching
$this->uri = new paneluri();
if (c::get('lang.support')) {
$path = $this->uri->path->toArray();
$first = array_shift($path);
if (!in_array($first, c::get('lang.available', array()))) {
$first = c::get('lang.default');
}
// set the current language
c::set('lang.current', $first);
$this->uri->path = new uriPath($path);
}
// get the first set of pages
$this->rootPages();
// get the additional site info from content/site.txt
$this->siteInfo();
}
示例2: current
/**
* Returns the current url with all bells and whistles
*
* @return string
*/
public static function current()
{
if (!is_null(static::$current)) {
return static::$current;
}
return static::$current = static::scheme() . '://' . server::get('HTTP_HOST') . server::get('REQUEST_URI');
}
示例3: raw
function raw($uri = false)
{
$raw = $uri ? $uri : ltrim(server::get('request_uri'), '/');
// strip subfolders from uri
if (c::get('subfolder')) {
$raw = ltrim(str_replace(c::get('subfolder') . '/', '/', $raw), '/');
}
return $raw;
}
示例4: config
static function config()
{
parent::config();
// load the default panel config file
self::file(c::get('root.panel') . '/defaults/config/config.php');
$root = c::get('root.site') . '/' . c::get('panel.folder') . '/config';
self::file($root . '/config.php');
self::file($root . '/config.' . server::get('server_name') . '.php');
}
示例5: raw
static function raw($uri = false)
{
$raw = $uri ? $uri : ltrim(server::get('request_uri'), '/');
// strip subfolders from uri
if (c::get('subfolder')) {
$raw = ltrim(preg_replace('!^' . preg_quote(c::get('subfolder')) . '\\/!i', '/', $raw), '/');
}
return $raw;
}
示例6: configure
public function configure()
{
// load all available config files
$root = $this->roots()->config();
$configs = array('main' => 'config.php', 'host' => 'config.' . server::get('SERVER_NAME') . '.php', 'addr' => 'config.' . server::get('SERVER_ADDR') . '.php');
$allowed = array_filter(dir::read($root), function ($file) {
return substr($file, 0, 7) === 'config.' and substr($file, -4) === '.php';
});
foreach ($configs as $config) {
$file = $root . DS . $config;
if (in_array($config, $allowed, true) and file_exists($file)) {
include_once $file;
}
}
// apply the options
$this->options = array_merge($this->options, c::$data);
// overwrite the autodetected url
if ($this->options['url']) {
$this->urls->index = $this->options['url'];
}
// connect the url class with its handlers
url::$home = $this->urls()->index();
url::$to = $this->option('url.to', function ($url = '') {
if (url::isAbsolute($url)) {
return $url;
}
$start = substr($url, 0, 1);
switch ($start) {
case '#':
return $url;
break;
case '.':
return page()->url() . '/' . $url;
break;
default:
// don't convert absolute urls
return url::makeAbsolute($url);
break;
}
});
// setup the thumbnail generator
thumb::$defaults['root'] = $this->roots->thumbs();
thumb::$defaults['url'] = $this->urls->thumbs();
thumb::$defaults['driver'] = $this->option('thumbs.driver');
thumb::$defaults['filename'] = $this->option('thumbs.filename');
// simple error handling
if ($this->options['debug'] === true) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
} else {
if ($this->options['debug'] === false) {
error_reporting(0);
ini_set('display_errors', 0);
}
}
}
示例7: index
public function index()
{
if (isset($this->index)) {
return $this->index;
}
if (r::cli()) {
return $this->index = '/';
} else {
return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
}
}
示例8: index
public function index($text = null, $exception = null)
{
$this->auth();
if (is_null($text)) {
$text = l('pages.error.missing');
}
if (server::get('HTTP_MODAL')) {
return $this->modal('error', array('text' => $text, 'back' => url::last()));
} else {
return $this->screen('error/index', 'error', array('text' => $text, 'exception' => $exception));
}
}
示例9: index
public function index()
{
if (isset($this->index)) {
return $this->index;
}
// this value is used by the Panel
$this->indexDetected = true;
if (r::cli()) {
return $this->index = '/';
} else {
return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
}
}
示例10: testSanitization
public function testSanitization()
{
$_SERVER['HTTP_HOST'] = '<script>alert("xss")</script>';
$_SERVER['SERVER_NAME'] = '<script>alert("xss")</script>';
$this->assertEquals('alertxss', server::get('HTTP_HOST'));
$this->assertEquals('alertxss', server::get('SERVER_NAME'));
$_SERVER['HTTP_HOST'] = '127.0.0.1';
$_SERVER['SERVER_NAME'] = '127.0.0.1';
$this->assertEquals('127.0.0.1', server::get('HTTP_HOST'));
$this->assertEquals('127.0.0.1', server::get('SERVER_NAME'));
$_SERVER['SERVER_PORT'] = '<script>alert("xss")</script>999';
$this->assertEquals('999', server::get('SERVER_PORT'));
}
示例11: __construct
function __construct($uri = false)
{
// set the defaults
$this->path = new uriPath();
$this->params = new uriParams();
$this->query = new uriQuery(str::parse(server::get('query_string'), 'query'));
$this->extension = false;
$this->original = $_SERVER['REQUEST_URI'];
$this->raw = $this->raw($uri);
$this->url = url(ltrim($this->raw, '/'));
// crawl the uri and get all elements
$this->crawl();
}
示例12: configure
public static function configure()
{
if (is_null(static::$site)) {
static::$site = kirby::panelsetup();
}
// load all available routes
static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'api.php');
static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'views.php');
// setup the blueprint root
blueprint::$root = c::get('root.site') . DS . 'blueprints';
// start the router
static::$router = new Router();
static::$router->register(static::$routes);
// content language switcher variable
if (static::$site->multilang()) {
if ($language = server::get('http_language') or $language = s::get('lang')) {
static::$site->visit('/', $language);
}
app::$language = static::$site->language()->code();
s::set('lang', app::$language);
}
// load the interface language file
if (static::$site->user()) {
$languageCode = static::$site->user()->language();
} else {
$languageCode = c::get('panel.language', 'en');
}
// validate the language code
if (!in_array($languageCode, static::languages()->keys())) {
$languageCode = 'en';
}
// store the interface language
app::$interfaceLanguage = $languageCode;
$language = (require root('panel.app.languages') . DS . $languageCode . '.php');
// set all language variables
l::$data = $language['data'];
// register router filters
static::$router->filter('auth', function () {
if (!app::$site->user()) {
go('panel/login');
}
});
// check for a completed installation
static::$router->filter('isInstalled', function () {
if (app::$site->users()->count() == 0) {
go('panel/install');
}
});
// only use the fragments of the path without params
static::$path = implode('/', (array) url::fragments(detect::path()));
}
示例13: index
public function index()
{
if (isset($this->index)) {
return $this->index;
}
if (r::cli()) {
$index = '/';
} else {
$index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
}
// fix index URL for the Panel
if (function_exists('panel')) {
$index = dirname($index);
}
return $this->index = $index;
}
示例14: configure
public function configure()
{
// load all available config files
$root = $this->roots()->config();
$configs = array('main' => $root . DS . 'config.php', 'host' => $root . DS . 'config.' . server::get('HTTP_HOST') . '.php', 'addr' => $root . DS . 'config.' . server::get('SERVER_ADDR') . '.php');
foreach ($configs as $config) {
if (file_exists($config)) {
include_once $config;
}
}
// apply the options
$this->options = array_merge($this->options, c::$data);
// connect the url class with its handlers
url::$home = $this->urls()->index();
url::$to = $this->option('url.to', function ($url = '') {
if (url::isAbsolute($url)) {
return $url;
}
$start = substr($url, 0, 1);
switch ($start) {
case '#':
return $url;
break;
case '.':
return page()->url() . '/' . $url;
break;
default:
// don't convert absolute urls
return url::makeAbsolute($url);
break;
}
});
// setup the thumbnail generator
thumb::$defaults['root'] = $this->roots->thumbs();
thumb::$defaults['url'] = $this->urls->thumbs();
thumb::$defaults['driver'] = $this->option('thumbs.driver');
thumb::$defaults['filename'] = $this->option('thumbs.filename');
// simple error handling
if ($this->option('debug')) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
} else {
error_reporting(0);
ini_set('display_errors', 0);
}
}
示例15: license
public function license()
{
$key = c::get('license');
$type = 'trial';
/**
* Hey stranger,
*
* So this is the mysterious place where the panel checks for
* valid licenses. As you can see, this is not reporting
* back to any server and the license keys are rather simple to
* hack. If you really feel like removing the warning in the panel
* or tricking Kirby into believing you bought a valid license even
* if you didn't, go for it! But remember that literally thousands of
* hours of work have gone into Kirby in order to make your
* life as a developer, designer, publisher, etc. easier. If this
* doesn't mean anything to you, you are probably a lost case anyway.
*
* Have a great day!
*
* Bastian
*/
if (str::startsWith($key, 'K2-PRO') and str::length($key) == 39) {
$type = 'Kirby 2 Professional';
} else {
if (str::startsWith($key, 'K2-PERSONAL') and str::length($key) == 44) {
$type = 'Kirby 2 Personal';
} else {
if (str::startsWith($key, 'MD-') and str::length($key) == 35) {
$type = 'Kirby 1';
} else {
if (str::startsWith($key, 'BETA') and str::length($key) == 9) {
$type = 'Kirby 1';
} else {
if (str::length($key) == 32) {
$type = 'Kirby 1';
} else {
$key = null;
}
}
}
}
}
$localhosts = array('::1', '127.0.01', '0.0.0.0');
return new Obj(array('key' => $key, 'local' => in_array(server::get('SERVER_ADDR'), $localhosts) or server::get('SERVER_NAME') == 'localhost', 'type' => $type));
}