PHP简易排队限流实现
2024-11-18 14:58:32 Author: www.yanglong.pro(查看原文) 阅读量:4 收藏


$fp = fopen(sprintf("tmp/wk_exam_examination.%d.lock", $userid % 10), "w");
if (!flock($fp, LOCK_EX | LOCK_NB)) {
?>
<style>
#info {
text-align: center;
margin: 50px 0;
}

#info td {
font-size: 36px;
color: seagreen;
}
</style>
<div id='info'></div>
<script>
let sec = 5000
setTimeout(function () {
window.location.reload()
}, sec)
setInterval(function () {
sec -= 100
if (sec >= 0) {
let ok = sec / 1000
document.getElementById('info').innerHTML = `<table style="margin: 0 auto;">
<tr><td style='width: 50%; text-align: right;'>页面排队中...</td>
<td style="width: 2em; text-align: center;">${ok}</td><td>秒后将重试!</td></tr></table>`;
}
}, 100)
</script><?php
die;
}


文章来源: https://www.yanglong.pro/php%e7%ae%80%e6%98%93%e6%8e%92%e9%98%9f%e9%99%90%e6%b5%81%e5%ae%9e%e7%8e%b0/
如有侵权请联系:admin#unsafe.sh