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';
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';
41 require_once './libraries/footer.inc.php';
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">
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
>
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;
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;
107 $version_status = $strTrackingStatusNotActive;
109 $tmp_link = 'tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']);
110 $delete_link = 'db_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']) . '&delete_tracking=true&';
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; ?>&report=true&version=<?php echo $version_data['version'];?>"><?php
echo $strTrackingReport;?
></a
>
122 |
<a href
="<?php echo $tmp_link; ?>&snapshot=true&version=<?php echo $version_data['version'];?>"><?php
echo $strTrackingStructureSnapshot;?
></a
></td
>
125 if ($style == 'even') {
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">
156 <th width
="300"><?php
echo $strTable;?
></th
>
162 // Print out list of untracked tables
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 . '&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
>
180 if ($style == 'even') {
193 // If available print out database log
194 if (count($data['ddlog']) > 0) {
196 foreach ($data['ddlog'] as $entry) {
197 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
199 PMA_showMessage($strTrackingDatabaseLog, $log);
205 require_once './libraries/footer.inc.php';