Chia Sẽ Kinh Nghiệm Về IT



Tìm Kiếm Với Google
-


Gởi Ðề Tài Mới  Gửi trả lời
 
Công Cụ Xếp Bài
Tuổi 23-02-2010, 09:38 AM   #1
emailhoc
Administrator
 
Gia nhập: Jul 2009
Trả Lời: 245
[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>"; 
 } 
 ?>
emailhoc vắng mặt   Trả lời ngay kèm theo trích dẫn này
Gửi trả lời


Công Cụ
Xếp Bài

Quyền Hạn Của Bạn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Hình Cảm xúc đang Mở
[IMG] đang Mở
Mã HTML đang Tắt




Bây giờ là 01:27 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.