Пример #1
0
 public static function setup_environment()
 {
     mb_internal_encoding('UTF-8');
     JxBotConfig::$config['bot_url'] = JxBotUtil::request_url();
     $config_file = dirname(dirname(__FILE__)) . '/config.php';
     if (!is_readable($config_file)) {
         return JxBotConfig::run_installer();
     }
     if (!JxBotConfig::load_config()) {
         JxBot::fatal_error("Couldn't load database configuration.");
     }
     /*$jxbot = array();
     		require_once($config_file);
     		JxBotConfig::$config = $jxbot;
     		
     		if (!isset($jxbot['bot_url']))
     			JxBot::fatal_error("Bot configuraton is missing bot_url.");*/
     /*if (isset($jxbot['debug']) && $jxbot['debug']) 
     		{
     			// PHP debugging for the program; distinct from AIML debugging
     			error_reporting(E_ALL);
     			ini_set('display_errors', 1);
     		}*/
     /*if (!isset($jxbot['db_host']))
     			JxBot::fatal_error("JxBot database not configured.");
     		if (!isset($jxbot['db_name']))
     			JxBot::fatal_error("JxBot database not configured.");
     		if (!isset($jxbot['db_prefix']))
     			$jxbot['db_prefix'] = '';
     		if (!isset($jxbot['db_username']))
     			JxBot::fatal_error("JxBot database not configured.");
     		if (!isset($jxbot['db_password']))
     			JxBot::fatal_error("JxBot database not configured.");
     		
     		JxBotDB::connect($jxbot['db_host'], $jxbot['db_name'], $jxbot['db_prefix'],
     			$jxbot['db_username'], $jxbot['db_password']);*/
     if (!JxBotConfig::try_connect_db()) {
         JxBot::fatal_error("Couldn't connect to database.");
     }
     JxBotConfig::load_configuration();
     JxBotConfig::$is_installed = true;
     date_default_timezone_set(JxBotConfig::option('bot_tz'));
 }