]>
src.bluestatic.org Git - bugdar.git/blob - includes/init.php
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 /*! @var \hoplite\http\Input Input filter for the new stack. */
67 static $options = array ();
68 static $user = array ();
69 static $datastore = array ();
72 // ###################################################################
73 // Hoplite early initialization.
75 define ( 'HOPLITE_ROOT' , dirname ( __FILE__
) . '/hoplite' );
78 require_once HOPLITE_ROOT
. '/base/profiling.php' ;
79 \hoplite\base\Profiling
:: EnableProfiling ();
82 // ###################################################################
83 // Connect to the database.
87 require_once HOPLITE_ROOT
. '/data/profiling_pdo.php' ;
88 $pdo_class = ' \\ hoplite \\ data \\ ProfilingPDO' ;
90 Bugdar
:: $db = new $pdo_class ( "mysql:dbname= $database ;host= $servername" , $username , $password );
91 unset( $database , $servername , $username , $password );
93 // Let ISSO handle the database connection failure message.
94 $bugsys- >load('db_mysql_pdo', 'db', true);
95 $db- >connect(Bugdar:: $db );
97 Bugdar:: $db- >SetAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
98 Bugdar:: $db- >SetAttribute(\PDO::ATTR_EMULATE_PREPARES, FALSE);
99 Bugdar:: $db- >SetAttribute(\PDO::ATTR_STRINGIFY_FETCHES, FALSE);
103 $db- >query(" SET NAMES utf8
");
106 // don't use sql strict mode
107 $db- >query(" SET sql_mode
= '' ");
109 $bugsys- >load('functions', 'funct', true);
110 $bugsys- >load('xml', 'xml', true);
112 // change cookie expiration to one hour
113 $funct- >cookieexp = 3600;
115 define('TABLE_PREFIX', $tableprefix );
116 define('COOKIE_PREFIX', $cookieprefix );
118 unset( $usepconnect , $tableprefix , $cookieprefix );
120 require_once('./includes/functions_datastore.php');
121 require_once('./includes/functions.php');
122 require_once('./includes/language.php');
124 // ###################################################################
125 // Hoplite late initialization.
127 require_once HOPLITE_ROOT . '/data/model.php';
128 \hoplite\data\Model::set_db(Bugdar:: $db );
130 require_once HOPLITE_ROOT . '/http/input.php';
131 Bugdar:: $input = new \hoplite\http\Input(\hoplite\http\Input::TYPE_HTML);
133 // ###################################################################
135 header(" Expires
: Mon
, 26 Jul
1997 05 : 00 : 00 GMT
");
136 header(" Last
- Modified
: " . gmdate(" D
, d M Y H
: i
: s
") . " GMT
");
137 header(" Cache
- Control
: no
- store
, no
- cache
, must
- revalidate
");
138 header(" Cache
- Control
: post
- check
= 0 , pre
- check
= 0 ", false);
141 header(" Content
- Type
: text
/ html
; charset
=\" utf8\"
");
143 header(" Pragma
: no
- cache
");
145 // ###################################################################
146 // populate our caches
147 $db- >showerrors = false;
148 $datastoretemp = $db- >query(" SELECT
* FROM
" . TABLE_PREFIX . " datastore
");
149 $db- >showerrors = true;
153 echo '<div style=" font
- size
: 18 px
"><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 />';
154 $db- >error('Invalid SQL error');
157 while ( $store = $db- >fetch_array( $datastoretemp ))
159 Bugdar:: $datastore [" $store [ title
] "] = unserialize( $store ['data']);
162 $bugsys- >options = Bugdar:: $datastore ['setting'];
163 $bugsys- >options['columnoptions'] = unserialize( $bugsys- >options['columnoptions']);
164 unset(Bugdar:: $datastore ['setting']);
165 Bugdar:: $options = $bugsys- >options;
167 $bugsys- >setAppVersion( $bugsys- >options['trackerversion']);
169 // ###################################################################
172 require_once('./includes/permissions.php');
174 // ###################################################################
177 $authMethod = ((defined('USE_DEFAULT_AUTH_METHOD') AND constant('USE_DEFAULT_AUTH_METHOD') == 1) ? 'default' : $bugsys- >options['authmethod']);
178 require_once('./includes/auth/auth_' . $authMethod . '.php');
180 $authClass = 'Authentication' . str_replace(' ', '', ucwords(str_replace('_', ' ', $authMethod )));
181 $bugsys- >auth = $auth = new $authClass ();
183 if ( $auth- >authenticateCookies())
185 $bugsys- >userinfo = $auth- >fetchBugdarUser();
186 $bugsys- >userinfo['permissions'] = FetchUserPermissions( $bugsys- >userinfo);
187 $bugsys- >userinfo['displaytitle'] = Bugdar:: $datastore ['usergroup'][ $bugsys- >userinfo['usergroupid'] ]['displaytitle'];
188 $bugsys- >userinfo['columnoptions'] = unserialize( $bugsys- >userinfo['columnoptions']);
192 $bugsys- >userinfo = fetch_guest_user();
194 Bugdar:: $user = $bugsys- >userinfo;
196 // ###################################################################
197 // initialize localization system
199 $language = fetch_user_language();
201 $stylevar ['lang'] = $language ['langcode'];
202 $stylevar ['lang_dir'] = $language ['direction'];
203 $stylevar ['charset'] = $language ['charset'];
204 $stylevar ['left'] = ( $language ['direction'] == 'ltr' ? 'left' : 'right');
205 $stylevar ['right'] = ( $language ['direction'] == 'ltr' ? 'right' : 'left');
207 require_once('./includes/definitions.php');
209 // ###################################################################
210 // initialize the date system
211 $bugsys- >load('date', 'datef', true);
212 $datef- >usertz = $bugsys- >userinfo['timezone'] + ( $bugsys- >userinfo['usedst'] * 1);
213 $bugsys- >debug('user tz = ' . $bugsys- >userinfo['timezone'] . '; use version = ' . $datef- >usertz);
214 $datef- >fetch_offset();
216 // ###################################################################
218 $bugsys- >load('mail', 'mail', true);
219 $mail- >setFromAddress( $bugsys- >options['webmasteremail']);
220 $mail- >setFromName(T('Bugdar Notification'));