typo in HTML
[phpmyadmin/madhuracj.git] / db_tracking.php
blob68d284cc08edff21868093266c6acd250563d773
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 // Get tracked data about the database
24 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
26 // No tables present and no log exist
27 if ($num_tables == 0 && count($data['ddlog']) == 0) {
28 echo '<p>' . $strNoTablesFound . '</p>' . "\n";
30 if (empty($db_is_information_schema)) {
31 require './libraries/display_create_table.lib.php';
34 // Display the footer
35 require_once './libraries/footer.inc.php';
36 exit;
39 // ---------------------------------------------------------------------------
42 * Display top menu links
44 require_once './libraries/db_links.inc.php';
46 <p/>
47 <p/>
48 <?php
51 * List versions of current table
54 // Prepare statement to get HEAD version
55 $sql_query = ' SELECT *, MAX(version) as version FROM ' .
56 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
57 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
58 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
59 ' AND ' . PMA_backquote('table_name') . ' <> \'' . PMA_sqlAddslashes('') . '\' ' .
60 ' GROUP BY '. PMA_backquote('table_name') .
61 ' ORDER BY '. PMA_backquote('table_name') .'ASC , '. PMA_backquote('version') .' ASC ';
63 $sql_result = PMA_query_as_controluser($sql_query);
65 // Init HEAD version
66 $last_version = 0;
68 // Get HEAD version
69 $maxversion = PMA_DBI_fetch_array($sql_result);
70 $last_version = $maxversion['version'];
72 // If a HEAD version exists
73 if ($last_version > 0) {
75 <h3><?php echo $strTrackingTrackedTables;?></h3>
77 <table id="versions" class="data">
78 <thead>
79 <tr>
80 <th><?php echo $strDatabase;?></th>
81 <th><?php echo $strTable;?></th>
82 <th><?php echo $strTrackingThLastVersion;?></th>
83 <th><?php echo $strTrackingThCreated;?></th>
84 <th><?php echo $strTrackingThUpdated;?></th>
85 <th><?php echo $strStatus;?></th>
86 <th><?php echo $strShow;?></th>
87 </tr>
88 </thead>
89 <tbody>
90 <?php
92 // Print out information about versions
94 $style = 'odd';
95 PMA_DBI_data_seek($sql_result, 0);
96 while ($version = PMA_DBI_fetch_array($sql_result)) {
97 if ($version['tracking_active'] == 1) {
98 $version_status = $strTrackingStatusActive;
99 } else {
100 $version_status = $strTrackingStatusNotActive;
103 if (($version['version'] == $last_version) && ($version_status == $strTrackingStatusNotActive)) {
104 $tracking_active = false;
106 if (($version['version'] == $last_version) && ($version_status == $strTrackingStatusActive)) {
107 $tracking_active = true;
110 <tr class="<?php echo $style;?>">
111 <td><?php echo $version['db_name'];?></td>
112 <td><?php echo $version['table_name'];?></td>
113 <td><?php echo $version['version'];?></td>
114 <td><?php echo $version['date_created'];?></td>
115 <td><?php echo $version['date_updated'];?></td>
116 <td><?php echo $version_status;?></td>
117 <td> <a href="tbl_tracking.php?<?php echo $url_query;?>&table=<?php echo $version['table_name'];?>"><?php echo $strTrackingVersions;?></a>
118 | <a href="tbl_tracking.php?<?php echo $url_query;?>&table=<?php echo $version['table_name'];?>&report=true&version=<?php echo $version['version'];?>"><?php echo $strTrackingReport;?></a>
119 | <a href="tbl_tracking.php?<?php echo $url_query;?>&table=<?php echo $version['table_name'];?>&snapshot=true&version=<?php echo $version['version'];?>"><?php echo $strTrackingStructureSnapshot;?></a></td>
120 </tr>
121 <?php
122 if ($style == 'even') {
123 $style = 'odd';
124 } else {
125 $style = 'even';
129 </tbody>
130 </table>
131 <?php
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 $strTrackingUntrackedTables;?></h3>
149 <table id="noversions" class="data">
150 <thead>
151 <tr>
152 <th width="300"><?php echo $strTable;?></th>
153 <th></th>
154 </tr>
155 </thead>
156 <tbody>
157 <?php
158 // Print out list of untracked tables
160 $style = 'odd';
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=' . $tablename .'">';
166 if ($cfg['PropertiesIconic']) {
167 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
169 $my_link .= $strTrackingTrackTable . '</a>';
171 <tr class="<?php echo $style;?>">
172 <td><?php echo $tablename;?></td>
173 <td><?php echo $my_link;?></td>
174 </tr>
175 <?php
176 if ($style == 'even') {
177 $style = 'odd';
178 } else {
179 $style = 'even';
184 </tbody>
185 </table>
187 <?php
190 <p/>
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';