Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install.php #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static function conn()
/* MySQL VARIABLES */
$db_serv = 'localhost';
$db_user = 'root';
$db_pass = 'root';
$db_pass = '';
$db_name = 'kat_status';

if (!self::$conn) {
Expand Down
6 changes: 6 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
if (file_exists('install.php')) {
header('Location: /install.php');
}
?>
<?php 'SELECT * FROM `users`' ?>
<?php
$conf = file_get_contents('./config.json');
$CONFIG = json_decode($conf);
?>
Expand Down
76 changes: 76 additions & 0 deletions install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php include './backend/funcs.php'; ?>
<?php if (isset($_POST['signup']) && $_POST['username'] !== '' && $_POST['password'] !== '') {
$new_pass = password_hash($_POST['password'], CRYPT_BLOWFISH);
$db_conn = \funcs\Functions::conn();
$sql = "INSERT INTO `users` (username, password) VALUES (?, ?)";
$stmt = mysqli_prepare($db_conn, $sql);
$user_cleaned = \funcs\Functions::escape_string($_POST['username']);
$pass_cleaned = \funcs\Functions::escape_string($new_pass);
mysqli_stmt_bind_param($stmt, "ss", $user_cleaned, $pass_cleaned);
$res = \funcs\Functions::execute_stmt($stmt);
if (file_exists('install.php') && $res) {
$sql = 'SELECT * FROM `users`';
$stmt = mysqli_prepare($db_conn, $sql);
$res = \funcs\Functions::execute_stmt($stmt);
unlink('./install.php');
header('Location: /');
}
}
include './head.php';
?>
<body>
<style>
.btn {
background-image: -webkit-linear-gradient(top, #B7A35A 0%, #A69350 100%);
background-image: linear-gradient(-180deg, #B7A35A 0%, #A69350 100%);
box-shadow: 0px 1px 0px 0px #7D6F35;
border-radius: 2px;
border: none;
padding: 6px 20px 4px;
color: #FFFFFF;
white-space: nowrap;
font-size: .8em;
text-shadow: 0 1px 0 #8D7610;
margin: 0 !important;
line-height: 160%;
width: 100%;
}
input {
position: relative;
line-height: 20px;
z-index: 1;
box-sizing: border-box;
width: 100%;
font-size: 14px;
padding: 5px 60px 5px 8px;
color: #7c6a59;
margin: 0 !important;
border: none;
box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.2);
-webkit-appearance: none !important;
border-radius: 2px;
}
.content {
padding-top: 5%;
}
label {
text-align: left;
float: left;
font-weight: bold;
}
</style>
<?php include './header.php'; ?>
<div class="main-content">
<div class="content">
<section class="b-issue">
<h1>Sign Up</h1>

<form enctype="multipart/form-data" action="" method="post">
<label for="username">Username:</label> <input type="text" name="username"><br/><br/>
<label for="password">Password:</label> <input type="password" name="password"><br/><br/>
<button type="submit" name="signup" class="btn">Sign Up</button>
</form>
</section>
</div>
</div>
</body>
24 changes: 0 additions & 24 deletions login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@
echo 'Incorrect Password';
}
}
if (isset($_POST['signup']) && $_POST['username'] !== '' && $_POST['password'] !== '') {
$new_pass = password_hash($_POST['password'], CRYPT_BLOWFISH);
$sql = "INSERT INTO `users` (username, password) VALUES (?, ?)";
$stmt = mysqli_prepare($db_conn, $sql);

$user_cleaned = \funcs\Functions::escape_string($_POST['username']);
$pass_cleaned = \funcs\Functions::escape_string($new_pass);
mysqli_stmt_bind_param($stmt, "ss", $user_cleaned, $pass_cleaned);

$res = \funcs\Functions::execute_stmt($stmt);
$signedup = ($res) ? true : false;
}
?>
<style>
.btn {
Expand Down Expand Up @@ -105,18 +93,6 @@
</form>
</section>
<br/>
<section class="b-issue">
<h1>Sign Up</h1>

<form enctype="multipart/form-data" action="" method="post">
<label for="username">Username:</label> <input type="text" name="username"><br/><br/>
<label for="password">Password:</label> <input type="password" name="password"><br/><br/>
<button type="submit" name="signup" class="btn">Sign Up</button>
</form>
<div class="status">
<p><?php echo (isset($signedup)) ? 'Successfully signed up.' : 'Couldn\'t create account.'; ?><p>
</div>
</section>
</div>
</div>
</body>
Expand Down