aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author7trey <7trey@noreply.codeberg.org>2021-04-01 06:53:09 +0200
committer7trey <7trey@noreply.codeberg.org>2021-04-01 06:53:09 +0200
commit3d3e70c3811367605c8e41514760b2f20a9dae4c (patch)
tree23c00e3d5a717144a22449b8258512fd61baacab
parent048892d2499aaad75ad9b958b88cba22bfdc8edd (diff)
downloadcloudflare-tor-3d3e70c3811367605c8e41514760b2f20a9dae4c.tar.lz
cloudflare-tor-3d3e70c3811367605c8e41514760b2f20a9dae4c.tar.xz
cloudflare-tor-3d3e70c3811367605c8e41514760b2f20a9dae4c.zip
Add 'tool/example.json.is_cloudflare.php'
-rw-r--r--tool/example.json.is_cloudflare.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/tool/example.json.is_cloudflare.php b/tool/example.json.is_cloudflare.php
new file mode 100644
index 00000000..104adf60
--- /dev/null
+++ b/tool/example.json.is_cloudflare.php
@@ -0,0 +1,56 @@
+<?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
+