2. soruna gelince hostingin / domainin aktif olup olmadığını öğrenmenin bir kaç yolu var
ping atabilirsin (ama hostunda exec aktif olmalı);
if( exec("ping 93.89.226.24") ) {
echo exec("ping 93.89.226.24");
} else {
echo "bağlanılamadı";
}curl ile bağlanabilirsin (curl aktif olmalı ve daha hızlıdır)
function SiteKontrol($url=NULL)
{
if($url == NULL) return false;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode>=200 && $httpcode<300){
return true;
} else {
return false;
}
}
if(SiteKontrol("http://www.siteadresi.com/dosyaadi.php")){
echo "sorun yok";
} else {
echo "sorun var";
}