PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/4.8/administrator/components/com_mostlydbadmin/admin.mostlydbadmin.html.php

http://miacms.googlecode.com/
PHP | 242 lines | 224 code | 4 blank | 14 comment | 17 complexity | e512722b718214d980f8b9dd434bb270 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-2.0
  1. <?php
  2. /**
  3. * @package MiaCMS
  4. * @author MiaCMS see README.php
  5. * @copyright see README.php
  6. * See COPYRIGHT.php for copyright notices and details.
  7. * @license GNU/GPL Version 2, see LICENSE.php
  8. * MiaCMS is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; version 2 of the License.
  11. */
  12. /** ensure this file is being included by a parent file */
  13. defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  14. /**
  15. * @package MiaCMS_4.6
  16. */
  17. class HTML_dbadmin
  18. {
  19. function backupIntro( $tablelist, $p_option )
  20. {
  21. ?>
  22. <table cellpadding="4" cellspacing="0" width="100%">
  23. <tr>
  24. <td width="100%" class="sectionname"><img src="images/backup.png" alt="backup" class="imgcenter" /><?php echo T_('Database Backup'); ?></td>
  25. </tr>
  26. </table>
  27. <form action="<?php echo htmlentities('index2.php?option=com_mostlydbadmin&task=doBackup'); ?>" method="post">
  28. <table align="center" cellspacing="0" cellpadding="2" width="100%" class="adminform">
  29. <tr>
  30. <td><?php echo T_('Where would you like to back up your Database Tables to?'); ?><br /> <br />
  31. <input type="radio" name="OutDest" value="screen" />
  32. <?php echo T_('Display Results on the Screen'); ?><br />
  33. <input type="radio" name="OutDest" value="remote"/>
  34. <?php echo T_('Download to a file on my local computer'); ?><br />
  35. <input type="radio" name="OutDest" value="local" checked="checked" />
  36. <?php echo T_('Store the file in the backup directory on the server'); ?>
  37. </td>
  38. <td>&nbsp;</td>
  39. <td><?php echo T_('What format would you like to save them as?'); ?><br /> <br />
  40. <?php if (function_exists('gzcompress'))
  41. {
  42. ?>
  43. <input type="radio" name="OutType" value="zip" /><?php echo T_('As a Zip file'); ?><br />
  44. <?php
  45. }
  46. if (function_exists('bzcompress'))
  47. {
  48. ?>
  49. <input type="radio" name="OutType" value="bzip" /><?php echo T_('As a BZip file'); ?><br />
  50. <?php
  51. }
  52. if (function_exists('gzencode'))
  53. {
  54. ?>
  55. <input type="radio" name="OutType" value="gzip" /><?php echo T_('As a GZip file'); ?><br />
  56. <?php
  57. }
  58. ?>
  59. <input type="radio" name="OutType" value="sql" checked="checked" /><?php echo T_('As a SQL (plain text) file'); ?>
  60. <br />
  61. <input type="radio" name="OutType" value="html" /><?php echo T_('As formatted HTML'); ?></td>
  62. </tr>
  63. <tr>
  64. <td> <p><?php echo T_('What do you want to back up?'); ?><br /><br />
  65. <input type="radio" name="toBackUp" value="data" /><?php echo T_('Data Only'); ?><br />
  66. <input type="radio" name="toBackUp" value="structure" /><?php echo T_('Structure Only'); ?><br />
  67. <input type="radio" name="toBackUp" value="both" checked="checked" /><?php echo T_('Data and Structure'); ?></p>
  68. </td>
  69. <td>&nbsp;</td>
  70. <td> <p align="left"><?php echo T_('Which Database Tables would you like to back up?<br />
  71. Please note, it is highly recommended you select ALL your tables.'); ?></p>
  72. <?php echo $tablelist; ?>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td>&nbsp;</td>
  77. <td>&nbsp;</td>
  78. <td align="center">&nbsp;<br /> <input type="submit" value="<?php echo T_('Backup the Selected Tables'); ?>" class="button" /></td>
  79. </tr>
  80. </table>
  81. </form>
  82. <?php
  83. }
  84. function restoreIntro($enctype,$uploads_okay,$local_backup_path)
  85. {
  86. ?>
  87. <table cellpadding="4" cellspacing="0" width="100%">
  88. <tr>
  89. <td width="100%" class="sectionname"><img src="images/dbrestore.png" class="imgcenter" alt="restore" />Database Restore</td>
  90. </tr>
  91. </table>
  92. <form action="<?php echo htmlentities('index2.php?option=com_mostlydbadmin&task=doRestore'); ?>" method="post" <?php echo $enctype;?>>
  93. <table align="center" cellspacing="0" cellpadding="2" width="100%" class="adminform">
  94. <tr>
  95. <th class="title" colspan="3"><?php echo T_('Existing Backups'); ?></th>
  96. </tr>
  97. <?php
  98. if (isset($local_backup_path))
  99. {
  100. if ($handle = @opendir($local_backup_path))
  101. {
  102. ?>
  103. <tr><td>&nbsp;</td><td><strong><?php echo T_('Backup File Name'); ?></strong></td><td><strong><?php echo T_('Created Date/Time'); ?></strong></td></tr>
  104. <?php
  105. while ($file = @readdir($handle))
  106. {
  107. if (is_file($local_backup_path . "/" . $file))
  108. {
  109. if (eregi(".\.sql$",$file) || eregi(".\.bz2$",$file) || eregi(".\.gz$",$file) || eregi(".\.zip$",$file))
  110. {
  111. echo "\t\t<tr><td align=\"center\"><input type=\"radio\" name=\"file\" value=\"$file\"></td><td>$file</td><td>" . date("m/d/y H:i:sa", filemtime($local_backup_path . "/" . $file)) . "</td></tr>\n";
  112. }
  113. }
  114. }
  115. }
  116. else
  117. {
  118. echo "\t\t<tr><td colspan=\"3\" class=\"error\">". T_('Error!<br />Invalid or non-existant backup path in your configuration file :')." <br />" . $local_backup_path . "/" . $file . "</td></tr>\n";
  119. }
  120. @closedir($handle);
  121. }
  122. else
  123. {
  124. echo "\t\t<tr><td colspan=\"3\" class=\"error\">". T_('Error!<br />Backup path in your configuration file has not been configured.')."</td></tr>\n";
  125. }
  126. if ($uploads_okay)
  127. {
  128. ?>
  129. <tr>
  130. <td colspan="3"><br /><?php echo T_('Or alternatively, if you\'ve downloaded a backup to your computer, you can restore from a local file :'); ?></td>
  131. </tr>
  132. <tr>
  133. <td>&nbsp;</td>
  134. <td><br /><input type="file" name="upfile" class="button" /></td>
  135. <td>&nbsp;</td>
  136. </tr>
  137. <?php
  138. }
  139. ?>
  140. <tr>
  141. <td>&nbsp;</td>
  142. <td>&nbsp;<br />
  143. <input type="submit" class="button" value="<?php echo T_('Perform the Restore'); ?>" />&nbsp;&nbsp; <input type="reset" class="button" value="<?php echo T_('Reset'); ?>" /></td>
  144. <td>&nbsp;</td>
  145. </tr>
  146. </table>
  147. </form>
  148. <?php
  149. }
  150. function showDbAdminMessage($message,$title,$option,$task)
  151. {
  152. global $PHP_SELF;
  153. ?>
  154. <table cellpadding="4" cellspacing="0" width="100%" class="adminlist">
  155. <tr>
  156. <th width="55%" class="title"><?php echo $title; ?></th>
  157. </tr>
  158. <tr>
  159. <td align="left"><strong><?php echo $message; ?></strong></td>
  160. </tr>
  161. </table>
  162. <?php
  163. }
  164. function xquery( $sql='', $msg='', $rows=null, $option ) {
  165. ?>
  166. <form action="index2.php" method="post" id="adminForm" name="adminForm">
  167. <table cellpadding="4" cellspacing="0" width="100%">
  168. <tr>
  169. <td width="100%" class="sectionname"><img src="images/query.png" alt="query" class="imgcenter" /><?php echo T_('Execute Query'); ?></td>
  170. <td nowrap="nowrap">&nbsp;</td>
  171. </tr>
  172. </table>
  173. <table cellpadding="4" cellspacing="1" width="100%" class="adminform">
  174. <tr>
  175. <td>SQL:</td>
  176. </tr>
  177. <tr>
  178. <td><textarea id="sql" name="sql" rows="10" cols="80" class="inputbox"><?php echo $sql;?></textarea></td>
  179. </tr>
  180. <tr>
  181. <td>
  182. <input id="execute_query" type="submit" value="<?php echo T_('Execute Query'); ?>" class="button" />
  183. <input id="clear_query" type="button" value="<?php echo T_('Clear Query'); ?>" class="button" />
  184. <input type="checkbox" name="batch" value="1" /> <?php echo T_('Batch Mode'); ?>
  185. </td>
  186. </tr>
  187. <?php if ($msg) { ?>
  188. <tr>
  189. <td><?php echo $msg;?></td>
  190. </tr>
  191. <?php } ?>
  192. <?php
  193. if (is_array( $rows ) && count( $rows ) > 0) {
  194. $n = count( $rows );
  195. ?>
  196. <tr>
  197. <td>
  198. <table cellspacing="0" cellpadding="2" border="1">
  199. <tr>
  200. <th>#</th>
  201. <?php foreach($rows[0] as $key => $value) { ?>
  202. <th><?php echo $key;?></th>
  203. <?php } ?>
  204. </tr>
  205. <?php for ($i=0; $i < $n; $i++) {
  206. echo "\n <tr>";
  207. echo "\n <td>$i</td>";
  208. foreach($rows[$i] as $key => $value) {
  209. echo "\n <td>$value</td>";
  210. }
  211. echo "\n </tr>";
  212. }
  213. ?>
  214. </table>
  215. </td>
  216. </tr>
  217. <?php } ?>
  218. </table>
  219. <input type="hidden" name="option" value="<?php echo $option; ?>" />
  220. <input type="hidden" name="task" value="xquery" />
  221. </form>
  222. <script type="text/javascript">
  223. YAHOO.util.Event.addListener("execute_query", "click", function(e) {
  224. var sqlText = YAHOO.miacms.base.trim(YAHOO.util.Dom.get("sql").value);
  225. if (sqlText==='') {
  226. alert('<?php echo T_('The query is empty!'); ?>');
  227. YAHOO.miacms.base.preventBrowserDefault(e);
  228. return false;
  229. }
  230. });
  231. YAHOO.util.Event.addListener("clear_query", "click", function() {
  232. YAHOO.util.Dom.get("sql").value='';
  233. });
  234. </script>
  235. <?php
  236. }
  237. }
  238. ?>