Hits: 41191
Try: ca/tecreations/ViewFile.php -- Online
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/Base.php";
global $user;
$user->setDebug(true);
if (isset($_SESSION['uid']) && isset($_SESSION['level'])) {
header("Location: $PREFIX_DIR/Apps/Welcome.php");
}
$email = $pass = $email_err = $pass_err = "";
if (isset($_SERVER['QUERY_STRING'])) {
if (!empty($_SERVER['QUERY_STRING'])) {
if (!(isset($_REQUEST['email']) && isset($_REQUEST['pass']))) {
Unauthorized();
die("Unauthorized.");
} else {
if (!empty($_REQUEST['email'])) {
$email = $_REQUEST['email'];
} else $email_err = "Empty email address.";
if (!$user->exists($email)) $email_err = "Non-existent user.";
if (!empty($_REQUEST['pass'])) {
$pass = $_REQUEST['pass'];
} else $pass_err = "Empty password.";
if ($email_err == "" && $pass_err == "") {
if ($user->isLocked($email) == "1") {
header("Location: $PREFIX_DIR/Login/AccountLocked.php");
die();
}
if ($user->getToken($email) != "") {
header("Location: $PREFIX_DIR/Login/ConfirmEmail.php?email=$email");
die();
}
if (password_verify($pass,$user->getPass($email))) {
$_SESSION['email'] = $email;
$_SESSION['uid'] = $user->getUID($email);
$_SESSION['level'] = $user->getLevel($_SESSION['uid']);
$user->login($_SESSION['uid']);
// check for email confirmation and security questions being answered
header("Location: $PREFIX_DIR/Login/Security.php?email=$email");
die();
} else {
$user->attempt($email);
$pass_err = "Incorrect password. You have " . $user->triesLeft($email) . " tries remaining before your account will be locked.";
if ($user->isLocked($email)) {
header("Location: $PREFIX_DIR/Login/AccountLocked.php");
die();
}
}
}
}
}
}
require_once $_SERVER['DOCUMENT_ROOT'] . $PREFIX_DIR . "/start.php";
?>
<link rel="stylesheet" href="site.css" type="text/css">
<title>Login</title>
<style type="text/css">
.wrapper { width: 450px; padding: 25px; }
</style>
<script>
function ValidateForm() {
if (ValidateEmail(document.form1.email)) {
return true;
} else {
if (document.form1.email.val().equals("")) {
document.form1.email-err.val("Email cannot be empty.");
} else {
document.form1.email-err.val("You have entered an invalid email address!");
}
document.form1.email.focus();
return false;
}
}
function showPassword() {
var x = document.form1.pass;
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
</script>
</head>
<body>
<?php
global $DOCROOT;
include_once $DOCROOT . "/$PREFIX_DIR/header_start.php";
include_once $DOCROOT . "$PREFIX_DIR/menu/java.php";
include_once $DOCROOT . "$PREFIX_DIR/menu/apps.php";
include_once $DOCROOT . "/$PREFIX_DIR/menu/register.php";
include_once $DOCROOT . "/$PREFIX_DIR/menu/contact.php";
include_once $DOCROOT . "/$PREFIX_DIR/header_finish.php";
?>
<div class="wrapper">
<h2>Login</h2>
<p>Please fill out this form to login to your account.</p>
<form action="<?php $_SERVER["PHP_SELF"]; ?>" method="<?php GLOBAL $METHOD; echo $METHOD; ?>" name="form1">
<div class="form-group <?php echo (!empty($email_err)) ? 'has-error' : ''; ?>">
<label>Email</label>
<input type="text" name="email" class="form-control" value="<?php echo htmlspecialchars($email); ?>">
<span class="help-block" id="email-err"><?php echo $email_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($pass_err)) ? 'has-error' : ''; ?>">
<label>Password</label>
<input autocomplete="off" type="password" name="pass" id="pass" class="form-control" value="<?php echo htmlspecialchars($pass); ?>">
<input type="checkbox" onclick="showPassword()">Show Password
<span class="help-block"><?php echo $pass_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit" onclick="return ValidateForm()">
<input type="reset" class="btn btn-default" value="Reset">
</div>
<p align="center"><a href="<?php echo $PREFIX_DIR; ?>/Login/Forgot.php">Forgotten Password?</a></p>
</form>
</div>
<script src="/ca/tecreations/email-validation.js"></script>
<?php require_once "$DOCROOT$PREFIX_DIR/footer.html"; ?>