Merge remote-tracking branch 'origin/master'
[phpmyadmin.git] / tbl_tracking.php
blob2abd935c739a6830958757e1d2400f02f561a778
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Table tracking page
6 * @package PhpMyAdmin
7 */
9 // Run common work
10 require_once './libraries/common.inc.php';
12 require_once './libraries/tbl_tracking.lib.php';
14 define('TABLE_MAY_BE_ABSENT', true);
15 require './libraries/tbl_common.inc.php';
16 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
17 $url_params['goto'] = 'tbl_tracking.php';
18 $url_params['back'] = 'tbl_tracking.php';
20 // Init vars for tracking report
21 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
22 $data = PMA_Tracker::getTrackedData(
23 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']
26 $selection_schema = false;
27 $selection_data = false;
28 $selection_both = false;
30 if (! isset($_REQUEST['logtype'])) {
31 $_REQUEST['logtype'] = 'schema_and_data';
33 if ($_REQUEST['logtype'] == 'schema') {
34 $selection_schema = true;
35 } elseif ($_REQUEST['logtype'] == 'data') {
36 $selection_data = true;
37 } else {
38 $selection_both = true;
40 if (! isset($_REQUEST['date_from'])) {
41 $_REQUEST['date_from'] = $data['date_from'];
43 if (! isset($_REQUEST['date_to'])) {
44 $_REQUEST['date_to'] = $data['date_to'];
46 if (! isset($_REQUEST['users'])) {
47 $_REQUEST['users'] = '*';
49 $filter_ts_from = strtotime($_REQUEST['date_from']);
50 $filter_ts_to = strtotime($_REQUEST['date_to']);
51 $filter_users = array_map('trim', explode(',', $_REQUEST['users']));
54 // Prepare export
55 if (isset($_REQUEST['report_export'])) {
56 $entries = PMA_getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users);
59 // Export as file download
60 if (isset($_REQUEST['report_export'])
61 && $_REQUEST['export_type'] == 'sqldumpfile'
62 ) {
63 PMA_exportAsFileDownload($entries);
66 $html = '<br />';
68 /**
69 * Actions
72 // Create tracking version
73 if (isset($_REQUEST['submit_create_version'])) {
74 PMA_createTrackingVersion();
77 // Deactivate tracking
78 if (isset($_REQUEST['submit_deactivate_now'])) {
79 PMA_deactivateTracking();
82 // Activate tracking
83 if (isset($_REQUEST['submit_activate_now'])) {
84 PMA_activateTracking();
87 // Export as SQL execution
88 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
89 $sql_result = PMA_exportAsSQLExecution($entries);
92 // Export as SQL dump
93 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
94 PMA_exportAsSQLDump($entries);
98 * Schema snapshot
100 if (isset($_REQUEST['snapshot'])) {
101 $html .= PMA_getHtmlForSchemaSnapshot($url_query);
103 // end of snapshot report
106 * Tracking report
108 if (isset($_REQUEST['report'])
109 && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))
111 PMA_deleteTrackingReportRows($data);
114 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
115 $html .= PMA_getHtmlForTrackingReport(
116 $url_query, $data, $url_params, $selection_schema, $selection_data,
117 $selection_both, $filter_ts_to, $filter_ts_from, $filter_users
119 } // end of report
123 * List selectable tables
125 $selectable_tables_sql_result = PMA_getSQLResultForSelectableTables();
126 if ($GLOBALS['dbi']->numRows($selectable_tables_sql_result) > 0) {
127 $html .= PMA_getHtmlForSelectableTables(
128 $selectable_tables_sql_result, $url_query
131 $html .= '<br />';
134 * List versions of current table
136 $sql_result = PMA_getListOfVersionsOfTable();
137 $last_version = PMA_getTableLastVersionNumber($sql_result);
138 if ($last_version > 0) {
139 $html .= PMA_getHtmlForTableVersionDetails(
140 $sql_result, $last_version, $url_params, $url_query
144 $html .= PMA_getHtmlForDataDefinitionAndManipulationStatements(
145 $url_query, $last_version
148 $html .= '<br class="clearfloat"/>';
150 $response = PMA_Response::getInstance();
151 $response->addHTML($html);