Last active
September 30, 2022 18:59
-
-
Save zoghal/e57015def08221b8a9c5b6608233ebe3 to your computer and use it in GitHub Desktop.
simple script for test CURL connections in iran
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$urls = [ | |
// در داخل ایران هاست شده است. | |
'https://farsi.khamenei.ir/', | |
'https://toofan.soozanchi.ir', | |
// در خارج ایران هاست [github page] شده است. | |
'https://libre.font-store.ir', | |
// در خارج ایران هاست شده است. | |
'https://api.wordpress.org', | |
'https://www.php.net', | |
'https://docs.rs/' | |
]; | |
function testCurlConnection($url){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 20); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPGET, true); | |
curl_setopt($ch, CURLOPT_VERBOSE, true); | |
$streamVerboseHandle = fopen("php://temp", "w+"); | |
curl_setopt($ch, CURLOPT_STDERR, $streamVerboseHandle); | |
$responce = curl_exec($ch); | |
$error = curl_error($ch) ; | |
rewind($streamVerboseHandle); | |
$verboseLog = stream_get_contents($streamVerboseHandle); | |
echo "\n\n------------------------------------------------------\n\n"; | |
echo "\e[1;37;41m test url = " . $url . "\e[0m\n"; | |
echo "\e[1;32;40m ERROR : " . $error . "\e[0m\n\n"; | |
echo "\e[1;37;44m cUrl verbose information:\e[0m\n"; | |
echo "\e[0;37;40m" . htmlspecialchars($verboseLog). "\e[0m\n"; | |
} | |
foreach ($urls as $url){ | |
testCurlConnection($url); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment