Rev 148 | Rev 159 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 148 | Rev 150 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | 19 | ||
20 | if (!defined('IN_OIDPLUS')) die(); |
20 | if (!defined('IN_OIDPLUS')) die(); |
21 | 21 | ||
22 | class OIDplus { |
22 | class OIDplus { |
23 | private static /*OIDplusPagePlugin[][]*/ $pagePlugins = array(); |
23 | private static /*OIDplusPagePlugin[][]*/ $pagePlugins = array(); |
24 | private static /*OIDplusObject*/ $objectTypes = array(); |
24 | private static /*OIDplusObject[]*/ $objectTypes = array(); |
25 | private static /*OIDplusObject*/ $disabledObjectTypes = array(); |
25 | private static /*OIDplusObject[]*/ $disabledObjectTypes = array(); |
- | 26 | private static /*OIDplusDatabase[]*/ $dbPlugins = array(); |
|
26 | 27 | ||
27 | private function __construct() { |
28 | private function __construct() { |
28 | } |
29 | } |
29 | 30 | ||
30 | public static function db() { |
31 | public static function db() { |
31 | static $database = null; |
- | |
32 | if (is_null($database)) { |
32 | if (!isset(self::$dbPlugins[OIDPLUS_DATABASE_PLUGIN])) { |
33 | $database = new OIDplusDataBaseMySQL(); |
33 | throw new Exception("Database plugin '".htmlentities(OIDPLUS_DATABASE_PLUGIN)."' not found. Please check config.inc.php or run <a href=\"setup/\">setup</a> again."); |
34 | } |
34 | } |
- | 35 | $obj = self::$dbPlugins[OIDPLUS_DATABASE_PLUGIN]; |
|
- | 36 | if (!$obj->isConnected()) $obj->connect(); |
|
35 | return $database; |
37 | return $obj; |
36 | } |
38 | } |
37 | 39 | ||
38 | public static function config() { |
40 | public static function config() { |
39 | static $config = null; |
41 | static $config = null; |
40 | if (is_null($config)) { |
42 | if (is_null($config)) { |
Line 99... | Line 101... | ||
99 | } |
101 | } |
100 | 102 | ||
101 | return $res; |
103 | return $res; |
102 | } |
104 | } |
103 | 105 | ||
- | 106 | public static function registerDatabasePlugin(OIDplusDatabase $plugin) { |
|
- | 107 | $name = $plugin->name(); |
|
- | 108 | if ($name === false) return false; |
|
- | 109 | ||
- | 110 | self::$dbPlugins[$name] = $plugin; |
|
- | 111 | ||
- | 112 | return true; |
|
- | 113 | } |
|
- | 114 | ||
- | 115 | public static function getDatabasePlugins() { |
|
- | 116 | return self::$dbPlugins; |
|
- | 117 | } |
|
- | 118 | ||
104 | public static function registerPagePlugin(OIDplusPagePlugin $plugin) { |
119 | public static function registerPagePlugin(OIDplusPagePlugin $plugin) { |
105 | $type = $plugin->type(); |
120 | $type = $plugin->type(); |
106 | if ($type === false) return false; |
121 | if ($type === false) return false; |
107 | 122 | ||
108 | $prio = $plugin->priority(); |
123 | $prio = $plugin->priority(); |
Line 272... | Line 287... | ||
272 | 287 | ||
273 | // Auto-fill non-existing config values |
288 | // Auto-fill non-existing config values |
274 | 289 | ||
275 | if (!defined('OIDPLUS_CONFIG_VERSION')) define('OIDPLUS_CONFIG_VERSION', 0.0); |
290 | if (!defined('OIDPLUS_CONFIG_VERSION')) define('OIDPLUS_CONFIG_VERSION', 0.0); |
276 | if (!defined('OIDPLUS_ADMIN_PASSWORD')) define('OIDPLUS_ADMIN_PASSWORD', ''); |
291 | if (!defined('OIDPLUS_ADMIN_PASSWORD')) define('OIDPLUS_ADMIN_PASSWORD', ''); |
- | 292 | if (!defined('OIDPLUS_DATABASE_PLUGIN')) define('OIDPLUS_DATABASE_PLUGIN', 'MySQL'); |
|
277 | if (!defined('OIDPLUS_MYSQL_HOST')) define('OIDPLUS_MYSQL_HOST', 'localhost'); |
293 | if (!defined('OIDPLUS_MYSQL_HOST')) define('OIDPLUS_MYSQL_HOST', 'localhost'); |
278 | if (!defined('OIDPLUS_MYSQL_USERNAME')) define('OIDPLUS_MYSQL_USERNAME', 'root'); |
294 | if (!defined('OIDPLUS_MYSQL_USERNAME')) define('OIDPLUS_MYSQL_USERNAME', 'root'); |
279 | if (!defined('OIDPLUS_MYSQL_PASSWORD')) define('OIDPLUS_MYSQL_PASSWORD', ''); |
295 | if (!defined('OIDPLUS_MYSQL_PASSWORD')) define('OIDPLUS_MYSQL_PASSWORD', ''); // base64 encoded |
280 | if (!defined('OIDPLUS_MYSQL_DATABASE')) define('OIDPLUS_MYSQL_DATABASE', 'oidplus'); |
296 | if (!defined('OIDPLUS_MYSQL_DATABASE')) define('OIDPLUS_MYSQL_DATABASE', 'oidplus'); |
281 | if (!defined('OIDPLUS_TABLENAME_PREFIX')) define('OIDPLUS_TABLENAME_PREFIX', ''); |
297 | if (!defined('OIDPLUS_TABLENAME_PREFIX')) define('OIDPLUS_TABLENAME_PREFIX', ''); |
282 | if (!defined('OIDPLUS_SESSION_SECRET')) define('OIDPLUS_SESSION_SECRET', ''); |
298 | if (!defined('OIDPLUS_SESSION_SECRET')) define('OIDPLUS_SESSION_SECRET', ''); |
283 | if (!defined('RECAPTCHA_ENABLED')) define('RECAPTCHA_ENABLED', false); |
299 | if (!defined('RECAPTCHA_ENABLED')) define('RECAPTCHA_ENABLED', false); |
284 | if (!defined('RECAPTCHA_PUBLIC')) define('RECAPTCHA_PUBLIC', ''); |
300 | if (!defined('RECAPTCHA_PUBLIC')) define('RECAPTCHA_PUBLIC', ''); |
Line 294... | Line 310... | ||
294 | echo 'The information located in includes/config.inc.php is outdated. Please run setup again.'; |
310 | echo 'The information located in includes/config.inc.php is outdated. Please run setup again.'; |
295 | } |
311 | } |
296 | die(); |
312 | die(); |
297 | } |
313 | } |
298 | 314 | ||
- | 315 | // Register database types (highest priority) |
|
- | 316 | ||
- | 317 | $ary = glob(__DIR__ . '/../../plugins/database/'.'*'.'/plugin.inc.php'); |
|
- | 318 | foreach ($ary as $a) include $a; |
|
- | 319 | ||
299 | // Do redirect stuff etc. |
320 | // Do redirect stuff etc. |
300 | 321 | ||
301 | define('OIDPLUS_SSL_AVAILABLE', self::isSslAvailable()); |
322 | define('OIDPLUS_SSL_AVAILABLE', self::isSslAvailable()); |
302 | 323 | ||
303 | // System config settings |
324 | // System config settings |
Line 312... | Line 333... | ||
312 | 333 | ||
313 | OIDplus::pkiStatus(true); |
334 | OIDplus::pkiStatus(true); |
314 | 335 | ||
315 | // Register plugins |
336 | // Register plugins |
316 | 337 | ||
- | 338 | $ary = glob(__DIR__ . '/../../plugins/objectTypes/'.'*'.'/*.class.php'); |
|
- | 339 | foreach ($ary as $a) include $a; |
|
- | 340 | ||
317 | $ary = glob(__DIR__ . '/../../plugins/publicPages/'.'*'.'/plugin.inc.php'); |
341 | $ary = glob(__DIR__ . '/../../plugins/publicPages/'.'*'.'/plugin.inc.php'); |
318 | foreach ($ary as $a) include $a; |
342 | foreach ($ary as $a) include $a; |
319 | $ary = glob(__DIR__ . '/../../plugins/raPages/'.'*'.'/plugin.inc.php'); |
343 | $ary = glob(__DIR__ . '/../../plugins/raPages/'.'*'.'/plugin.inc.php'); |
320 | foreach ($ary as $a) include $a; |
344 | foreach ($ary as $a) include $a; |
321 | $ary = glob(__DIR__ . '/../../plugins/adminPages/'.'*'.'/plugin.inc.php'); |
345 | $ary = glob(__DIR__ . '/../../plugins/adminPages/'.'*'.'/plugin.inc.php'); |
322 | foreach ($ary as $a) include $a; |
346 | foreach ($ary as $a) include $a; |
323 | $ary = glob(__DIR__ . '/../../plugins/objectTypes/'.'*'.'/*.class.php'); |
- | |
324 | foreach ($ary as $a) include $a; |
- | |
325 | 347 | ||
326 | // Initialize plugins |
348 | // Initialize plugins |
327 | 349 | ||
328 | foreach (OIDplus::getPagePlugins('*') as $plugin) { |
350 | foreach (OIDplus::getPagePlugins('*') as $plugin) { |
329 | $plugin->init($html); |
351 | $plugin->init($html); |