home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / xampp-win32-1.6.5-installer.exe / phpMyAdmin / libraries / header.inc.php < prev    next >
Encoding:
PHP Script  |  2007-12-20  |  11.0 KB  |  270 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: header.inc.php 10631 2007-09-12 09:25:24Z lem9 $
  6.  */
  7.  
  8. /**
  9.  *
  10.  */
  11. require_once './libraries/common.inc.php';
  12.  
  13. if (empty($GLOBALS['is_header_sent'])) {
  14.  
  15.     /**
  16.      * Gets a core script and starts output buffering work
  17.      */
  18.     require_once './libraries/common.inc.php';
  19.     require_once './libraries/ob.lib.php';
  20.     PMA_outBufferPre();
  21.  
  22.     // garvin: For re-usability, moved http-headers and stylesheets
  23.     // to a seperate file. It can now be included by header.inc.php,
  24.     // querywindow.php.
  25.  
  26.     require_once './libraries/header_http.inc.php';
  27.     require_once './libraries/header_meta_style.inc.php';
  28.  
  29.     // generate title
  30.     $title     = str_replace(
  31.                     array(
  32.                         '@HTTP_HOST@',
  33.                         '@SERVER@',
  34.                         '@VERBOSE@',
  35.                         '@VSERVER@',
  36.                         '@DATABASE@',
  37.                         '@TABLE@',
  38.                         '@PHPMYADMIN@',
  39.                         ),
  40.                     array(
  41.                         PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '',
  42.                         isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '',
  43.                         isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '',
  44.                         !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''),
  45.                         $GLOBALS['db'],
  46.                         $GLOBALS['table'],
  47.                         'phpMyAdmin ' . PMA_VERSION,
  48.                         ),
  49.                     !empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] :
  50.                     (!empty($GLOBALS['db']) ? $GLOBALS['cfg']['TitleDatabase'] :
  51.                     (!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] :
  52.                     $GLOBALS['cfg']['TitleDefault']))
  53.                     );
  54.     // here, the function does not exist with this configuration: $cfg['ServerDefault'] = 0;
  55.     $is_superuser    = function_exists('PMA_isSuperuser') && PMA_isSuperuser();
  56.     ?>
  57.     <script type="text/javascript">
  58.     // <![CDATA[
  59.     // Updates the title of the frameset if possible (ns4 does not allow this)
  60.     if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
  61.         && typeof(parent.document.title) == 'string') {
  62.         parent.document.title = '<?php echo PMA_sanitize(str_replace('\'', '\\\'', $title)); ?>';
  63.     }
  64.     <?php
  65.     // Add some javascript instructions if required
  66.     if (isset($js_to_run) && $js_to_run == 'functions.js') {
  67.         echo "\n";
  68.         ?>
  69.     // js form validation stuff
  70.     var errorMsg0   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
  71.     var errorMsg1   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
  72.     var noDropDbMsg = '<?php echo (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase'])
  73.         ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''; ?>';
  74.     var confirmMsg  = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
  75.     var confirmMsgDropDB  = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDropDatabaseStrongWarning']) : ''); ?>';
  76.     // ]]>
  77.     </script>
  78.     <script src="./js/functions.js" type="text/javascript"></script>
  79.         <?php
  80.     } elseif (isset($js_to_run) && $js_to_run == 'user_password.js') {
  81.         echo "\n";
  82.         ?>
  83.     // js form validation stuff
  84.     var jsHostEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
  85.     var jsUserEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
  86.     var jsPasswordEmpty   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
  87.     var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
  88.     // ]]>
  89.     </script>
  90.     <script src="./js/user_password.js" type="text/javascript"></script>
  91.         <?php
  92.     } elseif (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
  93.         echo "\n";
  94.         ?>
  95.     // js form validation stuff
  96.     var jsHostEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
  97.     var jsUserEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
  98.     var jsPasswordEmpty   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
  99.     var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
  100.     // ]]>
  101.     </script>
  102.     <script src="./js/server_privileges.js" type="text/javascript"></script>
  103.     <script src="./js/functions.js" type="text/javascript"></script>
  104.         <?php
  105.     } elseif (isset($js_to_run) && $js_to_run == 'indexes.js') {
  106.         echo "\n";
  107.         ?>
  108.     // js index validation stuff
  109.     var errorMsg0   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
  110.     var errorMsg1   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
  111.     // ]]>
  112.     </script>
  113.     <script src="./js/indexes.js" type="text/javascript"></script>
  114.         <?php
  115.     } elseif (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
  116.         echo "\n";
  117.         ?>
  118.     // ]]>
  119.     </script>
  120.     <script src="./js/tbl_change.js" type="text/javascript"></script>
  121.         <?php
  122.     } else {
  123.         echo "\n";
  124.         ?>
  125.     // ]]>
  126.     </script>
  127.         <?php
  128.     }
  129.     echo "\n";
  130.  
  131.     // Reloads the navigation frame via JavaScript if required
  132.     PMA_reloadNavigation();
  133.     ?>
  134.     <script src="./js/tooltip.js" type="text/javascript"></script>
  135.     <meta name="OBGZip" content="<?php echo ($GLOBALS['cfg']['OBGzip'] ? 'true' : 'false'); ?>" />
  136.     <?php /* remove vertical scroll bar bug in ie */ ?>
  137.     <!--[if IE 6]>
  138.     <style type="text/css">
  139.     /* <![CDATA[ */
  140.     html {
  141.         overflow-y: scroll;
  142.     }
  143.     /* ]]> */
  144.     </style>
  145.     <![endif]-->
  146. </head>
  147.  
  148. <body>
  149. <div id="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div>
  150.     <?php
  151.  
  152.     // Include possible custom headers
  153.     if (file_exists('./config.header.inc.php')) {
  154.         require './config.header.inc.php';
  155.     }
  156.  
  157.  
  158.     // message of "Cookies required" displayed for auth_type http or config
  159.     // note: here, the decoration won't work because without cookies,
  160.     // our standard CSS is not operational
  161.     if (empty($_COOKIE)) {
  162.          echo '<div class="notice">' . $GLOBALS['strCookiesRequired'] . '</div>' . "\n";
  163.     }
  164.  
  165.     if (!defined('PMA_DISPLAY_HEADING')) {
  166.         define('PMA_DISPLAY_HEADING', 1);
  167.     }
  168.  
  169.     /**
  170.      * Display heading if needed. Design can be set in css file.
  171.      */
  172.  
  173.     if (PMA_DISPLAY_HEADING) {
  174.         $server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
  175.                         ? $GLOBALS['cfg']['Server']['verbose']
  176.                         : $GLOBALS['cfg']['Server']['host'] . (empty($GLOBALS['cfg']['Server']['port'])
  177.                                                                ? ''
  178.                                                                : ':' . $GLOBALS['cfg']['Server']['port']
  179.                                                               )
  180.                        );
  181.         $item = '<a href="%1$s?%2$s" class="item">';
  182.         if ($GLOBALS['cfg']['NavigationBarIconic']) {
  183.             $separator = '        <span class="separator"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'item_ltr.png" width="5" height="9" alt="-" /></span>' . "\n";
  184.             $item .= '        <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . '%5$s" width="16" height="16" alt="" /> ' . "\n";
  185.         } else {
  186.             $separator = '        <span class="separator"> - </span>' . "\n";
  187.         }
  188.  
  189.         if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) {
  190.             $item .= '%4$s: ';
  191.         }
  192.         $item .= '%3$s</a>' . "\n";
  193.  
  194.         echo '<div id="serverinfo">' . "\n";
  195.         printf($item,
  196.                 $GLOBALS['cfg']['DefaultTabServer'],
  197.                 PMA_generate_common_url(),
  198.                 htmlspecialchars($server_info),
  199.                 $GLOBALS['strServer'],
  200.                 's_host.png');
  201.  
  202.         if (strlen($GLOBALS['db'])) {
  203.  
  204.             echo $separator;
  205.             printf($item,
  206.                     $GLOBALS['cfg']['DefaultTabDatabase'],
  207.                     PMA_generate_common_url($GLOBALS['db']),
  208.                     htmlspecialchars($GLOBALS['db']),
  209.                     $GLOBALS['strDatabase'],
  210.                     's_db.png');
  211.  
  212.             if (strlen($GLOBALS['table'])) {
  213.                 require_once './libraries/tbl_info.inc.php';
  214.  
  215.                 echo $separator;
  216.                 printf($item,
  217.                         $GLOBALS['cfg']['DefaultTabTable'],
  218.                         PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']),
  219.                         str_replace(' ', ' ', htmlspecialchars($GLOBALS['table'])),
  220.                         (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? $GLOBALS['strView'] : $GLOBALS['strTable']),
  221.                         (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views' : 's_tbl') . '.png');
  222.  
  223.                 /**
  224.                  * Displays table comment
  225.                  * @uses $show_comment from libraries/tbl_info.inc.php
  226.                  * @uses $GLOBALS['avoid_show_comment'] from tbl_relation.php
  227.                  */
  228.                 if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) {
  229.                     if (strstr($show_comment, '; InnoDB free')) {
  230.                         $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
  231.                     }
  232.                     echo '<span class="table_comment" id="span_table_comment">'
  233.                         .'"' . htmlspecialchars($show_comment)
  234.                         .'"</span>' . "\n";
  235.                 } // end if
  236.             } else {
  237.                 // no table selected, display database comment if present
  238.                 /**
  239.                  * Settings for relations stuff
  240.                  */
  241.                 require_once './libraries/relation.lib.php';
  242.                 $cfgRelation = PMA_getRelationsParam();
  243.  
  244.                 // Get additional information about tables for tooltip is done
  245.                 // in libraries/db_info.inc.php only once
  246.                 if ($cfgRelation['commwork']) {
  247.                     $comment = PMA_getComments($GLOBALS['db']);
  248.  
  249.                     /**
  250.                      * Displays table comment
  251.                      */
  252.                     if (is_array($comment) && ! empty($comment)) {
  253.                         echo '<span class="table_comment"'
  254.                             .' id="span_table_comment">"'
  255.                             .htmlspecialchars(implode(' ', $comment))
  256.                             .'"</span>' . "\n";
  257.                     } // end if
  258.                 }
  259.             }
  260.         }
  261.         echo '</div>';
  262.  
  263.     }
  264.     /**
  265.      * Sets a variable to remember headers have been sent
  266.      */
  267.     $GLOBALS['is_header_sent'] = true;
  268. }
  269. ?>
  270.