setAppPath(getcwd());
$bugsys->setApplication('Bugdar');
$bugsys->setAppVersion(BUGDAR_VERSION);
if (!file_exists('./includes/config.php'))
{
echo 'includes/config.php needs to be present!';
exit;
}
require_once('./includes/config.php');
$bugsys->setDebug($debug);
$bugsys->load('db_mysql_pdo', 'db', true);
$db->connect($servername, $username, $password, $database, $usepconnect);
if ($utf8)
{
$db->query("SET NAMES utf8");
}
// don't use sql strict mode
$db->query("SET sql_mode = ''");
$bugsys->load('functions', 'funct', true);
$bugsys->load('xml', 'xml', true);
// change cookie expiration to one hour
$funct->cookieexp = 3600;
define('DEVDEBUG', $debug);
define('TABLE_PREFIX', $tableprefix);
define('COOKIE_PREFIX', $cookieprefix);
unset($database, $servername, $theuser, $password, $thepass, $usepconnect, $tableprefix, $cookieprefix);
require_once('./includes/functions_datastore.php');
require_once('./includes/functions.php');
require_once('./includes/language.php');
// ###################################################################
// init the big three
$bugsys->options = array();
$bugsys->userinfo = array();
bugdar::$datastore = array();
class bugdar
{
/*! @var \PDO The database connection instance. */
static $db = NULL;
/*! @var \hoplite\http\Input Input filter for the new stack. */
static $input = NULL;
static $options = array();
static $user = array();
static $datastore = array();
}
define('BUGDAR_ROOT', dirname(dirname(__FILE__)));
// ###################################################################
// Initialize Hoplite concurrently with ISSO 2.x.
define('HOPLITE_ROOT', dirname(__FILE__) . '/hoplite');
require_once HOPLITE_ROOT . '/data/model.php';
\hoplite\data\Model::set_db($db->dblink);
require_once HOPLITE_ROOT . '/http/input.php';
bugdar::$input = new \hoplite\http\Input(\hoplite\http\Input::TYPE_HTML);
bugdar::$db = $db->dblink;
// ###################################################################
// send nocache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
if ($utf8)
{
header("Content-Type: text/html; charset=\"utf8\"");
}
header("Pragma: no-cache");
// ###################################################################
// populate our caches
$db->showerrors = false;
$datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX . "datastore");
$db->showerrors = true;
if (!$datastoretemp)
{
echo '
Notice: This error could be caused if you have not installed Bugdar. If this is the case, you can run the installer
here.
';
$db->error('Invalid SQL error');
}
while ($store = $db->fetch_array($datastoretemp))
{
bugdar::$datastore["$store[title]"] = unserialize($store['data']);
}
$bugsys->options = bugdar::$datastore['setting'];
$bugsys->options['columnoptions'] = unserialize($bugsys->options['columnoptions']);
unset(bugdar::$datastore['setting']);
bugdar::$options = $bugsys->options;
$bugsys->setAppVersion($bugsys->options['trackerversion']);
// ###################################################################
// load permissions
require_once('./includes/permissions.php');
// ###################################################################
// load userinfo
$authMethod = ((defined('USE_DEFAULT_AUTH_METHOD') AND constant('USE_DEFAULT_AUTH_METHOD') == 1) ? 'default' : $bugsys->options['authmethod']);
require_once('./includes/auth/auth_' . $authMethod . '.php');
$authClass = 'Authentication' . str_replace(' ', '', ucwords(str_replace('_', ' ', $authMethod)));
$bugsys->auth = $auth = new $authClass();
if ($auth->authenticateCookies())
{
$bugsys->userinfo = $auth->fetchBugdarUser();
$bugsys->userinfo['permissions'] = FetchUserPermissions($bugsys->userinfo);
$bugsys->userinfo['displaytitle'] = bugdar::$datastore['usergroup'][ $bugsys->userinfo['usergroupid'] ]['displaytitle'];
$bugsys->userinfo['columnoptions'] = unserialize($bugsys->userinfo['columnoptions']);
}
else
{
$bugsys->userinfo = fetch_guest_user();
}
bugdar::$user = $bugsys->userinfo;
// ###################################################################
// initialize localization system
$language = fetch_user_language();
$stylevar['lang'] = $language['langcode'];
$stylevar['lang_dir'] = $language['direction'];
$stylevar['charset'] = $language['charset'];
$stylevar['left'] = ($language['direction'] == 'ltr' ? 'left' : 'right');
$stylevar['right'] = ($language['direction'] == 'ltr' ? 'right' : 'left');
require_once('./includes/definitions.php');
// ###################################################################
// initialize the date system
$bugsys->load('date', 'datef', true);
$datef->usertz = $bugsys->userinfo['timezone'] + ($bugsys->userinfo['usedst'] * 1);
$bugsys->debug('user tz = ' . $bugsys->userinfo['timezone'] . '; use version = ' . $datef->usertz);
$datef->fetch_offset();
// ###################################################################
// mail system
$bugsys->load('mail', 'mail', true);
$mail->setFromAddress($bugsys->options['webmasteremail']);
$mail->setFromName(T('Bugdar Notification'));