Translation update done using Pootle.
[phpmyadmin/crack.git] / db_tracking.php
blob68faafec3f0af48de627d493a65b600b8c24b8a3
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @version $Id$
5 * @package phpMyAdmin
6 */
8 /**
9 * Run common work
11 require_once './libraries/common.inc.php';
12 require_once './libraries/Table.class.php';
14 require './libraries/db_common.inc.php';
15 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
17 // Get the database structure
18 $sub_part = '_structure';
19 require './libraries/db_info.inc.php';
21 // Get relation settings
22 require_once './libraries/relation.lib.php';
24 // Work to do?
25 // (here, do not use $_REQUEST['db] as it can be crafted)
26 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
27 PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
30 // Get tracked data about the database
31 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
33 // No tables present and no log exist
34 if ($num_tables == 0 && count($data['ddlog']) == 0) {
35 echo '<p>' . __('No tables found in database.') . '</p>' . "\n";
37 if (empty($db_is_information_schema)) {
38 require './libraries/display_create_table.lib.php';
41 // Display the footer
42 require_once './libraries/footer.inc.php';
43 exit;
46 // ---------------------------------------------------------------------------
49 * Display top menu links
51 require_once './libraries/db_links.inc.php';
53 // Prepare statement to get HEAD version
54 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
55 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
56 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
57 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
58 ' GROUP BY '. PMA_backquote('table_name') .
59 ' ORDER BY '. PMA_backquote('table_name') .' ASC';
61 $all_tables_result = PMA_query_as_controluser($all_tables_query);
63 // If a HEAD version exists
64 if (PMA_DBI_num_rows($all_tables_result) > 0) {
66 <h3><?php echo __('Tracked tables');?></h3>
68 <table id="versions" class="data">
69 <thead>
70 <tr>
71 <th><?php echo __('Database');?></th>
72 <th><?php echo __('Table');?></th>
73 <th><?php echo __('Last version');?></th>
74 <th><?php echo __('Created');?></th>
75 <th><?php echo __('Updated');?></th>
76 <th><?php echo __('Status');?></th>
77 <th><?php echo __('Action');?></th>
78 <th><?php echo __('Show');?></th>
79 </tr>
80 </thead>
81 <tbody>
82 <?php
84 // Print out information about versions
86 $drop_image_or_text = '';
87 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
88 $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') . '" />';
90 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
91 $drop_image_or_text .= __('Drop');
94 $style = 'odd';
95 while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
96 list($table_name, $version_number) = $one_result;
97 $table_query = ' SELECT * FROM ' .
98 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
99 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
100 ' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
102 $table_result = PMA_query_as_controluser($table_query);
103 $version_data = PMA_DBI_fetch_array($table_result);
105 if ($version_data['tracking_active'] == 1) {
106 $version_status = __('active');
107 } else {
108 $version_status = __('not active');
110 $tmp_link = 'tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
111 $delete_link = 'db_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
113 <tr class="<?php echo $style;?>">
114 <td><?php echo htmlspecialchars($version_data['db_name']);?></td>
115 <td><?php echo htmlspecialchars($version_data['table_name']);?></td>
116 <td><?php echo $version_data['version'];?></td>
117 <td><?php echo $version_data['date_created'];?></td>
118 <td><?php echo $version_data['date_updated'];?></td>
119 <td><?php echo $version_status;?></td>
120 <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>
121 <td> <a href="<?php echo $tmp_link; ?>"><?php echo __('Versions');?></a>
122 | <a href="<?php echo $tmp_link; ?>&amp;report=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Tracking report');?></a>
123 | <a href="<?php echo $tmp_link; ?>&amp;snapshot=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Structure snapshot');?></a></td>
124 </tr>
125 <?php
126 if ($style == 'even') {
127 $style = 'odd';
128 } else {
129 $style = 'even';
132 unset($tmp_link);
134 </tbody>
135 </table>
136 <?php
139 // Get list of tables
140 $table_list = PMA_getTableList($GLOBALS['db']);
142 // For each table try to get the tracking version
143 foreach ($table_list as $key => $value) {
144 if (PMA_Tracker::getVersion($GLOBALS['db'], $value['Name']) == -1) {
145 $my_tables[] = $value['Name'];
149 // If untracked tables exist
150 if (isset($my_tables)) {
152 <h3><?php echo __('Untracked tables');?></h3>
154 <table id="noversions" class="data">
155 <thead>
156 <tr>
157 <th width="300"><?php echo __('Table');?></th>
158 <th></th>
159 </tr>
160 </thead>
161 <tbody>
162 <?php
163 // Print out list of untracked tables
165 $style = 'odd';
167 foreach ($my_tables as $key => $tablename) {
168 if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
169 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($tablename) .'">';
171 if ($cfg['PropertiesIconic']) {
172 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
174 $my_link .= __('Track table') . '</a>';
176 <tr class="<?php echo $style;?>">
177 <td><?php echo htmlspecialchars($tablename);?></td>
178 <td><?php echo $my_link;?></td>
179 </tr>
180 <?php
181 if ($style == 'even') {
182 $style = 'odd';
183 } else {
184 $style = 'even';
189 </tbody>
190 </table>
192 <?php
194 // If available print out database log
195 if (count($data['ddlog']) > 0) {
196 $log = '';
197 foreach ($data['ddlog'] as $entry) {
198 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
200 PMA_showMessage(__('Database Log'), $log);
204 * Display the footer
206 require_once './libraries/footer.inc.php';