More overhauls.

This commit is contained in:
flash 2022-02-06 17:36:54 +01:00
parent 4224e0324c
commit 1af12aec6f
3 changed files with 20 additions and 38 deletions

View file

@ -10,19 +10,19 @@
// Ajax Chat backend logic: // Ajax Chat backend logic:
class AJAXChat { class AJAXChat {
private $db; protected $db;
private $_config; protected $_config;
private $_requestVars; protected $_requestVars;
private $_infoMessages; protected $_infoMessages;
private $_channels; protected $_channels;
private $_allChannels; protected $_allChannels;
private $_view; protected $_view;
private $_lang; protected $_lang;
private $_invitations; protected $_invitations;
private $_customVars; protected $_customVars;
private $_sessionNew; protected $_sessionNew;
private $_onlineUsersData; protected $_onlineUsersData;
private $_bannedUsersData; protected $_bannedUsersData;
function __construct() { function __construct() {
// Initialize configuration settings: // Initialize configuration settings:
@ -43,7 +43,7 @@ class AJAXChat {
function initConfig() { function initConfig() {
$config = null; $config = null;
if(!include_once AJAX_CHAT_PATH . '/config/config.php')) { if(!include_once AJAX_CHAT_PATH . '/config/config.php') {
print('<strong>Error:</strong> Configuration file could not be loaded.'); print('<strong>Error:</strong> Configuration file could not be loaded.');
exit; exit;
} }

View file

@ -15,18 +15,10 @@ class AJAXChatDataBase {
function __construct(&$dbConnectionConfig) { function __construct(&$dbConnectionConfig) {
switch($dbConnectionConfig['type']) { switch($dbConnectionConfig['type']) {
case 'mysqli': case 'mysqli':
$this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig); $this->_db = new AJAXChatDataBaseMySQLi($dbConnectionConfig);
break;
case 'mysql':
$this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig);
break; break;
default: default:
// Use MySQLi if available, else MySQL (and check the type of a given database connection object): $this->_db = new AJAXChatDataBaseMySQLi($dbConnectionConfig);
if(function_exists('mysqli_connect') && (!$dbConnectionConfig['link'] || is_object($dbConnectionConfig['link']))) {
$this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig);
} else {
$this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig);
}
} }
} }

View file

@ -93,20 +93,10 @@ class AJAXChatEncoding {
} }
public static function decodeEntities($str, $encoding='UTF-8', $htmlEntitiesMap=null) { 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: // Replace numeric and literal entities:
if(function_exists('html_entity_decode') && version_compare(phpversion(), 5, '>=')) { $str = html_entity_decode($str, ENT_QUOTES, $encoding);
// Replace numeric and literal entities: // Replace additional literal HTML entities if an HTML entities map is given:
$str = html_entity_decode($str, ENT_QUOTES, $encoding); if($htmlEntitiesMap) {
// 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));
$str = strtr($str, $htmlEntitiesMap); $str = strtr($str, $htmlEntitiesMap);
} }
return $str; return $str;