Skip to content

Instantly share code, notes, and snippets.

@zoghal
Last active September 30, 2022 18:59
Show Gist options
  • Save zoghal/e57015def08221b8a9c5b6608233ebe3 to your computer and use it in GitHub Desktop.
Save zoghal/e57015def08221b8a9c5b6608233ebe3 to your computer and use it in GitHub Desktop.
simple script for test CURL connections in iran
<?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