Browse Source

Allow anonymous uploads

Also hide some who-did-this information from normal users

Requires database change
Invalidates caches
spaghetti 4 years ago
parent
commit
e5f97629bb

+ 1
- 5
classes/revisionhistory.class.php View File

@@ -7,11 +7,7 @@ class RevisionHistory {
7 7
    * @return array
8 8
    */
9 9
   public static function get_revision_history($Page, $PageID) {
10
-    if ($Page == 'artists') {
11
-      $Table = 'wiki_artists';
12
-    } else {
13
-      $Table = 'wiki_torrents';
14
-    }
10
+    $Table = ($Page == 'artists') ? 'wiki_artists' : 'wiki_torrents';
15 11
     $QueryID = G::$DB->get_query_id();
16 12
     G::$DB->query("
17 13
       SELECT

+ 4
- 0
classes/revisionhistoryview.class.php View File

@@ -11,7 +11,9 @@ class RevisionHistoryView {
11 11
     <tr class="colhead">
12 12
       <td>Revision</td>
13 13
       <td>Date</td>
14
+<? if (check_perms('users_mod')) { ?>
14 15
       <td>User</td>
16
+<? } ?>
15 17
       <td>Summary</td>
16 18
     </tr>
17 19
 <?
@@ -25,9 +27,11 @@ class RevisionHistoryView {
25 27
       <td>
26 28
         <?=$Time?>
27 29
       </td>
30
+<? if (check_perms('users_mod')) { ?>
28 31
       <td>
29 32
         <?=Users::format_username($UserID, false, false, false)?>
30 33
       </td>
34
+<? } ?>
31 35
       <td>
32 36
         <?=($Summary ? $Summary : '(empty)')?>
33 37
       </td>

+ 4
- 0
classes/torrent_form.class.php View File

@@ -184,6 +184,10 @@ Source: <input type="text" value="<?=Users::get_upload_sources()[0]?>" size="20"
184 184
       }
185 185
     }
186 186
 ?>
187
+      <tr>
188
+        <td class="label tooltip" title="Checking this will hide your username from other users on the torrent details page. Stats will still be attributed to you.">Upload Anonymously:</td>
189
+        <td><input type="checkbox" name="anonymous" value="1" <?=(($Torrent['Anonymous'] ?? false) ? 'checked ' : '')?>/></td>
190
+      </tr>
187 191
       <tr>
188 192
         <td colspan="2" style="text-align: center;">
189 193
           <p>Be sure that your torrent is approved by the <a href="rules.php?p=upload" target="_blank">rules</a>. Not doing this will result in a <strong class="important_text">warning</strong> or <strong class="important_text">worse</strong>.</p>

+ 1
- 0
gazelle.sql View File

@@ -1083,6 +1083,7 @@ CREATE TABLE `torrents` (
1083 1083
   `Subbing` varchar(10) DEFAULT NULL,
1084 1084
   `Language` varchar(20) DEFAULT NULL,
1085 1085
   `Censored` tinyint(1) NOT NULL DEFAULT '1',
1086
+  `Anonymous` tinyint(1) NOT NULL DEFAULT '0',
1086 1087
   `info_hash` blob NOT NULL,
1087 1088
   `FileCount` int(6) NOT NULL,
1088 1089
   `FileList` mediumtext,

+ 2
- 2
sections/ajax/torrent.php View File

@@ -103,8 +103,8 @@ $JsonTorrentList[] = [
103 103
   'mediaInfo'   => $Torrent['MediaInfo'],
104 104
   'fileList'    => $FileList,
105 105
   'filePath'    => $Torrent['FilePath'],
106
-  'userId'      => (int)$Torrent['UserID'],
107
-  'username'    => $Userinfo['Username']
106
+  'userId'      => (int)($Torrent['Anonymous'] ? 0 : $Torrent['UserID']),
107
+  'username'    => ($Torrent['Anonymous'] ? 'Anonymous' : $Userinfo['Username'])
108 108
 ];
109 109
 
110 110
 json_die("success", ['group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList)]);

+ 2
- 2
sections/ajax/torrentgroup.php View File

@@ -97,8 +97,8 @@ foreach ($TorrentList as $Torrent) {
97 97
     'mediaInfo'   => $Torrent['MediaInfo'],
98 98
     'fileList'    => $FileList,
99 99
     'filePath'    => $Torrent['FilePath'],
100
-    'userId'      => (int)$Torrent['UserID'],
101
-    'username'    => $Userinfo['Username']
100
+    'userId'      => (int)($Torrent['Anonymous'] ? 0 : $Torrent['UserID']),
101
+    'username'    => ($Torrent['Anonymous'] ? 'Anonymous' : $Userinfo['Username'])
102 102
   ];
103 103
 }
104 104
 

+ 8
- 4
sections/torrents/details.php View File

@@ -364,7 +364,7 @@ function filelist($Str) {
364 364
 
365 365
 foreach ($TorrentList as $Torrent) {
366 366
   list($TorrentID, $Media, $Container, $Codec, $Resolution, $AudioFormat, $Subbing,
367
-    $Subber, $Language, $Censored, $Archive, $FileCount, $Size, $Seeders, $Leechers,
367
+    $Subber, $Language, $Censored, $Anonymous, $Archive, $FileCount, $Size, $Seeders, $Leechers,
368 368
     $Snatched, $FreeTorrent, $FreeLeechType, $TorrentTime, $Description, $MediaInfo, $FileList,
369 369
     $FilePath, $UserID, $LastActive, $InfoHash, $BadTags, $BadFolders, $BadFiles,
370 370
     $LastReseedRequest, $LogInDB, $HasFile, $PersonalFL, $IsSnatched, $IsSeeding, $IsLeeching
@@ -541,7 +541,7 @@ foreach ($TorrentList as $Torrent) {
541 541
         <td colspan="5">
542 542
           <div id="release_<?=$TorrentID?>" class="no_overflow">
543 543
             <blockquote>
544
-              Uploaded by <?=Users::format_username($UserID, false, false, false)?> <?=time_diff($TorrentTime);?>
544
+              Uploaded by <?=($Anonymous ? 'Anonymous' : Users::format_username($UserID, false, false, false))?> <?=time_diff($TorrentTime);?>
545 545
 <?  if ($Seeders == 0) {
546 546
     if ($LastActive && time() - strtotime($LastActive) >= 1209600) { ?>
547 547
             <br /><strong>Last active: <?=time_diff($LastActive); ?></strong>
@@ -775,8 +775,12 @@ if (count($PersonalCollages) > 0) {
775 775
       <div class="body torrent_screenshots hidden">
776 776
 <?
777 777
     foreach($Screenshots as $Screenshot) {
778
-      $SSURL = ImageTools::process($Screenshot['Image'], false)
779
-      ?><img class='tooltip lightbox-init' title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' src="<?=$SSURL?>" /><?
778
+      $SSURL = ImageTools::process($Screenshot['Image'], false);
779
+      if (check_perms('users_mod')) {
780
+        ?><img class='tooltip lightbox-init' title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' src="<?=$SSURL?>" /><?
781
+      } else {
782
+        ?><img class='tooltip lightbox-init' title='Added <?=time_diff($Screenshot['Time'])?>' src="<?=$SSURL?>" /><?
783
+      }
780 784
     }
781 785
 ?>
782 786
       </div>

+ 24
- 24
sections/torrents/edit.php View File

@@ -26,6 +26,7 @@ $DB->query("
26 26
     t.Language,
27 27
     t.Subber,
28 28
     t.Censored,
29
+    t.Anonymous,
29 30
     t.Archive,
30 31
     t.FreeTorrent,
31 32
     t.FreeLeechType,
@@ -66,32 +67,31 @@ if (($LoggedUser['ID'] != $Properties['UserID'] && !check_perms('torrents_edit')
66 67
 
67 68
 View::show_header('Edit torrent', 'upload,torrent');
68 69
 
69
-if (!($Properties['Remastered'] && !$Properties['RemasterYear']) || check_perms('edit_unknowns')) {
70
-  $TorrentForm = new TORRENT_FORM($Properties, $Err, false);
70
+$TorrentForm = new TORRENT_FORM($Properties, $Err, false);
71 71
 
72
-  $TorrentForm->head();
73
-  switch ($UploadForm) {
74
-    case 'Movies':
75
-      $TorrentForm->movies_form('');
76
-      break;
77
-    case 'Anime':
78
-      $TorrentForm->anime_form('');
79
-      break;
80
-    case 'Manga':
81
-      $TorrentForm->manga_form('');
82
-      break;
83
-    case 'Games':
84
-      $TorrentForm->game_form('');
85
-      break;
86
-    case 'Other':
87
-      $TorrentForm->simple_form();
88
-      break;
89
-    default:
90
-      $TorrentForm->movies_form('');
91
-  }
92
-  $TorrentForm->foot();
72
+$TorrentForm->head();
73
+switch ($UploadForm) {
74
+  case 'Movies':
75
+    $TorrentForm->movies_form('');
76
+    break;
77
+  case 'Anime':
78
+    $TorrentForm->anime_form('');
79
+    break;
80
+  case 'Manga':
81
+    $TorrentForm->manga_form('');
82
+    break;
83
+  case 'Games':
84
+    $TorrentForm->game_form('');
85
+    break;
86
+  case 'Other':
87
+    $TorrentForm->simple_form();
88
+    break;
89
+  default:
90
+    $TorrentForm->movies_form('');
93 91
 }
94
-if (check_perms('torrents_edit') && (check_perms('users_mod') || $Properties['CategoryID'] == 1)) {
92
+$TorrentForm->foot();
93
+
94
+if (check_perms('torrents_edit') || check_perms('users_mod')) {
95 95
 ?>
96 96
 <div class="thin">
97 97
 <?

+ 1
- 0
sections/torrents/functions.php View File

@@ -79,6 +79,7 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
79 79
         t.Subber,
80 80
         t.Language,
81 81
         t.Censored,
82
+        t.Anonymous,
82 83
         t.Archive,
83 84
         t.FileCount,
84 85
         t.Size,

+ 10
- 4
sections/torrents/grouplog.php View File

@@ -6,10 +6,10 @@ if (!is_number($GroupID)) {
6 6
 
7 7
 View::show_header("History for Group $GroupID");
8 8
 
9
-$Groups = Torrents::get_groups(array($GroupID), true, true, false);
9
+$Groups = Torrents::get_groups([$GroupID], true, true, false);
10 10
 if (!empty($Groups[$GroupID])) {
11 11
   $Group = $Groups[$GroupID];
12
-  $Title = Artists::display_artists($Group['ExtendedArtists']).'<a href="torrents.php?id='.$GroupID.'">'.$Group['Name'].'</a>';
12
+  $Title = Artists::display_artists($Group['ExtendedArtists']).'<a href="torrents.php?id='.$GroupID.'">'.($Group['Name'] ? $Group['Name'] : ($Group['NameRJ'] ? $Group['NameRJ']: $Group['NameJP'])).'</a>';
13 13
 } else {
14 14
   $Title = "Group $GroupID";
15 15
 }
@@ -28,6 +28,7 @@ if (!empty($Groups[$GroupID])) {
28 28
       <td>Info</td>
29 29
     </tr>
30 30
 <?
31
+  $AnonTorrents = [];
31 32
   $Log = $DB->query("
32 33
       SELECT TorrentID, UserID, Info, Time
33 34
       FROM group_log
@@ -36,6 +37,11 @@ if (!empty($Groups[$GroupID])) {
36 37
   $LogEntries = $DB->to_array(false, MYSQLI_NUM);
37 38
   foreach ($LogEntries AS $LogEntry) {
38 39
     list($TorrentID, $UserID, $Info, $Time) = $LogEntry;
40
+    if (!isset($AnonTorrents[$TorrentID])) {
41
+      $DB->query("SELECT UserID, Anonymous FROM torrents WHERE ID=$TorrentID");
42
+      list($AnonUser, $IsAnon) = $DB->next_record();
43
+      $AnonTorrents[$TorrentID] = $IsAnon ? $AnonUser : -1;
44
+    }
39 45
 ?>
40 46
     <tr class="row">
41 47
       <td><?=$Time?></td>
@@ -61,8 +67,8 @@ if (!empty($Groups[$GroupID])) {
61 67
 <?        }
62 68
       } else { ?>
63 69
         <td></td>
64
-<?      }  ?>
65
-      <td><?=Users::format_username($UserID, false, false, false)?></td>
70
+<?      } ?>
71
+      <td><?=($UserID == $AnonTorrents[$TorrentID])?'Anonymous':Users::format_username($UserID, false, false, false)?></td>
66 72
       <td><?=$Info?></td>
67 73
     </tr>
68 74
 <?

+ 6
- 8
sections/torrents/takeedit.php View File

@@ -50,6 +50,7 @@ $Properties['Subbing'] = $_POST['sub'];
50 50
 $Properties['Language'] = $_POST['lang'];
51 51
 $Properties['Subber']= $_POST['subber'];
52 52
 $Properties['Censored'] = (isset($_POST['censored'])) ? 1 : 0;
53
+$Properties['Anonymous'] = (isset($_POST['anonymous'])) ? 1 : 0;
53 54
 $Properties['Archive'] = (isset($_POST['archive']) && $_POST['archive'] != '---') ? $_POST['archive'] : '';
54 55
 
55 56
 if ($_POST['album_desc']) {
@@ -241,20 +242,15 @@ foreach ($Properties as $Key => $Value) {
241 242
 }
242 243
 
243 244
 $T['Censored'] = $Properties['Censored'];
245
+$T['Anonymous'] = $Properties['Anonymous'];
244 246
 
245 247
 
246 248
 //******************************************************************************//
247 249
 //--------------- Start database stuff -----------------------------------------//
248 250
 
249 251
 $DBTorVals = [];
250
-/*
251
-$DB->query("
252
-  SELECT Media, Format, Encoding, RemasterYear, Remastered, RemasterTItle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, Description
253
-  FROM torrents
254
-  WHERE ID = $TorrentID");
255
-  */
256 252
 $DB->query("
257
-  SELECT Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description, MediaInfo, Censored, Archive, Subber
253
+  SELECT Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description, MediaInfo, Censored, Anonymous, Archive, Subber
258 254
   FROM torrents
259 255
   WHERE ID = $TorrentID");
260 256
 $DBTorVals = $DB->to_array(false, MYSQLI_ASSOC);
@@ -277,6 +273,7 @@ foreach ($DBTorVals as $Key => $Value) {
277 273
   }
278 274
 }
279 275
 $T['Censored'] = $Properties['Censored'];
276
+$T['Anonymous'] = $Properties['Anonymous'];
280 277
 
281 278
 // Update info for the torrent
282 279
 /*
@@ -307,7 +304,8 @@ $SQL = "
307 304
     Subber = $T[Subber],
308 305
     Archive = $T[Archive],
309 306
     MediaInfo = $T[MediaInfo],
310
-    Censored = $T[Censored],";
307
+    Censored = $T[Censored],
308
+    Anonymous = $T[Anonymous],";
311 309
 
312 310
 if (check_perms('torrents_freeleech')) {
313 311
   $SQL .= "FreeTorrent = $T[FreeLeech],";

+ 4
- 2
sections/upload/upload_handle.php View File

@@ -62,6 +62,7 @@ $Properties['Language'] = isset($_POST['lang']) ? $_POST['lang'] : '';
62 62
 $Properties['Subber'] = isset($_POST['subber']) ? $_POST['subber'] : '';
63 63
 $Properties['DLsiteID'] = (isset($_POST['dlsiteid'])) ? $_POST['dlsiteid'] : '';
64 64
 $Properties['Censored'] = (isset($_POST['censored'])) ? 1 : 0;
65
+$Properties['Anonymous'] = (isset($_POST['anonymous'])) ? 1 : 0;
65 66
 $Properties['Archive'] = (isset($_POST['archive']) && $_POST['archive'] != '---') ? $_POST['archive'] : '';
66 67
 if (isset($_POST['library_image'])) $Properties['LibraryImage'] = $_POST['library_image'];
67 68
 if (isset($_POST['tags'])) $Properties['TagList'] = implode(',',array_unique(explode(',', str_replace(' ','',$_POST['tags']))));
@@ -254,6 +255,7 @@ foreach ($Properties as $Key => $Value) {
254 255
 }
255 256
 
256 257
 $T['Censored'] = $Properties['Censored'];
258
+$T['Anonymous'] = $Properties['Anonymous'];
257 259
 
258 260
 
259 261
 //******************************************************************************//
@@ -564,11 +566,11 @@ if (($Type == "Movies" || $Type == "Anime") && ($T['Container'] == "'ISO'" || $T
564 566
 $DB->query("
565 567
   INSERT INTO torrents
566 568
     (GroupID, UserID, Media, Container, Codec, Resolution, AudioFormat,
567
-    Subbing, Language, Subber, Censored, Archive, info_hash, FileCount, FileList,
569
+    Subbing, Language, Subber, Censored, Anonymous, Archive, info_hash, FileCount, FileList,
568 570
     FilePath, Size, Time, Description, MediaInfo, FreeTorrent, FreeLeechType)
569 571
   VALUES
570 572
     ($GroupID, $LoggedUser[ID], $T[Media], $T[Container], $T[Codec], $T[Resolution], $T[AudioFormat],
571
-    $T[Subbing], $T[Language], $T[Subber], $T[Censored], $T[Archive],'".db_string($InfoHash)."', $NumFiles, '$FileString',
573
+    $T[Subbing], $T[Language], $T[Subber], $T[Censored], $T[Anonymous], $T[Archive],'".db_string($InfoHash)."', $NumFiles, '$FileString',
572 574
     '$FilePath', $TotalSize, '".sqltime()."', $T[TorrentDescription], $T[MediaInfo], '$T[FreeTorrent]', '$T[FreeLeechType]')");
573 575
 
574 576
 $Cache->increment('stats_torrent_count');

Loading…
Cancel
Save