r665: Renaming product from "BugStrike" to "Bugdar"
[bugdar.git] / includes / init.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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 = 'Bugdar';
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 // send nocache
68 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
69 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
70 header("Cache-Control: no-store, no-cache, must-revalidate");
71 header("Cache-Control: post-check=0, pre-check=0", false);
72 header("Pragma: no-cache");
73
74 // ###################################################################
75 // populate our caches
76 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX . "datastore");
77 while ($store = $db->fetch_array($datastoretemp))
78 {
79 $bugsys->datastore["$store[title]"] = unserialize($store['data']);
80 }
81 $bugsys->options = $bugsys->datastore['setting'];
82 unset($bugsys->datastore['setting']);
83
84 // ###################################################################
85 // load userinfo
86 $userid = intval($bugsys->in[COOKIE_PREFIX . 'userid']);
87
88 if ($userid)
89 {
90 $userinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $userid");
91 if (is_array($userinfo) AND $bugsys->in[COOKIE_PREFIX . 'authkey'] == $userinfo['authkey'])
92 {
93 $userinfo['permissions'] = (int)$bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['permissions'];
94 $userinfo['displaytitle'] = $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['displaytitle'];
95 $bugsys->userinfo = $userinfo;
96 $funct->cookie(COOKIE_PREFIX . 'userid', $bugsys->userinfo['userid']);
97 $funct->cookie(COOKIE_PREFIX . 'authkey', $bugsys->userinfo['authkey']);
98 }
99 }
100
101 if (!$userinfo)
102 {
103 $funct->cookie(COOKIE_PREFIX . 'userid');
104 $funct->cookie(COOKIE_PREFIX . 'authkey');
105 $bugsys->userinfo = array(
106 'usergroupid' => 1,
107 'userid' => 0,
108 'email' => '',
109 'displayname' => '',
110 'showcolours' => 1,
111 'permissions' => $bugsys->datastore['usergroup'][1]['permissions'],
112 'displaytitle' => $bugsys->datastore['usergroup'][1]['displaytitle'],
113 );
114 }
115
116 // ###################################################################
117 // initialize localization system
118 $bugsys->load('localize');
119
120 require_once('./includes/language.php');
121
122 $LANGDATA = fetch_user_language();
123 $lang->init_with_table(fetch_strings($LANGDATA['id']));
124
125 $stylevar['lang'] = $LANGDATA['code'];
126 $stylevar['lang_dir'] = $LANGDATA['direction'];
127 $stylevar['charset'] = $LANGDATA['charset'];
128
129 // ###################################################################
130 // initialize the date system
131 $bugsys->load('date');
132 $datef->usertz = $bugsys->userinfo['timezone'];
133 $datef->fetch_offset();
134
135 // ###################################################################
136 // mail system
137 $bugsys->load('mail');
138 $mail->from = $bugsys->options['webmasteremail'];
139 $mail->fromname = $lang->string('Bugdar Notification');
140
141 // ###################################################################
142 // load permissions
143
144 require_once('./includes/permissions.php');
145
146 /*=====================================================================*\
147 || ###################################################################
148 || # $HeadURL$
149 || # $Id$
150 || ###################################################################
151 \*=====================================================================*/
152 ?>