1616use FeatherBB \Controller \Install ;
1717use FeatherBB \Core \Database as DB ;
1818use FeatherBB \Core \Email ;
19+ use FeatherBB \Core \Error ;
1920use FeatherBB \Core \Hooks ;
2021use FeatherBB \Core \Parser ;
2122use FeatherBB \Core \Plugin as PluginManager ;
@@ -33,7 +34,7 @@ class Core
3334 'Content-type ' => 'text/html ' ,
3435 'X-Frame-Options ' => 'deny ' );
3536
36- public function __construct (array $ data )
37+ public function __construct ($ data )
3738 {
3839 // Handle empty values in data
3940 $ data = array_merge (array ('config_file ' => 'featherbb/config.php ' ,
@@ -43,7 +44,7 @@ public function __construct(array $data)
4344 $ this ->forum_env ['FEATHER_ROOT ' ] = realpath (dirname (__FILE__ ).'/../../ ' ).'/ ' ;
4445 $ this ->forum_env ['FORUM_CACHE_DIR ' ] = is_writable ($ this ->forum_env ['FEATHER_ROOT ' ].$ data ['cache_dir ' ]) ? realpath ($ this ->forum_env ['FEATHER_ROOT ' ].$ data ['cache_dir ' ]).'/ ' : null ;
4546 $ this ->forum_env ['FORUM_CONFIG_FILE ' ] = $ this ->forum_env ['FEATHER_ROOT ' ].$ data ['config_file ' ];
46- $ this ->forum_env ['FEATHER_DEBUG ' ] = $ this ->forum_env ['FEATHER_SHOW_QUERIES ' ] = ($ data ['debug ' ] == 'all ' || $ data ['debug ' ] == true );
47+ $ this ->forum_env ['FEATHER_DEBUG ' ] = $ this ->forum_env ['FEATHER_SHOW_QUERIES ' ] = ($ data ['debug ' ] == 'all ' || filter_var ( $ data ['debug ' ], FILTER_VALIDATE_BOOLEAN ) == true );
4748 $ this ->forum_env ['FEATHER_SHOW_INFO ' ] = ($ data ['debug ' ] == 'info ' || $ data ['debug ' ] == 'all ' );
4849
4950 // Populate forum_env
@@ -105,14 +106,23 @@ public static function init_db(array $config, $log_queries = false)
105106 $ config ['db_prefix ' ] = (!empty ($ config ['db_prefix ' ])) ? $ config ['db_prefix ' ] : '' ;
106107 switch ($ config ['db_type ' ]) {
107108 case 'mysql ' :
109+ if (!extension_loaded ('pdo_mysql ' )) {
110+ throw new Error ('Driver pdo_mysql not installed. ' , 500 , false , false , true );
111+ }
108112 DB ::configure ('mysql:host= ' .$ config ['db_host ' ].';dbname= ' .$ config ['db_name ' ]);
109113 DB ::configure ('driver_options ' , array (\PDO ::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8 ' ));
110114 break ;
111115 case 'sqlite ' ;
112116 case 'sqlite3 ' ;
117+ if (!extension_loaded ('pdo_sqlite ' )) {
118+ throw new Error ('Driver pdo_mysql not installed. ' , 500 , false , false , true );
119+ }
113120 DB ::configure ('sqlite:./ ' .$ config ['db_name ' ]);
114121 break ;
115122 case 'pgsql ' :
123+ if (!extension_loaded ('pdo_pgsql ' )) {
124+ throw new Error ('Driver pdo_mysql not installed. ' , 500 , false , false , true );
125+ }
116126 DB ::configure ('pgsql:host= ' .$ config ['db_host ' ].'dbname= ' .$ config ['db_name ' ]);
117127 break ;
118128 }
@@ -258,6 +268,11 @@ public function __invoke($req, $res, $next)
258268 // Define time formats and add them to the container
259269 Container::set ('forum_time_formats ' , array (ForumSettings::get ('time_format ' ), 'H:i:s ' , 'H:i ' , 'g:i:s a ' , 'g:i a ' ));
260270 Container::set ('forum_date_formats ' , array (ForumSettings::get ('date_format ' ), 'Y-m-d ' , 'Y-d-m ' , 'd-m-Y ' , 'm-d-Y ' , 'M j Y ' , 'jS M Y ' ));
271+
272+ // Check if we have DOM support (not installed by default in PHP >= 7.0, results in utf8_decode not defined
273+ if (!function_exists ('utf8_decode ' )) {
274+ throw new Error ('Please install the php7.0-xml package. ' , 500 , false , false , true );
275+ }
261276
262277 return $ next ($ req , $ res );
263278 }
0 commit comments