Moderator: Moderators
<?php
$host = "polarhome.com";
$port = "80";
$sock = socket_create(AF_INET, SOCK_STREAM, TCP);
socket_set_block($sock);
socket_connect($sock, $host, $port);
if (socket_strerror(socket_last_error($sock)) == "Success") {
echo "Ok"; // Redirect code
}
else {
echo "err"; // And code again ;)
}
socket_close($sock);
?>
zoli wrote:Uros, this is a good solution. It would be desirable to add functionality to check his homepages's url instead of polarhome web server. They are not connected and polarhome's homepage might work while redhat is down or just the web server on redhat does not work.
<?php
$host = "polarhome.com";
$port = "753";
$sock = socket_create(AF_INET, SOCK_STREAM, TCP);
socket_set_block($sock);
socket_connect($sock, $host, $port);
if (socket_strerror(socket_last_error($sock)) == "Success") {
echo "Ok"; // Redirect code
}
else {
echo "err"; // And code again ;)
}
socket_close($sock);
?>
Warning: socket_create() expects parameter 3 to be long, string given in /home/m/mko/public_html/index.php on line 10
Warning: socket_set_block() expects parameter 1 to be resource, null given in /home/m/mko/public_html/index.php on line 11
Warning: socket_connect() expects parameter 1 to be resource, null given in /home/m/mko/public_html/index.php on line 12
Warning: socket_last_error() expects parameter 1 to be resource, null given in /home/m/mko/public_html/index.php on line 13
Ok
Warning: socket_close() expects parameter 1 to be resource, null given in /home/m/mko/public_html/index.php on line 19
Fatal error: Call to undefined function: socket_create() in /data/members/free/tripod/uk/m/k/o/mkozel/htdocs/test.php on line 20
Another host reccomendation will be useful.Warning: socket_create() has been disabled for security reasons in
<?php
$conf_here = 1; // <- DO NOT EDIT THIS
// Location of the webpage that is redirected when
// every thing is ok. Must start with http://
$ok_loc = "http://www.polarhome.com:753/~mko/blog/";
// Print error, or redirect to another page?
// 1 = Print error | 0 = Redirect
$err_type = 0;
// Location of the webpage that is redirected when
// something is not right. Must start with http://
// Used if $err_type is set to 0
$err_loc = "http://ustkat.blogspot.com/";
// Error message
// Used when $err_type is set to 1
$err_message = "Soory... Webapge currently unavailable.";
// Host we are checking
$host_check = "polarhome.com";
// Port we are checking
$port_check = 753;
?>
Users browsing this forum: No registered users and 7 guests