You are viewing our Forum Archives. To view or take place in current topics click here.
[PHP] Website Status Checker [Source]
Posted:
[PHP] Website Status Checker [Source]Posted:
Status: Offline
Joined: Dec 31, 200914Year Member
Posts: 892
Reputation Power: 38
Status: Offline
Joined: Dec 31, 200914Year Member
Posts: 892
Reputation Power: 38
Hello TTG, here is a source of a site status checker. It is the same source used in the PHPacademy tutorial. It uses CURL and status codes to check whether the website is up or down. To get this to work on your host, make sure curl is enabled in ini.php. Any questions please post them.
<?php
function upordown($url) {
$cs = curl_init($url);
curl_setopt($cs, CURLOPT_NOBODY, true);
curl_setopt($cs, CURLOPT_FOLLOWLOCATION, true);
curl_exec($cs);
$status_code = curl_getinfo($cs, CURLINFO_HTTP_CODE);
return ($status_code == 200) ? true : false;
}
if (isset($_POST['url']) == true && empty($_POST['url']) == false) {
$url = trim($_POST['url']);
if (filter_var($url, FILTER_VALIDATE_URL) == true) {
if (upordown($url) == true) {
echo '<p style="color:green">That website is up!</p>';
} else {
echo '<p style="color:red">Sorry, that website is down!</p>';
}
} else {
echo '<p style="color:red">Invalid url!</p>';
}
}
?>
<form action="" method="post">
Up, or down? <input type="text" name="url"/>
<input type="submit"/>
</form>
#2. Posted:
Status: Offline
Joined: Oct 10, 201113Year Member
Posts: 2,175
Reputation Power: 94
Status: Offline
Joined: Oct 10, 201113Year Member
Posts: 2,175
Reputation Power: 94
Nice, now think about implementing this into something bigger. Even though its simple it could be useful.
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Dec 31, 200914Year Member
Posts: 892
Reputation Power: 38
Status: Offline
Joined: Dec 31, 200914Year Member
Posts: 892
Reputation Power: 38
Tolerated wrote Nice, now think about implementing this into something bigger. Even though its simple it could be useful.
If you do make sure to give credit to the original creator, Alex from PHPAcademy.
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Nov 11, 201212Year Member
Posts: 74
Reputation Power: 4
Status: Offline
Joined: Nov 11, 201212Year Member
Posts: 74
Reputation Power: 4
Thanks i am going to impliment this into my system that checks for the devise the user is using.
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.