2015-09-19 09:19:56 +00:00
|
|
|
<?php
|
|
|
|
register_module([
|
|
|
|
"name" => "Password hashing action",
|
2018-05-10 22:38:11 +00:00
|
|
|
"version" => "0.7",
|
2015-09-19 09:19:56 +00:00
|
|
|
"author" => "Starbeamrainbowlabs",
|
|
|
|
"description" => "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.",
|
|
|
|
"id" => "action-hash",
|
|
|
|
"code" => function() {
|
2016-06-12 12:40:28 +00:00
|
|
|
/**
|
|
|
|
* @api {get} ?action=hash&string={text} Hash a password
|
|
|
|
* @apiName Hash
|
|
|
|
* @apiGroup Utility
|
2016-06-12 20:15:43 +00:00
|
|
|
* @apiPermission Anonymous
|
|
|
|
*
|
2016-06-12 12:40:28 +00:00
|
|
|
* @apiParam {string} string The string to hash.
|
2016-06-12 20:15:43 +00:00
|
|
|
* @apiParam {boolean} raw Whether to return the hashed password as a raw string instead of as part of an HTML page.
|
|
|
|
*
|
|
|
|
* @apiError ParamNotFound The string parameter was not specified.
|
2016-06-12 12:40:28 +00:00
|
|
|
*/
|
2015-12-26 12:55:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ██ ██ █████ ███████ ██ ██
|
|
|
|
* ██ ██ ██ ██ ██ ██ ██
|
|
|
|
* ███████ ███████ ███████ ███████
|
|
|
|
* ██ ██ ██ ██ ██ ██ ██
|
|
|
|
* ██ ██ ██ ██ ███████ ██ ██
|
|
|
|
*/
|
2015-09-19 09:19:56 +00:00
|
|
|
add_action("hash", function() {
|
2015-10-10 12:00:46 +00:00
|
|
|
global $settings;
|
|
|
|
|
2019-02-10 23:18:34 +00:00
|
|
|
if(!isset($_GET["string"])) {
|
2015-09-19 09:19:56 +00:00
|
|
|
http_response_code(422);
|
|
|
|
exit(page_renderer::render_main("Missing parameter", "<p>The <code>GET</code> parameter <code>string</code> must be specified.</p>
|
|
|
|
<p>It is strongly recommended that you utilise this page via a private or incognito window in order to prevent your password from appearing in your browser history.</p>"));
|
|
|
|
}
|
2019-02-10 23:18:34 +00:00
|
|
|
else if(!empty($_GET["raw"])) {
|
2016-06-12 12:40:28 +00:00
|
|
|
header("content-type: text/plain");
|
|
|
|
exit(hash_password($_GET["string"]));
|
|
|
|
}
|
2019-02-10 23:18:34 +00:00
|
|
|
else {
|
2018-05-10 22:38:11 +00:00
|
|
|
exit(page_renderer::render_main("Hashed string", "<p>Algorithm: <code>$settings->password_algorithm</code></p>\n<p><code>" . $_GET["string"] . "</code> → <code>" . hash_password($_GET["string"]) . "</code></p>"));
|
2015-09-19 09:19:56 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
?>
|