本文整理汇总了PHP中vB::initialized方法的典型用法代码示例。如果您正苦于以下问题:PHP vB::initialized方法的具体用法?PHP vB::initialized怎么用?PHP vB::initialized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB
的用法示例。
在下文中一共展示了vB::initialized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initializes the vB framework.
* All framework level objects and services are created so that they are available
* throughout the application. This is only done once per actual request.
*
* Note: If the framework is used this way then there are several limitations.
* - If no vB_Bootstrap was created (ie, the admincp), then you cannot render any
* views created by the framework.
* - VB_ENTRY must be defined to a valid request script that runs the framework
* with vB::Main()
* - If you are rendering views, try to create all of the views that will be
* used before rendering any of them. This optimises template and phrase
* fetching.
*/
public static function init($relative_path = false)
{
global $vbulletin, $vbphrase;
if (self::$initialized) {
return;
}
// Reference legacy registry
self::$vbulletin = $vbulletin;
// Legacy DB
self::$db = $vbulletin->db;
// Set a top level exception handler
set_exception_handler(array('vB', 'handleException'));
// Set unserializer to use spl registered autoloader
ini_set('unserialize_callback_func', 'spl_autoload_call');
// Set class autoloader
spl_autoload_register(array('vB', 'autoload'));
// Legacy language
vB_Phrase::setLanguage(!empty(self::$vbulletin->session->vars['languageid']) ? self::$vbulletin->session->vars['languageid'] : intval(self::$vbulletin->options['languageid']));
vB_Phrase::preCache($vbphrase, $GLOBALS['phrasegroups']);
// Ensure we have friendly url class
require_once DIR . '/includes/class_friendly_url.php';
if ($relative_path) {
vB_Router::setRelativePath($relative_path);
}
// Done
self::$initialized = true;
}
示例2: init
/**
* Initializes the vB framework.
* All framework level objects and services are created so that they are available
* throughout the application. This is only done once per actual request.
*
* Note: If the framework is used this way then there are several limitations.
* - If no vB_Bootstrap was created (ie, the admincp), then you cannot render any
* views created by the framework.
* - VB_ENTRY must be defined to a valid request script that runs the framework
* with vB::Main()
* - If you are rendering views, try to create all of the views that will be
* used before rendering any of them. This optimises template and phrase
* fetching.
*/
public static function init($relative_path = false)
{
if (self::$initialized) {
return;
}
/**
* Set a bunch of constants.
*/
//We were getting CWD defined as something like '<install location>/vb5/..'
//This causes problems when uploading a default avatar, where we need to parse the path
//. It's much easier to decode if the path is just <install location>
if (!defined('CWD')) {
if (is_link(dirname($_SERVER["SCRIPT_FILENAME"]))) {
$cwd = dirname($_SERVER["SCRIPT_FILENAME"]) . DIRECTORY_SEPARATOR . 'core';
} else {
$cwd = dirname(__FILE__);
}
if (($pos = strrpos($cwd, DIRECTORY_SEPARATOR)) === false) {
//we can't figure this out.
define('CWD', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..');
} else {
define('CWD', substr($cwd, 0, $pos));
}
}
if (!defined('DIR')) {
define('DIR', CWD);
}
if (!defined('VB_PATH')) {
define('VB_PATH', DIR . '/vb/');
}
if (!defined('VB5_PATH')) {
define('VB5_PATH', DIR . '/vb5/');
}
if (!defined('VB_PKG_PATH')) {
define('VB_PKG_PATH', realpath(VB_PATH . '../packages') . '/');
}
if (!defined('VB_ENTRY')) {
define('VB_ENTRY', 1);
}
if (!defined('SIMPLE_VERSION')) {
define('SIMPLE_VERSION', '519');
}
/***
* Clean up the php environment
*/
if (isset($_REQUEST['GLOBALS']) or isset($_FILES['GLOBALS'])) {
echo 'Request tainting attempted.';
exit(4);
}
@ini_set('pcre.backtrack_limit', -1);
/* The min requirement for vB5 is 5.3.0,
so version checking here isnt necessary */
@date_default_timezone_set(date_default_timezone_get());
// Disabling magic quotes at runtime
// Code copied from PHP Manual: http://www.php.net/manual/en/security.magicquotes.disabling.php
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] =& $process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
// overwrite GET[x] and REQUEST[x] with POST[x] if it exists (overrides server's GPC order preference)
if (isset($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] == 'POST') {
foreach (array_keys($_POST) as $key) {
if (isset($_GET["{$key}"])) {
$_GET["{$key}"] = $_REQUEST["{$key}"] = $_POST["{$key}"];
}
}
}
// deal with cookies that may conflict with _GET and _POST data, and create our own _REQUEST with no _COOKIE input
foreach (array_keys($_COOKIE) as $varname) {
unset($_REQUEST["{$varname}"]);
if (isset($_POST["{$varname}"])) {
$_REQUEST["{$varname}"] =& $_POST["{$varname}"];
} else {
if (isset($_GET["{$varname}"])) {
$_REQUEST["{$varname}"] =& $_GET["{$varname}"];
//.........这里部分代码省略.........