Basic detection if mime-features are available, better check on error
[phpmyadmin/crack.git] / header.inc.php3
blob119b8a2693be8de5e70c19aff900c3c86b226f8a
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Gets a core script and starts output buffering work
7 */
8 if (!defined('PMA_COMMON_LIB_INCLUDED')) {
9 include('./libraries/common.lib.php3');
11 if (!defined('PMA_OB_LIB_INCLUDED')) {
12 include('./libraries/ob.lib.php3');
14 if ($GLOBALS['cfg']['OBGzip']) {
15 $GLOBALS['ob_mode'] = PMA_outBufferModeGet();
16 if ($GLOBALS['ob_mode']) {
17 PMA_outBufferPre($GLOBALS['ob_mode']);
22 /**
23 * Sends http headers
25 // Don't use cache (required for Opera)
26 $GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT';
27 header('Expires: ' . $GLOBALS['now']); // rfc2616 - Section 14.21
28 header('Last-Modified: ' . $GLOBALS['now']);
29 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
30 header('Pragma: no-cache'); // HTTP/1.0
31 // Define the charset to be used
32 header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
35 /**
36 * Sends the beginning of the html page then returns to the calling script
38 // Gets the font sizes to use
39 PMA_setFontSizes();
40 // Defines the cell alignment values depending on text direction
41 if ($GLOBALS['text_dir'] == 'ltr') {
42 $GLOBALS['cell_align_left'] = 'left';
43 $GLOBALS['cell_align_right'] = 'right';
44 } else {
45 $GLOBALS['cell_align_left'] = 'right';
46 $GLOBALS['cell_align_right'] = 'left';
49 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
50 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
51 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
53 <head>
54 <title>phpMyAdmin</title>
55 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
56 <?php
57 if (!empty($GLOBALS['cfg']['PmaAbsoluteUri'])) {
58 echo '<base href="' . $GLOBALS['cfg']['PmaAbsoluteUri'] . '" />' . "\n";
61 <style type="text/css">
62 <!--
63 body {
64 font-family: <?php echo $GLOBALS['right_font_family']; ?>;
65 font-size: <?php echo $GLOBALS['font_size']; ?>;
66 color: #000000;
67 <?php
68 if ($GLOBALS['cfg']['RightBgImage'] == '') {
69 echo ' background-image: url(\'./images/vertical_line.png\');' . "\n"
70 . ' background-repeat: repeat-y;' . "\n";
71 } else {
72 echo ' background-image: url(\'' . $GLOBALS['cfg']['RightBgImage'] . '\');' . "\n";
73 } // end if... else...
75 background-color: <?php echo $GLOBALS['cfg']['RightBgColor'] . "\n"; ?>
77 pre, tt {font-size: <?php echo $GLOBALS['font_size']; ?>}
78 th {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; font-weight: bold; color: #000000; background-color: <?php echo $GLOBALS['cfg']['ThBgcolor']; ?>}
79 td {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>}
80 form {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>}
81 input {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>}
82 input.textfield {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; color: #000000; background-color: #FFFFFF}
83 select {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; color: #000000; background-color: #FFFFFF}
84 textarea {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; color: #000000; background-color: #FFFFFF}
85 h1 {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_biggest']; ?>; font-weight: bold}
86 h2 {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_bigger']; ?>; font-weight: bold}
87 h3 {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; font-weight: bold}
88 a:link {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; text-decoration: none; color: #0000FF}
89 a:visited {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; text-decoration: none; color: #0000FF}
90 a:hover {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; text-decoration: underline; color: #FF0000}
91 a.nav:link {font-family: <?php echo $GLOBALS['right_font_family']; ?>; color: #000000}
92 a.nav:visited {font-family: <?php echo $GLOBALS['right_font_family']; ?>; color: #000000}
93 a.nav:hover {font-family: <?php echo $GLOBALS['right_font_family']; ?>; color: #FF0000}
94 a.h1:link {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_biggest']; ?>; font-weight: bold; color: #000000}
95 a.h1:active {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_biggest']; ?>; font-weight: bold; color: #000000}
96 a.h1:visited {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_biggest']; ?>; font-weight: bold; color: #000000}
97 a.h1:hover {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_biggest']; ?>; font-weight: bold; color: #FF0000}
98 a.h2:link {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_bigger']; ?>; font-weight: bold; color: #000000}
99 a.h2:active {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_bigger']; ?>; font-weight: bold; color: #000000}
100 a.h2:visited {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_bigger']; ?>; font-weight: bold; color: #000000}
101 a.h2:hover {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_bigger']; ?>; font-weight: bold; color: #FF0000}
102 a.drop:link {font-family: <?php echo $GLOBALS['right_font_family']; ?>; color: #ff0000}
103 a.drop:visited {font-family: <?php echo $GLOBALS['right_font_family']; ?>; color: #ff0000}
104 a.drop:hover {font-family: <?php echo $GLOBALS['right_font_family']; ?>; color: #ffffff; background-color:#ff0000; text-decoration: none}
105 dfn {font-style: normal}
106 dfn:hover {font-style: normal; cursor: help}
107 .nav {font-family: <?php echo $GLOBALS['right_font_family']; ?>; color: #000000}
108 .warning {font-family: <?php echo $GLOBALS['right_font_family']; ?>; font-size: <?php echo $GLOBALS['font_size']; ?>; font-weight: bold; color: #FF0000}
109 td.topline {font-size: 1px}
110 td.tab {
111 border-top: 1px solid #999;
112 border-right: 1px solid #666;
113 border-left: 1px solid #999;
114 border-bottom: none;
115 border-radius: 2px;
116 -moz-border-radius: 2px;
118 table.tabs {
119 border-top: none;
120 border-right: none;
121 border-left: none;
122 border-bottom: 1px solid #666;
125 .print{font-family:arial;font-size:8pt;}
127 .syntax {font-family: sans-serif; font-size: <?php echo $font_smaller; ?>;}
128 .syntax_comment {}
129 .syntax_digit {}
130 .syntax_digit_hex {}
131 .syntax_digit_integer {}
132 .syntax_digit_float {}
133 .syntax_punct {}
134 .syntax_alpha {text-transform: lowercase;}
135 .syntax_alpha_columnType {text-transform: uppercase;}
136 .syntax_alpha_columnAttrib {text-transform: uppercase;}
137 .syntax_alpha_reservedWord {text-transform: uppercase; font-weight: bold;}
138 .syntax_alpha_functionName {text-transform: uppercase;}
139 .syntax_alpha_identifier {}
140 .syntax_alpha_variable {}
141 .syntax_quote {}
142 .syntax_quote_backtick {}
143 <?php
144 echo PMA_SQP_buildCssData();
146 //-->
147 </style>
149 <?php
150 $title = '';
151 if (isset($GLOBALS['db'])) {
152 $title .= str_replace('\'', '\\\'', $GLOBALS['db']);
154 if (isset($GLOBALS['table'])) {
155 $title .= (empty($title) ? '' : '.') . str_replace('\'', '\\\'', $GLOBALS['table']);
157 if (!empty($GLOBALS['cfg']['Server']) && isset($GLOBALS['cfg']['Server']['host'])) {
158 $title .= (empty($title) ? 'phpMyAdmin ' : ' ')
159 . sprintf($GLOBALS['strRunning'], (empty($GLOBALS['cfg']['Server']['verbose']) ? str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['host']) : str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['verbose'])));
161 $title .= (empty($title) ? '' : ' - ') . 'phpMyAdmin ' . PMA_VERSION;
163 <script type="text/javascript" language="javascript">
164 <!--
165 // Updates the title of the frameset if possible (ns4 does not allow this)
166 if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
167 && typeof(parent.document.title) == 'string') {
168 parent.document.title = '<?php echo $title; ?>';
170 <?php
171 // Add some javascript instructions if required
172 if (isset($js_to_run) && $js_to_run == 'functions.js') {
173 echo "\n";
175 // js form validation stuff
176 var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
177 var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
178 var errorMsg2 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotValidNumber']); ?>';
179 var noDropDbMsg = '<?php echo((!$GLOBALS['cfg']['AllowUserDropDatabase']) ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''); ?>';
180 var confirmMsg = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
181 //-->
182 </script>
183 <script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
184 <?php
185 } else if (isset($js_to_run) && $js_to_run == 'user_details.js') {
186 echo "\n";
188 // js form validation stuff
189 var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
190 var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
191 var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
192 var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
193 //-->
194 </script>
195 <script src="libraries/user_details.js" type="text/javascript" language="javascript"></script>
196 <?php
197 } else if (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
198 echo "\n";
200 // js form validation stuff
201 var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
202 var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
203 var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
204 var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
205 //-->
206 </script>
207 <script src="libraries/server_privileges.js" type="text/javascript" language="javascript"></script>
208 <?php
209 } else if (isset($js_to_run) && $js_to_run == 'indexes.js') {
210 echo "\n";
212 // js index validation stuff
213 var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
214 var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
215 var errorMsg2 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotValidNumber']); ?>';
216 //-->
217 </script>
218 <script src="libraries/indexes.js" type="text/javascript" language="javascript"></script>
219 <?php
220 } else if (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
221 echo "\n";
223 //-->
224 </script>
225 <script src="libraries/tbl_change.js" type="text/javascript" language="javascript"></script>
226 <?php
227 } else {
228 echo "\n";
230 //-->
231 </script>
232 <?php
234 echo "\n";
236 // If query window is wanted and open, update with latest selected db/table.
237 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
239 <script>
240 <?php
241 if ($cfg['QueryFrameDebug']) {
243 document.writeln("Updating query window. DB: <?php echo (isset($db) ? $db : 'FALSE'); ?>, Table: <?php echo (isset($table) ? $table : 'FALSE'); ?><br>");
244 document.writeln("Window: " + top.frames.queryframe.querywindow.location + "<br>");
245 <?php
249 if (top.frames.queryframe) {
250 <?php echo (isset($db) ? 'top.frames.queryframe.document.queryframeform.db.value = "' . htmlspecialchars($db) . '";' : ''); ?>
251 <?php echo (isset($table) ? 'top.frames.queryframe.document.queryframeform.table.value = "' . htmlspecialchars($table) . '";' : ''); ?>
254 function reload_querywindow () {
255 if (top.frames.queryframe && !top.frames.queryframe.querywindow.closed && top.frames.queryframe.querywindow.location) {
256 <?php echo ($cfg['QueryFrameDebug'] ? 'document.writeln("<a href=\'#\' onClick=\'top.frames.queryframe.querywindow.focus(); return false;\'>Query Window</a> can be updated.<br>");' : ''); ?>
258 top.frames.queryframe.querywindow.document.querywindow.db.value = "<?php echo (isset($db) ? htmlspecialchars($db) : '') ?>";
259 top.frames.queryframe.querywindow.document.querywindow.query_history_latest_db.value = "<?php echo (isset($db) ? htmlspecialchars($db) : '') ?>";
260 top.frames.queryframe.querywindow.document.querywindow.table.value = "<?php echo (isset($table) ? htmlspecialchars($table) : '') ?>";
261 top.frames.queryframe.querywindow.document.querywindow.query_history_latest_table.value = "<?php echo (isset($table) ? htmlspecialchars($table) : '') ?>";
263 <?php echo (isset($sql_query) ? 'top.frames.queryframe.querywindow.document.querywindow.query_history_latest.value = "' . urlencode($sql_query) . '";' : ''); ?>
265 <?php echo ($cfg['QueryFrameDebug'] ? 'alert(\'Querywindow submits. Last chance to check variables.\');' : ''); ?>
266 top.frames.queryframe.querywindow.document.querywindow.submit();
270 function focus_querywindow() {
271 if (top.frames.queryframe.querywindow && !top.frames.queryframe.querywindow.closed && top.frames.queryframe.querywindow.location) {
272 top.frames.queryframe.querywindow.focus();
273 } else {
274 top.frames.queryframe.querywindow=window.open('querywindow.php3?<?php echo PMA_generate_common_url('', ''); ?>&db=<?php echo (isset($db) ? htmlspecialchars($db) : ''); ?>&table=<?php echo (isset($table) ? htmlspecialchars($table) : ''); ?>', 'js_querywindow','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width=<?php echo $cfg['QueryWindowWidth']; ?>,height=<?php echo $cfg['QueryWindowHeight']; ?>');
276 if (!top.frames.queryframe.querywindow.opener) {
277 top.frames.queryframe.querywindow.opener = top.frames.queryframe;
280 reload_querywindow();
284 reload_querywindow();
285 self.focus();
288 </script>
289 <?php
292 </head>
295 <?php
296 if ($GLOBALS['cfg']['RightBgImage'] != '') {
297 $bkg_img = ' background="' . $GLOBALS['cfg']['RightBgImage'] . '"';
298 } else {
299 $bkg_img = '';
302 <body bgcolor="<?php echo $GLOBALS['cfg']['RightBgColor'] . '"' . $bkg_img; ?>>
303 <?php
304 if (!defined('PMA_DISPLAY_HEADING')) {
305 define('PMA_DISPLAY_HEADING', 1);
307 if (PMA_DISPLAY_HEADING) {
308 $header_url_qry = '?' . PMA_generate_common_url();
309 echo '<h1>' . "\n";
310 $server_info = (!empty($cfg['Server']['verbose'])
311 ? $cfg['Server']['verbose']
312 : $server_info = $cfg['Server']['host'] . (empty($cfg['Server']['port'])
313 ? ''
314 : ':' . $cfg['Server']['port']
317 if (isset($GLOBALS['db'])) {
318 echo ' ' . $GLOBALS['strDatabase'] . ' <i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . $header_url_qry . '&amp;db=' . urlencode($GLOBALS['db']) . '">' . htmlspecialchars($GLOBALS['db']) . '</a></i>' . "\n";
319 if (!empty($GLOBALS['table'])) {
320 echo ' - ' . $GLOBALS['strTable'] . ' <i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabTable'] . $header_url_qry . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '">' . htmlspecialchars($GLOBALS['table']) . '</a></i>' . "\n";
322 echo ' ' . sprintf($GLOBALS['strRunning'], '<i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabServer'] . $header_url_qry . '">' . htmlspecialchars($server_info) . '</a></i>');
323 } else {
324 echo ' ' . sprintf($GLOBALS['strServer'], '<i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabServer'] . $header_url_qry . '">' . htmlspecialchars($server_info) . '</a></i>');
326 echo "\n" . '</h1>' . "\n";
328 echo "\n";
332 * Sets a variable to remember headers have been sent
334 $GLOBALS['is_header_sent'] = TRUE;