Gestion download au travers de premiumizeme
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.

60 lines
1.6 KiB

5 years ago
5 years ago
5 years ago
1 year ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. function getStatus()
  3. {
  4. $listAdded = Download::listByState('added');
  5. $listDownloading = Download::listByState('downloading');
  6. $listDownloaded = Download::listByState('downloaded');
  7. $listDupp = Download::listByState('dupp');
  8. $streamFinished = Stream::listByState('finished');
  9. $streamBegin = Stream::listByState('begin');
  10. $infos = PremiumizeMe::getStatus();
  11. $tmpRestant = $infos['premium_until']->diff(new DateTime());
  12. $restant = '';
  13. if (0 !== $tmpRestant->m) {
  14. $restant .= $tmpRestant->m.' mois ';
  15. }
  16. if (0 !== $tmpRestant->d) {
  17. $restant .= $tmpRestant->d.' jours';
  18. }
  19. include __DIR__.'/../templates/status.php';
  20. }
  21. function cleanList()
  22. {
  23. header('Content-type: application/json');
  24. if (!isset($_GET['type']) || empty($_GET['type'])) {
  25. echo json_encode('pas de type, exit');
  26. exit();
  27. }
  28. if (!isset($_GET['state']) || empty($_GET['state'])) {
  29. echo json_encode('pas de state, exit');
  30. exit();
  31. }
  32. if ($_GET['type'] === 'download') {
  33. if (!in_array($_GET['state'], Download::$validStates)) {
  34. echo json_encode('mauvais state, exit');
  35. exit();
  36. }
  37. Download::clear($_GET['state']);
  38. echo json_encode('ok');
  39. } elseif ($_GET['type'] === 'stream') {
  40. if (!in_array($_GET['state'], Stream::$validStates)) {
  41. echo json_encode('mauvais state, exit');
  42. exit();
  43. }
  44. Stream::clear($_GET['state']);
  45. echo json_encode('ok');
  46. } else {
  47. echo json_encode('mauvais type, exit');
  48. exit();
  49. }
  50. }