3.3.6 release
[phpmyadmin-themes.git] / db_tracking.php
blob799e96b1f0fe9e8b4264623d414b2025d229ff7a
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @version $Id$
5 * @author Alexander Rutkowski
6 * @package phpMyAdmin
7 */
9 // Run common work
10 require_once './libraries/common.inc.php';
11 require_once './libraries/Table.class.php';
13 require './libraries/db_common.inc.php';
14 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
16 // Get the database structure
17 $sub_part = '_structure';
18 require './libraries/db_info.inc.php';
20 // Get relation settings
21 require_once './libraries/relation.lib.php';
23 // Work to do?
24 // (here, do not use $_REQUEST['db] as it can be crafted)
25 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
26 PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
29 // Get tracked data about the database
30 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
32 // No tables present and no log exist
33 if ($num_tables == 0 && count($data['ddlog']) == 0) {
34 echo '<p>' . $strNoTablesFound . '</p>' . "\n";
36 if (empty($db_is_information_schema)) {
37 require './libraries/display_create_table.lib.php';
40 // Display the footer
41 require_once './libraries/footer.inc.php';
42 exit;
45 // ---------------------------------------------------------------------------
48 * Display top menu links
50 require_once './libraries/db_links.inc.php';
52 // Prepare statement to get HEAD version
53 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
54 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
55 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
56 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
57 ' GROUP BY '. PMA_backquote('table_name') .
58 ' ORDER BY '. PMA_backquote('table_name') .' ASC';
60 $all_tables_result = PMA_query_as_controluser($all_tables_query);
62 // If a HEAD version exists
63 if (PMA_DBI_num_rows($all_tables_result) > 0) {
65 <h3><?php echo $strTrackingTrackedTables;?></h3>
67 <table id="versions" class="data">
68 <thead>
69 <tr>
70 <th><?php echo $strDatabase;?></th>
71 <th><?php echo $strTable;?></th>
72 <th><?php echo $strTrackingThLastVersion;?></th>
73 <th><?php echo $strTrackingThCreated;?></th>
74 <th><?php echo $strTrackingThUpdated;?></th>
75 <th><?php echo $strStatus;?></th>
76 <th><?php echo $strAction;?></th>
77 <th><?php echo $strShow;?></th>
78 </tr>
79 </thead>
80 <tbody>
81 <?php
83 // Print out information about versions
85 $drop_image_or_text = '';
86 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
87 $drop_image_or_text .= '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . $strDeleteTrackingData . '" title="' . $strDeleteTrackingData . '" />';
89 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
90 $drop_image_or_text .= $strDrop;
93 $style = 'odd';
94 while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
95 list($table_name, $version_number) = $one_result;
96 $table_query = ' SELECT * FROM ' .
97 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
98 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
99 ' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
101 $table_result = PMA_query_as_controluser($table_query);
102 $version_data = PMA_DBI_fetch_array($table_result);
104 if ($version_data['tracking_active'] == 1) {
105 $version_status = $strTrackingStatusActive;
106 } else {
107 $version_status = $strTrackingStatusNotActive;
109 $tmp_link = 'tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
110 $delete_link = 'db_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
112 <tr class="<?php echo $style;?>">
113 <td><?php echo htmlspecialchars($version_data['db_name']);?></td>
114 <td><?php echo htmlspecialchars($version_data['table_name']);?></td>
115 <td><?php echo $version_data['version'];?></td>
116 <td><?php echo $version_data['date_created'];?></td>
117 <td><?php echo $version_data['date_updated'];?></td>
118 <td><?php echo $version_status;?></td>
119 <td><a href="<?php echo $delete_link;?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($strDeleteTrackingData, false); ?>')"><?php echo $drop_image_or_text; ?></a></td>
120 <td> <a href="<?php echo $tmp_link; ?>"><?php echo $strTrackingVersions;?></a>
121 | <a href="<?php echo $tmp_link; ?>&amp;report=true&amp;version=<?php echo $version_data['version'];?>"><?php echo $strTrackingReport;?></a>
122 | <a href="<?php echo $tmp_link; ?>&amp;snapshot=true&amp;version=<?php echo $version_data['version'];?>"><?php echo $strTrackingStructureSnapshot;?></a></td>
123 </tr>
124 <?php
125 if ($style == 'even') {
126 $style = 'odd';
127 } else {
128 $style = 'even';
131 unset($tmp_link);
133 </tbody>
134 </table>
135 <?php
138 // Get list of tables
139 $table_list = PMA_getTableList($GLOBALS['db']);
141 // For each table try to get the tracking version
142 foreach ($table_list as $key => $value) {
143 if (PMA_Tracker::getVersion($GLOBALS['db'], $value['Name']) == -1) {
144 $my_tables[] = $value['Name'];
148 // If untracked tables exist
149 if (isset($my_tables)) {
151 <h3><?php echo $strTrackingUntrackedTables;?></h3>
153 <table id="noversions" class="data">
154 <thead>
155 <tr>
156 <th width="300"><?php echo $strTable;?></th>
157 <th></th>
158 </tr>
159 </thead>
160 <tbody>
161 <?php
162 // Print out list of untracked tables
164 $style = 'odd';
166 foreach ($my_tables as $key => $tablename) {
167 if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
168 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($tablename) .'">';
170 if ($cfg['PropertiesIconic']) {
171 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
173 $my_link .= $strTrackingTrackTable . '</a>';
175 <tr class="<?php echo $style;?>">
176 <td><?php echo htmlspecialchars($tablename);?></td>
177 <td><?php echo $my_link;?></td>
178 </tr>
179 <?php
180 if ($style == 'even') {
181 $style = 'odd';
182 } else {
183 $style = 'even';
188 </tbody>
189 </table>
191 <?php
193 // If available print out database log
194 if (count($data['ddlog']) > 0) {
195 $log = '';
196 foreach ($data['ddlog'] as $entry) {
197 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
199 PMA_showMessage($strTrackingDatabaseLog, $log);
203 * Display the footer
205 require_once './libraries/footer.inc.php';