-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpurge_cache.php
More file actions
110 lines (110 loc) · 3.3 KB
/
purge_cache.php
File metadata and controls
110 lines (110 loc) · 3.3 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/************************************\
| Telegram-канал: https://t.me/z_tds |
| Cloudflare API v.0.5 |
| Очистка кэша |
| Список аккаунтов: data/cf.txt |
| Список доменов: data/domains.txt |
\************************************/
@error_reporting(-1);
@ini_set('display_errors', 1);
@set_time_limit(0);
$num_domains = 200;//доменов на странице
/*Ниже ничего не изменяйте*/
echo "<!DOCTYPE html><html><head><title>CF API</title><script>window.stopScroll=0;scrollingElement=(document.scrollingElement||document.body);setTimeout(function(){scrollBottom();},1000*1);function scrollBottom(){if(window.stopScroll!=1){setTimeout(function(){scrollBottom();},1000*0.5);}scrollingElement.scrollTop=scrollingElement.scrollHeight;}</script></head><body>";
$success = '<span style="color:green">success</span>';
$error = '<span style="color:red">error</span>';
//список аккаунтов cf
$cf = file(__DIR__.'/data/cf.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if(empty($cf)){
output("Empty");
stop();
}
//список доменов
$domains = file(__DIR__.'/data/domains.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($cf as $v){
$v = explode(';', $v);
$email = $v[0];
$api_key = $v[1];
//headers
$headers = array();
$headers[] = "X-Auth-Email: $email";
$headers[] = "X-Auth-Key: $api_key";
$headers[] = "Content-Type: application/json";
//проверяем авторизацию
$url = 'https://api.cloudflare.com/client/v4/user';
$type = 'get';
curl();
output($email.'<br>');
if($auth_code == 200 && $res->success){
output("authorization: $success<br><br>");
$t = '';
clear();
if(empty($t)){
output("not found<br>");
}
}
else{
output("authorization: $error<br>");
}
output('--------------------<br>');
}
stop();
//
function clear(){
global $url, $res, $name, $num_domains, $domains, $type, $data, $t;
//получаем список доменов и их идентификаторы
$url = "https://api.cloudflare.com/client/v4/zones?page=1&per_page=$num_domains";
$type = 'get';
curl();
output('domains: '.count($res->result).'<br>');
$res_1 = $res;
$data = '{"purge_everything":true}';
foreach($res_1->result as $e1){
$name = $e1->name;
$id = $e1->id;
$url = "https://api.cloudflare.com/client/v4/zones/$id/purge_cache";
if(empty($domains) || in_array($name, $domains)){
$t = 1;
$type = 'post';
curl();
}
}
}
//
function curl(){
global $url, $headers, $data, $name, $res, $type, $success, $error, $auth_code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if($type == 'post'){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$res = json_decode(curl_exec($ch));
$auth_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($type == 'post'){
if($res->success){
output("$name => $success<br>");
}
else{
output("$name => $error<br>");
}
}
}
//
function output($str){
echo $str;
ob_flush();
flush();
}
//
function stop(){
echo "<script>window.stopScroll=1;</script></body></html>";
exit();
}
?>