2021-04-01 04:53:09 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
|
2021-04-01 06:26:54 +00:00
|
|
|
How to use json file
|
2021-04-01 04:53:09 +00:00
|
|
|
|
2021-04-06 01:53:04 +00:00
|
|
|
1. Download .json files: /cloudflare_users/domains
|
2021-04-01 06:26:54 +00:00
|
|
|
2. Edit path: "/path/to/jsonfiles/"
|
2021-04-01 04:53:09 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2021-04-01 06:26:54 +00:00
|
|
|
is_listed_cf(string Domain)
|
2021-04-01 04:53:09 +00:00
|
|
|
return
|
|
|
|
[false, false]: file error
|
|
|
|
[true, true]: is cloudflare
|
|
|
|
[true, false]: not listed
|
|
|
|
*/
|
|
|
|
function is_listed_cf($domain)
|
|
|
|
{
|
2021-04-02 05:42:16 +00:00
|
|
|
if (!in_array($domain[0], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], true)) {
|
2021-04-01 04:53:09 +00:00
|
|
|
return [false, false];
|
|
|
|
}
|
|
|
|
$got = @json_decode(file_get_contents('/path/to/jsonfiles/cloudflare_' . $domain[0] . '.json'), true);
|
|
|
|
if (!is_array($got)) {
|
|
|
|
return [false, false];
|
|
|
|
}
|
|
|
|
return isset($got[$domain]) ? [true, true] : [true, false];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-04-01 06:26:54 +00:00
|
|
|
is_cloudflare_cached(string Domain)
|
2021-04-01 04:53:09 +00:00
|
|
|
return
|
|
|
|
true: is cloudflare
|
|
|
|
false: not listed
|
|
|
|
*/
|
|
|
|
function is_cloudflare_cached($f)
|
|
|
|
{
|
|
|
|
global $tmpCacheCFlist;
|
|
|
|
if (!isset($tmpCacheCFlist)) {
|
|
|
|
$tmpCacheCFlist = [];
|
|
|
|
}
|
|
|
|
$d = $f;
|
|
|
|
//$d = get_domainname($f)[1];
|
|
|
|
if (isset($tmpCacheCFlist[$d])) {
|
|
|
|
return $tmpCacheCFlist[$d];
|
|
|
|
}
|
|
|
|
$tmpCacheCFlist[$d] = is_listed_cf($d)[1] ? true : false;
|
|
|
|
return $tmpCacheCFlist[$d];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// example
|
|
|
|
|
|
|
|
var_dump(is_cloudflare_cached('codeberg.org'));// false
|
|
|
|
|