public function sqlConnect() { if (!$this->connection_handler) { $this->connection_handler = @mysql_connect($this->connection['server'], $this->connection['login'], $this->connection['password'], true); // The system has not been designed to use special SQL modes that were introduced since MySQL 5 @mysql_query("set session sql_mode='';", $this->connection_handler); @mysql_select_db($this->connection['base'], $this->connection_handler); // Initialization of the database connection encoding to be used. // The internationalization library should be already initialized. @mysql_query("SET SESSION character_set_server='utf8';", $this->connection_handler); @mysql_query("SET SESSION collation_server='utf8_general_ci';", $this->connection_handler); $system_encoding = api_get_system_encoding(); if (api_is_utf8($system_encoding)) { // See Bug #1802: For UTF-8 systems we prefer to use "SET NAMES 'utf8'" statement in order to avoid a bizarre problem with Chinese language. @mysql_query("SET NAMES 'utf8';", $this->connection_handler); } else { @mysql_query("SET CHARACTER SET '" . Database::to_db_encoding($system_encoding) . "';", $this->connection_handler); } } return ($this->connection_handler) ? true : false; }
/** * Constructs a SQL clause about default character set and default collation for newly created databases and tables. * Example: Database::make_charset_clause('UTF-8', 'bulgarian') returns * DEFAULT CHARACTER SET `utf8` DEFAULT COLLATE `utf8_general_ci` * @param string $encoding (optional) The default database/table encoding (a system conventional id) to be used. * @param string $language (optional) Language (a system conventional id) used for choosing language sensitive collation (if it is possible). * @return string Returns the constructed SQL clause or empty string if $encoding is not correct or is not supported. * @author Ivan Tcholakov */ public static function make_charset_clause($encoding = null, $language = null) { if (empty($encoding)) { $encoding = api_get_system_encoding(); } if (empty($language)) { $language = api_get_interface_language(); } $charset_clause = ''; if (self::is_encoding_supported($encoding)) { $db_encoding = Database::to_db_encoding($encoding); $charset_clause .= " DEFAULT CHARACTER SET `" . $db_encoding . "`"; $db_collation = Database::to_db_collation($encoding, $language); if (!empty($db_collation)) { $charset_clause .= " DEFAULT COLLATE `" . $db_collation . "`"; } } return $charset_clause; }
$charset = 'UTF-8'; } // Preserving the value of the global variable $charset. $charset_initial_value = $charset; // Initialization of the internationalization library. api_initialize_internationalization(); // Initialization of the default encoding that will be used by the multibyte string routines in the internationalization library. api_set_internationalization_default_encoding($charset); // Initialization of the database encoding to be used. Database::query("SET SESSION character_set_server='utf8';"); Database::query("SET SESSION collation_server='utf8_general_ci';"); if (api_is_utf8($charset)) { // See Bug #1802: For UTF-8 systems we prefer to use "SET NAMES 'utf8'" statement in order to avoid a bizarre problem with Chinese language. Database::query("SET NAMES 'utf8';"); } else { Database::query("SET CHARACTER SET '" . Database::to_db_encoding($charset) . "';"); } // Start session after the internationalization library has been initialized. Chamilo::session()->start($already_installed); // Remove quotes added by PHP - get_magic_quotes_gpc() is deprecated in PHP 5 see #2970 if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { array_walk_recursive_limited($_GET, 'stripslashes', true); array_walk_recursive_limited($_POST, 'stripslashes', true); array_walk_recursive_limited($_COOKIE, 'stripslashes', true); array_walk_recursive_limited($_REQUEST, 'stripslashes', true); } // access_url == 1 is the default chamilo location if ($_configuration['access_url'] != 1) { $url_info = api_get_access_url($_configuration['access_url']); if ($url_info['active'] == 1) { $settings_by_access =& api_get_settings(null, 'list', $_configuration['access_url'], 1);