corrade-http-templates
/groupChat/groupChat.html |
@@ -60,7 +60,7 @@ |
<script src="bower_components/velocity/velocity.min.js"></script> |
<script> |
$(document).ready(function () { |
function sendGroupMessage(token) { |
function sendGroupMessage() { |
// Hide the controls. |
$("#controls").animate( |
{ |
@@ -77,8 +77,7 @@ |
url: "sendGroupMessage.php", |
data: { |
name: $("#name").val(), |
message: $("#message").val(), |
token: token |
message: $("#message").val() |
} |
}).done(function(data) { |
// If any error occurred, display it. |
@@ -97,7 +96,6 @@ |
); |
}); |
} |
|
// Polls the chatlog every second for changes. |
(function retrieveMessages() { |
$.get("chat.log?t=" + Math.random(), function(data) { |
@@ -106,22 +104,18 @@ |
setTimeout(retrieveMessages, 1000); |
}); |
}()); |
|
$.get('session.php').then((token) => { |
// When the send button is pressed, then call the sendGroupMessage function to |
// send the message to the PHP script, which then send the message to Corrade. |
$("#send").click(function(e){ |
sendGroupMessage(token); |
}); |
|
// Subscribe to pressing enter with the message input box selected. |
$("#message").keypress(function(e) { |
if (e.which == 13) { |
sendGroupMessage(token); |
return false; |
} |
}); |
// When the send button is pressed, then call the sendGroupMessage function to |
// send the message to the PHP script, which then send the message to Corrade. |
$("#send").click(function(e){ |
sendGroupMessage(); |
}); |
// Subscribe to pressing enter with the message input box selected. |
$("#message").keypress(function(e) { |
if (e.which == 13) { |
sendGroupMessage(); |
return false; |
} |
}); |
}); |
</script> |
</body> |
/groupChat/sendGroupMessage.php |
@@ -17,13 +17,6 @@ |
## INTERNALS ## |
########################################################################### |
|
# CRSF. |
session_start(); |
if (empty($_POST['token']) || !hash_equals($_SESSION['token'], $_POST['token'])) { |
http_response_code(403); |
die('Forbidden.'); |
} |
|
# If there is no message set or no name set or if the message or the name |
# are empty then do not proceed any further. |
if(!isset($_POST['message']) || |