More overhauls.
This commit is contained in:
parent
4224e0324c
commit
1af12aec6f
3 changed files with 20 additions and 38 deletions
|
@ -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('<strong>Error:</strong> Configuration file could not be loaded.');
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,22 +93,12 @@ 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));
|
||||
$str = strtr($str, $htmlEntitiesMap);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue