r352: We do use the email system!
[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->load('mail');
45 $bugsys->exec_sanitize_data();
46
47 // change cookie expiration to one hour
48 $funct->cookieexp = 3600;
49
50 define('DEVDEBUG', $debug);
51 define('TABLE_PREFIX', $tableprefix);
52 define('COOKIE_PREFIX', $cookieprefix);
53
54 unset($database, $servername, $username, $password, $usepconnect, $tableprefix, $cookieprefix);
55
56 define('LOG_TIME', time());
57
58 require_once('./includes/functions_datastore.php');
59 require_once('./includes/functions.php');
60
61 // ###################################################################
62 // init the big three
63 $bugsys->options = array();
64 $bugsys->userinfo = array();
65 $bugsys->datastore = array();
66
67 // ###################################################################
68 // populate our caches
69 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX . "datastore");
70 while ($store = $db->fetch_array($datastoretemp))
71 {
72 $bugsys->datastore["$store[title]"] = unserialize($store['data']);
73 }
74 $bugsys->options = $bugsys->datastore['setting'];
75 unset($bugsys->datastore['setting']);
76
77 $mail->from = $bugsys->options['webmasteremail'];
78 $mail->fromname = 'BugStrike Notification';
79
80 // ###################################################################
81 // load userinfo
82 $userid = intval($bugsys->in[COOKIE_PREFIX . 'userid']);
83
84 if ($userid)
85 {
86 $userinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $userid");
87 if (is_array($userinfo) AND $bugsys->in[COOKIE_PREFIX . 'authkey'] == $userinfo['authkey'])
88 {
89 $userinfo['permissions'] = (int)$bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['permissions'];
90 $userinfo['displaytitle'] = $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['displaytitle'];
91 fetch_user_display_name($userinfo);
92 $userinfo['mdisplayname'] = $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['opentag'] . $userinfo['displayname'] . $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['closetag'];
93 $bugsys->userinfo = $userinfo;
94 $funct->cookie(COOKIE_PREFIX . 'userid', $bugsys->userinfo['userid']);
95 $funct->cookie(COOKIE_PREFIX . 'authkey', $bugsys->userinfo['authkey']);
96 }
97 }
98
99 if (!$userinfo)
100 {
101 $funct->cookie(COOKIE_PREFIX . 'userid');
102 $funct->cookie(COOKIE_PREFIX . 'authkey');
103 $bugsys->userinfo = array(
104 'usergroupid' => 1,
105 'userid' => 0,
106 'email' => '',
107 'displayname' => '',
108 'permissions' => $bugsys->datastore['usergroup'][1]['permissions'],
109 'displaytitle' => $bugsys->datastore['usergroup'][1]['displaytitle'],
110 'mdisplayname' => $bugsys->datastore['usergroup'][1]['opentag'] . '' . $bugsys->datastore['usergroup'][1]['closetag']
111 );
112 }
113
114 // ###################################################################
115 // load language information
116 require_once('./includes/class_language.php');
117 $bugsys->lang =& lang::init();
118
119 // ###################################################################
120 // initialize the date system
121 $bugsys->load('date');
122 $datef->usertz = $bugsys->userinfo['timezone'];
123 $datef->fetch_offset();
124
125 // ###################################################################
126 // Initialize usergroup system
127 $_PERMISSION = array(
128 'canviewbugs' => 1, // can view bugs
129 'cansearch' => 2, // can use the search
130 'cansubscribe' => 4, // can email subscribe
131 'canvote' => 8, // can vote on bugs
132 'cansubmitbugs' => 16, // can submit new bugs
133 'canpostcomments' => 32, // can post new comments
134 'cangetattach' => 64, // can dl attachments
135 'canputattach' => 128, // can ul attachments
136 'caneditown' => 256, // can edit own comments
137 'caneditothers' => 512, // can edit others' comments
138 'caneditinfo' => 1024, // can edit bug info -- works in conjunction with canedit(own|others)
139 'canassign' => 2048, // can assign bug
140 'canchangestatus' => 4096, // can change bug status
141 'canadminpanel' => 8192, // can view admin panel
142 'canadminbugs' => 16384, // can administrate bug functions
143 'canadminversions' => 32768, // can admin version info
144 'canadminusers' => 65536, // can admin users
145 'canadmingroups' => 131072, // can admin permission masks
146 'canadmintools' => 262144, // can use admin tools
147 'canadminfields' => 524288, // can admin custom bug fields
148 'canbeassignedto' => 1048576, // can be assigned bugs,
149 'caneditattach' => 2097152, // can edit attachments
150 'canviewhidden' => 4194304 // can see hidden bugs
151 );
152
153 foreach ($_PERMISSION AS $name => $maskvalue)
154 {
155 define(strtoupper($name), $maskvalue);
156 }
157
158 /*=====================================================================*\
159 || ###################################################################
160 || # $HeadURL$
161 || # $Id$
162 || ###################################################################
163 \*=====================================================================*/
164 ?>