argh, commited not final version...
[phpmyadmin/crack.git] / db_printview.php
blob01192e9726b0f341fe497e5e92f50f3d009154c7
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once './libraries/common.lib.php';
7 /**
8 * Gets the variables sent or posted to this script, then displays headers
9 */
10 $print_view = true;
11 require_once './libraries/header.inc.php';
13 PMA_checkParameters(array('db'));
15 /**
16 * Defines the url to return to in case of error in a sql statement
18 $err_url = 'db_details.php?' . PMA_generate_common_url($db);
20 /**
21 * Settings for relations stuff
23 require_once './libraries/relation.lib.php';
24 $cfgRelation = PMA_getRelationsParam();
26 /**
27 * Gets the list of the table in the current db and informations about these
28 * tables if possible
30 * @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
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 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
36 // Blending out tables in use
37 if ($result != false && PMA_DBI_num_rows($result) > 0) {
38 while ($tmp = PMA_DBI_fetch_row($result)) {
39 // if in use memorize tablename
40 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
41 $sot_cache[$tmp[0]] = true;
44 PMA_DBI_free_result($result);
46 if (isset($sot_cache)) {
47 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
48 if ($result != false && PMA_DBI_num_rows($result) > 0) {
49 while ($tmp = PMA_DBI_fetch_row($result)) {
50 if (!isset($sot_cache[$tmp[0]])) {
51 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
52 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
53 $tables[] = $sts_tmp;
54 } else { // table in use
55 $tables[] = array('Name' => $tmp[0]);
58 PMA_DBI_free_result($result);
59 $sot_ready = true;
62 unset($tmp, $result);
66 if (! isset($sot_ready)) {
67 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
68 if (PMA_DBI_num_rows($result) > 0) {
69 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
70 $tables[] = $sts_tmp;
72 PMA_DBI_free_result($result);
73 unset($res);
78 /**
79 * If there is at least one table, displays the printer friendly view, else
80 * an error message
82 $tables = PMA_DBI_get_tables_full($db);
83 $num_tables = count($tables);
85 echo '<br />';
87 // 1. No table
88 if ($num_tables == 0) {
89 echo $strNoTablesFound;
91 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
92 else {
94 <table>
95 <thead>
96 <tr>
97 <th><?php echo $strTable; ?></th>
98 <th><?php echo $strRecords; ?></th>
99 <th><?php echo $strType; ?></th>
100 <?php
101 if ($cfg['ShowStats']) {
102 echo '<th>' . $strSize . '</th>';
105 <th><?php echo $strComments; ?></th>
106 </tr>
107 </thead>
108 <tbody>
109 <?php
110 $sum_entries = $sum_size = 0;
111 $odd_row = true;
112 foreach ($tables as $sts_data) {
113 if (strtoupper($sts_data['ENGINE']) == 'MRG_MYISAM'
114 || strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
115 $merged_size = true;
116 } else {
117 $merged_size = false;
119 $sum_entries += $sts_data['TABLE_ROWS'];
121 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
122 <th>
123 <?php echo htmlspecialchars($sts_data['TABLE_NAME']); ?>
124 </th>
125 <?php
127 if (isset($sts_data['TABLE_ROWS'])) {
129 <td align="right">
130 <?php
131 if ($merged_size) {
132 echo '<i>' . number_format($sts_data['TABLE_ROWS'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
133 } else {
134 echo number_format($sts_data['TABLE_ROWS'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
137 </td>
138 <td nowrap="nowrap">
139 <?php echo $sts_data['ENGINE']; ?>
140 </td>
141 <?php
142 if ($cfg['ShowStats']) {
143 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
144 $sum_size += $tblsize;
145 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
147 <td align="right" nowrap="nowrap">
148 <?php echo $formated_size . ' ' . $unit; ?>
149 </td>
150 <?php
151 } // end if
152 } else {
154 <td colspan="3" align="center">
155 <?php echo $strInUse; ?>
156 </td>
157 <?php
160 <td>
161 <?php
162 if (! empty($sts_data['Comment'])) {
163 echo $sts_data['Comment'];
164 $needs_break = '<br />';
165 } else {
166 $needs_break = '';
169 if (! empty($sts_data['Create_time'])
170 || ! empty($sts_data['Update_time'])
171 || ! empty($sts_data['Check_time'])) {
172 echo $needs_break;
174 <table width="100%">
175 <?php
177 if (! empty($sts_data['Create_time'])) {
179 <tr>
180 <td align="right"><?php echo $strStatCreateTime . ': '; ?></td>
181 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
182 </tr>
183 <?php
186 if (! empty($sts_data['Update_time'])) {
188 <tr>
189 <td align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
190 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
191 </tr>
192 <?php
195 if (! empty($sts_data['Check_time'])) {
197 <tr>
198 <td align="right"><?php echo $strStatCheckTime . ': '; ?></td>
199 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
200 </tr>
201 <?php
204 </table>
205 <?php
208 </td>
209 </tr>
210 <?php
213 <tr>
214 <th align="center">
215 <?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?>
216 </th>
217 <th align="right" nowrap="nowrap">
218 <?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?>
219 </th>
220 <th align="center">
222 </th>
223 <?php
224 if ($cfg['ShowStats']) {
225 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
227 <th align="right" nowrap="nowrap">
228 <?php echo $sum_formated . ' ' . $unit; ?>
229 </th>
230 <?php
233 <th>&nbsp;</th>
234 </tr>
235 </tbody>
236 </table>
237 <?php
241 * Displays the footer
245 <script type="text/javascript" language="javascript">
246 //<![CDATA[
247 function printPage()
249 // Do print the page
250 if (typeof(window.print) != 'undefined') {
251 window.print();
254 //]]>
255 </script>
256 <br /><br />
258 <input type="button" class="print_ignore"
259 id="print" value="<?php echo $strPrint; ?>" onclick="printPage()" />
261 <?php
262 require_once './libraries/footer.inc.php';