Translated using Weblate (Indonesian)
[phpmyadmin.git] / tbl_tracking.php
blobe9ef0ba8e2c08befd0f1a4042650d80a5a4f50ba
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 use PMA\libraries\Tracker;
11 use PMA\libraries\Response;
13 require_once './libraries/common.inc.php';
15 require_once './libraries/tracking.lib.php';
17 //Get some js files needed for Ajax requests
18 $response = Response::getInstance();
19 $header = $response->getHeader();
20 $scripts = $header->getScripts();
21 $scripts->addFile('jquery/jquery.tablesorter.js');
22 $scripts->addFile('tbl_tracking.js');
24 define('TABLE_MAY_BE_ABSENT', true);
25 require './libraries/tbl_common.inc.php';
27 if (Tracker::isActive()
28 && Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])
29 && ! (isset($_REQUEST['toggle_activation'])
30 && $_REQUEST['toggle_activation'] == 'deactivate_now')
31 && ! (isset($_REQUEST['report_export'])
32 && $_REQUEST['export_type'] == 'sqldumpfile')
33 ) {
34 $msg = PMA\libraries\Message::notice(
35 sprintf(
36 __('Tracking of %s is activated.'),
37 htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"])
40 $response->addHTML($msg->getDisplay());
43 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
44 $url_params['goto'] = 'tbl_tracking.php';
45 $url_params['back'] = 'tbl_tracking.php';
47 // Init vars for tracking report
48 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
49 $data = Tracker::getTrackedData(
50 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']
53 $selection_schema = false;
54 $selection_data = false;
55 $selection_both = false;
57 if (! isset($_REQUEST['logtype'])) {
58 $_REQUEST['logtype'] = 'schema_and_data';
60 if ($_REQUEST['logtype'] == 'schema') {
61 $selection_schema = true;
62 } elseif ($_REQUEST['logtype'] == 'data') {
63 $selection_data = true;
64 } else {
65 $selection_both = true;
67 if (! isset($_REQUEST['date_from'])) {
68 $_REQUEST['date_from'] = $data['date_from'];
70 if (! isset($_REQUEST['date_to'])) {
71 $_REQUEST['date_to'] = $data['date_to'];
73 if (! isset($_REQUEST['users'])) {
74 $_REQUEST['users'] = '*';
76 $filter_ts_from = strtotime($_REQUEST['date_from']);
77 $filter_ts_to = strtotime($_REQUEST['date_to']);
78 $filter_users = array_map('trim', explode(',', $_REQUEST['users']));
81 // Prepare export
82 if (isset($_REQUEST['report_export'])) {
83 $entries = PMA_getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users);
86 // Export as file download
87 if (isset($_REQUEST['report_export'])
88 && $_REQUEST['export_type'] == 'sqldumpfile'
89 ) {
90 PMA_exportAsFileDownload($entries);
93 $html = '<br />';
95 /**
96 * Actions
98 if (isset($_REQUEST['submit_mult'])) {
99 if (! empty($_REQUEST['selected_versions'])) {
100 if ($_REQUEST['submit_mult'] == 'delete_version') {
101 foreach ($_REQUEST['selected_versions'] as $version) {
102 PMA_deleteTrackingVersion($version);
104 $html .= PMA\libraries\Message::success(
105 __('Tracking versions deleted successfully.')
106 )->getDisplay();
108 } else {
109 $html .= PMA\libraries\Message::notice(
110 __('No versions selected.')
111 )->getDisplay();
115 if (isset($_REQUEST['submit_delete_version'])) {
116 $html .= PMA_deleteTrackingVersion($_REQUEST['version']);
119 // Create tracking version
120 if (isset($_REQUEST['submit_create_version'])) {
121 $html .= PMA_createTrackingVersion();
124 // Deactivate tracking
125 if (isset($_REQUEST['toggle_activation'])
126 && $_REQUEST['toggle_activation'] == 'deactivate_now'
128 $html .= PMA_changeTracking('deactivate');
131 // Activate tracking
132 if (isset($_REQUEST['toggle_activation'])
133 && $_REQUEST['toggle_activation'] == 'activate_now'
135 $html .= PMA_changeTracking('activate');
138 // Export as SQL execution
139 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
140 $sql_result = PMA_exportAsSQLExecution($entries);
141 $msg = PMA\libraries\Message::success(__('SQL statements executed.'));
142 $html .= $msg->getDisplay();
145 // Export as SQL dump
146 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
147 $html .= PMA_exportAsSQLDump($entries);
151 * Schema snapshot
153 if (isset($_REQUEST['snapshot'])) {
154 $html .= PMA_getHtmlForSchemaSnapshot($url_query);
156 // end of snapshot report
159 * Tracking report
161 if (isset($_REQUEST['report'])
162 && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))
164 $html .= PMA_deleteTrackingReportRows($data);
167 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
168 $html .= PMA_getHtmlForTrackingReport(
169 $url_query, $data, $url_params, $selection_schema, $selection_data,
170 $selection_both, $filter_ts_to, $filter_ts_from, $filter_users
172 } // end of report
176 * List selectable tables
178 $selectable_tables_sql_result = PMA_getSQLResultForSelectableTables();
179 if ($GLOBALS['dbi']->numRows($selectable_tables_sql_result) > 0) {
180 $html .= PMA_getHtmlForSelectableTables(
181 $selectable_tables_sql_result, $url_query
184 $html .= '<br />';
187 * List versions of current table
189 $sql_result = PMA_getListOfVersionsOfTable();
190 $last_version = PMA_getTableLastVersionNumber($sql_result);
191 if ($last_version > 0) {
192 $html .= PMA_getHtmlForTableVersionDetails(
193 $sql_result, $last_version, $url_params,
194 $url_query, $pmaThemeImage, $text_dir
198 $type = $GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])
199 ->isView() ? 'view' : 'table';
200 $html .= PMA_getHtmlForDataDefinitionAndManipulationStatements(
201 'tbl_tracking.php' . $url_query,
202 $last_version,
203 $GLOBALS['db'],
204 array($GLOBALS['table']),
205 $type
208 $html .= '<br class="clearfloat"/>';
210 $response->addHTML($html);