tbl_tracking.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Table tracking page
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. // Run common work
  9. require_once './libraries/common.inc.php';
  10. require_once './libraries/tbl_tracking.lib.php';
  11. define('TABLE_MAY_BE_ABSENT', true);
  12. require './libraries/tbl_common.inc.php';
  13. $url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
  14. $url_params['goto'] = 'tbl_tracking.php';
  15. $url_params['back'] = 'tbl_tracking.php';
  16. // Init vars for tracking report
  17. if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
  18. $data = PMA_Tracker::getTrackedData(
  19. $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']
  20. );
  21. $selection_schema = false;
  22. $selection_data = false;
  23. $selection_both = false;
  24. if (! isset($_REQUEST['logtype'])) {
  25. $_REQUEST['logtype'] = 'schema_and_data';
  26. }
  27. if ($_REQUEST['logtype'] == 'schema') {
  28. $selection_schema = true;
  29. } elseif ($_REQUEST['logtype'] == 'data') {
  30. $selection_data = true;
  31. } else {
  32. $selection_both = true;
  33. }
  34. if (! isset($_REQUEST['date_from'])) {
  35. $_REQUEST['date_from'] = $data['date_from'];
  36. }
  37. if (! isset($_REQUEST['date_to'])) {
  38. $_REQUEST['date_to'] = $data['date_to'];
  39. }
  40. if (! isset($_REQUEST['users'])) {
  41. $_REQUEST['users'] = '*';
  42. }
  43. $filter_ts_from = strtotime($_REQUEST['date_from']);
  44. $filter_ts_to = strtotime($_REQUEST['date_to']);
  45. $filter_users = array_map('trim', explode(',', $_REQUEST['users']));
  46. }
  47. // Prepare export
  48. if (isset($_REQUEST['report_export'])) {
  49. $entries = PMA_getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users);
  50. }
  51. // Export as file download
  52. if (isset($_REQUEST['report_export'])
  53. && $_REQUEST['export_type'] == 'sqldumpfile'
  54. ) {
  55. PMA_exportAsFileDownload($entries);
  56. }
  57. $html = '<br />';
  58. /**
  59. * Actions
  60. */
  61. // Create tracking version
  62. if (isset($_REQUEST['submit_create_version'])) {
  63. PMA_createTrackingVersion();
  64. }
  65. // Deactivate tracking
  66. if (isset($_REQUEST['submit_deactivate_now'])) {
  67. PMA_deactivateTracking();
  68. }
  69. // Activate tracking
  70. if (isset($_REQUEST['submit_activate_now'])) {
  71. PMA_activateTracking();
  72. }
  73. // Export as SQL execution
  74. if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
  75. $sql_result = PMA_exportAsSQLExecution($entries);
  76. }
  77. // Export as SQL dump
  78. if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
  79. PMA_exportAsSQLDump($entries);
  80. }
  81. /*
  82. * Schema snapshot
  83. */
  84. if (isset($_REQUEST['snapshot'])) {
  85. $html .= PMA_getHtmlForSchemaSnapshot($url_query);
  86. }
  87. // end of snapshot report
  88. /*
  89. * Tracking report
  90. */
  91. if (isset($_REQUEST['report'])
  92. && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))
  93. ) {
  94. PMA_deleteTrackingReportRows($data);
  95. }
  96. if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
  97. $html .= PMA_getHtmlForTrackingReport(
  98. $url_query, $data, $url_params, $selection_schema, $selection_data,
  99. $selection_both, $filter_ts_to, $filter_ts_from, $filter_users
  100. );
  101. } // end of report
  102. /*
  103. * List selectable tables
  104. */
  105. $selectable_tables_sql_result = PMA_getSQLResultForSelectableTables();
  106. if ($GLOBALS['dbi']->numRows($selectable_tables_sql_result) > 0) {
  107. $html .= PMA_getHtmlForSelectableTables(
  108. $selectable_tables_sql_result, $url_query
  109. );
  110. }
  111. $html .= '<br />';
  112. /*
  113. * List versions of current table
  114. */
  115. $sql_result = PMA_getListOfVersionsOfTable();
  116. $last_version = PMA_getTableLastVersionNumber($sql_result);
  117. if ($last_version > 0) {
  118. $html .= PMA_getHtmlForTableVersionDetails(
  119. $sql_result, $last_version, $url_params, $url_query
  120. );
  121. }
  122. $html .= PMA_getHtmlForDataDefinitionAndManipulationStatements(
  123. $url_query, $last_version
  124. );
  125. $html .= '<br class="clearfloat"/>';
  126. $response = PMA_Response::getInstance();
  127. $response->addHTML($html);
  128. ?>