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 require_once('./includes/version.php');
32 require_once('./framework/kernel.php');
35 $bugsys->setAppPath(getcwd());
36 $bugsys->setApplication('Bugdar');
37 $bugsys->setAppVersion(BUGDAR_VERSION
);
39 if (!file_exists('./includes/config.php'))
41 echo 'includes/config.php needs to be present!';
45 require_once('./includes/config.php');
47 $bugsys->setDebug($debug);
49 $bugsys->load('db_mysql_pdo', 'db', true
);
50 $db->connect($servername, $username, $password, $database, $usepconnect);
53 $db->query("SET NAMES utf8");
56 // don't use sql strict mode
57 $db->query("SET sql_mode = ''");
59 $bugsys->load('functions', 'funct', true
);
60 $bugsys->load('xml', 'xml', true
);
62 // change cookie expiration to one hour
63 $funct->cookieexp
= 3600;
65 define('DEVDEBUG', $debug);
66 define('TABLE_PREFIX', $tableprefix);
67 define('COOKIE_PREFIX', $cookieprefix);
69 unset($database, $servername, $theuser, $password, $thepass, $usepconnect, $tableprefix, $cookieprefix);
71 require_once('./includes/functions_datastore.php');
72 require_once('./includes/functions.php');
73 require_once('./includes/language.php');
75 // ###################################################################
77 $bugsys->options
= array();
78 $bugsys->userinfo
= array();
79 bugdar
::$datastore = array();
85 static $options = array();
86 static $user = array();
87 static $datastore = array();
90 bugdar
::$db = $db->dblink
;
92 // ###################################################################
94 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
95 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
96 header("Cache-Control: no-store, no-cache, must-revalidate");
97 header("Cache-Control: post-check=0, pre-check=0", false
);
100 header("Content-Type: text/html; charset=\"utf8\"");
102 header("Pragma: no-cache");
104 // ###################################################################
105 // populate our caches
106 $db->showerrors
= false
;
107 $datastoretemp = $db->query("SELECT * FROM " . TABLE_PREFIX
. "datastore");
108 $db->showerrors
= true
;
112 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 />';
113 $db->error('Invalid SQL error');
116 while ($store = $db->fetch_array($datastoretemp))
118 bugdar
::$datastore["$store[title]"] = unserialize($store['data']);
121 $bugsys->options
= bugdar
::$datastore['setting'];
122 $bugsys->options
['columnoptions'] = unserialize($bugsys->options
['columnoptions']);
123 unset(bugdar
::$datastore['setting']);
124 bugdar
::$options = $bugsys->options
;
126 $bugsys->setAppVersion($bugsys->options
['trackerversion']);
128 // ###################################################################
131 require_once('./includes/permissions.php');
133 // ###################################################################
136 $authMethod = ((defined('USE_DEFAULT_AUTH_METHOD') AND constant('USE_DEFAULT_AUTH_METHOD') == 1) ?
'default' : $bugsys->options
['authmethod']);
137 require_once('./includes/auth/auth_' . $authMethod . '.php');
139 $authClass = 'Authentication' . str_replace(' ', '', ucwords(str_replace('_', ' ', $authMethod)));
140 $bugsys->auth
= $auth = new $authClass();
142 if ($auth->authenticateCookies())
144 $bugsys->userinfo
= $auth->fetchBugdarUser();
145 $bugsys->userinfo
['permissions'] = FetchUserPermissions($bugsys->userinfo
);
146 $bugsys->userinfo
['displaytitle'] = bugdar
::$datastore['usergroup'][ $bugsys->userinfo
['usergroupid'] ]['displaytitle'];
147 $bugsys->userinfo
['columnoptions'] = unserialize($bugsys->userinfo
['columnoptions']);
151 $bugsys->userinfo
= fetch_guest_user();
153 bugdar
::$user = $bugsys->userinfo
;
155 // ###################################################################
156 // initialize localization system
158 $language = fetch_user_language();
160 $stylevar['lang'] = $language['langcode'];
161 $stylevar['lang_dir'] = $language['direction'];
162 $stylevar['charset'] = $language['charset'];
163 $stylevar['left'] = ($language['direction'] == 'ltr' ?
'left' : 'right');
164 $stylevar['right'] = ($language['direction'] == 'ltr' ?
'right' : 'left');
166 // start gettext engine
167 if (!$bugsys->options
['devgettext'])
169 putenv("LANG=$language[langcode]");
170 putenv("LANGUAGE=$language[langcode]");
172 setlocale(LC_ALL
, $language['langcode']);
174 bindtextdomain('MESSAGES', $bugsys->apppath
. 'locale/');
175 textdomain('MESSAGES');
177 bind_textdomain_codeset('MESSAGES', $language['charset']);
181 $bugsys->debug("using custom MOReader instead of Gettext");
184 require_once('./includes/definitions.php');
186 // ###################################################################
187 // initialize the date system
188 $bugsys->load('date', 'datef', true
);
189 $datef->usertz
= $bugsys->userinfo
['timezone'] +
($bugsys->userinfo
['usedst'] * 1);
190 $bugsys->debug('user tz = ' . $bugsys->userinfo
['timezone'] . '; use version = ' . $datef->usertz
);
191 $datef->fetch_offset();
193 // ###################################################################
195 $bugsys->load('mail', 'mail', true
);
196 $mail->setFromAddress($bugsys->options
['webmasteremail']);
197 $mail->setFromName(T('Bugdar Notification'));