mirror of
https://codeberg.org/crimeflare/cloudflare-tor
synced 2024-12-23 08:00:35 +00:00
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
|
<?php
|
||
|
/*
|
||
|
|
||
|
How to use json file
|
||
|
|
||
|
1. Download .json files: https://codeberg.org/crimeflare/cloudflare-tor/src/branch/master/cloudflare_users/domains
|
||
|
2. Edit path: "/path/to/jsonfiles/"
|
||
|
|
||
|
*/
|
||
|
|
||
|
|
||
|
/*
|
||
|
is_listed_cf(str Domain)
|
||
|
return
|
||
|
[false, false]: file error
|
||
|
[true, true]: is cloudflare
|
||
|
[true, false]: not listed
|
||
|
*/
|
||
|
function is_listed_cf($domain)
|
||
|
{
|
||
|
if (!in_array(substr($domain, 0, 1), ['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)) {
|
||
|
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];
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
is_cloudflare_cached(str Domain)
|
||
|
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
|
||
|
|