国内流行的内容管理系统(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.

187 lines
5.9KB

  1. <?php
  2. /**
  3. * 系统配置
  4. *
  5. * @version $Id: sys_info.php 1 22:28 2010年7月20日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license/v6
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__)."/config.php");
  13. CheckPurview('sys_Edit');
  14. if(empty($dopost)) $dopost = "";
  15. $configfile = DEDEDATA.'/config.cache.inc.php';
  16. //更新配置函数
  17. function ReWriteConfig()
  18. {
  19. global $dsql,$configfile;
  20. if(!is_writeable($configfile))
  21. {
  22. echo "配置文件'{$configfile}'不支持写入,无法修改系统配置参数!";
  23. exit();
  24. }
  25. $fp = fopen($configfile,'w');
  26. flock($fp,3);
  27. fwrite($fp,"<"."?php\r\n");
  28. $dsql->SetQuery("SELECT `varname`,`type`,`value`,`groupid` FROM `#@__sysconfig` ORDER BY aid ASC ");
  29. $dsql->Execute();
  30. while($row = $dsql->GetArray())
  31. {
  32. if($row['type']=='number')
  33. {
  34. if($row['value']=='') $row['value'] = 0;
  35. fwrite($fp,"\${$row['varname']} = ".$row['value'].";\r\n");
  36. }
  37. else
  38. {
  39. fwrite($fp,"\${$row['varname']} = '".str_replace("'",'',$row['value'])."';\r\n");
  40. }
  41. }
  42. fwrite($fp,"?".">");
  43. fclose($fp);
  44. }
  45. //保存配置的改动
  46. if($dopost=="save")
  47. {
  48. CheckCSRF();
  49. foreach($_POST as $k=>$v)
  50. {
  51. if(preg_match("#^edit___#", $k))
  52. {
  53. $v = cn_substrR(${$k}, 1024);
  54. }
  55. else
  56. {
  57. continue;
  58. }
  59. $k = preg_replace("#^edit___#", "", $k);
  60. $dsql->ExecuteNoneQuery("UPDATE `#@__sysconfig` SET `value`='$v' WHERE varname='$k' ");
  61. }
  62. ReWriteConfig();
  63. ShowMsg("成功更改站点配置!", "sys_info.php");
  64. exit();
  65. }
  66. //增加新变量
  67. else if($dopost=='add')
  68. {
  69. CheckCSRF();
  70. if($vartype=='bool' && ($nvarvalue!='Y' && $nvarvalue!='N'))
  71. {
  72. ShowMsg("布尔变量值必须为'Y'或'N'!","-1");
  73. exit();
  74. }
  75. if(trim($nvarname)=='' || preg_match("#[^a-z_]#i", $nvarname) )
  76. {
  77. ShowMsg("变量名不能为空并且必须为[a-z_]组成!","-1");
  78. exit();
  79. }
  80. $row = $dsql->GetOne("SELECT varname FROM `#@__sysconfig` WHERE varname LIKE '$nvarname' ");
  81. if(is_array($row))
  82. {
  83. ShowMsg("该变量名称已经存在!","-1");
  84. exit();
  85. }
  86. $row = $dsql->GetOne("SELECT aid FROM `#@__sysconfig` ORDER BY aid DESC ");
  87. $aid = $row['aid'] + 1;
  88. $inquery = "INSERT INTO `#@__sysconfig`(`aid`,`varname`,`info`,`value`,`type`,`groupid`)
  89. VALUES ('$aid','$nvarname','$varmsg','$nvarvalue','$vartype','$vargroup')";
  90. $rs = $dsql->ExecuteNoneQuery($inquery);
  91. if(!$rs)
  92. {
  93. ShowMsg("新增变量失败,可能有非法字符!", "sys_info.php?gp=$vargroup");
  94. exit();
  95. }
  96. if(!is_writeable($configfile))
  97. {
  98. ShowMsg("成功保存变量,但由于 $configfile 无法写入,因此不能更新配置文件!","sys_info.php?gp=$vargroup");
  99. exit();
  100. }else
  101. {
  102. ReWriteConfig();
  103. ShowMsg("成功保存变量并更新配置文件!","sys_info.php?gp=$vargroup");
  104. exit();
  105. }
  106. }
  107. // 搜索配置
  108. else if ($dopost=='search')
  109. {
  110. $keywords = isset($keywords)? strip_tags($keywords) : '';
  111. $i = 1;
  112. $configstr = <<<EOT
  113. <table width="100%" cellspacing="1" cellpadding="1" border="0" bgcolor="#cfcfcf" id="tdSearch" style="">
  114. <tbody>
  115. <tr height="25" bgcolor="#fbfce2" align="center">
  116. <td width="300">参数说明</td>
  117. <td>参数值</td>
  118. <td width="220">变量名</td>
  119. </tr>
  120. EOT;
  121. echo $configstr;
  122. if ($keywords)
  123. {
  124. $dsql->SetQuery("SELECT * FROM `#@__sysconfig` WHERE info LIKE '%$keywords%' OR varname LIKE '%$keywords%' order by aid asc");
  125. $dsql->Execute();
  126. while ($row = $dsql->GetArray()) {
  127. $bgcolor = ($i++%2==0)? "#F9FCEF" : "#ffffff";
  128. $row['info'] = preg_replace("#{$keywords}#", '<font color="red">'.$keywords.'</font>', $row['info']);
  129. $row['varname'] = preg_replace("#{$keywords}#", '<font color="red">'.$keywords.'</font>', $row['varname']);
  130. ?>
  131. <tr align="center" height="25" bgcolor="<?php echo $bgcolor?>">
  132. <td width="300"><?php echo $row['info']; ?>: </td>
  133. <td align="left" style="padding:3px;">
  134. <?php
  135. if($row['type']=='bool')
  136. {
  137. $c1='';
  138. $c2 = '';
  139. $row['value']=='Y' ? $c1=" checked" : $c2=" checked";
  140. echo "<input type='radio' class='np' name='edit___{$row['varname']}' value='Y'$c1>是 ";
  141. echo "<input type='radio' class='np' name='edit___{$row['varname']}' value='N'$c2>否 ";
  142. }else if($row['type']=='bstring')
  143. {
  144. echo "<textarea name='edit___{$row['varname']}' row='4' id='edit___{$row['varname']}' class='textarea_info' style='width:98%;height:50px'>".dede_htmlspecialchars($row['value'])."</textarea>";
  145. }else if($row['type']=='number')
  146. {
  147. echo "<input type='text' name='edit___{$row['varname']}' id='edit___{$row['varname']}' value='{$row['value']}' style='width:30%'>";
  148. }else
  149. {
  150. echo "<input type='text' name='edit___{$row['varname']}' id='edit___{$row['varname']}' value=\"".dede_htmlspecialchars($row['value'])."\" style='width:80%'>";
  151. }
  152. ?>
  153. </td>
  154. <td><?php echo $row['varname']?></td>
  155. </tr>
  156. <?php
  157. }
  158. ?>
  159. </table>
  160. <?php
  161. exit;
  162. }
  163. if ($i == 1)
  164. {
  165. echo ' <tr align="center" bgcolor="#F9FCEF" height="25">
  166. <td colspan="3">没有找到搜索的内容</td>
  167. </tr></table>';
  168. }
  169. exit;
  170. } else if ($dopost=='make_encode')
  171. {
  172. $chars='abcdefghigklmnopqrstuvwxwyABCDEFGHIGKLMNOPQRSTUVWXWY0123456789';
  173. $hash='';
  174. $length = rand(28,32);
  175. $max = strlen($chars) - 1;
  176. for($i = 0; $i < $length; $i++) {
  177. $hash .= $chars[mt_rand(0, $max)];
  178. }
  179. echo $hash;
  180. exit();
  181. }
  182. include DedeInclude('templets/sys_info.htm');