phpldapadmin/htdocs/password_checker.php

87 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2009-06-30 09:22:30 +00:00
<?php
2009-06-30 09:29:51 +00:00
/**
* Check the password used by an entry.
*
2009-06-30 09:29:51 +00:00
* @package phpLDAPadmin
* @subpackage Page
2009-06-30 09:29:51 +00:00
*/
2009-06-30 09:29:51 +00:00
/**
*/
2009-06-30 09:22:30 +00:00
require './common.php';
$www['page'] = new page();
$request = array();
$request['componentid'] = get_request('componentid','REQUEST');
$request['hash'] = get_request('hash','REQUEST');
$request['password'] = get_request('check_password','REQUEST');
$request['action'] = get_request('action','REQUEST');
2009-06-30 09:22:30 +00:00
2009-06-30 10:46:00 +00:00
if (get_request('base64','REQUEST')) {
$request['hash'] = base64_decode($request['hash']);
$request['password'] = base64_decode($request['password']);
2009-06-30 09:22:30 +00:00
}
$request['enc_type'] = get_enc_type($request['hash']);
2009-06-30 10:46:00 +00:00
printf('<h3 class="subtitle">%s</h3>',_('Password Checker Tool'));
echo '<form action="password_checker.php" method="post">';
echo '<input type="hidden" name="action" value="compare" />';
2009-06-30 11:51:50 +00:00
echo '<table class="forminput" width=100% border=0>';
2009-06-30 10:46:00 +00:00
echo '<tr>';
2009-06-30 11:51:50 +00:00
printf('<td class="heading">%s</td>',_('Compare'));
printf('<td><input type="%s" name="hash" id="hash" value="%s" /></td>',
(obfuscate_password_display($request['enc_type']) ? 'password' : 'text'),htmlspecialchars($request['hash']));
2009-06-30 10:46:00 +00:00
echo '</tr>';
echo '<tr>';
2009-06-30 11:51:50 +00:00
printf('<td class="heading">%s</td>',_('To'));
printf('<td><input type="password" name="check_password" value="%s" /></td>',
htmlspecialchars($request['password']));
2009-06-30 10:46:00 +00:00
echo '</tr>';
echo '<tr>';
echo '<td>&nbsp;</td>';
echo '<td><input type="submit" value="Compare" />';
2009-06-30 09:22:30 +00:00
if ($request['action'] == 'compare') {
2009-06-30 10:46:00 +00:00
echo '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
if (password_check($request['hash'],$request['password']))
2009-06-30 10:46:00 +00:00
printf('<span class="good">%s</span>',_('Passwords match!'));
else
printf('<span class="bad">%s</span>',_('Passwords do not match!'));
echo '</b>';
}
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</form>';
# Pull our password from the form that opened this window.
if ($request['componentid']) {
echo '<script type="text/javascript">';
2009-08-22 11:30:50 +00:00
printf('var c = window.opener.document.getElementById("%s");',$request['componentid']);
printf('var h = document.getElementById("%s");','hash');
2009-06-30 10:46:00 +00:00
echo 'if (c && h) { h.value = c.value; }';
echo '</script>';
}
# Capture the output and put into the body of the page.
$www['body'] = new block();
$www['body']->SetBody(ob_get_contents());
$www['page']->block_add('body',$www['body']);
ob_end_clean();
# Render the popup.
$www['page']->display(array('CONTROL'=>false,'FOOT'=>false,'HEAD'=>false,'TREE'=>false));
2009-06-30 10:46:00 +00:00
?>