2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * @author Alexander Rutkowski
10 require_once './libraries/common.inc.php';
11 require_once './libraries/Table.class.php';
13 require './libraries/db_common.inc.php';
14 $url_query .= '&goto=tbl_tracking.php&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';
35 require_once './libraries/footer.inc.php';
39 // ---------------------------------------------------------------------------
42 * Display top menu links
44 require_once './libraries/db_links.inc.php';
46 // Prepare statement to get HEAD version
47 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
48 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
49 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
50 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
51 ' GROUP BY '. PMA_backquote('table_name') .
52 ' ORDER BY '. PMA_backquote('table_name') .' ASC';
54 $all_tables_result = PMA_query_as_controluser($all_tables_query);
56 // If a HEAD version exists
57 if (PMA_DBI_num_rows($all_tables_result) > 0) {
59 <h3
><?php
echo $strTrackingTrackedTables;?
></h3
>
61 <table id
="versions" class="data">
64 <th
><?php
echo $strDatabase;?
></th
>
65 <th
><?php
echo $strTable;?
></th
>
66 <th
><?php
echo $strTrackingThLastVersion;?
></th
>
67 <th
><?php
echo $strTrackingThCreated;?
></th
>
68 <th
><?php
echo $strTrackingThUpdated;?
></th
>
69 <th
><?php
echo $strStatus;?
></th
>
70 <th
><?php
echo $strShow;?
></th
>
76 // Print out information about versions
79 while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
80 list($table_name, $version_number) = $one_result;
81 $table_query = ' SELECT * FROM ' .
82 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
83 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
84 ' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
86 $table_result = PMA_query_as_controluser($table_query);
87 $version_data = PMA_DBI_fetch_array($table_result);
89 if ($version_data['tracking_active'] == 1) {
90 $version_status = $strTrackingStatusActive;
92 $version_status = $strTrackingStatusNotActive;
94 $tmp_link = 'tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']);
96 <tr
class="<?php echo $style;?>">
97 <td
><?php
echo htmlspecialchars($version_data['db_name']);?
></td
>
98 <td
><?php
echo htmlspecialchars($version_data['table_name']);?
></td
>
99 <td
><?php
echo $version_data['version'];?
></td
>
100 <td
><?php
echo $version_data['date_created'];?
></td
>
101 <td
><?php
echo $version_data['date_updated'];?
></td
>
102 <td
><?php
echo $version_status;?
></td
>
103 <td
> <a href
="<?php echo $tmp_link; ?>"><?php
echo $strTrackingVersions;?
></a
>
104 |
<a href
="<?php echo $tmp_link; ?>&report=true&version=<?php echo $version_data['version'];?>"><?php
echo $strTrackingReport;?
></a
>
105 |
<a href
="<?php echo $tmp_link; ?>&snapshot=true&version=<?php echo $version_data['version'];?>"><?php
echo $strTrackingStructureSnapshot;?
></a
></td
>
108 if ($style == 'even') {
121 // Get list of tables
122 $table_list = PMA_getTableList($GLOBALS['db']);
124 // For each table try to get the tracking version
125 foreach ($table_list as $key => $value) {
126 if (PMA_Tracker
::getVersion($GLOBALS['db'], $value['Name']) == -1) {
127 $my_tables[] = $value['Name'];
131 // If untracked tables exist
132 if (isset($my_tables)) {
134 <h3
><?php
echo $strTrackingUntrackedTables;?
></h3
>
136 <table id
="noversions" class="data">
139 <th width
="300"><?php
echo $strTable;?
></th
>
145 // Print out list of untracked tables
149 foreach ($my_tables as $key => $tablename) {
150 if (PMA_Tracker
::getVersion($GLOBALS['db'], $tablename) == -1) {
151 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($tablename) .'">';
153 if ($cfg['PropertiesIconic']) {
154 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
156 $my_link .= $strTrackingTrackTable . '</a>';
158 <tr
class="<?php echo $style;?>">
159 <td
><?php
echo htmlspecialchars($tablename);?
></td
>
160 <td
><?php
echo $my_link;?
></td
>
163 if ($style == 'even') {
176 // If available print out database log
177 if (count($data['ddlog']) > 0) {
179 foreach ($data['ddlog'] as $entry) {
180 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
182 PMA_showMessage($strTrackingDatabaseLog, $log);
188 require_once './libraries/footer.inc.php';