dedecms后台添加新变量删除的功能

dede后台新建 sys_check.php?phprequire_once(dirname(__FILE__).'/config.php');$row = $dsql-GetOne(quot;SELECT * FROM `dede_sysconfig` WHERE aid='$id'quot;);$info=$row;if( $action == 'del' ){$id = explode(quot; ... ,魔客吧
dede后台新建 sys_check.php

  1. <?php
  2. require_once(dirname(__FILE__).'/config.php');
  3. $row = $dsql->GetOne("SELECT * FROM `dede_sysconfig` WHERE aid='$id'");
  4. $info=$row["info"];
  5. if( $action == 'del' )
  6. {
  7.         $id = explode("`", $id);
  8.         foreach ($id as $var)
  9.         {
  10.             $query = "delete from `dede_sysconfig` WHERE `aid` = '$var'";
  11.             $dsql->ExecuteNoneQuery($query);
  12.         }
  13.         ShowMsg("已删除变量 $info ","sys_info.php");
  14.         exit();
  15. }
  16. ?>

dede/templets/sys_info.htm 替换为一下内容 ,53行至111行,    202行,   224行,      226行,      259行至265行 为新增内容
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
  5. <title>系统配置参数</title>
  6. <script language="javascript" src="../include/js/dedeajax2.js"></script>
  7. <script language="javascript">
  8. var searchconfig = false;
  9. function Nav()
  10. {
  11.     if(window.navigator.userAgent.indexOf("MSIE")>=1) return 'IE';
  12.     else if(window.navigator.userAgent.indexOf("Firefox")>=1) return 'FF';
  13.     else return "OT";
  14. }
  15. function $Obj(objname)
  16. {
  17.     return document.getElementById(objname);
  18. }
  19. function ShowConfig(em,allgr)
  20. {
  21.     if(searchconfig) location.reload();
  22.     for(var i=1;i<=allgr;i++)
  23.     {
  24.         if(i==em) $Obj('td'+i).style.display = (Nav()=='IE' ? 'block' : 'table');
  25.         else $Obj('td'+i).style.display = 'none';
  26.     }
  27.     $Obj('addvar').style.display = 'none';
  28. }


  29. function ShowHide(objname)
  30. {
  31.     var obj = $Obj(objname);
  32.     if(obj.style.display != "none") obj.style.display = "none";
  33.     else obj.style.display = (Nav()=='IE' ? 'block' : 'table-row');
  34. }


  35. function backSearch()
  36. {
  37.     location.reload();
  38. }
  39. function getSearch()
  40. {
  41.     var searchKeywords = $Obj('keywds').value;
  42.     var myajax = new DedeAjax($Obj('_search'));
  43.     myajax.SendGet('sys_info.php?dopost=search&keywords='+searchKeywords)
  44.     $Obj('_searchback').innerHTML = '<input name="searchbackBtn" type="button" value="返回" id="searchbackBtn" onclick="backSearch()"/>'
  45.     $Obj('_mainsearch').innerHTML = '';
  46.     searchconfig = true;
  47. }
  48. </script>
  49. <script type="text/javascript">
  50. function getOneItem()
  51. {
  52.     var allSel="";
  53.     if(document.form1.id.value) return document.form1.id.value;
  54.     for(i=0;i<document.form1.id.length;i++)
  55.     {
  56.         if(document.form1.id[i].checked)
  57.         {
  58.                 allSel = document.form1.id[i].value;
  59.                 break;
  60.         }
  61.     }
  62.     return allSel;
  63. }
  64. function getCheckboxItem()
  65. {
  66.     var allSel="";
  67.     if(document.form1.id.value) return document.form1.id.value;
  68.     for(i=0;i<document.form1.id.length;i++)
  69.     {
  70.         if(document.form1.id[i].checked)
  71.         {
  72.             if(allSel=="")
  73.                 allSel=document.form1.id[i].value;
  74.             else
  75.                 allSel=allSel+","+document.form1.id[i].value;
  76.         }
  77.     }
  78.     return allSel;
  79. }
  80. function selAll()
  81. {
  82.     for(i=0;i<document.form1.id.length;i++)
  83.     {
  84.         if(!document.form1.id[i].checked)
  85.         {
  86.             document.form1.id[i].checked=true;
  87.         }
  88.     }
  89. }
  90. function noSelAll()
  91. {
  92.     for(i=0;i<document.form1.id.length;i++)
  93.     {
  94.         if(document.form1.id[i].checked)
  95.         {
  96.             document.form1.id[i].checked=false;
  97.         }
  98.     }
  99. }


  100. function del()
  101. {
  102.     var qstr=getCheckboxItem();
  103.     if(qstr=="") alert("请选择ID!");
  104.     else if(window.confirm("您确定要删除所选证书吗?")) location.href="sys_check.php?action=del&id="+qstr;}
  105. </script>
  106. <link href="css/base.css" rel="stylesheet" type="text/css">
  107. </head>
  108. <body background='images/allbg.gif' leftmargin='8' topmargin='8'>
  109. <div style="min-width:780px">
  110. <table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D6D6D6" align="center">
  111.   <tr>
  112.    <td height="28" background="images/tbg.gif" style="padding-left:10px;"><b>DedeCMS系统配置参数:</b></td>
  113.   </tr>
  114.   <tr>
  115.    <td height="24" bgcolor="#ffffff" align="center"><?php
  116. $ds = file(DEDEADMIN.'/inc/configgroup.txt');
  117. $totalGroup = count($ds);
  118. $i = 0;
  119. foreach($ds as $dl)
  120. {
  121.     $dl = trim($dl);
  122.     if(empty($dl)) continue;
  123.     $dls = explode(',',$dl);
  124.     $i++;
  125.     if($i>1) echo " | <a href='javascript:ShowConfig($i,$totalGroup)'>{$dls[1]}</a> ";
  126.     else{
  127.         echo " <a href='javascript:ShowConfig($i,$totalGroup)'>{$dls[1]}</a> ";
  128.     }
  129. }
  130. ?>
  131.     | <a href="#" onClick="ShowHide('addvar')">添加新变量</a></td>
  132.   </tr>
  133.   <tr id="addvar" style="display:none">
  134.    <td height="24" bgcolor="#ffffff" align="center"><form name="fadd" action="sys_info.php" method="post">
  135.      <input type='hidden' name='dopost' value='add'>
  136.      <table width="98%" border="0" cellspacing="0" cellpadding="0">
  137.       <tr>
  138.        <td width="12%" height="26">变量名称:</td>
  139.        <td width="38%" align="left"><input name="nvarname" type="text" id="nvarname" class="npvar" style="width:80%" /></td>
  140.        <td width="12%" align="center">变量值:</td>
  141.        <td width="38%" align="left"><input name="nvarvalue" type="text" id="nvarvalue" class="npvar" style="width:80%" /></td>
  142.       </tr>
  143.       <tr>
  144.        <td width="10%" height="26">变量类型:</td>
  145.        <td colspan='3' align="left"><input name="vartype" type="radio"  value="string" class='np' checked='checked' />
  146.         文本
  147.         <input name="vartype" type="radio"  value="number" class='np' />
  148.         数字
  149.         <input type="radio" name="vartype" value="bool" class='np' />
  150.         布尔(Y/N)
  151.         <input type="radio" name="vartype" value="bstring" class='np' />
  152.         多行文本 </td>
  153.       </tr>
  154.       <tr>
  155.        <td height="26">参数说明:</td>
  156.        <td align="left"><input type="text" name="varmsg"  id="varmsg" class="npvar" style="width:80%" /></td>
  157.        <td align="center">所属组:</td>
  158.        <td align="left"><?php
  159.                 echo "<select name='vargroup' class='npvar'>\r\n";
  160.                 foreach($ds as $dl){
  161.                     $dl = trim($dl);
  162.                     if(empty($dl)) continue;
  163.                     $dls = explode(',',$dl);
  164.                     echo "<option value='{$dls[0]}'>{$dls[1]}</option>\r\n";
  165.                 }
  166.                 echo "</select>\r\n";
  167.               ?>
  168.         <input type="submit" name="Submit" value="保存变量" class="np coolbg" /></td>
  169.       </tr>
  170.      </table>
  171.     </form></td>
  172.   </tr>
  173. </table>
  174. <table width="98%" border="0" cellpadding="0" cellspacing="0" style="margin-top:10px" bgcolor="#D6D6D6" align="center">
  175.   <tr>
  176.    <td height="28" align="right" background="images/tbg.gif" style="border:1px solid #cfcfcf;border-bottom:none;">   配置搜索:
  177.     <input type="text" name="keywds" id="keywds" />
  178.     <input name="searchBtn" type="button" value="搜索" id="searchBtn" onclick="getSearch()"/>
  179.      <span id="_searchback"></span></td>
  180.   </tr>
  181.   <tr>
  182.    <td bgcolor="#FFFFFF" width="100%"><form action="sys_info.php" method="post" name="form1">
  183.      <input type="hidden" name="dopost" value="save">
  184. <div id="_search"></div>
  185. <div id="_mainsearch">
  186.      <?php
  187. $n = 0;
  188. if(!isset($gp)) $gp = 1;
  189. foreach($ds as $dl)
  190. {
  191.     $dl = trim($dl);
  192.     if(empty($dl)) continue;
  193.     $dls = explode(',',$dl);
  194.     $n++;
  195. ?>
  196.      <table width="100%" style='<?php if($n!=$gp) echo "display:none"; ?>' id="td<?php echo $n?>" border="0" cellspacing="1" cellpadding="1" bgcolor="#cfcfcf">
  197.       <tr align="center" bgcolor="#FBFCE2" height="25">
  198.       <td width="50">aid</td>
  199.        <td width="300">参数说明</td>
  200.        <td>参数值</td>
  201.        <td width="220">变量名</td>
  202.       </tr>
  203.       <?php
  204. $dsql->SetQuery("Select * From `dede_sysconfig` where groupid='{$dls[0]}' order by aid asc");
  205. $dsql->Execute();
  206. $i = 1;
  207. while($row = $dsql->GetArray())
  208. {
  209.     if($i%2==0)
  210.     {
  211.         $bgcolor = "#F9FCEF";
  212.     }
  213.     else
  214.     {
  215.         $bgcolor = "#ffffff";
  216.     }
  217.     $i++;
  218. ?>
  219.       <tr align="center" height="25" bgcolor="<?php echo $bgcolor?>">
  220.       <td width="50"><?php if($row['aid'] <= 761){echo "!";}else{echo "<input name='id' type='checkbox' id='id' value='".$row['aid']."' class='np'>";}?></td>
  221.        <td width="300"><?php echo $row['info']; ?>: </td>
  222.        <td align="left" style="padding:3px;"><?php
  223. if($row['type']=='bool')
  224. {
  225.     $c1='';
  226.     $c2 = '';
  227.     $row['value']=='Y' ? $c1=" checked" : $c2=" checked";
  228.     echo "<input type='radio' class='np' name='edit___{$row['varname']}' value='Y'$c1>是 ";
  229.     echo "<input type='radio' class='np' name='edit___{$row['varname']}' value='N'$c2>否 ";
  230. }else if($row['type']=='bstring')
  231. {
  232.     echo "<textarea name='edit___{$row['varname']}' row='4' id='edit___{$row['varname']}' class='textarea_info' style='width:98%;height:50px'>".htmlspecialchars($row['value'])."</textarea>";
  233. }else if($row['type']=='number')
  234. {
  235.     echo "<input type='text' name='edit___{$row['varname']}' id='edit___{$row['varname']}' value='{$row['value']}' style='width:30%'>";
  236. }else
  237. {
  238.     echo "<input type='text' name='edit___{$row['varname']}' id='edit___{$row['varname']}' value=\"".htmlspecialchars($row['value'])."\" style='width:80%'>";
  239. }
  240. ?></td>
  241.        <td><?php echo $row['varname']?></td>
  242.       </tr>
  243.       <?php
  244. }


  245. ?>
  246.      </table>
  247.      <?php
  248. }
  249. ?>
  250. </div>
  251.      <table width="100%" border="0" cellspacing="1" cellpadding="1"  style="border:1px solid #cfcfcf;border-top:none;">
  252.       <tr bgcolor="#F9FCEF">
  253.        <td height="50" colspan="3">
  254.        <table width="98%" border="0" cellspacing="1" cellpadding="1">
  255.          <tr>
  256.           <td width="11%"> <a href="javascript:selAll()" class="coolbg">全选</a>
  257.             <a href="javascript:noSelAll()" class="coolbg">取消</a>
  258.             <a href="#" onClick="del()" class="coolbg">删除</a></td>
  259.          </tr>
  260.         </table>
  261.        <table width="98%" border="0" cellspacing="1" cellpadding="1">
  262.          <tr>
  263.           <td width="11%"> </td>
  264.           <td width="11%"> </td>
  265.           <td width="11%"><input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" border="0" class="np"></td>
  266.           <td width="78%"><img src="images/button_reset.gif" width="60" height="22" style="cursor:pointer" onClick="document.form1.reset()"></td>
  267.          </tr>
  268.         </table></td>
  269.       </tr>
  270.      </table>
  271.     </form></td>
  272.   </tr>
  273. </table>
  274. </div>
  275. </body>
  276. </html>

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