r514: - Now three different ID's that can be logged (bug, comment, attachment)
[bugdar.git] / includes / init.php
1 <?php
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 \*=====================================================================*/
12
13 error_reporting(E_ALL & ~E_NOTICE);
14
15 // ###################################################################
16 // initialize the database
17
18 define('ISSO_MT_START', microtime());
19
20 if (!file_exists('./includes/config.php'))
21 {
22 echo 'includes/config.php needs to be present!';
23 exit;
24 }
25
26 require_once('./includes/config.php');
27
28 define('ISSO_ESCAPE_STRINGS', 1);
29 define('ISSO_CHECK_POST_REFERER', 1);
30
31 require_once($pathtoisso . 'kernel.php');
32 $bugsys =& $_isso;
33 $bugsys->application = 'BugStrike';
34 $bugsys->apppath = $bugsys->fetch_sourcepath(getcwd());
35 $bugsys->appversion = '[#]version[#]';
36 $bugsys->debug = $debug;
37 $bugsys->sourcepath = $bugsys->fetch_sourcepath($pathtoisso);
38
39 $bugsys->load('db_mysql');
40 $db->database = $database;
41 $db->connect($servername, $username, $password, $usepconnect);
42
43 $bugsys->load('functions');
44 $bugsys->exec_sanitize_data();
45
46 $bugsys->load('xml');
47
48 // change cookie expiration to one hour
49 $funct->cookieexp = 3600;
50
51 define('DEVDEBUG', $debug);
52 define('TABLE_PREFIX', $tableprefix);
53 define('COOKIE_PREFIX', $cookieprefix);
54
55 unset($database, $servername, $username, $password, $usepconnect, $tableprefix, $cookieprefix);
56
57 require_once('./includes/functions_datastore.php');
58 require_once('./includes/functions.php');
59
60 // ###################################################################
61 // init the big three
62 $bugsys->options = array();
63 $bugsys->userinfo = array();
64 $bugsys->datastore = array();
65
66 // ###################################################################
67 // populate our caches
68 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX . "datastore");
69 while ($store = $db->fetch_array($datastoretemp))
70 {
71 $bugsys->datastore["$store[title]"] = unserialize($store['data']);
72 }
73 $bugsys->options = $bugsys->datastore['setting'];
74 unset($bugsys->datastore['setting']);
75
76 // ###################################################################
77 // load userinfo
78 $userid = intval($bugsys->in[COOKIE_PREFIX . 'userid']);
79
80 if ($userid)
81 {
82 $userinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $userid");
83 if (is_array($userinfo) AND $bugsys->in[COOKIE_PREFIX . 'authkey'] == $userinfo['authkey'])
84 {
85 $userinfo['permissions'] = (int)$bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['permissions'];
86 $userinfo['displaytitle'] = $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['displaytitle'];
87 fetch_user_display_name($userinfo);
88 $userinfo['mdisplayname'] = $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['opentag'] . $userinfo['displayname'] . $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['closetag'];
89 $bugsys->userinfo = $userinfo;
90 $funct->cookie(COOKIE_PREFIX . 'userid', $bugsys->userinfo['userid']);
91 $funct->cookie(COOKIE_PREFIX . 'authkey', $bugsys->userinfo['authkey']);
92 }
93 }
94
95 if (!$userinfo)
96 {
97 $funct->cookie(COOKIE_PREFIX . 'userid');
98 $funct->cookie(COOKIE_PREFIX . 'authkey');
99 $bugsys->userinfo = array(
100 'usergroupid' => 1,
101 'userid' => 0,
102 'email' => '',
103 'displayname' => '',
104 'showcolours' => 1,
105 'permissions' => $bugsys->datastore['usergroup'][1]['permissions'],
106 'displaytitle' => $bugsys->datastore['usergroup'][1]['displaytitle'],
107 'mdisplayname' => $bugsys->datastore['usergroup'][1]['opentag'] . '' . $bugsys->datastore['usergroup'][1]['closetag']
108 );
109 }
110
111 // ###################################################################
112 // initialize localization system
113 $bugsys->load('localize');
114
115 require_once('./includes/language.php');
116
117 $LANGDATA = fetch_user_language();
118 $lang->init_with_table(fetch_strings($LANGDATA['id']));
119
120 $stylevar['lang'] = $LANGDATA['code'];
121
122 // ###################################################################
123 // initialize the date system
124 $bugsys->load('date');
125 $datef->usertz = $bugsys->userinfo['timezone'];
126 $datef->fetch_offset();
127
128 // ###################################################################
129 // mail system
130 $bugsys->load('mail');
131 $mail->from = $bugsys->options['webmasteremail'];
132 $mail->fromname = $lang->string('BugStrike Notification');
133
134 // ###################################################################
135 // Initialize usergroup system
136 $_PERMISSION = array(
137 'canviewbugs' => 1, // can view bugs
138 'cansearch' => 2, // can use the search
139 'cansubscribe' => 4, // can email subscribe
140 'canvote' => 8, // can vote on bugs
141 'cansubmitbugs' => 16, // can submit new bugs
142 'canpostcomments' => 32, // can post new comments
143 'cangetattach' => 64, // can dl attachments
144 'canputattach' => 128, // can ul attachments
145 'caneditown' => 256, // can edit own comments
146 'caneditothers' => 512, // can edit others' comments
147 'caneditinfo' => 1024, // can edit bug info -- works in conjunction with canedit(own|others)
148 'canassign' => 2048, // can assign bug
149 'canchangestatus' => 4096, // can change bug status
150 'canadminpanel' => 8192, // can view admin panel
151 'canadminbugs' => 16384, // can administrate bug functions
152 'canadminversions' => 32768, // can admin version info
153 'canadminusers' => 65536, // can admin users
154 'canadmingroups' => 131072, // can admin permission masks
155 'canadmintools' => 262144, // can use admin tools
156 'canadminfields' => 524288, // can admin custom bug fields
157 'canbeassignedto' => 1048576, // can be assigned bugs,
158 'caneditattach' => 2097152, // can edit attachments
159 'canviewhidden' => 4194304 // can see hidden bugs
160 );
161
162 foreach ($_PERMISSION AS $name => $maskvalue)
163 {
164 define(strtoupper($name), $maskvalue);
165 }
166
167 /*=====================================================================*\
168 || ###################################################################
169 || # $HeadURL$
170 || # $Id$
171 || ###################################################################
172 \*=====================================================================*/
173 ?>