function get_html() { global $HTTP_POST_VARS, $HTTP_GET_VARS; $s = $this->get_config_item_header(); if (isset($HTTP_POST_VARS['create']) or isset($HTTP_GET_VARS['create'])) { $new_password = random_good_password(); $this->default_value = $new_password; $s .= "Created password: <strong>{$new_password}</strong><br /> <br />"; } // dont re-encrypt already encrypted passwords $value = $this->value(); $encrypted = !empty($GLOBALS['properties']["Encrypted Passwords"]) and $GLOBALS['properties']["Encrypted Passwords"]->value(); if (empty($value)) { $encrypted = false; } $s .= "<input type=\"" . ($encrypted ? "text" : "password") . "\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $value . "\" {$this->jscheck} />" . " <input type=\"submit\" name=\"create\" value=\"Create Random Password\" />"; if (empty($value)) { $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>"; } elseif (strlen($this->default_value) < 4) { $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Must be longer than 4 chars.</p>"; } else { $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>"; } return $s; }
return $newpass; } /** PHP5 deprecated old-style globals if !(bool)ini_get('register_long_arrays'). * See Bug #1180115 * We want to work with those old ones instead of the new superglobals, * for easier coding. */ foreach (array('SERVER', 'GET', 'POST', 'ENV') as $k) { if (!isset($GLOBALS['HTTP_' . $k . '_VARS']) and isset($GLOBALS['_' . $k])) { $GLOBALS['HTTP_' . $k . '_VARS'] =& $GLOBALS['_' . $k]; } } unset($k); $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 /> \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) {