appname = 'Renapsus'; $DB_sql->database = $database; $DB_sql->connect($servername, $username, $password, $usepconnect); define('DEVDEBUG', $debug); define('TABLE_PREFIX', $tableprefix); define('COOKIE_PREFIX', $cookieprefix); unset($database, $servername, $username, $password, $usepconnect, $tableprefix, $cookieprefix); // ################################################################### // Initialize our environment require_once('./includes/functions_datastore.php'); require_once('./includes/functions.php'); class BugTracker { var $options = array(); var $userinfo = array(); var $language = array(); var $datastore = array(); function BugTracker() { global $DB_sql, $vars; // Fetch all the datastore caches $datastoretemp = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "datastore"); while ($store = $DB_sql->fetch_array($datastoretemp)) { $this->datastore["$store[title]"] = unserialize($store['data']); } // Assign options and fetch the userinfo $this->options = $this->datastore['setting']; unset($this->datastore['setting']); $this->userinfo = (array)$this->fetch_userinfo(-1, true); // Pull our languageid if ($this->userinfo['userid']) { $languageid = $this->userinfo['languageid']; $language = $this->datastore['language']["$languageid"]; } if (!$languageid) { foreach ($this->datastore['language'] AS $language) { if ($language['default']) { $languageid = $language['languageid']; $language = $this->datastore['language']["$languageid"]; break; } } } $this->options['lang_id'] = $language['languageid']; $this->options['lang_charset'] = $language['charset']; $this->options['lang_dir'] = $language['direction']; $this->options['lang_code'] = $language['languagecode']; /* // can't use this because not everyone has MySQL >= 4.0.17 ... one day, one day $phrases = $DB_sql->query(" (SELECT varname, phrasetext FROM " . TABLE_PREFIX . "phrase) UNION DISTINCT (SELECT varname AS lvarname, phrasetext AS lphrasetext FROM " . TABLE_PREFIX . "locale AS locale WHERE languageid = " . $this->options['lang_id'] . ")" ); while ($phrase = $DB_sql->fetch_array($phrases)) { $this->language["$phrase[varname]"] = $phrase['phrasetext']; } $DB_sql->free_result($phrases); */ // load master language $phrases = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "phrase"); while ($phrase = $DB_sql->fetch_array($phrases)) { $this->language["$phrase[varname]"] = $phrase['phrasetext']; } $DB_sql->free_result($phrases); // load locale data $locale = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "locale WHERE languageid = " . $this->options['lang_id']); while ($phrase = $DB_sql->fetch_array($locale)) { $this->language["$phrase[varname]"] = $phrase['phrasetext']; } $DB_sql->free_result($phrases); // get the templateset if ($this->userinfo['userid']) { $templatesetid = $this->userinfo['templatesetid']; $templateset = $this->datastore['templateset']["$templatesetid"]; } if (!$templatesetid) { foreach ($this->datastore['templateset'] AS $templateset) { if ($templateset['default']) { $templatesetid = $templateset['templatesetid']; $templateset = $this->datastore['templateset']["$templatesetid"]; } } } // load the template system if (file_exists("./templates/$templateset[shortname]/tsinfo.php")) { $this->options['ts_includepath'] = "./templates/$templateset[shortname]/"; } else { echo "template set info (templates/$templateset[shortname]/tsinfo.php) could not be loaded!"; exit; } } function fetch_userinfo($userid = -1, $verify_password = false) { global $DB_sql; // Get the userid if not specified if ($userid == -1) { $userid = intval($_COOKIE[COOKIE_PREFIX . 'userid']); } // Set the falseinfo stuff $falseinfo = array( 'usergroupid' => 1, 'userid' => 0, 'email' => '', 'displayname' => '', 'permissions' => $this->datastore['usergroup'][1]['permissions'], 'displaytitle' => $this->datastore['usergroup'][1]['displaytitle'], 'mdisplayname' => $this->datastore['usergroup'][1]['opentag'] . '' . $this->datastore['usergroup'][1]['closetag'] ); // Get the userinfo $userinfo = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $userid"); if (is_array($userinfo)) { $userinfo['permissions'] = (int)$this->datastore['usergroup']["$userinfo[usergroupid]"]['permissions']; $userinfo['displaytitle'] = $this->datastore['usergroup']["$userinfo[usergroupid]"]['displaytitle']; fetch_user_display_name($userinfo); $userinfo['mdisplayname'] = $this->datastore['usergroup']["$userinfo[usergroupid]"]['opentag'] . $userinfo['displayname'] . $this->datastore['usergroup']["$userinfo[usergroupid]"]['closetag']; // Verify that the cookie isn't fake if ($verify_password) { if ($_COOKIE[COOKIE_PREFIX . 'authkey'] == $userinfo['authkey']) { return $userinfo; } else { mysetcookie(COOKIE_PREFIX . 'userid'); mysetcookie(COOKIE_PREFIX . 'authkey'); return $falseinfo; } } else { return $userinfo; } } else { mysetcookie(COOKIE_PREFIX . 'userid'); mysetcookie(COOKIE_PREFIX . 'authkey'); return $falseinfo; } } } $bugsys = new BugTracker(); // ################################################################### // Initialize usergroup system $_PERMISSION = array( 'canviewbugs' => 1, // can view bugs 'cansearch' => 2, // can use the search 'cansubscribe' => 4, // can email subscribe 'canvote' => 8, // can vote on bugs 'cansubmitbugs' => 16, // can submit new bugs 'canpostcomments' => 32, // can post new comments 'cangetattach' => 64, // can dl attachments 'canputattach' => 128, // can ul attachments 'caneditown' => 256, // can edit own comments 'caneditothers' => 512, // can edit others' comments 'caneditinfo' => 1024, // can edit bug info -- works in conjunction with canedit(own|others) 'canassign' => 2048, // can assign bug 'canchangestatus' => 4096, // can change bug status 'canadminpanel' => 8192, // can view admin panel 'canadminbugs' => 16384, // can administrate bug functions 'canadminversions' => 32768, // can admin version info 'canadminusers' => 65536, // can admin users 'canadmingroups' => 131072, // can admin permission masks 'canadmintools' => 262144, // can use admin tools 'canadminfields' => 524288, // can admin custom bug fields 'canbeassignedto' => 1048576 // can be assigned bugs ); foreach ($_PERMISSION AS $name => $maskvalue) { define(strtoupper($name), $maskvalue); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>