Quản trị net diễn đàn chia sẻ thông tin các thủ thuật mạng, internet bảo mật thông tin dành cho giới IT VIệt hy vọng là nơi bổ ích cho cộng đồng

Quản trị net diễn đàn chia sẻ thông tin các thủ thuật mạng, internet bảo mật thông tin dành cho giới IT VIệt hy vọng là nơi bổ ích cho cộng đồng (http://quantrinet.com/forum/index.php)
-   Tool, Website suppost for Webmaster (http://quantrinet.com/forum/forumdisplay.php?f=303)
-   -   [Code] Đọan script giúp theo dõi tình trạng website (http://quantrinet.com/forum/showthread.php?t=4696)

emailhoc 23-02-2010 09:38 AM

[Code] Đọan script giúp theo dõi tình trạng website
 
Bạn có thể có nhiều domain, mà không phải ngày nào bạn cũng tốn thời gian để kiểm tra theo dõi chúng (Website Monitoring).. đoạn code PHP dưới đây sẽ giúp bạn
  1. Tạo một file domain_names.txt với nội dung liệt kê mỗi domain của bạn trên một dòng. Sau đó upload file này lên một hosting.
  2. Tạo file site_test.txt trên thư mục root của mỗi domain với nội dung "The site is up".
  3. Tạo file domain_test.php với nội dung như sau

Mã:

<?php
 /*
 This script is used to validate that all of the websites in a list are operational.
 It actually reads the contents of a file on each website.
 This ensures the domain name is pointing where it should, the site is up, and at least one file is intact.
 It can help identify unauthorized DNS changes, server outages, or global file issues.
 It must be run from a server where none of the sites are located, or the DNS test will not be valid.  << IMPORTANT POINT
 /
 The script assumes that each site has a file named site_test.txt at the document root.
 That file must contain the text "The site is up" (no quotes or line break).
 /
 The only alteration to the script should be the $filename variable, which has the location of the domain name file.
 The domain name file is a text file with the domain names listed (i.e. example.com) one per line.
 The domain name file can be located on any server (you can use a url location).
 /
 The output of the script will list the domain names in green (OK) or red (problem).
 This script will not identify the specific problem with a domain, only that there is a problem.
 */
 $filename = "domain_names.txt";
 $site = file($filename);
 echo "<span style='font-weight: bold;'>Domain Validation</span><br>";
 foreach ($site as $domain) {
 $domain = preg_replace("#\r\n?|\n#", "", $domain);
 $testFile = @file_get_contents("http://" . $domain . "/site_test.txt");
 if ($testFile == "The site is up")
 echo "<span style='color: green;'>$domain</span><br>";
 else
 echo "<span style='color: red;'>$domain</span><br>";
 }
 ?>



Bây giờ là 10:42 AM. Giờ GMT +7

Diễn đàn tin học QuantriNet
quantrinet.com | quantrimang.co.cc
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.