aa31eaa84b47335a37484af402f8bfda8771ee9b
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2002-2007 Blue Static
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 2 of the License.
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
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 \*=====================================================================*/
22 error_reporting(E_ALL
& ~E_NOTICE
);
24 // ###################################################################
25 // initialize the database
27 define('ISSO_MT_START', microtime());
28 define('ISSO_CHECK_POST_REFERER', 1);
30 // TODO(port): Define this in index.php instead.
31 define('BUGDAR_ROOT', dirname(dirname(__FILE__
)));
33 require_once('./includes/version.php');
35 require_once('./framework/kernel.php');
38 $bugsys->setAppPath(getcwd());
39 $bugsys->setApplication('Bugdar');
40 $bugsys->setAppVersion(BUGDAR_VERSION
);
42 if (!file_exists('./includes/config.php'))
44 echo 'includes/config.php needs to be present!';
48 require_once('./includes/config.php');
50 $bugsys->setDebug($debug);
51 define('DEVDEBUG', $debug);
54 // ###################################################################
56 $bugsys->options
= array();
57 $bugsys->userinfo
= array();
61 /*! @var \PDO The database connection instance. */
64 static $options = array();
65 static $user = array();
66 static $datastore = array();
69 // ###################################################################
70 // Hoplite early initialization.
72 define('HOPLITE_ROOT', dirname(__FILE__
) . '/hoplite');
75 require_once HOPLITE_ROOT
. '/base/profiling.php';
76 \hoplite
\base\Profiling
::EnableProfiling();
79 // ###################################################################
80 // Connect to the database.
84 require_once HOPLITE_ROOT
. '/data/profiling_pdo.php';
85 $pdo_class = '\\hoplite\\data\\ProfilingPDO';
87 Bugdar
::$db = new $pdo_class("mysql:dbname=$database;host=$servername", $username, $password);
88 unset($database, $servername, $username, $password);
90 // Let ISSO handle the database connection failure message.
91 $bugsys->load('db_mysql_pdo', 'db', true
);
92 $db->connect(Bugdar
::$db);
94 Bugdar
::$db->SetAttribute(\PDO
::ATTR_ERRMODE
, \PDO
::ERRMODE_WARNING
);
95 Bugdar
::$db->SetAttribute(\PDO
::ATTR_EMULATE_PREPARES
, FALSE
);
96 Bugdar
::$db->SetAttribute(\PDO
::ATTR_STRINGIFY_FETCHES
, FALSE
);
100 $db->query("SET NAMES utf8");
103 // don't use sql strict mode
104 $db->query("SET sql_mode = ''");
106 $bugsys->load('functions', 'funct', true
);
107 $bugsys->load('xml', 'xml', true
);
109 // change cookie expiration to one hour
110 $funct->cookieexp
= 3600;
112 define('TABLE_PREFIX', $tableprefix);
113 define('COOKIE_PREFIX', $cookieprefix);
115 unset($usepconnect, $tableprefix, $cookieprefix);
117 require_once('./includes/functions_datastore.php');
118 require_once('./includes/functions.php');
119 require_once('./includes/language.php');
121 // ###################################################################
122 // Hoplite late initialization.
124 require_once HOPLITE_ROOT
. '/data/model.php';
125 \hoplite\data\Model
::set_db(Bugdar
::$db);
127 // ###################################################################
129 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
130 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
131 header("Cache-Control: no-store, no-cache, must-revalidate");
132 header("Cache-Control: post-check=0, pre-check=0", false
);
135 header("Content-Type: text/html; charset=\"utf8\"");
137 header("Pragma: no-cache");
139 // ###################################################################
140 // populate our caches
141 $db->showerrors
= false
;
142 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX
. "datastore");
143 $db->showerrors
= true
;
147 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 />';
148 $db->error('Invalid SQL error');
151 while ($store = $db->fetch_array($datastoretemp))
153 Bugdar
::$datastore["$store[title]"] = unserialize($store['data']);
156 $bugsys->options
= Bugdar
::$datastore['setting'];
157 $bugsys->options
['columnoptions'] = unserialize($bugsys->options
['columnoptions']);
158 unset(Bugdar
::$datastore['setting']);
159 Bugdar
::$options = $bugsys->options
;
161 $bugsys->setAppVersion($bugsys->options
['trackerversion']);
163 // ###################################################################
166 require_once('./includes/permissions.php');
168 // ###################################################################
171 $authMethod = ((defined('USE_DEFAULT_AUTH_METHOD') AND constant('USE_DEFAULT_AUTH_METHOD') == 1) ?
'default' : $bugsys->options
['authmethod']);
172 require_once('./includes/auth/auth_' . $authMethod . '.php');
174 $authClass = 'Authentication' . str_replace(' ', '', ucwords(str_replace('_', ' ', $authMethod)));
175 $bugsys->auth
= $auth = new $authClass();
177 if ($auth->authenticateCookies())
179 $bugsys->userinfo
= $auth->fetchBugdarUser();
180 $bugsys->userinfo
['permissions'] = FetchUserPermissions($bugsys->userinfo
);
181 $bugsys->userinfo
['displaytitle'] = Bugdar
::$datastore['usergroup'][ $bugsys->userinfo
['usergroupid'] ]['displaytitle'];
182 $bugsys->userinfo
['columnoptions'] = unserialize($bugsys->userinfo
['columnoptions']);
186 $bugsys->userinfo
= fetch_guest_user();
188 Bugdar
::$user = $bugsys->userinfo
;
190 // ###################################################################
191 // initialize localization system
193 $language = fetch_user_language();
195 $stylevar['lang'] = $language['langcode'];
196 $stylevar['lang_dir'] = $language['direction'];
197 $stylevar['charset'] = $language['charset'];
198 $stylevar['left'] = ($language['direction'] == 'ltr' ?
'left' : 'right');
199 $stylevar['right'] = ($language['direction'] == 'ltr' ?
'right' : 'left');
201 require_once('./includes/definitions.php');
203 // ###################################################################
204 // initialize the date system
205 $bugsys->load('date', 'datef', true
);
206 $datef->usertz
= $bugsys->userinfo
['timezone'] +
($bugsys->userinfo
['usedst'] * 1);
207 $bugsys->debug('user tz = ' . $bugsys->userinfo
['timezone'] . '; use version = ' . $datef->usertz
);
208 $datef->fetch_offset();
210 // ###################################################################
212 $bugsys->load('mail', 'mail', true
);
213 $mail->setFromAddress($bugsys->options
['webmasteremail']);
214 $mail->setFromName(T('Bugdar Notification'));