2 /* vim: set expandtab sw=4 ts=4 sts=4: */
10 require_once './libraries/common.inc.php';
12 require './libraries/db_common.inc.php';
13 $url_query .= '&goto=tbl_tracking.php&back=db_tracking.php';
15 // Get the database structure
16 $sub_part = '_structure';
17 require './libraries/db_info.inc.php';
20 // (here, do not use $_REQUEST['db] as it can be crafted)
21 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
22 PMA_Tracker
::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
25 // Get tracked data about the database
26 $data = PMA_Tracker
::getTrackedData($_REQUEST['db'], '', '1');
28 // No tables present and no log exist
29 if ($num_tables == 0 && count($data['ddlog']) == 0) {
30 echo '<p>' . __('No tables found in database.') . '</p>' . "\n";
32 if (empty($db_is_information_schema)) {
33 require './libraries/display_create_table.lib.php';
37 require './libraries/footer.inc.php';
41 // ---------------------------------------------------------------------------
44 * Display top menu links
46 require_once './libraries/db_links.inc.php';
48 // Prepare statement to get HEAD version
49 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
50 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
51 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
52 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
53 ' GROUP BY '. PMA_backquote('table_name') .
54 ' ORDER BY '. PMA_backquote('table_name') .' ASC';
56 $all_tables_result = PMA_query_as_controluser($all_tables_query);
58 // If a HEAD version exists
59 if (PMA_DBI_num_rows($all_tables_result) > 0) {
61 <h3
><?php
echo __('Tracked tables');?
></h3
>
63 <table id
="versions" class="data">
66 <th
><?php
echo __('Database');?
></th
>
67 <th
><?php
echo __('Table');?
></th
>
68 <th
><?php
echo __('Last version');?
></th
>
69 <th
><?php
echo __('Created');?
></th
>
70 <th
><?php
echo __('Updated');?
></th
>
71 <th
><?php
echo __('Status');?
></th
>
72 <th
><?php
echo __('Action');?
></th
>
73 <th
><?php
echo __('Show');?
></th
>
79 // Print out information about versions
81 $drop_image_or_text = '';
82 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
83 $drop_image_or_text .= '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . __('Delete tracking data for this table') . '" title="' . __('Delete tracking data for this table') . '" />';
85 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] ||
false === $GLOBALS['cfg']['PropertiesIconic']) {
86 $drop_image_or_text .= __('Drop');
90 while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
91 list($table_name, $version_number) = $one_result;
92 $table_query = ' SELECT * FROM ' .
93 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
94 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
95 ' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
97 $table_result = PMA_query_as_controluser($table_query);
98 $version_data = PMA_DBI_fetch_array($table_result);
100 if ($version_data['tracking_active'] == 1) {
101 $version_status = __('active');
103 $version_status = __('not active');
105 $tmp_link = 'tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']);
106 $delete_link = 'db_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']) . '&delete_tracking=true&';
108 <tr
class="<?php echo $style;?>">
109 <td
><?php
echo htmlspecialchars($version_data['db_name']);?
></td
>
110 <td
><?php
echo htmlspecialchars($version_data['table_name']);?
></td
>
111 <td
><?php
echo $version_data['version'];?
></td
>
112 <td
><?php
echo $version_data['date_created'];?
></td
>
113 <td
><?php
echo $version_data['date_updated'];?
></td
>
114 <td
><?php
echo $version_status;?
></td
>
115 <td
><a href
="<?php echo $delete_link;?>" onclick
="return confirmLink(this, '<?php echo PMA_jsFormat(__('Delete tracking data for this table'), false); ?>')"><?php
echo $drop_image_or_text; ?
></a
></td
>
116 <td
> <a href
="<?php echo $tmp_link; ?>"><?php
echo __('Versions');?
></a
>
117 |
<a href
="<?php echo $tmp_link; ?>&report=true&version=<?php echo $version_data['version'];?>"><?php
echo __('Tracking report');?
></a
>
118 |
<a href
="<?php echo $tmp_link; ?>&snapshot=true&version=<?php echo $version_data['version'];?>"><?php
echo __('Structure snapshot');?
></a
></td
>
121 if ($style == 'even') {
134 // Get list of tables
135 $table_list = PMA_getTableList($GLOBALS['db']);
137 // For each table try to get the tracking version
138 foreach ($table_list as $key => $value) {
139 if (PMA_Tracker
::getVersion($GLOBALS['db'], $value['Name']) == -1) {
140 $my_tables[] = $value['Name'];
144 // If untracked tables exist
145 if (isset($my_tables)) {
147 <h3
><?php
echo __('Untracked tables');?
></h3
>
149 <table id
="noversions" class="data">
152 <th width
="300"><?php
echo __('Table');?
></th
>
158 // Print out list of untracked tables
162 foreach ($my_tables as $key => $tablename) {
163 if (PMA_Tracker
::getVersion($GLOBALS['db'], $tablename) == -1) {
164 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($tablename) .'">';
166 if ($cfg['PropertiesIconic']) {
167 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
169 $my_link .= __('Track table') . '</a>';
171 <tr
class="<?php echo $style;?>">
172 <td
><?php
echo htmlspecialchars($tablename);?
></td
>
173 <td
><?php
echo $my_link;?
></td
>
176 if ($style == 'even') {
189 // If available print out database log
190 if (count($data['ddlog']) > 0) {
192 foreach ($data['ddlog'] as $entry) {
193 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
195 PMA_showMessage(__('Database Log'), $log);
201 require './libraries/footer.inc.php';