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

135 lines
4.7KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="<?php echo $cfg_soft_lang;?>">
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  6. <title>数据批量替换</title>
  7. <link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
  8. <link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
  9. <link rel="stylesheet" href="../static/web/css/admin.css">
  10. <script src="../static/web/js/jquery.min.js"></script>
  11. <script src="../static/web/js/bootstrap.bundle.min.js"></script>
  12. <script src="js/main.js"></script>
  13. <script src='../static/web/js/webajax.js'></script>
  14. <script>
  15. function ShowFields() {
  16. var exptable = $DE('exptable').options[$DE('exptable').selectedIndex].value;
  17. var queryUrl = "sys_data_replace.php?exptable=" + exptable + "&action=getfields";
  18. fetch(queryUrl).then(resp => {
  19. if (resp.ok) {
  20. return resp.text()
  21. }
  22. throw new Error('x');
  23. }).then((d) => {
  24. $DE('fields').innerHTML = d;
  25. }).catch((error) => {
  26. $DE('fields').innerHTML = errMsg;
  27. });
  28. }
  29. function CheckSubmit() {
  30. if ($DE('rpfield').value == "") {
  31. ShowMsg("您选择的操作为手工指定字段,但您并没指定");
  32. return false;
  33. }
  34. if ($DE('rpstring').value == "") {
  35. ShowMsg("您没指定要替换的字符串");
  36. return false;
  37. }
  38. return true;
  39. }
  40. function pf(v) {
  41. $DE('rpfield').value = v;
  42. }
  43. </script>
  44. </head>
  45. <body>
  46. <table width="98%" cellpadding="1" cellspacing="1" align="center" class="table maintable mt-3 mb-3">
  47. <form action="sys_data_replace.php" name="form1" method="post" target="stafrm" onSubmit="return CheckSubmit()">
  48. <input type="hidden" name="action" value="apply">
  49. <tr>
  50. <td bgcolor="#f8f8f8">数据库内容替换</td>
  51. </tr>
  52. <tr>
  53. <td class="p-0">
  54. <table width="100%" cellpadding="2" cellspacing="2" class="table table-borderless">
  55. <tr>
  56. <td colspan="2"><div class="alert alert-info mb-0">程序用于批量替换数据库中某字段的内容,此操作极为危险,请小心使用</div></td>
  57. </tr>
  58. <tr id="datasel">
  59. <td width="260">选择数据表与字段:</td>
  60. <td>
  61. <table width="98%" cellspacing="0" cellpadding="0">
  62. <tr>
  63. <td id="tables">
  64. <?php
  65. $dsql->SetQuery("Show Tables");
  66. $dsql->Execute('t');
  67. if ($dsql->GetError()!=''){
  68. echo "<span class='text-danger'>找不到您所指定的数据库 $dbname</span><br>";
  69. echo $qbutton;
  70. }
  71. echo "<select name='exptable' id='exptable' onchange='ShowFields()' style='width:260px'>";
  72. while($row = $dsql->GetArray('t',MYSQL_BOTH)){
  73. echo "<option value='{$row[0]}'>{$row[0]}</option>";
  74. }
  75. echo "</select>";
  76. $dsql->Close();
  77. ?>
  78. </td>
  79. </tr>
  80. <tr>
  81. <td id='fields'></td>
  82. </tr>
  83. <tr>
  84. <td><input type="text" name="rpfield" id="rpfield" style="width:260px">(选择替换字段)</td>
  85. </tr>
  86. </table>
  87. </td>
  88. </tr>
  89. <tr>
  90. <td>替换方式:</td>
  91. <td>
  92. <label><input type="radio" name="rptype" id="ot1" value="replace" checked="1"> 普通替换</label>
  93. <label><input type="radio" name="rptype" id="ot2" value="regex"> 正则表达式</label>
  94. 主键字段:<input type="text" name="keyfield" id="keyfield" size="12">(正则模式必须指定)
  95. </td>
  96. </tr>
  97. <tr>
  98. <td>被替换内容:</td>
  99. <td><textarea name="rpstring" id="rpstring" style="width:60%;height:50px"></textarea></td>
  100. </tr>
  101. <tr>
  102. <td>替换为:</td>
  103. <td><textarea name="tostring" id="tostring" style="width:60%;height:50px"></textarea></td>
  104. </tr>
  105. <tr>
  106. <td>替换条件:</td>
  107. <td><input type="text" name="condition" id="condition" style="width:60%">(空完全替换)</td>
  108. </tr>
  109. <tr>
  110. <td>安全确认码:</td>
  111. <td>
  112. <input type="text" name="validate" class="w-25 text-uppercase">
  113. <img src="../apps/vdimgck.php" onClick="this.src='../apps/vdimgck.php?'+new Date().getTime()+Math.round(Math.random() * 10000)" title="验证码">
  114. </td>
  115. </tr>
  116. </table>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td bgcolor="#fbfce2" align="center" class="py-2">
  121. <button type="submit" name="Submit" class="btn btn-success btn-sm">开始替换数据</button>
  122. </td>
  123. </tr>
  124. </form>
  125. <tr>
  126. <td>结果:</td>
  127. </tr>
  128. <tr>
  129. <td id="mtd">
  130. <div id="mdv" class="biz-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe></div>
  131. </td>
  132. </tr>
  133. </table>
  134. </body>
  135. </html>