function plugin_md5_action() { global $get, $post; if (PKWK_SAFE_MODE || PKWK_READONLY) { die_message('Prohibited by admin'); } // Wait POST $phrase = isset($post['phrase']) ? $post['phrase'] : ''; if ($phrase == '') { // Show the form // If plugin=md5&md5=password, only set it (Don't compute) $value = isset($get['md5']) ? $get['md5'] : ''; return array('msg' => 'Compute userPassword', 'body' => plugin_md5_show_form(isset($post['phrase']), $value)); } else { // Compute (Don't show its $phrase at the same time) $prefix = isset($post['prefix']); $salt = isset($post['salt']) ? $post['salt'] : ''; // With scheme-prefix or not if (!preg_match('/^\\{.+\\}.*$/', $salt)) { $scheme = isset($post['scheme']) ? '{' . $post['scheme'] . '}' : ''; $salt = $scheme . $salt; } return array('msg' => 'Result', 'body' => pkwk_hash_compute($phrase, $salt, $prefix, true)); } }
function plugin_md5_action() { global $vars; // if (PKWK_SAFE_MODE || PKWK_READONLY) die_message(T_('Prohibited')); if (Auth::check_role('safemode') || Auth::check_role('readonly')) { Utility::dieMessage(T_('Prohibited')); } // Wait POST $phrase = isset($vars['phrase']) ? $vars['phrase'] : null; if (empty($phrase)) { // Show the form // If plugin=md5&md5=password, only set it (Don't compute) $value = isset($vars['md5']) ? $vars['md5'] : null; return array('msg' => T_('Compute userPassword'), 'body' => plugin_md5_show_form(isset($vars['phrase']), $value)); } else { // Compute (Don't show its $phrase at the same time) $prefix = isset($vars['prefix']); $salt = isset($vars['salt']) ? $vars['salt'] : null; // With scheme-prefix or not if (!preg_match('/^\\{.+\\}.*$/', $salt)) { $scheme = isset($vars['scheme']) ? '{' . $vars['scheme'] . '}' : null; $salt = $scheme . $salt; } return array('msg' => 'Result', 'body' => ($prefix ? '<label for="result">userPassword: </label>' : '') . '<input type="text" id="result" readonly="readonly" value="' . Auth::hash_compute($phrase, $salt, $prefix, TRUE) . '" class="form-control" />'); } }