First wave of Adjustments

This commit is contained in:
flash 2022-02-06 17:26:14 +01:00
parent 524a12f184
commit 4224e0324c
47 changed files with 4995 additions and 5204 deletions

25
ajaxchat.php Normal file
View File

@ -0,0 +1,25 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
define('AJAX_CHAT_PATH', __DIR__);
// Include Class libraries:
require_once AJAX_CHAT_PATH . '/src/AJAXChat.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatDataBase.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatMySQLiDataBase.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatMySQLiQuery.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatEncoding.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatString.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatFileSystem.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatHTTPHeader.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatLanguage.php';
require_once AJAX_CHAT_PATH . '/src/AJAXChatTemplate.php';
require_once AJAX_CHAT_PATH . '/src/CustomAJAXChat.php';
require_once AJAX_CHAT_PATH . '/src/CustomAJAXChatShoutBox.php';
require_once AJAX_CHAT_PATH . '/src/CustomAJAXChatInterface.php';

5
config/config-db.php Normal file
View File

@ -0,0 +1,5 @@
<?php
$config['dbConnection']['host'] = 'localhost';
$config['dbConnection']['user'] = 'ajax-chat';
$config['dbConnection']['pass'] = 'dGmOnRgOcThK2svQfHaF1WIJi7wjbDZc';
$config['dbConnection']['name'] = 'ajax-chat';

View File

@ -8,16 +8,16 @@
*/
// Define AJAX Chat user roles:
define('DONATOR', 9);
define('DOKURO', 8);
define('BOTS', 7);
define('CMOD', 6);
define('AJAX_CHAT_CHATBOT', 5);
define('PURPLE', 4);
define('AJAX_CHAT_ADMIN', 3);
define('AJAX_CHAT_MODERATOR', 2);
define('AJAX_CHAT_USER', 1);
define('AJAX_CHAT_GUEST', 0);
define('DONATOR', 9);
define('DOKURO', 8);
define('BOTS', 7);
define('CMOD', 6);
define('AJAX_CHAT_CHATBOT', 5);
define('PURPLE', 4);
define('AJAX_CHAT_ADMIN', 3);
define('AJAX_CHAT_MODERATOR', 2);
define('AJAX_CHAT_USER', 1);
define('AJAX_CHAT_GUEST', 0);
// AJAX Chat config parameters:
$config = array();
@ -39,10 +39,10 @@ $config['dbConnection']['link'] = null;
// Database table names:
$config['dbTableNames'] = array();
$config['dbTableNames']['online'] = 'ajax_chat_online';
$config['dbTableNames']['messages'] = 'ajax_chat_messages';
$config['dbTableNames']['bans'] = 'ajax_chat_bans';
$config['dbTableNames']['invitations'] = 'ajax_chat_invitations';
$config['dbTableNames']['online'] = 'ajax_chat_online';
$config['dbTableNames']['messages'] = 'ajax_chat_messages';
$config['dbTableNames']['bans'] = 'ajax_chat_bans';
$config['dbTableNames']['invitations'] = 'ajax_chat_invitations';
// Available languages:
$config['langAvailable'] = array('en');

120
lang/en.php Normal file
View File

@ -0,0 +1,120 @@
<?php
$lang = array();
$lang['title'] = 'Flashii Chat';
$lang['titleinchat'] = 'Flashii Chat Legacy';
$lang['userName'] = 'Username';
$lang['password'] = 'Password';
$lang['login'] = 'Login';
$lang['logout'] = 'Logout';
$lang['mobile'] = 'Mobile';
$lang['desktop'] = 'Desktop';
$lang['channel'] = 'Channel';
$lang['style'] = 'Style';
$lang['language'] = 'Language';
$lang['inputLineBreak'] = 'Press SHIFT+ENTER to input a line break';
$lang['messageSubmit'] = 'Send';
$lang['registeredUsers'] = 'Log in with your Flashii credentials, this chat is entirely unregulated so enter at your own risk.';
$lang['onlineUsers'] = 'Online users';
$lang['toggleAutoScroll'] = 'Autoscroll on/off';
$lang['toggleAudio'] = 'Sound on/off';
$lang['toggleHelp'] = 'Show/hide help';
$lang['toggleSettings'] = 'Show/hide settings';
$lang['toggleOnlineList'] = 'Show/hide online list';
$lang['bbCodeLabelBold'] = 'b';
$lang['bbCodeLabelItalic'] = 'i';
$lang['bbCodeLabelUnderline'] = 'u';
$lang['bbCodeLabelQuote'] = 'Quote';
$lang['bbCodeLabelCode'] = 'Code';
$lang['bbCodeLabelURL'] = 'URL';
$lang['bbCodeLabelImg'] = 'Image';
$lang['bbCodeLabelColor'] = 'Colour';
$lang['bbCodeTitleBold'] = 'Bold text: [b]text[/b]';
$lang['bbCodeTitleItalic'] = 'Italic text: [i]text[/i]';
$lang['bbCodeTitleUnderline'] = 'Underline text: [u]text[/u]';
$lang['bbCodeTitleQuote'] = 'Quote text: [quote]text[/quote] or [quote=author]text[/quote]';
$lang['bbCodeTitleCode'] = 'Code display: [code]code[/code]';
$lang['bbCodeTitleURL'] = 'Insert URL: [url]http://example.org[/url] or [url=http://example.org]text[/url]';
$lang['bbCodeTitleImg'] = 'Insert image: [img]http://example.org/image.jpg[/img]';
$lang['bbCodeTitleColor'] = 'Font Colour: [color=red]text[/color]';
$lang['help'] = 'Help';
$lang['helpItemDescJoin'] = 'Join a channel:';
$lang['helpItemCodeJoin'] = '/join Channelname';
$lang['helpItemDescJoinCreate'] = 'Create a private room (Registered users only):';
$lang['helpItemCodeJoinCreate'] = '/join';
$lang['helpItemDescInvite'] = 'Invite someone (e.g. to a private room):';
$lang['helpItemCodeInvite'] = '/invite Username';
$lang['helpItemDescUninvite'] = 'Revoke invitation:';
$lang['helpItemCodeUninvite'] = '/uninvite Username';
$lang['helpItemDescLogout'] = 'Logout from Chat:';
$lang['helpItemCodeLogout'] = '/quit';
$lang['helpItemDescPrivateMessage'] = 'Private message:';
$lang['helpItemCodePrivateMessage'] = '/msg Username Text';
$lang['helpItemDescQueryOpen'] = 'Open a private channel:';
$lang['helpItemCodeQueryOpen'] = '/query Username';
$lang['helpItemDescQueryClose'] = 'Close a private channel:';
$lang['helpItemCodeQueryClose'] = '/query';
$lang['helpItemDescAction'] = 'Describe action:';
$lang['helpItemCodeAction'] = '/action Text';
$lang['helpItemDescDescribe'] = 'Describe action in private message:';
$lang['helpItemCodeDescribe'] = '/describe Username Text';
$lang['helpItemDescIgnore'] = 'Ignore/accept messages from user:';
$lang['helpItemCodeIgnore'] = '/ignore Username';
$lang['helpItemDescIgnoreList'] = 'List ignored users:';
$lang['helpItemCodeIgnoreList'] = '/ignore';
$lang['helpItemDescWhereis'] = 'Display user channel:';
$lang['helpItemCodeWhereis'] = '/whereis Username';
$lang['helpItemDescKick'] = 'Kick a user (Moderators only):';
$lang['helpItemCodeKick'] = '/kick Username [Minutes banned]';
$lang['helpItemDescUnban'] = 'Unban a user (Moderators only):';
$lang['helpItemCodeUnban'] = '/unban Username';
$lang['helpItemDescBans'] = 'List banned users (Moderators only):';
$lang['helpItemCodeBans'] = '/bans';
$lang['helpItemDescWhois'] = 'Display user IP (Moderators only):';
$lang['helpItemCodeWhois'] = '/whois Username';
$lang['helpItemDescWho'] = 'List online users:';
$lang['helpItemCodeWho'] = '/who [Channelname]';
$lang['helpItemDescList'] = 'List available channels:';
$lang['helpItemCodeList'] = '/list';
$lang['helpItemDescRoll'] = 'Roll dice:';
$lang['helpItemCodeRoll'] = '/roll [number]d[sides]';
$lang['helpItemDescNick'] = 'Change username:';
$lang['helpItemCodeNick'] = '/nick Username';
$lang['settings'] = 'Settings';
$lang['settingsBBCode'] = 'Enable BBCode:';
$lang['settingsBBCodeImages'] = 'Enable image BBCode:';
$lang['settingsBBCodeColors'] = 'Enable font color BBCode:';
$lang['settingsHyperLinks'] = 'Enable hyperlinks:';
$lang['settingsLineBreaks'] = 'Enable line breaks:';
$lang['settingsEmoticons'] = 'Enable emoticons:';
$lang['settingsAutoFocus'] = 'Automatically set the focus on the input field:';
$lang['settingsMaxMessages'] = 'Maximum number of messages in the chatlist:';
$lang['settingsWordWrap'] = 'Enable wrapping of long words:';
$lang['settingsMaxWordLength'] = 'Maximum length of a word before it gets wrapped:';
$lang['settingsDateFormat'] = 'Format of date and time display:';
$lang['settingsPersistFontColor'] = 'Persist font color:';
$lang['settingsAudioVolume'] = 'Sound Volume:';
$lang['settingsSoundReceive'] = 'Sound for incoming messages:';
$lang['settingsSoundSend'] = 'Sound for outgoing messages:';
$lang['settingsSoundEnter'] = 'Sound for login and channel enter messages:';
$lang['settingsSoundLeave'] = 'Sound for logout and channel leave messages:';
$lang['settingsSoundChatBot'] = 'Sound for chatbot messages:';
$lang['settingsSoundError'] = 'Sound for error messages:';
$lang['settingsSoundPrivate'] = 'Sound for private messages:';
$lang['settingsBlink'] = 'Blink window title on new messages:';
$lang['settingsBlinkInterval'] = 'Blink interval in milliseconds:';
$lang['settingsBlinkIntervalNumber'] = 'Number of blink intervals:';
$lang['playSelectedSound'] = 'Play selected sound';
$lang['requiresJavaScript'] = 'Please enable JavaScript or use a compatible browser.';
$lang['errorInvalidUser'] = 'Invalid username or password.';
$lang['errorUserInUse'] = 'Username in use.';
//$lang['errorBanned'] = 'You are banned ;_;';
$lang['errorBanned'] = 'You have been kicked from this chatroom.';
$lang['errorMaxUsersLoggedIn'] = 'The chat has reached the maximum number of logged-in users.';
//$lang['errorChatClosed'] = 'It started with a call I stupidly answered You said you got my number from one of the dancers You waited right outside, you had something on mind But then I saw your eyes, your crazy eyes Now you got me into something very sick and twisted An evil kind of game I didn\'t know existed You traveled overseas to terrorize me And I don\'t understand, why can\'t you let me be? Believe me when I say, you stupid fool! You\'re scaring me to death, that\'s not cool! Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! I beg of you to stop and think this through It\'s time you started playing with someone new Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! You\'re scaring mom and dad, scaring off my girlfriend You\'re waiting by my door early in the morning I\'ve told you many times, don\'t follow me at night You\'re poisoning in my life, just tell me why! Believe me when I say, you stupid fool! You\'re scaring me to death, that\'s not cool! Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! I beg of you to stop and think this through It\'s time you started playing with someone new Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! Believe me when I say, you stupid fool! You\'re scaring me to death, that\'s not cool! Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! I beg of you to stop and think this through It\'s time you started playing with someone new Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone!';
$lang['errorChatClosed'] = 'Site maintenance';
$lang['logsTitle'] = 'The Evil Circle';
$lang['logsDate'] = 'Date';
$lang['logsTime'] = 'Time';
$lang['logsSearch'] = 'Search';
$lang['logsPrivateChannels'] = 'Private Channels';
$lang['logsPrivateMessages'] = 'Private Messages';

View File

@ -11,14 +11,8 @@
ini_set('display_errors', 'On');
error_reporting(-1);
// Path to the chat directory:
define('AJAX_CHAT_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
// Include Flashii System stuff:
//require('/var/www/flashii.net/system/core/modules.php');
// Include Class libraries:
require(AJAX_CHAT_PATH.'lib/classes.php');
require_once __DIR__ . '/../ajaxchat.php';
// Initialize the chat:
$ajaxChat = new CustomAJAXChat();

View File

@ -1,4 +0,0 @@
AuthType Basic
AuthName "Forbidden"
AuthUserFile /dev/null
require user nobody

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to initialize the DataBase connection:
class AJAXChatDataBase {
var $_db;
function __construct(&$dbConnectionConfig) {
switch($dbConnectionConfig['type']) {
case 'mysqli':
$this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig);
break;
case 'mysql':
$this->_db = new AJAXChatDatabaseMySQL($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);
}
}
}
// Method to connect to the DataBase server:
function connect(&$dbConnectionConfig) {
return $this->_db->connect($dbConnectionConfig);
}
// Method to select the DataBase:
function select($dbName) {
return $this->_db->select($dbName);
}
// Method to determine if an error has occured:
function error() {
return $this->_db->error();
}
// Method to return the error report:
function getError() {
return $this->_db->getError();
}
// Method to return the connection identifier:
function &getConnectionID() {
return $this->_db->getConnectionID();
}
// Method to prevent SQL injections:
function makeSafe($value) {
return $this->_db->makeSafe($value);
}
// Method to perform SQL queries:
function sqlQuery($sql) {
return $this->_db->sqlQuery($sql);
}
// Method to retrieve the current DataBase name:
function getName() {
return $this->_db->getName();
//If your database has hyphens ( - ) in it, try using this instead:
//return '`'.$this->_db->getName().'`';
}
// Method to retrieve the last inserted ID:
function getLastInsertedID() {
return $this->_db->getLastInsertedID();
}
}
?>

