Merge branch 'QA_3_4'
[phpmyadmin.git] / tbl_tracking.php
blob496982a828903bb34e8dfc5ad81a13404f16c60d
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 htmlspecialchars($field['Null']);?></td>
282 <td><?php echo htmlspecialchars($field['Default']);?></td>
283 <td><?php echo htmlspecialchars($field['Extra']);?></td>
284 <td><?php echo htmlspecialchars($field['Comment']);?></td>
285 </tr>
286 <?php
287 if ($style == 'even') {
288 $style = 'odd';
289 } else {
290 $style = 'even';
294 </tbody>
295 </table>
297 <?php
298 if (count($indexes) > 0) {
300 <h3><?php echo __('Indexes');?></h3>
301 <table id="tablestructure_indexes" class="data">
302 <thead>
303 <tr>
304 <th><?php echo __('Keyname');?></th>
305 <th><?php echo __('Type');?></th>
306 <th><?php echo __('Unique');?></th>
307 <th><?php echo __('Packed');?></th>
308 <th><?php echo __('Column');?></th>
309 <th><?php echo __('Cardinality');?></th>
310 <th><?php echo __('Collation');?></th>
311 <th><?php echo __('Null');?></th>
312 <th><?php echo __('Comment');?></th>
313 </tr>
314 <tbody>
315 <?php
316 $style = 'odd';
317 foreach ($indexes as $indexes_index => $index) {
318 if ($index['Non_unique'] == 0) {
319 $str_unique = __('Yes');
320 } else {
321 $str_unique = __('No');
323 if ($index['Packed'] != '') {
324 $str_packed = __('Yes');
325 } else {
326 $str_packed = __('No');
329 <tr class="noclick <?php echo $style; ?>">
330 <td><b><?php echo htmlspecialchars($index['Key_name']);?></b></td>
331 <td><?php echo htmlspecialchars($index['Index_type']);?></td>
332 <td><?php echo $str_unique;?></td>
333 <td><?php echo $str_packed;?></td>
334 <td><?php echo htmlspecialchars($index['Column_name']);?></td>
335 <td><?php echo htmlspecialchars($index['Cardinality']);?></td>
336 <td><?php echo htmlspecialchars($index['Collation']);?></td>
337 <td><?php echo htmlspecialchars($index['Null']);?></td>
338 <td><?php echo htmlspecialchars($index['Comment']);?></td>
339 </tr>
340 <?php
341 if ($style == 'even') {
342 $style = 'odd';
343 } else {
344 $style = 'even';
348 </tbody>
349 </table>
350 <?php
351 } // endif
353 <br /><hr /><br />
354 <?php
356 // end of snapshot report
359 * Tracking report
361 if (isset($_REQUEST['report']) && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))) {
363 if (isset($_REQUEST['delete_ddlog'])) {
365 // Delete ddlog row data
366 $delete_id = $_REQUEST['delete_ddlog'];
368 // Only in case of valable id
369 if ($delete_id == (int)$delete_id) {
370 unset($data['ddlog'][$delete_id]);
372 if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DDL', $data['ddlog']))
373 $msg = PMA_Message::success(__('Tracking data definition successfully deleted'));
374 else
375 $msg = PMA_Message::rawError(__('Query error'));
376 $msg->display();
380 if (isset($_REQUEST['delete_dmlog'])) {
382 // Delete dmlog row data
383 $delete_id = $_REQUEST['delete_dmlog'];
385 // Only in case of valable id
386 if ($delete_id == (int)$delete_id) {
387 unset($data['dmlog'][$delete_id]);
389 if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DML', $data['dmlog']))
390 $msg = PMA_Message::success(__('Tracking data manipulation successfully deleted'));
391 else
392 $msg = PMA_Message::rawError(__('Query error'));
393 $msg->display();
398 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
400 <h3><?php echo __('Tracking report');?> [<a href="tbl_tracking.php?<?php echo $url_query;?>"><?php echo __('Close');?></a>]</h3>
402 <small><?php echo __('Tracking statements') . ' ' . htmlspecialchars($data['tracking']); ?></small><br/>
403 <br/>
405 <form method="post" action="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $_REQUEST['version'])); ?>">
406 <?php
408 $str1 = '<select name="logtype">' .
409 '<option value="schema"' . ($selection_schema ? ' selected="selected"' : '') . '>' . __('Structure only') . '</option>' .
410 '<option value="data"' . ($selection_data ? ' selected="selected"' : ''). '>' . __('Data only') . '</option>' .
411 '<option value="schema_and_data"' . ($selection_both ? ' selected="selected"' : '') . '>' . __('Structure and data') . '</option>' .
412 '</select>';
413 $str2 = '<input type="text" name="date_from" value="' . htmlspecialchars($_REQUEST['date_from']) . '" size="19" />';
414 $str3 = '<input type="text" name="date_to" value="' . htmlspecialchars($_REQUEST['date_to']) . '" size="19" />';
415 $str4 = '<input type="text" name="users" value="' . htmlspecialchars($_REQUEST['users']) . '" />';
416 $str5 = '<input type="submit" name="list_report" value="' . __('Go') . '" />';
418 printf(__('Show %s with dates from %s to %s by user %s %s'), $str1, $str2, $str3, $str4, $str5);
420 // Prepare delete link content here
421 $drop_image_or_text = '';
422 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
423 $drop_image_or_text .= '<img class="icon ic_b_drop" src="themes/dot.gif" alt="' . __('Delete tracking data row from report') . '" title="' . __('Delete tracking data row from report') . '" />';
425 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
426 $drop_image_or_text .= __('Delete');
430 * First, list tracked data definition statements
432 $i = 1;
433 if (count($data['ddlog']) == 0 && count($data['dmlog']) == 0) {
434 $msg = PMA_Message::notice(__('No data'));
435 $msg->display();
438 if ($selection_schema || $selection_both && count($data['ddlog']) > 0) {
440 <table id="ddl_versions" class="data" width="100%">
441 <thead>
442 <tr>
443 <th width="18">#</th>
444 <th width="100"><?php echo __('Date');?></th>
445 <th width="60"><?php echo __('Username');?></th>
446 <th><?php echo __('Data definition statement');?></th>
447 <th><?php echo __('Delete');?></th>
448 </tr>
449 </thead>
450 <tbody>
451 <?php
453 $style = 'odd';
454 foreach ($data['ddlog'] as $entry) {
455 if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
456 $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
457 } else {
458 $statement = PMA_formatSql(PMA_SQP_parse($entry['statement']));
460 $timestamp = strtotime($entry['date']);
462 if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to &&
463 ( in_array('*', $filter_users) || in_array($entry['username'], $filter_users) ) ) {
465 <tr class="noclick <?php echo $style; ?>">
466 <td><small><?php echo $i;?></small></td>
467 <td><small><?php echo htmlspecialchars($entry['date']);?></small></td>
468 <td><small><?php echo htmlspecialchars($entry['username']); ?></small></td>
469 <td><?php echo $statement; ?></td>
470 <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>
471 </tr>
472 <?php
473 if ($style == 'even') {
474 $style = 'odd';
475 } else {
476 $style = 'even';
478 $i++;
482 </tbody>
483 </table>
484 <?php
486 } //endif
488 // Memorize data definition amount
489 $ddlog_count = $i;
492 * Secondly, list tracked data manipulation statements
495 if (($selection_data || $selection_both) && count($data['dmlog']) > 0) {
497 <table id="dml_versions" class="data" width="100%">
498 <thead>
499 <tr>
500 <th width="18">#</th>
501 <th width="100"><?php echo __('Date');?></th>
502 <th width="60"><?php echo __('Username');?></th>
503 <th><?php echo __('Data manipulation statement');?></th>
504 <th><?php echo __('Delete');?></th>
505 </tr>
506 </thead>
507 <tbody>
508 <?php
509 $style = 'odd';
510 foreach ($data['dmlog'] as $entry) {
511 if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
512 $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
513 } else {
514 $statement = PMA_formatSql(PMA_SQP_parse($entry['statement']));
516 $timestamp = strtotime($entry['date']);
518 if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to &&
519 ( in_array('*', $filter_users) || in_array($entry['username'], $filter_users) ) ) {
521 <tr class="noclick <?php echo $style; ?>">
522 <td><small><?php echo $i; ?></small></td>
523 <td><small><?php echo htmlspecialchars($entry['date']); ?></small></td>
524 <td><small><?php echo htmlspecialchars($entry['username']); ?></small></td>
525 <td><?php echo $statement; ?></td>
526 <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>
527 </tr>
528 <?php
529 if ($style == 'even') {
530 $style = 'odd';
531 } else {
532 $style = 'even';
534 $i++;
538 </tbody>
539 </table>
540 <?php
543 </form>
544 <form method="post" action="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $_REQUEST['version'])); ?>">
545 <?php
546 printf(__('Show %s with dates from %s to %s by user %s %s'), $str1, $str2, $str3, $str4, $str5);
548 $str_export1 = '<select name="export_type">' .
549 '<option value="sqldumpfile">' . __('SQL dump (file download)') . '</option>' .
550 '<option value="sqldump">' . __('SQL dump') . '</option>' .
551 '<option value="execution" onclick="alert(\'' . PMA_escapeJsString(__('This option will replace your table and contained data.')) .'\')">' . __('SQL execution') . '</option>' .
552 '</select>';
554 $str_export2 = '<input type="submit" name="report_export" value="' . __('Go') .'" />';
556 </form>
557 <form method="post" action="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $_REQUEST['version'])); ?>">
558 <input type="hidden" name="logtype" value="<?php echo htmlspecialchars($_REQUEST['logtype']);?>" />
559 <input type="hidden" name="date_from" value="<?php echo htmlspecialchars($_REQUEST['date_from']);?>" />
560 <input type="hidden" name="date_to" value="<?php echo htmlspecialchars($_REQUEST['date_to']);?>" />
561 <input type="hidden" name="users" value="<?php echo htmlspecialchars($_REQUEST['users']);?>" />
562 <?php
563 echo "<br/>" . sprintf(__('Export as %s'), $str_export1) . $str_export2 . "<br/>";
565 </form>
566 <?php
567 echo "<br/><br/><hr/><br/>\n";
568 } // end of report
572 * List selectable tables
575 $sql_query = " SELECT DISTINCT db_name, table_name FROM " .
576 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." .
577 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
578 " WHERE db_name = '" . PMA_sqlAddSlashes($GLOBALS['db']) . "' " .
579 " ORDER BY db_name, table_name";
581 $sql_result = PMA_query_as_controluser($sql_query);
583 if (PMA_DBI_num_rows($sql_result) > 0) {
585 <form method="post" action="tbl_tracking.php?<?php echo $url_query;?>">
586 <select name="table">
587 <?php
588 while ($entries = PMA_DBI_fetch_array($sql_result)) {
589 if (PMA_Tracker::isTracked($entries['db_name'], $entries['table_name'])) {
590 $status = ' (' . __('active') . ')';
591 } else {
592 $status = ' (' . __('not active') . ')';
594 if ($entries['table_name'] == $_REQUEST['table']) {
595 $s = ' selected="selected"';
596 } else {
597 $s = '';
599 echo '<option value="' . htmlspecialchars($entries['table_name']) . '"' . $s . '>' . htmlspecialchars($entries['db_name']) . ' . ' . htmlspecialchars($entries['table_name']) . $status . '</option>' . "\n";
602 </select>
603 <input type="submit" name="show_versions_submit" value="<?php echo __('Show versions');?>" />
604 </form>
605 <?php
608 <br />
609 <?php
612 * List versions of current table
615 $sql_query = " SELECT * FROM " .
616 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." .
617 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
618 " WHERE db_name = '" . PMA_sqlAddSlashes($_REQUEST['db']) . "' ".
619 " AND table_name = '" . PMA_sqlAddSlashes($_REQUEST['table']) ."' ".
620 " ORDER BY version DESC ";
622 $sql_result = PMA_query_as_controluser($sql_query);
624 $last_version = 0;
625 $maxversion = PMA_DBI_fetch_array($sql_result);
626 $last_version = $maxversion['version'];
628 if ($last_version > 0) {
630 <table id="versions" class="data">
631 <thead>
632 <tr>
633 <th><?php echo __('Database');?></th>
634 <th><?php echo __('Table');?></th>
635 <th><?php echo __('Version');?></th>
636 <th><?php echo __('Created');?></th>
637 <th><?php echo __('Updated');?></th>
638 <th><?php echo __('Status');?></th>
639 <th><?php echo __('Show');?></th>
640 </tr>
641 </thead>
642 <tbody>
643 <?php
644 $style = 'odd';
645 PMA_DBI_data_seek($sql_result, 0);
646 while ($version = PMA_DBI_fetch_array($sql_result)) {
647 if ($version['tracking_active'] == 1) {
648 $version_status = __('active');
649 } else {
650 $version_status = __('not active');
652 if ($version['version'] == $last_version) {
653 if ($version['tracking_active'] == 1) {
654 $tracking_active = true;
655 } else {
656 $tracking_active = false;
660 <tr class="noclick <?php echo $style;?>">
661 <td><?php echo htmlspecialchars($version['db_name']);?></td>
662 <td><?php echo htmlspecialchars($version['table_name']);?></td>
663 <td><?php echo htmlspecialchars($version['version']);?></td>
664 <td><?php echo htmlspecialchars($version['date_created']);?></td>
665 <td><?php echo htmlspecialchars($version['date_updated']);?></td>
666 <td><?php echo $version_status;?></td>
667 <td> <a href="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('report' => 'true', 'version' => $version['version'])
668 );?>"><?php echo __('Tracking report');?></a>
669 | <a href="tbl_tracking.php<?php echo PMA_generate_common_url($url_params + array('snapshot' => 'true', 'version' => $version['version'])
670 );?>"><?php echo __('Structure snapshot');?></a>
671 </td>
672 </tr>
673 <?php
674 if ($style == 'even') {
675 $style = 'odd';
676 } else {
677 $style = 'even';
681 </tbody>
682 </table>
683 <?php if ($tracking_active == true) {?>
684 <div id="div_deactivate_tracking">
685 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
686 <fieldset>
687 <legend><?php printf(__('Deactivate tracking for %s.%s'), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table'])); ?></legend>
688 <input type="hidden" name="version" value="<?php echo $last_version; ?>" />
689 <input type="submit" name="submit_deactivate_now" value="<?php echo __('Deactivate now'); ?>" />
690 </fieldset>
691 </form>
692 </div>
693 <?php
696 <?php if ($tracking_active == false) {?>
697 <div id="div_activate_tracking">
698 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
699 <fieldset>
700 <legend><?php printf(__('Activate tracking for %s.%s'), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table'])); ?></legend>
701 <input type="hidden" name="version" value="<?php echo $last_version; ?>" />
702 <input type="submit" name="submit_activate_now" value="<?php echo __('Activate now'); ?>" />
703 </fieldset>
704 </form>
705 </div>
706 <?php
711 <div id="div_create_version">
712 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
713 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
714 <fieldset>
715 <legend><?php printf(__('Create version %s of %s.%s'), ($last_version + 1), htmlspecialchars($GLOBALS['db']), htmlspecialchars($GLOBALS['table'])); ?></legend>
717 <input type="hidden" name="version" value="<?php echo ($last_version + 1); ?>" />
719 <p><?php echo __('Track these data definition statements:');?></p>
720 <input type="checkbox" name="alter_table" value="true" checked="checked" /> ALTER TABLE<br/>
721 <input type="checkbox" name="rename_table" value="true" checked="checked" /> RENAME TABLE<br/>
722 <input type="checkbox" name="create_table" value="true" checked="checked" /> CREATE TABLE<br/>
723 <input type="checkbox" name="drop_table" value="true" checked="checked" /> DROP TABLE<br/>
724 <br/>
725 <input type="checkbox" name="create_index" value="true" checked="checked" /> CREATE INDEX<br/>
726 <input type="checkbox" name="drop_index" value="true" checked="checked" /> DROP INDEX<br/>
727 <p><?php echo __('Track these data manipulation statements:');?></p>
728 <input type="checkbox" name="insert" value="true" checked="checked" /> INSERT<br/>
729 <input type="checkbox" name="update" value="true" checked="checked" /> UPDATE<br/>
730 <input type="checkbox" name="delete" value="true" checked="checked" /> DELETE<br/>
731 <input type="checkbox" name="truncate" value="true" checked="checked" /> TRUNCATE<br/>
733 </fieldset>
734 <fieldset class="tblFooters">
735 <input type="submit" name="submit_create_version" value="<?php echo __('Create version'); ?>" />
736 </fieldset>
737 </form>
738 </div>
740 <br class="clearfloat"/>
742 <?php
744 * Displays the footer
746 require './libraries/footer.inc.php';