I am programming a website where you can publish materials. This works with the following jQuery ajax:
$.ajax({
type: 'POST',
url: 'action/post.php',
data: 'posttext='+posttext+'&imageurl='+imageurl,
success: function(feedback){
$('#feedback').val(feedback);
}
});
Now I ask myself: anyone could write their own ajax to publish something on the site and do it again and again. How can I prevent this? I am sure that I will need some kind of security check in post.php - I already heard about the HTTP referrer, but this can be changed, so it is not trustworthy.
I would also like to add a timer to post.php, which ensures that a message from the same ip address can only be sent every x seconds and resets the timer if the message is sent below x seconds (the kind of stack overflow does this with comments )
Does anyone know how to protect ajax as well as how to set a timer? Or any other ideas on how to provide a publishing mechanism?
Thank!
Dennis
source
share