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

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