Adds Internet admin midi (#30457)

* Adds Internet admin midi

* Moves global regex into proc (shell_url_scrub)

* Moves shelleo to world
Adds quotes around the command in shelleo, to encapsulate it

* Admins can stop playing web sounds

* Revised internet midi extension order
Moved m4a to least preferred,
as it can potentially carry non-aac or non-mpeg-3 audio

* Kills \n in web sound

* play_web_sound availability based on config

* play web sound and shelleo tweaks

istypeless for in play web sound & readability parenthesis around binary AND
add return index defines for shelleo proc

* Security fix for play web sound
This commit is contained in:
JJRcop
2017-09-08 10:31:33 -04:00
committed by CitadelStationBot
parent ce787e7726
commit 00dd2f283b
12 changed files with 246 additions and 17 deletions
+14
View File
@@ -13,6 +13,7 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
var/cookieSent = FALSE // Has the client sent a cookie for analysis
var/broken = FALSE
var/list/connectionHistory //Contains the connection history passed from chat cookie
var/adminMusicVolume = 100 //This is for the Play Global Sound verb
/datum/chatOutput/New(client/C)
owner = C
@@ -79,6 +80,9 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
if("analyzeClientData")
data = analyzeClientData(arglist(params))
if("setMusicVolume")
data = setMusicVolume(arglist(params))
if(data)
ehjax_send(data = data)
@@ -120,6 +124,16 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
data = json_encode(data)
C << output("[data]", "[window]:ehjaxCallback")
/datum/chatOutput/proc/sendMusic(music, pitch)
var/list/music_data = list("adminMusic" = url_encode(url_encode(music)))
if(pitch)
music_data["musicRate"] = pitch
ehjax_send(data = music_data)
/datum/chatOutput/proc/setMusicVolume(volume = "")
if(volume)
adminMusicVolume = Clamp(text2num(volume), 0, 100)
//Sends client connection details to the chat to handle and save
/datum/chatOutput/proc/sendClientData()
//Get dem deets
@@ -101,7 +101,7 @@ a.popt {text-decoration: none;}
top: 0;
right: 0;
}
#options a {
#options .optionsCell {
background: #ddd;
height: 30px;
padding: 5px 0;
@@ -111,7 +111,7 @@ a.popt {text-decoration: none;}
line-height: 28px;
border-top: 1px solid #b4b4b4;
}
#options a:hover {background: #ccc;}
#options .optionsCell:hover {background: #ccc;}
#options .toggle {
width: 40px;
background: #ccc;
@@ -121,7 +121,7 @@ a.popt {text-decoration: none;}
}
#options .sub {clear: both; display: none; width: 160px;}
#options .sub.scroll {overflow-y: scroll;}
#options .sub a {padding: 3px 0 3px 8px; line-height: 30px; font-size: 0.9em; clear: both;}
#options .sub.optionsCell {padding: 3px 0 3px 8px; line-height: 30px; font-size: 0.9em; clear: both;}
#options .sub span {
display: block;
line-height: 30px;
@@ -136,6 +136,13 @@ a.popt {text-decoration: none;}
line-height: 30px;
float: right;
}
#options .sub input {
position: absolute;
padding: 7px 5px;
width: 121px;
line-height: 30px;
float: left;
}
#options .decreaseFont {border-top: 0;}
/* POPUPS */
@@ -28,17 +28,19 @@
<span class="ms" id="pingMs">--ms</span>
</div>
<div id="options">
<a href="#" class="toggle" id="toggleOptions" title="Options"><i class="icon-cog"></i></a>
<a href="#" class="optionsCell toggle" id="toggleOptions" title="Options"><i class="icon-cog"></i></a>
<div class="sub" id="subOptions">
<a href="#" class="decreaseFont" id="decreaseFont"><span>Decrease font size</span> <i class="icon-font">-</i></a>
<a href="#" class="increaseFont" id="increaseFont"><span>Increase font size</span> <i class="icon-font">+</i></a>
<a href="#" class="togglePing" id="togglePing"><span>Toggle ping display</span> <i class="icon-circle"></i></a>
<a href="#" class="highlightTerm" id="highlightTerm"><span>Highlight string</span> <i class="icon-tag"></i></a>
<a href="#" class="saveLog" id="saveLog"><span>Save chat log</span> <i class="icon-save"></i></a>
<a href="#" class="clearMessages" id="clearMessages"><span>Clear all messages</span> <i class="icon-eraser"></i></a>
<a href="#" class="optionsCell decreaseFont" id="decreaseFont"><span>Decrease font size</span> <i class="icon-font">-</i></a>
<a href="#" class="optionsCell increaseFont" id="increaseFont"><span>Increase font size</span> <i class="icon-font">+</i></a>
<a href="#" class="optionsCell togglePing" id="togglePing"><span>Toggle ping display</span> <i class="icon-circle"></i></a>
<a href="#" class="optionsCell highlightTerm" id="highlightTerm"><span>Highlight string</span> <i class="icon-tag"></i></a>
<a href="#" class="optionsCell saveLog" id="saveLog"><span>Save chat log</span> <i class="icon-save"></i></a>
<a href="#" class="optionsCell clearMessages" id="clearMessages"><span>Clear all messages</span> <i class="icon-eraser"></i></a>
<span class="optionsCell" id="musicVolumeSpan"><input type="range" class="hidden" id="musicVolume"><span id="musicVolumeText">Admin music volume</span><i class="icon-music"></i></span>
</div>
</div>
</div>
<audio class="hidden" id="adminMusic" autoplay></audio>
<script type="text/javascript" src="browserOutput.js"></script>
</body>
</html>
@@ -61,8 +61,17 @@ var opts = {
'clientDataLimit': 5,
'clientData': [],
//Admin music volume update
'volumeUpdateDelay': 5000, //Time from when the volume updates to data being sent to the server
'volumeUpdating': false, //True if volume update function set to fire
'updatedVolume': 0, //The volume level that is sent to the server
};
function clamp(val, min, max) {
return Math.max(min, Math.min(val, max))
}
function outerHTML(el) {
var wrap = document.createElement('div');
wrap.appendChild(el.cloneNode(true));
@@ -95,6 +104,15 @@ function linkify(text) {
});
}
function byondDecode(message) {
// Basically we url_encode twice server side so we can manually read the encoded version and actually do UTF-8.
// The replace for + is because FOR SOME REASON, BYOND replaces spaces with a + instead of %20, and a plus with %2b.
// Marvelous.
message = message.replace(/\+/g, "%20");
message = decoder(message);
return message;
}
//Actually turns the highlight term match into appropriate html
function addHighlightMarkup(match) {
var extra = '';
@@ -176,11 +194,7 @@ function output(message, flag) {
if (flag !== 'internal')
opts.lastPang = Date.now();
// Basically we url_encode twice server side so we can manually read the encoded version and actually do UTF-8.
// The replace for + is because FOR SOME REASON, BYOND replaces spaces with a + instead of %20, and a plus with %2b.
// Marvelous.
message = message.replace(/\+/g, "%20")
message = decoder(message)
message = byondDecode(message)
//The behemoth of filter-code (for Admin message filters)
//Note: This is proooobably hella inefficient
@@ -423,7 +437,22 @@ function ehjaxCallback(data) {
var firebugEl = document.createElement('script');
firebugEl.src = 'https://getfirebug.com/firebug-lite-debug.js';
document.body.appendChild(firebugEl);
}
} else if (data.adminMusic) {
if (typeof data.adminMusic === 'string') {
var adminMusic = byondDecode(data.adminMusic);
adminMusic = adminMusic.match(/https?:\/\/\S+/) || '';
if (data.musicRate) {
var newRate = Number(data.musicRate);
if(newRate) {
$('#adminMusic').prop('defaultPlaybackRate', newRate);
}
} else {
$('#adminMusic').prop('defaultPlaybackRate', 1.0);
}
$('#adminMusic').prop('src', adminMusic);
$('#adminMusic').trigger("play");
}
}
}
}
@@ -446,6 +475,13 @@ function toggleWasd(state) {
opts.wasd = (state == 'on' ? true : false);
}
function sendVolumeUpdate() {
opts.volumeUpdating = false;
if(opts.updatedVolume) {
runByond('?_src_=chat&proc=setMusicVolume&param[volume]='+opts.updatedVolume);
}
}
/*****************************************
*
* DOM READY
@@ -486,6 +522,7 @@ $(function() {
'spingDisabled': getCookie('pingdisabled'),
'shighlightTerms': getCookie('highlightterms'),
'shighlightColor': getCookie('highlightcolor'),
'smusicVolume': getCookie('musicVolume'),
};
if (savedConfig.sfontSize) {
@@ -517,6 +554,14 @@ $(function() {
opts.highlightColor = savedConfig.shighlightColor;
internalOutput('<span class="internal boldnshit">Loaded highlight color of: '+savedConfig.shighlightColor+'</span>', 'internal');
}
if (savedConfig.smusicVolume) {
var newVolume = clamp(savedConfig.smusicVolume, 0, 100);
$('#adminMusic').prop('volume', newVolume / 100);
$('#musicVolume').val(newVolume);
opts.updatedVolume = newVolume;
sendVolumeUpdate();
internalOutput('<span class="internal boldnshit">Loaded music volume of: '+savedConfig.smusicVolume+'</span>', 'internal');
}
(function() {
var dataCookie = getCookie('connData');
@@ -835,6 +880,26 @@ $(function() {
opts.messageCount = 0;
});
$('#musicVolumeSpan').hover(function() {
$('#musicVolumeText').addClass('hidden');
$('#musicVolume').removeClass('hidden');
}, function() {
$('#musicVolume').addClass('hidden');
$('#musicVolumeText').removeClass('hidden');
});
$('#musicVolume').change(function() {
var newVolume = $('#musicVolume').val();
newVolume = clamp(newVolume, 0, 100);
$('#adminMusic').prop('volume', newVolume / 100);
setCookie('musicVolume', newVolume, 365);
opts.updatedVolume = newVolume;
if(!opts.volumeUpdating) {
setTimeout(sendVolumeUpdate, opts.volumeUpdateDelay);
opts.volumeUpdating = true;
}
});
$('img.icon').error(iconError);