BioTorrents.de’s version of Gazelle
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.

upload_handle.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. # Line 88
  3. $Properties['Screenshots'] = isset($_POST['screenshots']) ? $_POST['screenshots'] : '';
  4. $Properties['Mirrors'] = isset($_POST['mirrors']) ? $_POST['mirrors'] : '';
  5. # Line 89
  6. # Line 512
  7. if (!isset($GroupID) || !$GroupID) {
  8. // Create torrent group
  9. $DB->query(
  10. "
  11. INSERT INTO torrents_group
  12. (CategoryID, Name, NameRJ, NameJP, Year,
  13. Series, Studio, CatalogueNumber, Pages, Time,
  14. WikiBody, WikiImage, DLsiteID)
  15. VALUES
  16. ( ?, ?, ?, ?, ?,
  17. ?, ?, ?, ?, NOW(),
  18. ?, ?, ? )",
  19. $TypeID,
  20. $T['Title'],
  21. $T['TitleRJ'],
  22. $T['TitleJP'],
  23. $T['Year'],
  24. $T['Series'],
  25. $T['Studio'],
  26. $T['CatalogueNumber'],
  27. $T['Pages'],
  28. $Body,
  29. $T['Image'],
  30. $T['DLsiteID']
  31. );
  32. $GroupID = $DB->inserted_id();
  33. foreach ($ArtistForm as $Num => $Artist) {
  34. $DB->query("
  35. INSERT IGNORE INTO torrents_artists (GroupID, ArtistID, UserID)
  36. VALUES ( ?, ?, ? )", $GroupID, $Artist['id'], $LoggedUser['ID']);
  37. $Cache->increment('stats_album_count');
  38. $Cache->delete_value('artist_groups_'.$Artist['id']);
  39. }
  40. $Cache->increment('stats_group_count');
  41. // Add screenshots
  42. // todo: Clear DB_MYSQL::exec_prepared_query() errors
  43. $Screenshots = explode("\n", $T['Screenshots']);
  44. $Screenshots = array_map('trim', $Screenshots);
  45. $Screenshots = array_filter($Screenshots, function ($s) {
  46. return preg_match('/^'.DOI_REGEX.'$/i', $s);
  47. });
  48. $Screenshots = array_unique($Screenshots);
  49. $Screenshots = array_slice($Screenshots, 0, 10);
  50. # Add optional web seeds similar to screenshots
  51. # Support an arbitrary and limited number of sources
  52. $Mirrors = explode("\n", $T['Mirrors']);
  53. $Mirrors = array_map('trim', $Mirrors);
  54. $Mirrors = array_filter($Mirrors, function ($s) {
  55. return preg_match('/^'.URL_REGEX.'$/i', $s);
  56. });
  57. $Mirrors = array_unique($Mirrors);
  58. $Mirrors = array_slice($Mirrors, 0, 2);
  59. # Downgrade TLS on resource URIs
  60. # Required for BEP 19 compatibility
  61. $Mirrors = str_ireplace('tps://', 'tp://', $Mirrors);
  62. # Perform the DB inserts here
  63. # Screenshots (publications)
  64. if (!empty($Screenshots)) {
  65. $Screenshot = '';
  66. $DB->prepare_query("
  67. INSERT INTO torrents_screenshots
  68. (GroupID, UserID, Time, Image)
  69. VALUES (?, ?, NOW(), ?)", $GroupID, $LoggedUser['ID'], $Screenshot);
  70. foreach ($Screenshots as $Screenshot) {
  71. $DB->exec_prepared_query();
  72. }
  73. }
  74. # Mirrors
  75. if (!empty($Mirrors)) {
  76. $Mirror = '';
  77. $DB->prepare_query("
  78. INSERT INTO torrents_mirrors
  79. (GroupID, UserID, Time, Resource)
  80. VALUES (?, ?, NOW(), ?)", $GroupID, $LoggedUser['ID'], $Mirror);
  81. foreach ($Mirrors as $Mirror) {
  82. $DB->exec_prepared_query();
  83. }
  84. }
  85. # Main if/else
  86. } else {
  87. $DB->query("
  88. UPDATE torrents_group
  89. SET Time = NOW()
  90. WHERE ID = ?", $GroupID);
  91. $Cache->delete_value("torrent_group_$GroupID");
  92. $Cache->delete_value("torrents_details_$GroupID");
  93. $Cache->delete_value("detail_files_$GroupID");
  94. }
  95. # Line 609