Files
QuickAPI/get-counter.php
muzihuaner 6c5e43ae2d 初始化
2026-03-14 23:26:53 +08:00

25 lines
605 B
PHP

<?php
header('Content-Type: application/json; charset=utf-8');
$totalCount = 0;
// 读取api目录下所有子目录的counter.dat文件
$apiDir = __DIR__ . '/api';
if (is_dir($apiDir)) {
$subdirs = scandir($apiDir);
foreach ($subdirs as $subdir) {
$counterFile = $apiDir . '/' . $subdir . '/counter.dat';
if (is_file($counterFile)) {
$count = intval(file_get_contents($counterFile));
$totalCount += $count;
}
}
}
// 返回JSON格式的调用次数
echo json_encode([
'count' => $totalCount,
'timestamp' => date('Y-m-d H:i:s')
]);
?>