Translated using Weblate (Malay)
[phpmyadmin.git] / tbl_tracking.php
blob7f8c44613b04543d7f7775a8c8c7033b65d9b748
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('jquery/jquery.tablesorter.js');
19 $scripts->addFile('tbl_tracking.js');
21 define('TABLE_MAY_BE_ABSENT', true);
22 require './libraries/tbl_common.inc.php';
24 if (PMA_Tracker::isActive()
25 && PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])
26 && ! (isset($_REQUEST['toggle_activation'])
27 && $_REQUEST['toggle_activation'] == 'deactivate_now')
28 && ! (isset($_REQUEST['report_export'])
29 && $_REQUEST['export_type'] == 'sqldumpfile')
30 ) {
31 $msg = PMA_Message::notice(
32 sprintf(
33 __('Tracking of %s is activated.'),
34 htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"])
37 PMA_Response::getInstance()->addHTML($msg->getDisplay());
40 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
41 $url_params['goto'] = 'tbl_tracking.php';
42 $url_params['back'] = 'tbl_tracking.php';
44 // Init vars for tracking report
45 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
46 $data = PMA_Tracker::getTrackedData(
47 $_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']
50 $selection_schema = false;
51 $selection_data = false;
52 $selection_both = false;
54 if (! isset($_REQUEST['logtype'])) {
55 $_REQUEST['logtype'] = 'schema_and_data';
57 if ($_REQUEST['logtype'] == 'schema') {
58 $selection_schema = true;
59 } elseif ($_REQUEST['logtype'] == 'data') {
60 $selection_data = true;
61 } else {
62 $selection_both = true;
64 if (! isset($_REQUEST['date_from'])) {
65 $_REQUEST['date_from'] = $data['date_from'];
67 if (! isset($_REQUEST['date_to'])) {
68 $_REQUEST['date_to'] = $data['date_to'];
70 if (! isset($_REQUEST['users'])) {
71 $_REQUEST['users'] = '*';
73 $filter_ts_from = strtotime($_REQUEST['date_from']);
74 $filter_ts_to = strtotime($_REQUEST['date_to']);
75 $filter_users = array_map('trim', explode(',', $_REQUEST['users']));
78 // Prepare export
79 if (isset($_REQUEST['report_export'])) {
80 $entries = PMA_getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users);
83 // Export as file download
84 if (isset($_REQUEST['report_export'])
85 && $_REQUEST['export_type'] == 'sqldumpfile'
86 ) {
87 PMA_exportAsFileDownload($entries);
90 $html = '<br />';
92 /**
93 * Actions
95 if (isset($_REQUEST['submit_mult'])) {
96 if (! empty($_REQUEST['selected_versions'])) {
97 if ($_REQUEST['submit_mult'] == 'delete_version') {
98 foreach ($_REQUEST['selected_versions'] as $version) {
99 PMA_deleteTrackingVersion($version);
101 $html .= PMA_Message::success(
102 __('Tracking versions deleted successfully.')
103 )->getDisplay();
105 } else {
106 $html .= PMA_Message::notice(
107 __('No versions selected.')
108 )->getDisplay();
112 if (isset($_REQUEST['submit_delete_version'])) {
113 $html .= PMA_deleteTrackingVersion($_REQUEST['version']);
116 // Create tracking version
117 if (isset($_REQUEST['submit_create_version'])) {
118 $html .= PMA_createTrackingVersion();
121 // Deactivate tracking
122 if (isset($_REQUEST['toggle_activation'])
123 && $_REQUEST['toggle_activation'] == 'deactivate_now'
125 $html .= PMA_deactivateTracking();
128 // Activate tracking
129 if (isset($_REQUEST['toggle_activation'])
130 && $_REQUEST['toggle_activation'] == 'activate_now'
132 $html .= PMA_activateTracking();
135 // Export as SQL execution
136 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
137 $sql_result = PMA_exportAsSQLExecution($entries);
138 $msg = PMA_Message::success(__('SQL statements executed.'));
139 $html .= $msg->getDisplay();
142 // Export as SQL dump
143 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
144 $html .= PMA_exportAsSQLDump($entries);
148 * Schema snapshot
150 if (isset($_REQUEST['snapshot'])) {
151 $html .= PMA_getHtmlForSchemaSnapshot($url_query);
153 // end of snapshot report
156 * Tracking report
158 if (isset($_REQUEST['report'])
159 && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))
161 $html .= PMA_deleteTrackingReportRows($data);
164 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
165 $html .= PMA_getHtmlForTrackingReport(
166 $url_query, $data, $url_params, $selection_schema, $selection_data,
167 $selection_both, $filter_ts_to, $filter_ts_from, $filter_users
169 } // end of report
173 * List selectable tables
175 $selectable_tables_sql_result = PMA_getSQLResultForSelectableTables();
176 if ($GLOBALS['dbi']->numRows($selectable_tables_sql_result) > 0) {
177 $html .= PMA_getHtmlForSelectableTables(
178 $selectable_tables_sql_result, $url_query
181 $html .= '<br />';
184 * List versions of current table
186 $sql_result = PMA_getListOfVersionsOfTable();
187 $last_version = PMA_getTableLastVersionNumber($sql_result);
188 if ($last_version > 0) {
189 $html .= PMA_getHtmlForTableVersionDetails(
190 $sql_result, $last_version, $url_params,
191 $url_query, $pmaThemeImage, $text_dir
195 $type = $GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])
196 ->isView() ? 'view' : 'table';
197 $html .= PMA_getHtmlForDataDefinitionAndManipulationStatements(
198 'tbl_tracking.php' . $url_query,
199 $last_version,
200 $GLOBALS['db'],
201 array($GLOBALS['table']),
202 $type
205 $html .= '<br class="clearfloat"/>';
207 $response = PMA_Response::getInstance();
208 $response->addHTML($html);