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