2 /* vim: set expandtab sw=4 ts=4 sts=4: */
10 require_once './libraries/common.inc.php';
12 //Get some js files needed for Ajax requests
13 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
14 $GLOBALS['js_include'][] = 'db_structure.js';
17 * If we are not in an Ajax request, then do the common work and show the links etc.
19 if($GLOBALS['is_ajax_request'] != true) {
20 require './libraries/db_common.inc.php';
22 $url_query .= '&goto=tbl_tracking.php&back=db_tracking.php';
24 // Get the database structure
25 $sub_part = '_structure';
26 require './libraries/db_info.inc.php';
29 // (here, do not use $_REQUEST['db] as it can be crafted)
30 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
31 PMA_Tracker
::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
34 * If in an Ajax request, generate the success message and use
35 * {@link PMA_ajaxResponse()} to send the output
37 if($GLOBALS['is_ajax_request'] == true) {
38 $message = PMA_Message
::success();
39 PMA_ajaxResponse($message, true);
43 // Get tracked data about the database
44 $data = PMA_Tracker
::getTrackedData($_REQUEST['db'], '', '1');
46 // No tables present and no log exist
47 if ($num_tables == 0 && count($data['ddlog']) == 0) {
48 echo '<p>' . __('No tables found in database.') . '</p>' . "\n";
50 if (empty($db_is_information_schema)) {
51 require './libraries/display_create_table.lib.php';
55 require './libraries/footer.inc.php';
59 // ---------------------------------------------------------------------------
62 * Display top menu links
64 require_once './libraries/db_links.inc.php';
66 // Prepare statement to get HEAD version
67 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
68 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
69 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
70 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' ' .
71 ' GROUP BY '. PMA_backquote('table_name') .
72 ' ORDER BY '. PMA_backquote('table_name') .' ASC';
74 $all_tables_result = PMA_query_as_controluser($all_tables_query);
76 // If a HEAD version exists
77 if (PMA_DBI_num_rows($all_tables_result) > 0) {
79 <h3
><?php
echo __('Tracked tables');?
></h3
>
81 <table id
="versions" class="data">
84 <th
><?php
echo __('Database');?
></th
>
85 <th
><?php
echo __('Table');?
></th
>
86 <th
><?php
echo __('Last version');?
></th
>
87 <th
><?php
echo __('Created');?
></th
>
88 <th
><?php
echo __('Updated');?
></th
>
89 <th
><?php
echo __('Status');?
></th
>
90 <th
><?php
echo __('Action');?
></th
>
91 <th
><?php
echo __('Show');?
></th
>
97 // Print out information about versions
99 $drop_image_or_text = '';
100 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
101 $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') . '" />';
103 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] ||
false === $GLOBALS['cfg']['PropertiesIconic']) {
104 $drop_image_or_text .= __('Drop');
108 while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
109 list($table_name, $version_number) = $one_result;
110 $table_query = ' SELECT * FROM ' .
111 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
112 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
113 ' WHERE `db_name` = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddSlashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
115 $table_result = PMA_query_as_controluser($table_query);
116 $version_data = PMA_DBI_fetch_array($table_result);
118 if ($version_data['tracking_active'] == 1) {
119 $version_status = __('active');
121 $version_status = __('not active');
123 $tmp_link = 'tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']);
124 $delete_link = 'db_tracking.php?' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']) . '&delete_tracking=true&';
126 <tr
class="noclick <?php echo $style;?>">
127 <td
><?php
echo htmlspecialchars($version_data['db_name']);?
></td
>
128 <td
><?php
echo htmlspecialchars($version_data['table_name']);?
></td
>
129 <td
><?php
echo $version_data['version'];?
></td
>
130 <td
><?php
echo $version_data['date_created'];?
></td
>
131 <td
><?php
echo $version_data['date_updated'];?
></td
>
132 <td
><?php
echo $version_status;?
></td
>
133 <td
><a
<?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
'class="drop_tracking_anchor"' : ''); ?
> href
="<?php echo $delete_link;?>" ><?php
echo $drop_image_or_text; ?
></a
></td
>
134 <td
> <a href
="<?php echo $tmp_link; ?>"><?php
echo __('Versions');?
></a
>
135 |
<a href
="<?php echo $tmp_link; ?>&report=true&version=<?php echo $version_data['version'];?>"><?php
echo __('Tracking report');?
></a
>
136 |
<a href
="<?php echo $tmp_link; ?>&snapshot=true&version=<?php echo $version_data['version'];?>"><?php
echo __('Structure snapshot');?
></a
></td
>
139 if ($style == 'even') {
152 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
154 // Get list of tables
155 $table_list = PMA_getTableList($GLOBALS['db']);
157 // For each table try to get the tracking version
158 foreach ($table_list as $key => $value) {
159 // If $value is a table group.
160 if (array_key_exists(('is' . $sep . 'group'), $value) && $value['is' . $sep . 'group']) {
161 foreach ($value as $temp_table) {
162 // If $temp_table is a table with the value for 'Name' is set,
163 // rather than a propery of the table group.
164 if (array_key_exists('Name', $temp_table)) {
165 if (PMA_Tracker
::getVersion($GLOBALS['db'], $temp_table['Name']) == -1) {
166 $my_tables[] = $temp_table['Name'];
170 // If $value is a table.
172 if (PMA_Tracker
::getVersion($GLOBALS['db'], $value['Name']) == -1) {
173 $my_tables[] = $value['Name'];
178 // If untracked tables exist
179 if (isset($my_tables)) {
181 <h3
><?php
echo __('Untracked tables');?
></h3
>
183 <table id
="noversions" class="data">
186 <th width
="300"><?php
echo __('Table');?
></th
>
192 // Print out list of untracked tables
196 foreach ($my_tables as $key => $tablename) {
197 if (PMA_Tracker
::getVersion($GLOBALS['db'], $tablename) == -1) {
198 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&table=' . htmlspecialchars($tablename) .'">';
200 if ($cfg['PropertiesIconic']) {
201 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
203 $my_link .= __('Track table') . '</a>';
205 <tr
class="noclick <?php echo $style;?>">
206 <td
><?php
echo htmlspecialchars($tablename);?
></td
>
207 <td
><?php
echo $my_link;?
></td
>
210 if ($style == 'even') {
223 // If available print out database log
224 if (count($data['ddlog']) > 0) {
226 foreach ($data['ddlog'] as $entry) {
227 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
229 PMA_showMessage(__('Database Log'), $log);
235 require './libraries/footer.inc.php';