diff --git a/Templates/Ranking/ally_top10.tpl b/Templates/Ranking/ally_top10.tpl index 8b6dea11..a39c1ac3 100644 --- a/Templates/Ranking/ally_top10.tpl +++ b/Templates/Ranking/ally_top10.tpl @@ -21,6 +21,27 @@ echo "Row ".$i; } + // --- ADDED: Week and Medal Reset calculation (identical to Automation.php) --- + $week = 1; + $nextReset = time() + MEDALINTERVAL; + $q = mysqli_query($database->dblink, "SELECT lastgavemedal FROM ".TB_PREFIX."config LIMIT 1"); + if($q && $rc = mysqli_fetch_assoc($q)){ + $last = (int)$rc['lastgavemedal']; + if($last > 0){ + $nextReset = $last; + while($nextReset <= time()){ $nextReset += MEDALINTERVAL; } + } else { + $setDays = round(MEDALINTERVAL/86400); + $nextReset = $setDays < 7 ? strtotime(($setDays + 1).' day midnight') : strtotime('next monday'); + } + } + $wq = mysqli_query($database->dblink, "SELECT week FROM ".TB_PREFIX."medal ORDER BY week DESC LIMIT 1"); + if($wq && mysqli_num_rows($wq)){ $week = mysqli_fetch_assoc($wq)['week'] + 1; } + $left = max(0, $nextReset - time()); + $days = floor($left / 86400); + $timeLeft = gmdate("H:i:s", $left % 86400); + // --- END MEDAL TIMER --- + $result = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."alidata ORDER BY ap DESC, id DESC Limit 10"); $result2 = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."alidata WHERE id = '".$session->alliance."' ORDER BY ap DESC, id DESC Limit 1"); ?> @@ -31,6 +52,26 @@ + +
| + Week: Medal reset in: d + | +