初始化
This commit is contained in:
24
get-counter.php
Normal file
24
get-counter.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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')
|
||||
]);
|
||||
?>
|
||||
Reference in New Issue
Block a user