From 1536f3048de73142669cad188322767dc9b3e915 Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 23 Sep 2022 00:36:51 +0000 Subject: [PATCH] Integrated AJAX Chat with the Futami common file settings, for some reason. --- public/css/meta.legacy.ajaxchat.css | 3 + public/css/meta.modern.ajaxchat.css | 3 + public/css/textcolours.ajaxchat.css | 163 +--------------- public/index.php | 144 ++++++++++++++ public/js/chat.js | 6 +- public/js/config.js | 292 ---------------------------- template/banned.html | 2 +- template/legacyLogin.html | 2 +- template/loggedIn.html | 2 +- template/loggedOut.html | 2 +- template/loggedOutFA.html | 2 +- template/loggedOut~.html | 2 +- template/logs.html | 2 +- template/mobile.html | 2 +- template/shoutbox.html | 2 +- template/~loggedOut.html | 2 +- 16 files changed, 165 insertions(+), 466 deletions(-) delete mode 100644 public/js/config.js diff --git a/public/css/meta.legacy.ajaxchat.css b/public/css/meta.legacy.ajaxchat.css index ff6b435..114679e 100644 --- a/public/css/meta.legacy.ajaxchat.css +++ b/public/css/meta.legacy.ajaxchat.css @@ -234,6 +234,9 @@ left:20px; bottom:57px; padding:3px; + max-height: 30px; + max-width: 600px; + overflow: auto; } #content #optionsContainer { position:absolute; diff --git a/public/css/meta.modern.ajaxchat.css b/public/css/meta.modern.ajaxchat.css index 55131f2..485a3f3 100644 --- a/public/css/meta.modern.ajaxchat.css +++ b/public/css/meta.modern.ajaxchat.css @@ -126,6 +126,9 @@ left:20px; bottom:57px; padding:3px; + max-height: 30px; + max-width: 600px; + overflow: auto; } #content #optionsContainer { position:absolute; diff --git a/public/css/textcolours.ajaxchat.css b/public/css/textcolours.ajaxchat.css index 4c3bb3b..ed36ed4 100644 --- a/public/css/textcolours.ajaxchat.css +++ b/public/css/textcolours.ajaxchat.css @@ -1,166 +1,5 @@ -/* Color Container */ -a.Silver { - background-color: #C0C0C0; -} -a.Citrine { - background-color: #F2D839; -} -a.Orange { - background-color: #FFA500; -} -a.Pumpkin { - background-color: #FF7518; -} -a.Red { - background-color: #F50000; -} -a.Crimson { - background-color: #C00000; -} -a.Ruby { - background-color: #E0115F; -} -a.Amaranth { - background-color: #E52B50; -} -a.Thulite { - background-color: #DE6FA1; -} -a.Pink { - background-color: #FF6FF2; -} -a.Purpureus { - background-color: #9A4EAE; -} -a.Antisia { - background-color: #915C83; -} -a.Cerulean { - background-color: #007BA7; -} -a.Cobalt { - background-color: #0047AB; -} -a.Aqua { - background-color: #20E4FF; -} -a.Mint { - background-color: #39F2B1; -} -a.Keppel { - background-color: #3AB09E; -} -a.Teal { - background-color: #008585; -} -a.Green { - background-color: #008500; -} -a.Chartreuse { - background-color: #7FFF00; -} -a.Nitrate { - background-color: #95CC00; -} -a.Lilive { - background-color: #C0C000; -} -a.Daive { - background-color: #858500; -} -a.Zaffre { - background-color: #0014A8; -} -a.Amethyst { - background-color: #9966CC; -} +@import url('/?common=colours'); -/* Text Color */ -#content .Silver { - color: #C0C0C0; -} -#content .Citrine { - color: #F2D839; -} -#content .Orange { - color: #FFA500; -} -#content .Pumpkin { - color: #FF7518; -} -#content .Red { - color: #F50000; -} -#content .Crimson { - color: #C00000; -} -#content .Ruby { - color: #E0115F; -} -#content .Amaranth { - color: #E52B50; -} -#content .Irresistible { - color: #B3446C; -} -#content .Thulite { - color: #DE6FA1; -} -#content .Pink { - color: #FF6FF2; -} -#content .Purpureus { - color: #9A4EAE; -} -#content .Antisia { - color: #915C83; -} -#content .Cerulean { - color: #007BA7; -} -#content .Cobalt { - color: #0047AB; -} -#content .Aqua { - color: #20E4FF; -} -#content .Turquoise { - color: #40E0D0; -} -#content .Mint { - color: #39F2B1; -} -#content .Keppel { - color: #3AB09E; -} -#content .Teal { - color: #008585; -} -#content .Green { - color: #008500; -} -#content .Lime { - color: #BFFF00; -} -#content .Chartreuse { - color: #7FFF00; -} -#content .Nitrate { - color: #95CC00; -} -#content .Lilive { - color: #C0C000; -} -#content .Daive { - color: #858500; -} -#content .Zaffre { - color: #0014A8; -} -#content .Amethyst { - color: #9966CC; -} - /* Username colors */ #content .guest { color: gray; diff --git a/public/index.php b/public/index.php index 20d9879..e17734b 100644 --- a/public/index.php +++ b/public/index.php @@ -7,6 +7,150 @@ * @link https://blueimp.net/ajax/ */ +if(!empty($_GET['common'])) { + $domain = (strpos($_SERVER['HTTP_HOST'], 'flashii.net') ? 'flashii' : 'edgii'); + $commonUrl = 'https://futami.' . $domain . '.net/common.json'; + $common = json_decode(file_get_contents($commonUrl)); + + if($_GET['common'] === 'config') { + function array_to_jsobj(array $array): string { + $isList = array_is_list($array); + $parts = []; + + foreach($array as $key => $value) { + $entry = $isList ? '' : ($key . ': '); + $type = gettype($value); + if($type === 'NULL') + $entry .= 'null'; + elseif($type === 'array') { + $entry .= array_to_jsobj($value); + } elseif($type === 'boolean') + $entry .= $value ? 'true' : 'false'; + elseif($type === 'integer') + $entry .= $value; + elseif($type === 'double') + $entry .= $value; + elseif($type === 'string') + $entry .= '\'' . addslashes($value) . '\''; + + $parts[] = $entry; + } + + return ($isList ? 'new Array(' : '{') + . implode(', ', $parts) + . ($isList ? ')' : '}'); + } + + $config = [ + 'loginChannelID' => null, + 'loginChannelName' => null, + 'timerRate' => 2000, + 'ajaxURL' => './?ajax=true', + 'baseURL' => './', + 'regExpMediaUrl' => '^((http)|(https)):\\/\\/', + 'startChatOnLoad' => true, + 'domIDs' => [ + 'chatList' => 'chatList', + 'onlineList' => 'onlineList', + 'inputField' => 'inputField', + 'messageLengthCounter' => 'messageLengthCounter', + 'channelSelection' => 'channelSelection', + 'styleSelection' => 'styleSelection', + 'emoticonsContainer' => 'emoticonsContainer', + 'colorCodesContainer' => 'colorCodesContainer', + 'flashInterfaceContainer' => 'flashInterfaceContainer', + ], + 'settings' => [ + 'bbCode' => true, + 'bbCodeImages' => true, + 'bbCodeColors' => true, + 'hyperLinks' => true, + 'lineBreaks' => true, + 'emoticons' => true, + 'autoFocus' => true, + 'autoScroll' => true, + 'maxMessages' => 0, + 'wordWrap' => false, + 'maxWordLength' => true, + 'dateFormat' => '(%H:%i:%s)', + 'persistFontColor' => true, + 'fontColor' => null, + 'audio' => true, + 'audioVolume' => 1.0, + 'soundReceive' => 'ajaxchat_incoming', + 'soundSend' => 'ajaxchat_outgoing', + 'soundEnter' => 'ajaxchat_join', + 'soundLeave' => 'ajaxchat_leave', + 'soundChatBot' => 'ajaxchat_server', + 'soundError' => 'local_error', + 'soundKick' => 'dokuro_pipiru', + 'soundPrivate' => 'ajaxchat_incoming', + 'blink' => true, + 'blinkInterval' => 500, + 'blinkIntervalNumber' => 10, + ], + 'nonPersistentSettings' => ['wordWrap'], + 'bbCodeTags' => ['b', 'i', 'u', 'quote', 'code', 'color', 'url', 'img'], + 'colorCodes' => [], + 'emoticonCodes' => [], + 'emoticonFiles' => [], + 'soundFiles' => [ + 'local_error' => '/sounds/ajax_error.mp3', + 'local_shit' => '/sounds/ajax_shit.mp3', + ], + 'sessionName' => 'ajax_chat', + 'cookieExpiration' => 365, + 'cookiePath' => '/', + 'cookieDomain' => null, + 'cookieSecure' => null, + 'chatBotName' => 'Koishi', + 'chatBotID' => 2147483647, + 'allowUserMessageDelete' => false, + 'inactiveTimeout' => 2, + 'privateChannelDiff' => 500000000, + 'privateMessageDiff' => 1000000000, + 'showChannelMessages' => true, + 'messageTextMaxLength' => 2000, + 'socketServerEnabled' => false, + 'socketServerHost' => 'localhost', + 'socketServerPort' => 1935, + 'socketServerChatID' => 0, + ]; + + + foreach($common->colours as $colourInfo) + $config['colorCodes'][] = str_replace(' ', '', $colourInfo->n); + + $config['title'] = $common->title; + + $soundsUrl = 'https:' . (isset($common->sounds2) ? $common->sounds2 : $common->sounds); + $sounds = json_decode(file_get_contents($soundsUrl)); + foreach($sounds->library as $soundInfo) + if(isset($soundInfo->sources->mp3)) + $config['soundFiles'][strtr($soundInfo->name, [':' => '_', '-' => '_'])] = $soundInfo->sources->mp3; + + $emotesUrl = 'https:' . $common->emotes; + $emotes = json_decode(file_get_contents($emotesUrl)); + foreach($emotes as $emoteInfo) + if($emoteInfo->Hierarchy < 1) { + $config['emoticonCodes'][] = $emoteInfo->Text[0]; + $config['emoticonFiles'][] = $emoteInfo->Image; + } + + header('Content-Type: application/javascript; charset=utf-8'); + echo 'var ajaxChatConfig = ' . array_to_jsobj($config) . ';'; + } elseif($_GET['common'] === 'colours') { + header('Content-Type: text/css'); + foreach($common->colours as $colourInfo) { + $colourName = str_replace(' ', '', $colourInfo->n); + $colourHex = '#' . str_pad(dechex($colourInfo->c), 6, '0', STR_PAD_LEFT); + echo 'a.' . $colourName . ' { background-color: ' . $colourHex . "; }\r\n"; + echo '#content .' . $colourName . ' { color: ' . $colourHex . "; }\r\n"; + } + } + exit; +} + // Include Class libraries: require_once __DIR__ . '/../ajaxchat.php'; diff --git a/public/js/chat.js b/public/js/chat.js index e3eca5f..38e845c 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -157,8 +157,10 @@ var ajaxChat = { this.dirs = new Object(); //this.dirs['emoticons'] = 'http://cdn.flashii.net/img/emoticons/'; //this.dirs['sounds'] = 'http://cdn.flashii.net/snd/chat/'; - this.dirs['emoticons'] = 'https://static.flash.moe/emoticons/'; - this.dirs['sounds'] = 'sounds/'; + //this.dirs['emoticons'] = 'https://static.flash.moe/emoticons/'; + this.dirs['emoticons'] = ''; + //this.dirs['sounds'] = 'sounds/'; + this.dirs['sounds'] = ''; }, initSettings: function() { diff --git a/public/js/config.js b/public/js/config.js deleted file mode 100644 index 1c1f546..0000000 --- a/public/js/config.js +++ /dev/null @@ -1,292 +0,0 @@ -/* - * @package AJAX_Chat - * @author Sebastian Tschan - * @copyright (c) Sebastian Tschan - * @license GNU Affero General Public License - * @link https://blueimp.net/ajax/ - */ - -// Ajax Chat config parameters: -var ajaxChatConfig = { - - // The channelID of the channel to enter on login (the loginChannelName is used if set to null): - loginChannelID: null, - // The channelName of the channel to enter on login (the default channel is used if set to null): - loginChannelName: null, - - // The time in ms between update calls to retrieve new chat messages: - timerRate: 2000, - - // The URL to retrieve the XML chat messages (must at least contain one parameter): - ajaxURL: './?ajax=true', - // The base URL of the chat directory, used to retrieve media files (images, sound files, etc.): - baseURL: './', - - // A regular expression for allowed source URL's for media content (e.g. images displayed inline); - regExpMediaUrl: '^((http)|(https)):\\/\\/', - - // If set to false the chat update is delayed until the event defined in ajaxChat.setStartChatHandler(): - startChatOnLoad: true, - - // Defines the IDs of DOM nodes accessed by the chat: - domIDs: { - // The ID of the chat messages list: - chatList: 'chatList', - // The ID of the online users list: - onlineList: 'onlineList', - // The ID of the message text input field: - inputField: 'inputField', - // The ID of the message text length counter: - messageLengthCounter: 'messageLengthCounter', - // The ID of the channel selection: - channelSelection: 'channelSelection', - // The ID of the style selection: - styleSelection: 'styleSelection', - // The ID of the emoticons container: - emoticonsContainer: 'emoticonsContainer', - // The ID of the color codes container: - colorCodesContainer: 'colorCodesContainer', - // The ID of the flash interface container: - flashInterfaceContainer: 'flashInterfaceContainer' - }, - - // Defines the settings which can be modified by users: - settings: { - // Defines if BBCode tags are replaced with the associated HTML code tags: - bbCode: true, - // Defines if image BBCode is replaced with the associated image HTML code: - bbCodeImages: true, - // Defines if color BBCode is replaced with the associated color HTML code: - bbCodeColors: true, - // Defines if hyperlinks are made clickable: - hyperLinks: true, - // Defines if line breaks are enabled: - lineBreaks: true, - // Defines if emoticon codes are replaced with their associated images: - emoticons: true, - - // Defines if the focus is automatically set to the input field on chat load or channel switch: - autoFocus: true, - // Defines if the chat list scrolls automatically to display the latest messages: - autoScroll: true, - // The maximum count of messages displayed in the chat list (will be ignored if set to 0): - maxMessages: 0, - - // Defines if long words are wrapped to avoid vertical scrolling: - wordWrap: false, - // Defines the maximum length before a word gets wrapped: - maxWordLength: 32, - - // Defines the format of the date and time displayed for each chat message: - dateFormat: '(%H:%i:%s)', - - // Defines if font colors persist without the need to assign them to each message: - persistFontColor: true, - // The default font color, uses the page default font color if set to null: - fontColor: null, - - // Defines if sounds are played: - audio: true, - // Defines the sound volume (0.0 = mute, 1.0 = max): - audioVolume: 1.0, - - // Defines the sound that is played when normal messages are reveived: - soundReceive: 'sound_1', - // Defines the sound that is played on sending normal messages: - soundSend: 'sound_2', - // Defines the sound that is played on channel enter or login: - soundEnter: 'sound_3', - // Defines the sound that is played on channel leave or logout: - soundLeave: 'sound_4', - // Defines the sound that is played on chatBot messages: - soundChatBot: 'sound_5', - // Defines the sound that is played on error messages: - soundError: 'sound_6', - // Defines the sound that is played on kicked messages: - soundKick: 'sound_7', - // Defines the sound that is played when private messages are received: - soundPrivate: 'sound_1', - - // Defines if the document title blinks on new messages: - blink: true, - // Defines the blink interval in ms: - blinkInterval: 500, - // Defines the number of blink intervals: - blinkIntervalNumber: 10 - }, - - // Defines a list of settings which are not to be stored in a session cookie: - nonPersistentSettings: new Array( - 'wordWrap' - ), - - // Defines the list of allowed BBCodes: - bbCodeTags: new Array( - 'b', - 'i', - 'u', - 'quote', - 'code', - 'color', - 'url', - 'img' - ), - - // Defines the list of allowed color codes: - colorCodes: new Array( - 'Silver', - 'Citrine', - 'Orange', - 'Pumpkin', - 'Red', - 'Crimson', - 'Ruby', - 'Amaranth', - 'Thulite', - 'Pink', - 'Amethyst', - 'Purpureus', - 'Antisia', - 'Cerulean', - 'Cobalt', - 'Aqua', - 'Mint', - 'Keppel', - 'Teal', - 'Green', - 'Chartreuse', - 'Nitrate', - 'Lilive', - 'Daive' - ), - - // Defines the list of allowed emoticon codes: - emoticonCodes: new Array( - ':happy:', - ':lmao:', - ':angry:', - ':angrier:', - ':evil:', - ':glare:', - ':eat:', - ':lol:', - ':dizzy:', - ':yay:', - ':wtf:', - ':sigh:', - ':omg:', - ':ouch:', - ':tired:', - ':kiss:', - ':love:', - ':sweat:', - ':suspicious:', - ':crying:', - ':blank:', - ':puke:', - ':ruse:', - ':meow:', - ':jew:', - ':winxp:', - ':childish:', - ':idea:' - ), - - // Defines the list of emoticon files associated with the emoticon codes: - emoticonFiles: new Array( - 'happy.png', - 'lmao.png', - 'angry.png', - 'angrier.png', - 'evil.png', - 'glare.png', - 'eat.gif', - 'lol.png', - 'dizzy.gif', - 'vhappy.png', - 'wtf.png', - 'sigh.png', - 'omg.png', - 'ouch.png', - 'tired.gif', - 'kiss.gif', - 'love.png', - 'sweat.gif', - 'suspicious.gif', - 'crying.png', - 'blank.png', - 'puke.gif', - 'ruse.png', - 'meow.png', - 'jew.png', - 'winxp.png', - 'childish.png', - 'idea.png' - ), - - // Defines the available sounds loaded on chat start: - soundFiles: { - sound_1: 'ajax_incoming.mp3', - sound_2: 'ajax_outgoing.mp3', - sound_3: 'ajax_login.mp3', - sound_4: 'ajax_logout.mp3', - sound_5: 'ajax_chatbot.mp3', - sound_6: 'ajax_error.mp3', - sound_7: 'dokuro_pipiru.mp3', - sound_8: 'ajax_shit.mp3', - dicks: 'dicks.mp3', - xp_1: 'xp_incoming.mp3', - xp_2: 'xp_outgoing.mp3', - xp_3: 'xp_login.mp3', - xp_4: 'xp_logout.mp3', - xp_5: 'xp_chatbot.mp3', - xp_6: 'xp_error.mp3' - }, - - - // The following configuration options are usually overwritten by server-side values: - - // Session identification, used for style and setting cookies: - sessionName: 'ajax_chat', - - // The time in days until the style and setting cookies expire: - cookieExpiration: 365, - // The path of the cookies, '/' allows to read the cookies from all directories: - cookiePath: '/', - // The domain of the cookies, defaults to the hostname of the server if set to null: - cookieDomain: null, - // If enabled, cookies must be sent over secure (SSL/TLS encrypted) connections: - cookieSecure: null, - - // The name of the chat bot: - chatBotName: 'Koishi', - // The userID of the chat bot: - chatBotID: 2147483647, - - // Allow/Disallow registered users to delete their own messages: - allowUserMessageDelete: false, - - // Minutes until a user is declared inactive (last status update) - the minimum is 2 minutes: - inactiveTimeout: 2, - - // UserID plus this value are private channels (this is also the max userID and max channelID): - privateChannelDiff: 500000000, - // UserID plus this value are used for private messages: - privateMessageDiff: 1000000000, - - // Defines if login/logout and channel enter/leave are displayed: - showChannelMessages: true, - - // Max messageText length: - messageTextMaxLength: 2000, - - // Defines if the socket server is enabled: - socketServerEnabled: false, - // Defines the hostname of the socket server used to connect from client side: - socketServerHost: 'localhost', - // Defines the port of the socket server: - socketServerPort: 1935, - // This ID can be used to distinguish between different chat installations using the same socket server: - socketServerChatID: 0 - -} \ No newline at end of file diff --git a/template/banned.html b/template/banned.html index 1d23b0c..0dd4a79 100644 --- a/template/banned.html +++ b/template/banned.html @@ -19,7 +19,7 @@ - + - + - + - + - + - + - + - + - +
diff --git a/template/~loggedOut.html b/template/~loggedOut.html index bdbfe18..fa14edc 100644 --- a/template/~loggedOut.html +++ b/template/~loggedOut.html @@ -20,7 +20,7 @@ - +