View File

@ -1,138 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to provide static encoding methods
class AJAXChatEncoding {
// Helper function to store special chars as we cannot use static class members in PHP4:
public static function getSpecialChars() {
static $specialChars;
if(!$specialChars) {
// As &apos; is not supported by IE, we use &#39; as replacement for "'":
$specialChars = array('&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', "'"=>'&#39;', '"'=>'&quot;');
}
return $specialChars;
}
// Helper function to store Regular expression for NO-WS-CTL as we cannot use static class members in PHP4:
public static function getRegExp_NO_WS_CTL() {
static $regExp_NO_WS_CTL;
if(!$regExp_NO_WS_CTL) {
// Regular expression for NO-WS-CTL, non-whitespace control characters (RFC 2822), decimal 18, 1112, 1431, and 127:
$regExp_NO_WS_CTL = '/[\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F]/';
}
return $regExp_NO_WS_CTL;
}
public static function convertEncoding($str, $charsetFrom, $charsetTo) {
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($str, $charsetTo, $charsetFrom);
}
if(function_exists('iconv')) {
return iconv($charsetFrom, $charsetTo, $str);
}
if(($charsetFrom == 'UTF-8') && ($charsetTo == 'ISO-8859-1')) {
return utf8_decode($str);
}
if(($charsetFrom == 'ISO-8859-1') && ($charsetTo == 'UTF-8')) {
return utf8_encode($str);
}
return $str;
}
public static function htmlEncode($str, $contentCharset='UTF-8') {
switch($contentCharset) {
case 'UTF-8':
// Encode only special chars (&, <, >, ', ") as entities:
return AJAXChatEncoding::encodeSpecialChars($str);
break;
case 'ISO-8859-1':
case 'ISO-8859-15':
// Encode special chars and all extended characters above ISO-8859-1 charset as entities, then convert to content charset:
return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array(
0x26, 0x26, 0, 0xFFFF, // &
0x3C, 0x3C, 0, 0xFFFF, // <
0x3E, 0x3E, 0, 0xFFFF, // >
0x27, 0x27, 0, 0xFFFF, // '
0x22, 0x22, 0, 0xFFFF, // "
0x100, 0x2FFFF, 0, 0xFFFF // above ISO-8859-1
)), 'UTF-8', $contentCharset);
break;
default:
// Encode special chars and all characters above ASCII charset as entities, then convert to content charset:
return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array(
0x26, 0x26, 0, 0xFFFF, // &
0x3C, 0x3C, 0, 0xFFFF, // <
0x3E, 0x3E, 0, 0xFFFF, // >
0x27, 0x27, 0, 0xFFFF, // '
0x22, 0x22, 0, 0xFFFF, // "
0x80, 0x2FFFF, 0, 0xFFFF // above ASCII
)), 'UTF-8', $contentCharset);
}
}
public static function encodeSpecialChars($str) {
return strtr($str, AJAXChatEncoding::getSpecialChars());
}
public static function decodeSpecialChars($str) {
return strtr($str, array_flip(AJAXChatEncoding::getSpecialChars()));
}
public static function encodeEntities($str, $encoding='UTF-8', $convmap=null) {
if($convmap && function_exists('mb_encode_numericentity')) {
return mb_encode_numericentity($str, $convmap, $encoding);
}
return htmlentities($str, ENT_QUOTES, $encoding);
}
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;
}
public static function unicodeChar($c) {
if($c <= 0x7F) {
return chr($c);
} else if($c <= 0x7FF) {
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
} else if($c <= 0xFFFF) {
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
} else if($c <= 0x10FFFF) {
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
} else {
return null;
}
}
public static function removeUnsafeCharacters($str) {
// Remove NO-WS-CTL, non-whitespace control characters (RFC 2822), decimal 18, 1112, 1431, and 127:
return preg_replace(AJAXChatEncoding::getRegExp_NO_WS_CTL(), '', $str);
}
}
?>

View File

