]>
src.bluestatic.org Git - bugdar.git/blob - includes/init.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2009 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 // ###################################################################
27 define ( 'ISSO_MT_START' , microtime ());
28 define ( 'ISSO_CHECK_POST_REFERER' , 1 );
30 require_once ( './includes/version.php' );
32 if (! file_exists ( './includes/config.php' ))
34 echo 'includes/config.php needs to be present!' ;
38 require_once ( './includes/config.php' );
40 define ( 'ISSO' , getcwd () . '/includes/framework/' );
41 require_once ISSO
. '/App.php' ;
42 BSApp
:: set_debug ( $debug );
44 require_once ISSO
. '/Functions.php' ;
45 BSFunctions
:: set_cookie_timeout ( 3600 );
47 require_once ISSO
. '/Input.php' ;
48 $input = BSApp
:: $input = new BSInput ();
50 // ###################################################################
51 // initialize the database
53 require_once ISSO
. '/DbMySqlI.php' ;
54 $db = BSApp
:: $db = new BSDBMySQLI ();
56 $db- > connect ( $servername , $username , $password , $database );
59 $db- > query ( "SET NAMES utf8" );
62 define ( 'DEVDEBUG' , $debug );
63 define ( 'TABLE_PREFIX' , $tableprefix );
64 define ( 'COOKIE_PREFIX' , $cookieprefix );
66 unset ( $database , $servername , $theuser , $password , $thepass , $usepconnect , $tableprefix , $cookieprefix );
68 require_once ( './includes/functions_datastore.php' );
69 require_once ( './includes/functions.php' );
70 require_once ( './includes/language.php' );
72 // ###################################################################
77 public static $options = array ();
78 public static $userinfo = array ();
79 public static $datastore = array ();
81 public static $permissions = array ();
82 public static $emailOptions = array ();
84 private function __construct () {}
87 // ###################################################################
89 header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
90 header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . " GMT" );
91 header ( "Cache-Control: no-store, no-cache, must-revalidate" );
92 header ( "Cache-Control: post-check=0, pre-check=0" , false );
95 header ( "Content-Type: text/html; charset= \" utf8 \" " );
97 header ( "Pragma: no-cache" );
99 // ###################################################################
100 // populate our caches
101 $db- > showerrors
= false ;
102 $datastoretemp = $db- > query ( "SELECT * FROM " . TABLE_PREFIX
. "datastore" );
103 $db- > showerrors
= true ;
107 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 />' ;
108 $db- > error ( 'Invalid SQL error' );
111 foreach ( $datastoretemp as $store )
113 bugdar
:: $datastore [ " $store [title]" ] = unserialize ( $store [ 'data' ]);
115 bugdar
:: $options = bugdar
:: $datastore [ 'setting' ];
116 bugdar
:: $options [ 'columnoptions' ] = unserialize ( bugdar
:: $options [ 'columnoptions' ]);
117 unset ( bugdar
:: $datastore [ 'setting' ]);
119 // ###################################################################
122 require_once ( './includes/permissions.php' );
124 // ###################################################################
127 $authMethod = (( defined ( 'USE_DEFAULT_AUTH_METHOD' ) AND constant ( 'USE_DEFAULT_AUTH_METHOD' ) == 1 ) ? 'default' : bugdar
:: $options [ 'authmethod' ]);
128 require_once ( './includes/auth/auth_' . $authMethod . '.php' );
130 $authClass = 'Authentication' . str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , $authMethod )));
131 $auth = new $authClass ();
133 if ( $auth- > authenticateCookies ())
135 bugdar
:: $userinfo = $auth- > fetchBugdarUser ();
136 bugdar
:: $userinfo [ 'permissions' ] = FetchUserPermissions ( bugdar
:: $userinfo );
137 bugdar
:: $userinfo [ 'displaytitle' ] = bugdar
:: $datastore [ 'usergroup' ][ bugdar
:: $userinfo [ 'usergroupid' ] ][ 'displaytitle' ];
138 bugdar
:: $userinfo [ 'columnoptions' ] = unserialize ( bugdar
:: $userinfo [ 'columnoptions' ]);
142 bugdar
:: $userinfo = fetch_guest_user ();
145 // ###################################################################
146 // initialize localization system
148 $language = fetch_user_language ();
150 $stylevar [ 'lang' ] = $language [ 'langcode' ];
151 $stylevar [ 'lang_dir' ] = $language [ 'direction' ];
152 $stylevar [ 'charset' ] = $language [ 'charset' ];
153 $stylevar [ 'left' ] = ( $language [ 'direction' ] == 'ltr' ? 'left' : 'right' );
154 $stylevar [ 'right' ] = ( $language [ 'direction' ] == 'ltr' ? 'right' : 'left' );
156 // start gettext engine
157 if (! bugdar
:: $options [ 'devgettext' ])
159 putenv ( "LANG= $language [langcode]" );
160 putenv ( "LANGUAGE= $language [langcode]" );
162 setlocale ( LC_ALL
, $language [ 'langcode' ]);
164 bindtextdomain ( 'MESSAGES' , $bugsys- > apppath
. 'locale/' );
165 textdomain ( 'MESSAGES' );
167 bind_textdomain_codeset ( 'MESSAGES' , $language [ 'charset' ]);
171 BSApp
:: debug ( "using custom MOReader instead of Gettext" );
174 // ###################################################################
175 // initialize the date system
176 require_once ISSO
. '/Date.php' ;
177 $datef = BSApp
:: $date = new BSDate ();
178 $datef- > setUserTimeZone ( bugdar
:: $userinfo [ 'timezone' ] +
( bugdar
:: $userinfo [ 'usedst' ] * 1 ));
179 BSApp
:: debug ( 'user tz = ' . bugdar
:: $userinfo [ 'timezone' ] . '; use version = ' . $datef- > usertz
);