Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

X3.1的新补丁,针对X3,X2.5的修改

[复制链接]
bugx 发表于 2014-3-5 09:58:00 | 显示全部楼层 |阅读模式
X3.1的新补丁是针对一些安全上的问题修补。3.0和2.5的补丁没发布,大家看着改吧。
以下是对比修改处,大家参照后酌情修改,修改的时候别忘记备份

  1. 1、admincp_setting.php
  2. 2591行
  3. if(isset($settingnew[$k])) {
  4.                         $settingnew[$k] = dhtmlspecialchars($settingnew[$k]);
  5.                 }
  6.         }

  7. 下面增加
  8.         if(isset($settingnew['statcode'])) {
  9.                 $settingnew['statcode'] = str_replace(array('<?', '?>'), array('<?', '?>'), $settingnew['statcode']);
  10.         }


  11. 2、admincp_misc.php
  12. 1211行
  13. $efile = explode(':', $_GET['filenamenew']);
  14. 下面增加
  15. if(substr($_GET['filenamenew'], -4) !== '.php') {
  16.                                         cpmsg('crons_filename_illegal', '', 'error');
  17.                                 }
  18. 1259行
  19. if(!file_exists($cronfile)) {
  20. 改为
  21. if(substr($cronfile, -4) !== '.php' || !file_exists($cronfile)) {


  22. 3、admincp_makehtml.php
  23. 459行
  24. if(!empty($re[0])) {
  25.                                 cpmsg(cplang('setting_functions_makehtml_topichtmldir_invalid').','.cplang('return'), NULL, 'error');
  26.                         }
  27. 下面增加
  28. $topichtmldir = realpath($settingnew['makehtml']['topichtmldir']);
  29.                         if($topichtmldir === false) {
  30.                                 dmkdir($settingnew['makehtml']['topichtmldir'], 777, false);
  31.                                 $topichtmldir = realpath($settingnew['makehtml']['topichtmldir']);
  32.                                 rmdir($settingnew['makehtml']['topichtmldir']);
  33.                                 if($topichtmldir === false) {
  34.                                         cpmsg(cplang('setting_functions_makehtml_topichtmldir_invalid').','.cplang('return'), NULL, 'error');
  35.                                 }
  36.                         }
  37.                         $topichtmldir = str_replace(DISCUZ_ROOT, '', $topichtmldir);
  38.                         $sysdir = array('api', 'archiver', 'config', 'data/diy', 'data\diy', 'install', 'source', 'static', 'template', 'uc_client', 'uc_server');
  39.                         foreach($sysdir as $_dir) {
  40.                                 if(stripos($topichtmldir, $_dir) === 0) {
  41.                                         cpmsg(cplang('setting_functions_makehtml_topichtmldir_invalid').','.cplang('return'), NULL, 'error');
  42.                                 }
  43.                         }


  44. 4、function_admincp.php
  45. 18行
  46. strpos(realpath(DISCUZ_ROOT.'./'.$dir), realpath(DISCUZ_ROOT.'./template')) === 0;
  47. 改为
  48. strpos(realpath(DISCUZ_ROOT.'./'.$dir), realpath(DISCUZ_ROOT.'./template').DIRECTORY_SEPARATOR) === 0;


  49. 5、function_blog.php
  50. 开头
  51. if(!defined('IN_DISCUZ')) {
  52.         exit('Access Denied');
  53. }
  54. 下面增加
  55. function blog_check_url($url) {
  56.         $url = durlencode(trim($url));
  57.         if(preg_match("/^(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\//i", $url)) {
  58.                 $return = '<a href="'.$url.'" target="_blank">';
  59.         } else {
  60.                 $return = '<a href="'.(!empty($GLOBALS['_G']['siteurl']) ? $GLOBALS['_G']['siteurl'] : 'http://').$url.'" target="_blank">';
  61.         }
  62.         return $return;
  63. }

  64. 69行
  65. '<a href="\\1" target="_blank">'
  66. 改为
  67. 'blog_check_url(\'\\1\')'

  68. <font color="#ff0000">这个地方上面有一个正则3.0中是/i修饰符,3.1中使用了/ie  修饰符,注意下。要使用这个补丁得要用上/ie。但是/e修饰符已经被PHP在后期版本中丢弃。因为并不是很安全。</font>

  69. 6、function_discuzcode.php
  70. 417行
  71. $url = addslashes($url);
  72.         if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
  73.                 $url = 'http://'.$url;
  74.         }

  75. 改为

  76.         $url = addslashes($url);
  77.         if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
  78.                 return dhtmlspecialchars($url);
  79.         }


  80. 7、static下
  81. mp3player.swf等3个swf替换
  82. 增加了
  83. bbcode.js


  84. 8、function_core.php
  85. 3.1以后自带
  86. function durlencode($url) {
  87.         static $fix = array('%21', '%2A','%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
  88.         static $replacements = array('!', '*', ';', ":", "@", "&", "=", "+", "[        DISCUZ_CODE_3        ]quot;, ",", "/", "?", "%", "#", "[", "]");
  89.         return str_replace($fix, $replacements, urlencode($url));
  90. }

  91. 3.0以前都要增加这个新函数。
复制代码



dej.sf 发表于 2014-3-5 13:12:17 | 显示全部楼层
确定X3.1的补丁适合X2.5?
回复

使用道具 举报

 楼主| bugx 发表于 2014-3-5 13:55:26 | 显示全部楼层
dej.sf 发表于 2014-3-5 13:12
确定X3.1的补丁适合X2.5?

直接拿x3.1的补丁覆盖当然不行。就逐个看这些变化的地方。是否相似,一样的就可以这样改
回复

使用道具 举报

pcyi 发表于 2014-3-5 16:29:39 | 显示全部楼层
楼主好用心,现在官方升级都不带 Fix 记录了,每次有补丁包都有点忐忑
回复

使用道具 举报

仿版者 发表于 2014-3-5 17:08:17 | 显示全部楼层
支持一下  很用心的说!
回复

使用道具 举报

li52lili 发表于 2014-3-6 13:37:41 | 显示全部楼层
{:soso_e162:}
回复

使用道具 举报

蝴蝶啊蝴蝶树 发表于 2014-3-6 16:33:01 | 显示全部楼层
支持一下!很不错。去研究一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-6-2 13:23 , Processed in 0.096457 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表