diff --git a/src/AJAXChat.php b/src/AJAXChat.php index 404e533..eac2922 100644 --- a/src/AJAXChat.php +++ b/src/AJAXChat.php @@ -10,19 +10,19 @@ // Ajax Chat backend logic: class AJAXChat { - private $db; - private $_config; - private $_requestVars; - private $_infoMessages; - private $_channels; - private $_allChannels; - private $_view; - private $_lang; - private $_invitations; - private $_customVars; - private $_sessionNew; - private $_onlineUsersData; - private $_bannedUsersData; + protected $db; + protected $_config; + protected $_requestVars; + protected $_infoMessages; + protected $_channels; + protected $_allChannels; + protected $_view; + protected $_lang; + protected $_invitations; + protected $_customVars; + protected $_sessionNew; + protected $_onlineUsersData; + protected $_bannedUsersData; function __construct() { // Initialize configuration settings: @@ -43,7 +43,7 @@ class AJAXChat { function initConfig() { $config = null; - if(!include_once AJAX_CHAT_PATH . '/config/config.php')) { + if(!include_once AJAX_CHAT_PATH . '/config/config.php') { print('Error: Configuration file could not be loaded.'); exit; } diff --git a/src/AJAXChatDataBase.php b/src/AJAXChatDataBase.php index d42e2a0..df38ee7 100644 --- a/src/AJAXChatDataBase.php +++ b/src/AJAXChatDataBase.php @@ -15,18 +15,10 @@ class AJAXChatDataBase { function __construct(&$dbConnectionConfig) { switch($dbConnectionConfig['type']) { case 'mysqli': - $this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig); - break; - case 'mysql': - $this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig); + $this->_db = new AJAXChatDataBaseMySQLi($dbConnectionConfig); break; default: - // Use MySQLi if available, else MySQL (and check the type of a given database connection object): - if(function_exists('mysqli_connect') && (!$dbConnectionConfig['link'] || is_object($dbConnectionConfig['link']))) { - $this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig); - } else { - $this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig); - } + $this->_db = new AJAXChatDataBaseMySQLi($dbConnectionConfig); } } diff --git a/src/AJAXChatEncoding.php b/src/AJAXChatEncoding.php index b8bdb52..6194139 100644 --- a/src/AJAXChatEncoding.php +++ b/src/AJAXChatEncoding.php @@ -93,20 +93,10 @@ class AJAXChatEncoding { } public static function decodeEntities($str, $encoding='UTF-8', $htmlEntitiesMap=null) { - // Due to PHP bug #25670, html_entity_decode does not work with UTF-8 for PHP versions < 5: - if(function_exists('html_entity_decode') && version_compare(phpversion(), 5, '>=')) { - // Replace numeric and literal entities: - $str = html_entity_decode($str, ENT_QUOTES, $encoding); - // Replace additional literal HTML entities if an HTML entities map is given: - if($htmlEntitiesMap) { - $str = strtr($str, $htmlEntitiesMap); - } - } else { - // Replace numeric entities: - $str = preg_replace('~&#([0-9]+);~e', 'AJAXChatEncoding::unicodeChar("\\1")', $str); - $str = preg_replace('~&#x([0-9a-f]+);~ei', 'AJAXChatEncoding::unicodeChar(hexdec("\\1"))', $str); - // Replace literal entities: - $htmlEntitiesMap = $htmlEntitiesMap ? $htmlEntitiesMap : array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES)); + // Replace numeric and literal entities: + $str = html_entity_decode($str, ENT_QUOTES, $encoding); + // Replace additional literal HTML entities if an HTML entities map is given: + if($htmlEntitiesMap) { $str = strtr($str, $htmlEntitiesMap); } return $str;