国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

122 行
4.4KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  6. <title>数据批量替换</title>
  7. <link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
  8. <link rel="stylesheet" href="/static/web/css/bootstrap.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.min.js"></script>
  12. <script src="/static/web/js/webajax.js"></script>
  13. <script src="/static/web/js/admin.main.js"></script>
  14. </head>
  15. <body>
  16. <ol class="breadcrumb">
  17. <li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
  18. <li class="breadcrumb-item active">数据批量替换</li>
  19. </ol>
  20. <div class="card shadow-sm">
  21. <div class="card-header">数据批量替换</div>
  22. <div class="card-body">
  23. <div class="alert alert-warning">数据批量替换,请谨慎操作</div>
  24. <form action="sys_data_replace.php" name="form1" method="post" target="stafrm">
  25. <input type="hidden" name="action" value="apply">
  26. <div class="table-responsive">
  27. <table class="table table-borderless">
  28. <tbody>
  29. <tr>
  30. <td width="260">数据表与字段</td>
  31. <td>
  32. <?php
  33. $dsql->SetQuery("Show Tables");
  34. $dsql->Execute('t');
  35. if ($dsql->GetError()!=''){
  36. echo "找不到您所指定的数据库".$dbname."";
  37. echo $qbutton;
  38. }
  39. echo "<select name='exptable' multiple='yes' onchange='ShowFields();' id='exptable' class='admin-input-lg mb-3'>";
  40. while($row = $dsql->GetArray('t',MYSQL_BOTH)){
  41. echo "<option value='{$row[0]}'>{$row[0]}</option>";
  42. }
  43. echo "</select>";
  44. $dsql->Close();
  45. ?>
  46. <div id="fields"></div>
  47. <input type="text" name="rpfield" id="rpfield" class="admin-input-sm" required>
  48. </td>
  49. </tr>
  50. <tr>
  51. <td>主键字段</td>
  52. <td>
  53. <input type="text" name="keyfield" id="keyfield" class="admin-input-sm">
  54. <label><input type="radio" name="rptype" id="ot1" value="replace" checked> 普通替换</label>
  55. <label><input type="radio" name="rptype" id="ot2" value="regex"> 正则表达式</label>
  56. </td>
  57. </tr>
  58. <tr>
  59. <td>被替换值</td>
  60. <td><textarea name="rpstring" id="rpstring" class="admin-textarea-xl" required></textarea></td>
  61. </tr>
  62. <tr>
  63. <td>值替换为</td>
  64. <td><textarea name="tostring" id="tostring" class="admin-textarea-xl"></textarea></td>
  65. </tr>
  66. <tr>
  67. <td>替换条件</td>
  68. <td><input type="text" name="condition" id="condition" class="admin-input-sm">(不填写则完全替换)</td>
  69. </tr>
  70. <tr>
  71. <td>验证码</td>
  72. <td>
  73. <input type="text" name="validate" class="admin-input-sm text-uppercase">
  74. <img src="<?php echo $cfg_phpurl;?>/vdimgck.php" onclick="this.src='<?php echo $cfg_phpurl;?>/vdimgck.php?'+new Date().getTime()+Math.round(Math.random() * 10000)" title="验证码">
  75. </td>
  76. </tr>
  77. <tr>
  78. <td colspan="2" align="center"><button type="submit"class="btn btn-success btn-sm">开始替换数据</button></td>
  79. </tr>
  80. <tr>
  81. <td colspan="2">
  82. <div class="admin-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe></div>
  83. </td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. </div>
  88. </form>
  89. </div>
  90. </div>
  91. <script>
  92. function ShowFields() {
  93. var exptable = $DE('exptable').options[$DE('exptable').selectedIndex].value;
  94. var queryUrl = "sys_data_replace.php?exptable=" + exptable + "&action=getfields";
  95. fetch(queryUrl).then(resp => {
  96. if (resp.ok) {
  97. return resp.text()
  98. }
  99. throw new Error('x');
  100. }).then((d) => {
  101. $DE('fields').innerHTML = d;
  102. }).catch((error) => {
  103. $DE('fields').innerHTML = errMsg;
  104. });
  105. }
  106. function CheckSubmit() {
  107. if ($DE('rpfield').value == "") {
  108. ShowMsg("您选择的操作为手工指定字段,但您并没指定");
  109. return false;
  110. }
  111. if ($DE('rpstring').value == "") {
  112. ShowMsg("您没指定要替换的字符串");
  113. return false;
  114. }
  115. return true;
  116. }
  117. function pf(v) {
  118. $DE('rpfield').value = v;
  119. }
  120. </script>
  121. </body>
  122. </html>