';
$reval = false;
if (empty($rootDir)) $rootDir = DEDEROOT;
if (TestWriteable($d)) {
@file_put_contents($d . '/' . $filename, $testStr);
$remoteUrl = $siteuRL . '/' . str_replace($rootDir, '', str_replace("\\", '/', realpath($d))) . '/' . $filename;
$tempStr = @PostHost($remoteUrl);
$reval = (md5($d) == trim($tempStr)) ? true : false;
unlink($d . '/' . $filename);
return $reval;
} else {
return -1;
}
}
}
if (!function_exists('PostHost')) {
function PostHost($host, $data = '', $method = 'GET', $showagent = null, $port = null, $timeout = 30)
{
$parse = @parse_url($host);
if (empty($parse)) return false;
if ((int)$port > 0) {
$parse['port'] = $port;
} elseif (!@$parse['port']) {
$parse['port'] = '80';
}
$parse['host'] = str_replace(array('http://', 'https://'), array('', 'ssl://'), "$parse[scheme]://") . $parse['host'];
if (!$fp = @fsockopen($parse['host'], $parse['port'], $errnum, $errstr, $timeout)) {
return false;
}
$method = strtoupper($method);
$wlength = $wdata = $responseText = '';
$parse['path'] = str_replace(array('\\', '//'), '/', @$parse['path']) . "?" . @$parse['query'];
if ($method == 'GET') {
$separator = @$parse['query'] ? '&' : '';
substr($data, 0, 1) == '&' && $data = substr($data, 1);
$parse['path'] .= $separator . $data;
} elseif ($method == 'POST') {
$wlength = "Content-length: " . strlen($data) . "\r\n";
$wdata = $data;
}
$write = "$method $parse[path] HTTP/1.0\r\nHost: $parse[host]\r\nContent-type: application/x-www-form-urlencoded\r\n{$wlength}Connection: close\r\n\r\n$wdata";
@fwrite($fp, $write);
while ($data = @fread($fp, 4096)) {
$responseText .= $data;
}
@fclose($fp);
empty($showagent) && $responseText = trim(stristr($responseText, "\r\n\r\n"), "\r\n");
return $responseText;
}
}
if (!function_exists('TestAdminPWD')) {
//返回结果,-1:没有更改默认管理员名称 -2:没有更改默认管理员用户名和密码 0:没有发现默认账号
function TestAdminPWD()
{
global $dsql;
// 查询栏目表确定栏目所在的目录
$sql = "SELECT usertype,userid,pwd FROM #@__admin WHERE `userid`='admin'";
$row = $dsql->GetOne($sql);
if (is_array($row)) {
if ($row['pwd'] == 'f297a57a5a743894a0e4') {
return -2;
} else {
return -1;
}
} else {
return 0;
}
}
}
if (!function_exists('IsWritable')) {
// 检测是否可写
function IsWritable($pathfile)
{
$isDir = substr($pathfile, -1) == '/' ? true : false;
if ($isDir) {
if (is_dir($pathfile)) {
mt_srand((float)microtime() * 1000000);
$pathfile = $pathfile . 'dede_' . uniqid(mt_rand()) . '.tmp';
} elseif (@mkdir($pathfile)) {
return IsWritable($pathfile);
} else {
return false;
}
}
@chmod($pathfile, 0777);
$fp = @fopen($pathfile, 'ab');
if ($fp === false) return false;
fclose($fp);
$isDir && @unlink($pathfile);
return true;
}
}
// 检测权限
$safeMsg = array();
//if(TestExecuteable(DEDEROOT.'/data',$cfg_basehost) || TestExecuteable(DEDEROOT.'/uploads',$cfg_basehost))
//{
// $helpurl = "http://help.dedecms.com/install-use/server/2011/1109/2124.html";
// $safeMsg[] = '目前data、uploads有执行.php权限,非常危险,需要立即取消目录的执行权限!
//
// 查看如何取消';
//}
$dirname = str_replace('index_body.php', '', strtolower($_SERVER['PHP_SELF']));
if (preg_match("#[\\|/]dede[\\|/]#", $dirname)) {
$safeMsg[] = '默认管理目录为dede,需要立即将它更名;';
}
if (IsWritable(DEDEDATA . '/common.inc.php')) {
$safeMsg[] = '强烈建议data/common.inc.php文件属性设置为644(Linux/Unix)或只读(NT);';
}
$rs = TestAdminPWD();
if ($rs < 0) {
$linkurl = "马上修改";
switch ($rs) {
case -1:
$msg = "没有更改默认管理员名称admin,建议您修改为其他管理账号!{$linkurl}";
break;
case -2:
$msg = "没有更改默认的管理员名称和密码,强烈建议您进行更改!{$linkurl}";
break;
}
$safeMsg[] = $msg;
}
//if(PostHost($cfg_basehost.'/data/admin/ver.txt') === @file_get_contents(DEDEDATA.'/admin/ver.txt'))
//{
// $helpurl = 'http://help.dedecms.com/install-use/apply/2011/1110/2129.html';
// $safeMsg[] = '强烈建议将data目录搬移到Web根目录以外;查看如何搬迁';
//}
?>
0) {
?>
. |