remove sakurako related things

This commit is contained in:
flash 2016-12-04 17:57:35 +01:00
parent 3b60cf457e
commit fa4d9a9226
9 changed files with 3 additions and 709 deletions

View file

@ -1,17 +0,0 @@
<?php
/**
* Holds the authentication interface.
* @package Sakura
*/
namespace Sakura\Chat;
/**
* Interface for authentication methods.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
interface AuthInterface
{
public function attempt();
}

View file

@ -1,81 +0,0 @@
<?php
/**
* Holds the link info object.
* @package Sakura
*/
namespace Sakura\Chat;
/**
* Object to serve back to the chat.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
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;
}

View file

@ -1,289 +0,0 @@
<?php
/**
* Hold the Sakurako settings object.
* @package Sakura
*/
namespace Sakura\Chat;
/**
* Chat settings. Keep this up-to-date with settings.json for Sakurako.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
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,
];
}
}

View file

@ -1,130 +0,0 @@
<?php
/**
* Holds the url resolver.
* @package Sakura
*/
namespace Sakura\Chat;
/**
* Resolves URL data.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
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;
}
}

View file

@ -1,128 +0,0 @@
<?php
/**
* Hold the controller for chat related pages.
* @package Sakura
*/
namespace Sakura\Controllers;
use Sakura\Chat\LinkInfo;
use Sakura\Chat\Settings;
use Sakura\Chat\URLResolver;
use Sakura\DB;
use Sakura\Session;
use Sakura\User;
/**
* Chat related controller.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
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";
}
}

View file

@ -52,9 +52,6 @@ cover =
; Close the site for maintenance ; Close the site for maintenance
maintenance = false maintenance = false
; URL of the sakurako chat (full path) without trailing slash
chat = http://chat.localghost
; Date formatting string ; Date formatting string
date_format = D Y-m-d H:i:s T 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 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 settings
[lastfm] [lastfm]
api_key = api_key =

View file

@ -10,17 +10,11 @@
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css"> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Exo+2:200,200italic,300,300italic,400,400italic" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Exo+2:200,200italic,300,300italic,400,400italic" rel="stylesheet" type="text/css">
{#<link href="{{ config('general.chat') }}/app.css" rel="stylesheet" type="text/css">#}
<link href="/css/libraries.css" rel="stylesheet" type="text/css" data-turbolinks-track> <link href="/css/libraries.css" rel="stylesheet" type="text/css" data-turbolinks-track>
<link href="/css/aitemu.css" rel="stylesheet" type="text/css" data-turbolinks-track> <link href="/css/aitemu.css" rel="stylesheet" type="text/css" data-turbolinks-track>
{{ block('css') }} {{ block('css') }}
{#<script>
window["sakurakoSettings"] = route('chat.settings');
</script>#}
<!-- we'll disable turbolinks for now script src="/js/libraries.js" data-turbolinks-track></script-->
<script src="/js/aitemu.js" data-turbolinks-track></script> <script src="/js/aitemu.js" data-turbolinks-track></script>
{#<script src="{{ config('general.chat') }}/app.js"></script>#}
{{ block('js') }} {{ block('js') }}
</head> </head>
<body> <body>
@ -55,10 +49,6 @@
</div> </div>
{{ block('content') }} {{ block('content') }}
{#<div class="platform" id="chat-interface" data-turbolinks-permanent>
@include('misc.chat')
</div>#}
</div> </div>
<div class="container__footer"> <div class="container__footer">
<div class="container__footer-copyright">flash.moe 2013-{{ ''|date('Y') }}</div> <div class="container__footer-copyright">flash.moe 2013-{{ ''|date('Y') }}</div>

View file

@ -44,7 +44,7 @@
<div class="header__menu--left" id="navMenuSite"> <div class="header__menu--left" id="navMenuSite">
<a class="header__menu-item fa fa-home" href="{{ route('main.index') }}" title="Home"></a> <a class="header__menu-item fa fa-home" href="{{ route('main.index') }}" title="Home"></a>
<a class="header__menu-item fa fa-newspaper-o" href="{{ route('news.category') }}" title="News"></a> <a class="header__menu-item fa fa-newspaper-o" href="{{ route('news.category') }}" title="News"></a>
<a class="header__menu-item fa fa-commenting" href="{{ route('chat.redirect') }}" title="Chat"></a> <a class="header__menu-item fa fa-commenting" href="#" title="Chat"></a>
<a class="header__menu-item fa fa-list" href="{{ route('forums.index') }}" title="Forums"></a> <a class="header__menu-item fa fa-list" href="{{ route('forums.index') }}" title="Forums"></a>
<a class="header__menu-item fa fa-search" href="{{ route('main.search') }}" title="Search"></a> <a class="header__menu-item fa fa-search" href="{{ route('main.search') }}" title="Search"></a>
{% if user.isActive %} {% if user.isActive %}

View file

@ -47,8 +47,8 @@ Router::group(['before' => 'maintenance'], function () {
'rules' => 'info.rules', 'rules' => 'info.rules',
'welcome' => 'info.welcome', 'welcome' => 'info.welcome',
//'profileapi' => 'api.manage.index', //'profileapi' => 'api.manage.index',
'chat' => 'chat.redirect', //'chat' => 'chat.redirect',
'irc' => 'chat.irc', //'irc' => 'chat.irc',
'feedback' => 'forums.index', 'feedback' => 'forums.index',
'mcp' => 'manage.index', 'mcp' => 'manage.index',
'mcptest' => 'manage.index', 'mcptest' => 'manage.index',
@ -87,18 +87,6 @@ Router::group(['before' => 'maintenance'], function () {
Router::get('/post/{id:i}', 'NewsController@post', 'news.post'); Router::get('/post/{id:i}', 'NewsController@post', 'news.post');
}); });
// Chat
Router::group(['prefix' => 'chat'], function () {
Router::get('/redirect', 'ChatController@redirect', 'chat.redirect');
Router::get('/settings', 'ChatController@settings', 'chat.settings');
Router::get('/auth', 'ChatController@auth', 'chat.auth');
Router::get('/resolve', 'ChatController@resolve', 'chat.resolve');
Router::get('/irc', 'ChatController@irc', 'chat.irc');
});
// Authentication for the "old" chat
Router::get('/web/sock-auth.php', 'ChatController@authLegacy');
// Forum // Forum
Router::group(['prefix' => 'forum'], function () { Router::group(['prefix' => 'forum'], function () {
// Post // Post