initial commit

This commit is contained in:
2021-09-02 08:27:03 -03:00
commit 7a18b18c39
72 changed files with 3489 additions and 0 deletions

56
setup/index.php Normal file
View File

@ -0,0 +1,56 @@
<?php
if(session_status() !== PHP_SESSION_ACTIVE){
session_start();
}
if(!isset($_SESSION['setup']))
{
unset($_SESSION['setup']);
header('Location: index.php');
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/menu.css">
<link rel="stylesheet" href="../css/forms.css">
<link rel="stylesheet" href="../css/article.css">
<link rel="stylesheet" href="../css/input.css">
</head>
<body>
<nav id="menu">
<ul>
<li><a>CONFIGURAÇÃO INICIAL</a></li>
</ul>
</nav>
<article>
<section class='center'>
<h1>Usuário Administrador não existe.</h1>
<h4>Por favor, utilize o formulário abaixo para criar.</h4>
<hr>
<?php if(isset($_SESSION['msg'])){?>
<div class="msg">
<?php echo $_SESSION['msg'];
unset($_SESSION['msg']);?>
</div>
<?php }?>
<div style='margin: auto'>
<form action='setup.php' method='POST'>
<label for='username'>Usuário:</label><br>
<input type='text' name='username' placeholder="Ex.: Administrador" required><br>
<label for='password'>Senha:</label><br>
<input type='password' name='passwd' placeholder="Senha" required><br>
<label for='password'>E-Mail:</label><br>
<input type='email' name='email' placeholder="Ex.: exemplo@teste.com" required><br><br>
<table class='input'>
<td><input class='buttons' type='submit' name="entrar"></td>
<td><input class='buttons' type='reset'></td>
</table>
</form>
</div>
<hr>
</section>
</article>
</body>
</html>

39
setup/setup.php Normal file
View File

@ -0,0 +1,39 @@
<?php
if(session_status() !== PHP_SESSION_ACTIVE){
session_start();
}
include('../conexao_publica.php');
$usuario = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$senha = filter_input(INPUT_POST, 'passwd', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING);
$empty = 'vazio';
$nome = 'Administrador';
$tipo='adm';
$sql = "INSERT INTO tbclientes (nome, endereco, bairro, cidade, estado, email, cpf_cnpj, rg) VALUES (?,?,?,?,?,?,?,?)";
$stmt = $con->prepare($sql);
$stmt->bind_param('ssssssss',$nome,$empty,$empty,$empty,$empty,$email,$empty,$empty);
if($stmt->execute())
{
$id=$stmt->insert_id;
$stmt->close();
$sql = "INSERT INTO login_usuarios (login,senha,tipo,id_cliente) VALUES(?,?,?,?)";
$hashed = password_hash($senha,PASSWORD_DEFAULT);
$stmt = $con->prepare($sql);
$stmt->bind_param('ssss',$usuario,$hashed,$tipo,$id);
if($stmt->execute())
{
$_SESSION['msg'] = "Configurado com sucess, por favor faça o login!";
unset($_SESSION['setup']);
}
else{
$_SESSION['msg'] = "Erro no cadastro!";
}
$stmt->close();
header('Location: ../index.php');
}
?>