PHP:¶ÌÐżà¿ØÍøÕ¾ÔËÐÐ״̬
Ô¤ÆÚ×¼±¸£º
Ò»¸ö139ÓÊÏ䣬ÊÕµ½Óʼþºó£¬¿ÉÒÔÃâ·Ñ¸øÄã¶ÌÐÅÌáÐÑ¡£Èç¹ûÄã²»ÐèÒª¶ÌÐÅÌáÐѹ¦ÄÜ£¬ÓÃʲôÓÊÏ䶼¿ÉÒÔ
ÁíÍâÒ»¸ö¿ÉÒÔÔËÐÐPHPÎļþµÄWeb·þÎñÆ÷£¨Ï൱ÓÚ¼à¿Ø·þÎñÆ÷£©£¬ÏÖÔÚÃâ·ÑµÄPHPÍøÕ¾¿Õ¼äºÜ¶à£¬ÉÏÍøËÑËÑ¡£Èç¹û½«PHP¼à¿ØÎļþ·Åµ½Äã×Ô¼ºµÄ·þÎñ
Æ÷ÉÏ£¬Õâ¸ö¼à¿ØÎļþÒ²¾ÍµÈÓÚ°ÚÉ裬·þÎñÆ÷¹ÒµôÁË£¬ËüÒ²ÎÞ·¨ÔËÐÐÁË£¬ÔõôÄÜÆðµ½¼à¿Ø×÷ÓÃÄØ£¿
1¡¢´´½¨¼à¿ØÎļþ
´ò¿ªÄãϲ»¶µÄÎı¾±à¼Æ÷£¬Ð½¨Ò»¸öPHPÎļþ£¬ÃüÃûΪmonitor.php¡£Õⲿ·Ö´úÂëÒ²ºÜ¼òµ¥£¬¾ÍÊÇÁ½¸öº¯Êý£¬Ò»¸öÓÃÓÚ²âÊÔ·þÎñÆ÷ÊÇ·ñ¿ÉÒÔ·Ã
ÎÊ£¬ÁíÒ»¸öÓÃÓÚ¸øÄã·¢ËÍÓʼþ֪ͨ
¸´ÖÆÕ³ÌùÒÔÏ´úÂëÖÁmonitor.phpÎļþ£º
<?php
function check($host, $find)
{
$fp = fsockopen($host, 80, $errno, $errstr, 10);
if (!$fp)
{
echo "$errstr ($errno)\n";
} else
{
$header = "GET / HTTP/1.1\r\n";
$header .= "Host: $host\r\n";
$header .= "Connection: close\r\n\r\n";
fputs($fp, $header);
while (!feof($fp))
{
$str .= fgets($fp, 1024);
}
fclose($fp);
return (strpos($str, $find) !== false);
}
}
function alert($host)
{
/* ÏÂÃæµÄyouremail@139.com¸Ä³ÉÄãµÄÓÊÏäµØÖ· */
mail('youremail@139.com', 'Monitoring', $host.' down');
}
/* ÏÂÃæµÄÍøÖ·¸Ä³ÉÄãÒª¼à¿ØµÄÍøÖ· */
$host = 'www.ludou.org';
/* ÏÂÃæµÄludou.org¸Ä³ÉÄãµÄÍøÕ¾Ê×Ò³Ô´´úÂëÖеÄÒ»¶ÎÌØÊâ×Ö·û´® */
$find = 'ludou.org';
if (!check($host, $find))
alert($host);
?>
µÚÒ»¸öº¯Êýcheck£¨£©£¬ÐèÒª´«µÝÁ½¸ö²ÎÊý£ºµÚÒ»$hostÊÇÄãÏëÒª¼à¿ØµÄÍøÕ¾£¨È磺www.crazyfrom.com£©£»µÚ¶þ¸ö$findÓÃ
ÓÚ²éÕÒÄãµÄÍøÕ¾Ê×Ò³Ô´´úÂëÖеÄÒ»¶Î×Ö·û´®£¬ÆäʵÌí¼ÓÕâ¸öµÄÄ¿µÄÊdzöÓÚ°²È«¿¼ÂÇ£¬Èç¹ûÄãµÄÊ×Ò³°üº¬Õâ¶Î×Ö·û´®£¬ËµÃ÷ÄãµÄÍøҳûÓб»Ð޸ģ¨È磺±»º§¿Í¶ñÒâÐÞ
¸Ä£©¡£
Èç¹ûÄãµÄÍøÕ¾ÎÞ·¨·ÃÎÊ»òÕß°²È«×Ö·û´®ÕÒ²»µ½£¬½«»áÔËÐÐalert£¨£©º¯Êý£¬¸øÄã·¢Ë͸澯Óʼþ¡£ÇëÈ·±£ÄãµÄ¼à¿ØÖ÷»ú¿ÉÒÔÕý³£Ê¹ÓÃPHPµÄ·¢ËÍÓʼþº¯Êý
mail£¨£©£¬·ñÔò½«ÎÞ·¨·¢ËÍÓʼþ£¬Ìæ´ú·½·¨ÊÇʹÓÃphpmailer
ºÃÁË£¬±£´æmonitor.php£¬²¢ÉÏ´«ÖÁÄãµÄ¼à¿Ø·þÎñÆ÷ÉÏ¡£
2¡¢ÉèÖÃÒ»¸ö¼Æ»®ÈÎÎñ
ÏÖÔÚÎÊÌâÓÖÀ´ÁË£¬ÒªÏëÈÃmonitor.phpÔËÐУ¬ÎÒÃǵÃÔÚä¯ÀÀÆ÷Öдò¿ªhttp://mymonitoring
Ïà¹ØÎĵµ£º
¹«Ë¾·´Ó¦Äͷɼҽ̺ͼæÖ°ºǫ́ÏÔʾµÄʱ¼ä¸úʵ¼Ê×¢²áµÄʱ¼äÏà²î8Сʱ¡£
·¢ÏÖʱ¼äÒ»Ö±¶Ô²»ÉÏ£¬date("Y-m-d h:i:s") ×ÜÊÇÓë·þÎñÆ÷ʱ¼ä²î8¸öСʱ£®ºóÀ´·¢ÏÖ£¬ÎÒÏÖÔڵĻúÆ÷ÉϵÄphpÊÇ5.14µÄ£®¡¡
ÔÀ´´Óphp5.1.0¿ªÊ¼£¬php.iniÀï¼ÓÈëÁËdate.timezoneÕâ¸öÑ¡ÏĬÈÏÇé¿öÏÂÊǹرյÄ
Ò²¾ÍÊÇÏÔʾµÄʱ¼ä£¨ÎÞÂÛÓÃʲôphpÃüÁ¶¼ÊǸñÁ ......
index.phpÎļþµÚÒ»ÐоÍÊÇ°üº¬ÁË
include_once('./common.php');
ÎļþËùÒÔÏȶÔcommon.phpÎļþ½âÎö
<?php
/*
[UCenter Home] (C) 2007-2008 Comsenz Inc.
$Id: common.php 10981 2009-01-14 03:05:20Z liguode $
*/
//¶¨ÒåÒ»¸ö³£Á¿£¬ÓÃÀ´ÔÚÆäËûÒ³ÃæÖУ¬·ÀÖ¹±»¶ñÒâÓû§Ö±½Óµ÷ÓÃÆäËûPHPÎļþ¡£
@def ......
Ò»¡¢zend studioµÄÅäÖÃ
1.µ½zendµÄ°²×°Ä¿Â¼ÏÂɾ³ýÁ½¸öÎļþ(¿ÉÓпÉÎÞ.ÖÁÉÙÎÒ²»É¾³ýÒ²²»Òƶ¯¿ÉÒÔ)
ÎҵݲװĿ¼£ºD:\Program Files\Zend\Zend Studio - 7.0.2\plugins\
ɾ³ýµÄÎļþÊÇ£ºcom.zend.php.debug.core_7.0.0.v20090607-1658.jar
&nbs ......
Õâ¸ö©¶´ÑϸñÉÏ˵²¢²»ÊÇ Nginx ºÍ PHP ±¾ÉíµÄ©¶´Ôì³ÉµÄ£¬¶øÊÇÓÉÅäÖÃÔì³ÉµÄ¡£ÔÚÎÒ֮ǰдµÄÐí¶àÅäÖÃÖУ¬¶¼ÆÕ±é´æÔÚÕâ¸ö©¶´¡£
¼òÒ×¼ì²â·½·¨£º
´ò¿ª Nginx + PHP ·þÎñÆ÷ÉϵÄÈÎÒâÒ»ÕÅͼƬ£¬È磺
http://blog.lrenwang.com/test.png
Èç¹ûÔÚͼƬÁ´½Óºó¼ÓÒ»´® /xxx.php £¨xxxΪÈÎÒâ×Ö·û£©ºó£¬È磺
http://blog.lrenwang.com/ ......
ÉùÃ÷£º²¹³ä·ÒëÁËÔÌûÖм¸´¦Î´·Òë´¦¡£
---------------------------------------------------- תÌû¿ªÊ¼ -------------------------------------------------------
PHPÖеÄCURLº¯Êý¿â£¨Client URL Library Function£©
curl_close - ¹Ø±ÕÒ»¸öcurl»á»°
curl_copy_handle - ¿½±´Ò»¸öcurlÁ¬½Ó×ÊÔ´µÄËùÓÐÄÚÈݺ ......