display errors in place
This commit is contained in:
Sebastian Mendel
2007-10-16 08:31:13 +00:00
parent 568e735186
commit 1c47906d0a

View File

@@ -33,36 +33,6 @@ if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) {
$iv = base64_decode($_COOKIE['pma_mcrypt_iv']); $iv = base64_decode($_COOKIE['pma_mcrypt_iv']);
} }
/**
* String padding
*
* @param string input string
* @param integer length of the result
* @param string the filling string
* @param integer padding mode
*
* @return string the padded string
*
* @access public
*/
function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) {
$str = '';
$length = $pad_length - strlen($input);
if ($length > 0) { // str_repeat doesn't like negatives
if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1
$str = $input.str_repeat($pad_string, $length);
} elseif ($pad_type == STR_PAD_BOTH) { // STR_PAD_BOTH == 2
$str = str_repeat($pad_string, floor($length/2));
$str .= $input;
$str .= str_repeat($pad_string, ceil($length/2));
} else { // defaults to STR_PAD_LEFT == 0
$str = str_repeat($pad_string, $length).$input;
}
} else { // if $length is negative or zero we don't need to do anything
$str = $input;
}
return $str;
}
/** /**
* Encryption using blowfish algorithm (mcrypt) * Encryption using blowfish algorithm (mcrypt)
* *
@@ -75,11 +45,9 @@ if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) {
* *
* @author lem9 * @author lem9
*/ */
function PMA_blowfish_encrypt($data, $secret) { function PMA_blowfish_encrypt($data, $secret)
{
global $iv; global $iv;
// Seems we don't need the padding. Anyway if we need it,
// we would have to replace 8 by the next 8-byte boundary.
//$data = full_str_pad($data, 8, "\0", STR_PAD_RIGHT);
return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv)); return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv));
} }
@@ -95,20 +63,17 @@ if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) {
* *
* @author lem9 * @author lem9
*/ */
function PMA_blowfish_decrypt($encdata, $secret) { function PMA_blowfish_decrypt($encdata, $secret)
{
global $iv; global $iv;
return trim(mcrypt_decrypt(MCRYPT_BLOWFISH, $secret, base64_decode($encdata), MCRYPT_MODE_CBC, $iv)); return trim(mcrypt_decrypt(MCRYPT_BLOWFISH, $secret, base64_decode($encdata), MCRYPT_MODE_CBC, $iv));
} }
} else { } else {
require_once './libraries/blowfish.php'; require_once './libraries/blowfish.php';
/**
* display warning in main.php
*/
trigger_error(PMA_sanitize(sprintf($strCantLoad, 'mcrypt')), E_USER_WARNING); trigger_error(PMA_sanitize(sprintf($strCantLoad, 'mcrypt')), E_USER_WARNING);
} }
/** /**
* Displays authentication form * Displays authentication form
* *
@@ -230,8 +195,7 @@ if (top != self) {
// Show error message // Show error message
if (! empty($conn_error)) { if (! empty($conn_error)) {
echo '<div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n"; PMA_Message::rawError($conn_error)->display();
echo $conn_error . '</div>' . "\n";
} }
// Displays the languages form // Displays the languages form
@@ -242,11 +206,12 @@ if (top != self) {
// Displays the warning message and the login form // Displays the warning message and the login form
if (empty($GLOBALS['cfg']['blowfish_secret'])) { if (empty($GLOBALS['cfg']['blowfish_secret'])) {
?> PMA_Message::error('strSecretRequired')->display();
<div class="error"><h1><?php echo $GLOBALS['strError']; ?></h1> if ($GLOBALS['error_handler']->hasDisplayErrors()) {
<?php echo $GLOBALS['strSecretRequired']; ?> echo '<div>';
</div> $GLOBALS['error_handler']->dispErrors();
<?php echo '</div>';
}
echo '</div>' . "\n"; echo '</div>' . "\n";
if (file_exists('./config.footer.inc.php')) { if (file_exists('./config.footer.inc.php')) {
require './config.footer.inc.php'; require './config.footer.inc.php';
@@ -331,7 +296,11 @@ if (top != self) {
if (empty($_COOKIE)) { if (empty($_COOKIE)) {
trigger_error($GLOBALS['strCookiesRequired'], E_USER_NOTICE); trigger_error($GLOBALS['strCookiesRequired'], E_USER_NOTICE);
} }
$GLOBALS['error_handler']->dispUserErrors(); if ($GLOBALS['error_handler']->hasDisplayErrors()) {
echo '<div>';
$GLOBALS['error_handler']->dispErrors();
echo '</div>';
}
?> ?>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@@ -350,16 +319,19 @@ function PMA_focusInput()
window.setTimeout('PMA_focusInput()', 500); window.setTimeout('PMA_focusInput()', 500);
// ]]> // ]]>
</script> </script>
</body>
</html>
<?php <?php
if (file_exists('./config.footer.inc.php')) { if (file_exists('./config.footer.inc.php')) {
require './config.footer.inc.php'; require './config.footer.inc.php';
} }
?>
</body>
</html>
<?php
exit; exit;
} // end of the 'PMA_auth()' function } // end of the 'PMA_auth()' function
/** /**
* Gets advanced authentication settings * Gets advanced authentication settings
* *