国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

209 строки
6.2KB

  1. <?php
  2. @set_time_limit(0);
  3. require_once(dirname(__FILE__)."/config.php");
  4. AjaxHead();
  5. if(!function_exists('TestWriteable'))
  6. {
  7. // 检测是否可写
  8. function TestWriteable($d, $c=false)
  9. {
  10. $tfile = '_write_able.txt';
  11. $d = preg_replace("/\/$/", '', $d);
  12. $fp = @fopen($d.'/'.$tfile,'w');
  13. if(!$fp)
  14. {
  15. if( $c==false )
  16. {
  17. @chmod($d, 0777);
  18. return false;
  19. }
  20. else return TestWriteable($d, true);
  21. }
  22. else
  23. {
  24. fclose($fp);
  25. return @unlink($d.'/'.$tfile) ? true : false;
  26. }
  27. }
  28. }
  29. if(!function_exists('TestExecuteable'))
  30. {
  31. // 检查是否具目录可执行
  32. function TestExecuteable($d='.', $siteuRL='', $rootDir='') {
  33. $testStr = '<'.chr(0x3F).'p'.chr(hexdec(68)).chr(112)."\n\r";
  34. $filename = md5($d).'.php';
  35. $testStr .= 'function test(){ echo md5(\''.$d.'\');}'."\n\rtest();\n\r";
  36. $testStr .= chr(0x3F).'>';
  37. $reval = false;
  38. if(empty($rootDir)) $rootDir = DEDEROOT;
  39. if (TestWriteable($d))
  40. {
  41. @file_put_contents($d.'/'.$filename, $testStr);
  42. $remoteUrl = $siteuRL.'/'.str_replace($rootDir, '', str_replace("\\", '/',realpath($d))).'/'.$filename;
  43. $tempStr = @PostHost($remoteUrl);
  44. $reval = (md5($d) == trim($tempStr))? true : false;
  45. unlink($d.'/'.$filename);
  46. return $reval;
  47. } else
  48. {
  49. return -1;
  50. }
  51. }
  52. }
  53. if(!function_exists('PostHost'))
  54. {
  55. function PostHost($host,$data='',$method='GET',$showagent=null,$port=null,$timeout=30){
  56. $parse = @parse_url($host);
  57. if (empty($parse)) return false;
  58. if ((int)$port>0) {
  59. $parse['port'] = $port;
  60. } elseif (!@$parse['port']) {
  61. $parse['port'] = '80';
  62. }
  63. $parse['host'] = str_replace(array('http://','https://'),array('','ssl://'),"$parse[scheme]://").$parse['host'];
  64. if (!$fp=@fsockopen($parse['host'],$parse['port'],$errnum,$errstr,$timeout)) {
  65. return false;
  66. }
  67. $method = strtoupper($method);
  68. $wlength = $wdata = $responseText = '';
  69. $parse['path'] = str_replace(array('\\','//'),'/',@$parse['path'])."?".@$parse['query'];
  70. if ($method=='GET') {
  71. $separator = @$parse['query'] ? '&' : '';
  72. substr($data,0,1)=='&' && $data = substr($data,1);
  73. $parse['path'] .= $separator.$data;
  74. } elseif ($method=='POST') {
  75. $wlength = "Content-length: ".strlen($data)."\r\n";
  76. $wdata = $data;
  77. }
  78. $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";
  79. @fwrite($fp,$write);
  80. while ($data = @fread($fp, 4096)) {
  81. $responseText .= $data;
  82. }
  83. @fclose($fp);
  84. empty($showagent) && $responseText = trim(stristr($responseText,"\r\n\r\n"),"\r\n");
  85. return $responseText;
  86. }
  87. }
  88. if(!function_exists('TestAdminPWD'))
  89. {
  90. //返回结果,-1:没有更改默认管理员名称 -2:没有更改默认管理员用户名和密码 0:没有发现默认账号
  91. function TestAdminPWD()
  92. {
  93. global $dsql;
  94. // 查询栏目表确定栏目所在的目录
  95. $sql = "SELECT usertype,userid,pwd FROM #@__admin WHERE `userid`='admin'";
  96. $row = $dsql->GetOne($sql);
  97. if(is_array($row))
  98. {
  99. if($row['pwd'] == 'f297a57a5a743894a0e4')
  100. {
  101. return -2;
  102. } else {
  103. return -1;
  104. }
  105. } else {
  106. return 0;
  107. }
  108. }
  109. }
  110. if(!function_exists('IsWritable'))
  111. {
  112. // 检测是否可写
  113. function IsWritable($pathfile) {
  114. $isDir = substr($pathfile,-1)=='/' ? true : false;
  115. if ($isDir) {
  116. if (is_dir($pathfile)) {
  117. mt_srand((double)microtime()*1000000);
  118. $pathfile = $pathfile.'dede_'.uniqid(mt_rand()).'.tmp';
  119. } elseif (@mkdir($pathfile)) {
  120. return IsWritable($pathfile);
  121. } else {
  122. return false;
  123. }
  124. }
  125. @chmod($pathfile,0777);
  126. $fp = @fopen($pathfile,'ab');
  127. if ($fp===false) return false;
  128. fclose($fp);
  129. $isDir && @unlink($pathfile);
  130. return true;
  131. }
  132. }
  133. // 检测权限
  134. $safeMsg = array();
  135. //if(TestExecuteable(DEDEROOT.'/data',$cfg_basehost) || TestExecuteable(DEDEROOT.'/uploads',$cfg_basehost))
  136. //{
  137. // $helpurl = "http://help.dedecms.com/install-use/server/2011/1109/2124.html";
  138. // $safeMsg[] = '目前data、uploads有执行.php权限,非常危险,需要立即取消目录的执行权限!
  139. // <a href="testenv.php" title="全面检测"><img src="images/btn_fullscan.gif" /></a>
  140. // <a href="'.$helpurl.'" style="color:blue;text-decoration:underline;" target="_blank">查看如何取消</a>';
  141. //}
  142. $dirname = str_replace('index_body.php', '', strtolower($_SERVER['PHP_SELF']));
  143. if(preg_match("#[\\|/]dede[\\|/]#", $dirname))
  144. {
  145. $safeMsg[] = '默认管理目录为dede,需要立即将它更名;';
  146. }
  147. if(IsWritable(DEDEDATA.'/common.inc.php'))
  148. {
  149. $safeMsg[] = '强烈建议data/common.inc.php文件属性设置为644(Linux/Unix)或只读(NT);';
  150. }
  151. $rs = TestAdminPWD();
  152. if($rs < 0)
  153. {
  154. $linkurl = "<a href='sys_admin_user.php' style='color:blue;text-decoration:underline;'>马上修改</a>";
  155. switch ($rs)
  156. {
  157. case -1:
  158. $msg = "没有更改默认管理员名称admin,建议您修改为其他管理账号!{$linkurl}";
  159. break;
  160. case -2:
  161. $msg = "没有更改默认的管理员名称和密码,强烈建议您进行更改!{$linkurl}";
  162. break;
  163. }
  164. $safeMsg[] = $msg;
  165. }
  166. //if(PostHost($cfg_basehost.'/data/admin/ver.txt') === @file_get_contents(DEDEDATA.'/admin/ver.txt'))
  167. //{
  168. // $helpurl = 'http://help.dedecms.com/install-use/apply/2011/1110/2129.html';
  169. // $safeMsg[] = '<font color="blue">强烈建议将data目录搬移到Web根目录以外;</font><a href="'.$helpurl.'" style="color:blue;text-decoration:underline;" target="_blank">查看如何搬迁</a>';
  170. //}
  171. ?>
  172. <?php
  173. if(count($safeMsg) > 0)
  174. {
  175. ?>
  176. <!--安全检测提示 -->
  177. <div id="safemsg">
  178. <dl class="dbox" id="item1" style="margin-left:0.5%;margin-right:0.5%; width:97%">
  179. <dt class='lside'><span class='l'><?php echo $cfg_soft_enname; ?>安全提示</span></dt>
  180. <dd>
  181. <div id='safelist'>
  182. <table width="98%" border="0" cellspacing="1" cellpadding="0" style="color:red">
  183. <?php
  184. $i=1;
  185. foreach($safeMsg as $key => $val)
  186. {
  187. ?>
  188. <tr>
  189. <td><font color="black"><?php echo $i;?>.</font><?php echo $val;?></td>
  190. </tr>
  191. <?php
  192. $i++;
  193. }
  194. ?>
  195. </table>
  196. </div>
  197. </dd>
  198. </dl>
  199. </div>
  200. <?php
  201. }
  202. ?>