Translated using Weblate (Hungarian)
[phpmyadmin.git] / db_tracking.php
blob8cd1075c5308f70d95a7049bd10bff2a68397b07
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Tracking configuration for database
6 * @package PhpMyAdmin
7 */
9 /**
10 * Run common work
12 require_once 'libraries/common.inc.php';
14 require_once './libraries/tracking.lib.php';
16 //Get some js files needed for Ajax requests
17 $response = PMA_Response::getInstance();
18 $header = $response->getHeader();
19 $scripts = $header->getScripts();
20 $scripts->addFile('db_structure.js');
22 /**
23 * If we are not in an Ajax request, then do the common work and show the links etc.
25 require 'libraries/db_common.inc.php';
26 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
28 // Get the database structure
29 $sub_part = '_structure';
30 require 'libraries/db_info.inc.php';
32 // Work to do?
33 // (here, do not use $_REQUEST['db] as it can be crafted)
34 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
35 PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
37 /**
38 * If in an Ajax request, generate the success message and use
39 * {@link PMA_Response()} to send the output
41 if ($GLOBALS['is_ajax_request'] == true) {
42 $response = PMA_Response::getInstance();
43 $response->addJSON('message', PMA_Message::success());
44 exit;
48 // Get tracked data about the database
49 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
51 // No tables present and no log exist
52 if ($num_tables == 0 && count($data['ddlog']) == 0) {
53 echo '<p>' . __('No tables found in database.') . '</p>' . "\n";
55 if (empty($db_is_system_schema)) {
56 include 'libraries/display_create_table.lib.php';
58 exit;
61 // ---------------------------------------------------------------------------
63 // Prepare statement to get HEAD version
64 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
65 PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
66 PMA_Util::backquote($GLOBALS['cfg']['Server']['tracking']) .
67 ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($_REQUEST['db']) . '\' ' .
68 ' GROUP BY table_name' .
69 ' ORDER BY table_name ASC';
71 $all_tables_result = PMA_queryAsControlUser($all_tables_query);
73 // If a HEAD version exists
74 if ($GLOBALS['dbi']->numRows($all_tables_result) > 0) {
76 <div id="tracked_tables">
77 <h3><?php echo __('Tracked tables');?></h3>
79 <table id="versions" class="data">
80 <thead>
81 <tr>
82 <th><?php echo __('Database');?></th>
83 <th><?php echo __('Table');?></th>
84 <th><?php echo __('Last version');?></th>
85 <th><?php echo __('Created');?></th>
86 <th><?php echo __('Updated');?></th>
87 <th><?php echo __('Status');?></th>
88 <th><?php echo __('Action');?></th>
89 <th><?php echo __('Show');?></th>
90 </tr>
91 </thead>
92 <tbody>
93 <?php
95 // Print out information about versions
97 $drop_image_or_text = '';
98 if (PMA_Util::showIcons('ActionLinksMode')) {
99 $drop_image_or_text .= PMA_Util::getImage(
100 'b_drop.png',
101 __('Delete tracking data for this table')
104 if (PMA_Util::showText('ActionLinksMode')) {
105 $drop_image_or_text .= __('Drop');
108 $style = 'odd';
109 while ($one_result = $GLOBALS['dbi']->fetchArray($all_tables_result)) {
110 list($table_name, $version_number) = $one_result;
111 $table_query = ' SELECT * FROM ' .
112 PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
113 PMA_Util::backquote($GLOBALS['cfg']['Server']['tracking']) .
114 ' WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($_REQUEST['db'])
115 . '\' AND `table_name` = \'' . PMA_Util::sqlAddSlashes($table_name)
116 . '\' AND `version` = \'' . $version_number . '\'';
118 $table_result = PMA_queryAsControlUser($table_query);
119 $version_data = $GLOBALS['dbi']->fetchArray($table_result);
121 $tmp_link = 'tbl_tracking.php' . $url_query . '&amp;table='
122 . htmlspecialchars($version_data['table_name']);
123 $delete_link = 'db_tracking.php' . $url_query . '&amp;table='
124 . htmlspecialchars($version_data['table_name'])
125 . '&amp;delete_tracking=true&amp';
127 <tr class="noclick <?php echo $style;?>">
128 <td><?php echo htmlspecialchars($version_data['db_name']);?></td>
129 <td><?php echo htmlspecialchars($version_data['table_name']);?></td>
130 <td><?php echo $version_data['version'];?></td>
131 <td><?php echo $version_data['date_created'];?></td>
132 <td><?php echo $version_data['date_updated'];?></td>
133 <td><?php echo PMA_getVersionStatus($version_data);?></td>
134 <td>
135 <a class="drop_tracking_anchor ajax" href="<?php echo $delete_link;?>" >
136 <?php echo $drop_image_or_text; ?></a>
137 <?php
138 echo '</td>'
139 . '<td>'
140 . '<a href="' . $tmp_link . '">' . __('Versions') . '</a>'
141 . '&nbsp;|&nbsp;'
142 . '<a href="' . $tmp_link . '&amp;report=true&amp;version='
143 . $version_data['version'] . '">' . __('Tracking report') . '</a>'
144 . '&nbsp;|&nbsp;'
145 . '<a href="' . $tmp_link . '&amp;snapshot=true&amp;version='
146 . $version_data['version'] . '">' . __('Structure snapshot')
147 . '</a>'
148 . '</td>'
149 . '</tr>';
150 if ($style == 'even') {
151 $style = 'odd';
152 } else {
153 $style = 'even';
156 unset($tmp_link);
158 </tbody>
159 </table>
160 </div>
161 <?php
164 $sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
166 // Get list of tables
167 $table_list = PMA_Util::getTableList($GLOBALS['db']);
169 $my_tables = array();
171 // For each table try to get the tracking version
172 foreach ($table_list as $key => $value) {
173 // If $value is a table group.
174 if (array_key_exists(('is' . $sep . 'group'), $value)
175 && $value['is' . $sep . 'group']
177 foreach ($value as $temp_table) {
178 // If $temp_table is a table with the value for 'Name' is set,
179 // rather than a property of the table group.
180 if (is_array($temp_table)
181 && array_key_exists('Name', $temp_table)
183 $tracking_version = PMA_Tracker::getVersion(
184 $GLOBALS['db'],
185 $temp_table['Name']
187 if ($tracking_version == -1) {
188 $my_tables[] = $temp_table['Name'];
192 } else { // If $value is a table.
193 if (PMA_Tracker::getVersion($GLOBALS['db'], $value['Name']) == -1) {
194 $my_tables[] = $value['Name'];
199 // If untracked tables exist
200 if (count($my_tables) > 0) {
202 <h3><?php echo __('Untracked tables');?></h3>
204 <table id="noversions" class="data">
205 <thead>
206 <tr>
207 <th style="width: 300px"><?php echo __('Table');?></th>
208 <th></th>
209 </tr>
210 </thead>
211 <tbody>
212 <?php
213 // Print out list of untracked tables
215 $style = 'odd';
217 foreach ($my_tables as $key => $tablename) {
218 if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
219 $my_link = '<a href="tbl_tracking.php' . $url_query
220 . '&amp;table=' . htmlspecialchars($tablename) . '">';
221 $my_link .= PMA_Util::getIcon('eye.png', __('Track table'));
222 $my_link .= '</a>';
224 <tr class="noclick <?php echo $style;?>">
225 <td><?php echo htmlspecialchars($tablename);?></td>
226 <td><?php echo $my_link;?></td>
227 </tr>
228 <?php
229 if ($style == 'even') {
230 $style = 'odd';
231 } else {
232 $style = 'even';
237 </tbody>
238 </table>
239 <?php
241 // If available print out database log
242 if (count($data['ddlog']) > 0) {
243 $log = '';
244 foreach ($data['ddlog'] as $entry) {
245 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n"
246 . $entry['statement'] . "\n";
248 echo PMA_Util::getMessage(__('Database Log'), $log);