-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsrc.php
More file actions
58 lines (58 loc) · 2.05 KB
/
Copy pathsrc.php
File metadata and controls
58 lines (58 loc) · 2.05 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
function cf_fe($token, $mail, $zonetag, $timestart)
{
$timenw = time();
$timestart = date("c", $timestart + 0.0001);
$limit = 1000;
$timeend = date("c", $timenw);
$url = "https://api.cloudflare.com/client/v4/graphql";
$data_arr = [
"query" => 'query ListFirewallEvents($zoneTag: string, $filter: FirewallEventsAdaptiveFilter_InputObject)
{
viewer {
zones(filter: { zoneTag: $zoneTag }) {
firewallEventsAdaptive(
filter: $filter
limit: ' . $limit . '
orderBy: [datetime_ASC]
) {
action
clientAsn
clientCountryName
clientIP
clientRequestPath
clientRequestQuery
datetime
source
userAgent
}
}
}
}',
"variables" => [
"zoneTag" => "$zonetag",
"filter" => [
"datetime_geq" => $timestart,
"datetime_leq" => $timeend,
],
],
];
$ch = curl_init();
$header = Array(
"X-Auth-Email: $mail",
"Authorization: Bearer $token",
"Content-Type: application/json"
);
$data_string = json_encode($data_arr);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data, true);
$answcf = $json['data']['viewer']['zones'][0]['firewallEventsAdaptive'];
foreach ($answcf as $key => $item) $answcf[$key]['datetime'] = date('c', strtotime($item['datetime']) + 60 * 60 * 3);
$json['data']['viewer']['zones'][0]['firewallEventsAdaptive'] = $answcf;
return $json;
}