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