转移 wp-config.php 文件

因为 wp-config.php 默认就是在根目录的,很多人就直接会对准这个目标已经攻击,因此我们还可以让 wp-config.php 文件搬个家~

清空 wp-config,php 的内容,加入:

<?php
if ( !defined('ABSPATH') )
  define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'path/to/wp-config.php');

PHP中转换twitter链接

function twitterify($ret) {
$ret = preg_replace("#(^|[n ])([w]+?://[w]+[^ "nrt< ]*)#", "1<a href="2" target="_blank">2</a>", $ret);
$ret = preg_replace("#(^|[n ])((www|ftp).[^ "tnr< ]*)#", "1<a href="http://2" target="_blank">2</a>", $ret);
$ret = preg_replace("/@(w+)/", "<a href="http://www.twitter.com/1" target="_blank">@1</a>", $ret);
$ret = preg_replace("/#(w+)/", "<a href="http://twitter.com/search?q=1" target="_blank">#1</a>", $ret);
return $ret;
}

用PHP监控网站在线状态

<?php
/**
*
* @param string $url
* @return boolean
*/
function SiteMonitorBot($url) {

$agent = ‘Mozilla/5.0 (compatible; SiteMonitorBot/1.0; +http://www.xiaokyun.com)’;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

$content = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

//echo $http_code.'<br>’;

if (($http_code >= 200 && $http_code <= 300) // (!empty($content) &&
|| $http_code == 301 || $http_code == 302 || $http_code == 307) { //允许跳转
return true;
} else {
return false;
}
}

ignore_user_abort(true);
set_time_limit(0);
while (true) {
SiteMonitorBot(‘http://www.xiaokyun.com’);
sleep(900); //每隔15分钟自动运行
}

?>

Get IP with PHP

<?php

$names = file(‘sites.txt’);
foreach ($names as $name) {
$ip = gethostbyname($name);
echo ‘<li>’ . $ip . ‘</li>’;
}

?>

PHP Ping

<?php

function ping($host, $port, $timeout) {
$tB = microtime(true);
$fP = fSockOpen($host, $port, $errno, $errstr, $timeout);
if (!$fP) { return "down"; }
$tA = microtime(true);
return round((($tA – $tB) * 1000), 0)." ms";
}

echo ping(‘www.google.com’, 80, 10);

?>