Answer the question
In order to leave comments, you need to log in
How do you like this implementation of the chat? Is it safe?
How do you like this implementation of the chat ?
Confused:
var objDiv = document.getElementById("message_box");
objDiv.scrollTop = objDiv.scrollHeight;
//prepare json data
var msg = {
message: mymessage,
name: '<?=$loggedIn['personaname']?>,
color : '<?php echo $colours[$user_colour]; ?>'
};
//convert and send data to server
websocket.send(JSON.stringify(msg));
Answer the question
In order to leave comments, you need to log in
Yes, you can send. I suggest that you supplement the request to the socket with another key parameter:
var msg = {
message: mymessage,
name: '<?=$loggedIn['personaname']?>,
key: '<?= $userKey ?>',
color : '<?php echo $colours[$user_colour]; ?>'
};
$salt = 'SDFGH$W#%^UHdfHE$#%';
$userKey = md5($loggedIn['personaname'] . $salt);
if($key !== md5($name . $salt)) {
// обработка поддельного запроса
} else {
// все ок
}
Of course you can send anything.
And even html with scripts can be sent.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question