File clickado.php
<?php
$time = time();
$usuario = $_POST['usuario'];
$fp = fopen("timerdobotao.txt", "w+");
$escreve = fwrite($fp, $time);
fclose($fp);
?>
Verify
<?php
$arquivo = fopen ('timerdobotao.txt', 'r');
$rt = "false";
while(!feof($arquivo)){
$linha = fgets($arquivo, 1024);
if($linha !=""){
if($linha < (time() - (1 * 60 * 60))){ // horas * minutos * segundos
$rt = "true";
}
}
}
echo $rt;
?>
In your html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>functionClickDoBotao(){varusuario="idDoUsuario";
$.post("clickado.php",{usuario:usuario}function(){
})
}
setInterval(function(){
var usuario = "idDoUsuario";
setInterval(function(){
$.get("verificabotao.php",{usuario:usuario},function(rt){
if(rt == "true"){
$("#meuBotao").prop("disabled",false);
}else{
$("#meuBotao").prop("disabled",true);
}
});
}, 5000);
});
</script>
Make a button and assign an id
<button onclick="ClickDoBotao()" id="meuBotao">
I did not have to test the code but the logic is this