Translated using Weblate (Greek)
[phpmyadmin.git] / tbl_tracking.php
blob7d15ffe99af36e729ae11059156ff16417016fcc
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/tracking.lib.php';
14 //Get some js files needed for Ajax requests
15 $response = PMA_Response::getInstance();
16 $header = $response->getHeader();
17 $scripts = $header->getScripts();
18 $scripts->addFile('tbl_tracking.js');
20 define('TABLE_MAY_BE_ABSENT', true);
21 require './libraries/tbl_common.inc.php';
23 if (PMA_Tracker::isActive()
24 && PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])
25 && ! isset($_REQUEST['submit_deactivate_now'])
26 && ! (isset($_REQUEST['report_export'])
27 && $_REQUEST['export_type'] == 'sqldumpfile')
28 ) {
29 $msg = PMA_Message::notice(
30 sprintf(
31 __('Tracking of %s is activated.'),
32 htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"])
35 PMA_Response::getInstance()->addHTML($msg->getDisplay());
38 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
39 $url_params['goto'] = 'tbl_tracking.php';
40 $url_params['back'] = 'tbl_tracking.php';
42 // Init vars for tracking report
43 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
44 $data = PMA_Tracker::getTrackedData(
45 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']
48 $selection_schema = false;
49 $selection_data = false;
50 $selection_both = false;
52 if (! isset($_REQUEST['logtype'])) {
53 $_REQUEST['logtype'] = 'schema_and_data';
55 if ($_REQUEST['logtype'] == 'schema') {
56 $selection_schema = true;
57 } elseif ($_REQUEST['logtype'] == 'data') {
58 $selection_data = true;
59 } else {
60 $selection_both = true;
62 if (! isset($_REQUEST['date_from'])) {
63 $_REQUEST['date_from'] = $data['date_from'];
65 if (! isset($_REQUEST['date_to'])) {
66 $_REQUEST['date_to'] = $data['date_to'];
68 if (! isset($_REQUEST['users'])) {
69 $_REQUEST['users'] = '*';
71 $filter_ts_from = strtotime($_REQUEST['date_from']);
72 $filter_ts_to = strtotime($_REQUEST['date_to']);
73 $filter_users = array_map('trim', explode(',', $_REQUEST['users']));
76 // Prepare export
77 if (isset($_REQUEST['report_export'])) {
78 $entries = PMA_getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users);
81 // Export as file download
82 if (isset($_REQUEST['report_export'])
83 && $_REQUEST['export_type'] == 'sqldumpfile'
84 ) {
85 PMA_exportAsFileDownload($entries);
88 $html = '<br />';
90 /**
91 * Actions
93 if (isset($_REQUEST['submit_mult'])) {
94 if (! empty($_REQUEST['selected_versions'])) {
95 if ($_REQUEST['submit_mult'] == 'delete_version') {
96 foreach ($_REQUEST['selected_versions'] as $version) {
97 PMA_deleteTrackingVersion($version);
99 $html .= PMA_Message::success(
100 __('Tracking versions deleted successfully.')
101 )->getDisplay();
103 } else {
104 $html .= PMA_Message::notice(
105 __('No versions selected.')
106 )->getDisplay();
110 if (isset($_REQUEST['submit_delete_version'])) {
111 $html .= PMA_deleteTrackingVersion($_REQUEST['version']);
114 // Create tracking version
115 if (isset($_REQUEST['submit_create_version'])) {
116 $html .= PMA_createTrackingVersion();
119 // Deactivate tracking
120 if (isset($_REQUEST['submit_deactivate_now'])) {
121 $html .= PMA_deactivateTracking();
124 // Activate tracking
125 if (isset($_REQUEST['submit_activate_now'])) {
126 $html .= PMA_activateTracking();
129 // Export as SQL execution
130 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
131 $sql_result = PMA_exportAsSQLExecution($entries);
132 $msg = PMA_Message::success(__('SQL statements executed.'));
133 $html .= $msg->getDisplay();
136 // Export as SQL dump
137 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
138 $html .= PMA_exportAsSQLDump($entries);
142 * Schema snapshot
144 if (isset($_REQUEST['snapshot'])) {
145 $html .= PMA_getHtmlForSchemaSnapshot($url_query);
147 // end of snapshot report
150 * Tracking report
152 if (isset($_REQUEST['report'])
153 && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))
155 $html .= PMA_deleteTrackingReportRows($data);
158 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
159 $html .= PMA_getHtmlForTrackingReport(
160 $url_query, $data, $url_params, $selection_schema, $selection_data,
161 $selection_both, $filter_ts_to, $filter_ts_from, $filter_users
163 } // end of report
167 * List selectable tables
169 $selectable_tables_sql_result = PMA_getSQLResultForSelectableTables();
170 if ($GLOBALS['dbi']->numRows($selectable_tables_sql_result) > 0) {
171 $html .= PMA_getHtmlForSelectableTables(
172 $selectable_tables_sql_result, $url_query
175 $html .= '<br />';
178 * List versions of current table
180 $sql_result = PMA_getListOfVersionsOfTable();
181 $last_version = PMA_getTableLastVersionNumber($sql_result);
182 if ($last_version > 0) {
183 $html .= PMA_getHtmlForTableVersionDetails(
184 $sql_result, $last_version, $url_params,
185 $url_query, $pmaThemeImage, $text_dir
189 $html .= PMA_getHtmlForDataDefinitionAndManipulationStatements(
190 'tbl_tracking.php' . $url_query,
191 $last_version,
192 $GLOBALS['db'],
193 array($GLOBALS['table'])
196 $html .= '<br class="clearfloat"/>';
198 $response = PMA_Response::getInstance();
199 $response->addHTML($html);