本文整理汇总了PHP中startup函数的典型用法代码示例。如果您正苦于以下问题:PHP startup函数的具体用法?PHP startup怎么用?PHP startup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startup函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_preflight
/**
* Perform preflight checks for Mercator
*
* Checks that we can actually run Mercator, then attaches the relevant actions
* and filters to make it useful.
*/
function run_preflight()
{
// Are we installing? Bail if so.
if (defined('WP_INSTALLING')) {
return;
}
// Are we still in sunrise stage?
if (did_action('muplugins_loaded')) {
warn_with_message('Mercator must be loaded in your <code>sunrise.php</code>. Check out the <a href="https://github.com/humanmade/Mercator/wiki/Installation">installation instructions</a>.');
return;
}
// Are we actually on multisite?
if (!is_multisite()) {
warn_with_message('Mercator requires WordPress to be in <a href="http://codex.wordpress.org/Create_A_Network">multisite mode</a>.');
return;
}
// Are we running a good version of WP?
if (!function_exists('get_site_by_path')) {
warn_with_message('Mercator requires <a href="https://wordpress.org/download/">WordPress 3.9</a> or newer. Update now.');
return;
}
// Check for COOKIE_DOMAIN definition
//
// Note that this can't be an admin notice, as you'd never be able to log in
// to see it.
if (defined('COOKIE_DOMAIN')) {
status_header(500);
header('X-Mercator: COOKIE_DOMAIN');
wp_die('The constant <code>COOKIE_DOMAIN</code> is defined (probably in <code>wp-config.php</code>). Please remove or comment out that <code>define()</code> line.');
}
// M: We have clearance, Clarence.
// O: Roger, Roger. What's our Vector Victor?
startup();
}
示例2: header
<?php
header('Content-Type: text/html; charset=utf-8');
//собираем всю информацию об защедщих на сайт
session_start();
include_once 'startup.php';
// Установка параметров, подключение к БД, запуск сессии.
startup();
//прооверяем, что мы админ
include 'variables.php';
if ($_SESSION['Guest_id']['id_user'] == $AdminID) {
include 'rss_scripts.php';
} else {
//echo 'Вы не Админ!!!';
}
echo "<br />";
//в дальнейшем бы надо закешировать структуры
//$_GET['avtor']='all';
//$_GET['avtor']='7';
$avtor = '';
if (isset($_POST['avtor'])) {
$_GET['avtor'] = $_POST['avtor'];
}
// include('MakeStructAvtArr.php');
if ($_GET['avtor'] != 'all') {
//если мы выводим структуру какого либо определенного автора, то просчитываем ее
include 'MakeStructAvtArr.php';
} else {
//если всех авторов, то вытаскиваем структуру из БД, куда ее запихиваем при всех изменениях авторов
$arrWho = array();
//вытаскиваем из БД
示例3: startup
<?php
require_once 'modules/startup.php';
require 'modules/classes.php';
require 'modules/repository.php';
$link = startup();
$id = $_GET['id'];
$article_get = ArticleRepo::load($link, $id);
$article_title = $article_get->getTitle();
$article_content = $article_get->getContent();
$getTitle = $article_title;
$img_get = array();
if (isset($_POST['edit'])) {
header("location: edit.php?id=" . $_GET['id']);
}
if (isset($_POST['delete'])) {
if (ArticleRepo::delete($link, $id)) {
header("location: editor.php");
}
}
if (is_dir("img_p")) {
$img_get = ImageRepo::loadAll($link, $id);
}
header('Content-type: text/html; charset=utf-8');
include 'views/header.php';
include 'views/v_article.php';
include 'views/footer.php';
示例4: __construct
/**
* App constructor.
*/
function __construct()
{
// we'll reset this after we read our config file
date_default_timezone_set('UTC');
$this->config = array('system' => array());
$this->page = array();
$this->pager = array();
$this->query_string = '';
startup();
set_include_path('include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
$this->scheme = 'http';
if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
$this->scheme = 'https';
} elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
$this->scheme = 'https';
}
if (x($_SERVER, 'SERVER_NAME')) {
$this->hostname = $_SERVER['SERVER_NAME'];
if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
}
/**
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
$path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
if (isset($path) && strlen($path) && $path != $this->path) {
$this->path = $path;
}
}
set_include_path("include/{$this->hostname}" . PATH_SEPARATOR . get_include_path());
if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
$this->query_string = substr($_SERVER['QUERY_STRING'], 2);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/") {
$this->query_string = substr($this->query_string, 1);
}
}
if (x($_GET, 'q')) {
$this->cmd = trim($_GET['q'], '/\\');
}
// unix style "homedir"
if (substr($this->cmd, 0, 1) === '~') {
$this->cmd = 'channel/' . substr($this->cmd, 1);
}
/*
* Break the URL path into C style argc/argv style arguments for our
* modules. Given "http://example.com/module/arg1/arg2", $this->argc
* will be 3 (integer) and $this->argv will contain:
* [0] => 'module'
* [1] => 'arg1'
* [2] => 'arg2'
*
* There will always be one argument. If provided a naked domain
* URL, $this->argv[0] is set to "home".
*/
$this->argv = explode('/', $this->cmd);
$this->argc = count($this->argv);
if (array_key_exists('0', $this->argv) && strlen($this->argv[0])) {
$this->module = str_replace(".", "_", $this->argv[0]);
$this->module = str_replace("-", "_", $this->module);
} else {
$this->argc = 1;
$this->argv = array('home');
$this->module = 'home';
}
/*
* See if there is any page number information, and initialise
* pagination
*/
$this->pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
$this->pager['itemspage'] = 60;
$this->pager['start'] = $this->pager['page'] * $this->pager['itemspage'] - $this->pager['itemspage'];
if ($this->pager['start'] < 0) {
$this->pager['start'] = 0;
}
$this->pager['total'] = 0;
/*
* Detect mobile devices
*/
$mobile_detect = new Mobile_Detect();
$this->is_mobile = $mobile_detect->isMobile();
$this->is_tablet = $mobile_detect->isTablet();
$this->head_set_icon('/images/rm-32.png');
BaseObject::set_app($this);
/*
* register template engines
*/
$dc = get_declared_classes();
foreach ($dc as $k) {
if (in_array("ITemplateEngine", class_implements($k))) {
$this->register_template_engine($k);
}
}
}
示例5: init
/**
* App constructor.
*/
public static function init()
{
// we'll reset this after we read our config file
date_default_timezone_set('UTC');
self::$config = array('system' => array());
self::$page = array();
self::$pager = array();
self::$query_string = '';
startup();
set_include_path('include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
self::$scheme = 'http';
if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
self::$scheme = 'https';
} elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
self::$scheme = 'https';
}
if (x($_SERVER, 'SERVER_NAME')) {
self::$hostname = $_SERVER['SERVER_NAME'];
if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
}
/**
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
$path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
if (isset($path) && strlen($path) && $path != self::$path) {
self::$path = $path;
}
}
set_include_path("include/self::{$hostname}" . PATH_SEPARATOR . get_include_path());
if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
self::$query_string = substr($_SERVER['QUERY_STRING'], 2);
// removing trailing / - maybe a nginx problem
if (substr(self::$query_string, 0, 1) == "/") {
self::$query_string = substr(self::$query_string, 1);
}
}
if (x($_GET, 'q')) {
self::$cmd = trim($_GET['q'], '/\\');
}
// unix style "homedir"
if (substr(self::$cmd, 0, 1) === '~') {
self::$cmd = 'channel/' . substr(self::$cmd, 1);
}
/*
* Break the URL path into C style argc/argv style arguments for our
* modules. Given "http://example.com/module/arg1/arg2", self::$argc
* will be 3 (integer) and self::$argv will contain:
* [0] => 'module'
* [1] => 'arg1'
* [2] => 'arg2'
*
* There will always be one argument. If provided a naked domain
* URL, self::$argv[0] is set to "home".
*/
self::$argv = explode('/', self::$cmd);
self::$argc = count(self::$argv);
if (array_key_exists('0', self::$argv) && strlen(self::$argv[0])) {
self::$module = str_replace(".", "_", self::$argv[0]);
self::$module = str_replace("-", "_", self::$module);
if (strpos(self::$module, '_') === 0) {
self::$module = substr(self::$module, 1);
}
} else {
self::$argc = 1;
self::$argv = array('home');
self::$module = 'home';
}
/*
* See if there is any page number information, and initialise
* pagination
*/
self::$pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
self::$pager['itemspage'] = 60;
self::$pager['start'] = self::$pager['page'] * self::$pager['itemspage'] - self::$pager['itemspage'];
if (self::$pager['start'] < 0) {
self::$pager['start'] = 0;
}
self::$pager['total'] = 0;
/*
* Detect mobile devices
*/
$mobile_detect = new Mobile_Detect();
self::$is_mobile = $mobile_detect->isMobile();
self::$is_tablet = $mobile_detect->isTablet();
self::head_set_icon('/images/hz-32.png');
/*
* register template engines
*/
spl_autoload_register('ZotlabsAutoloader::loader');
self::$meta = new Zotlabs\Web\HttpMeta();
// create an instance of the smarty template engine so we can register it.
$smarty = new Zotlabs\Render\SmartyTemplate();
$dc = get_declared_classes();
foreach ($dc as $k) {
if (in_array('Zotlabs\\Render\\TemplateEngine', class_implements($k))) {
//.........这里部分代码省略.........
示例6: __construct
function __construct()
{
global $default_timezone, $argv, $argc;
$this->timezone = x($default_timezone) ? $default_timezone : 'UTC';
date_default_timezone_set($this->timezone);
$this->performance["start"] = microtime(true);
$this->performance["database"] = 0;
$this->performance["network"] = 0;
$this->performance["rendering"] = 0;
$this->performance["parser"] = 0;
$this->performance["marktime"] = 0;
$this->performance["markstart"] = microtime(true);
$this->config = array();
$this->page = array();
$this->pager = array();
$this->query_string = '';
startup();
$this->scheme = 'http';
if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
$this->scheme = 'https';
} elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
$this->scheme = 'https';
}
if (x($_SERVER, 'SERVER_NAME')) {
$this->hostname = $_SERVER['SERVER_NAME'];
// See bug 437 - this didn't work so disabling it
//if(stristr($this->hostname,'xn--')) {
// PHP or webserver may have converted idn to punycode, so
// convert punycode back to utf-8
// require_once('library/simplepie/idn/idna_convert.class.php');
// $x = new idna_convert();
// $this->hostname = $x->decode($_SERVER['SERVER_NAME']);
//}
if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
}
/**
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
$path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
if (isset($path) && strlen($path) && $path != $this->path) {
$this->path = $path;
}
}
if (is_array($argv) && $argc > 1 && substr(end($argv), 0, 4) == "http") {
$this->set_baseurl(array_pop($argv));
$argc--;
}
set_include_path("include/{$this->hostname}" . PATH_SEPARATOR . 'include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
$this->query_string = substr($_SERVER['QUERY_STRING'], 2);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/") {
$this->query_string = substr($this->query_string, 1);
}
}
if (x($_GET, 'q')) {
$this->cmd = trim($_GET['q'], '/\\');
}
// unix style "homedir"
if (substr($this->cmd, 0, 1) === '~') {
$this->cmd = 'profile/' . substr($this->cmd, 1);
}
// Diaspora style profile url
if (substr($this->cmd, 0, 2) === 'u/') {
$this->cmd = 'profile/' . substr($this->cmd, 2);
}
/**
*
* Break the URL path into C style argc/argv style arguments for our
* modules. Given "http://example.com/module/arg1/arg2", $this->argc
* will be 3 (integer) and $this->argv will contain:
* [0] => 'module'
* [1] => 'arg1'
* [2] => 'arg2'
*
*
* There will always be one argument. If provided a naked domain
* URL, $this->argv[0] is set to "home".
*
*/
$this->argv = explode('/', $this->cmd);
$this->argc = count($this->argv);
if (array_key_exists('0', $this->argv) && strlen($this->argv[0])) {
$this->module = str_replace(".", "_", $this->argv[0]);
$this->module = str_replace("-", "_", $this->module);
} else {
$this->argc = 1;
$this->argv = array('home');
$this->module = 'home';
}
/**
* See if there is any page number information, and initialise
* pagination
*/
$this->pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
$this->pager['itemspage'] = 50;
$this->pager['start'] = $this->pager['page'] * $this->pager['itemspage'] - $this->pager['itemspage'];
if ($this->pager['start'] < 0) {
//.........这里部分代码省略.........
示例7: __construct
function __construct()
{
$this->config = array();
$this->page = array();
$this->pager = array();
$this->query_string = '';
startup();
$this->scheme = 'http';
if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
$this->scheme = 'https';
} elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
$this->scheme = 'https';
}
if (x($_SERVER, 'SERVER_NAME')) {
$this->hostname = $_SERVER['SERVER_NAME'];
if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
}
/**
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
$path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
if (isset($path) && strlen($path) && $path != $this->path) {
$this->path = $path;
}
}
set_include_path("include/{$this->hostname}" . PATH_SEPARATOR . 'include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR . '.');
if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
$this->query_string = substr($_SERVER['QUERY_STRING'], 2);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/") {
$this->query_string = substr($this->query_string, 1);
}
}
if (x($_GET, 'q')) {
$this->cmd = trim($_GET['q'], '/\\');
}
// unix style "homedir"
if (substr($this->cmd, 0, 1) === '~') {
$this->cmd = 'profile/' . substr($this->cmd, 1);
}
// Diaspora style profile url
if (substr($this->cmd, 0, 2) === 'u/') {
$this->cmd = 'profile/' . substr($this->cmd, 2);
}
/**
*
* Break the URL path into C style argc/argv style arguments for our
* modules. Given "http://example.com/module/arg1/arg2", $this->argc
* will be 3 (integer) and $this->argv will contain:
* [0] => 'module'
* [1] => 'arg1'
* [2] => 'arg2'
*
*
* There will always be one argument. If provided a naked domain
* URL, $this->argv[0] is set to "home".
*
*/
$this->argv = explode('/', $this->cmd);
$this->argc = count($this->argv);
if (array_key_exists('0', $this->argv) && strlen($this->argv[0])) {
$this->module = str_replace(".", "_", $this->argv[0]);
if (array_key_exists('2', $this->argv)) {
$this->category = $this->argv[2];
}
} else {
$this->argc = 1;
$this->argv = array('home');
$this->module = 'home';
}
/**
* Special handling for the webfinger/lrdd host XRD file
*/
if ($this->cmd === '.well-known/host-meta') {
$this->argc = 1;
$this->argv = array('hostxrd');
$this->module = 'hostxrd';
}
/**
* See if there is any page number information, and initialise
* pagination
*/
$this->pager['page'] = x($_GET, 'page') ? $_GET['page'] : 1;
$this->pager['itemspage'] = 50;
$this->pager['start'] = $this->pager['page'] * $this->pager['itemspage'] - $this->pager['itemspage'];
$this->pager['total'] = 0;
}
示例8: handle_data
function handle_data($data, $is_sock = False, $auth = False, $exec = False)
{
global $buckets;
global $alias_locks;
global $dest_overrides;
global $admin_accounts;
global $admin_data;
global $admin_is_sock;
global $admin_aliases;
global $exec_errors;
global $exec_list;
global $throttle_time;
global $ignore_list;
if ($auth == False) {
echo "[33m" . date("Y-m-d H:i:s", microtime(True)) . " > [0m{$data}";
handle_errors($data);
} else {
term_echo("*** auth = true");
}
$items = parse_data($data);
if ($items !== False) {
write_out_buffer_data($items);
if ($items["destination"] == DEBUG_CHAN) {
return;
}
if ($auth == False and $is_sock == True) {
log_items($items);
}
if (in_array($items["nick"], $ignore_list) == True) {
return;
}
if (isset($buckets[BUCKET_IGNORE_NEXT]) == True and $items["nick"] == get_bot_nick()) {
unset($buckets[BUCKET_IGNORE_NEXT]);
return;
}
if ($items["prefix"] == IRC_HOST and strpos(strtolower($items["trailing"]), "throttled") !== False) {
term_echo("*** THROTTLED BY SERVER - REFUSING ALL OUTGOING MESSAGES TO SERVER FOR " . THROTTLE_LOCKOUT_TIME . " SECONDS ***");
$throttle_time = microtime(True);
return;
}
if ($items["cmd"] == 330) {
authenticate($items);
}
if ($items["cmd"] == 376) {
dojoin(INIT_CHAN_LIST);
}
if ($items["cmd"] == "NOTICE" and $items["nick"] == "NickServ" and $items["trailing"] == NICKSERV_IDENTIFY_PROMPT) {
if (file_exists(PASSWORD_FILE) == True and NICKSERV_IDENTIFY === "1") {
rawmsg("NickServ IDENTIFY " . trim(file_get_contents(PASSWORD_FILE)), True);
}
startup();
}
$args = explode(" ", $items["trailing"]);
if (in_array($args[0], $admin_aliases) == True or has_account_list($args[0]) == True) {
if ($auth == False and $is_sock == True) {
term_echo("authenticating \"" . $args[0] . "\"...");
$admin_data = $items["data"];
$admin_is_sock = $is_sock;
rawmsg("WHOIS " . $items["nick"]);
return;
}
}
$alias = $args[0];
handle_events($items);
switch ($alias) {
case ALIAS_ADMIN_NICK:
if (count($args) == 2) {
rawmsg(":" . get_bot_nick() . " NICK :" . trim($args[1]));
set_bot_nick(trim($args[1]));
}
break;
case ALIAS_ADMIN_QUIT:
if (count($args) == 1) {
write_out_buffer_command($items, "quit");
process_scripts($items, ALIAS_QUIT);
}
break;
case ALIAS_ADMIN_PS:
if (count($args) == 1) {
write_out_buffer_command($items, "ps");
ps($items);
}
break;
case ALIAS_ADMIN_KILL:
if (count($args) == 2) {
write_out_buffer_command($items, "kill");
kill($items, $args[1]);
}
break;
case ALIAS_ADMIN_KILLALL:
if (count($args) == 1) {
write_out_buffer_command($items, "killall");
killall($items);
}
break;
case ALIAS_LIST:
if (check_nick($items, $alias) == True) {
if (count($args) == 1) {
write_out_buffer_command($items, "list");
get_list($items);
//.........这里部分代码省略.........
示例9: error_reporting
if (DEBUG) {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');
}
//session_start();
require_once 'config.php';
require_once MODELS_DIR . '/JL.php';
/*
//Создаём новый объект. Также можно писать и в процедурном стиле
$MC = new Memcache;
//Соединяемся с нашим сервером
$MC->connect('127.0.0.1', 11211) or die("Could not connect");
*/
require_once 'core/Controller.php';
spl_autoload_register('JL::AutoLoad');
global $DB;
$DB = startup();
if (isset($_GET['type'])) {
$contr = 'C_' . $_GET['type'];
if (isset($_GET['module'])) {
$contr = 'C_' . $_GET['module'] . '_' . $_GET['type'];
}
echo $contr;
$controller = new $contr();
} else {
$controller = new C_Index();
}
$controller->Request();
//Закрываем соединение с сервером Memcached
//$MC->close();
示例10: before
protected function before()
{
startup();
$this->title = 'Название сайта';
$this->content = '';
}