mirror of
				https://codeberg.org/crimeflare/cloudflare-tor
				synced 2025-11-04 10:27:05 +01:00 
			
		
		
		
	Add 'tool/example.json.is_cloudflare.php'
This commit is contained in:
		
							parent
							
								
									048892d249
								
							
						
					
					
						commit
						3d3e70c381
					
				
					 1 changed files with 56 additions and 0 deletions
				
			
		
							
								
								
									
										56
									
								
								tool/example.json.is_cloudflare.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								tool/example.json.is_cloudflare.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue