欢迎来到元素模板www.ys720.com,本站提供专业的织梦模板网站模板ASPCMS模板网站修改/网站仿站
当前位置:主页 > 程序教程 > DEDECMS教程 >
DEDECMS教程

织梦DeDeCMS dede/dede/sys_info.php代码详解

(元素模板) / 2020-05-19 12:51

<?php
//echo dirname(__FILE__)的值为:C:\wamp\www\dede\dede;
require_once(dirname(__FILE__)."/config.php");
//检查用户的权限,在dede/include/inc_userlogin.php中定义
CheckPurview('sys_Edit');
if(empty($dopost)) $dopost = "";
$configfile = dirname(__FILE__)."/../include/config_hand.php";
//echo $configfile的值为:C:\wamp\www\dede\dede/../include/config_hand.php;
$configfile_bak = dirname(__FILE__)."/../include/config_hand_bak.php";
//echo $configfile_bak的值为:C:\wamp\www\dede\dede/../include/config_hand_bak.php;
//$cft_ver_lang在dede/include/config_base.php中定义
header("Content-Type: text/html; charset={$cfg_ver_lang}");

if(!is_writeable($configfile)){
 echo "配置文件'{$configfile}'不支持写入,严禁修改系统配置参数!";
 exit();
}

if(empty($gp)) $gp = 1;

//保存更改
if($dopost=="save")
{
 $dsql = new DedeSql(false);
 foreach($_POST as $k=>$v){
 if(ereg("^edit___",$k)){
  $v = ${$k};

 }else continue;
  $k = ereg_replace("^edit___","",$k);
  if(strlen($v) > 250){
   showmsg("$k 太长,不能超过250字节",'-1');
   exit;
  }
  $dsql->ExecuteNoneQuery("Update dede_sysconfig set `value`='$v' where `varname`='$k' And `group`<>-1 ");
 }
 $dsql->SetQuery("Select `varname`,`value` From `dede_sysconfig` order by `aid` asc");
  $dsql->Execute();
  if($dsql->GetTotalRow()<=0){
  $dsql->Close();
  ShowMsg("成功保存变量但从数据库读取所有数据时失败,无法更新配置文件!","javascript:;");
   exit();
 }
  @copy($configfile,$configfile_bak);
 $fp = @fopen($configfile,'w');
 @flock($fp,3);
 @fwrite($fp,"<"."?php\r\n") or die("配置文件'{$configfile}'不支持写入,本次操作无效!<a href='sys_info.php'>返回</a>");
  while($row = $dsql->GetArray()){
   $row['value'] = str_replace("'","\\'",$row['value']);
   fwrite($fp,"\${$row['varname']} = '".$row['value']."';\r\n");
  }
  fwrite($fp,"?>");
  fclose($fp);
 $dsql->Close();
 ShowMsg("成功更改站点配置!","sys_info.php");
 exit();
}


require_once(dirname(__FILE__)."/templets/sys_info.htm");
//ClearAllLink()在dede/dede/inc/inc_admin_pub.php中定义
ClearAllLink();
?>

Copyright @ 2013-2021 元素模板 www.ys720.com All Rights Reserved. 版权所有 元素模板 www.ys720.com