Can I check website down or not through IP using php script ?
-
hi, can i check website down or not through IP, lets me take an example, if i want to check google.com is down or not, and I using google.com IP that is "209.85.175.139", can i check it using IP ? i'm using this function but it seem dont work if i want to check using IP <?php function checksite($url) { $url = @parse_url($url); if (!$url) return false; $url = array_map('trim', $url); $url['port'] = (!isset($url['port'])) ? 80 : (int)$url['port']; $path = (isset($url['path'])) ? $url['path'] : '/'; $path .= (isset($url['query'])) ? "?$url[query]" : ''; if (isset($url['host']) && $url['host'] != gethostbyname($url['host'])) { $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30); if (!$fp) return false; fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $url[host]\r\n\r\n"); $headers = fread($fp, 4096); fclose($fp); if(preg_match('#^HTTP/.*\s+[(200|301|302… $headers)) { return true; } else return false; } else return false; } ?> anyone ?
-
Answer:
The code you provide is parsing urls not IP addresses. If you wanna use IP address instead, remove the $url part function checksite($ip) { ... $fp = fsockopen($ip, 80, $errno, $errstr, 30); ... } UPDATE: I did not manage to test if it works or not!
Altenato... at Yahoo! Answers Visit the source
Related Q & A:
- How can I force the login to a specific ip address?Best solution by Stack Overflow
- how can I check when the last list item has been deleted?Best solution by SharePoint
- How can I check if the CC and BCC is valid or not?Best solution by stackoverflow.com
- How can I check my missed online messages?Best solution by Yahoo! Answers
- How can I check how much I have downloaded?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.