2016-01-01, 02:04 PM
I am trying to make a simple authentication plugin for Dokuwiki to allow forum members to view the wiki but I keep getting an error when I include "global.php".
The wiki is located in a sub-folder named "wiki" in the MyBB root folder. Therefore the plugin ends up in:
"{mybb_root}/wiki/lib/plugins/authmybb/auth.php"
If I create a "test.php" file in the root of my wiki with the following contents:
And I access it directly in my browser. The $db object is working properly and the include path is correct.
But if I do the following in my plugin:
(those nested dirname sure look awkard)
Then the include directory is also correct but instead I get this error:
MyBB version: 1.8.6
PHP version: 5.6.14
The wiki is located in a sub-folder named "wiki" in the MyBB root folder. Therefore the plugin ends up in:
"{mybb_root}/wiki/lib/plugins/authmybb/auth.php"
If I create a "test.php" file in the root of my wiki with the following contents:
define("IN_MYBB", 1);
define('MYBB_ROOT_DIR', dirname(dirname(__FILE__))."/");
echo MYBB_ROOT_DIR;
require_once MYBB_ROOT_DIR."global.php";
echo "<pre>";
var_dump($db);
echo "</pre>";
And I access it directly in my browser. The $db object is working properly and the include path is correct.
But if I do the following in my plugin:
if(!defined('DOKU_INC')) die();
define("IN_MYBB", 1);
define('MYBB_ROOT_DIR', dirname(dirname(dirname(dirname(dirname(__FILE__)))))."/");
echo MYBB_ROOT_DIR;
require_once MYBB_ROOT_DIR."global.php";
echo "<pre>";
var_dump($db);
echo "</pre>";
(those nested dirname sure look awkard)
Then the include directory is also correct but instead I get this error:
Fatal error: Call to a member function simple_select() on null in {mybb_root}/inc/class_datacache.php on line 117
MyBB version: 1.8.6
PHP version: 5.6.14