first attempt to centralize all include loading
Classes are loaded throug PHP5's class autoloader, all other includes are just loaded by default. This skips a lot of require_once calls. Parser and Plugin stuff isn't handled by the class loader yet.
This commit is contained in:
parent
fcd3bb7cfe
commit
1690534421
7
doku.php
7
doku.php
|
@ -20,13 +20,8 @@ if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])){
|
|||
$ACT = 'show';
|
||||
}
|
||||
|
||||
// load and initialize the core system
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
require_once(DOKU_INC.'inc/common.php');
|
||||
require_once(DOKU_INC.'inc/events.php');
|
||||
require_once(DOKU_INC.'inc/pageutils.php');
|
||||
require_once(DOKU_INC.'inc/html.php');
|
||||
require_once(DOKU_INC.'inc/auth.php');
|
||||
require_once(DOKU_INC.'inc/actions.php');
|
||||
|
||||
//import variables
|
||||
$QUERY = trim($_REQUEST['id']);
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/HTTPClient.php');
|
||||
require_once(DOKU_INC.'inc/SimplePie.php');
|
||||
|
||||
|
||||
/**
|
||||
* We override some methods of the original SimplePie class here
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
|
||||
// for DokuWiki
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/utf8.php');
|
||||
|
||||
/**
|
||||
* Marker constant for JSON::decode(), used to flag stack state
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/template.php');
|
||||
|
||||
|
||||
/**
|
||||
* Call the needed action handlers
|
||||
|
|
102
inc/auth.php
102
inc/auth.php
|
@ -10,8 +10,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/common.php');
|
||||
require_once(DOKU_INC.'inc/io.php');
|
||||
|
||||
// some ACL level defines
|
||||
define('AUTH_NONE',0);
|
||||
|
@ -22,15 +20,23 @@ define('AUTH_UPLOAD',8);
|
|||
define('AUTH_DELETE',16);
|
||||
define('AUTH_ADMIN',255);
|
||||
|
||||
global $conf;
|
||||
|
||||
if($conf['useacl']){
|
||||
require_once(DOKU_INC.'inc/blowfish.php');
|
||||
require_once(DOKU_INC.'inc/mail.php');
|
||||
|
||||
/**
|
||||
* Initialize the auth system.
|
||||
*
|
||||
* This function is automatically called at the end of init.php
|
||||
*
|
||||
* This used to be the main() of the auth.php
|
||||
*
|
||||
* @todo backend loading maybe should be handled by the class autoloader
|
||||
* @todo maybe split into multiple functions at the XXX marked positions
|
||||
*/
|
||||
function auth_setup(){
|
||||
global $conf;
|
||||
global $auth;
|
||||
|
||||
// load the the backend auth functions and instantiate the auth object
|
||||
if(!$conf['useacl']) return false;
|
||||
|
||||
// load the the backend auth functions and instantiate the auth object XXX
|
||||
if (@file_exists(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php')) {
|
||||
require_once(DOKU_INC.'inc/auth/basic.class.php');
|
||||
require_once(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php');
|
||||
|
@ -50,51 +56,49 @@ if($conf['useacl']){
|
|||
} else {
|
||||
nice_die($lang['authmodfailed']);
|
||||
}
|
||||
}
|
||||
|
||||
// do the login either by cookie or provided credentials
|
||||
if($conf['useacl']){
|
||||
if($auth){
|
||||
if (!isset($_REQUEST['u'])) $_REQUEST['u'] = '';
|
||||
if (!isset($_REQUEST['p'])) $_REQUEST['p'] = '';
|
||||
if (!isset($_REQUEST['r'])) $_REQUEST['r'] = '';
|
||||
$_REQUEST['http_credentials'] = false;
|
||||
if (!$conf['rememberme']) $_REQUEST['r'] = false;
|
||||
if(!$auth) return;
|
||||
|
||||
// streamline HTTP auth credentials (IIS/rewrite -> mod_php)
|
||||
if(isset($_SERVER['HTTP_AUTHORIZATION'])){
|
||||
list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) =
|
||||
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
|
||||
}
|
||||
// do the login either by cookie or provided credentials XXX
|
||||
if (!isset($_REQUEST['u'])) $_REQUEST['u'] = '';
|
||||
if (!isset($_REQUEST['p'])) $_REQUEST['p'] = '';
|
||||
if (!isset($_REQUEST['r'])) $_REQUEST['r'] = '';
|
||||
$_REQUEST['http_credentials'] = false;
|
||||
if (!$conf['rememberme']) $_REQUEST['r'] = false;
|
||||
|
||||
// if no credentials were given try to use HTTP auth (for SSO)
|
||||
if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){
|
||||
$_REQUEST['u'] = $_SERVER['PHP_AUTH_USER'];
|
||||
$_REQUEST['p'] = $_SERVER['PHP_AUTH_PW'];
|
||||
$_REQUEST['http_credentials'] = true;
|
||||
}
|
||||
|
||||
// apply cleaning
|
||||
$_REQUEST['u'] = $auth->cleanUser($_REQUEST['u']);
|
||||
|
||||
if(isset($_REQUEST['authtok'])){
|
||||
// when an authentication token is given, trust the session
|
||||
auth_validateToken($_REQUEST['authtok']);
|
||||
}elseif(!is_null($auth) && $auth->canDo('external')){
|
||||
// external trust mechanism in place
|
||||
$auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']);
|
||||
}else{
|
||||
$evdata = array(
|
||||
'user' => $_REQUEST['u'],
|
||||
'password' => $_REQUEST['p'],
|
||||
'sticky' => $_REQUEST['r'],
|
||||
'silent' => $_REQUEST['http_credentials'],
|
||||
);
|
||||
trigger_event('AUTH_LOGIN_CHECK', $evdata, 'auth_login_wrapper');
|
||||
}
|
||||
// streamline HTTP auth credentials (IIS/rewrite -> mod_php)
|
||||
if(isset($_SERVER['HTTP_AUTHORIZATION'])){
|
||||
list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) =
|
||||
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
|
||||
}
|
||||
|
||||
//load ACL into a global array
|
||||
// if no credentials were given try to use HTTP auth (for SSO)
|
||||
if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){
|
||||
$_REQUEST['u'] = $_SERVER['PHP_AUTH_USER'];
|
||||
$_REQUEST['p'] = $_SERVER['PHP_AUTH_PW'];
|
||||
$_REQUEST['http_credentials'] = true;
|
||||
}
|
||||
|
||||
// apply cleaning
|
||||
$_REQUEST['u'] = $auth->cleanUser($_REQUEST['u']);
|
||||
|
||||
if(isset($_REQUEST['authtok'])){
|
||||
// when an authentication token is given, trust the session
|
||||
auth_validateToken($_REQUEST['authtok']);
|
||||
}elseif(!is_null($auth) && $auth->canDo('external')){
|
||||
// external trust mechanism in place
|
||||
$auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']);
|
||||
}else{
|
||||
$evdata = array(
|
||||
'user' => $_REQUEST['u'],
|
||||
'password' => $_REQUEST['p'],
|
||||
'sticky' => $_REQUEST['r'],
|
||||
'silent' => $_REQUEST['http_credentials'],
|
||||
);
|
||||
trigger_event('AUTH_LOGIN_CHECK', $evdata, 'auth_login_wrapper');
|
||||
}
|
||||
|
||||
//load ACL into a global array XXX
|
||||
global $AUTH_ACL;
|
||||
if(is_readable(DOKU_CONF.'acl.auth.php')){
|
||||
$AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/io.php');
|
||||
require_once(DOKU_INC.'inc/pageutils.php');
|
||||
require_once(DOKU_INC.'inc/parserutils.php');
|
||||
|
||||
class cache {
|
||||
var $key = ''; // primary identifier for this item
|
||||
|
|
|
@ -7,13 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/io.php');
|
||||
require_once(DOKU_INC.'inc/changelog.php');
|
||||
require_once(DOKU_INC.'inc/utf8.php');
|
||||
require_once(DOKU_INC.'inc/mail.php');
|
||||
require_once(DOKU_INC.'inc/parserutils.php');
|
||||
require_once(DOKU_INC.'inc/infoutils.php');
|
||||
require_once DOKU_INC.'inc/subscription.php';
|
||||
|
||||
/**
|
||||
* These constants are used with the recents function
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/pluginutils.php');
|
||||
|
||||
class Doku_Event {
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/html.php');
|
||||
|
||||
/**
|
||||
* Class for creating simple HTML forms.
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/indexer.php');
|
||||
|
||||
|
||||
/**
|
||||
* The fulltext search
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
if(!defined('NL')) define('NL',"\n");
|
||||
require_once(DOKU_INC.'inc/parserutils.php');
|
||||
require_once(DOKU_INC.'inc/form.php');
|
||||
|
||||
/**
|
||||
* Convenience function to quickly build a wikilink
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/io.php');
|
||||
require_once(DOKU_INC.'inc/utf8.php');
|
||||
require_once(DOKU_INC.'inc/parserutils.php');
|
||||
|
||||
// set the minimum token length to use in the index (note, this doesn't apply to numeric tokens)
|
||||
if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH',2);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
if(!defined('DOKU_MESSAGEURL')) define('DOKU_MESSAGEURL','http://update.dokuwiki.org/check/');
|
||||
require_once(DOKU_INC.'inc/HTTPClient.php');
|
||||
|
||||
/**
|
||||
* Check for new messages from upstream
|
||||
|
|
|
@ -37,6 +37,9 @@ if (!defined('DOKU_E_LEVEL')) {
|
|||
error_reporting(DOKU_E_LEVEL);
|
||||
}
|
||||
|
||||
// load libraries
|
||||
require_once(DOKU_INC.'inc/load.php');
|
||||
|
||||
// init memory caches
|
||||
global $cache_revinfo;
|
||||
$cache_revinfo = array();
|
||||
|
@ -245,6 +248,8 @@ init_files();
|
|||
scriptify(DOKU_CONF.'users.auth');
|
||||
scriptify(DOKU_CONF.'acl.auth');
|
||||
|
||||
// setup authentication system
|
||||
auth_setup();
|
||||
|
||||
/**
|
||||
* Checks paths from config file
|
||||
|
@ -526,7 +531,6 @@ EOT;
|
|||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A realpath() replacement
|
||||
*
|
||||
|
@ -588,5 +592,3 @@ function fullpath($path,$exists=false){
|
|||
return $finalpath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/common.php');
|
||||
require_once(DOKU_INC.'inc/HTTPClient.php');
|
||||
require_once(DOKU_INC.'inc/events.php');
|
||||
require_once(DOKU_INC.'inc/utf8.php');
|
||||
|
||||
/**
|
||||
* Removes empty directories
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/**
|
||||
* Load all internal libraries and setup class autoloader
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
|
||||
// setup class autoloader
|
||||
spl_autoload_register('load_autoload');
|
||||
|
||||
// require all the common libraries
|
||||
// for a e few of these order does matter
|
||||
require_once(DOKU_INC.'inc/DifferenceEngine.php');
|
||||
require_once(DOKU_INC.'inc/EmailAddressValidator.php');
|
||||
require_once(DOKU_INC.'inc/SimplePie.php');
|
||||
require_once(DOKU_INC.'inc/FeedParser.php');
|
||||
require_once(DOKU_INC.'inc/HTTPClient.php');
|
||||
require_once(DOKU_INC.'inc/IXR_Library.php');
|
||||
require_once(DOKU_INC.'inc/JSON.php');
|
||||
require_once(DOKU_INC.'inc/JpegMeta.php');
|
||||
require_once(DOKU_INC.'inc/TarLib.class.php');
|
||||
require_once(DOKU_INC.'inc/ZipLib.class.php');
|
||||
require_once(DOKU_INC.'inc/adLDAP.php');
|
||||
require_once(DOKU_INC.'inc/blowfish.php');
|
||||
require_once(DOKU_INC.'inc/feedcreator.class.php');
|
||||
require_once(DOKU_INC.'inc/geshi.php');
|
||||
require_once(DOKU_INC.'inc/actions.php');
|
||||
require_once(DOKU_INC.'inc/cache.php');
|
||||
require_once(DOKU_INC.'inc/changelog.php');
|
||||
require_once(DOKU_INC.'inc/cliopts.php');
|
||||
require_once(DOKU_INC.'inc/common.php');
|
||||
require_once(DOKU_INC.'inc/confutils.php');
|
||||
require_once(DOKU_INC.'inc/pluginutils.php');
|
||||
require_once(DOKU_INC.'inc/plugin.php');
|
||||
require_once(DOKU_INC.'inc/plugincontroller.class.php');
|
||||
require_once(DOKU_INC.'inc/events.php');
|
||||
require_once(DOKU_INC.'inc/form.php');
|
||||
require_once(DOKU_INC.'inc/fulltext.php');
|
||||
require_once(DOKU_INC.'inc/html.php');
|
||||
require_once(DOKU_INC.'inc/httputils.php');
|
||||
require_once(DOKU_INC.'inc/indexer.php');
|
||||
require_once(DOKU_INC.'inc/infoutils.php');
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
require_once(DOKU_INC.'inc/io.php');
|
||||
require_once(DOKU_INC.'inc/load.php');
|
||||
require_once(DOKU_INC.'inc/mail.php');
|
||||
require_once(DOKU_INC.'inc/media.php');
|
||||
require_once(DOKU_INC.'inc/pageutils.php');
|
||||
require_once(DOKU_INC.'inc/parserutils.php');
|
||||
require_once(DOKU_INC.'inc/search.php');
|
||||
require_once(DOKU_INC.'inc/subscription.php');
|
||||
require_once(DOKU_INC.'inc/template.php');
|
||||
require_once(DOKU_INC.'inc/toolbar.php');
|
||||
require_once(DOKU_INC.'inc/utf8.php');
|
||||
require_once(DOKU_INC.'inc/auth.php');
|
||||
|
||||
/**
|
||||
* spl_autoload_register callback
|
||||
*
|
||||
* Contains a static list of DokuWiki's core classes and automatically
|
||||
* requires their associated php files when an object is instantiated.
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
* @todo add generic loading of plugins here
|
||||
*/
|
||||
function load_autoload($name){
|
||||
static $classes = null;
|
||||
if(is_null($classes)) $classes = array(
|
||||
'DokuHTTPClient' => DOKU_INC.'inc/HTTPClient.php',
|
||||
'DokuEvent' => DOKU_INC.'inc/',
|
||||
'JSON' => DOKU_INC.'inc/JSON.php',
|
||||
'adLDAP' => DOKU_INC.'inc/adLDAP.php',
|
||||
'Diff' => DOKU_INC.'inc/DifferenceEngine.php',
|
||||
'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
|
||||
'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
|
||||
'cache' => DOKU_INC.'inc/cache.php',
|
||||
'cache_parser' => DOKU_INC.'inc/cache.php',
|
||||
'cache_instructions' => DOKU_INC.'inc/cache.php',
|
||||
'cache_renderer' => DOKU_INC.'inc/cache.php',
|
||||
'Doku_Event' => DOKU_INC.'inc/events.php',
|
||||
'Doku_Event_Handler' => DOKU_INC.'inc/events.php',
|
||||
'Doku_Form' => DOKU_INC.'inc/form.php',
|
||||
'EmailAddressValidator' => DOKU_INC.'inc/EmailAddressValidator.php',
|
||||
'JpegMeta' => DOKU_INC.'inc/JpegMeta.php',
|
||||
'FeedParser' => DOKU_INC.'inc/FeedParser.php',
|
||||
'utf8_entity_decoder' => DOKU_INC.'inc/utf8.php',
|
||||
'IXR_Server' => DOKU_INC.'inc/IXR_Library.php',
|
||||
'IXR_Client' => DOKU_INC.'inc/IXR_Library.php',
|
||||
'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php',
|
||||
'GeSHi' => DOKU_INC.'inc/geshi.php',
|
||||
);
|
||||
|
||||
if(isset($classes[$name])){
|
||||
require_once($classes[$name]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/utf8.php');
|
||||
require_once(DOKU_INC.'inc/EmailAddressValidator.php');
|
||||
|
||||
// end of line for mail lines - RFC822 says CRLF but postfix (and other MTAs?)
|
||||
// think different
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
if(!defined('NL')) define('NL',"\n");
|
||||
require_once(DOKU_INC.'inc/html.php');
|
||||
require_once(DOKU_INC.'inc/search.php');
|
||||
require_once(DOKU_INC.'inc/JpegMeta.php');
|
||||
|
||||
/**
|
||||
* Lists pages which currently use a media file selected for deletion
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/confutils.php');
|
||||
require_once(DOKU_INC.'inc/pageutils.php');
|
||||
require_once(DOKU_INC.'inc/pluginutils.php');
|
||||
require_once(DOKU_INC.'inc/cache.php');
|
||||
|
||||
/**
|
||||
* Returns the parsed Wikitext in XHTML for the given id and revision.
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
// plugin related constants
|
||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||
require_once(DOKU_INC.'inc/plugincontroller.class.php');
|
||||
|
||||
$plugin_types = array('admin','syntax','action','renderer', 'helper');
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/common.php');
|
||||
|
||||
/**
|
||||
* recurse direcory
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*/
|
||||
|
||||
require_once DOKU_INC.'/inc/pageutils.php';
|
||||
|
||||
/**
|
||||
* Get the name of the metafile tracking subscriptions to target page or
|
||||
* namespace
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) die('meh.');
|
||||
require_once(DOKU_INC.'inc/JSON.php');
|
||||
|
||||
|
||||
/**
|
||||
* Prepares and prints an JavaScript array with all toolbar buttons
|
||||
|
|
Loading…
Reference in New Issue