diff --git a/app/Chat/AuthInterface.php b/app/Chat/AuthInterface.php deleted file mode 100644 index 8d8abea..0000000 --- a/app/Chat/AuthInterface.php +++ /dev/null @@ -1,17 +0,0 @@ - - */ -interface AuthInterface -{ - public function attempt(); -} diff --git a/app/Chat/LinkInfo.php b/app/Chat/LinkInfo.php deleted file mode 100644 index 34f120b..0000000 --- a/app/Chat/LinkInfo.php +++ /dev/null @@ -1,81 +0,0 @@ - - */ -class LinkInfo -{ - /** - * Types for $Type. - */ - const TYPES = [ - 'PLAIN' => 0, - 'META' => 1, - 'VIDEO' => 2, - 'AUDIO' => 3, - 'IMAGE' => 4, - 'EMBED' => 5, - ]; - - /** - * Modifiable url. - * @var string - */ - public $URL; - - /** - * Original url. - * @var string - */ - public $OriginalURL; - - /** - * Type (from const TYPES). - * @var int - */ - public $Type; - - /** - * Full image or thumbnail, depends on Type. - * @var string - */ - public $Image; - - /** - * Title/header text. - * @var string - */ - public $Title; - - /** - * Description text. - * @var string - */ - public $Description; - - /** - * The content type to assign if applicable. - * @var string - */ - public $ContentType; - - /** - * The width of an image if applicable. - * @var int - */ - public $Width; - - /** - * The height of an image if applicable. - * @var int - */ - public $Height; -} diff --git a/app/Chat/Settings.php b/app/Chat/Settings.php deleted file mode 100644 index 1e813e9..0000000 --- a/app/Chat/Settings.php +++ /dev/null @@ -1,289 +0,0 @@ - - */ -class Settings -{ - /** - * Protocol the chat will use. - * @var string - */ - public $protocol = 'TestRepeater'; - - /** - * Server address the chat will connect to. - * @var string - */ - public $server = null; - - /** - * Title to display on the window/tab. - * @var string - */ - public $title = 'Sakurako'; - - /** - * Location to redirect to when the authentication failed. - * @var string - */ - public $authRedir = null; - - /** - * Cookies to send to the server for authentication (in proper order). - * @var array - */ - public $authCookies = []; - - /** - * URL format for avatars, {0} gets replaced with the user's id and set to null to disable. - * @var string - */ - public $avatarUrl = null; - - /** - * URL format for profile links, works the same as avatars. - * @var string - */ - public $profileUrl = null; - - /** - * Enabling compact (classic) by default. - * @var bool - */ - public $compactView = false; - - /** - * Strobe the tab title on new message. - * @var bool - */ - public $flashTitle = true; - - /** - * Enabling browser notifications. - * @var bool - */ - public $enableNotifications = true; - - /** - * Words that trigger a notification separated with spaces. - * @var string - */ - public $notificationTriggers = ''; - - /** - * Show the contents of the message in the notification. - * @var bool - */ - public $notificationShowMessage = false; - - /** - * Enabling development mode (e.g. loading eruda). - * @var bool - */ - public $development = false; - - /** - * Default style. - * @var string - */ - public $style = 'dark'; - - /** - * Path to language files relative to the chat client's index. - * @var string - */ - public $languagePath = './languages/'; - - /** - * Default language file to use. - * @var string - */ - public $language = 'en-gb'; - - /** - * Available languages. - * @var array - */ - public $languages = [ - 'en-gb' => 'English', - ]; - - /** - * Formatting string to the timestamp, uses the PHP syntax. - * @var string - */ - public $dateTimeFormat = 'H:i:s'; - - /** - * Markup parser to use. - * @var string - */ - public $parser = 'WaterDown'; - - /** - * Enabling the markup parser. - * @var bool - */ - public $enableParser = true; - - /** - * Enabling emoticon parsing. - * @var bool - */ - public $enableEmoticons = true; - - /** - * Whether urls should be automatically detected in message. - * @var bool - */ - public $autoParseUrls = true; - - /** - * Whether the chat should embed url macros like image embedding. - * @var bool - */ - public $autoEmbed = true; - - /** - * Enabling automatically scrolling down when a new message is received. - * @var bool - */ - public $autoScroll = true; - - /** - * Enabling notification sounds. - * @var bool - */ - public $soundEnable = true; - - /** - * The volume percentage for sounds. - * @var int - */ - public $soundVolume = 80; - - /** - * The default sound pack. - * @var string - */ - public $soundPack = 'default'; - - /** - * Available sound packs. - * @var array - */ - public $soundPacks = [ - 'default' => 'Default', - ]; - - /** - * Enabling the user join sound. - * @var bool - */ - public $soundEnableJoin = true; - - /** - * Enabling the user leave sound. - * @var bool - */ - public $soundEnableLeave = true; - - /** - * Enabling the error sound. - * @var bool - */ - public $soundEnableError = true; - - /** - * Enabling the server broadcast sound. - * @var bool - */ - public $soundEnableServer = true; - - /** - * Enabling the incoming message sound. - * @var bool - */ - public $soundEnableIncoming = true; - - /** - * Enabling the outgoing message sound. - * @var bool - */ - public $soundEnableOutgoing = true; - - /** - * Enabling the private message sound. - * @var bool - */ - public $soundEnablePrivate = true; - - /** - * Enabling the forceful leave (kick/ban/etc) sound. - * @var bool - */ - public $soundEnableForceLeave = true; - - /** - * Whether to let the user confirm before closing the tab. - * @var bool - */ - public $closeTabConfirm = false; - - /** - * Emoticons to be loaded. - * @var array - */ - public $emoticons = []; - - /** - * Applies settings based on Sakura's configuration. - */ - public function loadStandard(): void - { - $this->protocol = config('chat.protocol'); - $this->server = config('chat.server'); - $this->title = config('chat.title'); - $this->authRedir = route('auth.login', null, true); - $cpfx = config('cookie.prefix'); - $this->authCookies = [ - "{$cpfx}id", - "{$cpfx}session", - ]; - $this->avatarUrl = route('user.avatar', '{0}', true); - $this->profileUrl = route('user.profile', '{0}', true); - $this->development = config('dev.show_errors'); - $this->languagePath = config('chat.language_path'); - $this->language = config('chat.language'); - $this->languages = config('chat.languages'); - $this->dateTimeFormat = config('chat.date_format'); - $this->parser = config('chat.parser'); - $this->soundPack = config('chat.sound_pack'); - $this->soundPacks = config('chat.sound_packs'); - } - - /** - * Adding an emoticon to the list. - * @param array $triggers - * @param string $image - * @param int $hierarchy - * @param bool $relativePath - */ - public function addEmoticon(array $triggers, string $image, int $hierarchy = 0, bool $relativePath = false): void - { - $this->emoticons[] = [ - 'Text' => $triggers, - 'Image' => ($relativePath ? full_domain() : '') . $image, - 'Hierarchy' => $hierarchy, - ]; - } -} diff --git a/app/Chat/URLResolver.php b/app/Chat/URLResolver.php deleted file mode 100644 index 91d8495..0000000 --- a/app/Chat/URLResolver.php +++ /dev/null @@ -1,130 +0,0 @@ - - */ -class URLResolver -{ - /** - * Resolves a url. - * @param string $protocol - * @param string $slashes - * @param string $authority - * @param string $host - * @param string $port - * @param string $path - * @param string $query - * @param string $hash - * @return LinkInfo - */ - public static function resolve(string $protocol, string $slashes, string $authority, string $host, string $port, string $path, string $query, string $hash): LinkInfo - { - $url = "{$protocol}:{$slashes}{$authority}{$host}{$port}{$path}{$query}{$hash}"; - $info = new LinkInfo; - $info->URL = $info->OriginalURL = $url; - $info->Type = LinkInfo::TYPES['PLAIN']; - - switch ($protocol) { - case 'http': - case 'https': - // youtube, handles .be, -nocookie.com and any possible tld and always uses -nocookie.com for the embedder - if (preg_match("#(?:www\.)?youtu(?:be\.(?:[a-z]{2,63})|\.be|\be-nocookie\.com)$#si", $host)) { - if ($host === 'youtu.be') { - $video_id = $path; - } else { - $split = split_query_string($query); - - if (!array_key_exists('v', $split)) { - break; - } - - $video_id = $split['v']; - } - - $info->URL = "https://www.youtube-nocookie.com/embed/{$video_id}"; - $info->Type = LinkInfo::TYPES['EMBED']; - $info->Width = 320; - $info->Height = 240; - break; - } - - $headers = get_headers($url); - $data = curl_fetch($url); - - if (strstr($headers[0], ' 40') !== false || strstr($headers[0], ' 50') !== false) { - $info->Type = LinkInfo::TYPES['PLAIN']; - break; - } - - if (getimagesizefromstring($data) !== false) { - $info->Type = LinkInfo::TYPES['IMAGE']; - break; - } - - $finfo = finfo_open(FILEINFO_MIME_TYPE); - $mime = finfo_buffer($finfo, $data); - finfo_close($finfo); - - if (strstr($mime, 'audio/') !== false) { - $info->Type = LinkInfo::TYPES['AUDIO']; - - if (strstr($mime, 'mp') !== false) { - $info->ContentType = 'audio/mp3'; - } elseif (strstr($mime, 'og') !== false) { - $info->ContentType = 'audio/ogg'; - } elseif (strstr($mime, 'webm') !== false) { - $info->ContentType = 'audio/webm'; - } else { - $info->ContentType = 'audio/wav'; - } - break; - } - - if (strstr($mime, 'video/') !== false) { - $info->Type = LinkInfo::TYPES['VIDEO']; - - if (strstr($mime, 'og') !== false) { - $info->ContentType = 'video/ogg'; - } elseif (strstr($mime, 'webm') !== false) { - $info->ContentType = 'video/webm'; - } else { - // just kind of assume it's mp4 - $info->ContentType = 'video/mp4'; - } - break; - } - - $tags = meta_tags($data); - - $info->Image = $tags['og:image'] ?? $tags['twitter:image:src'] ?? null; - $info->Title = $tags['og:title'] ?? $tags['twitter:title'] ?? $tags['title'] ?? null; - $info->Description = $tags['og:description'] ?? $tags['twitter:description'] ?? $tags['description'] ?? null; - - if ($info->Title === null && $info->Description === null) { - $info->Type = LinkInfo::TYPES['PLAIN']; - } else { - $info->Type = LinkInfo::TYPES['META']; - } - break; - - case 'osu': - // osu!direct - if ($host === 'dl' || $host === 'b') { - $info->Type = LinkInfo::TYPES['META']; - } else { - $info->Type = LinkInfo::TYPES['PLAIN']; - } - break; - } - - return $info; - } -} diff --git a/app/Controllers/ChatController.php b/app/Controllers/ChatController.php deleted file mode 100644 index 11e114d..0000000 --- a/app/Controllers/ChatController.php +++ /dev/null @@ -1,128 +0,0 @@ - - */ -class ChatController extends Controller -{ - /** - * Middlewares! - * @var array - */ - protected $middleware = [ - 'EnableCORS', - ]; - - /** - * Redirects the user to the chat client. - */ - public function redirect(): string - { - return redirect(config('chat.webclient')); - } - - /** - * Serves the settings for a Sakurako chat. - * @return string - */ - public function settings(): string - { - $settings = new Settings; - $settings->loadStandard(); - - $emotes = DB::table('emoticons') - ->get(); - - foreach ($emotes as $emote) { - $settings->addEmoticon([$emote->emote_string], $emote->emote_path, 1, true); - } - - return $this->json($settings); - } - - /** - * Resolves urls. - * @return string - */ - public function resolve(): string - { - $data = json_decode(file_get_contents('php://input')); - $info = new LinkInfo; - - if (json_last_error() === JSON_ERROR_NONE) { - $info = URLResolver::resolve( - $data->Protocol ?? null, - $data->Slashes ?? null, - $data->Authority ?? null, - $data->Host ?? null, - $data->Port ?? null, - $data->Path ?? null, - $data->Query ?? null, - $data->Hash ?? null - ); - } - - return $this->json($info); - } - - /** - * Handles the authentication for a chat server. - * @return string - */ - public function auth(): ?string - { - return null; - } - - /** - * IRC page. - * @return string - */ - public function irc(): ?string - { - return null; - } - - /** - * Legacy auth, for SockLegacy. Remove when the old chat server finally dies. - * @return string - */ - public function authLegacy(): string - { - $user = User::construct($_GET['arg1'] ?? null); - $session = new Session($_GET['arg2'] ?? null); - - if ($session->validate($user->id) - && !$user->activated - && $user->verified - && !$user->restricted) { - $hierarchy = $user->hierarchy(); - $moderator = $user->perms->isMod || $user->perms->isAdmin ? 1 : 0; - $changeName = $user->perms->changeUsername ? 1 : 0; - $createChans = $user->perms->isAdmin ? 2 : ( - $user->perms->isMod ? 1 : 0 - ); - - // The single 0 in here is used to determine log access, which isn't supported by sakurako anymore since it - // required direct database access and the chat is databaseless now. - return "yes{$user->id}\n{$user->username}\n{$user->colour}\n{$hierarchy}\f{$moderator}\f0\f{$changeName}\f{$createChans}\f"; - } - - return "no"; - } -} diff --git a/config/config.example.ini b/config/config.example.ini index 4bf9f6d..d05faa8 100644 --- a/config/config.example.ini +++ b/config/config.example.ini @@ -52,9 +52,6 @@ cover = ; Close the site for maintenance maintenance = false -; URL of the sakurako chat (full path) without trailing slash -chat = http://chat.localghost - ; Date formatting string date_format = D Y-m-d H:i:s T @@ -213,42 +210,6 @@ twit['smugwave'] = "Sakura's main developer" repo['Sakura'] = https://github.com/flashwave/sakura -; Chat specific settings -[chat] -; Path to the webclient -webclient = http://localhost/chat/ - -; Protocol to use -protocol = Sock - -; Server address -server = ws://localhost - -; Window/tab title -title = Sakurako - -; Path to language files directory for the chat (relative to the chat's client) -language_path = ./languages/ - -; Available languages -languages[en-gb] = English -languages[nl-nl] = Nederlands - -; Default language -language = en-gb - -; Date formatting used for chat message (standard PHP format) -date_format = H:i:s - -; Markup parser to use -parser = WaterDown - -; Soundpacks -sound_packs[default] = Default - -; Default soundpack to use -sound_pack = default - ; LastFM settings [lastfm] api_key = diff --git a/resources/views/aitemu/master.twig b/resources/views/aitemu/master.twig index 375f3ab..f6db108 100644 --- a/resources/views/aitemu/master.twig +++ b/resources/views/aitemu/master.twig @@ -10,17 +10,11 @@ - {##} {{ block('css') }} - {##} - - {##} {{ block('js') }}
@@ -55,10 +49,6 @@ {{ block('content') }} - - {#