]> src.bluestatic.org Git - bugdar.git/blob - includes/init.php
r780: Set apppath
[bugdar.git] / includes / init.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 error_reporting(E_ALL & ~E_NOTICE);
23
24 // ###################################################################
25 // initialize the database
26
27 define('ISSO_MT_START', microtime());
28 define('ISSO_CHECK_POST_REFERER', 1);
29
30 require_once('./framework/kernel.php');
31 $bugsys = new ISSO();
32
33 $bugsys->set('apppath', getcwd());
34 $bugsys->set('application', 'Bugdar');
35 $bugsys->set('appversion', '[#]verson[#]');
36
37 if (!file_exists('./includes/config.php'))
38 {
39 echo 'includes/config.php needs to be present!';
40 exit;
41 }
42
43 require_once('./includes/config.php');
44
45 $bugsys->set('debug', $debug);
46
47 define('ISSO_DB_LAYER', 'db_mysql');
48 $bugsys->load('db_mysql', 'db', true);
49 $db->connect($servername, $username, $password, $database, $usepconnect);
50
51 $bugsys->load('functions', 'funct', true);
52 $bugsys->exec_sanitize_data();
53
54 $bugsys->load('xml', 'xml', true);
55
56 // change cookie expiration to one hour
57 $funct->cookieexp = 3600;
58
59 define('DEVDEBUG', $debug);
60 define('TABLE_PREFIX', $tableprefix);
61 define('COOKIE_PREFIX', $cookieprefix);
62
63 unset($database, $servername, $theuser, $password, $thepass, $usepconnect, $tableprefix, $cookieprefix);
64
65 require_once('./includes/functions_datastore.php');
66 require_once('./includes/functions.php');
67
68 // ###################################################################
69 // init the big three
70 $bugsys->options = array();
71 $bugsys->userinfo = array();
72 $bugsys->datastore = array();
73
74 // ###################################################################
75 // send nocache
76 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
77 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
78 header("Cache-Control: no-store, no-cache, must-revalidate");
79 header("Cache-Control: post-check=0, pre-check=0", false);
80 header("Pragma: no-cache");
81
82 // ###################################################################
83 // populate our caches
84 $db->showerrors = false;
85 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX . "datastore");
86 $db->showerrors = true;
87
88 if (!$datastoretemp)
89 {
90 echo '<div style="font-size: 18px"><strong>Notice:</strong> This error could be caused if you have not installed Bugdar. If this is the case, you can run the installer <a href="install/install.php">here</a>.</div><br />';
91 $db->error('Invalid SQL error');
92 }
93
94 while ($store = $db->fetch_array($datastoretemp))
95 {
96 $bugsys->datastore["$store[title]"] = unserialize($store['data']);
97 }
98 $bugsys->options = $bugsys->datastore['setting'];
99 unset($bugsys->datastore['setting']);
100
101 // ###################################################################
102 // load userinfo
103 $userid = intval($bugsys->in[COOKIE_PREFIX . 'userid']);
104
105 if ($userid)
106 {
107 $userinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $userid");
108 if (is_array($userinfo) AND $bugsys->in[COOKIE_PREFIX . 'authkey'] == $userinfo['authkey'])
109 {
110 $userinfo['permissions'] = (int)$bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['permissions'];
111 $userinfo['displaytitle'] = $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['displaytitle'];
112 $bugsys->userinfo = $userinfo;
113 $funct->cookie(COOKIE_PREFIX . 'userid', $bugsys->userinfo['userid']);
114 $funct->cookie(COOKIE_PREFIX . 'authkey', $bugsys->userinfo['authkey']);
115 }
116 }
117
118 if (!$userinfo)
119 {
120 $funct->cookie(COOKIE_PREFIX . 'userid');
121 $funct->cookie(COOKIE_PREFIX . 'authkey');
122 $bugsys->userinfo = array(
123 'usergroupid' => 1,
124 'userid' => 0,
125 'email' => '',
126 'displayname' => '',
127 'showcolours' => 1,
128 'permissions' => $bugsys->datastore['usergroup'][1]['permissions'],
129 'displaytitle' => $bugsys->datastore['usergroup'][1]['displaytitle'],
130 );
131 }
132
133 // ###################################################################
134 // initialize localization system
135 $bugsys->load('localize', 'lang', true);
136
137 require_once('./includes/language.php');
138
139 $LANGDATA = fetch_user_language();
140 $lang->init_with_table(fetch_strings($LANGDATA['id']));
141
142 $stylevar['lang'] = $LANGDATA['code'];
143 $stylevar['lang_dir'] = $LANGDATA['direction'];
144 $stylevar['charset'] = $LANGDATA['charset'];
145
146 // ###################################################################
147 // initialize the date system
148 $bugsys->load('date', 'datef', true);
149 $datef->usertz = $bugsys->userinfo['timezone'];
150 $datef->fetch_offset();
151
152 // ###################################################################
153 // mail system
154 $bugsys->load('mail', 'mail', true);
155 $mail->set('from', $bugsys->options['webmasteremail']);
156 $mail->set('fromname', $lang->string('Bugdar Notification'));
157
158 // ###################################################################
159 // load permissions
160
161 require_once('./includes/permissions.php');
162
163 /*=====================================================================*\
164 || ###################################################################
165 || # $HeadURL$
166 || # $Id$
167 || ###################################################################
168 \*=====================================================================*/
169 ?>