fixed inactivity timeout failure
[openemr.git] / interface / main / myadmin / db_printview.php
blobfdf77c983f27b05a3282eb297dc3d160a44b8617
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Gets the variables sent or posted to this script, then displays headers
8 */
9 require_once('./libraries/grab_globals.lib.php');
10 require_once('./header.inc.php');
12 // Check parameters
13 require_once('./libraries/common.lib.php');
15 PMA_checkParameters(array('db'));
17 /**
18 * Defines the url to return to in case of error in a sql statement
20 $err_url = 'db_details.php?' . PMA_generate_common_url($db);
22 /**
23 * Settings for relations stuff
25 require_once('./libraries/relation.lib.php');
26 $cfgRelation = PMA_getRelationsParam();
28 /**
29 * Gets the list of the table in the current db and informations about these
30 * tables if possible
32 // staybyte: speedup view on locked tables - 11 June 2001
33 // Special speedup for newer MySQL Versions (in 4.0 format changed)
34 if ($cfg['SkipLockedTables'] == TRUE) {
35 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
36 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
37 // Blending out tables in use
38 if ($result != FALSE && mysql_num_rows($result) > 0) {
39 while ($tmp = PMA_mysql_fetch_array($result)) {
40 // if in use memorize tablename
41 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
42 $sot_cache[$tmp[0]] = TRUE;
45 mysql_free_result($result);
47 if (isset($sot_cache)) {
48 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
49 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
50 if ($result != FALSE && mysql_num_rows($result) > 0) {
51 while ($tmp = PMA_mysql_fetch_array($result)) {
52 if (!isset($sot_cache[$tmp[0]])) {
53 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
54 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
55 $sts_tmp = PMA_mysql_fetch_array($sts_result);
56 $tables[] = $sts_tmp;
57 } else { // table in use
58 $tables[] = array('Name' => $tmp[0]);
61 mysql_free_result($result);
62 $sot_ready = TRUE;
67 if (!isset($sot_ready)) {
68 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
69 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
70 if ($result != FALSE && mysql_num_rows($result) > 0) {
71 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
72 $tables[] = $sts_tmp;
74 mysql_free_result($result);
77 $num_tables = (isset($tables) ? count($tables) : 0);
79 if ($cfgRelation['commwork']) {
80 $comment = PMA_getComments($db);
82 /**
83 * Displays DB comment
85 if (is_array($comment)) {
87 <!-- DB comment -->
88 <p><i>
89 <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
90 </i></p>
91 <?php
92 } // end if
95 /**
96 * If there is at least one table, displays the printer friendly view, else
97 * an error message
99 // 1. No table
100 if ($num_tables == 0) {
101 echo $strNoTablesFound;
103 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
104 else {
107 <!-- The tables list -->
108 <table border="<?php echo $cfg['Border']; ?>">
109 <tr>
110 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
111 <th><?php echo $strRecords; ?></th>
112 <th><?php echo $strType; ?></th>
113 <?php
114 if ($cfg['ShowStats']) {
115 echo '<th>' . $strSize . '</th>';
117 echo "\n";
119 <th><?php echo $strComments; ?></th>
120 </tr>
121 <?php
122 $i = $sum_entries = $sum_size = 0;
123 foreach($tables AS $keyname => $sts_data) {
124 $table = $sts_data['Name'];
125 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
126 echo "\n";
128 <tr>
129 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
130 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
131 </td>
132 <?php
133 echo "\n";
134 $mergetable = FALSE;
135 $nonisam = FALSE;
136 if (isset($sts_data['Type'])) {
137 if ($sts_data['Type'] == 'MRG_MyISAM') {
138 $mergetable = TRUE;
139 } else if (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) {
140 $nonisam = TRUE;
144 if (isset($sts_data['Rows'])) {
145 if ($mergetable == FALSE) {
146 if ($cfg['ShowStats'] && $nonisam == FALSE) {
147 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
148 $sum_size += $tblsize;
149 if ($tblsize > 0) {
150 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
151 } else {
152 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
154 } else if ($cfg['ShowStats']) {
155 $formated_size = '&nbsp;-&nbsp;';
156 $unit = '';
158 $sum_entries += $sts_data['Rows'];
160 // MyISAM MERGE Table
161 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
162 $formated_size = '&nbsp;-&nbsp;';
163 $unit = '';
165 else if ($cfg['ShowStats']) {
166 $formated_size = 'unknown';
167 $unit = '';
170 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
171 <?php
172 echo "\n" . ' ';
173 if ($mergetable == TRUE) {
174 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
175 } else {
176 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
179 </td>
180 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
181 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
182 </td>
183 <?php
184 if ($cfg['ShowStats']) {
185 echo "\n";
187 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
188 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
189 </td>
190 <?php
191 echo "\n";
192 } // end if
193 } else {
195 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
196 <?php echo $strInUse . "\n"; ?>
197 </td>
198 <?php
200 echo "\n";
202 <td bgcolor="<?php echo $bgcolor; ?>">
203 <?php echo $sts_data['Comment']; ?>
204 <?php
205 if (!empty($sts_data['Comment'])) {
206 $needs_break = '<br />';
207 } else {
208 $needs_break = '';
211 if ((isset($sts_data['Create_time']) && !empty($sts_data['Create_time']))
212 || (isset($sts_data['Update_time']) && !empty($sts_data['Update_time']))
213 || (isset($sts_data['Check_time']) && !empty($sts_data['Check_time']))) {
214 echo $needs_break;
216 <table border="0" cellpadding="1" cellspacing="1" width="100%">
217 <?php
219 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
221 <tr>
222 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCreateTime . ': '; ?></td>
223 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
224 </tr>
225 <?php
228 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
230 <tr>
231 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
232 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
233 </tr>
234 <?php
237 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
239 <tr>
240 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCheckTime . ': '; ?></td>
241 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
242 </tr>
243 <?php
246 </table>
247 <?php
250 </td>
251 </tr>
252 <?php
254 // Show Summary
255 if ($cfg['ShowStats']) {
256 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
258 echo "\n";
260 <tr>
261 <th align="center">
262 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
263 </th>
264 <th align="right" nowrap="nowrap">
265 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
266 </th>
267 <th align="center">
268 <b>--</b>
269 </th>
270 <?php
271 if ($cfg['ShowStats']) {
272 echo "\n";
274 <th align="right" nowrap="nowrap">
275 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
276 </th>
277 <?php
279 echo "\n";
281 <th>&nbsp;</th>
282 </tr>
283 </table>
284 <?php
288 * Displays the footer
290 echo "\n";
292 <script type="text/javascript" language="javascript1.2">
293 <!--
294 function printPage()
296 document.getElementById('print').style.visibility = 'hidden';
297 // Do print the page
298 if (typeof(window.print) != 'undefined') {
299 window.print();
301 document.getElementById('print').style.visibility = '';
303 //-->
304 </script>
305 <?php
306 echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
308 require_once('./footer.inc.php');