Skip to content

Commit

Permalink
style: format code with PHP CS Fixer, Prettier and StandardJS
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in fbfdc45 according to the output
from PHP CS Fixer, Prettier and StandardJS.

Details: None
  • Loading branch information
deepsource-autofix[bot] committed Nov 17, 2023
1 parent fbfdc45 commit 886981f
Show file tree
Hide file tree
Showing 42 changed files with 1,712 additions and 1,709 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# JobInt

progetto di maturità del gruppo: David Julian Belfiori, Andrea ebano,Cristi Anitoi,Farietti Niccolò

In teoria ancora online su: jobint.altervista.org
75 changes: 24 additions & 51 deletions db/database_connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,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'];
}
}
Expand All @@ -22,10 +22,9 @@ function fetch_user_last_activity($user_id, $conn)
function get_user_name($user_id, $conn)
{
$query = "SELECT username FROM user WHERE iduser = '$user_id'";
$result=mysqli_query($conn,$query);
$result = mysqli_query($conn, $query);

while($row=mysqli_fetch_assoc($result))
{
while($row = mysqli_fetch_assoc($result)) {
return $row['username'];
}
}
Expand All @@ -43,38 +42,28 @@ function fetch_user_chat_history($from_user_id, $to_user_id, $conn)
AND to_user_id = '".$from_user_id."')
ORDER BY timestamp DESC
";
$result=mysqli_query($conn,$query);
$result = mysqli_query($conn, $query);

$output = '<ul class="list-unstyled">';
while($row =mysqli_fetch_assoc($result))
{
while($row = mysqli_fetch_assoc($result)) {
$user_name = '';
$dynamic_background = '';
$chat_message = '';
if($row["from_user_id"] == $from_user_id)
{
if($row["status"] == '2')
{
if($row["from_user_id"] == $from_user_id) {
if($row["status"] == '2') {
$chat_message = '<em>This message has been removed</em>';
$user_name = '<b class="text-success">You</b>';
}
else
{
} else {
$chat_message = $row['chat_message'];
$user_name = '<button type="button" class="btn btn-danger btn-xs remove_chat" id="'.$row['chat_message_id'].'">x</button>&nbsp;<b class="text-success">You</b>';
}


$dynamic_background = 'background-color:#ffe6e6;';
}
else
{
if($row["status"] == '2')
{
} else {
if($row["status"] == '2') {
$chat_message = '<em>This message has been removed</em>';
}
else
{
} else {
$chat_message = $row["chat_message"];
}
$user_name = '<b class="text-danger">'.get_user_name($row['from_user_id'], $conn).'</b>';
Expand Down Expand Up @@ -120,34 +109,24 @@ function fetch_group_chat_history($conn)
$result = $statement->fetchAll();

$output = '<ul class="list-unstyled">';
foreach($result as $row)
{
foreach($result as $row) {
$user_name = '';
$dynamic_background = '';
$chat_message = '';
if($row["from_user_id"] == $_SESSION["user_id"])
{
if($row["status"] == '2')
{
if($row["from_user_id"] == $_SESSION["user_id"]) {
if($row["status"] == '2') {
$chat_message = '<em>This message has been removed</em>';
$user_name = '<b class="text-success">You</b>';
}
else
{
} else {
$chat_message = $row["chat_message"];
$user_name = '<button type="button" class="btn btn-danger btn-xs remove_chat" id="'.$row['chat_message_id'].'">x</button>&nbsp;<b class="text-success">You</b>';
}

$dynamic_background = 'background-color:#ffe6e6;';
}
else
{
if($row["status"] == '2')
{
} else {
if($row["status"] == '2') {
$chat_message = '<em>This message has been removed</em>';
}
else
{
} else {
$chat_message = $row["chat_message"];
}
$user_name = '<b class="text-danger">'.get_user_name($row['from_user_id'], $conn).'</b>';
Expand Down Expand Up @@ -178,11 +157,10 @@ function count_unseen_message($from_user_id, $to_user_id, $conn)
AND status = '1'
";

$statement= mysqli_query($conn, $query);
$statement = mysqli_query($conn, $query);
$count = mysqli_num_rows($statement);
$output = '';
if($count > 0)
{
if($count > 0) {
$output = '<span class="label label-success">'.$count.'</span>';
}
return $output;
Expand All @@ -199,18 +177,13 @@ function fetch_is_type_status($user_id, $conn)
";


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

$output = '';
while($row=mysqli_fetch_assoc($statement))
{
if($row["is_type"] == 'yes')
{
while($row = mysqli_fetch_assoc($statement)) {
if($row["is_type"] == 'yes') {
$output = ' - <small><em><span class="text-muted">Typing...</span></em></small>';
}
}
return $output;
}


?>
10 changes: 5 additions & 5 deletions page/Unlike.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
include "../db/config.php";
session_start();

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

header("Location: welcomeAzienda.php");

Expand Down
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');
}
?>

0 comments on commit 886981f

Please sign in to comment.