-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautowork.php
More file actions
77 lines (68 loc) · 2.51 KB
/
Copy pathautowork.php
File metadata and controls
77 lines (68 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
ini_set('display_errors', 'Off'); // 关闭报错
define('ROOTS', dirname(__FILE__) . '/');
define('ROOT', dirname(ROOTS) . '/');
include './data/database/config.php';
include './data/database/db.php';
$work = $_GET['work'];
$key = $_GET['key'];
if ($key != file_get_contents('./data/autowork.key')) {
echo 'key_error';
exit;
}
// autowork 文件夹检测
if (!file_exists('./data/autowork')) {
mkdir('./data/autowork', 0755);
}
switch ($work) {
case 'save_user_api_information':
$success = 0;
$error = 0;
$total = 0;
$user = [];
$r = $pdo->query('select identification from user;');
foreach ($r as $row) {
array_push($user, $row['identification']);
}
foreach ($user as $id) {
$app = [];
$r = $pdo->query('select identification,api_times from app where host = "' . $id . '";');
foreach ($r as $row) {
array_push(
$app,
array(
'identification' => $row['identification'],
'api_times' => $row['api_times'],
)
);
}
if (!is_dir('./data/autowork/user_apitimes')) {
mkdir('./data/autowork/user_apitimes', 0755);
}
if (!is_dir('./data/autowork/user_apitimes/' . $id)) {
mkdir('./data/autowork/user_apitimes/' . $id, 0755);
}
foreach ($app as $row) {
if (!is_dir('./data/autowork/user_apitimes/' . $id . '/' . $row['identification'])) {
mkdir('./data/autowork/user_apitimes/' . $id . '/' . $row['identification'], 0755);
}
if (file_put_contents('./data/autowork/user_apitimes/' . $id . '/' . $row['identification'] . '/' . date('N'), $row['api_times'])) {
$success++;
} else {
$error++;
}
$total++;
}
}
echo 'ok:total=>' . $total . ';success=>' . $success . ';error=>' . $error;
break;
case 'clear_everyday_app_api_times':
$pdo->exec('update app set api_times = 0;');
echo 'clear_everyday_app_api_times ok!';
break;
case 'reset_0_auth':
$pdo->exec('update appauth set switch = 0 , activation_time = 0 , heartbeat = 0 , version = 0 , end_time = 0 where version = 0 and ' . time() . ' - activation_time >= 600;');
echo 'reset_0_auth ok!';
break;
}
?>