ConfirmUploadAction.class.php 841 B

123456789101112131415161718192021222324
  1. <?php
  2. class ConfirmUploadAction implements IAction {
  3. public function execute() {
  4. if(!Authorize::isLoggedIn()) {
  5. return array("error" => "Access not authorized");
  6. }
  7. $projectId = $_POST['project_id'] ?? $_GET['project_id'];
  8. $filePath = $_POST['filepath'] ?? $_GET['filepath'];
  9. $userId = $_SESSION['user_id'];
  10. $database = SqliteDatabase::getSingleton();
  11. $sql = "DELETE FROM upload_logs WHERE project_id = :project_id AND user_id = :user_id AND filepath = :filepath LIMIT 1;";
  12. $preparedQuery = $database->prepare($sql);
  13. $preparedQuery->bindValue(':project_id', $projectId);
  14. $preparedQuery->bindValue(':user_id', $userId);
  15. $preparedQuery->bindValue(':filepath', $filePath);
  16. $result = $preparedQuery->execute();
  17. $result->finalize();
  18. return array("message" => "upload confirmed", "filepath" => $filePath);
  19. }
  20. }