国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
8.3KB

  1. <?php
  2. /**
  3. * @version $Id: config.php 1 8:38 2010年7月9日Z tianya $
  4. * @package DedeCMS.Member
  5. * @copyright Copyright (c) 2007 - 2019, DesDev, Inc.
  6. * @license http://help.dedecms.com/usersguide/license.html
  7. * @link http://www.dedecms.com
  8. */
  9. //针对会员中心操作进行XSS过滤
  10. function XSSClean($val) {
  11. global $cfg_soft_lang;
  12. if($cfg_soft_lang=='gb2312') gb2utf8($val);
  13. if (is_array($val))
  14. {
  15. // while (list($key) = each($val))
  16. foreach ($val as $key => $value)
  17. {
  18. if(in_array($key,array('tags','body','dede_fields','dede_addonfields','dopost','introduce'))) continue;
  19. $val[$key] = XSSClean($val[$key]);
  20. }
  21. return $val;
  22. }
  23. $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val);
  24. $search = 'abcdefghijklmnopqrstuvwxyz';
  25. $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  26. $search .= '1234567890!@#$%^&*()';
  27. $search .= '~`";:?+/={}[]-_|\'\\';
  28. for ($i = 0; $i < strlen($search); $i++) {
  29. $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ;
  30. $val = preg_replace('/(&#0{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ;
  31. }
  32. $val = str_replace("`","‘",$val);
  33. $val = str_replace("'","‘",$val);
  34. $val = str_replace("\"","“",$val);
  35. $val = str_replace(",",",",$val);
  36. $val = str_replace("(","(",$val);
  37. $val = str_replace(")",")",$val);
  38. $ra1 = array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base');
  39. $ra2 = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');
  40. $ra = array_merge($ra1, $ra2);
  41. $found = true;
  42. while ($found == true) {
  43. $val_before = $val;
  44. for ($i = 0; $i < sizeof($ra); $i++) {
  45. $pattern = '/';
  46. for ($j = 0; $j < strlen($ra[$i]); $j++) {
  47. if ($j > 0) {
  48. $pattern .= '(';
  49. $pattern .= '(&#[xX]0{0,8}([9ab]);)';
  50. $pattern .= '|';
  51. $pattern .= '|(&#0{0,8}([9|10|13]);)';
  52. $pattern .= ')*';
  53. }
  54. $pattern .= $ra[$i][$j];
  55. }
  56. $pattern .= '/i';
  57. $replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2);
  58. $val = preg_replace($pattern, $replacement, $val);
  59. if ($val_before == $val) {
  60. $found = false;
  61. }
  62. }
  63. }
  64. if($cfg_soft_lang=='gb2312') utf82gb($val);
  65. return $val;
  66. }
  67. $_GET = XSSClean($_GET);
  68. $_POST = XSSClean($_POST);
  69. $_REQUEST = XSSClean($_REQUEST);
  70. $_COOKIE = XSSClean($_COOKIE);
  71. require_once(dirname(__FILE__).'/../include/common.inc.php');
  72. require_once(DEDEINC.'/filter.inc.php');
  73. require_once(DEDEINC.'/memberlogin.class.php');
  74. require_once(DEDEINC.'/dedetemplate.class.php');
  75. //获得当前脚本名称,如果你的系统被禁用了$_SERVER变量,请自行更改这个选项
  76. $dedeNowurl = $s_scriptName = '';
  77. $dedeNowurl = GetCurUrl();
  78. $dedeNowurls = explode('?', $dedeNowurl);
  79. $s_scriptName = $dedeNowurls[0];
  80. $menutype = '';
  81. $menutype_son = '';
  82. $gourl = empty($gourl)? "" : RemoveXSS($gourl);
  83. //检查是否开放会员功能
  84. if($cfg_mb_open=='N')
  85. {
  86. if ( defined( 'AJAXLOGIN' ) )
  87. {
  88. die('');
  89. } else {
  90. ShowMsg("系统关闭了会员功能,因此你无法访问此页面!","javascript:;");
  91. exit();
  92. }
  93. }
  94. $keeptime = isset($keeptime) && is_numeric($keeptime) ? $keeptime : -1;
  95. $cfg_ml = new MemberLogin($keeptime);
  96. //判断用户是否登录
  97. $myurl = '';
  98. if($cfg_ml->IsLogin())
  99. {
  100. $myurl = $cfg_memberurl."/index.php?uid=".urlencode($cfg_ml->M_LoginID);
  101. if(!preg_match("#^http:#i", $myurl)) $myurl = $cfg_basehost.$myurl;
  102. }
  103. /**
  104. * 检查用户是否有权限进行某个操作
  105. *
  106. * @param int $rank 权限值
  107. * @param int $money 金币
  108. * @param bool $needinfo 是否需要填写详细信息
  109. * @return void
  110. */
  111. function CheckRank($rank=0, $money=0, $needinfo=TRUE)
  112. {
  113. global $cfg_ml,$cfg_memberurl,$cfg_mb_reginfo,$cfg_mb_spacesta;
  114. if(!$cfg_ml->IsLogin())
  115. {
  116. header("Location:{$cfg_memberurl}/login.php?gourl=".urlencode(GetCurUrl()));
  117. exit();
  118. }
  119. else
  120. {
  121. if($cfg_mb_reginfo == 'Y' && $needinfo)
  122. {
  123. //如果启用注册详细信息
  124. if($cfg_ml->fields['spacesta'] == 0 || $cfg_ml->fields['spacesta'] == 1)
  125. {
  126. ShowMsg("尚未完成详细资料,请完善...","{$cfg_memberurl}/index_do.php?fmdo=user&dopost=regnew&step=2",0,1000);
  127. exit;
  128. }
  129. }
  130. if($cfg_mb_spacesta == '-10')
  131. {
  132. //如果启用注册邮件验证
  133. if($cfg_ml->fields['spacesta'] == '-10')
  134. {
  135. $msg="您尚未进行邮件验证,请到邮箱查阅...</br>重新发送邮件验证 <a href='/member/index_do.php?fmdo=sendMail'><font color='red'>点击此处</font></a>";
  136. ShowMsg($msg,"-1",0,5000);
  137. exit;
  138. }
  139. }
  140. if($cfg_ml->M_Rank < $rank)
  141. {
  142. $needname = "";
  143. if($cfg_ml->M_Rank==0)
  144. {
  145. $row = $dsql->GetOne("SELECT membername FROM #@__arcrank WHERE rank='$rank'");
  146. $myname = "普通会员";
  147. $needname = $row['membername'];
  148. }
  149. else
  150. {
  151. $dsql->SetQuery("SELECT membername From #@__arcrank WHERE rank='$rank' OR rank='".$cfg_ml->M_Rank."' ORDER BY rank DESC");
  152. $dsql->Execute();
  153. $row = $dsql->GetObject();
  154. $needname = $row->membername;
  155. if($row = $dsql->GetObject())
  156. {
  157. $myname = $row->membername;
  158. }
  159. else
  160. {
  161. $myname = "普通会员";
  162. }
  163. }
  164. ShowMsg("对不起,需要:<span style='font-size:11pt;color:red'>$needname</span> 才能访问本页面。<br>你目前的等级是:<span style='font-size:11pt;color:red'>$myname</span> 。","-1",0,5000);
  165. exit();
  166. }
  167. else if($cfg_ml->M_Money < $money)
  168. {
  169. ShowMsg("对不起,需要花费金币:<span style='font-size:11pt;color:red'>$money</span> 才能访问本页面。<br>你目前拥有的金币是:<span style='font-size:11pt;color:red'>".$cfg_ml->M_Money."</span> 。","-1",0,5000);
  170. exit();
  171. }
  172. }
  173. }
  174. /**
  175. * 更新文档统计
  176. *
  177. * @access public
  178. * @param int $channelid 频道模型id
  179. * @return string
  180. */
  181. function countArchives($channelid)
  182. {
  183. global $cfg_ml,$dsql;
  184. $id = (int)$channelid;
  185. if($cfg_ml->IsLogin())
  186. {
  187. $channeltype = array(1 => 'article',2 => 'album',3 => 'soft',-8 => 'infos');
  188. if(isset($channeltype[$id]))
  189. {
  190. $_field = $channeltype[$id];
  191. }
  192. else
  193. {
  194. $_field = 'articles';
  195. }
  196. $row = $dsql->GetOne("SELECT COUNT(*) AS nums FROM #@__archives WHERE channel='$id' AND mid='".$cfg_ml->M_ID."'");
  197. $dsql->ExecuteNoneQuery("UPDATE #@__member_tj SET ".$_field."='".$row['nums']."' WHERE mid='".$cfg_ml->M_ID."'");
  198. }
  199. else
  200. {
  201. return FALSE;
  202. }
  203. }