Пример #1
0
 function _get_config_line($posted_value)
 {
     if ($this->description) {
         $n = "\n";
     }
     if ($posted_value == '') {
         $p = "{$n};" . $this->_config_format("");
         $p .= "\n; If you used the passencrypt.php utility to encode the password";
         $p .= "\n; then uncomment this line:";
         $p .= "\n;ENCRYPTED_PASSWD = true";
         return $p;
     } else {
         if (function_exists('crypt')) {
             $salt_length = max(CRYPT_SALT_LENGTH, 2 * CRYPT_STD_DES, 9 * CRYPT_EXT_DES, 12 * CRYPT_MD5, 16 * CRYPT_BLOWFISH);
             // generate an encrypted password
             $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
             $p = "{$n}" . $this->_config_format($crypt_pass);
             return $p . "\nENCRYPTED_PASSWD = true";
         } else {
             $p = "{$n}" . $this->_config_format($posted_value);
             $p .= "\n; Encrypted passwords cannot be used:";
             $p .= "\n; 'function crypt()' not available in this version of php";
             $p .= "\nENCRYPTED_PASSWD = false";
             return $p;
         }
     }
 }
Пример #2
0
$posted = $GLOBALS['HTTP_POST_VARS'];
if (!empty($posted['create'])) {
    $new_password = random_good_password();
    echo "<p>The newly created random password is:<br />\n<br />&nbsp;&nbsp;&nbsp;\n<tt><strong>", htmlentities($new_password), "</strong></tt></p>\n";
    $posted['password'] = $new_password;
    $posted['password2'] = $new_password;
}
if ($posted['password'] != "" && $posted['password'] == $posted['password2']) {
    $password = $posted['password'];
    /**
     * http://www.php.net/manual/en/function.crypt.php
     */
    // Use the maximum salt length the system can handle.
    $salt_length = max(CRYPT_SALT_LENGTH, 2 * CRYPT_STD_DES, 9 * CRYPT_EXT_DES, 12 * CRYPT_MD5, 16 * CRYPT_BLOWFISH);
    // Generate the encrypted password.
    $encrypted_password = crypt($password, rand_ascii($salt_length));
    $debug = $HTTP_GET_VARS['debug'];
    if ($debug) {
        echo "The password was encrypted using a salt length of: {$salt_length}<br />\n";
    }
    echo "<p>The encrypted password is:<br />\n<br />&nbsp;&nbsp;&nbsp;\n<tt><strong>", htmlentities($encrypted_password), "</strong></tt></p>\n";
    echo "<hr />\n";
} else {
    if ($posted['password'] != "") {
        echo "The passwords did not match. Please try again.<br />\n";
    }
}
if (empty($REQUEST_URI)) {
    $REQUEST_URI = $HTTP_ENV_VARS['REQUEST_URI'];
}
if (empty($REQUEST_URI)) {