0
0
mirror of https://codeberg.org/crimeflare/cloudflare-tor synced 2024-11-04 16:32:39 +00:00
cloudflare-tor/tool/example.json.is_cloudflare.php

57 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/*
2021-04-01 06:26:54 +00:00
How to use json file
2021-04-01 06:26:54 +00:00
1. Download .json files: https://codeberg.org/crimeflare/cloudflare-tor/src/branch/master/cloudflare_users/domains
2. Edit path: "/path/to/jsonfiles/"
*/
/*
2021-04-01 06:26:54 +00:00
is_listed_cf(string Domain)
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)) {
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)
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