You've already forked OpenShorte.old
Refactored database, refactored config file, corrected login redirection
Moved database function in class "Database"; Corrected database-using webpages accordingly; Moved config file from PHP to JSON with more config variables; Corrected login page redirection on wrong username or password.
This commit is contained in:
@@ -4,21 +4,22 @@
|
||||
exit;
|
||||
}
|
||||
if ( isset ( $session [ 1 ] ) && $session [ 1 ] == "forgot" ) {
|
||||
include ( 'lib/php/forgotpassword.php' );
|
||||
include ( $config [ 'installation_path ' ] . '/lib/php/forgotpassword.php' );
|
||||
exit;
|
||||
}
|
||||
if ( isset ( $_POST [ 'username' ] ) && isset ( $_POST [ 'password' ] ) ) {
|
||||
$username = $_POST [ 'username' ];
|
||||
$password = $_POST [ 'password' ];
|
||||
$db_connection = db_connect ( );
|
||||
$statement = db_prepare ( $db_connection, "SELECT users.id FROM users WHERE users.username = ? AND users.password = ?" );
|
||||
$database = new Database ( $config [ 'db' ] );
|
||||
$database->connect ( );
|
||||
$database->prepare ( "SELECT users.id FROM users WHERE users.username = ? AND users.password = ?" );
|
||||
$parameters = [
|
||||
[ "ss" ],
|
||||
[ &$username, &$password ],
|
||||
];
|
||||
db_bind ( $statement, $parameters );
|
||||
db_execute ( $statement );
|
||||
$result = $statement->get_result ( );
|
||||
$database->bind ( $parameters );
|
||||
$database->execute ( );
|
||||
$result = $database->get_result ( );
|
||||
$row = $result->fetch_assoc ( );
|
||||
if ( ! $row ) {
|
||||
header ( 'Content-Type: application/json' );
|
||||
@@ -27,6 +28,7 @@
|
||||
'error_message' => 'Username or password not correct.',
|
||||
];
|
||||
echo ( json_encode ( $response ) );
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$_SESSION [ 'user_id' ] = $row [ 'id' ];
|
||||
@@ -36,6 +38,7 @@
|
||||
'message' => 'Authentication succesfully executed.',
|
||||
];
|
||||
echo ( json_encode ( $response ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -44,46 +47,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>BJPHoster URL Shortener | Login</title>
|
||||
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
|
||||
<style>
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.login-container{
|
||||
margin-top: 5%;
|
||||
margin-bottom: 5%;
|
||||
margin-left: 30%;
|
||||
}
|
||||
.login-form-1{
|
||||
padding: 5%;
|
||||
box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.2), 0 9px 26px 0 rgba(0, 0, 0, 0.19);
|
||||
}
|
||||
.login-form-1 h3{
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
.login-container form{
|
||||
padding: 10%;
|
||||
}
|
||||
.btnSubmit
|
||||
{
|
||||
width: 50%;
|
||||
border-radius: 1rem;
|
||||
padding: 1.5%;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.login-form-1 .btnSubmit{
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
background-color: #0062cc;
|
||||
}
|
||||
.login-form-1 .ForgetPwd{
|
||||
color: #0062cc;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/lib/css/login.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container login-container">
|
||||
@@ -98,7 +63,7 @@
|
||||
<input type="password" class="form-control" placeholder="Password" value="" id="form-password" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="btnSubmit" value="Login" onclick="login()" />
|
||||
<input type="button" class="btnSubmit" value="Login" onclick="login()" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<a href="<?=substr($_SERVER[ 'SCRIPT_NAME' ],0,-10)."/login/forgot"?>" class="ForgetPwd">Forgot Password?</a>
|
||||
@@ -106,9 +71,8 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="responsetext"></div>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="js/sha512.min.js"></script>
|
||||
<script src="js/login.js"></script>
|
||||
<script>var script_name = "<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>";</script>
|
||||
|
Reference in New Issue
Block a user