2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 error_reporting(E_ALL
& ~E_NOTICE
);
15 // ###################################################################
16 // initialize the database
18 if (!file_exists('./includes/config.php'))
20 echo 'includes/config.php needs to be present!';
24 require_once('./includes/config.php');
26 define('ISSO_ESCAPE_STRINGS', 1);
27 define('ISSO_CHECK_POST_REFERER', 1);
29 require_once($pathtoisso . 'kernel.php');
31 $bugsys->application
= 'BugStrike';
32 $bugsys->apppath
= $bugsys->fetch_sourcepath(getcwd());
33 $bugsys->appversion
= '[#]version[#]';
34 $bugsys->debug
= $debug;
35 $bugsys->sourcepath
= $bugsys->fetch_sourcepath($pathtoisso);
37 $bugsys->load('db_mysql');
38 $db->database
= $database;
39 $db->connect($servername, $username, $password, $usepconnect);
41 $bugsys->load('functions');
42 $bugsys->load('mail');
44 define('DEVDEBUG', $debug);
45 define('TABLE_PREFIX', $tableprefix);
46 define('COOKIE_PREFIX', $cookieprefix);
48 unset($database, $servername, $username, $password, $usepconnect, $tableprefix, $cookieprefix);
50 require_once('./includes/functions_datastore.php');
51 require_once('./includes/functions.php');
53 // ###################################################################
55 $bugsys->options
= array();
56 $bugsys->userinfo
= array();
57 $bugsys->language
= array();
58 $bugsys->datastore
= array();
60 // ###################################################################
61 // populate our caches
62 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX
. "datastore");
63 while ($store = $db->fetch_array($datastoretemp))
65 $bugsys->datastore
["$store[title]"] = unserialize($store['data']);
67 $bugsys->options
= $bugsys->datastore
['setting'];
68 unset($bugsys->datastore
['setting']);
70 $mail->from
= $bugsys->options
['webmasteremail'];
71 $mail->fromname
= 'BugStrike Notification';
73 // ###################################################################
75 $userid = intval($_COOKIE[COOKIE_PREFIX
. 'userid']);
77 $userinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = $userid");
78 if (is_array($userinfo) AND $_COOKIE[COOKIE_PREFIX
. 'authkey'] == $userinfo['authkey'])
80 $userinfo['permissions'] = (int)$bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['permissions'];
81 $userinfo['displaytitle'] = $bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['displaytitle'];
82 fetch_user_display_name($userinfo);
83 $userinfo['mdisplayname'] = $bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['opentag'] . $userinfo['displayname'] . $bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['closetag'];
84 $bugsys->userinfo
= $userinfo;
88 mysetcookie(COOKIE_PREFIX
. 'userid');
89 mysetcookie(COOKIE_PREFIX
. 'authkey');
90 $bugsys->userinfo
= array(
95 'permissions' => $bugsys->datastore
['usergroup'][1]['permissions'],
96 'displaytitle' => $bugsys->datastore
['usergroup'][1]['displaytitle'],
97 'mdisplayname' => $bugsys->datastore
['usergroup'][1]['opentag'] . '' . $bugsys->datastore
['usergroup'][1]['closetag']
101 // ###################################################################
102 // pull our languageid
103 if ($bugsys->userinfo
['userid'])
105 $languageid = $bugsys->userinfo
['languageid'];
106 $language = $bugsys->datastore
['language']["$languageid"];
110 foreach ($bugsys->datastore
['language'] AS $language)
112 if ($language['default'])
114 $languageid = $language['languageid'];
115 $language = $bugsys->datastore
['language']["$languageid"];
121 $bugsys->options
['lang_id'] = $language['languageid'];
122 $bugsys->options
['lang_charset'] = $language['charset'];
123 $bugsys->options
['lang_dir'] = $language['direction'];
124 $bugsys->options
['lang_code'] = $language['languagecode'];
126 // ###################################################################
127 // load master language
129 // can't use this because not everyone has MySQL >= 4.0.17 ... one day, one day
130 $phrases = $db->query("
131 (SELECT varname, phrasetext FROM " . TABLE_PREFIX . "phrase)
133 (SELECT varname AS lvarname, phrasetext AS lphrasetext FROM " . TABLE_PREFIX . "locale AS locale WHERE languageid = " . $bugsys->options['lang_id'] . ")"
135 while ($phrase = $db->fetch_array($phrases))
137 $bugsys->language["$phrase[varname]"] = $phrase['phrasetext'];
139 $db->free_result($phrases);
142 $phrases = $db->query("SELECT * FROM " . TABLE_PREFIX
. "phrase");
143 while ($phrase = $db->fetch_array($phrases))
145 $bugsys->language
["$phrase[varname]"] = $phrase['phrasetext'];
147 $db->free_result($phrases);
149 // ###################################################################
151 $locale = $db->query("SELECT * FROM " . TABLE_PREFIX
. "locale WHERE languageid = " . $bugsys->options
['lang_id']);
152 while ($phrase = $db->fetch_array($locale))
154 $bugsys->language
["$phrase[varname]"] = $phrase['phrasetext'];
156 $db->free_result($phrases);
158 // ###################################################################
159 // get the templateset
160 if ($bugsys->userinfo
['userid'])
162 $templatesetid = $bugsys->userinfo
['templatesetid'];
163 $templateset = $bugsys->datastore
['templateset']["$templatesetid"];
167 foreach ($bugsys->datastore
['templateset'] AS $templateset)
169 if ($templateset['default'])
171 $templatesetid = $templateset['templatesetid'];
172 $templateset = $bugsys->datastore
['templateset']["$templatesetid"];
177 // ###################################################################
178 // load the template system
179 if (file_exists("./templates/$templateset[shortname]/tsinfo.php"))
181 $bugsys->load('template_fs');
182 $template->extension
= 'tpl';
183 $template->templatedir
= $bugsys->fetch_sourcepath("templates/$templateset[shortname]/");
187 echo "template set info (templates/$templateset[shortname]/tsinfo.php) could not be loaded!";
191 // ###################################################################
192 // Initialize usergroup system
193 $_PERMISSION = array(
194 'canviewbugs' => 1, // can view bugs
195 'cansearch' => 2, // can use the search
196 'cansubscribe' => 4, // can email subscribe
197 'canvote' => 8, // can vote on bugs
198 'cansubmitbugs' => 16, // can submit new bugs
199 'canpostcomments' => 32, // can post new comments
200 'cangetattach' => 64, // can dl attachments
201 'canputattach' => 128, // can ul attachments
202 'caneditown' => 256, // can edit own comments
203 'caneditothers' => 512, // can edit others' comments
204 'caneditinfo' => 1024, // can edit bug info -- works in conjunction with canedit(own|others)
205 'canassign' => 2048, // can assign bug
206 'canchangestatus' => 4096, // can change bug status
207 'canadminpanel' => 8192, // can view admin panel
208 'canadminbugs' => 16384, // can administrate bug functions
209 'canadminversions' => 32768, // can admin version info
210 'canadminusers' => 65536, // can admin users
211 'canadmingroups' => 131072, // can admin permission masks
212 'canadmintools' => 262144, // can use admin tools
213 'canadminfields' => 524288, // can admin custom bug fields
214 'canbeassignedto' => 1048576 // can be assigned bugs
217 foreach ($_PERMISSION AS $name => $maskvalue)
219 define(strtoupper($name), $maskvalue);
222 /*=====================================================================*\
223 || ###################################################################
226 || ###################################################################
227 \*=====================================================================*/