Skip to content

Commit

Permalink
Format code with prettier, standardjs and php-cs-fixer
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 7d1465b according to the output
from prettier, standardjs and php-cs-fixer.

Details: https://deepsource.io/gh/davidbelfiori/JobInt/transform/fe607716-9286-4379-9747-477ef971bae0/
  • Loading branch information
deepsource-autofix[bot] committed May 7, 2022
1 parent 7d1465b commit 5ce7535
Show file tree
Hide file tree
Showing 26 changed files with 388 additions and 452 deletions.
5 changes: 2 additions & 3 deletions db/database_connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ function fetch_user_last_activity($user_id, $conn)
ORDER BY last_activity DESC
LIMIT 1
";
$result= mysqli_query($conn,$query);
while($row = mysqli_fetch_assoc($result)){
$result= mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
return $row['last_activity'];
}
}
?>
7 changes: 3 additions & 4 deletions page/Unlike.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

include "../db/config.php";

if(isset($_GET['id'])){
if (isset($_GET['id'])) {
$idLavoratore=$_GET['id'];
$sql_query="delete from `like` where idLavoratore='$idLavoratore'";
$result = mysqli_query($conn,$sql_query);
$result = mysqli_query($conn, $sql_query);

header("Location: likeProfili.php");

}
?>
2 changes: 1 addition & 1 deletion page/chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
include("../db/config.php");
session_start();

if(!isset($_SESSION['user_id'])){
if (!isset($_SESSION['user_id'])) {
header("location: index.php");
}
?>
Expand Down
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: noreply.jobint@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');
}
?>
92 changes: 43 additions & 49 deletions page/dettagli.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
$username = $_SESSION['username'];
$email= $_SESSION['email'];

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

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

$sql= "select * from user,user_image,curriculum,lavoratore,professione,indirizzo
Expand All @@ -16,57 +15,49 @@
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'];

if(isset($_POST['like'])){
header("content-type: application/pdf");
readfile("uploads/curriculum/$file_name");
}

$sql= "select * from user,azienda,ateco
if (isset($_POST['like'])) {
$sql= "select * from user,azienda,ateco
where user.iduser=azienda.idUser1 and ateco.idCodiceATECO=azienda.idAzienda and username='$username' and email='$email'";
$result = mysqli_query($conn, $sql);
while($row1 = mysqli_fetch_array($result))
{




$idAzienda=$row1['idAzienda'];

$lavoratorenome=$row['nome'];
$lavoratorecognome=$row['cognome'];
$nomeAzienda=$row1['nome'];
$settore=$row1['settore'];
$emaillavoratore=$row['email'];

$sql3="select * from `like` where idAzienda='$idAzienda' and idLavoratore='$idlavoratore'";
$result=mysqli_query($conn,$sql3);
if($result->num_rows>0){
echo "like gia messo";
header('location: ricercaLavoratore.php');


}else{$sql2="insert into `like` (idAzienda, idLavoratore) VALUES ('$idAzienda','$idlavoratore')";
$res1=mysqli_query($conn,$sql2);

$subject = "Interessi ad una azienda!";
$message = "Ciao Lavoratore: $lavoratorenome $lavoratorecognome \n l'azienda $nomeAzienda che lavora nel settore $settore ha manifestato il suo interesse per te. \n Buona fortuna dal team JobInt";
$sender = "From: noreply.jobint@gmail.com";
if(!mail($emaillavoratore, $subject, $message, $sender)){
echo "<script>alert('Failed while sending email!')</script>";
}}}

}

?>
$result = mysqli_query($conn, $sql);
while ($row1 = mysqli_fetch_array($result)) {
$idAzienda=$row1['idAzienda'];

$lavoratorenome=$row['nome'];
$lavoratorecognome=$row['cognome'];
$nomeAzienda=$row1['nome'];
$settore=$row1['settore'];
$emaillavoratore=$row['email'];

$sql3="select * from `like` where idAzienda='$idAzienda' and idLavoratore='$idlavoratore'";
$result=mysqli_query($conn, $sql3);
if ($result->num_rows>0) {
echo "like gia messo";
header('location: ricercaLavoratore.php');
} else {
$sql2="insert into `like` (idAzienda, idLavoratore) VALUES ('$idAzienda','$idlavoratore')";
$res1=mysqli_query($conn, $sql2);

$subject = "Interessi ad una azienda!";
$message = "Ciao Lavoratore: $lavoratorenome $lavoratorecognome \n l'azienda $nomeAzienda che lavora nel settore $settore ha manifestato il suo interesse per te. \n Buona fortuna dal team JobInt";
$sender = "From: noreply.jobint@gmail.com";
if (!mail($emaillavoratore, $subject, $message, $sender)) {
echo "<script>alert('Failed while sending email!')</script>";
}
}
}
} ?>
<div class="user-image" style="width: 200px;
height: 120px;">
<img src="uploads/userimage/<?=$row['image_url']?>" alt="" style=" width: 100%;
Expand Down Expand Up @@ -100,4 +91,7 @@



<?php }} }?>
<?php
}
}
}?>
24 changes: 8 additions & 16 deletions page/fetch_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
session_start();


$res1= mysqli_query($conn,"select * from user where iduser='".$_SESSION['user_id']."'");
$res1= mysqli_query($conn, "select * from user where iduser='".$_SESSION['user_id']."'");
$row=mysqli_fetch_assoc($res1);
if($row['typeuser']=='azienda'){
if ($row['typeuser']=='azienda') {
$query = "
SELECT * FROM `like`,lavoratore,user
WHERE lavoratore.idlavoratore=`like`.idLavoratore and iduser = lavoratore.idUser1 and `like`.idAzienda = '".$_SESSION['idAzienda']."'
";
}else{

$query="
} else {
$query="
select *
from `like`,azienda,user
where `like`.idAzienda=azienda.idAzienda and iduser=azienda.idUser1 and idLavoratore='".$_SESSION['idlavoratore']."' ;";
}


$result= mysqli_query($conn,$query);
$result= mysqli_query($conn, $query);


$output = '
Expand All @@ -37,19 +36,14 @@



while($row=mysqli_fetch_assoc($result)){


while ($row=mysqli_fetch_assoc($result)) {
$status = '';
$current_timestamp = strtotime(date("Y-m-d H:i:s") . '- 10 second');
$current_timestamp = date('Y-m-d H:i:s', $current_timestamp);
$user_last_activity = fetch_user_last_activity($row['iduser'], $conn);
if($user_last_activity > $current_timestamp)
{
if ($user_last_activity > $current_timestamp) {
$status = '<span class="label label-success">Online</span>';
}
else
{
} else {
$status = '<span class="label label-danger">Offline</span>';
}

Expand All @@ -60,9 +54,7 @@
<td><button type="button" class="btn btn-info btn-xs start_chat" data-touserid="'.$row['iduser'].'" data-tousername="'.$row['nome'].'">Start Chat</button></td>
</tr>
';

}

$output .= '</table>';
echo $output;
?>
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

0 comments on commit 5ce7535

Please sign in to comment.