Translation update done using Pootle.
[phpmyadmin.git] / tbl_tracking.php
blob3f147451b8f769e8afa9f42e32b614e34d57fa0f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
8 // Run common work
9 require_once './libraries/common.inc.php';
11 define('TABLE_MAY_BE_ABSENT', true);
12 require './libraries/tbl_common.php';
13 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
14 $url_params['goto'] = 'tbl_tracking.php';;
15 $url_params['back'] = 'tbl_tracking.php';
17 // Init vars for tracking report
18 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
19 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']);
21 $selection_schema = false;
22 $selection_data = false;
23 $selection_both = false;
25 if (! isset($_REQUEST['logtype'])) {
26 $_REQUEST['logtype'] = 'schema_and_data';
28 if ($_REQUEST['logtype'] == 'schema') {
29 $selection_schema = true;
30 } elseif ($_REQUEST['logtype'] == 'data') {
31 $selection_data = true;
32 } else {
33 $selection_both = true;
35 if (! isset($_REQUEST['date_from'])) {
36 $_REQUEST['date_from'] = $data['date_from'];
38 if (! isset($_REQUEST['date_to'])) {
39 $_REQUEST['date_to'] = $data['date_to'];
41 if (! isset($_REQUEST['users'])) {
42 $_REQUEST['users'] = '*';
44 $filter_ts_from = strtotime($_REQUEST['date_from']);
45 $filter_ts_to = strtotime($_REQUEST['date_to']);
46 $filter_users = array_map('trim', explode(',', $_REQUEST['users']));
49 // Prepare export
50 if (isset($_REQUEST['report_export'])) {
52 /**
53 * Filters tracking entries
55 * @param array the entries to filter
56 * @param string "from" date
57 * @param string "to" date
58 * @param string users
60 * @return array filtered entries
63 function PMA_filter_tracking($data, $filter_ts_from, $filter_ts_to, $filter_users) {
64 $tmp_entries = array();
65 $id = 0;
66 foreach ( $data as $entry ) {
67 $timestamp = strtotime($entry['date']);
69 if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to &&
70 ( in_array('*', $filter_users) || in_array($entry['username'], $filter_users) ) ) {
71 $tmp_entries[] = array( 'id' => $id,
72 'timestamp' => $timestamp,
73 'username' => $entry['username'],
74 'statement' => $entry['statement']
77 $id++;
79 return($tmp_entries);
82 $entries = array();
83 // Filtering data definition statements
84 if ($_REQUEST['logtype'] == 'schema' || $_REQUEST['logtype'] == 'schema_and_data') {
85 $entries = array_merge($entries, PMA_filter_tracking($data['ddlog'], $filter_ts_from, $filter_ts_to, $filter_users));
88 // Filtering data manipulation statements
89 if ($_REQUEST['logtype'] == 'data' || $_REQUEST['logtype'] == 'schema_and_data') {
90 $entries = array_merge($entries, PMA_filter_tracking($data['dmlog'], $filter_ts_from, $filter_ts_to, $filter_users));
93 // Sort it
94 foreach ($entries as $key => $row) {
95 $ids[$key] = $row['id'];
96 $timestamps[$key] = $row['timestamp'];
97 $usernames[$key] = $row['username'];
98 $statements[$key] = $row['statement'];
101 array_multisort($timestamps, SORT_ASC, $ids, SORT_ASC, $usernames, SORT_ASC, $statements, SORT_ASC, $entries);
105 // Export as file download
106 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldumpfile') {
107 @ini_set('url_rewriter.tags', '');
109 $dump = "# " . sprintf(__('Tracking report for table `%s`'), htmlspecialchars($_REQUEST['table'])) . "\n" .
110 "# " . date('Y-m-d H:i:s') . "\n";
111 foreach ($entries as $entry) {
112 $dump .= $entry['statement'];
114 $filename = 'log_' . htmlspecialchars($_REQUEST['table']) . '.sql';
115 PMA_download_header($filename, 'text/x-sql', strlen($dump));
117 echo $dump;
118 exit();
123 * Gets tables informations
127 * Displays top menu links
129 require_once './libraries/tbl_links.inc.php';
130 echo '<br />';
133 * Actions
136 // Create tracking version
137 if (isset($_REQUEST['submit_create_version'])) {
138 $tracking_set = '';
140 if ($_REQUEST['alter_table'] == true) {
141 $tracking_set .= 'ALTER TABLE,';
143 if ($_REQUEST['rename_table'] == true) {
144 $tracking_set .= 'RENAME TABLE,';
146 if ($_REQUEST['create_table'] == true) {
147 $tracking_set .= 'CREATE TABLE,';
149 if ($_REQUEST['drop_table'] == true) {
150 $tracking_set .= 'DROP TABLE,';
152 if ($_REQUEST['create_index'] == true) {
153 $tracking_set .= 'CREATE INDEX,';
155 if ($_REQUEST['drop_index'] == true) {
156 $tracking_set .= 'DROP INDEX,';
158 if ($_REQUEST['insert'] == true) {
159 $tracking_set .= 'INSERT,';
161 if ($_REQUEST['update'] == true) {
162 $tracking_set .= 'UPDATE,';
164 if ($_REQUEST['delete'] == true) {
165 $tracking_set .= 'DELETE,';
167 if ($_REQUEST['truncate'] == true) {
168 $tracking_set .= 'TRUNCATE,';
170 $tracking_set = rtrim($tracking_set, ',');
172 if (PMA_Tracker::createVersion($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version'], $tracking_set )) {
173 $msg = PMA_Message::success(sprintf(__('Version %s is created, tracking for %s.%s is activated.'), $_REQUEST['version'], htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table'])));
174 $msg->display();
178 // Deactivate tracking
179 if (isset($_REQUEST['submit_deactivate_now'])) {
180 if (PMA_Tracker::deactivateTracking($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version'])) {
181 $msg = PMA_Message::success(sprintf(__('Tracking for %s.%s , version %s is deactivated.'), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table']), $_REQUEST['version']));
182 $msg->display();
186 // Activate tracking
187 if (isset($_REQUEST['submit_activate_now'])) {
188 if (PMA_Tracker::activateTracking($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version'])) {
189 $msg = PMA_Message::success(sprintf(__('Tracking for %s.%s , version %s is activated.'), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table']), $_REQUEST['version']));
190 $msg->display();
194 // Export as SQL execution
195 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
196 foreach ($entries as $entry) {
197 $sql_result = PMA_DBI_query( "/*NOTRACK*/\n" . $entry['statement'] );
199 $msg = PMA_Message::success(__('SQL statements executed.'));
200 $msg->display();
203 // Export as SQL dump
204 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
205 $new_query = "# " . __('You can execute the dump by creating and using a temporary database. Please ensure that you have the privileges to do so.') . "\n" .
206 "# " . __('Comment out these two lines if you do not need them.') . "\n" .
207 "\n" .
208 "CREATE database IF NOT EXISTS pma_temp_db; \n" .
209 "USE pma_temp_db; \n" .
210 "\n";
212 foreach ($entries as $entry) {
213 $new_query .= $entry['statement'];
215 $msg = PMA_Message::success(__('SQL statements exported. Please copy the dump or execute it.'));
216 $msg->display();
218 $db_temp = $db;
219 $table_temp = $table;
221 $db = $table = '';
222 include_once './libraries/sql_query_form.lib.php';
224 PMA_sqlQueryForm($new_query, 'sql');
226 $db = $db_temp;
227 $table = $table_temp;
231 * Schema snapshot
233 if (isset($_REQUEST['snapshot'])) {
235 <h3><?php echo __('Structure snapshot');?> [<a href="tbl_tracking.php?<?php echo $url_query;?>"><?php echo __('Close');?></a>]</h3>
236 <?php
237 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']);
239 // Get first DROP TABLE and CREATE TABLE statements
240 $drop_create_statements = $data['ddlog'][0]['statement'];
242 if (strstr($data['ddlog'][0]['statement'], 'DROP TABLE')) {
243 $drop_create_statements .= $data['ddlog'][1]['statement'];
245 // Print SQL code
246 PMA_showMessage(sprintf(__('Version %s snapshot (SQL code)'), $_REQUEST['version']), $drop_create_statements);
248 // Unserialize snapshot
249 $temp = unserialize($data['schema_snapshot']);
250 $columns = $temp['COLUMNS'];
251 $indexes = $temp['INDEXES'];
253 <h3><?php echo __('Structure');?></h3>
254 <table id="tablestructure" class="data">
255 <thead>
256 <tr>
257 <th><?php echo __('Column'); ?></th>
258 <th><?php echo __('Type'); ?></th>
259 <th><?php echo __('Collation'); ?></th>
260 <th><?php echo __('Null'); ?></th>
261 <th><?php echo __('Default'); ?></th>
262 <th><?php echo __('Extra'); ?></th>
263 <th><?php echo __('Comment'); ?></th>
264 </tr>
265 </thead>
266 <tbody>
267 <?php
268 $style = 'odd';
269 foreach ($columns as $field_index => $field) {
271 <tr class="noclick <?php echo $style; ?>">
272 <?php
273 if ($field['Key'] == 'PRI') {
274 echo '<td><b><u>' . htmlspecialchars($field['Field']) . '</u></b></td>' . "\n";
275 } else {
276 echo '<td><b>' . htmlspecialchars($field['Field']) . '</b></td>' . "\n";
279 <td><?php echo htmlspecialchars($field['Type']);?></td>
280 <td><?php echo htmlspecialchars($field['Collation']);?></td>
281 <td><?php echo (($field['Null'] == 'YES') ? __('Yes') : __('No')); ?></td>
282 <td><?php
283 if (isset($field['Default'])) {
284 $extracted_fieldspec = PMA_extractFieldSpec($field['Type']);
285 if ($extracted_fieldspec['type'] == 'bit') {
286 // here, $field['Default'] contains something like b'010'
287 echo PMA_convert_bit_default_value($field['Default']);
288 } else {
289 echo htmlspecialchars($field['Default']);
291 } else {
292 if ($field['Null'] == 'YES') {
293 echo '<i>NULL</i>';
294 } else {
295 echo '<i>' . _pgettext('None for default', 'None') . '</i>';
297 } ?></td>
298 <td><?php echo htmlspecialchars($field['Extra']);?></td>
299 <td><?php echo htmlspecialchars($field['Comment']);?></td>
300 </tr>
301 <?php
302 if ($style == 'even') {
303 $style = 'odd';
304 } else {
305 $style = 'even';
309 </tbody>
310 </table>
312 <?php
313 if (count($indexes) > 0) {
315 <h3><?php echo __('Indexes');?></h3>
316 <table id="tablestructure_indexes" class="data">
317 <thead>
318 <tr>
319 <th><?php echo __('Keyname');?></th>
320 <th><?php echo __('Type');?></th>
321 <th><?php echo __('Unique');?></th>
322 <th><?php echo __('Packed');?></th>
323 <th><?php echo __('Column');?></th>
324 <th><?php echo __('Cardinality');?></th>
325 <th><?php echo __('Collation');?></th>
326 <th><?php echo __('Null');?></th>
327 <th><?php echo __('Comment');?></th>
328 </tr>
329 <tbody>
330 <?php
331 $style = 'odd';
332 foreach ($indexes as $indexes_index => $index) {
333 if ($index['Non_unique'] == 0) {
334 $str_unique = __('Yes');
335 } else {
336 $str_unique = __('No');
338 if ($index['Packed'] != '') {
339 $str_packed = __('Yes');
340 } else {
341 $str_packed = __('No');
344 <tr class="noclick <?php echo $style; ?>">
345 <td><b><?php echo htmlspecialchars($index['Key_name']);?></b></td>
346 <td><?php echo htmlspecialchars($index['Index_type']);?></td>
347 <td><?php echo $str_unique;?></td>
348 <td><?php echo $str_packed;?></td>
349 <td><?php echo htmlspecialchars($index['Column_name']);?></td>
350 <td><?php echo htmlspecialchars($index['Cardinality']);?></td>
351 <td><?php echo htmlspecialchars($index['Collation']);?></td>
352 <td><?php echo htmlspecialchars($index['Null']);?></td>
353 <td><?php echo htmlspecialchars($index['Comment']);?></td>
354 </tr>
355 <?php
356 if ($style == 'even') {
357 $style = 'odd';
358 } else {
359 $style = 'even';
363 </tbody>
364 </table>
365 <?php
366 } // endif
368 <br /><hr /><br />
369 <?php
371 // end of snapshot report
374 * Tracking report
376 if (isset($_REQUEST['report']) && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))) {
378 if (isset($_REQUEST['delete_ddlog'])) {
380 // Delete ddlog row data
381 $delete_id = $_REQUEST['delete_ddlog'];
383 // Only in case of valable id
384 if ($delete_id == (int)$delete_id) {
385 unset($data['ddlog'][$delete_id]);
387 if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DDL', $data['ddlog']))
388 $msg = PMA_Message::success(__('Tracking data definition successfully deleted'));
389 else
390 $msg = PMA_Message::rawError(__('Query error'));
391 $msg->display();
395 if (isset($_REQUEST['delete_dmlog'])) {
397 // Delete dmlog row data
398 $delete_id = $_REQUEST['delete_dmlog'];
400 // Only in case of valable id
401 if ($delete_id == (int)$delete_id) {
402 unset($data['dmlog'][$delete_id]);
404 if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DML', $data['dmlog']))
405 $msg = PMA_Message::success(__('Tracking data manipulation successfully deleted'));
406 else
407 $msg = PMA_Message::rawError(__('Query error'));
408 $msg->display();
413 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
415 <h3><?php echo __('Tracking report');?> [<a href="tbl_tracking.php?<?php echo $url_query;?>"><?php echo __('Close');?></a>]</h3>
417 <small><?php echo __('Tracking statements') . ' ' . htmlspecialchars($data['tracking']); ?></small><br/>
418 <br/>
420 <form method="post" action="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $_REQUEST['version'])); ?>">
421 <?php
423 $str1 = '<select name="logtype">' .
424 '<option value="schema"' . ($selection_schema ? ' selected="selected"' : '') . '>' . __('Structure only') . '</option>' .
425 '<option value="data"' . ($selection_data ? ' selected="selected"' : ''). '>' . __('Data only') . '</option>' .
426 '<option value="schema_and_data"' . ($selection_both ? ' selected="selected"' : '') . '>' . __('Structure and data') . '</option>' .
427 '</select>';
428 $str2 = '<input type="text" name="date_from" value="' . htmlspecialchars($_REQUEST['date_from']) . '" size="19" />';
429 $str3 = '<input type="text" name="date_to" value="' . htmlspecialchars($_REQUEST['date_to']) . '" size="19" />';
430 $str4 = '<input type="text" name="users" value="' . htmlspecialchars($_REQUEST['users']) . '" />';
431 $str5 = '<input type="submit" name="list_report" value="' . __('Go') . '" />';
433 printf(__('Show %s with dates from %s to %s by user %s %s'), $str1, $str2, $str3, $str4, $str5);
435 // Prepare delete link content here
436 $drop_image_or_text = '';
437 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
438 $drop_image_or_text .= PMA_getImage('b_drop.png', __('Delete tracking data row from report'));
440 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
441 $drop_image_or_text .= __('Delete');
445 * First, list tracked data definition statements
447 $i = 1;
448 if (count($data['ddlog']) == 0 && count($data['dmlog']) == 0) {
449 $msg = PMA_Message::notice(__('No data'));
450 $msg->display();
453 if ($selection_schema || $selection_both && count($data['ddlog']) > 0) {
455 <table id="ddl_versions" class="data" width="100%">
456 <thead>
457 <tr>
458 <th width="18">#</th>
459 <th width="100"><?php echo __('Date');?></th>
460 <th width="60"><?php echo __('Username');?></th>
461 <th><?php echo __('Data definition statement');?></th>
462 <th><?php echo __('Delete');?></th>
463 </tr>
464 </thead>
465 <tbody>
466 <?php
468 $style = 'odd';
469 foreach ($data['ddlog'] as $entry) {
470 if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
471 $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
472 } else {
473 $statement = PMA_formatSql(PMA_SQP_parse($entry['statement']));
475 $timestamp = strtotime($entry['date']);
477 if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to &&
478 ( in_array('*', $filter_users) || in_array($entry['username'], $filter_users) ) ) {
480 <tr class="noclick <?php echo $style; ?>">
481 <td><small><?php echo $i;?></small></td>
482 <td><small><?php echo htmlspecialchars($entry['date']);?></small></td>
483 <td><small><?php echo htmlspecialchars($entry['username']); ?></small></td>
484 <td><?php echo $statement; ?></td>
485 <td nowrap="nowrap"><a href="tbl_tracking.php?<?php echo $url_query;?>&amp;report=true&amp;version=<?php echo $version['version'];?>&amp;delete_ddlog=<?php echo $i-1; ?>"><?php echo $drop_image_or_text; ?></a></td>
486 </tr>
487 <?php
488 if ($style == 'even') {
489 $style = 'odd';
490 } else {
491 $style = 'even';
493 $i++;
497 </tbody>
498 </table>
499 <?php
501 } //endif
503 // Memorize data definition amount
504 $ddlog_count = $i;
507 * Secondly, list tracked data manipulation statements
510 if (($selection_data || $selection_both) && count($data['dmlog']) > 0) {
512 <table id="dml_versions" class="data" width="100%">
513 <thead>
514 <tr>
515 <th width="18">#</th>
516 <th width="100"><?php echo __('Date');?></th>
517 <th width="60"><?php echo __('Username');?></th>
518 <th><?php echo __('Data manipulation statement');?></th>
519 <th><?php echo __('Delete');?></th>
520 </tr>
521 </thead>
522 <tbody>
523 <?php
524 $style = 'odd';
525 foreach ($data['dmlog'] as $entry) {
526 if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
527 $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
528 } else {
529 $statement = PMA_formatSql(PMA_SQP_parse($entry['statement']));
531 $timestamp = strtotime($entry['date']);
533 if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to &&
534 ( in_array('*', $filter_users) || in_array($entry['username'], $filter_users) ) ) {
536 <tr class="noclick <?php echo $style; ?>">
537 <td><small><?php echo $i; ?></small></td>
538 <td><small><?php echo htmlspecialchars($entry['date']); ?></small></td>
539 <td><small><?php echo htmlspecialchars($entry['username']); ?></small></td>
540 <td><?php echo $statement; ?></td>
541 <td nowrap="nowrap"><a href="tbl_tracking.php?<?php echo $url_query;?>&amp;report=true&amp;version=<?php echo $version['version'];?>&amp;delete_dmlog=<?php echo $i-$ddlog_count; ?>"><?php echo $drop_image_or_text; ?></a></td>
542 </tr>
543 <?php
544 if ($style == 'even') {
545 $style = 'odd';
546 } else {
547 $style = 'even';
549 $i++;
553 </tbody>
554 </table>
555 <?php
558 </form>
559 <form method="post" action="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $_REQUEST['version'])); ?>">
560 <?php
561 printf(__('Show %s with dates from %s to %s by user %s %s'), $str1, $str2, $str3, $str4, $str5);
563 $str_export1 = '<select name="export_type">' .
564 '<option value="sqldumpfile">' . __('SQL dump (file download)') . '</option>' .
565 '<option value="sqldump">' . __('SQL dump') . '</option>' .
566 '<option value="execution" onclick="alert(\'' . PMA_escapeJsString(__('This option will replace your table and contained data.')) .'\')">' . __('SQL execution') . '</option>' .
567 '</select>';
569 $str_export2 = '<input type="submit" name="report_export" value="' . __('Go') .'" />';
571 </form>
572 <form method="post" action="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $_REQUEST['version'])); ?>">
573 <input type="hidden" name="logtype" value="<?php echo htmlspecialchars($_REQUEST['logtype']);?>" />
574 <input type="hidden" name="date_from" value="<?php echo htmlspecialchars($_REQUEST['date_from']);?>" />
575 <input type="hidden" name="date_to" value="<?php echo htmlspecialchars($_REQUEST['date_to']);?>" />
576 <input type="hidden" name="users" value="<?php echo htmlspecialchars($_REQUEST['users']);?>" />
577 <?php
578 echo "<br/>" . sprintf(__('Export as %s'), $str_export1) . $str_export2 . "<br/>";
580 </form>
581 <?php
582 echo "<br/><br/><hr/><br/>\n";
583 } // end of report
587 * List selectable tables
590 $sql_query = " SELECT DISTINCT db_name, table_name FROM " .
591 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." .
592 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
593 " WHERE db_name = '" . PMA_sqlAddSlashes($GLOBALS['db']) . "' " .
594 " ORDER BY db_name, table_name";
596 $sql_result = PMA_query_as_controluser($sql_query);
598 if (PMA_DBI_num_rows($sql_result) > 0) {
600 <form method="post" action="tbl_tracking.php?<?php echo $url_query;?>">
601 <select name="table">
602 <?php
603 while ($entries = PMA_DBI_fetch_array($sql_result)) {
604 if (PMA_Tracker::isTracked($entries['db_name'], $entries['table_name'])) {
605 $status = ' (' . __('active') . ')';
606 } else {
607 $status = ' (' . __('not active') . ')';
609 if ($entries['table_name'] == $_REQUEST['table']) {
610 $s = ' selected="selected"';
611 } else {
612 $s = '';
614 echo '<option value="' . htmlspecialchars($entries['table_name']) . '"' . $s . '>' . htmlspecialchars($entries['db_name']) . ' . ' . htmlspecialchars($entries['table_name']) . $status . '</option>' . "\n";
617 </select>
618 <input type="submit" name="show_versions_submit" value="<?php echo __('Show versions');?>" />
619 </form>
620 <?php
623 <br />
624 <?php
627 * List versions of current table
630 $sql_query = " SELECT * FROM " .
631 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." .
632 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
633 " WHERE db_name = '" . PMA_sqlAddSlashes($_REQUEST['db']) . "' ".
634 " AND table_name = '" . PMA_sqlAddSlashes($_REQUEST['table']) ."' ".
635 " ORDER BY version DESC ";
637 $sql_result = PMA_query_as_controluser($sql_query);
639 $last_version = 0;
640 $maxversion = PMA_DBI_fetch_array($sql_result);
641 $last_version = $maxversion['version'];
643 if ($last_version > 0) {
645 <table id="versions" class="data">
646 <thead>
647 <tr>
648 <th><?php echo __('Database');?></th>
649 <th><?php echo __('Table');?></th>
650 <th><?php echo __('Version');?></th>
651 <th><?php echo __('Created');?></th>
652 <th><?php echo __('Updated');?></th>
653 <th><?php echo __('Status');?></th>
654 <th><?php echo __('Show');?></th>
655 </tr>
656 </thead>
657 <tbody>
658 <?php
659 $style = 'odd';
660 PMA_DBI_data_seek($sql_result, 0);
661 while ($version = PMA_DBI_fetch_array($sql_result)) {
662 if ($version['tracking_active'] == 1) {
663 $version_status = __('active');
664 } else {
665 $version_status = __('not active');
667 if ($version['version'] == $last_version) {
668 if ($version['tracking_active'] == 1) {
669 $tracking_active = true;
670 } else {
671 $tracking_active = false;
675 <tr class="noclick <?php echo $style;?>">
676 <td><?php echo htmlspecialchars($version['db_name']);?></td>
677 <td><?php echo htmlspecialchars($version['table_name']);?></td>
678 <td><?php echo htmlspecialchars($version['version']);?></td>
679 <td><?php echo htmlspecialchars($version['date_created']);?></td>
680 <td><?php echo htmlspecialchars($version['date_updated']);?></td>
681 <td><?php echo $version_status;?></td>
682 <td> <a href="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $version['version'])
683 );?>"><?php echo __('Tracking report');?></a>
684 | <a href="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('snapshot' => 'true', 'version' => $version['version'])
685 );?>"><?php echo __('Structure snapshot');?></a>
686 </td>
687 </tr>
688 <?php
689 if ($style == 'even') {
690 $style = 'odd';
691 } else {
692 $style = 'even';
696 </tbody>
697 </table>
698 <?php if ($tracking_active == true) {?>
699 <div id="div_deactivate_tracking">
700 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
701 <fieldset>
702 <legend><?php printf(__('Deactivate tracking for %s.%s'), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table'])); ?></legend>
703 <input type="hidden" name="version" value="<?php echo $last_version; ?>" />
704 <input type="submit" name="submit_deactivate_now" value="<?php echo __('Deactivate now'); ?>" />
705 </fieldset>
706 </form>
707 </div>
708 <?php
711 <?php if ($tracking_active == false) {?>
712 <div id="div_activate_tracking">
713 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
714 <fieldset>
715 <legend><?php printf(__('Activate tracking for %s.%s'), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table'])); ?></legend>
716 <input type="hidden" name="version" value="<?php echo $last_version; ?>" />
717 <input type="submit" name="submit_activate_now" value="<?php echo __('Activate now'); ?>" />
718 </fieldset>
719 </form>
720 </div>
721 <?php
726 <div id="div_create_version">
727 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
728 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
729 <fieldset>
730 <legend><?php printf(__('Create version %s of %s.%s'), ($last_version + 1), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table'])); ?></legend>
732 <input type="hidden" name="version" value="<?php echo ($last_version + 1); ?>" />
734 <p><?php echo __('Track these data definition statements:');?></p>
735 <input type="checkbox" name="alter_table" value="true" checked="checked" /> ALTER TABLE<br/>
736 <input type="checkbox" name="rename_table" value="true" checked="checked" /> RENAME TABLE<br/>
737 <input type="checkbox" name="create_table" value="true" checked="checked" /> CREATE TABLE<br/>
738 <input type="checkbox" name="drop_table" value="true" checked="checked" /> DROP TABLE<br/>
739 <br/>
740 <input type="checkbox" name="create_index" value="true" checked="checked" /> CREATE INDEX<br/>
741 <input type="checkbox" name="drop_index" value="true" checked="checked" /> DROP INDEX<br/>
742 <p><?php echo __('Track these data manipulation statements:');?></p>
743 <input type="checkbox" name="insert" value="true" checked="checked" /> INSERT<br/>
744 <input type="checkbox" name="update" value="true" checked="checked" /> UPDATE<br/>
745 <input type="checkbox" name="delete" value="true" checked="checked" /> DELETE<br/>
746 <input type="checkbox" name="truncate" value="true" checked="checked" /> TRUNCATE<br/>
748 </fieldset>
749 <fieldset class="tblFooters">
750 <input type="submit" name="submit_create_version" value="<?php echo __('Create version'); ?>" />
751 </fieldset>
752 </form>
753 </div>
755 <br class="clearfloat"/>
757 <?php
759 * Displays the footer
761 require './libraries/footer.inc.php';