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 6894e83 according to the output
from php-cs-fixer.

Details: https://deepsource.io/gh/davidbelfiori/JobInt/transform/2859ae3e-d2e5-4adf-8767-e22297fde08d/
  • Loading branch information
deepsource-autofix[bot] committed Mar 7, 2022
1 parent 6894e83 commit a68f41c
Show file tree
Hide file tree
Showing 20 changed files with 315 additions and 361 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');
}
?>
26 changes: 13 additions & 13 deletions page/dettagli.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
session_start();
include "../db/config.php";

if(isset($_GET['id'])){

if (isset($_GET['id'])) {
$idlavoratore=$_GET['id'];

$sql= "select * from user,user_image,curriculum,lavoratore,professione,indirizzo
Expand All @@ -14,19 +13,17 @@
and indirizzo.idlavoratore1=lavoratore.idlavoratore
and professione.idlavoratore1=lavoratore.idlavoratore";

$res = mysqli_query($conn,$sql);
$res = mysqli_query($conn, $sql);
$rescheck= mysqli_num_rows($res);

if($rescheck>0){
while ($row = mysqli_fetch_assoc($res)){
if(isset($_POST['view_pdf'])){
$file_name=$row['pdf_url'];

header("content-type: application/pdf");
readfile("uploads/curriculum/$file_name");
}
if ($rescheck>0) {
while ($row = mysqli_fetch_assoc($res)) {
if (isset($_POST['view_pdf'])) {
$file_name=$row['pdf_url'];

?>
header("content-type: application/pdf");
readfile("uploads/curriculum/$file_name");
} ?>
<div class="user-image" style="width: 200px;
height: 120px;">
<img src="uploads/userimage/<?=$row['image_url']?>" alt="" style=" width: 100%;
Expand All @@ -47,4 +44,7 @@
</form>

<a href="ricercaLavoratore.php">ricerca</a>
<?php }} }?>
<?php
}
}
}?>
17 changes: 6 additions & 11 deletions page/fetchdata.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
<?php

//fetchdata.php
if(isset($_POST["action"]))
{
if (isset($_POST["action"])) {
$conn = mysqli_connect("localhost", "root", "root", "jobint");
$output = '';
if($_POST["action"] == "Area_professionale")
{
if ($_POST["action"] == "Area_professionale") {
$query = "SELECT sotto_area FROM jobint.categoriaprofessionale WHERE area = '".$_POST["query"]."' GROUP BY sotto_area";
$result = mysqli_query($conn, $query);
$output .= '<option value="">Select Sotto area</option>';
while($row = mysqli_fetch_array($result))
{
while ($row = mysqli_fetch_array($result)) {
$output .= '<option value="'.$row["sotto_area"].'">'.$row["sotto_area"].'</option>';
}
}
if($_POST["action"] == "Sotto_area_professionale")
{
if ($_POST["action"] == "Sotto_area_professionale") {
$query = "SELECT categoria FROM jobint.categoriaprofessionale WHERE sotto_area= '".$_POST["query"]."'";
$result = mysqli_query($conn, $query);
$output .= '<option value="">Select categoria</option>';
while($row = mysqli_fetch_array($result))
{
while ($row = mysqli_fetch_array($result)) {
$output .= '<option value="'.$row["categoria"].'">'.$row["categoria"].'</option>';
}
}
echo $output;
}
?>
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
47 changes: 23 additions & 24 deletions page/help.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
<?php
include "validate_email.php";

if (isset($_POST['submit'])){

if (isset($_POST['submit'])) {
$username = $_POST['username'];
$email = $_POST['email'];
$subject=$_POST['subject'];
$problema=$_POST['problema'];



if(ValidateEmail($email)==='valid'){

$to="jobint.help@gmail.com";
if (ValidateEmail($email)==='valid') {
$to="jobint.help@gmail.com";

$headers="Form:".$email;
$message="Hai ricevuto una email da ".$username.".\n\n ".$problema;

if(isset($username) and isset($email) and isset($subject) and isset($problema)){
if(mail($to,$subject,$message,$headers)) {
$headers="Form:".$email;
$message="Hai ricevuto una email da ".$username.".\n\n ".$problema;

$subject = "Jobint Help";
$message = "Grazie per averci contattato" .$username.".\n\n La tua richiesta: ".$problema."\n\n Con i tuoi feedback rendiamo JobInt migliore";
$sender = "From: jobint.help@gmail.com ";
if(mail($email, $subject, $message, $sender)){
header("Location: index.php");
exit();}
}else{
echo "<script> alert('errore1')</script>";}
}else{
echo "<script> alert('si prega di compilare gli spazi vuoti')</script>";}
}else{
echo "<script> alert('email non valida'); </script>";
//header("Location: help.php");
if (isset($username) and isset($email) and isset($subject) and isset($problema)) {
if (mail($to, $subject, $message, $headers)) {
$subject = "Jobint Help";
$message = "Grazie per averci contattato" .$username.".\n\n La tua richiesta: ".$problema."\n\n Con i tuoi feedback rendiamo JobInt migliore";
$sender = "From: jobint.help@gmail.com ";
if (mail($email, $subject, $message, $sender)) {
header("Location: index.php");
exit();
}
} else {
echo "<script> alert('errore1')</script>";
}
} else {
echo "<script> alert('si prega di compilare gli spazi vuoti')</script>";
}
} else {
echo "<script> alert('email non valida'); </script>";
//header("Location: help.php");
}

}

?>
Expand Down
16 changes: 5 additions & 11 deletions page/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,31 @@

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



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


$sql1="select * from user where email='$email' AND password='$password'";
$result1=mysqli_query($conn,$sql1);
if($result1->num_rows>0){
$result1=mysqli_query($conn, $sql1);
if ($result1->num_rows>0) {
$row= mysqli_fetch_assoc($result1);
$code=$row['code'];
if($code!=0) {
if ($code!=0) {
$_SESSION['email']=$row['email'];
header("location: verificationcode.php");
exit;
}
//ricerca nel database delle credenziali con il confronto tra email e password inserite con quelle presenti nel db
$_SESSION['username'] = $row['username'];
$_SESSION['email']=$row['email'];
if($row['typeuser']=='lavoratore'){
if ($row['typeuser']=='lavoratore') {
header("location: welcomeLavoratoreHome.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

0 comments on commit a68f41c

Please sign in to comment.