示例#1
0
function validatePassword($password, $good_password, $format)
{
    if ($format == "pbkdf2") {
        require_once includePath() . "/pbkdf2.php";
        return pbkdf2_validate_password($password, $good_password);
    } else {
        if ($format == "hash") {
            return chash($password) == $good_password;
        } else {
            return $password == $good_password;
        }
    }
}
示例#2
0
    $password = $_REQUEST['password'];
    $format = "pbkdf2";
    if (isset($_REQUEST['format'])) {
        if ($_REQUEST['format'] == "hash") {
            $format = "hash";
        } else {
            if ($_REQUEST['format'] == "plain") {
                $format = "plain";
            }
        }
    }
    if ($format == "pbkdf2") {
        $password = pbkdf2_create_hash($password);
    } else {
        if ($format == "hash") {
            $password = chash($password);
        }
    }
    echo "<p>mkpasswd result: {$password}</p>";
}
?>

<form method="POST" action="mkpasswd.php">
Password: <input type="password" name="password" />
<br />Format: <select name="format">
	<option value="pbkdf2">PBKDF2 (recommended)</option>
	<option value="hash">SHA-512</option>
	<option value="plain">Plain text</option>
<br /><input type="submit" value="mkpasswd" />
</form>
</body>
示例#3
0
		$line = trim($line);
		if($line !== '') {
			mysql_query($line) or die("There was an error while attempting to create the oneapp tables.<br />" . mysql_error());
		}
	}
} else {
	die("Error: could not read from the install.sql file!");
}

//make sure that users aren't set up yet
echo "Checking users table<br />";
$result = mysql_query("SELECT COUNT(*) FROM users");
$row = mysql_fetch_row($result);

if($row[0] == 0) {
	echo "Creating site administrative user (username=admin, password is blank)<br />";
	
	mysql_query("INSERT INTO users (username, password, name, email, register_time, accessed) VALUES ('admin', '" . chash("") . "', 'Site Administrator', '*****@*****.**', '0', '0')");
	$admin_id = escape(mysql_insert_id());
	mysql_query("INSERT INTO user_groups (user_id, `group`) VALUES ('$admin_id', '0')");
	mysql_query("INSERT INTO user_groups (user_id, `group`) VALUES ('$admin_id', '-1')");
	
	initMessaging($admin_id);
	
	echo "<font color=\"green\">Installation is complete.</font>";
} else {
	die("Error: at least one user has been created. For security reasons, the users table must be empty to run this installation script.");
}

?>