Tuesday, March 22, 2011

Check whether site is down or good using php

Below is the function to check whether the site is down or good using php.

function VisitSite($url){
    $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL,$url );
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch,CURLOPT_VERBOSE,false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    $page=curl_exec($ch);
    //echo curl_error($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if($httpcode >= 200 && $httpcode < 300){
        return true;
    }
    else {
        return false;
    }
}
if(VisitSite('http://www.google.com')){
       echo "Website looks Good";
}else{
      echo "Website looks Down";
}
 

Saturday, March 5, 2011

Photoshop Shortcuts

Photoshop shortcuts. Please check the below image for the photograph shortcuts. This may help you.

If I miss any of them, please make a comment so that I can also know it.





 

Wednesday, February 23, 2011

Change Page title using Javascript

Code to change the Page title using Javascript is shown below.

document.title = 'Page Title has been Changed using Javascript';


Monday, January 31, 2011

Auto Refresh a Div or an Element using Jquery

Below is the code to refresh a div or an element using Jquery.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Refresh</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function()
{
$('#replace_content').load('
replace_content.php');
}, 1000);
</script>
<style type="text/css">
#shouts { background: #36F; height: 200px; overflow: auto; width: 300px; }
</style>
</head>

<body>
<div id="replace_content"><?php include'replace_content.php'?></div>
</body>
</html>