Skip to content

Commit

Permalink
Format code with php-cs-fixer
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 8e18e36 according to the output
from php-cs-fixer.

Details: https://deepsource.io/gh/davidbelfiori/JobInt/transform/9d023590-97e7-4e8c-8f49-5ba0ae79a939/
  • Loading branch information
deepsource-autofix[bot] committed Feb 28, 2022
1 parent 8e18e36 commit 37cdc4b
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 230 deletions.
33 changes: 16 additions & 17 deletions page/controllerUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,79 +9,78 @@
$errors = array();

//if user click continue button in forgot password form
if(isset($_POST['check-email'])){
if (isset($_POST['check-email'])) {
$email = mysqli_real_escape_string($conn, $_POST['email']);
$check_email = "SELECT * FROM user WHERE email='$email'";
$run_sql = mysqli_query($conn, $check_email);
if(mysqli_num_rows($run_sql) > 0){
if (mysqli_num_rows($run_sql) > 0) {
$code = rand(999999, 111111);
$insert_code = "UPDATE user SET code = $code WHERE email = '$email'";
$run_query = mysqli_query($conn, $insert_code);
if($run_query){
if ($run_query) {
$subject = "Password Reset Code";
$message = "Your password reset code is $code";
$sender = "From: jobint.help@gmail.com ";
if(mail($email, $subject, $message, $sender)){
if (mail($email, $subject, $message, $sender)) {
$info = "We've sent a passwrod reset otp to your email - $email";
$_SESSION['info'] = $info;
$_SESSION['email'] = $email;
header('location: reset-code.php');
exit();
}else{
} else {
$errors['otp-error'] = "Failed while sending code!";
}
}else{
} else {
$errors['db-error'] = "Qualcosa è andato stotro!";
}
}else{
} else {
$errors['email'] = "Questa email non esiste!";
}
}

//if user click check reset otp button
if(isset($_POST['check-reset-otp'])){
if (isset($_POST['check-reset-otp'])) {
$_SESSION['info'] = "";
$otp_code = mysqli_real_escape_string($conn, $_POST['otp']);
$check_code = "SELECT * FROM user WHERE code = $otp_code";
$code_res = mysqli_query($conn, $check_code);
if(mysqli_num_rows($code_res) > 0){
if (mysqli_num_rows($code_res) > 0) {
$fetch_data = mysqli_fetch_assoc($code_res);
$email = $fetch_data['email'];
$_SESSION['email'] = $email;
$info = "Per favore crea una nuova password che non usi su nessun altro sito.";
$_SESSION['info'] = $info;
header('location: new-password.php');
exit();
}else{
} else {
$errors['otp-error'] = "Hai inserito un codice errato!";
}
}

//if user click change password button
if(isset($_POST['change-password'])){
if (isset($_POST['change-password'])) {
$_SESSION['info'] = "";
$password = mysqli_real_escape_string($conn, $_POST['password']);
$cpassword = mysqli_real_escape_string($conn, $_POST['cpassword']);
if($password !== $cpassword){
if ($password !== $cpassword) {
$errors['password'] = "Le password non corrispondono!";
}else{
} else {
$code = 0;
$email = $_SESSION['email']; //getting this email using session
$encpass = md5($password);
$update_pass = "UPDATE user SET code = $code, password = '$encpass' WHERE email = '$email'";
$run_query = mysqli_query($conn, $update_pass);
if($run_query){
if ($run_query) {
$info = "La tua password è cambiata. Ora puoi accedere con la tua nuova password.";
$_SESSION['info'] = $info;
header('Location: password-changed.php');
}else{
} else {
$errors['db-error'] = "Impossibile modificare la password!";
}
}
}

//if login now button click
if(isset($_POST['login-now'])){
if (isset($_POST['login-now'])) {
header('Location: index.php');
}
?>
7 changes: 3 additions & 4 deletions page/forgot-password.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
<h2 class="text-center">Hai dimenticato la Password</h2>
<p class="text-center">Inserisci il tuo indirizzo mail</p>
<?php
if(count($errors) > 0){
if (count($errors) > 0) {
?>
<div class="alert alert-danger text-center">
<?php
foreach($errors as $error){
foreach ($errors as $error) {
echo $error;
}
?>
} ?>
</div>
<?php
}
Expand Down
13 changes: 2 additions & 11 deletions page/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

//controllo delle credenziali email e password
if (isset($_POST['submit'])) {

$email = $_POST['email'];
$password = md5($_POST['password']);

Expand All @@ -24,19 +23,11 @@
$row = mysqli_fetch_assoc($result);
$_SESSION['username'] = $row['username'];
$_SESSION['email']=$row['email'];
if($row['typeuser']=='lavoratore'){




if ($row['typeuser']=='lavoratore') {
header("location: welcomeLavoratore.php");

}else{
} else {
header("Location: welcomeAzienda.php");
}



} else {
echo "<script>alert('Woops! Email or Password is Wrong.')</script>";
}
Expand Down
2 changes: 0 additions & 2 deletions page/logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
session_destroy();

header("Location: index.php");

?>
11 changes: 5 additions & 6 deletions page/new-password.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php require_once "controllerUserData.php"; ?>
<?php
$email = $_SESSION['email'];
if($email == false){
if ($email == false) {
header('Location: index.php');
}
?>
Expand All @@ -20,7 +20,7 @@
<form action="new-password.php" method="POST" autocomplete="off">
<h2 class="text-center">New Password</h2>
<?php
if(isset($_SESSION['info'])){
if (isset($_SESSION['info'])) {
?>
<div class="alert alert-success text-center">
<?php echo $_SESSION['info']; ?>
Expand All @@ -29,14 +29,13 @@
}
?>
<?php
if(count($errors) > 0){
if (count($errors) > 0) {
?>
<div class="alert alert-danger text-center">
<?php
foreach($errors as $showerror){
foreach ($errors as $showerror) {
echo $showerror;
}
?>
} ?>
</div>
<?php
}
Expand Down
4 changes: 2 additions & 2 deletions page/password-changed.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php require_once "controllerUserData.php"; ?>
<?php
if($_SESSION['info'] == false){
if ($_SESSION['info'] == false) {
header('Location: index.php');
}
?>
Expand All @@ -17,7 +17,7 @@
<div class="row">
<div class="col-md-4 offset-md-4 form login-form">
<?php
if(isset($_SESSION['info'])){
if (isset($_SESSION['info'])) {
?>
<div class="alert alert-success text-center">
<?php echo $_SESSION['info']; ?>
Expand Down
12 changes: 4 additions & 8 deletions page/reg1UA.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@

session_start();

if (isset($_POST['submit'])){
foreach ($_POST as $key =>$value){
if (isset($_POST['submit'])) {
foreach ($_POST as $key =>$value) {
$_SESSION['info'][$key]=$value;
}

$keys= array_keys($_SESSION['info']);

if(in_array('submit',$keys)){
if (in_array('submit', $keys)) {
unset($_SESSION['info']['submit']);
}
header("Location: reg2Azienda.php" );




header("Location: reg2Azienda.php");
}

?>
Expand Down
81 changes: 40 additions & 41 deletions page/reg2Azienda.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,61 @@



if(isset($_SESSION['info'])){
if (isset($_SESSION['info'])) {
extract($_SESSION['info']);



if (isset($_POST['submit'])) {
//inserimento delle variabili
if (isset($_POST['submit'])) {
//inserimento delle variabili

$pw=md5($password);
$cpw=md5($cpassword);
$nomeAzienda=$_POST['nomeAzienda'];
$nsedi=$_POST['nsedi'];
$settore=$_POST['settore'];
$ndipendenti=$_POST['ndipendenti'];
$luogosedi=$_POST['luogosedi'];
$codiceAteco=$_POST['codiceAteco'];
$pw=md5($password);
$cpw=md5($cpassword);
$nomeAzienda=$_POST['nomeAzienda'];
$nsedi=$_POST['nsedi'];
$settore=$_POST['settore'];
$ndipendenti=$_POST['ndipendenti'];
$luogosedi=$_POST['luogosedi'];
$codiceAteco=$_POST['codiceAteco'];

//confronto delle password(pw,cpw)
//confronto delle password(pw,cpw)

if($password == $cpassword){

$sql = "SELECT * FROM jobint.user WHERE email='$email' and username='$username'" ;
$result = mysqli_query($conn, $sql);
if(!$result->num_rows > 0){
$sql = "
insert into jobint.user (email, password, typeuser, username) values ('$email','$pw','azienda','$username');";
if ($password == $cpassword) {
$sql = "SELECT * FROM jobint.user WHERE email='$email' and username='$username'" ;
$result = mysqli_query($conn, $sql);
if (!$result->num_rows > 0) {
$sql = "
insert into jobint.user (email, password, typeuser, username) values ('$email','$pw','azienda','$username');";
$result = mysqli_query($conn, $sql);

$sql="select * from jobint.azienda where nomeAzienda='$nomeAzienda'";
$result= mysqli_query($conn,$sql);
if(!$result->num_rows >0){


$sql2 = "insert into jobint.azienda (nomeAzienda, numeroSedi, numeroDipendenti, luogoSedi, idUser1)
$sql="select * from jobint.azienda where nomeAzienda='$nomeAzienda'";
$result= mysqli_query($conn, $sql);
if (!$result->num_rows >0) {
$sql2 = "insert into jobint.azienda (nomeAzienda, numeroSedi, numeroDipendenti, luogoSedi, idUser1)
values ('$nomeAzienda', '$nsedi' , '$ndipendenti' ,'$luogosedi',(select iduser from user where email='$email'));";
$sql3 = "insert into jobint.ateco (idCodiceATECO,codiceATECO, settore)
$sql3 = "insert into jobint.ateco (idCodiceATECO,codiceATECO, settore)
values ((select idAzienda from azienda where nomeAzienda='$nomeAzienda'),'$codiceAteco','$settore');";

$result2 = mysqli_query($conn, $sql2);
$result3 = mysqli_query($conn, $sql3);
if ($result and $result2 and $result3) {
echo "<script> alert('registrazione completata')</script>";
header("location: index.php");
exit;
$result2 = mysqli_query($conn, $sql2);
$result3 = mysqli_query($conn, $sql3);
if ($result and $result2 and $result3) {
echo "<script> alert('registrazione completata')</script>";
header("location: index.php");
exit;
} else {
echo mysqli_error($conn);
echo "<script>alert('Qualcosa è andato storto.')</script>";
}
} else {
echo "<script>alert('Email o username non disponibile.')</script>";
}
} else {
echo mysqli_error($conn);
echo "<script>alert('Qualcosa è andato storto.')</script>";
echo "<script>alert('Email o username non disponibile.')</script>";
}

} else {
echo "<script>alert('Email o username non disponibile.')</script>";}

}else{ echo "<script>alert('Email o username non disponibile.')</script>"; }
}else{
echo"<script> alert('le password non corrispondono')</script>";}
}
echo"<script> alert('le password non corrispondono')</script>";
}
}
}


Expand Down
12 changes: 4 additions & 8 deletions page/regUserLavoratore.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@

session_start();

if (isset($_POST['submit'])){
foreach ($_POST as $key =>$value){
if (isset($_POST['submit'])) {
foreach ($_POST as $key =>$value) {
$_SESSION['info'][$key]=$value;
}

$keys= array_keys($_SESSION['info']);

if(in_array('submit',$keys)){
if (in_array('submit', $keys)) {
unset($_SESSION['info']['submit']);
}
header("Location:regUserLavoratore2.php" );




header("Location:regUserLavoratore2.php");
}

?>
Expand Down

0 comments on commit 37cdc4b

Please sign in to comment.