getTenantInstance();
if (_IsPostback())
{
if ($_GET["do_pw"] == "1")
{
$password = $_POST["password"];
$password_salt = generateRandomString(32);
$password_hash = hash("sha512", $password . $password_salt);
echo($password_hash);
echo ("
");
echo($password_salt);
return;
}
$username = get_ec_value(new InstanceKey(56, 1));
$password = get_ec_value(new InstanceKey(56, 2));
$pdo = getPDO();
$query = "SELECT * FROM bst_users WHERE username = :username";
$statement = $pdo->prepare($query);
$statement->execute(array(
"username" => $username
));
$results = $statement->fetchAll();
if (count($results) > 0)
{
$result = $results[0];
$password_hash = $result["password_hash"];
$password_salt = $result["password_salt"];
$expected_hash = hash("sha512", $password . $password_salt);
if ($expected_hash == $password_hash)
{
$error_message = "";
$user_id = $result["id"];
$ip_address = $_SERVER["REMOTE_ADDR"];
$session_tag = generateRandomString(32);
$_SESSION["user_token"] = $session_tag;
$statement = $pdo->prepare("INSERT INTO bst_sessions (session_tag, user_id, start_datetime, ip_address) VALUES (:session_tag, :user_id, NOW(), :ip_address)");
$statement->execute(array("session_tag" => $session_tag, "user_id" => $user_id, "ip_address" => $ip_address));
if (isset($_SESSION["LoginRedirectURL"]))
{
header("Location: /" . $_SESSION["LoginRedirectURL"]);
unset($_SESSION["LoginRedirectURL"]);
}
else
{
header("Location: /bst/");
}
return;
}
else
{
$error_message = "The user name or password you entered is incorrect. ( " . $password_hash . " ; " . $password_salt . " ; " . $expected_hash . " )";
}
}
else
{
$error_message = "The user name or password you entered is incorrect.";
}
}
function renderElementSingularVertically(Oms $oms, InstanceReference $element)
{
?>
| getRelatedInstances($elementContent, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Element_Content__has__Element_Content_Display_Option)); if ($elementContentDisplayOptions !== null) { foreach ($elementContentDisplayOptions as $displayOption) { if ($displayOption->GlobalIdentifier == KnownInstanceGuids::DisplayOption__ObscuredText) { $obscuredText = true; } } } if ($obscuredText) { ?> |