Skip to content

Commit

Permalink
Fix security issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-wagner committed Aug 18, 2024
1 parent 0d73f20 commit f2850b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
26 changes: 14 additions & 12 deletions WebApp/functions_database.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,23 @@ public static function transaction_delete_all ()


//Delete group transaction
public static function transaction_delete_group ($TrDeleteArr)
{
$const_dbpath = costant::database_path();
$N = count($TrDeleteArr);
$SQLDelete = "";
for($i=0; $i < $N; $i++)
{$SQLDelete = $SQLDelete.$TrDeleteArr[$i] . ",";}
$SQLDelete = rtrim($SQLDelete, ",");
public static function transaction_delete_group($TrDeleteArr)
{
$const_dbpath = costant::database_path();
$N = count($TrDeleteArr);

$db = new PDO("sqlite:${const_dbpath}");
$db->exec ("DELETE FROM New_Transaction WHERE ID IN (${SQLDelete});");
// Create placeholders for each element in $TrDeleteArr
$placeholders = rtrim(str_repeat('?,', $N), ',');

$db = null;
}
// Prepare the SQL statement
$db = new PDO("sqlite:${const_dbpath}");
$stmt = $db->prepare("DELETE FROM New_Transaction WHERE ID IN (${placeholders})");

// Execute the statement with the array of IDs
$stmt->execute($TrDeleteArr);

$db = null;
}

// Update transaction
public static function transaction_update ($TrEditedId,$TrDate,$TrStatus,$TrType,$TrAccount,$TrToAccount,$TrPayee,$TrCategory,$TrSubCategory,$TrAmount,$TrNotes)
Expand Down
1 change: 1 addition & 0 deletions WebApp/functions_security.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static function redirect_if_not_loggedin ()
elseif ($_SERVER['PHP_SELF'] != "/index.php")
{
header("Location: index.php");
exit();
}
}
}
Expand Down

0 comments on commit f2850b2

Please sign in to comment.