]>
src.bluestatic.org Git - bugdar.git/blob - init.php
65e0868b38ab42f47af953467035a5d7543e8ed2
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©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 define ( 'ISSO_DB_LAYER' , 'db_mysql' );
50 $bugsys- > load ( 'db_mysql' , 'db' , true );
51 $db- > connect ( $servername , $username , $password , $database , $usepconnect );
54 $db- > query ( "SET NAMES utf8" );
57 $bugsys- > load ( 'functions' , 'funct' , true );
58 $bugsys- > load ( 'xml' , 'xml' , true );
60 // change cookie expiration to one hour
61 $funct- > cookieexp
= 3600 ;
63 define ( 'DEVDEBUG' , $debug );
64 define ( 'TABLE_PREFIX' , $tableprefix );
65 define ( 'COOKIE_PREFIX' , $cookieprefix );
67 unset ( $database , $servername , $theuser , $password , $thepass , $usepconnect , $tableprefix , $cookieprefix );
69 require_once ( './includes/functions_datastore.php' );
70 require_once ( './includes/functions.php' );
71 require_once ( './includes/language.php' );
73 // ###################################################################
75 $bugsys- > options
= array ();
76 $bugsys- > userinfo
= array ();
77 $bugsys- > datastore
= array ();
79 // ###################################################################
81 header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
82 header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . " GMT" );
83 header ( "Cache-Control: no-store, no-cache, must-revalidate" );
84 header ( "Cache-Control: post-check=0, pre-check=0" , false );
87 header ( "Content-Type: text/html; charset= \" utf8 \" " );
89 header ( "Pragma: no-cache" );
91 // ###################################################################
92 // populate our caches
93 $db- > showerrors
= false ;
94 $datastoretemp = $db- > query ( "SELECT * FROM " . TABLE_PREFIX
. "datastore" );
95 $db- > showerrors
= true ;
99 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 />' ;
100 $db- > error ( 'Invalid SQL error' );
103 while ( $store = $db- > fetch_array ( $datastoretemp ))
105 $bugsys- > datastore
[ " $store [title]" ] = unserialize ( $store [ 'data' ]);
107 $bugsys- > options
= $bugsys- > datastore
[ 'setting' ];
108 $bugsys- > options
[ 'columnoptions' ] = unserialize ( $bugsys- > options
[ 'columnoptions' ]);
109 unset ( $bugsys- > datastore
[ 'setting' ]);
111 $bugsys- > setAppVersion ( $bugsys- > options
[ 'trackerversion' ]);
113 // ###################################################################
116 require_once ( './includes/permissions.php' );
118 // ###################################################################
121 $authMethod = (( defined ( 'USE_DEFAULT_AUTH_METHOD' ) AND constant ( 'USE_DEFAULT_AUTH_METHOD' ) == 1 ) ? 'default' : $bugsys- > options
[ 'authmethod' ]);
122 require_once ( './includes/auth/auth_' . $authMethod . '.php' );
124 $authClass = 'Authentication' . str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , $authMethod )));
125 $bugsys- > auth
= $auth = new $authClass ();
127 if ( $auth- > authenticateCookies ())
129 $bugsys- > userinfo
= $auth- > fetchBugdarUser ();
130 $bugsys- > userinfo
[ 'permissions' ] = FetchUserPermissions ( $bugsys- > userinfo
);
131 $bugsys- > userinfo
[ 'displaytitle' ] = $bugsys- > datastore
[ 'usergroup' ][ $bugsys- > userinfo
[ 'usergroupid' ] ][ 'displaytitle' ];
132 $bugsys- > userinfo
[ 'columnoptions' ] = unserialize ( $bugsys- > userinfo
[ 'columnoptions' ]);
136 $bugsys- > userinfo
= fetch_guest_user ();
139 // ###################################################################
140 // initialize localization system
142 $language = fetch_user_language ();
144 $stylevar [ 'lang' ] = $language [ 'langcode' ];
145 $stylevar [ 'lang_dir' ] = $language [ 'direction' ];
146 $stylevar [ 'charset' ] = $language [ 'charset' ];
147 $stylevar [ 'left' ] = ( $language [ 'direction' ] == 'ltr' ? 'left' : 'right' );
148 $stylevar [ 'right' ] = ( $language [ 'direction' ] == 'ltr' ? 'right' : 'left' );
150 // start gettext engine
151 putenv ( "LANG= $language [langcode]" );
152 putenv ( "LANGUAGE= $language [langcode]" );
154 setlocale ( LC_ALL
, $language [ 'langcode' ]);
156 bindtextdomain ( 'MESSAGES' , $bugsys- > apppath
. 'locale/' );
157 textdomain ( 'MESSAGES' );
159 bind_textdomain_codeset ( 'MESSAGES' , $language [ 'charset' ]);
161 // ###################################################################
162 // initialize the date system
163 $bugsys- > load ( 'date' , 'datef' , true );
164 $datef- > usertz
= $bugsys- > userinfo
[ 'timezone' ] +
( $bugsys- > userinfo
[ 'usedst' ] * 1 );
165 $bugsys- > debug ( 'user tz = ' . $bugsys- > userinfo
[ 'timezone' ] . '; use version = ' . $datef- > usertz
);
166 $datef- > fetch_offset ();
168 // ###################################################################
170 $bugsys- > load ( 'mail' , 'mail' , true );
171 $mail- > setFromAddress ( $bugsys- > options
[ 'webmasteremail' ]);
172 $mail- > setFromName ( _ ( 'Bugdar Notification' ));
174 /*=====================================================================*\
175 || ###################################################################
178 || ###################################################################
179 \*=====================================================================*/