Merge branch 'QA_3_4'
[phpmyadmin-regexreplace.git] / tbl_tracking.php
blob9c3aae14b8928ecd2ee620309c94d3f7709ce0b0
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 header('Content-Type: text/x-sql');
116 header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
117 header('Content-Disposition: attachment; filename="' . $filename . '"');
118 if (PMA_USR_BROWSER_AGENT == 'IE') {
119 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
120 header('Pragma: public');
121 } else {
122 header('Pragma: no-cache');
123 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
126 echo $dump;
127 exit();
132 * Gets tables informations
136 * Displays top menu links
138 require_once './libraries/tbl_links.inc.php';
139 echo '<br />';
142 * Actions
145 // Create tracking version
146 if (isset($_REQUEST['submit_create_version'])) {
147 $tracking_set = '';
149 if ($_REQUEST['alter_table'] == true) {
150 $tracking_set .= 'ALTER TABLE,';
152 if ($_REQUEST['rename_table'] == true) {
153 $tracking_set .= 'RENAME TABLE,';
155 if ($_REQUEST['create_table'] == true) {
156 $tracking_set .= 'CREATE TABLE,';
158 if ($_REQUEST['drop_table'] == true) {
159 $tracking_set .= 'DROP TABLE,';
161 if ($_REQUEST['create_index'] == true) {
162 $tracking_set .= 'CREATE INDEX,';
164 if ($_REQUEST['drop_index'] == true) {
165 $tracking_set .= 'DROP INDEX,';
167 if ($_REQUEST['insert'] == true) {
168 $tracking_set .= 'INSERT,';
170 if ($_REQUEST['update'] == true) {
171 $tracking_set .= 'UPDATE,';
173 if ($_REQUEST['delete'] == true) {
174 $tracking_set .= 'DELETE,';
176 if ($_REQUEST['truncate'] == true) {
177 $tracking_set .= 'TRUNCATE,';
179 $tracking_set = rtrim($tracking_set, ',');
181 if (PMA_Tracker::createVersion($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version'], $tracking_set )) {
182 $msg = PMA_Message::success(sprintf(__('Version %s is created, tracking for %s.%s is activated.'), $_REQUEST['version'], $GLOBALS['db'], $GLOBALS['table']));
183 $msg->display();
187 // Deactivate tracking
188 if (isset($_REQUEST['submit_deactivate_now'])) {
189 if (PMA_Tracker::deactivateTracking($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version'])) {
190 $msg = PMA_Message::success(sprintf(__('Tracking for %s.%s , version %s is deactivated.'), $GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']));
191 $msg->display();
195 // Activate tracking
196 if (isset($_REQUEST['submit_activate_now'])) {
197 if (PMA_Tracker::activateTracking($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version'])) {
198 $msg = PMA_Message::success(sprintf(__('Tracking for %s.%s , version %s is activated.'), $GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']));
199 $msg->display();
203 // Export as SQL execution
204 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') {
205 foreach($entries as $entry) {
206 $sql_result = PMA_DBI_query( "/*NOTRACK*/\n" . $entry['statement'] );
208 $msg = PMA_Message::success(__('SQL statements executed.'));
209 $msg->display();
212 // Export as SQL dump
213 if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
214 $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" .
215 "# " . __('Comment out these two lines if you do not need them.') . "\n" .
216 "\n" .
217 "CREATE database IF NOT EXISTS pma_temp_db; \n" .
218 "USE pma_temp_db; \n" .
219 "\n";
221 foreach($entries as $entry) {
222 $new_query .= $entry['statement'];
224 $msg = PMA_Message::success(__('SQL statements exported. Please copy the dump or execute it.'));
225 $msg->display();
227 $db_temp = $db;
228 $table_temp = $table;
230 $db = $table = '';
231 require_once './libraries/sql_query_form.lib.php';
233 PMA_sqlQueryForm($new_query, 'sql');
235 $db = $db_temp;
236 $table = $table_temp;
240 * Schema snapshot
242 if (isset($_REQUEST['snapshot'])) {
244 <h3><?php echo __('Structure snapshot');?> [<a href="tbl_tracking.php?<?php echo $url_query;?>"><?php echo __('Close');?></a>]</h3>
245 <?php
246 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']);
248 // Get first DROP TABLE and CREATE TABLE statements
249 $drop_create_statements = $data['ddlog'][0]['statement'];
251 if (strstr($data['ddlog'][0]['statement'], 'DROP TABLE')) {
252 $drop_create_statements .= $data['ddlog'][1]['statement'];
254 // Print SQL code
255 PMA_showMessage(sprintf(__('Version %s snapshot (SQL code)'), $_REQUEST['version']), $drop_create_statements);
257 // Unserialize snapshot
258 $temp = unserialize($data['schema_snapshot']);
259 $columns = $temp['COLUMNS'];
260 $indexes = $temp['INDEXES'];
262 <h3><?php echo __('Structure');?></h3>
263 <table id="tablestructure" class="data">
264 <thead>
265 <tr>
266 <th><?php echo __('Column'); ?></th>
267 <th><?php echo __('Type'); ?></th>
268 <th><?php echo __('Collation'); ?></th>
269 <th><?php echo __('Null'); ?></th>
270 <th><?php echo __('Default'); ?></th>
271 <th><?php echo __('Extra'); ?></th>
272 <th><?php echo __('Comment'); ?></th>
273 </tr>
274 </thead>
275 <tbody>
276 <?php
277 $style = 'odd';
278 foreach($columns as $field_index => $field) {
280 <tr class="noclick <?php echo $style; ?>">
281 <?php
282 if ($field['Key'] == 'PRI') {
283 echo '<td><b><u>' . $field['Field'] . '</u></b></td>' . "\n";
284 } else {
285 echo '<td><b>' . $field['Field'] . '</b></td>' . "\n";
288 <td><?php echo $field['Type'];?></td>
289 <td><?php echo $field['Collation'];?></td>
290 <td><?php echo $field['Null'];?></td>
291 <td><?php echo $field['Default'];?></td>
292 <td><?php echo $field['Extra'];?></td>
293 <td><?php echo $field['Comment'];?></td>
294 </tr>
295 <?php
296 if ($style == 'even') {
297 $style = 'odd';
298 } else {
299 $style = 'even';
303 </tbody>
304 </table>
306 <?php
307 if (count($indexes) > 0) {
309 <h3><?php echo __('Indexes');?></h3>
310 <table id="tablestructure_indexes" class="data">
311 <thead>
312 <tr>
313 <th><?php echo __('Keyname');?></th>
314 <th><?php echo __('Type');?></th>
315 <th><?php echo __('Unique');?></th>
316 <th><?php echo __('Packed');?></th>
317 <th><?php echo __('Column');?></th>
318 <th><?php echo __('Cardinality');?></th>
319 <th><?php echo __('Collation');?></th>
320 <th><?php echo __('Null');?></th>
321 <th><?php echo __('Comment');?></th>
322 </tr>
323 <tbody>
324 <?php
325 $style = 'odd';
326 foreach ($indexes as $indexes_index => $index) {
327 if ($index['Non_unique'] == 0) {
328 $str_unique = __('Yes');
329 } else {
330 $str_unique = __('No');
332 if ($index['Packed'] != '') {
333 $str_packed = __('Yes');
334 } else {
335 $str_packed = __('No');
338 <tr class="noclick <?php echo $style; ?>">
339 <td><b><?php echo $index['Key_name'];?></b></td>
340 <td><?php echo $index['Index_type'];?></td>
341 <td><?php echo $str_unique;?></td>
342 <td><?php echo $str_packed;?></td>
343 <td><?php echo $index['Column_name'];?></td>
344 <td><?php echo $index['Cardinality'];?></td>
345 <td><?php echo $index['Collation'];?></td>
346 <td><?php echo $index['Null'];?></td>
347 <td><?php echo $index['Comment'];?></td>
348 </tr>
349 <?php
350 if ($style == 'even') {
351 $style = 'odd';
352 } else {
353 $style = 'even';
357 </tbody>
358 </table>
359 <?php
360 } // endif
362 <br /><hr /><br />
363 <?php
365 // end of snapshot report
368 * Tracking report
370 if (isset($_REQUEST['report']) && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))) {
372 if(isset($_REQUEST['delete_ddlog'])){
374 // Delete ddlog row data
375 $delete_id = $_REQUEST['delete_ddlog'];
377 // Only in case of valable id
378 if($delete_id == (int)$delete_id){
379 unset($data['ddlog'][$delete_id]);
381 if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DDL', $data['ddlog']))
382 $msg = PMA_Message::success(__('Tracking data definition succesfully deleted'));
383 else
384 $msg = PMA_Message::rawError(__('Query error'));
385 $msg->display();
389 if(isset($_REQUEST['delete_dmlog'])){
391 // Delete dmlog row data
392 $delete_id = $_REQUEST['delete_dmlog'];
394 // Only in case of valable id
395 if($delete_id == (int)$delete_id){
396 unset($data['dmlog'][$delete_id]);
398 if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DML', $data['dmlog']))
399 $msg = PMA_Message::success(__('Tracking data manipulation succesfully deleted'));
400 else
401 $msg = PMA_Message::rawError(__('Query error'));
402 $msg->display();
407 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
409 <h3><?php echo __('Tracking report');?> [<a href="tbl_tracking.php?<?php echo $url_query;?>"><?php echo __('Close');?></a>]</h3>
411 <small><?php echo __('Tracking statements') . ' ' . $data['tracking']; ?></small><br/>
412 <br/>
414 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>&amp;report=true&amp;version=<?php echo $_REQUEST['version'];?>">
415 <?php
417 $str1 = '<select name="logtype">' .
418 '<option value="schema"' . ($selection_schema ? ' selected="selected"' : '') . '>' . __('Structure only') . '</option>' .
419 '<option value="data"' . ($selection_data ? ' selected="selected"' : ''). '>' . __('Data only') . '</option>' .
420 '<option value="schema_and_data"' . ($selection_both ? ' selected="selected"' : '') . '>' . __('Structure and data') . '</option>' .
421 '</select>';
422 $str2 = '<input type="text" name="date_from" value="' . $_REQUEST['date_from'] . '" size="19" />';
423 $str3 = '<input type="text" name="date_to" value="' . $_REQUEST['date_to'] . '" size="19" />';
424 $str4 = '<input type="text" name="users" value="' . $_REQUEST['users'] . '" />';
425 $str5 = '<input type="submit" name="list_report" value="' . __('Go') . '" />';
427 printf(__('Show %s with dates from %s to %s by user %s %s'), $str1, $str2, $str3, $str4, $str5);
429 // Prepare delete link content here
430 $drop_image_or_text = '';
431 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
432 $drop_image_or_text .= '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . __('Delete tracking data row from report') . '" title="' . __('Delete tracking data row from report') . '" />';
434 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
435 $drop_image_or_text .= __('Delete');
439 * First, list tracked data definition statements
441 $i = 1;
442 if (count($data['ddlog']) == 0 && count($data['dmlog']) == 0) {
443 $msg = PMA_Message::notice(__('No data'));
444 $msg->display();
447 if ($selection_schema || $selection_both && count($data['ddlog']) > 0) {
449 <table id="ddl_versions" class="data" width="100%">
450 <thead>
451 <tr>
452 <th width="18">#</th>
453 <th width="100"><?php echo __('Date');?></th>
454 <th width="60"><?php echo __('Username');?></th>
455 <th><?php echo __('Data definition statement');?></th>
456 <th><?php echo __('Delete');?></th>
457 </tr>
458 </thead>
459 <tbody>
460 <?php
462 $style = 'odd';
463 foreach ($data['ddlog'] as $entry) {
464 if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
465 $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
466 } else {
467 $statement = PMA_formatSql(PMA_SQP_parse($entry['statement']));
469 $timestamp = strtotime($entry['date']);
471 if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to &&
472 ( in_array('*', $filter_users) || in_array($entry['username'], $filter_users) ) ) {
474 <tr class="noclick <?php echo $style; ?>">
475 <td><small><?php echo $i;?></small></td>
476 <td><small><?php echo $entry['date'];?></small></td>
477 <td><small><?php echo $entry['username']; ?></small></td>
478 <td><?php echo $statement; ?></td>
479 <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>
480 </tr>
481 <?php
482 if ($style == 'even') {
483 $style = 'odd';
484 } else {
485 $style = 'even';
487 $i++;
491 </tbody>
492 </table>
493 <?php
495 } //endif
497 // Memorize data definition amount
498 $ddlog_count = $i;
501 * Secondly, list tracked data manipulation statements
504 if (($selection_data || $selection_both) && count($data['dmlog']) > 0) {
506 <table id="dml_versions" class="data" width="100%">
507 <thead>
508 <tr>
509 <th width="18">#</th>
510 <th width="100"><?php echo __('Date');?></th>
511 <th width="60"><?php echo __('Username');?></th>
512 <th><?php echo __('Data manipulation statement');?></th>
513 <th><?php echo __('Delete');?></th>
514 </tr>
515 </thead>
516 <tbody>
517 <?php
518 $style = 'odd';
519 foreach ($data['dmlog'] as $entry) {
520 if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
521 $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
522 } else {
523 $statement = PMA_formatSql(PMA_SQP_parse($entry['statement']));
525 $timestamp = strtotime($entry['date']);
527 if ($timestamp >= $filter_ts_from && $timestamp <= $filter_ts_to &&
528 ( in_array('*', $filter_users) || in_array($entry['username'], $filter_users) ) ) {
530 <tr class="noclick <?php echo $style; ?>">
531 <td><small><?php echo $i; ?></small></td>
532 <td><small><?php echo $entry['date']; ?></small></td>
533 <td><small><?php echo $entry['username']; ?></small></td>
534 <td><?php echo $statement; ?></td>
535 <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>
536 </tr>
537 <?php
538 if ($style == 'even') {
539 $style = 'odd';
540 } else {
541 $style = 'even';
543 $i++;
547 </tbody>
548 </table>
549 <?php
552 </form>
553 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>&amp;report=true&amp;version=<?php echo $_REQUEST['version'];?>">
554 <?php
555 printf(__('Show %s with dates from %s to %s by user %s %s'), $str1, $str2, $str3, $str4, $str5);
557 $str_export1 = '<select name="export_type">' .
558 '<option value="sqldumpfile">' . __('SQL dump (file download)') . '</option>' .
559 '<option value="sqldump">' . __('SQL dump') . '</option>' .
560 '<option value="execution" onclick="alert(\'' . PMA_escapeJsString(__('This option will replace your table and contained data.')) .'\')">' . __('SQL execution') . '</option>' .
561 '</select>';
563 $str_export2 = '<input type="submit" name="report_export" value="' . __('Go') .'" />';
565 </form>
566 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>&amp;report=true&amp;version=<?php echo $_REQUEST['version'];?>">
567 <input type="hidden" name="logtype" value="<?php echo $_REQUEST['logtype'];?>" />
568 <input type="hidden" name="date_from" value="<?php echo $_REQUEST['date_from'];?>" />
569 <input type="hidden" name="date_to" value="<?php echo $_REQUEST['date_to'];?>" />
570 <input type="hidden" name="users" value="<?php echo $_REQUEST['users'];?>" />
571 <?php
572 echo "<br/>" . sprintf(__('Export as %s'), $str_export1) . $str_export2 . "<br/>";
574 </form>
575 <?php
576 echo "<br/><br/><hr/><br/>\n";
577 } // end of report
581 * List selectable tables
584 $sql_query = " SELECT DISTINCT db_name, table_name FROM " .
585 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." .
586 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
587 " WHERE " . PMA_backquote('db_name') . " = '" . PMA_sqlAddslashes($GLOBALS['db']) . "' " .
588 " ORDER BY ". PMA_backquote('db_name') . ", " . PMA_backquote('table_name');
590 $sql_result = PMA_query_as_controluser($sql_query);
592 if (PMA_DBI_num_rows($sql_result) > 0) {
594 <form method="post" action="tbl_tracking.php?<?php echo $url_query;?>">
595 <select name="table">
596 <?php
597 while ($entries = PMA_DBI_fetch_array($sql_result)) {
598 if (PMA_Tracker::isTracked($entries['db_name'], $entries['table_name'])) {
599 $status = ' (' . __('active') . ')';
600 } else {
601 $status = ' (' . __('not active') . ')';
603 if ($entries['table_name'] == $_REQUEST['table']) {
604 $s = ' selected="selected"';
605 } else {
606 $s = '';
608 echo '<option value="' . htmlspecialchars($entries['table_name']) . '"' . $s . '>' . htmlspecialchars($entries['db_name']) . ' . ' . htmlspecialchars($entries['table_name']) . $status . '</option>' . "\n";
611 </select>
612 <input type="submit" name="show_versions_submit" value="<?php echo __('Show versions');?>" />
613 </form>
614 <?php
617 <br />
618 <?php
621 * List versions of current table
624 $sql_query = " SELECT * FROM " .
625 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." .
626 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
627 " WHERE " . PMA_backquote('db_name') . " = '" . PMA_sqlAddslashes($_REQUEST['db']) . "' ".
628 " AND " . PMA_backquote('table_name') . " = '" . PMA_sqlAddslashes($_REQUEST['table']) ."' ".
629 " ORDER BY ". PMA_backquote('version') . " DESC ";
631 $sql_result = PMA_query_as_controluser($sql_query);
633 $last_version = 0;
634 $maxversion = PMA_DBI_fetch_array($sql_result);
635 $last_version = $maxversion['version'];
637 if ($last_version > 0) {
639 <table id="versions" class="data">
640 <thead>
641 <tr>
642 <th><?php echo __('Database');?></th>
643 <th><?php echo __('Table');?></th>
644 <th><?php echo __('Version');?></th>
645 <th><?php echo __('Created');?></th>
646 <th><?php echo __('Updated');?></th>
647 <th><?php echo __('Status');?></th>
648 <th><?php echo __('Show');?></th>
649 </tr>
650 </thead>
651 <tbody>
652 <?php
653 $style = 'odd';
654 PMA_DBI_data_seek($sql_result, 0);
655 while($version = PMA_DBI_fetch_array($sql_result)) {
656 if ($version['tracking_active'] == 1) {
657 $version_status = __('active');
658 } else {
659 $version_status = __('not active');
661 if ($version['version'] == $last_version){
662 if ($version['tracking_active'] == 1) {
663 $tracking_active = true;
664 } else {
665 $tracking_active = false;
669 <tr class="noclick <?php echo $style;?>">
670 <td><?php echo htmlspecialchars($version['db_name']);?></td>
671 <td><?php echo htmlspecialchars($version['table_name']);?></td>
672 <td><?php echo $version['version'];?></td>
673 <td><?php echo $version['date_created'];?></td>
674 <td><?php echo $version['date_updated'];?></td>
675 <td><?php echo $version_status;?></td>
676 <td> <a href="tbl_tracking.php?<?php echo $url_query;?>&amp;report=true&amp;version=<?php echo $version['version'];?>"><?php echo __('Tracking report');?></a> | <a href="tbl_tracking.php?<?php echo $url_query;?>&amp;snapshot=true&amp;version=<?php echo $version['version'];?>"><?php echo __('Structure snapshot');?></a></td>
677 </tr>
678 <?php
679 if ($style == 'even') {
680 $style = 'odd';
681 } else {
682 $style = 'even';
686 </tbody>
687 </table>
688 <?php if ($tracking_active == true) {?>
689 <div id="div_deactivate_tracking">
690 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
691 <fieldset>
692 <legend><?php printf(__('Deactivate tracking for %s.%s'), $GLOBALS['db'], $GLOBALS['table']); ?></legend>
693 <input type="hidden" name="version" value="<?php echo $last_version; ?>" />
694 <input type="submit" name="submit_deactivate_now" value="<?php echo __('Deactivate now'); ?>" />
695 </fieldset>
696 </form>
697 </div>
698 <?php
701 <?php if ($tracking_active == false) {?>
702 <div id="div_activate_tracking">
703 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
704 <fieldset>
705 <legend><?php printf(__('Activate tracking for %s.%s'), $GLOBALS['db'], $GLOBALS['table']); ?></legend>
706 <input type="hidden" name="version" value="<?php echo $last_version; ?>" />
707 <input type="submit" name="submit_activate_now" value="<?php echo __('Activate now'); ?>" />
708 </fieldset>
709 </form>
710 </div>
711 <?php
716 <div id="div_create_version">
717 <form method="post" action="tbl_tracking.php?<?php echo $url_query; ?>">
718 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
719 <fieldset>
720 <legend><?php printf(__('Create version %s of %s.%s'), ($last_version + 1), $GLOBALS['db'], $GLOBALS['table']); ?></legend>
722 <input type="hidden" name="version" value="<?php echo ($last_version + 1); ?>" />
724 <p><?php echo __('Track these data definition statements:');?></p>
725 <input type="checkbox" name="alter_table" value="true" checked="checked" /> ALTER TABLE<br/>
726 <input type="checkbox" name="rename_table" value="true" checked="checked" /> RENAME TABLE<br/>
727 <input type="checkbox" name="create_table" value="true" checked="checked" /> CREATE TABLE<br/>
728 <input type="checkbox" name="drop_table" value="true" checked="checked" /> DROP TABLE<br/>
729 <br/>
730 <input type="checkbox" name="create_index" value="true" checked="checked" /> CREATE INDEX<br/>
731 <input type="checkbox" name="drop_index" value="true" checked="checked" /> DROP INDEX<br/>
732 <p><?php echo __('Track these data manipulation statements:');?></p>
733 <input type="checkbox" name="insert" value="true" checked="checked" /> INSERT<br/>
734 <input type="checkbox" name="update" value="true" checked="checked" /> UPDATE<br/>
735 <input type="checkbox" name="delete" value="true" checked="checked" /> DELETE<br/>
736 <input type="checkbox" name="truncate" value="true" checked="checked" /> TRUNCATE<br/>
738 </fieldset>
739 <fieldset class="tblFooters">
740 <input type="submit" name="submit_create_version" value="<?php echo __('Create version'); ?>" />
741 </fieldset>
742 </form>
743 </div>
745 <br class="clearfloat"/>
747 <?php
749 * Displays the footer
751 require './libraries/footer.inc.php';