Integrated authentication libraries with PMA_Header class

This commit is contained in:
Rouslan Placella 2012-05-30 13:49:41 +01:00
parent e306fadaab
commit da1e70e1fb
8 changed files with 41 additions and 56 deletions

View File

@ -29,10 +29,15 @@ class PMA_Header {
private $_bodyId;
private $_menuEnabled;
private $_isPrintView;
private $_isAjax;
public static $headerIsSent;
private function __construct()
{
$this->_isAjax = false;
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
$this->_isAjax = true;
}
$this->_bodyId = '';
$this->_title = 'phpMyAdmin';
$this->_menu = new PMA_Menu(
@ -101,7 +106,7 @@ class PMA_Header {
$retval = '';
if (! self::$headerIsSent) {
$this->sendHttpHeaders();
if ($GLOBALS['is_ajax_request'] === false) {
if ($this->_isAjax === false) {
$retval .= $this->_getHtmlStart();
$retval .= $this->_getMetaTags();
$retval .= $this->_getLinkTags();

View File

@ -68,21 +68,18 @@ function PMA_auth_set_user()
function PMA_auth_fails()
{
$conn_error = PMA_DBI_getError();
if (!$conn_error) {
if (! $conn_error) {
$conn_error = __('Cannot connect: invalid settings.');
}
// Defines the charset to be used
header('Content-Type: text/html; charset=utf-8');
/* HTML header */
$page_title = __('Access denied');
include './libraries/header_meta_style.inc.php';
include './libraries/header_scripts.inc.php';
?>
$GLOBALS['page_title'] = __('Access denied');
$header = PMA_Header::getInstance();
$header->setTitle(__('Access denied'));
$header->disableMenu();
$header->display();
</head>
<body>
?>
<br /><br />
<center>
<h1><?php echo sprintf(__('Welcome to %s'), ' phpMyAdmin '); ?></h1>

View File

@ -154,20 +154,12 @@ function PMA_auth()
$cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right';
// Defines the charset to be used
header('Content-Type: text/html; charset=utf-8');
$GLOBALS['page_title'] = 'phpMyAdmin';
$header = PMA_Header::getInstance();
$header->setBodyId('loginform');
$header->disableMenu();
$header->display();
/* HTML header; do not show here the PMA version to improve security */
$page_title = 'phpMyAdmin ';
include './libraries/header_meta_style.inc.php';
// if $page_title is set, this script uses it as the title:
include './libraries/header_scripts.inc.php';
?>
</head>
<body class="loginform">
<?php
if (file_exists(CUSTOM_HEADER_FILE)) {
include CUSTOM_HEADER_FILE;
}
@ -189,7 +181,7 @@ function PMA_auth()
<?php
echo sprintf(
__('Welcome to %s'),
'<bdo dir="ltr" lang="en">' . $page_title . '</bdo>'
'<bdo dir="ltr" lang="en">phpMyAdmin</bdo>'
);
?>
</h1>
@ -306,7 +298,7 @@ function PMA_auth()
<script type="text/javascript">
//<![CDATA[
// show login form in top frame.
if (top != self || document.body.className != 'loginform') {
if (top != self || ! $('body#loginform').length) {
window.top.location.href=location;
}
//]]>

View File

@ -48,20 +48,14 @@ function PMA_auth()
header('status: 401 Unauthorized');
}
// Defines the charset to be used
header('Content-Type: text/html; charset=utf-8');
/* HTML header */
$page_title = __('Access denied');
include './libraries/header_meta_style.inc.php';
?>
</head>
<body>
<?php
if (file_exists(CUSTOM_HEADER_FILE)) {
include CUSTOM_HEADER_FILE;
}
?>
$GLOBALS['page_title'] = __('Access denied');
$header = PMA_Header::getInstance();
$header->setTitle(__('Access denied'));
$header->disableMenu();
$header->display();
?>
<br /><br />
<center>
<h1><?php echo sprintf(__('Welcome to %s'), ' phpMyAdmin'); ?></h1>

View File

@ -84,6 +84,11 @@ if (version_compare(phpversion(), '5.4', 'lt')) {
*/
define('PHPMYADMIN', true);
/**
* Used to generate the header of the page
*/
include_once 'libraries/Header.class.php';
/**
* core functions
*/
@ -1092,8 +1097,4 @@ if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
exit();
}
/**
* Used to generate the header of the page
*/
include_once 'libraries/Header.class.php';
?>

View File

@ -8,12 +8,6 @@ if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Starts output buffering work
*/
require_once './libraries/ob.lib.php';
PMA_outBufferPre();
$header = PMA_Header::getInstance();
$header->enablePrintView();
$header->display();

View File

@ -641,17 +641,18 @@ div#querychart {
/**
* login form
*/
body.loginform h1,
body.loginform a.logo {
body#loginform h1,
body#loginform a.logo {
display: block;
text-align: center;
}
body.loginform {
body#loginform {
margin-top: 1em;
text-align: center;
}
body.loginform div.container {
body#loginform div.container {
text-align: <?php echo $left; ?>;
width: 30em;
margin: 0 auto;

View File

@ -855,17 +855,18 @@ td.disabled {
/**
* login form
*/
body.loginform h1,
body.loginform a.logo {
body#loginform h1,
body#loginform a.logo {
display: block;
text-align: center;
}
body.loginform {
body#loginform {
margin-top: 1em;
text-align: center;
}
body.loginform div.container {
body#loginform div.container {
text-align: <?php echo $left; ?>;
width: 30em;
margin: 0 auto;