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_MEMORY_START', memory_get_usage(true
));
29 define('ISSO_CHECK_POST_REFERER', 1);
31 require_once('./includes/version.php');
33 require_once('./framework/kernel.php');
36 $bugsys->setAppPath(getcwd());
37 $bugsys->setApplication('Bugdar');
38 $bugsys->setAppVersion(BUGDAR_VERSION
);
40 if (!file_exists('./includes/config.php'))
42 echo 'includes/config.php needs to be present!';
46 require_once('./includes/config.php');
48 $bugsys->setDebug($debug);
50 $bugsys->load('db_mysql_pdo', 'db', true
);
51 $db->connect($servername, $username, $password, $database, $usepconnect);
54 $db->query("SET NAMES utf8");
57 // don't use sql strict mode
58 $db->query("SET sql_mode = ''");
60 $bugsys->load('functions', 'funct', true
);
61 $bugsys->load('xml', 'xml', true
);
63 // change cookie expiration to one hour
64 $funct->cookieexp
= 3600;
66 define('DEVDEBUG', $debug);
67 define('TABLE_PREFIX', $tableprefix);
68 define('COOKIE_PREFIX', $cookieprefix);
70 unset($database, $servername, $theuser, $password, $thepass, $usepconnect, $tableprefix, $cookieprefix);
72 require_once('./includes/functions_datastore.php');
73 require_once('./includes/functions.php');
74 require_once('./includes/language.php');
76 // ###################################################################
78 $bugsys->options
= array();
79 $bugsys->userinfo
= array();
80 bugdar
::$datastore = array();
86 static $options = array();
87 static $user = array();
88 static $datastore = array();
91 bugdar
::$db = $db->dblink
;
93 // ###################################################################
95 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
96 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
97 header("Cache-Control: no-store, no-cache, must-revalidate");
98 header("Cache-Control: post-check=0, pre-check=0", false
);
101 header("Content-Type: text/html; charset=\"utf8\"");
103 header("Pragma: no-cache");
105 // ###################################################################
106 // populate our caches
107 $db->showerrors
= false
;
108 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX
. "datastore");
109 $db->showerrors
= true
;
113 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 />';
114 $db->error('Invalid SQL error');
117 while ($store = $db->fetch_array($datastoretemp))
119 bugdar
::$datastore["$store[title]"] = unserialize($store['data']);
122 $bugsys->options
= bugdar
::$datastore['setting'];
123 $bugsys->options
['columnoptions'] = unserialize($bugsys->options
['columnoptions']);
124 unset(bugdar
::$datastore['setting']);
125 bugdar
::$options = $bugsys->options
;
127 $bugsys->setAppVersion($bugsys->options
['trackerversion']);
129 // ###################################################################
132 require_once('./includes/permissions.php');
134 // ###################################################################
137 $authMethod = ((defined('USE_DEFAULT_AUTH_METHOD') AND constant('USE_DEFAULT_AUTH_METHOD') == 1) ?
'default' : $bugsys->options
['authmethod']);
138 require_once('./includes/auth/auth_' . $authMethod . '.php');
140 $authClass = 'Authentication' . str_replace(' ', '', ucwords(str_replace('_', ' ', $authMethod)));
141 $bugsys->auth
= $auth = new $authClass();
143 if ($auth->authenticateCookies())
145 $bugsys->userinfo
= $auth->fetchBugdarUser();
146 $bugsys->userinfo
['permissions'] = FetchUserPermissions($bugsys->userinfo
);
147 $bugsys->userinfo
['displaytitle'] = bugdar
::$datastore['usergroup'][ $bugsys->userinfo
['usergroupid'] ]['displaytitle'];
148 $bugsys->userinfo
['columnoptions'] = unserialize($bugsys->userinfo
['columnoptions']);
152 $bugsys->userinfo
= fetch_guest_user();
154 bugdar
::$user = $bugsys->userinfo
;
156 // ###################################################################
157 // initialize localization system
159 $language = fetch_user_language();
161 $stylevar['lang'] = $language['langcode'];
162 $stylevar['lang_dir'] = $language['direction'];
163 $stylevar['charset'] = $language['charset'];
164 $stylevar['left'] = ($language['direction'] == 'ltr' ?
'left' : 'right');
165 $stylevar['right'] = ($language['direction'] == 'ltr' ?
'right' : 'left');
167 require_once('./includes/definitions.php');
169 // ###################################################################
170 // initialize the date system
171 $bugsys->load('date', 'datef', true
);
172 $datef->usertz
= $bugsys->userinfo
['timezone'] +
($bugsys->userinfo
['usedst'] * 1);
173 $bugsys->debug('user tz = ' . $bugsys->userinfo
['timezone'] . '; use version = ' . $datef->usertz
);
174 $datef->fetch_offset();
176 // ###################################################################
178 $bugsys->load('mail', 'mail', true
);
179 $mail->setFromAddress($bugsys->options
['webmasteremail']);
180 $mail->setFromName(T('Bugdar Notification'));