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');
43 $bugsys->exec_sanitize_data();
45 define('DEVDEBUG', $debug);
46 define('TABLE_PREFIX', $tableprefix);
47 define('COOKIE_PREFIX', $cookieprefix);
49 unset($database, $servername, $username, $password, $usepconnect, $tableprefix, $cookieprefix);
51 require_once('./includes/functions_datastore.php');
52 require_once('./includes/functions.php');
54 // ###################################################################
56 $bugsys->options
= array();
57 $bugsys->userinfo
= array();
58 $bugsys->language
= array();
59 $bugsys->datastore
= array();
61 // ###################################################################
62 // populate our caches
63 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX
. "datastore");
64 while ($store = $db->fetch_array($datastoretemp))
66 $bugsys->datastore
["$store[title]"] = unserialize($store['data']);
68 $bugsys->options
= $bugsys->datastore
['setting'];
69 unset($bugsys->datastore
['setting']);
71 $mail->from
= $bugsys->options
['webmasteremail'];
72 $mail->fromname
= 'BugStrike Notification';
74 // ###################################################################
76 $userid = intval($_COOKIE[COOKIE_PREFIX
. 'userid']);
78 $userinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = $userid");
79 if (is_array($userinfo) AND $_COOKIE[COOKIE_PREFIX
. 'authkey'] == $userinfo['authkey'])
81 $userinfo['permissions'] = (int)$bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['permissions'];
82 $userinfo['displaytitle'] = $bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['displaytitle'];
83 fetch_user_display_name($userinfo);
84 $userinfo['mdisplayname'] = $bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['opentag'] . $userinfo['displayname'] . $bugsys->datastore
['usergroup']["$userinfo[usergroupid]"]['closetag'];
85 $bugsys->userinfo
= $userinfo;
89 mysetcookie(COOKIE_PREFIX
. 'userid');
90 mysetcookie(COOKIE_PREFIX
. 'authkey');
91 $bugsys->userinfo
= array(
96 'permissions' => $bugsys->datastore
['usergroup'][1]['permissions'],
97 'displaytitle' => $bugsys->datastore
['usergroup'][1]['displaytitle'],
98 'mdisplayname' => $bugsys->datastore
['usergroup'][1]['opentag'] . '' . $bugsys->datastore
['usergroup'][1]['closetag']
102 // ###################################################################
103 // pull our languageid
104 if ($bugsys->userinfo
['userid'])
106 $languageid = $bugsys->userinfo
['languageid'];
107 $language = $bugsys->datastore
['language']["$languageid"];
111 foreach ($bugsys->datastore
['language'] AS $language)
113 if ($language['default'])
115 $languageid = $language['languageid'];
116 $language = $bugsys->datastore
['language']["$languageid"];
122 $bugsys->options
['lang_id'] = $language['languageid'];
123 $bugsys->options
['lang_charset'] = $language['charset'];
124 $bugsys->options
['lang_dir'] = $language['direction'];
125 $bugsys->options
['lang_code'] = $language['languagecode'];
127 // ###################################################################
128 // load master language
130 // can't use this because not everyone has MySQL >= 4.0.17 ... one day, one day
131 $phrases = $db->query("
132 (SELECT varname, phrasetext FROM " . TABLE_PREFIX . "phrase)
134 (SELECT varname AS lvarname, phrasetext AS lphrasetext FROM " . TABLE_PREFIX . "locale AS locale WHERE languageid = " . $bugsys->options['lang_id'] . ")"
136 while ($phrase = $db->fetch_array($phrases))
138 $bugsys->language["$phrase[varname]"] = $phrase['phrasetext'];
140 $db->free_result($phrases);
143 $phrases = $db->query("SELECT * FROM " . TABLE_PREFIX
. "phrase");
144 while ($phrase = $db->fetch_array($phrases))
146 $bugsys->language
["$phrase[varname]"] = $phrase['phrasetext'];
148 $db->free_result($phrases);
150 // ###################################################################
152 $locale = $db->query("SELECT * FROM " . TABLE_PREFIX
. "locale WHERE languageid = " . $bugsys->options
['lang_id']);
153 while ($phrase = $db->fetch_array($locale))
155 $bugsys->language
["$phrase[varname]"] = $phrase['phrasetext'];
157 $db->free_result($phrases);
159 // ###################################################################
160 // get the templateset
161 if ($bugsys->userinfo
['userid'])
163 $templatesetid = $bugsys->userinfo
['templatesetid'];
164 $templateset = $bugsys->datastore
['templateset']["$templatesetid"];
168 foreach ($bugsys->datastore
['templateset'] AS $templateset)
170 if ($templateset['default'])
172 $templatesetid = $templateset['templatesetid'];
173 $templateset = $bugsys->datastore
['templateset']["$templatesetid"];
178 // ###################################################################
179 // load the template system
180 if (file_exists("./templates/$templateset[shortname]/tsinfo.php"))
182 $bugsys->load('template_fs');
183 $template->extension
= 'tpl';
184 $template->templatedir
= $bugsys->fetch_sourcepath("templates/$templateset[shortname]/");
188 echo "template set info (templates/$templateset[shortname]/tsinfo.php) could not be loaded!";
192 // ###################################################################
193 // Initialize usergroup system
194 $_PERMISSION = array(
195 'canviewbugs' => 1, // can view bugs
196 'cansearch' => 2, // can use the search
197 'cansubscribe' => 4, // can email subscribe
198 'canvote' => 8, // can vote on bugs
199 'cansubmitbugs' => 16, // can submit new bugs
200 'canpostcomments' => 32, // can post new comments
201 'cangetattach' => 64, // can dl attachments
202 'canputattach' => 128, // can ul attachments
203 'caneditown' => 256, // can edit own comments
204 'caneditothers' => 512, // can edit others' comments
205 'caneditinfo' => 1024, // can edit bug info -- works in conjunction with canedit(own|others)
206 'canassign' => 2048, // can assign bug
207 'canchangestatus' => 4096, // can change bug status
208 'canadminpanel' => 8192, // can view admin panel
209 'canadminbugs' => 16384, // can administrate bug functions
210 'canadminversions' => 32768, // can admin version info
211 'canadminusers' => 65536, // can admin users
212 'canadmingroups' => 131072, // can admin permission masks
213 'canadmintools' => 262144, // can use admin tools
214 'canadminfields' => 524288, // can admin custom bug fields
215 'canbeassignedto' => 1048576 // can be assigned bugs
218 foreach ($_PERMISSION AS $name => $maskvalue)
220 define(strtoupper($name), $maskvalue);
223 /*=====================================================================*\
224 || ###################################################################
227 || ###################################################################
228 \*=====================================================================*/