├── LICENSE ├── Proxiesfo-Users └── iproxy.php ├── README.md ├── iproxy.php └── proxy.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Furqonflynn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Proxiesfo-Users/iproxy.php: -------------------------------------------------------------------------------- 1 | "\033[32m", 6 | 'br' => "\033[34m", 7 | 'red' => "\033[31m", 8 | 'yl' => "\033[33m", 9 | 'gb' => "\033[4m", 10 | 'or' => "\033[35m", 11 | 'cy' => "\033[36m", 12 | 'oc' => "\033[95m", 13 | 'am' => "\033[91m", 14 | 'rt' => "\033[0m" 15 | ]; 16 | 17 | // Check if cURL extension is installed 18 | if (!extension_loaded('curl')) { 19 | $installInstructions = "Error: PHP cURL extension is not installed.\n\n"; 20 | $installInstructions .= "Installation instructions:\n\n"; 21 | $installInstructions .= "For Windows:\n"; 22 | $installInstructions .= "1. Open php.ini file\n"; 23 | $installInstructions .= "2. Uncomment extension=curl\n"; 24 | $installInstructions .= "3. Restart your web server\n\n"; 25 | $installInstructions .= "For Linux (Ubuntu/Debian):\n"; 26 | $installInstructions .= "sudo apt-get install php-curl\n"; 27 | $installInstructions .= "sudo service apache2 restart\n\n"; 28 | $installInstructions .= "For macOS:\n"; 29 | $installInstructions .= "1. Using Homebrew: brew install php@8.x\n"; 30 | $installInstructions .= "2. Or modify php.ini to enable curl extension\n"; 31 | die($cl['red'] . $installInstructions . $cl['rt']); 32 | } 33 | 34 | function CoderMark($cl, &$CoderMarkPrinted) { 35 | if (!$CoderMarkPrinted) { 36 | echo " 37 | ╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━┳╮ 38 | ┃╭━━╯╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━━┫┃{$cl['gr']} 39 | ┃╰━━┳╮╭┳━┳━━┳━━┳━╮┃╰━━┫┃╭╮╱╭┳━╮╭━╮ 40 | ┃╭━━┫┃┃┃╭┫╭╮┃╭╮┃╭╮┫╭━━┫┃┃┃╱┃┃╭╮┫╭╮╮{$cl['br']} 41 | ┃┃╱╱┃╰╯┃┃┃╰╯┃╰╯┃┃┃┃┃╱╱┃╰┫╰━╯┃┃┃┃┃┃┃ 42 | ╰╯╱╱╰━━┻╯╰━╮┣━━┻╯╰┻╯╱╱╰━┻━╮╭┻╯╰┻╯╰╯{$cl['rt']} 43 | ╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱╱╭━╯┃ 44 | ╱╱╱╱╱╱╱╱╱╱╱╰╯╱╱╱╱╱╱╱╱╱╱╱╰━━╯ 45 | \n{$cl['gr']} Proxy IP Checker {$cl['am']} v.0.1 {$cl['rt']} 46 | {$cl['gr']}-------------------------------------- 47 | \n{$cl['yl']}[+]{$cl['rt']} GH : {$cl['br']}https://github.com/cmalf/ 48 | \n{$cl['gr']}-------------------------------------- 49 | "; 50 | $CoderMarkPrinted = true; 51 | } 52 | } 53 | 54 | function checkProxy($proxyLine) { 55 | try { 56 | $parts = explode('://', $proxyLine); 57 | if (count($parts) !== 2) { 58 | throw new Exception('Invalid proxy format'); 59 | } 60 | 61 | [$protocol, $rest] = $parts; 62 | 63 | if (!function_exists('curl_init')) { 64 | throw new Exception('cURL extension is not installed'); 65 | } 66 | 67 | $ch = curl_init(); 68 | if ($ch === false) { 69 | throw new Exception('Failed to initialize cURL'); 70 | } 71 | 72 | curl_setopt($ch, CURLOPT_URL, 'https://ipwhois.app/json/'); 73 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 74 | curl_setopt($ch, CURLOPT_PROXY, $rest); 75 | curl_setopt($ch, CURLOPT_PROXYTYPE, $protocol === 'http' ? CURLPROXY_HTTP : CURLPROXY_SOCKS5); 76 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); 77 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 78 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'); 79 | 80 | $response = curl_exec($ch); 81 | $error = curl_error($ch); 82 | $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 83 | curl_close($ch); 84 | 85 | if ($error) { 86 | throw new Exception($error); 87 | } 88 | 89 | if ($httpCode !== 200) { 90 | throw new Exception("HTTP Error: $httpCode"); 91 | } 92 | 93 | $data = json_decode($response, true); 94 | if (!$data) { 95 | throw new Exception('Invalid response from server'); 96 | } 97 | 98 | return [ 99 | 'proxy' => $proxyLine, 100 | 'success' => true, 101 | 'ip' => $data['ip'], 102 | 'country' => $data['country'], 103 | 'region' => $data['region'], 104 | 'city' => $data['city'] 105 | ]; 106 | } catch (Exception $error) { 107 | return [ 108 | 'proxy' => $proxyLine, 109 | 'success' => false, 110 | 'error' => $error->getMessage() 111 | ]; 112 | } 113 | } 114 | 115 | function checkProxyList() { 116 | global $cl; 117 | try { 118 | echo "{$cl['yl']}Enter List Proxies File Name To check: {$cl['rt']}"; 119 | $filename = trim(readline()); 120 | 121 | if (!file_exists($filename)) { 122 | throw new Exception("File not found: $filename"); 123 | } 124 | 125 | $proxyList = array_filter( 126 | array_map( 127 | 'trim', 128 | file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) 129 | ) 130 | ); 131 | 132 | echo "\nLoading " . count($proxyList) . " proxies...\n"; 133 | 134 | $validProxies = []; 135 | foreach ($proxyList as $proxy) { 136 | $result = checkProxy($proxy); 137 | 138 | if ($result['success']) { 139 | // New logic: accept proxy if country is NOT United States. 140 | if ($result['country'] !== 'United States') { 141 | echo "{$cl['br']}{$proxy}{$cl['rt']} -> IP: {$cl['gr']}{$result['ip']}{$cl['rt']} ({$result['country']}) ✓\n"; 142 | $validProxies[] = $proxy; 143 | } else { 144 | echo "{$cl['red']}{$proxy}{$cl['rt']} -> IP: {$cl['gr']}{$result['ip']}{$cl['rt']} ({$result['country']}) ✗\n"; 145 | } 146 | } else { 147 | echo "{$cl['red']}{$proxy}{$cl['rt']} -> {$cl['oc']}{$result['error']}{$cl['rt']} ✗\n"; 148 | } 149 | } 150 | 151 | file_put_contents($filename, implode("\n", $validProxies)); 152 | 153 | echo "\nSummary:\n"; 154 | echo "Total proxies processed: " . count($proxyList) . "\n"; 155 | echo "Valid non-US proxies saved: " . count($validProxies) . "\n"; 156 | echo "Removed proxies: " . (count($proxyList) - count($validProxies)) . "\n"; 157 | echo "\nProxy list has been updated with only working non-US proxies.\n"; 158 | 159 | } catch (Exception $error) { 160 | echo "{$cl['red']}Error: {$cl['rt']}" . $error->getMessage() . "\n"; 161 | } 162 | } 163 | 164 | // Run the checker 165 | CoderMark($cl, $CoderMarkPrinted); 166 | checkProxyList(); 167 | ?> 168 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🌐 proxy-ip-checker-php 2 | 3 | A `PHP` script to efficiently check the validity and IP of various proxy types (`SOCKS, SOCKS5, HTTP, HTTPS`). 4 | 5 | # 🧐 How To Do 6 | 7 | - Clone This Repository 8 | ```bash 9 | git clone https://github.com/cmalf/proxy-ip-checker-php.git 10 | ``` 11 | - Go To the Folder 12 | ```bash 13 | cd proxy-ip-checker-php 14 | ``` 15 | - Put Your Proxy to proxy.txt (Format Proxy is `protocol://username:password@hostname:port` ) 16 | - Run The Script 17 | ```bash 18 | php iproxy.php 19 | ``` 20 | # 📸 Screenshot 21 | 22 | ![Screenshot 2024-12-21 at 22 32 39](https://github.com/user-attachments/assets/acc0138b-5d96-4772-a328-ce18c3105b2f) 23 | 24 | ![Screenshot 2024-12-21 at 22 37 02](https://github.com/user-attachments/assets/49f4958e-082e-4988-9719-2a41f7fe8de0) 25 | -------------------------------------------------------------------------------- /iproxy.php: -------------------------------------------------------------------------------- 1 | "\033[32m", 6 | 'br' => "\033[34m", 7 | 'red' => "\033[31m", 8 | 'yl' => "\033[33m", 9 | 'gb' => "\033[4m", 10 | 'or' => "\033[35m", 11 | 'cy' => "\033[36m", 12 | 'oc' => "\033[95m", 13 | 'am' => "\033[91m", 14 | 'rt' => "\033[0m" 15 | ]; 16 | 17 | // Check if cURL extension is installed 18 | if (!extension_loaded('curl')) { 19 | $installInstructions = "Error: PHP cURL extension is not installed.\n\n"; 20 | $installInstructions .= "Installation instructions:\n\n"; 21 | $installInstructions .= "For Windows:\n"; 22 | $installInstructions .= "1. Open php.ini file\n"; 23 | $installInstructions .= "2. Uncomment extension=curl\n"; 24 | $installInstructions .= "3. Restart your web server\n\n"; 25 | $installInstructions .= "For Linux (Ubuntu/Debian):\n"; 26 | $installInstructions .= "sudo apt-get install php-curl\n"; 27 | $installInstructions .= "sudo service apache2 restart\n\n"; 28 | $installInstructions .= "For macOS:\n"; 29 | $installInstructions .= "1. Using Homebrew: brew install php@8.x\n"; 30 | $installInstructions .= "2. Or modify php.ini to enable curl extension\n"; 31 | die($cl['red'] . $installInstructions . $cl['rt']); 32 | } 33 | 34 | function CoderMark($cl, &$CoderMarkPrinted) { 35 | if (!$CoderMarkPrinted) { 36 | echo " 37 | ╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━┳╮ 38 | ┃╭━━╯╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━━┫┃{$cl['gr']} 39 | ┃╰━━┳╮╭┳━┳━━┳━━┳━╮┃╰━━┫┃╭╮╱╭┳━╮╭━╮ 40 | ┃╭━━┫┃┃┃╭┫╭╮┃╭╮┃╭╮┫╭━━┫┃┃┃╱┃┃╭╮┫╭╮╮{$cl['br']} 41 | ┃┃╱╱┃╰╯┃┃┃╰╯┃╰╯┃┃┃┃┃╱╱┃╰┫╰━╯┃┃┃┃┃┃┃ 42 | ╰╯╱╱╰━━┻╯╰━╮┣━━┻╯╰┻╯╱╱╰━┻━╮╭┻╯╰┻╯╰╯{$cl['rt']} 43 | ╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱╱╭━╯┃ 44 | ╱╱╱╱╱╱╱╱╱╱╱╰╯╱╱╱╱╱╱╱╱╱╱╱╰━━╯ 45 | \n{$cl['gr']} Proxy IP Checker {$cl['am']} v.0.1 {$cl['rt']} 46 | {$cl['gr']}-------------------------------------- 47 | \n{$cl['yl']}[+]{$cl['rt']} GH : {$cl['br']}https://github.com/cmalf/ 48 | \n{$cl['gr']}-------------------------------------- 49 | "; 50 | $CoderMarkPrinted = true; 51 | } 52 | } 53 | 54 | function checkProxy($proxyLine) { 55 | try { 56 | $parts = explode('://', $proxyLine); 57 | if (count($parts) !== 2) { 58 | throw new Exception('Invalid proxy format'); 59 | } 60 | 61 | [$protocol, $rest] = $parts; 62 | 63 | $ch = curl_init(); 64 | curl_setopt($ch, CURLOPT_URL, 'https://ipinfo.io/json'); 65 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 66 | curl_setopt($ch, CURLOPT_PROXY, $rest); 67 | curl_setopt($ch, CURLOPT_PROXYTYPE, $protocol === 'http' ? CURLPROXY_HTTP : CURLPROXY_SOCKS5); 68 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); 69 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 70 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'); 71 | 72 | $response = curl_exec($ch); 73 | $error = curl_error($ch); 74 | $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 75 | curl_close($ch); 76 | 77 | if ($error) { 78 | throw new Exception($error); 79 | } 80 | 81 | if ($httpCode !== 200) { 82 | throw new Exception("HTTP Error: $httpCode"); 83 | } 84 | 85 | $data = json_decode($response, true); 86 | if (!$data) { 87 | throw new Exception('Invalid response from server'); 88 | } 89 | 90 | return [ 91 | 'proxy' => $proxyLine, 92 | 'success' => true, 93 | 'ip' => $data['ip'], 94 | 'country' => $data['country'], 95 | 'region' => $data['region'], 96 | 'city' => $data['city'] 97 | ]; 98 | } catch (Exception $error) { 99 | return [ 100 | 'proxy' => $proxyLine, 101 | 'success' => false, 102 | 'error' => $error->getMessage() 103 | ]; 104 | } 105 | } 106 | 107 | function checkProxyList() { 108 | global $cl; 109 | try { 110 | $proxyList = array_filter( 111 | array_map( 112 | 'trim', 113 | file('proxy.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) 114 | ) 115 | ); 116 | 117 | echo "Loading " . count($proxyList) . " proxies...\n"; 118 | 119 | $results = []; 120 | foreach ($proxyList as $proxy) { 121 | $result = checkProxy($proxy); 122 | 123 | if ($result['success']) { 124 | echo "{$cl['br']}{$proxy}{$cl['rt']} -> IP: {$cl['gr']}{$result['ip']}{$cl['rt']} ({$result['country']})\n"; 125 | } else { 126 | echo "{$cl['red']}{$proxy}{$cl['rt']} -> IP: {$cl['oc']}{$result['error']}{$cl['rt']}\n"; 127 | } 128 | 129 | $results[] = $result; 130 | } 131 | 132 | $timestamp = date('Y-m-d-H-i-s'); 133 | $outputFile = "proxy_check_results_{$timestamp}.json"; 134 | 135 | file_put_contents($outputFile, json_encode($results, JSON_PRETTY_PRINT)); 136 | echo "\nResults saved to {$outputFile}\n"; 137 | 138 | $working = count(array_filter($results, fn($r) => $r['success'])); 139 | echo "\nSummary:\n"; 140 | echo "Total proxies: " . count($results) . "\n"; 141 | echo "Working: {$working}\n"; 142 | echo "Failed: " . (count($results) - $working) . "\n"; 143 | 144 | } catch (Exception $error) { 145 | echo 'Error reading proxy file: ' . $error->getMessage() . "\n"; 146 | } 147 | } 148 | 149 | // Run the checker 150 | CoderMark($cl, $CoderMarkPrinted); 151 | checkProxyList(); 152 | -------------------------------------------------------------------------------- /proxy.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmalf/proxy-ip-checker-php/3ef9eb3e5235b28a506f09899429e5acbeed3187/proxy.txt --------------------------------------------------------------------------------