Simple upload filter script for Article 13 of EU copyright reform
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

  1. <?php
  2. if (!isset($_GET['token'])) {
  3. echo 'No token specified!';
  4. die();
  5. }
  6. require_once('db.php');
  7. $token = $_GET['token'];
  8. $query = $db->prepare("SELECT fileId FROM validations WHERE token=:token LIMIT 1;");
  9. $query->execute(array(':token' => $token));
  10. $validation = $query->fetchAll(PDO::FETCH_ASSOC);
  11. if (!isset($validation[0])) {
  12. echo 'Invalid token specified!';
  13. die();
  14. }
  15. $query = $db->prepare("SELECT * FROM files WHERE id=:fileId LIMIT 1;");
  16. $query->execute(array(':fileId' => $validation[0]['fileId']));
  17. $file = $query->fetchAll(PDO::FETCH_ASSOC);
  18. $file = $file[0];
  19. if (isset($_GET['download'])) {
  20. header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
  21. header("Cache-Control: public");
  22. header("Content-Transfer-Encoding: Binary");
  23. header("Content-Length:".filesize($file['filePath']));
  24. header("Content-Disposition: attachment; filename=" . basename($file['filePath']));
  25. readfile($file['filePath']);
  26. die();
  27. } else if (isset($_GET['validate'])) {
  28. $query = $db->prepare("UPDATE validations SET validated = 1 WHERE token=:token LIMIT 1;");
  29. $query->execute(array(':token' => $token));
  30. } else if (isset($_GET['infringement'])) {
  31. $query = $db->prepare("UPDATE validations SET validated = 0 WHERE token=:token LIMIT 1;");
  32. $query->execute(array(':token' => $token));
  33. }
  34. ?>
  35. <a href="validate.php?token=<?php echo $token; ?>&download">Download File</a><br \>
  36. <a href="validate.php?token=<?php echo $token; ?>&validate">Mark File as validated</a> <br \>
  37. <a href="validate.php?token=<?php echo $token; ?>&infringement">Report copyright infringement</a>