admin_db.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php if(!defined('UC_ROOT')) exit('Access Denied');?>
  2. <?php include $this->gettpl('header');?>
  3. <script src="js/common.js" type="text/javascript"></script>
  4. <div class="container">
  5. <?php if($operate == 'list') { ?>
  6. <h3 class="marginbot">
  7. <a href="admin.php?m=db&a=ls&o=export" class="sgbtn">数据备份</a>
  8. 数据恢复
  9. </h3>
  10. <div class="note fixwidthdec">
  11. <p class="i">根据备份日期选择要恢复的备份,点击“详情”进入之后选择要恢复的应用备份</p>
  12. </div>
  13. <div class="mainbox">
  14. <form id="theform">
  15. <table class="datalist" onmouseover="addMouseEvent(this);">
  16. <tr>
  17. <th nowrap="nowrap"><input type="checkbox" name="chkall" id="chkall" onclick="checkall('operate[]')" class="checkbox" /><label for="chkall">删除</label></th>
  18. <th nowrap="nowrap">备份所在目录</th>
  19. <th nowrap="nowrap">备份日期</th>
  20. <th nowrap="nowrap">操作</th>
  21. <th nowrap="nowrap">&nbsp;</th>
  22. <th nowrap="nowrap">&nbsp;</th>
  23. </tr>
  24. <?php foreach((array)$baklist as $bak) {?>
  25. <tr>
  26. <td width="50"><input type="checkbox" name="operate[]" value="<?php echo $bak['name'];?>" class="checkbox" /></td>
  27. <td width="200"><a href="admin.php?m=db&a=ls&o=view&dir=<?php echo $bak['name'];?>"><?php echo $bak['name'];?></a></td>
  28. <td width="120"><?php echo $bak['date'];?></td>
  29. <td><a href="admin.php?m=db&a=ls&o=view&dir=<?php echo $bak['name'];?>">详情</a></td>
  30. <td id="db_operate_<?php echo $bak['name'];?>"></td>
  31. <td><iframe id="operate_iframe_<?php echo $bak['name'];?>" style="display:none" width="0" height="0"></iframe></td>
  32. </tr>
  33. <?php } ?>
  34. <tr class="nobg">
  35. <td colspan="6"><input type="button" value="提 交" onclick="db_delete($('theform'))" class="btn" /></td>
  36. </tr>
  37. </table>
  38. </form>
  39. </div>
  40. <?php } elseif($operate == 'view') { ?>
  41. <h3 class="marginbot">
  42. <a href="admin.php?m=db&a=ls&o=export" class="sgbtn">数据备份</a>
  43. 数据恢复
  44. </h3>
  45. <div class="note fixwidthdec">
  46. <p class="i">在需要恢复的应用前面勾选,之后点击“提交”按钮即可恢复备份数据</p>
  47. </div>
  48. <div class="mainbox">
  49. <form id="theform">
  50. <table class="datalist" onmouseover="addMouseEvent(this);">
  51. <tr>
  52. <th nowrap="nowrap"><input type="checkbox" name="chkall" id="chkall" onclick="checkall('operate[]')" class="checkbox" /><label for="chkall">导入</label></th>
  53. <th nowrap="nowrap">ID</th>
  54. <th nowrap="nowrap">应用名称</th>
  55. <th nowrap="nowrap">应用的主 URL</th>
  56. <th nowrap="nowrap">&nbsp;</th>
  57. <th nowrap="nowrap">&nbsp;</th>
  58. </tr>
  59. <tr>
  60. <td width="50"><input type="checkbox" name="operate_uc" class="checkbox" /></td>
  61. <td width="35"></td>
  62. <td><strong>UCenter</strong></td>
  63. <td></td>
  64. <td id="db_operate_0"><img src="images/correct.gif" border="0" class="statimg" /><span class="green">备份存在</span></td>
  65. <td><iframe id="operate_iframe_0" style="display:none" width="0" height="0"></iframe></td>
  66. </tr>
  67. <?php foreach((array)$applist as $app) {?>
  68. <tr>
  69. <td width="50"><input type="checkbox" name="operate[]" value="<?php echo $app['appid'];?>" class="checkbox" /></td>
  70. <td width="35"><?php echo $app['appid'];?></td>
  71. <td width="160"><a href="admin.php?m=app&a=detail&appid=<?php echo $app['appid'];?>"><strong><?php echo $app['name'];?></strong></a></td>
  72. <td><a href="<?php echo $app['url'];?>" target="_blank"><?php echo $app['url'];?></a></td>
  73. <td id="db_operate_<?php echo $app['appid'];?>"></td>
  74. <td><iframe id="operate_iframe_<?php echo $app['appid'];?>" src="admin.php?m=db&a=ls&o=ping&appid=<?php echo $app['appid'];?>&dir=<?php echo $dir;?>" style="display:none" width="0" height="0"></iframe></td>
  75. </tr>
  76. <?php } ?>
  77. <tr class="nobg">
  78. <td colspan="6"><input type="button" value="提 交" onclick="db_operate($('theform'), 'import')" class="btn" /></td>
  79. </tr>
  80. </table>
  81. </form>
  82. </div>
  83. <?php } else { ?>
  84. <h3 class="marginbot">
  85. 数据备份
  86. <a href="admin.php?m=db&a=ls&o=list" class="sgbtn">数据恢复</a>
  87. </h3>
  88. <div class="mainbox">
  89. <form id="theform">
  90. <table class="datalist" onmouseover="addMouseEvent(this);">
  91. <tr>
  92. <th nowrap="nowrap"><input type="checkbox" name="chkall" id="chkall" checked="checked" onclick="checkall('operate[]')" class="checkbox" /><label for="chkall">数据备份</label></th>
  93. <th nowrap="nowrap">ID</th>
  94. <th nowrap="nowrap">应用名称</th>
  95. <th nowrap="nowrap">应用的主 URL</th>
  96. <th nowrap="nowrap">&nbsp;</th>
  97. <th nowrap="nowrap">&nbsp;</th>
  98. </tr>
  99. <tr>
  100. <td width="50"><input type="checkbox" name="operate_uc" disabled="disabled" checked="checked" class="checkbox" /></td>
  101. <td width="35"></td>
  102. <td><strong>UCenter</strong></td>
  103. <td></td>
  104. <td id="db_operate_0"></td>
  105. <td><iframe id="operate_iframe_0" style="display:none" width="0" height="0"></iframe></td>
  106. </tr>
  107. <?php foreach((array)$applist as $app) {?>
  108. <tr>
  109. <td width="50"><input type="checkbox" name="operate[]" value="<?php echo $app['appid'];?>" checked="checked" class="checkbox" /></td>
  110. <td width="35"><?php echo $app['appid'];?></td>
  111. <td width="160"><a href="admin.php?m=app&a=detail&appid=<?php echo $app['appid'];?>"><strong><?php echo $app['name'];?></strong></a></td>
  112. <td><a href="<?php echo $app['url'];?>" target="_blank"><?php echo $app['url'];?></a></td>
  113. <td id="db_operate_<?php echo $app['appid'];?>"></td>
  114. <td><iframe id="operate_iframe_<?php echo $app['appid'];?>" style="display:none" width="0" height="0"></iframe></td>
  115. </tr>
  116. <?php } ?>
  117. <tr class="nobg">
  118. <td colspan="6"><input type="button" value="提 交" onclick="db_operate($('theform'), 'export')" class="btn" /></td>
  119. </tr>
  120. </table>
  121. </form>
  122. </div>
  123. <?php } ?>
  124. </div>
  125. <script type="text/javascript">
  126. var import_status = new Array();
  127. function db_delete(theform) {
  128. var lang_tips = '开始删除备份数据,请等待,请勿关闭浏览器';
  129. if(!confirm('删除数据库备份会同时删除UCenter 下所有应用的同目录下的备份,您确定要删除吗?')) {
  130. return;
  131. }
  132. for(i = 0; theform[i] != null; i++) {
  133. ele = theform[i];
  134. if(/^operate\[/.test(ele.name) && ele.type == "checkbox" && ele.checked) {
  135. show_status(ele.value, lang_tips);
  136. $('operate_iframe_'+ele.value).src = 'admin.php?m=db&a=delete&backupdir='+ele.value;
  137. }
  138. }
  139. }
  140. function db_operate(theform, operate) {
  141. operate = operate == 'import' ? 'import' : 'export';
  142. if(operate == 'export') {
  143. var lang_tips = '开始备份数据,请等待,请勿关闭浏览器';
  144. } else {
  145. if(!confirm('导入备份数据会覆盖现有的数据,您确定导入吗?')) {
  146. return;
  147. }
  148. if(theform.operate_uc.checked && !confirm('导入备份数据将会覆盖现有用户中心的数据,您确定导入吗?')) {
  149. return;
  150. }
  151. var lang_tips = '开始恢复数据,请等待,请勿关闭浏览器';
  152. }
  153. if(theform.operate_uc.checked) {
  154. show_status(0, lang_tips);
  155. $('operate_iframe_0').src = 'admin.php?m=db&a=operate&t='+operate+'&appid=0&backupdir=<?php echo $dir;?>&sid=<?php echo $sid;?>';
  156. }
  157. for(i = 0; theform[i] != null; i++) {
  158. ele = theform[i];
  159. if(/^operate\[\]$/.test(ele.name) && ele.type == "checkbox" && ele.checked) {
  160. if(operate != 'import' || import_status[ele.value] != false) {
  161. show_status(ele.value, lang_tips);
  162. $('operate_iframe_'+ele.value).src = 'admin.php?m=db&a=operate&t='+operate+'&appid='+ele.value+'&backupdir=<?php echo $dir;?>&sid=<?php echo $sid;?>';
  163. }
  164. }
  165. }
  166. }
  167. function show_status(extid, msg) {
  168. var o = $('db_operate_'+extid);
  169. o.innerHTML = msg;
  170. }
  171. </script>
  172. <?php include $this->gettpl('footer');?>