@ -1,56 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to manage HTTP header
class AJAXChatHTTPHeader {
var $_contentType;
var $_constant;
var $_noCache;
function __construct($encoding='UTF-8', $contentType=null, $noCache=true) {
if($contentType) {
$this->_contentType = $contentType.'; charset='.$encoding;
$this->_constant = true;
} else {
if(isset($_SERVER['HTTP_ACCEPT']) && (strpos($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml') !== false)) {
$this->_contentType = 'application/xhtml+xml; charset='.$encoding;
} else {
$this->_contentType = 'text/html; charset='.$encoding;
}
$this->_constant = false;
}
$this->_noCache = $noCache;
}
// Method to send the HTTP header:
function send() {
// Prevent caching:
if($this->_noCache) {
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
}
// Send the content-type-header:
header('Content-Type: '.$this->_contentType);
// Send vary header if content-type varies (important for proxy-caches):
if(!$this->_constant) {
header('Vary: Accept');
}
}
// Method to return the content-type string:
function getContentType() {
// Return the content-type string:
return $this->_contentType;
}
}
?>

View File

@ -1,102 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
class AJAXChatLanguage {
var $_regExpAcceptLangCode;
var $_availableLangCodes;
var $_defaultLangCode;
var $_strictMode;
var $_langCode;
function __construct($availableLangCodes, $defaultLangCode, $langCode=null, $strictMode=false) {
$this->_regExpAcceptLangCode = '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i';
$this->_availableLangCodes = $availableLangCodes;
$this->_defaultLangCode = $defaultLangCode;
if($langCode && in_array($langCode, $availableLangCodes)) {
$this->_langCode = $langCode;
}
$this->_strictMode = $strictMode;
}
// Method to detect the language code from the HTTP_ACCEPT_LANGUAGE header:
function detectLangCode() {
// If HTTP_ACCEPT_LANGUAGE is empty use defaultLangCode:
if(empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$this->_langCode = $this->_defaultLangCode;
return;
}
// Split up the HTTP_ACCEPT_LANGUAGE header:
$acceptedLanguages = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$currentLangCode = $this->_defaultLangCode;
$currentLangQuality = 0.0;
foreach($acceptedLanguages as $acceptedLanguage) {
// Parse the language string:
$match = preg_match($this->_regExpAcceptLangCode, $acceptedLanguage, $matches);
// Check if the syntax is valid:
if(!$match) {
continue;
}
// Get and split the language code:
$langCodeParts = explode ('-', $matches[1]);
// Get the language quality given as float value:
if(isset($matches[2])) {
$langQuality = (float)$matches[2];
} else {
// Missing language quality value is maximum quality:
$langQuality = 1.0;
}
// Go through it until the language code is empty:
while(count($langCodeParts)) {
// Join the current langCodeParts:
$langCode = strtolower(join('-', $langCodeParts));
// Check if the langCode is in the available list:
if(in_array($langCode, $this->_availableLangCodes)) {
// Check the quality setting:
if ($langQuality > $currentLangQuality) {
$currentLangCode = $langCode;
$currentLangQuality = $langQuality;
break;
}
}
// If strict mode is set, don't minimalize the language code:
if($this->_strictMode) {
break;
}
// else chop off the right part:
array_pop($langCodeParts);
}
}
$this->_langCode = $currentLangCode;
}
function getLangCode() {
if(!$this->_langCode) {
$this->detectLangCode();
}
return $this->_langCode;
}
function setLangCode($langCode) {
$this->_langCode = $langCode;
}
function getLangCodes() {
return $this->_availableLangCodes;
}
}
?>

View File

@ -1,92 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to initialize the MySQL DataBase connection:
class AJAXChatDataBaseMySQL {
var $_connectionID;
var $_errno = 0;
var $_error = '';
var $_dbName;
function __construct(&$dbConnectionConfig) {
$this->_connectionID = $dbConnectionConfig['link'];
$this->_dbName = $dbConnectionConfig['name'];
}
// Method to connect to the DataBase server:
function connect(&$dbConnectionConfig) {
$this->_connectionID = @mysql_connect(
$dbConnectionConfig['host'],
$dbConnectionConfig['user'],
$dbConnectionConfig['pass'],
true
);
if(!$this->_connectionID) {
$this->_errno = null;
$this->_error = 'Database connection failed.';
return false;
}
return true;
}
// Method to select the DataBase:
function select($dbName) {
if(!@mysql_select_db($dbName, $this->_connectionID)) {
$this->_errno = mysql_errno($this->_connectionID);
$this->_error = mysql_error($this->_connectionID);
return false;
}
$this->_dbName = $dbName;
return true;
}
// Method to determine if an error has occured:
function error() {
return (bool)$this->_error;
}
// Method to return the error report:
function getError() {
if($this->error()) {
$str = 'Error-Report: ' .$this->_error."\n";
$str .= 'Error-Code: '.$this->_errno."\n";
} else {
$str = 'No errors.'."\n";
}
return $str;
}
// Method to return the connection identifier:
function &getConnectionID() {
return $this->_connectionID;
}
// Method to prevent SQL injections:
function makeSafe($value) {
return "'".mysql_real_escape_string($value, $this->_connectionID)."'";
}
// Method to perform SQL queries:
function sqlQuery($sql) {
return new AJAXChatMySQLQuery($sql, $this->_connectionID);
}
// Method to retrieve the current DataBase name:
function getName() {
return $this->_dbName;
}
// Method to retrieve the last inserted ID:
function getLastInsertedID() {
return mysql_insert_id($this->_connectionID);
}
}
?>

View File

@ -1,89 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to perform SQL (MySQL) queries:
class AJAXChatMySQLQuery {
var $_connectionID;
var $_sql = '';
var $_result = 0;
var $_errno = 0;
var $_error = '';
// Constructor:
function __construct($sql, $connectionID = null) {
$this->_sql = trim($sql);
$this->_connectionID = $connectionID;
if($this->_connectionID) {
$this->_result = mysql_query($this->_sql, $this->_connectionID);
if(!$this->_result) {
$this->_errno = mysql_errno($this->_connectionID);
$this->_error = mysql_error($this->_connectionID);
}
} else {
$this->_result = mysql_query($this->_sql);
if(!$this->_result) {
$this->_errno = mysql_errno();
$this->_error = mysql_error();
}
}
}
// Returns true if an error occured:
function error() {
// Returns true if the Result-ID is valid:
return !(bool)($this->_result);
}
// Returns an Error-String:
function getError() {
if($this->error()) {
$str = 'Query: ' .$this->_sql ."\n";
$str .= 'Error-Report: ' .$this->_error."\n";
$str .= 'Error-Code: '.$this->_errno;
} else {
$str = "No errors.";
}
return $str;
}
// Returns the content:
function fetch() {
if($this->error()) {
return null;
} else {
return mysql_fetch_assoc($this->_result);
}
}
// Returns the number of rows (SELECT or SHOW):
function numRows() {
if($this->error()) {
return null;
} else {
return mysql_num_rows($this->_result);
}
}
// Returns the number of affected rows (INSERT, UPDATE, REPLACE or DELETE):
function affectedRows() {
if($this->error()) {
return null;
} else {
return mysql_affected_rows($this->_connectionID);
}
}
// Frees the memory:
function free() {
@mysql_free_result($this->_result);
}
}
?>

View File

@ -1,91 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to initialize the MySQL DataBase connection:
class AJAXChatDataBaseMySQLi {
var $_connectionID;
var $_errno = 0;
var $_error = '';
var $_dbName;
function __construct(&$dbConnectionConfig) {
$this->_connectionID = $dbConnectionConfig['link'];
$this->_dbName = $dbConnectionConfig['name'];
}
// Method to connect to the DataBase server:
function connect(&$dbConnectionConfig) {
$this->_connectionID = new mysqli(
$dbConnectionConfig['host'],
$dbConnectionConfig['user'],
$dbConnectionConfig['pass']
);
if(!$this->_connectionID) {
$this->_errno = mysqli_connect_errno();
$this->_error = mysqli_connect_error();
return false;
}
return true;
}
// Method to select the DataBase:
function select($dbName) {
if(!$this->_connectionID->select_db($dbName)) {
$this->_errno = $this->_connectionID->errno;
$this->_error = $this->_connectionID->error;
return false;
}
$this->_dbName = $dbName;
return true;
}
// Method to determine if an error has occured:
function error() {
return (bool)$this->_error;
}
// Method to return the error report:
function getError() {
if($this->error()) {
$str = 'Error-Report: ' .$this->_error."\n";
$str .= 'Error-Code: '.$this->_errno."\n";
} else {
$str = 'No errors.'."\n";
}
return $str;
}
// Method to return the connection identifier:
function &getConnectionID() {
return $this->_connectionID;
}
// Method to prevent SQL injections:
function makeSafe($value) {
return "'".$this->_connectionID->escape_string($value)."'";
}
// Method to perform SQL queries:
function sqlQuery($sql) {
return new AJAXChatMySQLiQuery($sql, $this->_connectionID);
}
// Method to retrieve the current DataBase name:
function getName() {
return $this->_dbName;
}
// Method to retrieve the last inserted ID:
function getLastInsertedID() {
return $this->_connectionID->insert_id;
}
}
?>

View File

@ -1,81 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to perform SQL (MySQLi) queries:
class AJAXChatMySQLiQuery {
var $_connectionID;
var $_sql = '';
var $_result = 0;
var $_errno = 0;
var $_error = '';
// Constructor:
function __construct($sql, $connectionID) {
$this->_sql = trim($sql);
$this->_connectionID = $connectionID;
$this->_result = $this->_connectionID->query($this->_sql);
if(!$this->_result) {
$this->_errno = $this->_connectionID->errno;
$this->_error = $this->_connectionID->error;
}
}
// Returns true if an error occured:
function error() {
// Returns true if the Result-ID is valid:
return !(bool)($this->_result);
}
// Returns an Error-String:
function getError() {
if($this->error()) {
$str = 'Query: ' .$this->_sql ."\n";
$str .= 'Error-Report: ' .$this->_error."\n";
$str .= 'Error-Code: '.$this->_errno;
} else {
$str = "No errors.";
}
return $str;
}
// Returns the content:
function fetch() {
if($this->error()) {
return null;
} else {
return $this->_result->fetch_assoc();
}
}
// Returns the number of rows (SELECT or SHOW):
function numRows() {
if($this->error()) {
return null;
} else {
return $this->_result->num_rows;
}
}
// Returns the number of affected rows (INSERT, UPDATE, REPLACE or DELETE):
function affectedRows() {
if($this->error()) {
return null;
} else {
return $this->_connectionID->affected_rows;
}
}
// Frees the memory:
function free() {
$this->_result->free();
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to provide multibyte enabled string methods
class AJAXChatString {
public static function subString($str, $start=0, $length=null, $encoding='UTF-8') {
if($length === null) {
$length = AJAXChatString::stringLength($str);
}
if(function_exists('mb_substr')) {
return mb_substr($str, $start, $length, $encoding);
} else if(function_exists('iconv_substr')) {
return iconv_substr($str, $start, $length, $encoding);
} else {
return substr($str, $start, $length);
}
}
public static function stringLength($str, $encoding='UTF-8') {
if(function_exists('mb_strlen')) {
return mb_strlen($str, $encoding);
} else if(function_exists('iconv_strlen')) {
return iconv_strlen($str, $encoding);
} else {
return strlen($str);
}
}
}
?>

View File

@ -1,359 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to handle HTML templates
class AJAXChatTemplate {
var $ajaxChat;
var $_regExpTemplateTags;
var $_templateFile;
var $_contentType;
var $_content;
var $_parsedContent;
// Constructor:
function __construct(&$ajaxChat, $templateFile, $contentType=null) {
$this->ajaxChat = $ajaxChat;
$this->_regExpTemplateTags = '/\[(\w+?)(?:(?:\/)|(?:\](.+?)\[\/\1))\]/s';
$this->_templateFile = $templateFile;
$this->_contentType = $contentType;
}
function getParsedContent() {
if(!$this->_parsedContent) {
$this->parseContent();
}
return $this->_parsedContent;
}
function getContent() {
if(!$this->_content) {
$this->_content = AJAXChatFileSystem::getFileContents($this->_templateFile);
}
return $this->_content;
}
function parseContent() {
$this->_parsedContent = $this->getContent();
// Remove the XML declaration if the content-type is not xml:
if($this->_contentType && (strpos($this->_contentType,'xml') === false)) {
$doctypeStart = strpos($this->_parsedContent, '<!DOCTYPE ');
if($doctypeStart !== false) {
// Removing the XML declaration (in front of the document type) prevents IE<7 to go into "Quirks mode":
$this->_parsedContent = substr($this->_parsedContent, $doctypeStart);
}
}
// Replace template tags ([TAG/] and [TAG]content[/TAG]) and return parsed template content:
$this->_parsedContent = preg_replace_callback($this->_regExpTemplateTags, array($this, 'replaceTemplateTags'), $this->_parsedContent);
}
function replaceTemplateTags($tagData) {
switch($tagData[1]) {
case 'AJAX_CHAT_URL':
return $this->ajaxChat->htmlEncode($this->ajaxChat->getChatURL());
case 'LANG':
return $this->ajaxChat->htmlEncode($this->ajaxChat->getLang($tagData[2]));
case 'LANG_CODE':
return $this->ajaxChat->getLangCode();
case 'BASE_DIRECTION':
return $this->getBaseDirectionAttribute();
case 'CONTENT_ENCODING':
return $this->ajaxChat->getConfig('contentEncoding');
case 'CONTENT_TYPE':
return $this->_contentType;
case 'LOGIN_URL':
return ($this->ajaxChat->getRequestVar('view') == 'logs') ? './?view=logs' : './';
case 'USER_NAME_MAX_LENGTH':
return $this->ajaxChat->getConfig('userNameMaxLength');
case 'MESSAGE_TEXT_MAX_LENGTH':
return $this->ajaxChat->getConfig('messageTextMaxLength');
case 'LOGIN_CHANNEL_ID':
return $this->ajaxChat->getValidRequestChannelID();
case 'SESSION_NAME':
return $this->ajaxChat->getConfig('sessionName');
case 'COOKIE_EXPIRATION':
return $this->ajaxChat->getConfig('sessionCookieLifeTime');
case 'COOKIE_PATH':
return $this->ajaxChat->getConfig('sessionCookiePath');
case 'COOKIE_DOMAIN':
return $this->ajaxChat->getConfig('sessionCookieDomain');
case 'COOKIE_SECURE':
return $this->ajaxChat->getConfig('sessionCookieSecure');
case 'CHAT_BOT_NAME':
return rawurlencode($this->ajaxChat->getConfig('chatBotName'));
case 'CHAT_BOT_ID':
return $this->ajaxChat->getConfig('chatBotID');
case 'ALLOW_USER_MESSAGE_DELETE':
if($this->ajaxChat->getConfig('allowUserMessageDelete'))
return 1;
else
return 0;
case 'INACTIVE_TIMEOUT':
return $this->ajaxChat->getConfig('inactiveTimeout');
case 'PRIVATE_CHANNEL_DIFF':
return $this->ajaxChat->getConfig('privateChannelDiff');
case 'PRIVATE_MESSAGE_DIFF':
return $this->ajaxChat->getConfig('privateMessageDiff');
case 'SHOW_CHANNEL_MESSAGES':
if($this->ajaxChat->getConfig('showChannelMessages'))
return 1;
else
return 0;
case 'SOCKET_SERVER_ENABLED':
if($this->ajaxChat->getConfig('socketServerEnabled'))
return 1;
else
return 0;
case 'SOCKET_SERVER_HOST':
if($this->ajaxChat->getConfig('socketServerHost')) {
$socketServerHost = $this->ajaxChat->getConfig('socketServerHost');
} else {
$socketServerHost = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);
}
return rawurlencode($socketServerHost);
case 'SOCKET_SERVER_PORT':
return $this->ajaxChat->getConfig('socketServerPort');
case 'SOCKET_SERVER_CHAT_ID':
return $this->ajaxChat->getConfig('socketServerChatID');
case 'STYLE_SHEETS':
return $this->getStyleSheetLinkTags();
case 'CHANNEL_OPTIONS':
return $this->getChannelOptionTags();
case 'STYLE_OPTIONS':
return $this->getStyleOptionTags();
case 'LANGUAGE_OPTIONS':
return $this->getLanguageOptionTags();
case 'ERROR_MESSAGES':
return $this->getErrorMessageTags();
case 'LOGS_CHANNEL_OPTIONS':
return $this->getLogsChannelOptionTags();
case 'LOGS_YEAR_OPTIONS':
return $this->getLogsYearOptionTags();
case 'LOGS_MONTH_OPTIONS':
return $this->getLogsMonthOptionTags();
case 'LOGS_DAY_OPTIONS':
return $this->getLogsDayOptionTags();
case 'LOGS_HOUR_OPTIONS':
return $this->getLogsHourOptionTags();
case 'MENU_BAR':
return <<<EOF
<ul>
<li class="first notcurrent"><a href="https://flashii.net/">Home</a></li>
<li class="notcurrent"><a href="https://flashii.net/news.php">News</a></li>
<li class="current"><a href="./">Chat</a></li>
<li class="notcurrent"><a href="https://flashii.net/members.php">Members</a></li>
<li class="notcurrent"><a href="https://flashii.net/donate.php">Donate</a></li>
<li class="notcurrent"><a href="https://status.flashii.net">Status</a></li>
</ul>
EOF;
case 'COPYRIGHT':
return <<<EOF
<div class="copyright">
Copyright &copy; 2013-2015 <a href="https://flash.moe/" target="_blank">Flashwave</a>
<br /><a href="https://blueimp.net/ajax/" target="_blank">AJAX Chat</a> &copy; <a href="https://blueimp.net" target="_blank">blueimp.net</a>
<br />
<a href="https://flashii.net/forum">Feedback</a> |
<a href="https://flashii.net/changelog.php">Changelog</a> |
<a href="https://flashii.net/info.php/rules">Rules &amp; Info</a> |
<a href="https://flashii.net/info.php/terms">Terms of Service</a> |
<a href="https://flashii.net/info.php/contact">Contact</a> |
<a href="https://test.flashii.net">DevSite</a> |
<a href="?view=legacy">Legacy Login</a>
</div><br />
EOF;
case 'SANDSTORM':
if(date('md') === '0127' || !empty($_GET['sandstorm']))
return <<<HTML
<br />
<audio loop="loop" autoplay="autoplay" controls="controls">
<source type="audio/ogg" src="./sandstorm.ogg" />
<source type="audio/mpeg" src="./sandstorm.mp3" />
</audio>
<br />
HTML;
else
return '';
default:
return $this->ajaxChat->replaceCustomTemplateTags($tagData[1], (isset($tagData[2]) ? $tagData[2] : null));
}
}
// Function to display alternating table row colors:
function alternateRow($rowOdd='rowOdd', $rowEven='rowEven') {
static $i;
$i += 1;
if($i % 2 == 0) {
return $rowEven;
} else {
return $rowOdd;
}
}
function getBaseDirectionAttribute() {
$langCodeParts = explode('-', $this->ajaxChat->getLangCode());
switch($langCodeParts[0]) {
case 'ar':
case 'fa':
case 'he':
return 'rtl';
default:
return 'ltr';
}
}
function getStyleSheetLinkTags() {
$styleSheets = '';
foreach($this->ajaxChat->getConfig('styleAvailable') as $style) {
$alternate = ($style == $this->ajaxChat->getConfig('styleDefault')) ? '' : 'alternate ';
$styleSheets .= '<link rel="'.$alternate.'stylesheet" type="text/css" href="css/'.rawurlencode($style).'.ajaxchat.css" title="'.$this->ajaxChat->htmlEncode($style).'"/>';
}
return $styleSheets;
}
function getChannelOptionTags() {
$channelOptions = '';
$channelSelected = false;
foreach($this->ajaxChat->getChannels() as $key=>$value) {
if($this->ajaxChat->isLoggedIn()) {
$selected = ($value == $this->ajaxChat->getChannel()) ? ' selected="selected"' : '';
} else {
$selected = ($value == $this->ajaxChat->getConfig('defaultChannelID')) ? ' selected="selected"' : '';
}
if($selected) {
$channelSelected = true;
}
$channelOptions .= '<option value="'.$this->ajaxChat->htmlEncode($key).'"'.$selected.'>'.$this->ajaxChat->htmlEncode($key).'</option>';
}
if($this->ajaxChat->isLoggedIn() && $this->ajaxChat->isAllowedToCreatePrivateChannel()) {
// Add the private channel of the user to the options list:
if(!$channelSelected && $this->ajaxChat->getPrivateChannelID() == $this->ajaxChat->getChannel()) {
$selected = ' selected="selected"';
$channelSelected = true;
} else {
$selected = '';
}
$privateChannelName = $this->ajaxChat->getPrivateChannelName();
$channelOptions .= '<option value="'.$this->ajaxChat->htmlEncode($privateChannelName).'"'.$selected.'>'.$this->ajaxChat->htmlEncode($privateChannelName).'</option>';
}
// If current channel is not in the list, try to retrieve the channelName:
if(!$channelSelected) {
$channelName = $this->ajaxChat->getChannelName();
if($channelName !== null) {
$channelOptions .= '<option value="'.$this->ajaxChat->htmlEncode($channelName).'" selected="selected">'.$this->ajaxChat->htmlEncode($channelName).'</option>';
} else {
// Show an empty selection:
$channelOptions .= '<option value="" selected="selected">---</option>';
}
}
return $channelOptions;
}
function getStyleOptionTags() {
$styleOptions = '';
foreach($this->ajaxChat->getConfig('styleAvailable') as $style) {
$selected = ($style == $this->ajaxChat->getConfig('styleDefault')) ? ' selected="selected"' : '';
$styleOptions .= '<option value="'.$this->ajaxChat->htmlEncode($style).'"'.$selected.'>'.$this->ajaxChat->htmlEncode($style).'</option>';
}
return $styleOptions;
}
function getLanguageOptionTags() {
$languageOptions = '';
$languageNames = $this->ajaxChat->getConfig('langNames');
foreach($this->ajaxChat->getConfig('langAvailable') as $langCode) {
$selected = ($langCode == $this->ajaxChat->getLangCode()) ? ' selected="selected"' : '';
$languageOptions .= '<option value="'.$this->ajaxChat->htmlEncode($langCode).'"'.$selected.'>'.$languageNames[$langCode].'</option>';
}
return $languageOptions;
}
function getErrorMessageTags() {
$errorMessages = '';
foreach($this->ajaxChat->getInfoMessages('error') as $error) {
$errorMessages .= '<h3 class="miotitle">'.$this->ajaxChat->htmlEncode($this->ajaxChat->getLang($error)).'</h3>';
}
return $errorMessages;
}
function getLogsChannelOptionTags() {
$channelOptions = '';
$channelOptions .= '<option value="-3">------</option>';
foreach($this->ajaxChat->getChannels() as $key=>$value) {
if($this->ajaxChat->getUserRole() != AJAX_CHAT_ADMIN && $this->ajaxChat->getConfig('logsUserAccessChannelList') && !in_array($value, $this->ajaxChat->getConfig('logsUserAccessChannelList'))) {
continue;
}
$channelOptions .= '<option value="'.$value.'">'.$this->ajaxChat->htmlEncode($key).'</option>';
}
$channelOptions .= '<option value="-1">'.$this->ajaxChat->htmlEncode($this->ajaxChat->getLang('logsPrivateChannels')).'</option>';
$channelOptions .= '<option value="-2">'.$this->ajaxChat->htmlEncode($this->ajaxChat->getLang('logsPrivateMessages')).'</option>';
return $channelOptions;
}
function getLogsYearOptionTags() {
$yearOptions = '';
$yearOptions .= '<option value="-1">----</option>';
for($year=date('Y'); $year>=$this->ajaxChat->getConfig('logsFirstYear'); $year--) {
$yearOptions .= '<option value="'.$year.'">'.$year.'</option>';
}
return $yearOptions;
}
function getLogsMonthOptionTags() {
$monthOptions = '';
$monthOptions .= '<option value="-1">--</option>';
for($month=1; $month<=12; $month++) {
$monthOptions .= '<option value="'.$month.'">'.sprintf("%02d", $month).'</option>';
}
return $monthOptions;
}
function getLogsDayOptionTags() {
$dayOptions = '';
$dayOptions .= '<option value="-1">--</option>';
for($day=1; $day<=31; $day++) {
$dayOptions .= '<option value="'.$day.'">'.sprintf("%02d", $day).'</option>';
}
return $dayOptions;
}
function getLogsHourOptionTags() {
$hourOptions = '';
$hourOptions .= '<option value="-1">-----</option>';
for($hour=0; $hour<=23; $hour++) {
$hourOptions .= '<option value="'.$hour.'">'.sprintf("%02d", $hour).':00</option>';
}
return $hourOptions;
}
}
?>

View File

@ -1,25 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
class CustomAJAXChatShoutBox extends CustomAJAXChat {
function initialize() {
// Initialize configuration settings:
$this->initConfig();
}
function getShoutBoxContent() {
$template = new AJAXChatTemplate($this, AJAX_CHAT_PATH.'lib/template/shoutbox.html');
// Return parsed template content:
return $template->getParsedContent();
}
}
?>

View File

@ -1,239 +0,0 @@
<?php
// Configuration
$satoriSetting = array();
$satoriSetting['enabled'] = true;
$satoriSetting['userID'] = 9;
$satoriSetting['userName'] = 'Satori';
$satoriSetting['userRank'] = BOTS;
$satoriSetting['userIP'] = '127.0.0.1';
// Parsing
$satoriParse = strtolower($text);
$satoriParse = preg_replace('/\\[(?:\\/)?(\\w+)(?:=([^<>]*?))?\\]/ms', '', $satoriParse);
$textParts = explode(' ', $satoriParse);
// Random Stuff
$defaultResponseArray = ['What do you want?', 'Kindly fuck off.', 'Don\'t know how to "%s" something.', 'Come again?', 'Satori returned an empty result set (i.e. zero rows).'];
$defaultResponse = sprintf($defaultResponseArray[array_rand($defaultResponseArray)], $textParts[0]);
// Actions
if(preg_match('/^k$/im', $satoriParse)) {
$satoriResp = ['Thank you for your amazing and insightful message. It is truly an honour to have this message in my database. I can\'t thank you more than to say go fuck yourself. You truly touched me... Thank you.'];
}
if(preg_match('/^time to break the chat$/im', $satoriParse)) {
$satoriResp = ['Stay away from me!'];
}
if(preg_match('/^all aboard the sailboat$/im', $satoriParse)) {
$satoriResp = ['Why would we get on something that is about to sink :^)'];
}
// Reactions
if(preg_match('/^satori/im', $textParts[0])) {
switch($satoriInput = preg_replace('/^satori? ?/', '', $satoriParse)) {
case 'version':
$satoriResp = ['[b][color=Red]S[/color][color=Ruby]a[/color][color=Citrine]t[/color][color=Green]o[/color][color=Teal]r[/color][color=Cobalt]i[/color][/b] Version not [b]6[/b]'];
break;
case 'what are you':
$satoriResp = ['I am nice girl for nice chat.', '[img]http://i.imgur.com/NcFitL2.jpg[/img]'];
break;
case 'hi':
$satoriResp = ['sup'];
break;
case 'help':
$satoriResp = ['If you need help with things refer to the [url=http://flashii.net/r/faq]FAQ[/url].', 'If this didn\'t help you don\'t hesitate to ask an active user.'];
break;
case 'why do you exist':
$satoriResp = ['So you have someone to hate. <3'];
break;
case 'suck my dick':
$satoriResp = ['Do you even have one? Can\'t see it.'];
break;
case 'make me admin':
$satoriResp = ['Why the fuck would you WANT admin? It\'s nothing more than extra work for an ugly red username! Look now the colour for deactivated user, that one\'s fucking hot.'];
break;
case 'anime':
$satoriResp = ['Oh god, i wish i could leave this chat but i\'m stuck in here ;__;'];
break;
case 'e':
$satoriResp = ['Do I look like Nasbot or something?'];
break;
case 'meow':
$satoriResp = ['Mewow!'];
break;
case 'puush':
$satoriResp = ['Something you should be using.'];
break;
case 'what is flash\'s password':
case 'what is flashwave\'s password':
case 'what is moka\'s password':
$satoriResp = ['/suicide', 'I do recommend sending it in chat right now.'];
break;
case 'what do you think about snailmush':
case 'what do you like snailmush':
case 'snailmush':
$satoriResp = ['I-it\'s not like I like him or-or any-anything...... ;_;'];
break;
case 'x snailmush':
case 'loves snailmush':
case 'do you love snailmush':
case 'do you love snailmush?':
$satoriResp = ['NO!', '[s]Trigger Kick'];
break;
case 'saibateku':
$satoriResp = ['That place is still up?'];
break;
case 'titanic':
$satoriResp = ['Did you mean Sailboat?'];
break;
case 'did sailboat sink yet':
$satoriResp = ['No but I wish it would. Fuck that place. Seems to be getting pretty close however...'];
break;
case 'malwareup':
$satoriResp = ['Good malware discussion forum.'];
break;
case 'flashii':
$satoriResp = ['Mediocre shithole. 0/10'];
break;
case 'cybernetics':
$satoriResp = ['Did you mean "Saibateku"?'];
break;
case 'nathat':
$satoriResp = ['shut up'];
break;
case 'waifu':
case 'inori aizawa':
case 'internet explorer tan':
$satoriResp = ['Inori Aizawa Is Mai Waifu.', 'Welcome To Mai Web Browser Is Mai Waifu Land!'];
break;
case 'webkit':
case 'safari':
case 'blink':
case 'chrome':
$satoriResp = [':puke::puke::puke:'];
break;
case 'gecko':
case 'trident':
case 'internet explorer':
case 'iexplore':
case 'firefox':
case 'mozilla firefox':
$satoriResp = [':love::love::love:'];
break;
case 'bribob':
case 'bribob4':
$satoriResp = ['Mediocre faggot. 0/10'];
break;
case 'kelopez':
case 'brante':
$satoriResp = ['http://en.wikipedia.org/wiki/Mexican'];
break;
case 'kamil':
case 'rakowski':
case 'kamilrakowski':
$satoriResp = ['http://en.wikipedia.org/wiki/Jews'];
break;
case 'secret':
$satoriResp = ['I\'m not a secret ripoff, what are you talking about?', '[i]My code is better, time to kill yourself![/i]'];
break;
case 'koishi':
$satoriResp = ['Don\'t fuck with Koishi.'];
break;
case ':^)':
$satoriResp = ['8^)'];
break;
case 'nookls':
$satoriResp = ['HOOOOLLLLLYYYYYYYYYYYYY CRAP NOOKLS IS SO AMAZING WOWOWOWOWOWOW HE\'S ACTUALLY ON THIS SITE WORSHIP WORSHIP AMAZING BRILLIANT I LOVE YOU NOOKLS WE ALL LOVE YOU WE LOVE YOU AS MUCH AS FANGIRLS LOVE JUSTIN BIEBER AAAAAAAAHHHHHHHHHHHH THIS IS THE BEST MOMENT!'];
break;
case 'zeniea':
$satoriResp = ['For whatever reason I have the urge to say "This place smells like a catholic church on crack"...'];
break;
case 'zquest':
$satoriResp = ['Good comic 10/10'];
break;
case 'fuck me':
$satoriResp = [':wtf:'];
break;
case 'satori':
$satoriResp = ['Wait, what are you trying to do?'];
break;
case 'satori satori':
$satoriResp = ['Don\'t fucking do this to me...'];
break;
case 'satori satori satori':
$satoriResp = ['[b][i]I\'ll fucking murder you![/i][/b]'];
break;
case 'satori satori satori satori':
$satoriResp = ['no don\'t'];
break;
case 'satori satori satori satori satori':
$satoriResp = ['please don\'t do this to me'];
break;
case 'satori satori satori satori satori satori':
$satoriResp = ['i have a waifu and kids'];
break;
case 'satori satori satori satori satori satori satori':
$satoriResp = ['okay i was kidding about the kids part'];
break;
case 'satori satori satori satori satori satori satori satori':
$satoriResp = ['rip life'];
break;
case 'you are annoying':
case 'please die':
case 'die':
$satoriResp = ['Well I\'m God and you can\'t do shit.'];
break;
case 'misaka-20001':
$satoriResp = ['We\'ll have to move one of these days...', 'The good ol\' Pentium 4 doesn\'t seem to be able to handle shit anymore...'];
break;
case 'how old are you':
case 'how old is flashii':
case 'how old is koishi':
$satoriResp = [date_diff(date_create('2013-01-27 22:14:44 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
break;
case 'how old is zeniea':
case 'how old is secret':
$satoriResp = [date_diff(date_create('2011-07-07 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
break;
case 'how old is zquest':
$satoriResp = [date_diff(date_create('2013-11-16 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
break;
case 'are you broken':
case 'are you broken?':
case 'is flashii broken':
case 'is flashii broken?':
$satoriResp = ['yes'];
break;
default:
$satoriResp = [$defaultResponse];
break;
}
}
// Check if disabled
if(!$satoriSetting['enabled'])
$satoriResp = null;
// Bring the process of sending a message down to one if
if(isset($satoriResp)) {
foreach($satoriResp as $directives => $response) {
if($response == '[s]Trigger Kick') {
$this->logout('Kicked');
} else {
$this->insertCustomMessage(
$satoriSetting['userID'],
$satoriSetting['userName'],
$satoriSetting['userRank'],
$this->getChannel(),
vsprintf($response, $directives),
$satoriSetting['userIP'],
0
);
}
}
}

View File

@ -1,26 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Include Class libraries:
require(AJAX_CHAT_PATH.'lib/class/AJAXChat.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatDataBase.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatMySQLDataBase.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatMySQLQuery.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatMySQLiDataBase.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatMySQLiQuery.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatEncoding.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatString.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatFileSystem.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatHTTPHeader.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatLanguage.php');
require(AJAX_CHAT_PATH.'lib/class/AJAXChatTemplate.php');
require(AJAX_CHAT_PATH.'lib/class/CustomAJAXChat.php');
require(AJAX_CHAT_PATH.'lib/class/CustomAJAXChatShoutBox.php');
require(AJAX_CHAT_PATH.'lib/class/CustomAJAXChatInterface.php');
?>

View File

@ -1,11 +0,0 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Include custom libraries and initialization code here
?>

View File

@ -1,120 +0,0 @@
<?php
$lang = array();
$lang['title'] = 'Flashii Chat';
$lang['titleinchat'] = 'Flashii Chat Legacy';
$lang['userName'] = 'Username';
$lang['password'] = 'Password';
$lang['login'] = 'Login';
$lang['logout'] = 'Logout';
$lang['mobile'] = 'Mobile';
$lang['desktop'] = 'Desktop';
$lang['channel'] = 'Channel';
$lang['style'] = 'Style';
$lang['language'] = 'Language';
$lang['inputLineBreak'] = 'Press SHIFT+ENTER to input a line break';
$lang['messageSubmit'] = 'Send';
$lang['registeredUsers'] = 'Log in with your Flashii credentials, this chat is entirely unregulated so enter at your own risk.';
$lang['onlineUsers'] = 'Online users';
$lang['toggleAutoScroll'] = 'Autoscroll on/off';
$lang['toggleAudio'] = 'Sound on/off';
$lang['toggleHelp'] = 'Show/hide help';
$lang['toggleSettings'] = 'Show/hide settings';
$lang['toggleOnlineList'] = 'Show/hide online list';
$lang['bbCodeLabelBold'] = 'b';
$lang['bbCodeLabelItalic'] = 'i';
$lang['bbCodeLabelUnderline'] = 'u';
$lang['bbCodeLabelQuote'] = 'Quote';
$lang['bbCodeLabelCode'] = 'Code';
$lang['bbCodeLabelURL'] = 'URL';
$lang['bbCodeLabelImg'] = 'Image';
$lang['bbCodeLabelColor'] = 'Colour';
$lang['bbCodeTitleBold'] = 'Bold text: [b]text[/b]';
$lang['bbCodeTitleItalic'] = 'Italic text: [i]text[/i]';
$lang['bbCodeTitleUnderline'] = 'Underline text: [u]text[/u]';
$lang['bbCodeTitleQuote'] = 'Quote text: [quote]text[/quote] or [quote=author]text[/quote]';
$lang['bbCodeTitleCode'] = 'Code display: [code]code[/code]';
$lang['bbCodeTitleURL'] = 'Insert URL: [url]http://example.org[/url] or [url=http://example.org]text[/url]';
$lang['bbCodeTitleImg'] = 'Insert image: [img]http://example.org/image.jpg[/img]';
$lang['bbCodeTitleColor'] = 'Font Colour: [color=red]text[/color]';
$lang['help'] = 'Help';
$lang['helpItemDescJoin'] = 'Join a channel:';
$lang['helpItemCodeJoin'] = '/join Channelname';
$lang['helpItemDescJoinCreate'] = 'Create a private room (Registered users only):';
$lang['helpItemCodeJoinCreate'] = '/join';
$lang['helpItemDescInvite'] = 'Invite someone (e.g. to a private room):';
$lang['helpItemCodeInvite'] = '/invite Username';
$lang['helpItemDescUninvite'] = 'Revoke invitation:';
$lang['helpItemCodeUninvite'] = '/uninvite Username';
$lang['helpItemDescLogout'] = 'Logout from Chat:';
$lang['helpItemCodeLogout'] = '/quit';
$lang['helpItemDescPrivateMessage'] = 'Private message:';
$lang['helpItemCodePrivateMessage'] = '/msg Username Text';
$lang['helpItemDescQueryOpen'] = 'Open a private channel:';
$lang['helpItemCodeQueryOpen'] = '/query Username';
$lang['helpItemDescQueryClose'] = 'Close a private channel:';
$lang['helpItemCodeQueryClose'] = '/query';
$lang['helpItemDescAction'] = 'Describe action:';
$lang['helpItemCodeAction'] = '/action Text';
$lang['helpItemDescDescribe'] = 'Describe action in private message:';
$lang['helpItemCodeDescribe'] = '/describe Username Text';
$lang['helpItemDescIgnore'] = 'Ignore/accept messages from user:';
$lang['helpItemCodeIgnore'] = '/ignore Username';
$lang['helpItemDescIgnoreList'] = 'List ignored users:';
$lang['helpItemCodeIgnoreList'] = '/ignore';
$lang['helpItemDescWhereis'] = 'Display user channel:';
$lang['helpItemCodeWhereis'] = '/whereis Username';
$lang['helpItemDescKick'] = 'Kick a user (Moderators only):';
$lang['helpItemCodeKick'] = '/kick Username [Minutes banned]';
$lang['helpItemDescUnban'] = 'Unban a user (Moderators only):';
$lang['helpItemCodeUnban'] = '/unban Username';
$lang['helpItemDescBans'] = 'List banned users (Moderators only):';
$lang['helpItemCodeBans'] = '/bans';
$lang['helpItemDescWhois'] = 'Display user IP (Moderators only):';
$lang['helpItemCodeWhois'] = '/whois Username';
$lang['helpItemDescWho'] = 'List online users:';
$lang['helpItemCodeWho'] = '/who [Channelname]';
$lang['helpItemDescList'] = 'List available channels:';
$lang['helpItemCodeList'] = '/list';
$lang['helpItemDescRoll'] = 'Roll dice:';
$lang['helpItemCodeRoll'] = '/roll [number]d[sides]';
$lang['helpItemDescNick'] = 'Change username:';
$lang['helpItemCodeNick'] = '/nick Username';
$lang['settings'] = 'Settings';
$lang['settingsBBCode'] = 'Enable BBCode:';
$lang['settingsBBCodeImages'] = 'Enable image BBCode:';
$lang['settingsBBCodeColors'] = 'Enable font color BBCode:';
$lang['settingsHyperLinks'] = 'Enable hyperlinks:';
$lang['settingsLineBreaks'] = 'Enable line breaks:';
$lang['settingsEmoticons'] = 'Enable emoticons:';
$lang['settingsAutoFocus'] = 'Automatically set the focus on the input field:';
$lang['settingsMaxMessages'] = 'Maximum number of messages in the chatlist:';
$lang['settingsWordWrap'] = 'Enable wrapping of long words:';
$lang['settingsMaxWordLength'] = 'Maximum length of a word before it gets wrapped:';
$lang['settingsDateFormat'] = 'Format of date and time display:';
$lang['settingsPersistFontColor'] = 'Persist font color:';
$lang['settingsAudioVolume'] = 'Sound Volume:';
$lang['settingsSoundReceive'] = 'Sound for incoming messages:';
$lang['settingsSoundSend'] = 'Sound for outgoing messages:';
$lang['settingsSoundEnter'] = 'Sound for login and channel enter messages:';
$lang['settingsSoundLeave'] = 'Sound for logout and channel leave messages:';
$lang['settingsSoundChatBot'] = 'Sound for chatbot messages:';
$lang['settingsSoundError'] = 'Sound for error messages:';
$lang['settingsSoundPrivate'] = 'Sound for private messages:';
$lang['settingsBlink'] = 'Blink window title on new messages:';
$lang['settingsBlinkInterval'] = 'Blink interval in milliseconds:';
$lang['settingsBlinkIntervalNumber'] = 'Number of blink intervals:';
$lang['playSelectedSound'] = 'Play selected sound';
$lang['requiresJavaScript'] = 'Please enable JavaScript or use a compatible browser.';
$lang['errorInvalidUser'] = 'Invalid username or password.';
$lang['errorUserInUse'] = 'Username in use.';
//$lang['errorBanned'] = 'You are banned ;_;';
$lang['errorBanned'] = 'You have been kicked from this chatroom.';
$lang['errorMaxUsersLoggedIn'] = 'The chat has reached the maximum number of logged-in users.';
//$lang['errorChatClosed'] = 'It started with a call I stupidly answered You said you got my number from one of the dancers You waited right outside, you had something on mind But then I saw your eyes, your crazy eyes Now you got me into something very sick and twisted An evil kind of game I didn\'t know existed You traveled overseas to terrorize me And I don\'t understand, why can\'t you let me be? Believe me when I say, you stupid fool! You\'re scaring me to death, that\'s not cool! Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! I beg of you to stop and think this through It\'s time you started playing with someone new Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! You\'re scaring mom and dad, scaring off my girlfriend You\'re waiting by my door early in the morning I\'ve told you many times, don\'t follow me at night You\'re poisoning in my life, just tell me why! Believe me when I say, you stupid fool! You\'re scaring me to death, that\'s not cool! Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! I beg of you to stop and think this through It\'s time you started playing with someone new Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! Believe me when I say, you stupid fool! You\'re scaring me to death, that\'s not cool! Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone! I beg of you to stop and think this through It\'s time you started playing with someone new Why won\'t you leave me alone? Just leave me alone! You\'re crazy, leave me alone!';
$lang['errorChatClosed'] = 'Site maintenance';
$lang['logsTitle'] = 'The Evil Circle';
$lang['logsDate'] = 'Date';
$lang['logsTime'] = 'Time';
$lang['logsSearch'] = 'Search';
$lang['logsPrivateChannels'] = 'Private Channels';
$lang['logsPrivateMessages'] = 'Private Messages';

3491
src/AJAXChat.php Normal file

File diff suppressed because it is too large Load Diff

80
src/AJAXChatDataBase.php Normal file
View File

@ -0,0 +1,80 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to initialize the DataBase connection:
class AJAXChatDataBase {
private $_db;
function __construct(&$dbConnectionConfig) {
switch($dbConnectionConfig['type']) {
case 'mysqli':
$this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig);
break;
case 'mysql':
$this->_db = new AJAXChatDatabaseMySQL($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);
}
}
}
// Method to connect to the DataBase server:
function connect(&$dbConnectionConfig) {
return $this->_db->connect($dbConnectionConfig);
}
// Method to select the DataBase:
function select($dbName) {
return $this->_db->select($dbName);
}
// Method to determine if an error has occured:
function error() {
return $this->_db->error();
}
// Method to return the error report:
function getError() {
return $this->_db->getError();
}
// Method to return the connection identifier:
function &getConnectionID() {
return $this->_db->getConnectionID();
}
// Method to prevent SQL injections:
function makeSafe($value) {
return $this->_db->makeSafe($value);
}
// Method to perform SQL queries:
function sqlQuery($sql) {
return $this->_db->sqlQuery($sql);
}
// Method to retrieve the current DataBase name:
function getName() {
return $this->_db->getName();
//If your database has hyphens ( - ) in it, try using this instead:
//return '`'.$this->_db->getName().'`';
}
// Method to retrieve the last inserted ID:
function getLastInsertedID() {
return $this->_db->getLastInsertedID();
}
}

137
src/AJAXChatEncoding.php Normal file
View File

@ -0,0 +1,137 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to provide static encoding methods
class AJAXChatEncoding {
// Helper function to store special chars as we cannot use static class members in PHP4:
public static function getSpecialChars() {
static $specialChars;
if(!$specialChars) {
// As &apos; is not supported by IE, we use &#39; as replacement for "'":
$specialChars = array('&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', "'"=>'&#39;', '"'=>'&quot;');
}
return $specialChars;
}
// Helper function to store Regular expression for NO-WS-CTL as we cannot use static class members in PHP4:
public static function getRegExp_NO_WS_CTL() {
static $regExp_NO_WS_CTL;
if(!$regExp_NO_WS_CTL) {
// Regular expression for NO-WS-CTL, non-whitespace control characters (RFC 2822), decimal 18, 1112, 1431, and 127:
$regExp_NO_WS_CTL = '/[\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F]/';
}
return $regExp_NO_WS_CTL;
}
public static function convertEncoding($str, $charsetFrom, $charsetTo) {
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($str, $charsetTo, $charsetFrom);
}
if(function_exists('iconv')) {
return iconv($charsetFrom, $charsetTo, $str);
}
if(($charsetFrom == 'UTF-8') && ($charsetTo == 'ISO-8859-1')) {
return utf8_decode($str);
}
if(($charsetFrom == 'ISO-8859-1') && ($charsetTo == 'UTF-8')) {
return utf8_encode($str);
}
return $str;
}
public static function htmlEncode($str, $contentCharset='UTF-8') {
switch($contentCharset) {
case 'UTF-8':
// Encode only special chars (&, <, >, ', ") as entities:
return AJAXChatEncoding::encodeSpecialChars($str);
break;
case 'ISO-8859-1':
case 'ISO-8859-15':
// Encode special chars and all extended characters above ISO-8859-1 charset as entities, then convert to content charset:
return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array(
0x26, 0x26, 0, 0xFFFF, // &
0x3C, 0x3C, 0, 0xFFFF, // <
0x3E, 0x3E, 0, 0xFFFF, // >
0x27, 0x27, 0, 0xFFFF, // '
0x22, 0x22, 0, 0xFFFF, // "
0x100, 0x2FFFF, 0, 0xFFFF // above ISO-8859-1
)), 'UTF-8', $contentCharset);
break;
default:
// Encode special chars and all characters above ASCII charset as entities, then convert to content charset:
return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array(
0x26, 0x26, 0, 0xFFFF, // &
0x3C, 0x3C, 0, 0xFFFF, // <
0x3E, 0x3E, 0, 0xFFFF, // >
0x27, 0x27, 0, 0xFFFF, // '
0x22, 0x22, 0, 0xFFFF, // "
0x80, 0x2FFFF, 0, 0xFFFF // above ASCII
)), 'UTF-8', $contentCharset);
}
}
public static function encodeSpecialChars($str) {
return strtr($str, AJAXChatEncoding::getSpecialChars());
}
public static function decodeSpecialChars($str) {
return strtr($str, array_flip(AJAXChatEncoding::getSpecialChars()));
}
public static function encodeEntities($str, $encoding='UTF-8', $convmap=null) {
if($convmap && function_exists('mb_encode_numericentity')) {
return mb_encode_numericentity($str, $convmap, $encoding);
}
return htmlentities($str, ENT_QUOTES, $encoding);
}
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;
}
public static function unicodeChar($c) {
if($c <= 0x7F) {
return chr($c);
} else if($c <= 0x7FF) {
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
} else if($c <= 0xFFFF) {
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
} else if($c <= 0x10FFFF) {
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
} else {
return null;
}
}
public static function removeUnsafeCharacters($str) {
// Remove NO-WS-CTL, non-whitespace control characters (RFC 2822), decimal 18, 1112, 1431, and 127:
return preg_replace(AJAXChatEncoding::getRegExp_NO_WS_CTL(), '', $str);
}
}

View File

@ -10,13 +10,12 @@
// Class to provide methods for file system access:
class AJAXChatFileSystem {
public static function getFileContents($file) {
if(function_exists('file_get_contents')) {
return file_get_contents($file);
} else {
return(implode('', file($file)));
}
}
public static function getFileContents($file) {
if(function_exists('file_get_contents')) {
return file_get_contents($file);
} else {
return(implode('', file($file)));
}
}
}
?>

View File

@ -0,0 +1,55 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to manage HTTP header
class AJAXChatHTTPHeader {
private $_contentType;
private $_constant;
private $_noCache;
function __construct($encoding='UTF-8', $contentType=null, $noCache=true) {
if($contentType) {
$this->_contentType = $contentType.'; charset='.$encoding;
$this->_constant = true;
} else {
if(isset($_SERVER['HTTP_ACCEPT']) && (strpos($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml') !== false)) {
$this->_contentType = 'application/xhtml+xml; charset='.$encoding;
} else {
$this->_contentType = 'text/html; charset='.$encoding;
}
$this->_constant = false;
}
$this->_noCache = $noCache;
}
// Method to send the HTTP header:
function send() {
// Prevent caching:
if($this->_noCache) {
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
}
// Send the content-type-header:
header('Content-Type: '.$this->_contentType);
// Send vary header if content-type varies (important for proxy-caches):
if(!$this->_constant) {
header('Vary: Accept');
}
}
// Method to return the content-type string:
function getContentType() {
// Return the content-type string:
return $this->_contentType;
}
}

101
src/AJAXChatLanguage.php Normal file
View File

@ -0,0 +1,101 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
class AJAXChatLanguage {
private $_regExpAcceptLangCode;
private $_availableLangCodes;
private $_defaultLangCode;
private $_strictMode;
private $_langCode;
function __construct($availableLangCodes, $defaultLangCode, $langCode=null, $strictMode=false) {
$this->_regExpAcceptLangCode = '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i';
$this->_availableLangCodes = $availableLangCodes;
$this->_defaultLangCode = $defaultLangCode;
if($langCode && in_array($langCode, $availableLangCodes)) {
$this->_langCode = $langCode;
}
$this->_strictMode = $strictMode;
}
// Method to detect the language code from the HTTP_ACCEPT_LANGUAGE header:
function detectLangCode() {
// If HTTP_ACCEPT_LANGUAGE is empty use defaultLangCode:
if(empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$this->_langCode = $this->_defaultLangCode;
return;
}
// Split up the HTTP_ACCEPT_LANGUAGE header:
$acceptedLanguages = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$currentLangCode = $this->_defaultLangCode;
$currentLangQuality = 0.0;
foreach($acceptedLanguages as $acceptedLanguage) {
// Parse the language string:
$match = preg_match($this->_regExpAcceptLangCode, $acceptedLanguage, $matches);
// Check if the syntax is valid:
if(!$match) {
continue;
}
// Get and split the language code:
$langCodeParts = explode ('-', $matches[1]);
// Get the language quality given as float value:
if(isset($matches[2])) {
$langQuality = (float)$matches[2];
} else {
// Missing language quality value is maximum quality:
$langQuality = 1.0;
}
// Go through it until the language code is empty:
while(count($langCodeParts)) {
// Join the current langCodeParts:
$langCode = strtolower(join('-', $langCodeParts));
// Check if the langCode is in the available list:
if(in_array($langCode, $this->_availableLangCodes)) {
// Check the quality setting:
if ($langQuality > $currentLangQuality) {
$currentLangCode = $langCode;
$currentLangQuality = $langQuality;
break;
}
}
// If strict mode is set, don't minimalize the language code:
if($this->_strictMode) {
break;
}
// else chop off the right part:
array_pop($langCodeParts);
}
}
$this->_langCode = $currentLangCode;
}
function getLangCode() {
if(!$this->_langCode) {
$this->detectLangCode();
}
return $this->_langCode;
}
function setLangCode($langCode) {
$this->_langCode = $langCode;
}
function getLangCodes() {
return $this->_availableLangCodes;
}
}

View File

@ -0,0 +1,90 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to initialize the MySQL DataBase connection:
class AJAXChatDataBaseMySQLi {
private $_connectionID;
private $_errno = 0;
private $_error = '';
private $_dbName;
function __construct(&$dbConnectionConfig) {
$this->_connectionID = $dbConnectionConfig['link'];
$this->_dbName = $dbConnectionConfig['name'];
}
// Method to connect to the DataBase server:
function connect(&$dbConnectionConfig) {
$this->_connectionID = new mysqli(
$dbConnectionConfig['host'],
$dbConnectionConfig['user'],
$dbConnectionConfig['pass']
);
if(!$this->_connectionID) {
$this->_errno = mysqli_connect_errno();
$this->_error = mysqli_connect_error();
return false;
}
return true;
}
// Method to select the DataBase:
function select($dbName) {
if(!$this->_connectionID->select_db($dbName)) {
$this->_errno = $this->_connectionID->errno;
$this->_error = $this->_connectionID->error;
return false;
}
$this->_dbName = $dbName;
return true;
}
// Method to determine if an error has occured:
function error() {
return (bool)$this->_error;
}
// Method to return the error report:
function getError() {
if($this->error()) {
$str = 'Error-Report: ' .$this->_error."\n";
$str .= 'Error-Code: '.$this->_errno."\n";
} else {
$str = 'No errors.'."\n";
}
return $str;
}
// Method to return the connection identifier:
function &getConnectionID() {
return $this->_connectionID;
}
// Method to prevent SQL injections:
function makeSafe($value) {
return "'".$this->_connectionID->escape_string($value)."'";
}
// Method to perform SQL queries:
function sqlQuery($sql) {
return new AJAXChatMySQLiQuery($sql, $this->_connectionID);
}
// Method to retrieve the current DataBase name:
function getName() {
return $this->_dbName;
}
// Method to retrieve the last inserted ID:
function getLastInsertedID() {
return $this->_connectionID->insert_id;
}
}

View File

@ -0,0 +1,80 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to perform SQL (MySQLi) queries:
class AJAXChatMySQLiQuery {
private $_connectionID;
private $_sql = '';
private $_result = 0;
private $_errno = 0;
private $_error = '';
// Constructor:
function __construct($sql, $connectionID) {
$this->_sql = trim($sql);
$this->_connectionID = $connectionID;
$this->_result = $this->_connectionID->query($this->_sql);
if(!$this->_result) {
$this->_errno = $this->_connectionID->errno;
$this->_error = $this->_connectionID->error;
}
}
// Returns true if an error occured:
function error() {
// Returns true if the Result-ID is valid:
return !(bool)($this->_result);
}
// Returns an Error-String:
function getError() {
if($this->error()) {
$str = 'Query: ' .$this->_sql ."\n";
$str .= 'Error-Report: ' .$this->_error."\n";
$str .= 'Error-Code: '.$this->_errno;
} else {
$str = "No errors.";
}
return $str;
}
// Returns the content:
function fetch() {
if($this->error()) {
return null;
} else {
return $this->_result->fetch_assoc();
}
}
// Returns the number of rows (SELECT or SHOW):
function numRows() {
if($this->error()) {
return null;
} else {
return $this->_result->num_rows;
}
}
// Returns the number of affected rows (INSERT, UPDATE, REPLACE or DELETE):
function affectedRows() {
if($this->error()) {
return null;
} else {
return $this->_connectionID->affected_rows;
}
}
// Frees the memory:
function free() {
$this->_result->free();
}
}

36
src/AJAXChatString.php Normal file
View File

@ -0,0 +1,36 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to provide multibyte enabled string methods
class AJAXChatString {
public static function subString($str, $start=0, $length=null, $encoding='UTF-8') {
if($length === null) {
$length = AJAXChatString::stringLength($str);
}
if(function_exists('mb_substr')) {
return mb_substr($str, $start, $length, $encoding);
} else if(function_exists('iconv_substr')) {
return iconv_substr($str, $start, $length, $encoding);
} else {
return substr($str, $start, $length);
}
}
public static function stringLength($str, $encoding='UTF-8') {
if(function_exists('mb_strlen')) {
return mb_strlen($str, $encoding);
} else if(function_exists('iconv_strlen')) {
return iconv_strlen($str, $encoding);
} else {
return strlen($str);
}
}
}

358
src/AJAXChatTemplate.php Normal file
View File

@ -0,0 +1,358 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to handle HTML templates
class AJAXChatTemplate {
private $ajaxChat;
private $_regExpTemplateTags;
private $_templateFile;
private $_contentType;
private $_content;
private $_parsedContent;
// Constructor:
function __construct(&$ajaxChat, $templateFile, $contentType=null) {
$this->ajaxChat = $ajaxChat;
$this->_regExpTemplateTags = '/\[(\w+?)(?:(?:\/)|(?:\](.+?)\[\/\1))\]/s';
$this->_templateFile = $templateFile;
$this->_contentType = $contentType;
}
function getParsedContent() {
if(!$this->_parsedContent) {
$this->parseContent();
}
return $this->_parsedContent;
}
function getContent() {
if(!$this->_content) {
$this->_content = AJAXChatFileSystem::getFileContents($this->_templateFile);
}
return $this->_content;
}
function parseContent() {
$this->_parsedContent = $this->getContent();
// Remove the XML declaration if the content-type is not xml:
if($this->_contentType && (strpos($this->_contentType,'xml') === false)) {
$doctypeStart = strpos($this->_parsedContent, '<!DOCTYPE ');
if($doctypeStart !== false) {
// Removing the XML declaration (in front of the document type) prevents IE<7 to go into "Quirks mode":
$this->_parsedContent = substr($this->_parsedContent, $doctypeStart);
}
}
// Replace template tags ([TAG/] and [TAG]content[/TAG]) and return parsed template content:
$this->_parsedContent = preg_replace_callback($this->_regExpTemplateTags, array($this, 'replaceTemplateTags'), $this->_parsedContent);
}
function replaceTemplateTags($tagData) {
switch($tagData[1]) {
case 'AJAX_CHAT_URL':
return $this->ajaxChat->htmlEncode($this->ajaxChat->getChatURL());
case 'LANG':
return $this->ajaxChat->htmlEncode($this->ajaxChat->getLang($tagData[2]));
case 'LANG_CODE':
return $this->ajaxChat->getLangCode();
case 'BASE_DIRECTION':
return $this->getBaseDirectionAttribute();
case 'CONTENT_ENCODING':
return $this->ajaxChat->getConfig('contentEncoding');
case 'CONTENT_TYPE':
return $this->_contentType;
case 'LOGIN_URL':
return ($this->ajaxChat->getRequestVar('view') == 'logs') ? './?view=logs' : './';
case 'USER_NAME_MAX_LENGTH':
return $this->ajaxChat->getConfig('userNameMaxLength');
case 'MESSAGE_TEXT_MAX_LENGTH':
return $this->ajaxChat->getConfig('messageTextMaxLength');
case 'LOGIN_CHANNEL_ID':
return $this->ajaxChat->getValidRequestChannelID();
case 'SESSION_NAME':
return $this->ajaxChat->getConfig('sessionName');
case 'COOKIE_EXPIRATION':
return $this->ajaxChat->getConfig('sessionCookieLifeTime');
case 'COOKIE_PATH':
return $this->ajaxChat->getConfig('sessionCookiePath');
case 'COOKIE_DOMAIN':
return $this->ajaxChat->getConfig('sessionCookieDomain');
case 'COOKIE_SECURE':
return $this->ajaxChat->getConfig('sessionCookieSecure');
case 'CHAT_BOT_NAME':
return rawurlencode($this->ajaxChat->getConfig('chatBotName'));
case 'CHAT_BOT_ID':
return $this->ajaxChat->getConfig('chatBotID');
case 'ALLOW_USER_MESSAGE_DELETE':
if($this->ajaxChat->getConfig('allowUserMessageDelete'))
return 1;
else
return 0;
case 'INACTIVE_TIMEOUT':
return $this->ajaxChat->getConfig('inactiveTimeout');
case 'PRIVATE_CHANNEL_DIFF':
return $this->ajaxChat->getConfig('privateChannelDiff');
case 'PRIVATE_MESSAGE_DIFF':
return $this->ajaxChat->getConfig('privateMessageDiff');
case 'SHOW_CHANNEL_MESSAGES':
if($this->ajaxChat->getConfig('showChannelMessages'))
return 1;
else
return 0;
case 'SOCKET_SERVER_ENABLED':
if($this->ajaxChat->getConfig('socketServerEnabled'))
return 1;
else
return 0;
case 'SOCKET_SERVER_HOST':
if($this->ajaxChat->getConfig('socketServerHost')) {
$socketServerHost = $this->ajaxChat->getConfig('socketServerHost');
} else {
$socketServerHost = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);
}
return rawurlencode($socketServerHost);
case 'SOCKET_SERVER_PORT':
return $this->ajaxChat->getConfig('socketServerPort');
case 'SOCKET_SERVER_CHAT_ID':
return $this->ajaxChat->getConfig('socketServerChatID');
case 'STYLE_SHEETS':
return $this->getStyleSheetLinkTags();
case 'CHANNEL_OPTIONS':
return $this->getChannelOptionTags();
case 'STYLE_OPTIONS':
return $this->getStyleOptionTags();
case 'LANGUAGE_OPTIONS':
return $this->getLanguageOptionTags();
case 'ERROR_MESSAGES':
return $this->getErrorMessageTags();
case 'LOGS_CHANNEL_OPTIONS':
return $this->getLogsChannelOptionTags();
case 'LOGS_YEAR_OPTIONS':
return $this->getLogsYearOptionTags();
case 'LOGS_MONTH_OPTIONS':
return $this->getLogsMonthOptionTags();
case 'LOGS_DAY_OPTIONS':
return $this->getLogsDayOptionTags();
case 'LOGS_HOUR_OPTIONS':
return $this->getLogsHourOptionTags();
case 'MENU_BAR':
return <<<EOF
<ul>
<li class="first notcurrent"><a href="https://flashii.net/">Home</a></li>
<li class="notcurrent"><a href="https://flashii.net/news.php">News</a></li>
<li class="current"><a href="./">Chat</a></li>
<li class="notcurrent"><a href="https://flashii.net/members.php">Members</a></li>
<li class="notcurrent"><a href="https://flashii.net/donate.php">Donate</a></li>
<li class="notcurrent"><a href="https://status.flashii.net">Status</a></li>
</ul>
EOF;
case 'COPYRIGHT':
return <<<EOF
<div class="copyright">
Copyright &copy; 2013-2015 <a href="https://flash.moe/" target="_blank">Flashwave</a>
<br /><a href="https://blueimp.net/ajax/" target="_blank">AJAX Chat</a> &copy; <a href="https://blueimp.net" target="_blank">blueimp.net</a>
<br />
<a href="https://flashii.net/forum">Feedback</a> |
<a href="https://flashii.net/changelog.php">Changelog</a> |
<a href="https://flashii.net/info.php/rules">Rules &amp; Info</a> |
<a href="https://flashii.net/info.php/terms">Terms of Service</a> |
<a href="https://flashii.net/info.php/contact">Contact</a> |
<a href="https://test.flashii.net">DevSite</a> |
<a href="?view=legacy">Legacy Login</a>
</div><br />
EOF;
case 'SANDSTORM':
if(date('md') === '0127' || !empty($_GET['sandstorm']))
return <<<HTML
<br />
<audio loop="loop" autoplay="autoplay" controls="controls">
<source type="audio/ogg" src="./sandstorm.ogg" />
<source type="audio/mpeg" src="./sandstorm.mp3" />
</audio>
<br />
HTML;
else
return '';
default:
return $this->ajaxChat->replaceCustomTemplateTags($tagData[1], (isset($tagData[2]) ? $tagData[2] : null));
}
}
// Function to display alternating table row colors:
function alternateRow($rowOdd='rowOdd', $rowEven='rowEven') {
static $i;
$i += 1;
if($i % 2 == 0) {
return $rowEven;
} else {
return $rowOdd;
}
}
function getBaseDirectionAttribute() {
$langCodeParts = explode('-', $this->ajaxChat->getLangCode());
switch($langCodeParts[0]) {
case 'ar':
case 'fa':
case 'he':
return 'rtl';
default:
return 'ltr';
}
}
function getStyleSheetLinkTags() {
$styleSheets = '';
foreach($this->ajaxChat->getConfig('styleAvailable') as $style) {
$alternate = ($style == $this->ajaxChat->getConfig('styleDefault')) ? '' : 'alternate ';
$styleSheets .= '<link rel="'.$alternate.'stylesheet" type="text/css" href="css/'.rawurlencode($style).'.ajaxchat.css" title="'.$this->ajaxChat->htmlEncode($style).'"/>';
}
return $styleSheets;
}
function getChannelOptionTags() {
$channelOptions = '';
$channelSelected = false;
foreach($this->ajaxChat->getChannels() as $key=>$value) {
if($this->ajaxChat->isLoggedIn()) {
$selected = ($value == $this->ajaxChat->getChannel()) ? ' selected="selected"' : '';
} else {
$selected = ($value == $this->ajaxChat->getConfig('defaultChannelID')) ? ' selected="selected"' : '';
}
if($selected) {
$channelSelected = true;
}
$channelOptions .= '<option value="'.$this->ajaxChat->htmlEncode($key).'"'.$selected.'>'.$this->ajaxChat->htmlEncode($key).'</option>';
}
if($this->ajaxChat->isLoggedIn() && $this->ajaxChat->isAllowedToCreatePrivateChannel()) {
// Add the private channel of the user to the options list:
if(!$channelSelected && $this->ajaxChat->getPrivateChannelID() == $this->ajaxChat->getChannel()) {
$selected = ' selected="selected"';
$channelSelected = true;
} else {
$selected = '';
}
$privateChannelName = $this->ajaxChat->getPrivateChannelName();
$channelOptions .= '<option value="'.$this->ajaxChat->htmlEncode($privateChannelName).'"'.$selected.'>'.$this->ajaxChat->htmlEncode($privateChannelName).'</option>';
}
// If current channel is not in the list, try to retrieve the channelName:
if(!$channelSelected) {
$channelName = $this->ajaxChat->getChannelName();
if($channelName !== null) {
$channelOptions .= '<option value="'.$this->ajaxChat->htmlEncode($channelName).'" selected="selected">'.$this->ajaxChat->htmlEncode($channelName).'</option>';
} else {
// Show an empty selection:
$channelOptions .= '<option value="" selected="selected">---</option>';
}
}
return $channelOptions;
}
function getStyleOptionTags() {
$styleOptions = '';
foreach($this->ajaxChat->getConfig('styleAvailable') as $style) {
$selected = ($style == $this->ajaxChat->getConfig('styleDefault')) ? ' selected="selected"' : '';
$styleOptions .= '<option value="'.$this->ajaxChat->htmlEncode($style).'"'.$selected.'>'.$this->ajaxChat->htmlEncode($style).'</option>';
}
return $styleOptions;
}
function getLanguageOptionTags() {
$languageOptions = '';
$languageNames = $this->ajaxChat->getConfig('langNames');
foreach($this->ajaxChat->getConfig('langAvailable') as $langCode) {
$selected = ($langCode == $this->ajaxChat->getLangCode()) ? ' selected="selected"' : '';
$languageOptions .= '<option value="'.$this->ajaxChat->htmlEncode($langCode).'"'.$selected.'>'.$languageNames[$langCode].'</option>';
}
return $languageOptions;
}
function getErrorMessageTags() {
$errorMessages = '';
foreach($this->ajaxChat->getInfoMessages('error') as $error) {
$errorMessages .= '<h3 class="miotitle">'.$this->ajaxChat->htmlEncode($this->ajaxChat->getLang($error)).'</h3>';
}
return $errorMessages;
}
function getLogsChannelOptionTags() {
$channelOptions = '';
$channelOptions .= '<option value="-3">------</option>';
foreach($this->ajaxChat->getChannels() as $key=>$value) {
if($this->ajaxChat->getUserRole() != AJAX_CHAT_ADMIN && $this->ajaxChat->getConfig('logsUserAccessChannelList') && !in_array($value, $this->ajaxChat->getConfig('logsUserAccessChannelList'))) {
continue;
}
$channelOptions .= '<option value="'.$value.'">'.$this->ajaxChat->htmlEncode($key).'</option>';
}
$channelOptions .= '<option value="-1">'.$this->ajaxChat->htmlEncode($this->ajaxChat->getLang('logsPrivateChannels')).'</option>';
$channelOptions .= '<option value="-2">'.$this->ajaxChat->htmlEncode($this->ajaxChat->getLang('logsPrivateMessages')).'</option>';
return $channelOptions;
}
function getLogsYearOptionTags() {
$yearOptions = '';
$yearOptions .= '<option value="-1">----</option>';
for($year=date('Y'); $year>=$this->ajaxChat->getConfig('logsFirstYear'); $year--) {
$yearOptions .= '<option value="'.$year.'">'.$year.'</option>';
}
return $yearOptions;
}
function getLogsMonthOptionTags() {
$monthOptions = '';
$monthOptions .= '<option value="-1">--</option>';
for($month=1; $month<=12; $month++) {
$monthOptions .= '<option value="'.$month.'">'.sprintf("%02d", $month).'</option>';
}
return $monthOptions;
}
function getLogsDayOptionTags() {
$dayOptions = '';
$dayOptions .= '<option value="-1">--</option>';
for($day=1; $day<=31; $day++) {
$dayOptions .= '<option value="'.$day.'">'.sprintf("%02d", $day).'</option>';
}
return $dayOptions;
}
function getLogsHourOptionTags() {
$hourOptions = '';
$hourOptions .= '<option value="-1">-----</option>';
for($hour=0; $hour<=23; $hour++) {
$hourOptions .= '<option value="'.$hour.'">'.sprintf("%02d", $hour).':00</option>';
}
return $hourOptions;
}
}

View File

@ -9,17 +9,17 @@
class CustomAJAXChat extends AJAXChat {
// Returns an associative array containing userName, userID and userRole
// Returns null if login is invalid
function getValidLoginUserData() {
if($this->getRequestVar('password')) {
// Check if we have a valid registered user:
// Returns an associative array containing userName, userID and userRole
// Returns null if login is invalid
function getValidLoginUserData() {
if($this->getRequestVar('password')) {
// Check if we have a valid registered user:
$userName = $this->getRequestVar('userName');
$userName = $this->convertEncoding($userName, $this->getConfig('contentEncoding'), $this->getConfig('sourceEncoding'));
$userName = $this->getRequestVar('userName');
$userName = $this->convertEncoding($userName, $this->getConfig('contentEncoding'), $this->getConfig('sourceEncoding'));
$password = $this->getRequestVar('password');
$password = $this->convertEncoding($password, $this->getConfig('contentEncoding'), $this->getConfig('sourceEncoding'));
$password = $this->getRequestVar('password');
$password = $this->convertEncoding($password, $this->getConfig('contentEncoding'), $this->getConfig('sourceEncoding'));
$flashiiConfig = parse_ini_file('/www/flashii.net/config/config.ini', true, INI_SCANNER_TYPED);
@ -78,136 +78,136 @@ class CustomAJAXChat extends AJAXChat {
}
}
return null;
} else {
// Guest users:
return $this->getGuestUser();
}
}
return null;
} else {
// Guest users:
return $this->getGuestUser();
}
}
// Store the channels the current user has access to
// Make sure channel names don't contain any whitespace
function &getChannels() {
if($this->_channels === null) {
$this->_channels = array();
/*$customUsers = $this->getCustomUsers();
// Get the channels, the user has access to:
if($this->getUserRole() == AJAX_CHAT_GUEST) {
$validChannels = $customUsers[0]['channels'];
} else {
$validChannels = $customUsers[$this->getUserID()]['channels'];
}*/
// Add the valid channels to the channel list (the defaultChannelID is always valid):
foreach($this->getAllChannels() as $key=>$value) {
// Check if we have to limit the available channels:
if($this->getConfig('limitChannelList') && !in_array($value, $this->getConfig('limitChannelList'))) {
continue;
}
//if(in_array($value, $validChannels) || $value == $this->getConfig('defaultChannelID')) {
$this->_channels[$key] = $value;
//}
}
}
return $this->_channels;
}
// Store the channels the current user has access to
// Make sure channel names don't contain any whitespace
function &getChannels() {
if($this->_channels === null) {
$this->_channels = array();
// Store all existing channels
// Make sure channel names don't contain any whitespace
function &getAllChannels() {
if($this->_allChannels === null) {
// Get all existing channels:
$customChannels = $this->getCustomChannels();
$defaultChannelFound = false;
foreach($customChannels as $key=>$value) {
$forumName = $this->trimChannelName($value);
$this->_allChannels[$forumName] = $key;
if($key == $this->getConfig('defaultChannelID')) {
$defaultChannelFound = true;
}
}
if(!$defaultChannelFound) {
// Add the default channel as first array element to the channel list:
$this->_allChannels = array_merge(
array(
$this->trimChannelName($this->getConfig('defaultChannelName'))=>$this->getConfig('defaultChannelID')
),
$this->_allChannels
);
}
}
return $this->_allChannels;
}
/*$customUsers = $this->getCustomUsers();
/*function &getCustomUsers() {
global $database;
// Get the channels, the user has access to:
if($this->getUserRole() == AJAX_CHAT_GUEST) {
$validChannels = $customUsers[0]['channels'];
} else {
$validChannels = $customUsers[$this->getUserID()]['channels'];
}*/
$userlist = $database->query("SELECT * FROM `accounts`.`flashii_users` WHERE `userrole` != '0'")->fetch_all(MYSQLI_ASSOC);
// Add the valid channels to the channel list (the defaultChannelID is always valid):
foreach($this->getAllChannels() as $key=>$value) {
// Check if we have to limit the available channels:
if($this->getConfig('limitChannelList') && !in_array($value, $this->getConfig('limitChannelList'))) {
continue;
}
//if(in_array($value, $validChannels) || $value == $this->getConfig('defaultChannelID')) {
$this->_channels[$key] = $value;
//}
}
}
return $this->_channels;
}
// Store all existing channels
// Make sure channel names don't contain any whitespace
function &getAllChannels() {
if($this->_allChannels === null) {
// Get all existing channels:
$customChannels = $this->getCustomChannels();
$defaultChannelFound = false;
foreach($customChannels as $key=>$value) {
$forumName = $this->trimChannelName($value);
$this->_allChannels[$forumName] = $key;
if($key == $this->getConfig('defaultChannelID')) {
$defaultChannelFound = true;
}
}
if(!$defaultChannelFound) {
// Add the default channel as first array element to the channel list:
$this->_allChannels = array_merge(
array(
$this->trimChannelName($this->getConfig('defaultChannelName'))=>$this->getConfig('defaultChannelID')
),
$this->_allChannels
);
}
}
return $this->_allChannels;
}
/*function &getCustomUsers() {
global $database;
$userlist = $database->query("SELECT * FROM `accounts`.`flashii_users` WHERE `userrole` != '0'")->fetch_all(MYSQLI_ASSOC);
$users = array();
$users[0] = array();
$users[0]['userRole'] = AJAX_CHAT_GUEST;
$users[0]['userName'] = null;
$users[0]['password'] = null;
$users[0]['channels'] = array(0,1);
$users = array();
$users[0] = array();
$users[0]['userRole'] = AJAX_CHAT_GUEST;
$users[0]['userName'] = null;
$users[0]['password'] = null;
$users[0]['channels'] = array(0,1);
foreach($userlist as $user) {
$users[$user['id']] = array();
$users[$user['id']]['userName'] = $user['username'];
$users[$user['id']]['password'] = $user['password'];
switch($user['userrole']) {
// Tenshi
case 7:
$users[$user['id']]['userRole'] = DONATOR;
$users[$user['id']]['channels'] = array(0, 1);
break;
// Chat Moderators
case 6:
$users[$user['id']]['userRole'] = CMOD;
$users[$user['id']]['channels'] = array(0, 1, 2);
break;
// Bots
case 5:
$users[$user['id']]['userRole'] = BOTS;
$users[$user['id']]['channels'] = array(0, 1, 2);
break;
// Developers
case 4:
$users[$user['id']]['userRole'] = PURPLE;
$users[$user['id']]['channels'] = array(0, 1, 2);
break;
// Administrator
case 3:
$users[$user['id']]['userRole'] = AJAX_CHAT_ADMIN;
$users[$user['id']]['channels'] = array(0, 1, 2);
break;
// Site Moderators
case 2:
$users[$user['id']]['userRole'] = AJAX_CHAT_MODERATOR;
$users[$user['id']]['channels'] = array(0, 1, 2);
break;
// Regular Users
case 1:
$users[$user['id']]['userRole'] = AJAX_CHAT_USER;
$users[$user['id']]['channels'] = array(0, 1);
break;
// Unknown and Deactivated Users
case 0:
default:
@ -215,16 +215,16 @@ class CustomAJAXChat extends AJAXChat {
$users[$user['id']]['channels'] = array(0);
}
}
return $users;
}*/
function &getCustomChannels() {
$channels = [
return $users;
}*/
function &getCustomChannels() {
$channels = [
0 => 'Public',
];
/*$result = $this->db->sqlQuery("SELECT * FROM ajax_chat_channels")->_result->fetch_all(MYSQLI_ASSOC);
/*$result = $this->db->sqlQuery("SELECT * FROM ajax_chat_channels")->_result->fetch_all(MYSQLI_ASSOC);
foreach($result as $channel) {
$channels[$channel['id']] = $channel['name'];
}*/
@ -232,29 +232,29 @@ class CustomAJAXChat extends AJAXChat {
if($this->isLoggedIn())
$channels[9001] = 'Secret';
return $channels;
}
function parseCustomCommands($text, $textParts) {
switch($textParts[0]) {
case '/afk':
$this->setUserName('<AFK>_' . $this->getUserName());
$this->updateOnlineList();
$this->addInfoMessage($this->getUserName(), 'userName');
$this->setSessionVar('AwayFromKeyboard', true);
return true;
default:
return false;
}
}
return $channels;
}
function onNewMessage($text) {
if($this->getSessionVar('AwayFromKeyboard')) {
$this->setUserName(substr($this->getUserName(), 6));
$this->updateOnlineList();
$this->addInfoMessage($this->getUserName(), 'userName');
$this->setSessionVar('AwayFromKeyboard', false);
}
return true;
}
function parseCustomCommands($text, $textParts) {
switch($textParts[0]) {
case '/afk':
$this->setUserName('<AFK>_' . $this->getUserName());
$this->updateOnlineList();
$this->addInfoMessage($this->getUserName(), 'userName');
$this->setSessionVar('AwayFromKeyboard', true);
return true;
default:
return false;
}
}
function onNewMessage($text) {
if($this->getSessionVar('AwayFromKeyboard')) {
$this->setUserName(substr($this->getUserName(), 6));
$this->updateOnlineList();
$this->addInfoMessage($this->getUserName(), 'userName');
$this->setSessionVar('AwayFromKeyboard', false);
}
return true;
}
}

View File

@ -9,13 +9,12 @@
class CustomAJAXChatInterface extends CustomAJAXChat {
function initialize() {
// Initialize configuration settings:
$this->initConfig();
function initialize() {
// Initialize configuration settings:
$this->initConfig();
// Initialize the DataBase connection:
$this->initDataBaseConnection();
}
// Initialize the DataBase connection:
$this->initDataBaseConnection();
}
}
?>

View File

@ -0,0 +1,24 @@
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
class CustomAJAXChatShoutBox extends CustomAJAXChat {
function initialize() {
// Initialize configuration settings:
$this->initConfig();
}
function getShoutBoxContent() {
$template = new AJAXChatTemplate($this, AJAX_CHAT_PATH . '/template/shoutbox.html');
// Return parsed template content:
return $template->getParsedContent();
}
}

239
src/satori.php Normal file
View File

@ -0,0 +1,239 @@
<?php
// Configuration
$satoriSetting = array();
$satoriSetting['enabled'] = true;
$satoriSetting['userID'] = 9;
$satoriSetting['userName'] = 'Satori';
$satoriSetting['userRank'] = BOTS;
$satoriSetting['userIP'] = '127.0.0.1';
// Parsing
$satoriParse = strtolower($text);
$satoriParse = preg_replace('/\\[(?:\\/)?(\\w+)(?:=([^<>]*?))?\\]/ms', '', $satoriParse);
$textParts = explode(' ', $satoriParse);
// Random Stuff
$defaultResponseArray = ['What do you want?', 'Kindly fuck off.', 'Don\'t know how to "%s" something.', 'Come again?', 'Satori returned an empty result set (i.e. zero rows).'];
$defaultResponse = sprintf($defaultResponseArray[array_rand($defaultResponseArray)], $textParts[0]);
// Actions
if(preg_match('/^k$/im', $satoriParse)) {
$satoriResp = ['Thank you for your amazing and insightful message. It is truly an honour to have this message in my database. I can\'t thank you more than to say go fuck yourself. You truly touched me... Thank you.'];
}
if(preg_match('/^time to break the chat$/im', $satoriParse)) {
$satoriResp = ['Stay away from me!'];
}
if(preg_match('/^all aboard the sailboat$/im', $satoriParse)) {
$satoriResp = ['Why would we get on something that is about to sink :^)'];
}
// Reactions
if(preg_match('/^satori/im', $textParts[0])) {
switch($satoriInput = preg_replace('/^satori? ?/', '', $satoriParse)) {
case 'version':
$satoriResp = ['[b][color=Red]S[/color][color=Ruby]a[/color][color=Citrine]t[/color][color=Green]o[/color][color=Teal]r[/color][color=Cobalt]i[/color][/b] Version not [b]6[/b]'];
break;
case 'what are you':
$satoriResp = ['I am nice girl for nice chat.', '[img]http://i.imgur.com/NcFitL2.jpg[/img]'];
break;
case 'hi':
$satoriResp = ['sup'];
break;
case 'help':
$satoriResp = ['If you need help with things refer to the [url=http://flashii.net/r/faq]FAQ[/url].', 'If this didn\'t help you don\'t hesitate to ask an active user.'];
break;
case 'why do you exist':
$satoriResp = ['So you have someone to hate. <3'];
break;
case 'suck my dick':
$satoriResp = ['Do you even have one? Can\'t see it.'];
break;
case 'make me admin':
$satoriResp = ['Why the fuck would you WANT admin? It\'s nothing more than extra work for an ugly red username! Look now the colour for deactivated user, that one\'s fucking hot.'];
break;
case 'anime':
$satoriResp = ['Oh god, i wish i could leave this chat but i\'m stuck in here ;__;'];
break;
case 'e':
$satoriResp = ['Do I look like Nasbot or something?'];
break;
case 'meow':
$satoriResp = ['Mewow!'];
break;
case 'puush':
$satoriResp = ['Something you should be using.'];
break;
case 'what is flash\'s password':
case 'what is flashwave\'s password':
case 'what is moka\'s password':
$satoriResp = ['/suicide', 'I do recommend sending it in chat right now.'];
break;
case 'what do you think about snailmush':
case 'what do you like snailmush':
case 'snailmush':
$satoriResp = ['I-it\'s not like I like him or-or any-anything...... ;_;'];
break;
case 'x snailmush':
case 'loves snailmush':
case 'do you love snailmush':
case 'do you love snailmush?':
$satoriResp = ['NO!', '[s]Trigger Kick'];
break;
case 'saibateku':
$satoriResp = ['That place is still up?'];
break;
case 'titanic':
$satoriResp = ['Did you mean Sailboat?'];
break;
case 'did sailboat sink yet':
$satoriResp = ['No but I wish it would. Fuck that place. Seems to be getting pretty close however...'];
break;
case 'malwareup':
$satoriResp = ['Good malware discussion forum.'];
break;
case 'flashii':
$satoriResp = ['Mediocre shithole. 0/10'];
break;
case 'cybernetics':
$satoriResp = ['Did you mean "Saibateku"?'];
break;
case 'nathat':
$satoriResp = ['shut up'];
break;
case 'waifu':
case 'inori aizawa':
case 'internet explorer tan':
$satoriResp = ['Inori Aizawa Is Mai Waifu.', 'Welcome To Mai Web Browser Is Mai Waifu Land!'];
break;
case 'webkit':
case 'safari':
case 'blink':
case 'chrome':
$satoriResp = [':puke::puke::puke:'];
break;
case 'gecko':
case 'trident':
case 'internet explorer':
case 'iexplore':
case 'firefox':
case 'mozilla firefox':
$satoriResp = [':love::love::love:'];
break;
case 'bribob':
case 'bribob4':
$satoriResp = ['Mediocre faggot. 0/10'];
break;
case 'kelopez':
case 'brante':
$satoriResp = ['http://en.wikipedia.org/wiki/Mexican'];
break;
case 'kamil':
case 'rakowski':
case 'kamilrakowski':
$satoriResp = ['http://en.wikipedia.org/wiki/Jews'];
break;
case 'secret':
$satoriResp = ['I\'m not a secret ripoff, what are you talking about?', '[i]My code is better, time to kill yourself![/i]'];
break;
case 'koishi':
$satoriResp = ['Don\'t fuck with Koishi.'];
break;
case ':^)':
$satoriResp = ['8^)'];
break;
case 'nookls':
$satoriResp = ['HOOOOLLLLLYYYYYYYYYYYYY CRAP NOOKLS IS SO AMAZING WOWOWOWOWOWOW HE\'S ACTUALLY ON THIS SITE WORSHIP WORSHIP AMAZING BRILLIANT I LOVE YOU NOOKLS WE ALL LOVE YOU WE LOVE YOU AS MUCH AS FANGIRLS LOVE JUSTIN BIEBER AAAAAAAAHHHHHHHHHHHH THIS IS THE BEST MOMENT!'];
break;
case 'zeniea':
$satoriResp = ['For whatever reason I have the urge to say "This place smells like a catholic church on crack"...'];
break;
case 'zquest':
$satoriResp = ['Good comic 10/10'];
break;
case 'fuck me':
$satoriResp = [':wtf:'];
break;
case 'satori':
$satoriResp = ['Wait, what are you trying to do?'];
break;
case 'satori satori':
$satoriResp = ['Don\'t fucking do this to me...'];
break;
case 'satori satori satori':
$satoriResp = ['[b][i]I\'ll fucking murder you![/i][/b]'];
break;
case 'satori satori satori satori':
$satoriResp = ['no don\'t'];
break;
case 'satori satori satori satori satori':
$satoriResp = ['please don\'t do this to me'];
break;
case 'satori satori satori satori satori satori':
$satoriResp = ['i have a waifu and kids'];
break;
case 'satori satori satori satori satori satori satori':
$satoriResp = ['okay i was kidding about the kids part'];
break;
case 'satori satori satori satori satori satori satori satori':
$satoriResp = ['rip life'];
break;
case 'you are annoying':
case 'please die':
case 'die':
$satoriResp = ['Well I\'m God and you can\'t do shit.'];
break;
case 'misaka-20001':
$satoriResp = ['We\'ll have to move one of these days...', 'The good ol\' Pentium 4 doesn\'t seem to be able to handle shit anymore...'];
break;
case 'how old are you':
case 'how old is flashii':
case 'how old is koishi':
$satoriResp = [date_diff(date_create('2013-01-27 22:14:44 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
break;
case 'how old is zeniea':
case 'how old is secret':
$satoriResp = [date_diff(date_create('2011-07-07 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
break;
case 'how old is zquest':
$satoriResp = [date_diff(date_create('2013-11-16 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')];
break;
case 'are you broken':
case 'are you broken?':
case 'is flashii broken':
case 'is flashii broken?':
$satoriResp = ['yes'];
break;
default:
$satoriResp = [$defaultResponse];
break;
}
}
// Check if disabled
if(!$satoriSetting['enabled'])
$satoriResp = null;
// Bring the process of sending a message down to one if
if(isset($satoriResp)) {
foreach($satoriResp as $directives => $response) {
if($response == '[s]Trigger Kick') {
$this->logout('Kicked');
} else {
$this->insertCustomMessage(
$satoriSetting['userID'],
$satoriSetting['userName'],
$satoriSetting['userRank'],
$this->getChannel(),
vsprintf($response, $directives),
$satoriSetting['userIP'],
0
);
}
}
}