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

sys_info.php 6.2KB

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