Stop the admin dashboard calendar from flooding /ajax

calendar.js called hasEventDay() twice per day cell, firing ~60-74
simultaneous POST /ajax requests on every dashboard load and month
change, which tripped the hosting WAF rate limit (429, then 403 IP
ban). The dayHasEvent action has no server handler and the async
result was never used, so the calls are removed outright. calendar.js
now goes through asset_ver() so browsers drop the cached old copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ubuntu
2026-10-19 13:10:20 +00:00
co-authored by Claude Opus 5.5
parent 152048d86a
commit 072e90e28d
2 changed files with 1 additions and 36 deletions
@@ -1,6 +1,6 @@
<div class="mainContentContainer" style="top:100px">
<div class="pageTitle"><?php echo $pageTitle;?></div>
<script src="<?php echo SITEURL;?>assets/js/calendar.js" defer></script>
<script src="<?php echo asset_ver('assets/js/calendar.js');?>" defer></script>
<div class="contianer">
<div class="calendar">
@@ -52,30 +52,4 @@ $(document).ready(function(){
});
function hasEventDay(year, monthNumber, dayNumber){
var month = monthNumber+1 > 9 ? (monthNumber+1) : '0' + (monthNumber+1);
var day = dayNumber > 9 ? dayNumber : '0' + dayNumber;
var selectedDate = year +'-'+ month +'-'+ day;
//console.log(selectedDate);
var status = 0;
$.ajax({
url: '<?php echo SITEURL;?>ajax',
type: 'POST',
data: {
action:'dayHasEvent',
dayDate: selectedDate
},
error: function() {
},
//dataType: 'json',
success: function(data) {
status = data;
return status;
console.log(status);
},
}).done(function(result){
});
return status;
}
</script>
-9
View File
@@ -70,15 +70,6 @@ const generateCalendar = (month, year) => {
for (let i = 1; i <= days_of_month[month] + first_day.getDay() - 1; i++) {
let day = document.createElement('div');
var l = hasEventDay(year, month, i);
console.log(l);
if(hasEventDay(year, month, i)){
day.classList.add('dayHasEvent');
console.log('leffut');
day.onclick = function(){
//this.parentElement.removeChild(this);
};
}
if (i >= first_day.getDay()) {
day.innerHTML = i - first_day.getDay() + 1;