Translated using Weblate (Interlingua)
[phpmyadmin.git] / tbl_tracking.php
blob190f11ad2b403dfeb1cdf37516a23cfb22fe415f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Table tracking page
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Message;
9 use PhpMyAdmin\Tracker;
10 use PhpMyAdmin\Tracking;
11 use PhpMyAdmin\Response;
13 require_once './libraries/common.inc.php';
15 //Get some js files needed for Ajax requests
16 $response = Response::getInstance();
17 $header = $response->getHeader();
18 $scripts = $header->getScripts();
19 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
20 $scripts->addFile('tbl_tracking.js');
22 define('TABLE_MAY_BE_ABSENT', true);
23 require './libraries/tbl_common.inc.php';
25 if (Tracker::isActive()
26 && Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])
27 && ! (isset($_REQUEST['toggle_activation'])
28 && $_REQUEST['toggle_activation'] == 'deactivate_now')
29 && ! (isset($_REQUEST['report_export'])
30 && $_REQUEST['export_type'] == 'sqldumpfile')
31 ) {
32 $msg = Message::notice(
33 sprintf(
34 __('Tracking of %s is activated.'),
35 htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"])
38 $response->addHTML($msg->getDisplay());
41 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
42 $url_params['goto'] = 'tbl_tracking.php';
43 $url_params['back'] = 'tbl_tracking.php';
45 // Init vars for tracking report
46 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
47 $data = Tracker::getTrackedData(
48 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']
51 $selection_schema = false;
52 $selection_data = false;
53 $selection_both = false;
55 if (! isset($_REQUEST['logtype'])) {
56 $_REQUEST['logtype'] = 'schema_and_data';
58 if ($_REQUEST['logtype'] == 'schema') {
59 $selection_schema = true;
60 } elseif ($_REQUEST['logtype'] == 'data') {
61 $selection_data = true;
62 } else {
63 $selection_both = true;
65 if (! isset($_REQUEST['date_from'])) {
66 $_REQUEST['date_from'] = $data['date_from'];
68 if (! isset($_REQUEST['date_to'])) {
69 $_REQUEST['date_to'] = $data['date_to'];
71 if (! isset($_REQUEST['users'])) {
72 $_REQUEST['users'] = '*';
74 $filter_ts_from = strtotime($_REQUEST['date_from']);
75 $filter_ts_to = strtotime($_REQUEST['date_to']);
76 $filter_users = array_map('trim', explode(',', $_REQUEST['users']));
79 // Prepare export
80 if (isset($_REQUEST['report_export'])) {
81 $entries = Tracking::getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users);
84 // Export as file download
85 if (isset($_REQUEST['report_export'])
86 && $_REQUEST['export_type'] == 'sqldumpfile'
87 ) {
88 Tracking::exportAsFileDownload($entries);
91 $html = '<br />';
93 /**
94 * Actions
96 if (isset($_REQUEST['submit_mult'])) {
97 if (! empty($_REQUEST['selected_versions'])) {
98 if ($_REQUEST['submit_mult'] == 'delete_version') {
99 foreach ($_REQUEST['selected_versions'] as $version) {
100 Tracking::deleteTrackingVersion($version);
102 $html .= Message::success(
103 __('Tracking versions deleted successfully.')
104 )->getDisplay();
106 } else {
107 $html .= Message::notice(
108 __('No versions selected.')
109 )->getDisplay();
113 if (isset($_REQUEST['submit_delete_version'])) {
114 $html .= Tracking::deleteTrackingVersion($_REQUEST['version']);
117 // Create tracking version
118 if (isset($_REQUEST['submit_create_version'])) {
119 $html .= Tracking::createTrackingVersion();
122 // Deactivate tracking
123 if (isset($_REQUEST['toggle_activation'])
124 && $_REQUEST['toggle_activation'] == 'deactivate_now'
126 $html .= Tracking::changeTracking('deactivate');
129 // Activate tracking
130 if (isset($_REQUEST['toggle_activation'])
131 && $_REQUEST['toggle_activation'] == 'activate_now'
133 $html .= Tracking::changeTracking('activate');
136 // Export as SQL execution
137 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
138 $sql_result = Tracking::exportAsSqlExecution($entries);
139 $msg = Message::success(__('SQL statements executed.'));
140 $html .= $msg->getDisplay();
143 // Export as SQL dump
144 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
145 $html .= Tracking::exportAsSqlDump($entries);
149 * Schema snapshot
151 if (isset($_REQUEST['snapshot'])) {
152 $html .= Tracking::getHtmlForSchemaSnapshot($url_query);
154 // end of snapshot report
157 * Tracking report
159 if (isset($_REQUEST['report'])
160 && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))
162 $html .= Tracking::deleteTrackingReportRows($data);
165 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
166 $html .= Tracking::getHtmlForTrackingReport(
167 $url_query, $data, $url_params, $selection_schema, $selection_data,
168 $selection_both, $filter_ts_to, $filter_ts_from, $filter_users
170 } // end of report
174 * List selectable tables
176 $selectable_tables_sql_result = Tracking::getSqlResultForSelectableTables();
177 if ($GLOBALS['dbi']->numRows($selectable_tables_sql_result) > 0) {
178 $html .= Tracking::getHtmlForSelectableTables(
179 $selectable_tables_sql_result, $url_query
182 $html .= '<br />';
185 * List versions of current table
187 $sql_result = Tracking::getListOfVersionsOfTable();
188 $last_version = Tracking::getTableLastVersionNumber($sql_result);
189 if ($last_version > 0) {
190 $html .= Tracking::getHtmlForTableVersionDetails(
191 $sql_result, $last_version, $url_params,
192 $url_query, $pmaThemeImage, $text_dir
196 $type = $GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])
197 ->isView() ? 'view' : 'table';
198 $html .= Tracking::getHtmlForDataDefinitionAndManipulationStatements(
199 'tbl_tracking.php' . $url_query,
200 $last_version,
201 $GLOBALS['db'],
202 array($GLOBALS['table']),
203 $type
206 $html .= '<br class="clearfloat"/>';
208 $response->addHTML($html);