r765: Say hello to the GPL
[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
29 if (!file_exists('./includes/config.php'))
30 {
31 echo 'includes/config.php needs to be present!';
32 exit;
33 }
34
35 require_once('./includes/config.php');
36 $thepass = $password; // GAH register_globals
37 $theuser = $username;
38
39 define('ISSO_ESCAPE_STRINGS', 1);
40 define('ISSO_CHECK_POST_REFERER', 1);
41
42 require_once($pathtoisso . 'kernel.php');
43 $bugsys =& $_isso;
44 $bugsys->application = 'Bugdar';
45 $bugsys->apppath = $bugsys->fetch_sourcepath(getcwd());
46 $bugsys->appversion = '[#]version[#]';
47 $bugsys->debug = $debug;
48 $bugsys->sourcepath = $bugsys->fetch_sourcepath($pathtoisso);
49
50 $bugsys->load('db_mysql');
51 $db->database = $database;
52 $db->connect($servername, $username, $thepass, $usepconnect);
53
54 $bugsys->load('functions');
55 $bugsys->exec_sanitize_data();
56
57 $bugsys->load('xml');
58
59 // change cookie expiration to one hour
60 $funct->cookieexp = 3600;
61
62 define('DEVDEBUG', $debug);
63 define('TABLE_PREFIX', $tableprefix);
64 define('COOKIE_PREFIX', $cookieprefix);
65
66 unset($database, $servername, $theuser, $password, $thepass, $usepconnect, $tableprefix, $cookieprefix);
67
68 require_once('./includes/functions_datastore.php');
69 require_once('./includes/functions.php');
70
71 // ###################################################################
72 // init the big three
73 $bugsys->options = array();
74 $bugsys->userinfo = array();
75 $bugsys->datastore = array();
76
77 // ###################################################################
78 // send nocache
79 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
80 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
81 header("Cache-Control: no-store, no-cache, must-revalidate");
82 header("Cache-Control: post-check=0, pre-check=0", false);
83 header("Pragma: no-cache");
84
85 // ###################################################################
86 // populate our caches
87 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX . "datastore");
88 while ($store = $db->fetch_array($datastoretemp))
89 {
90 $bugsys->datastore["$store[title]"] = unserialize($store['data']);
91 }
92 $bugsys->options = $bugsys->datastore['setting'];
93 unset($bugsys->datastore['setting']);
94
95 // ###################################################################
96 // load userinfo
97 $userid = intval($bugsys->in[COOKIE_PREFIX . 'userid']);
98
99 if ($userid)
100 {
101 $userinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $userid");
102 if (is_array($userinfo) AND $bugsys->in[COOKIE_PREFIX . 'authkey'] == $userinfo['authkey'])
103 {
104 $userinfo['permissions'] = (int)$bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['permissions'];
105 $userinfo['displaytitle'] = $bugsys->datastore['usergroup']["$userinfo[usergroupid]"]['displaytitle'];
106 $bugsys->userinfo = $userinfo;
107 $funct->cookie(COOKIE_PREFIX . 'userid', $bugsys->userinfo['userid']);
108 $funct->cookie(COOKIE_PREFIX . 'authkey', $bugsys->userinfo['authkey']);
109 }
110 }
111
112 if (!$userinfo)
113 {
114 $funct->cookie(COOKIE_PREFIX . 'userid');
115 $funct->cookie(COOKIE_PREFIX . 'authkey');
116 $bugsys->userinfo = array(
117 'usergroupid' => 1,
118 'userid' => 0,
119 'email' => '',
120 'displayname' => '',
121 'showcolours' => 1,
122 'permissions' => $bugsys->datastore['usergroup'][1]['permissions'],
123 'displaytitle' => $bugsys->datastore['usergroup'][1]['displaytitle'],
124 );
125 }
126
127 // ###################################################################
128 // initialize localization system
129 $bugsys->load('localize');
130
131 require_once('./includes/language.php');
132
133 $LANGDATA = fetch_user_language();
134 $lang->init_with_table(fetch_strings($LANGDATA['id']));
135
136 $stylevar['lang'] = $LANGDATA['code'];
137 $stylevar['lang_dir'] = $LANGDATA['direction'];
138 $stylevar['charset'] = $LANGDATA['charset'];
139
140 // ###################################################################
141 // initialize the date system
142 $bugsys->load('date');
143 $datef->usertz = $bugsys->userinfo['timezone'];
144 $datef->fetch_offset();
145
146 // ###################################################################
147 // mail system
148 $bugsys->load('mail');
149 $mail->from = $bugsys->options['webmasteremail'];
150 $mail->fromname = $lang->string('Bugdar Notification');
151
152 // ###################################################################
153 // load permissions
154
155 require_once('./includes/permissions.php');
156
157 /*=====================================================================*\
158 || ###################################################################
159 || # $HeadURL$
160 || # $Id$
161 || ###################################################################
162 \*=====================================================================*/
163 ?>