|
@@ -172,10 +172,6 @@ switch ($Type) {
|
172
|
172
|
$Validate->SetFields('groupid', '0', 'number', 'Group ID was not numeric');
|
173
|
173
|
}
|
174
|
174
|
|
175
|
|
-
|
176
|
|
-$Validate->SetFields('rules',
|
177
|
|
- '1','require','Your torrent must abide by the rules.');
|
178
|
|
-
|
179
|
175
|
$Err = $Validate->ValidateForm($_POST); // Validate the form
|
180
|
176
|
|
181
|
177
|
if (count(explode(',', $Properties['TagList'])) < 5) {
|
|
@@ -232,31 +228,13 @@ if ($Err) { // Show the upload form, with the data the user entered
|
232
|
228
|
die();
|
233
|
229
|
}
|
234
|
230
|
|
235
|
|
-// Strip out Amazon's padding
|
236
|
|
-$AmazonReg = '/(http:\/\/ecx.images-amazon.com\/images\/.+)(\._.*_\.jpg)/i';
|
237
|
|
-$Matches = [];
|
238
|
|
-//What the fuck is $RegX what.cd devs?
|
239
|
|
-//if (preg_match($RegX, $Properties['Image'], $Matches)) {
|
240
|
|
-if (preg_match($AmazonReg, $Properties['Image'], $Matches)) {
|
241
|
|
- $Properties['Image'] = $Matches[1].'.jpg';
|
242
|
|
-}
|
243
|
231
|
ImageTools::blacklisted($Properties['Image']);
|
244
|
232
|
|
245
|
233
|
//******************************************************************************//
|
246
|
234
|
//--------------- Make variables ready for database input ----------------------//
|
247
|
235
|
|
248
|
|
-// Shorten and escape $Properties for database input
|
249
|
|
-$T = [];
|
250
|
|
-foreach ($Properties as $Key => $Value) {
|
251
|
|
- $T[$Key] = "'".db_string(trim($Value))."'";
|
252
|
|
- if (!$T[$Key]) {
|
253
|
|
- $T[$Key] = null;
|
254
|
|
- }
|
255
|
|
-}
|
256
|
|
-
|
257
|
|
-$T['Censored'] = $Properties['Censored'];
|
258
|
|
-$T['Anonymous'] = $Properties['Anonymous'];
|
259
|
|
-
|
|
236
|
+// Prepared SQL statements do this for us, so there is nothing to do here anymore
|
|
237
|
+$T = $Properties;
|
260
|
238
|
|
261
|
239
|
//******************************************************************************//
|
262
|
240
|
//--------------- Generate torrent file ----------------------------------------//
|
|
@@ -264,7 +242,6 @@ $T['Anonymous'] = $Properties['Anonymous'];
|
264
|
242
|
$Tor = new BencodeTorrent($TorrentName, true);
|
265
|
243
|
$PublicTorrent = $Tor->make_private(); // The torrent is now private.
|
266
|
244
|
$UnsourcedTorrent = $Tor->make_sourced(); // The torrent now has the source field set.
|
267
|
|
-$TorEnc = $Tor->encode();
|
268
|
245
|
$InfoHash = pack('H*', $Tor->info_hash());
|
269
|
246
|
|
270
|
247
|
if (isset($Tor->Dec['encrypted_files'])) {
|
|
@@ -297,10 +274,6 @@ $FilePath = db_string($DirName);
|
297
|
274
|
$FileString = db_string(implode("\n", $TmpFileList));
|
298
|
275
|
$Debug->set_flag('upload: torrent decoded');
|
299
|
276
|
|
300
|
|
-/*if ($Type == 'Music') {
|
301
|
|
- include(SERVER_ROOT.'/sections/upload/generate_extra_torrents.php');
|
302
|
|
-}*/
|
303
|
|
-
|
304
|
277
|
if (!empty($Err)) { // Show the upload form, with the data the user entered
|
305
|
278
|
$UploadForm = $Type;
|
306
|
279
|
include(SERVER_ROOT.'/sections/upload/upload.php');
|
|
@@ -310,16 +283,15 @@ if (!empty($Err)) { // Show the upload form, with the data the user entered
|
310
|
283
|
//******************************************************************************//
|
311
|
284
|
//--------------- Start database stuff -----------------------------------------//
|
312
|
285
|
|
313
|
|
-$Body = $Properties['GroupDescription'];
|
|
286
|
+$Body = $T['GroupDescription'];
|
314
|
287
|
|
315
|
288
|
// Trickery
|
316
|
|
-if (!preg_match('/^'.IMAGE_REGEX.'$/i', $Properties['Image'])) {
|
317
|
|
- $Properties['Image'] = '';
|
318
|
|
- $T['Image'] = "''";
|
|
289
|
+if (!preg_match('/^'.IMAGE_REGEX.'$/i', $T['Image'])) {
|
|
290
|
+ $T['Image'] = '';
|
319
|
291
|
}
|
320
|
292
|
|
321
|
293
|
// Does it belong in a group?
|
322
|
|
-if ($Properties['GroupID']) {
|
|
294
|
+if ($T['GroupID']) {
|
323
|
295
|
$DB->query("
|
324
|
296
|
SELECT
|
325
|
297
|
ID,
|
|
@@ -330,77 +302,45 @@ if ($Properties['GroupID']) {
|
330
|
302
|
Year,
|
331
|
303
|
TagList
|
332
|
304
|
FROM torrents_group
|
333
|
|
- WHERE id = ".$Properties['GroupID']);
|
|
305
|
+ WHERE id = ?", $T['GroupID']);
|
334
|
306
|
if ($DB->has_results()) {
|
335
|
307
|
// Don't escape tg.Name. It's written directly to the log table
|
336
|
|
- list($GroupID, $WikiImage, $WikiBody, $RevisionID, $Properties['Title'], $Properties['Year'], $Properties['TagList']) = $DB->next_record(MYSQLI_NUM, array(4));
|
337
|
|
- $Properties['TagList'] = str_replace(array(' ', '.', '_'), array(', ', '.', '.'), $Properties['TagList']);
|
338
|
|
- if (!$Properties['Image'] && $WikiImage) {
|
339
|
|
- $Properties['Image'] = $WikiImage;
|
340
|
|
- $T['Image'] = "'".db_string($WikiImage)."'";
|
|
308
|
+ list($GroupID, $WikiImage, $WikiBody, $RevisionID, $T['Title'], $T['Year'], $T['TagList']) = $DB->next_record(MYSQLI_NUM, array(4));
|
|
309
|
+ $T['TagList'] = str_replace(array(' ', '.', '_'), array(', ', '.', '.'), $T['TagList']);
|
|
310
|
+ if (!$T['Image'] && $WikiImage) {
|
|
311
|
+ $T['Image'] = $WikiImage;
|
341
|
312
|
}
|
342
|
313
|
if (strlen($WikiBody) > strlen($Body)) {
|
343
|
314
|
$Body = $WikiBody;
|
344
|
|
- if (!$Properties['Image'] || $Properties['Image'] == $WikiImage) {
|
|
315
|
+ if (!$T['Image'] || $T['Image'] == $WikiImage) {
|
345
|
316
|
$NoRevision = true;
|
346
|
317
|
}
|
347
|
318
|
}
|
348
|
|
- $Properties['Artist'] = Artists::display_artists(Artists::get_artist($GroupID), false, false);
|
|
319
|
+ $T['Artist'] = Artists::display_artists(Artists::get_artist($GroupID), false, false);
|
349
|
320
|
}
|
350
|
321
|
}
|
351
|
322
|
if (!isset($GroupID) || !$GroupID) {
|
352
|
323
|
foreach ($ArtistForm as $Num => $Artist) {
|
353
|
|
- /*$DB->query("
|
|
324
|
+ // The album hasn't been uploaded. Try to get the artist IDs
|
|
325
|
+ $DB->query("
|
354
|
326
|
SELECT
|
355
|
|
- tg.id,
|
356
|
|
- tg.WikiImage,
|
357
|
|
- tg.WikiBody,
|
358
|
|
- tg.RevisionID
|
359
|
|
- FROM torrents_group AS tg
|
360
|
|
- LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
|
361
|
|
- LEFT JOIN artists_group AS ag ON ta.ArtistID = ag.ArtistID
|
362
|
|
- WHERE ag.Name = '".db_string($Artist['name'])."'
|
363
|
|
- AND tg.Name = ".$T['Title']."
|
364
|
|
- AND tg.Year = ".$T['Year']);
|
365
|
|
-
|
|
327
|
+ ArtistID,
|
|
328
|
+ Name
|
|
329
|
+ FROM artists_group
|
|
330
|
+ WHERE Name = ?", $Artist['name']);
|
366
|
331
|
if ($DB->has_results()) {
|
367
|
|
- list($GroupID, $WikiImage, $WikiBody, $RevisionID) = $DB->next_record();
|
368
|
|
- if (!$Properties['Image'] && $WikiImage) {
|
369
|
|
- $Properties['Image'] = $WikiImage;
|
370
|
|
- $T['Image'] = "'".db_string($WikiImage)."'";
|
371
|
|
- }
|
372
|
|
- if (strlen($WikiBody) > strlen($Body)) {
|
373
|
|
- $Body = $WikiBody;
|
374
|
|
- if (!$Properties['Image'] || $Properties['Image'] == $WikiImage) {
|
375
|
|
- $NoRevision = true;
|
376
|
|
- }
|
377
|
|
- }
|
378
|
|
- $ArtistForm = Artists::get_artist($GroupID);
|
379
|
|
- //This torrent belongs in a group
|
380
|
|
- break;
|
381
|
|
-
|
382
|
|
- } else {*/
|
383
|
|
- // The album hasn't been uploaded. Try to get the artist IDs
|
384
|
|
- $DB->query("
|
385
|
|
- SELECT
|
386
|
|
- ArtistID,
|
387
|
|
- Name
|
388
|
|
- FROM artists_group
|
389
|
|
- WHERE Name = '".db_string($Artist['name'])."'");
|
390
|
|
- if ($DB->has_results()) {
|
391
|
|
- while (list($ArtistID, $Name) = $DB->next_record(MYSQLI_NUM, false)) {
|
392
|
|
- if (!strcasecmp($Artist['name'], $Name)) {
|
393
|
|
- $ArtistForm[$Num] = array('id' => $ArtistID, 'name' => $Name);
|
394
|
|
- break;
|
395
|
|
- }
|
|
332
|
+ while (list($ArtistID, $Name) = $DB->next_record(MYSQLI_NUM, false)) {
|
|
333
|
+ if (!strcasecmp($Artist['name'], $Name)) {
|
|
334
|
+ $ArtistForm[$Num] = ['id' => $ArtistID, 'name' => $Name];
|
|
335
|
+ break;
|
396
|
336
|
}
|
397
|
337
|
}
|
398
|
|
- //}
|
|
338
|
+ }
|
399
|
339
|
}
|
400
|
340
|
}
|
401
|
341
|
|
402
|
342
|
//Needs to be here as it isn't set for add format until now
|
403
|
|
-$LogName .= $Properties['Title'];
|
|
343
|
+$LogName .= $T['Title'];
|
404
|
344
|
|
405
|
345
|
//For notifications--take note now whether it's a new group
|
406
|
346
|
$IsNewGroup = !isset($GroupID) || !$GroupID;
|
|
@@ -417,16 +357,11 @@ if ((!isset($GroupID) || !$GroupID)) {
|
417
|
357
|
// Create artist
|
418
|
358
|
$DB->query("
|
419
|
359
|
INSERT INTO artists_group (Name)
|
420
|
|
- VALUES ('".db_string($Artist['name'])."')");
|
|
360
|
+ VALUES ( ? )", $Artist['name']);
|
421
|
361
|
$ArtistID = $DB->inserted_id();
|
422
|
362
|
|
423
|
363
|
$Cache->increment('stats_artist_count');
|
424
|
364
|
|
425
|
|
- /*$DB->query("
|
426
|
|
- INSERT INTO artists_alias (ArtistID, Name)
|
427
|
|
- VALUES ($ArtistID, '".db_string($Artist['name'])."')");
|
428
|
|
- $AliasID = $DB->inserted_id();*/
|
429
|
|
-
|
430
|
365
|
$ArtistForm[$Num] = array('id' => $ArtistID, 'name' => $Artist['name']);
|
431
|
366
|
$ArtistsAdded[strtolower($Artist['name'])] = $ArtistForm[$Num];
|
432
|
367
|
}
|
|
@@ -439,21 +374,28 @@ if (!isset($GroupID) || !$GroupID) {
|
439
|
374
|
// Create torrent group
|
440
|
375
|
$DB->query("
|
441
|
376
|
INSERT INTO torrents_group
|
442
|
|
- (CategoryID, Name, NameRJ, NameJP, Year, Series, Studio, CatalogueNumber, Pages, Time, WikiBody, WikiImage, DLsiteID)
|
|
377
|
+ (CategoryID, Name, NameRJ, NameJP, Year,
|
|
378
|
+ Series, Studio, CatalogueNumber, Pages, Time,
|
|
379
|
+ WikiBody, WikiImage, DLsiteID)
|
443
|
380
|
VALUES
|
444
|
|
- ($TypeID, ".$T['Title'].", ".$T['TitleRJ'].", ".$T['TitleJP'].", ".$T['Year'].", ".$T['Series'].", ".$T['Studio'].", ".$T['CatalogueNumber'].", " . $T['Pages'] . ", NOW(), '".db_string($Body)."', ".$T['Image'].", ".$T['DLsiteID'].")");
|
|
381
|
+ ( ?, ?, ?, ?, ?,
|
|
382
|
+ ?, ?, ?, ?, NOW(),
|
|
383
|
+ ?, ?, ? )",
|
|
384
|
+ $TypeID, $T['Title'], $T['TitleRJ'], $T['TitleJP'], $T['Year'],
|
|
385
|
+ $T['Series'], $T['Studio'], $T['CatalogueNumber'], $T['Pages'],
|
|
386
|
+ $Body, $T['Image'], $T['DLsiteID']);
|
445
|
387
|
$GroupID = $DB->inserted_id();
|
446
|
388
|
foreach ($ArtistForm as $Num => $Artist) {
|
447
|
389
|
$DB->query("
|
448
|
390
|
INSERT IGNORE INTO torrents_artists (GroupID, ArtistID, UserID)
|
449
|
|
- VALUES ($GroupID, ".$Artist['id'].', '.$LoggedUser['ID'].")");
|
|
391
|
+ VALUES ( ?, ?, ? )", $GroupID, $Artist['id'], $LoggedUser['ID']);
|
450
|
392
|
$Cache->increment('stats_album_count');
|
451
|
393
|
$Cache->delete_value('artist_groups_'.$Artist['id']);
|
452
|
394
|
}
|
453
|
395
|
$Cache->increment('stats_group_count');
|
454
|
396
|
|
455
|
397
|
// Add screenshots
|
456
|
|
- $Screenshots = array_slice(array_filter(array_map("db_string", array_map("trim", array_unique(explode("\n", $Properties['Screenshots'])))), function ($s) { return preg_match('/^'.IMAGE_REGEX.'$/i', $s); }), 0, 10);
|
|
398
|
+ $Screenshots = array_slice(array_filter(array_map("db_string", array_map("trim", array_unique(explode("\n", $T['Screenshots'])))), function ($s) { return preg_match('/^'.IMAGE_REGEX.'$/i', $s); }), 0, 10);
|
457
|
399
|
|
458
|
400
|
$values = [];
|
459
|
401
|
foreach ($Screenshots as $s) {
|
|
@@ -471,7 +413,7 @@ if (!isset($GroupID) || !$GroupID) {
|
471
|
413
|
$DB->query("
|
472
|
414
|
UPDATE torrents_group
|
473
|
415
|
SET Time = NOW()
|
474
|
|
- WHERE ID = $GroupID");
|
|
416
|
+ WHERE ID = ?", $GroupID);
|
475
|
417
|
$Cache->delete_value("torrent_group_$GroupID");
|
476
|
418
|
$Cache->delete_value("torrents_details_$GroupID");
|
477
|
419
|
$Cache->delete_value("detail_files_$GroupID");
|
|
@@ -483,19 +425,19 @@ if (!isset($NoRevision) || !$NoRevision) {
|
483
|
425
|
INSERT INTO wiki_torrents
|
484
|
426
|
(PageID, Body, UserID, Summary, Time, Image)
|
485
|
427
|
VALUES
|
486
|
|
- ($GroupID, $T[GroupDescription], $LoggedUser[ID], 'Uploaded new torrent', NOW(), $T[Image])");
|
|
428
|
+ ( ?, ?, ?, 'Uploaded new torrent', NOW(), ? )", $GroupID, $T['GroupDescription'], $LoggedUser['ID'], $T['Image']);
|
487
|
429
|
$RevisionID = $DB->inserted_id();
|
488
|
430
|
|
489
|
431
|
// Revision ID
|
490
|
432
|
$DB->query("
|
491
|
433
|
UPDATE torrents_group
|
492
|
|
- SET RevisionID = '$RevisionID'
|
493
|
|
- WHERE ID = $GroupID");
|
|
434
|
+ SET RevisionID = ?
|
|
435
|
+ WHERE ID = ?", $RevisionID, $GroupID);
|
494
|
436
|
}
|
495
|
437
|
|
496
|
438
|
// Tags
|
497
|
|
-$Tags = explode(',', $Properties['TagList']);
|
498
|
|
-if (!$Properties['GroupID']) {
|
|
439
|
+$Tags = explode(',', $T['TagList']);
|
|
440
|
+if (!$T['GroupID']) {
|
499
|
441
|
foreach ($Tags as $Tag) {
|
500
|
442
|
$Tag = Misc::sanitize_tag($Tag);
|
501
|
443
|
if (!empty($Tag)) {
|
|
@@ -504,19 +446,17 @@ if (!$Properties['GroupID']) {
|
504
|
446
|
INSERT INTO tags
|
505
|
447
|
(Name, UserID)
|
506
|
448
|
VALUES
|
507
|
|
- ('$Tag', $LoggedUser[ID])
|
|
449
|
+ ( ?, ? )
|
508
|
450
|
ON DUPLICATE KEY UPDATE
|
509
|
|
- Uses = Uses + 1;
|
510
|
|
- ");
|
|
451
|
+ Uses = Uses + 1;", $Tag, $LoggedUser['ID']);
|
511
|
452
|
$TagID = $DB->inserted_id();
|
512
|
453
|
|
513
|
454
|
$DB->query("
|
514
|
455
|
INSERT INTO torrents_tags
|
515
|
456
|
(TagID, GroupID, UserID)
|
516
|
457
|
VALUES
|
517
|
|
- ($TagID, $GroupID, $LoggedUser[ID])
|
518
|
|
- ON DUPLICATE KEY UPDATE TagID=TagID
|
519
|
|
- ");
|
|
458
|
+ ( ?, ?, ? )
|
|
459
|
+ ON DUPLICATE KEY UPDATE TagID=TagID", $TagID, $GroupID, $LoggedUser['ID']);
|
520
|
460
|
}
|
521
|
461
|
}
|
522
|
462
|
}
|
|
@@ -542,7 +482,7 @@ if ($DB->has_results()) {
|
542
|
482
|
}
|
543
|
483
|
|
544
|
484
|
// movie and anime ISOs are neutral leech, and receive a BP bounty
|
545
|
|
-if (($Type == "Movies" || $Type == "Anime") && ($T['Container'] == "'ISO'" || $T['Container'] == "'M2TS'" || $T['Container'] == "'VOB IFO'")) {
|
|
485
|
+if (($Type == 'Movies' || $Type == 'Anime') && ($T['Container'] == 'ISO' || $T['Container'] == 'M2TS' || $T['Container'] == 'VOB IFO')) {
|
546
|
486
|
$T['FreeTorrent'] = 2;
|
547
|
487
|
$T['FreeLeechType'] = 2;
|
548
|
488
|
}
|
|
@@ -550,18 +490,29 @@ if (($Type == "Movies" || $Type == "Anime") && ($T['Container'] == "'ISO'" || $T
|
550
|
490
|
// Torrent
|
551
|
491
|
$DB->query("
|
552
|
492
|
INSERT INTO torrents
|
553
|
|
- (GroupID, UserID, Media, Container, Codec, Resolution, AudioFormat,
|
554
|
|
- Subbing, Language, Subber, Censored, Anonymous, Archive, info_hash, FileCount, FileList,
|
555
|
|
- FilePath, Size, Time, Description, MediaInfo, FreeTorrent, FreeLeechType)
|
|
493
|
+ (GroupID, UserID, Media, Container, Codec, Resolution,
|
|
494
|
+ AudioFormat, Subbing, Language, Subber, Censored,
|
|
495
|
+ Anonymous, Archive, info_hash, FileCount, FileList, FilePath, Size, Time,
|
|
496
|
+ Description, MediaInfo, FreeTorrent, FreeLeechType)
|
556
|
497
|
VALUES
|
557
|
|
- ($GroupID, $LoggedUser[ID], $T[Media], $T[Container], $T[Codec], $T[Resolution], $T[AudioFormat],
|
558
|
|
- $T[Subbing], $T[Language], $T[Subber], $T[Censored], $T[Anonymous], $T[Archive],'".db_string($InfoHash)."', $NumFiles, '$FileString',
|
559
|
|
- '$FilePath', $TotalSize, NOW(), $T[TorrentDescription], $T[MediaInfo], '$T[FreeTorrent]', '$T[FreeLeechType]')");
|
|
498
|
+ ( ?, ?, ?, ?, ?, ?,
|
|
499
|
+ ?, ?, ?, ?, ?,
|
|
500
|
+ ?, ?, ?, ?, ?, ?, ?, NOW(),
|
|
501
|
+ ?, ?, ?, ? )",
|
|
502
|
+ $GroupID, $LoggedUser['ID'], $T['Media'], $T['Container'], $T['Codec'], $T['Resolution'],
|
|
503
|
+ $T['AudioFormat'], $T['Subbing'], $T['Language'], $T['Subber'], $T['Censored'],
|
|
504
|
+ $T['Anonymous'], $T['Archive'], $InfoHash, $NumFiles, $FileString, $FilePath, $TotalSize,
|
|
505
|
+ $T['TorrentDescription'], $T['MediaInfo'], $T['FreeTorrent'], $T['FreeLeechType']);
|
560
|
506
|
|
561
|
507
|
$Cache->increment('stats_torrent_count');
|
562
|
508
|
$TorrentID = $DB->inserted_id();
|
|
509
|
+$Tor->Dec['comment'] = 'https://'.SITE_DOMAIN.'/torrents.php?torrentid='.$TorrentID;
|
563
|
510
|
|
564
|
|
-Tracker::update_tracker('add_torrent', array('id' => $TorrentID, 'info_hash' => rawurlencode($InfoHash), 'freetorrent' => $T['FreeTorrent']));
|
|
511
|
+Tracker::update_tracker('add_torrent', [
|
|
512
|
+ 'id' => $TorrentID,
|
|
513
|
+ 'info_hash' => rawurlencode($InfoHash),
|
|
514
|
+ 'freetorrent' => $T['FreeTorrent']
|
|
515
|
+]);
|
565
|
516
|
$Debug->set_flag('upload: ocelot updated');
|
566
|
517
|
|
567
|
518
|
// Prevent deletion of this torrent until the rest of the upload process is done
|
|
@@ -574,13 +525,13 @@ if (($Type == "Movies" || $Type == "Anime") && ($T['Container'] == "'ISO'" || $T
|
574
|
525
|
|
575
|
526
|
$DB->query("
|
576
|
527
|
UPDATE users_main
|
577
|
|
- SET BonusPoints = BonusPoints + $BPAmt
|
578
|
|
- WHERE ID = $LoggedUser[ID]");
|
|
528
|
+ SET BonusPoints = BonusPoints + ?
|
|
529
|
+ WHERE ID = ?", $BPAmt, $LoggedUser['ID']);
|
579
|
530
|
|
580
|
531
|
$DB->query("
|
581
|
532
|
UPDATE users_info
|
582
|
|
- SET AdminComment = CONCAT('".sqltime()." - Received $BPAmt ".BONUS_POINTS." for uploading a torrent $TorrentID\n\n', AdminComment)
|
583
|
|
- WHERE UserID = $LoggedUser[ID]");
|
|
533
|
+ SET AdminComment = CONCAT(NOW(), ' - Received $BPAmt ".BONUS_POINTS." for uploading a torrent $TorrentID\n\n', AdminComment)
|
|
534
|
+ WHERE UserID = ?", $LoggedUser['ID']);
|
584
|
535
|
$Cache->delete_value('user_info_heavy_'.$LoggedUser['ID']);
|
585
|
536
|
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
|
586
|
537
|
}
|
|
@@ -611,21 +562,17 @@ if ($T['FreeLeechType'] == 3) {
|
611
|
562
|
//******************************************************************************//
|
612
|
563
|
//--------------- Write torrent file -------------------------------------------//
|
613
|
564
|
|
614
|
|
-file_put_contents(TORRENT_STORE.$TorrentID.'.torrent', $TorEnc);
|
|
565
|
+file_put_contents(TORRENT_STORE.$TorrentID.'.torrent', $Tor->encode());
|
615
|
566
|
Misc::write_log("Torrent $TorrentID ($LogName) (".number_format($TotalSize / (1024 * 1024), 2).' MB) was uploaded by ' . $LoggedUser['Username']);
|
616
|
567
|
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'uploaded ('.number_format($TotalSize / (1024 * 1024), 2).' MB)', 0);
|
617
|
568
|
|
618
|
569
|
Torrents::update_hash($GroupID);
|
619
|
570
|
$Debug->set_flag('upload: sphinx updated');
|
620
|
571
|
|
621
|
|
-/*if ($Type == 'Music') {
|
622
|
|
- include(SERVER_ROOT.'/sections/upload/insert_extra_torrents.php');
|
623
|
|
-}*/
|
624
|
|
-
|
625
|
572
|
//******************************************************************************//
|
626
|
573
|
//---------------------- Recent Uploads ----------------------------------------//
|
627
|
574
|
|
628
|
|
-if (trim($Properties['Image']) != '') {
|
|
575
|
+if (trim($T['Image']) != '') {
|
629
|
576
|
$RecentUploads = $Cache->get_value("recent_uploads_$UserID");
|
630
|
577
|
if (is_array($RecentUploads)) {
|
631
|
578
|
do {
|
|
@@ -641,9 +588,9 @@ if (trim($Properties['Image']) != '') {
|
641
|
588
|
}
|
642
|
589
|
array_unshift($RecentUploads, array(
|
643
|
590
|
'ID' => $GroupID,
|
644
|
|
- 'Name' => trim($Properties['Title']),
|
|
591
|
+ 'Name' => trim($T['Title']),
|
645
|
592
|
'Artist' => Artists::display_artists($ArtistForm, false, true),
|
646
|
|
- 'WikiImage' => trim($Properties['Image'])));
|
|
593
|
+ 'WikiImage' => trim($T['Image'])));
|
647
|
594
|
$Cache->cache_value("recent_uploads_$UserID", $RecentUploads, 0);
|
648
|
595
|
} while (0);
|
649
|
596
|
}
|
|
@@ -660,13 +607,20 @@ if ($PublicTorrent) {
|
660
|
607
|
View::show_header('Warning');
|
661
|
608
|
?>
|
662
|
609
|
<h1>Warning</h1>
|
663
|
|
- <p><strong>Your torrent has been uploaded; however, you must download your torrent from <a href="torrents.php?id=<?=$GroupID?>">here</a> because you didn't make your torrent using the "private" option.</strong></p>
|
|
610
|
+ <p><strong>Your torrent has been uploaded - but you must re-download your torrent file from <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>">here</a> because the site modified it to make it private.</strong></p>
|
|
611
|
+<?
|
|
612
|
+ View::show_footer();
|
|
613
|
+} elseif ($UnsourcedTorrent) {
|
|
614
|
+ View::show_header('Warning');
|
|
615
|
+?>
|
|
616
|
+ <h1>Warning</h1>
|
|
617
|
+ <p><strong>Your torrent has been uploaded - but you must re-download your torrent file from <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>">here</a> because the site modified it to add a source flag.</strong></p>
|
664
|
618
|
<?
|
665
|
619
|
View::show_footer();
|
666
|
620
|
} elseif ($RequestID) {
|
667
|
621
|
header("Location: requests.php?action=takefill&requestid=$RequestID&torrentid=$TorrentID&auth=".$LoggedUser['AuthKey']);
|
668
|
622
|
} else {
|
669
|
|
- header("Location: torrents.php?id=$GroupID");
|
|
623
|
+ header("Location: torrents.php?id=$GroupID&torrentid=$TorrentID");
|
670
|
624
|
}
|
671
|
625
|
if (function_exists('fastcgi_finish_request')) {
|
672
|
626
|
fastcgi_finish_request();
|
|
@@ -683,16 +637,16 @@ $Announce = '';
|
683
|
637
|
|
684
|
638
|
$Announce .= Artists::display_artists($ArtistForm, false);
|
685
|
639
|
|
686
|
|
-$Announce .= substr(trim(empty($Properties['Title']) ? (empty($Properties['TitleRJ']) ? $Properties['TitleJP'] : $Properties['TitleRJ']) : $Properties['Title']), 0, 100);
|
|
640
|
+$Announce .= substr(trim(empty($T['Title']) ? (empty($T['TitleRJ']) ? $T['TitleJP'] : $T['TitleRJ']) : $T['Title']), 0, 100);
|
687
|
641
|
$Announce .= ' ';
|
688
|
642
|
if ($Type != 'Other') {
|
689
|
|
- $Announce .= '['.Torrents::torrent_info($Properties, false, false, false).']';
|
|
643
|
+ $Announce .= '['.Torrents::torrent_info($T, false, false, false).']';
|
690
|
644
|
}
|
691
|
|
-$Title = '['.$Properties['CategoryName'].'] '.$Announce;
|
|
645
|
+$Title = '['.$T['CategoryName'].'] '.$Announce;
|
692
|
646
|
|
693
|
647
|
$Announce = "$Title - ".site_url()."torrents.php?id=$GroupID / ".site_url()."torrents.php?action=download&id=$TorrentID";
|
694
|
648
|
|
695
|
|
-$Announce .= ' - '.trim($Properties['TagList']);
|
|
649
|
+$Announce .= ' - '.trim($T['TagList']);
|
696
|
650
|
|
697
|
651
|
// ENT_QUOTES is needed to decode single quotes/apostrophes
|
698
|
652
|
send_irc('PRIVMSG '.BOT_ANNOUNCE_CHAN.' '.html_entity_decode($Announce, ENT_QUOTES));
|
|
@@ -701,7 +655,7 @@ $Debug->set_flag('upload: announced on irc');
|
701
|
655
|
// Manage notifications
|
702
|
656
|
|
703
|
657
|
// For RSS
|
704
|
|
-$Item = $Feed->item($Title, Text::strip_bbcode($Body), 'torrents.php?action=download&authkey=[[AUTHKEY]]&torrent_pass=[[PASSKEY]]&id='.$TorrentID, $LoggedUser['Username'], 'torrents.php?id='.$GroupID, trim($Properties['TagList']));
|
|
658
|
+$Item = $Feed->item($Title, Text::strip_bbcode($Body), 'torrents.php?action=download&authkey=[[AUTHKEY]]&torrent_pass=[[PASSKEY]]&id='.$TorrentID, $LoggedUser['Username'], 'torrents.php?id='.$GroupID, trim($T['TagList']));
|
705
|
659
|
|
706
|
660
|
|
707
|
661
|
//Notifications
|
|
@@ -761,8 +715,8 @@ $SQL .= ") AND !(".implode(' OR ', $NotTagSQL).')';
|
761
|
715
|
|
762
|
716
|
$SQL .= " AND (Categories LIKE '%|".db_string(trim($Type))."|%' OR Categories = '') ";
|
763
|
717
|
|
764
|
|
-if ($Properties['ReleaseType']) {
|
765
|
|
- $SQL .= " AND (ReleaseTypes LIKE '%|".db_string(trim($ReleaseTypes[$Properties['ReleaseType']]))."|%' OR ReleaseTypes = '') ";
|
|
718
|
+if ($T['ReleaseType']) {
|
|
719
|
+ $SQL .= " AND (ReleaseTypes LIKE '%|".db_string(trim($ReleaseTypes[$T['ReleaseType']]))."|%' OR ReleaseTypes = '') ";
|
766
|
720
|
} else {
|
767
|
721
|
$SQL .= " AND (ReleaseTypes = '') ";
|
768
|
722
|
}
|
|
@@ -773,9 +727,8 @@ if ($Properties['ReleaseType']) {
|
773
|
727
|
2. If they set NewGroupsOnly to 1, it must also be the first torrent in the group to match the formatbitrate filter on the notification
|
774
|
728
|
*/
|
775
|
729
|
|
776
|
|
-
|
777
|
|
-if ($Properties['Format']) {
|
778
|
|
- $SQL .= " AND (Formats LIKE '%|".db_string(trim($Properties['Format']))."|%' OR Formats = '') ";
|
|
730
|
+if ($T['Format']) {
|
|
731
|
+ $SQL .= " AND (Formats LIKE '%|".db_string(trim($T['Format']))."|%' OR Formats = '') ";
|
779
|
732
|
} else {
|
780
|
733
|
$SQL .= " AND (Formats = '') ";
|
781
|
734
|
}
|
|
@@ -786,8 +739,8 @@ if ($_POST['bitrate']) {
|
786
|
739
|
$SQL .= " AND (Encodings = '') ";
|
787
|
740
|
}
|
788
|
741
|
|
789
|
|
-if ($Properties['Media']) {
|
790
|
|
- $SQL .= " AND (Media LIKE '%|".db_string(trim($Properties['Media']))."|%' OR Media = '') ";
|
|
742
|
+if ($T['Media']) {
|
|
743
|
+ $SQL .= " AND (Media LIKE '%|".db_string(trim($T['Media']))."|%' OR Media = '') ";
|
791
|
744
|
} else {
|
792
|
745
|
$SQL .= " AND (Media = '') ";
|
793
|
746
|
}
|
|
@@ -796,25 +749,11 @@ if ($Properties['Media']) {
|
796
|
749
|
$SQL .= "AND ((NewGroupsOnly = '0' ";
|
797
|
750
|
// Or this is the first torrent in the group to match the formatbitrate filter
|
798
|
751
|
$SQL .= ") OR ( NewGroupsOnly = '1' ";
|
799
|
|
-// Test the filter doesn't match any previous formatbitrate in the group
|
800
|
|
-/*
|
801
|
|
-foreach ($UsedFormatBitrates as $UsedFormatBitrate) {
|
802
|
|
- $FormatReq = "(Formats LIKE '%|".db_string($UsedFormatBitrate['format'])."|%' OR Formats = '') ";
|
803
|
|
- $BitrateReq = "(Encodings LIKE '%|".db_string($UsedFormatBitrate['bitrate'])."|%' OR Encodings = '') ";
|
804
|
|
- $SQL .= "AND (NOT($FormatReq AND $BitrateReq)) ";
|
805
|
|
-}
|
806
|
|
-*/
|
807
|
752
|
$SQL .= '))';
|
808
|
753
|
|
809
|
754
|
|
810
|
|
-/*if ($Properties['Year'] && $Properties['RemasterYear']) {
|
811
|
|
- $SQL .= " AND (('".db_string(trim($Properties['Year']))."' BETWEEN FromYear AND ToYear)
|
812
|
|
- OR ('".db_string(trim($Properties['RemasterYear']))."' BETWEEN FromYear AND ToYear)
|
813
|
|
- OR (FromYear = 0 AND ToYear = 0)) ";
|
814
|
|
-} else*/
|
815
|
|
-if ($Properties['Year'] || $Properties['RemasterYear']) {
|
816
|
|
- //$SQL .= " AND (('".db_string(trim(Max($Properties['Year'],$Properties['RemasterYear'])))."' BETWEEN FromYear AND ToYear)
|
817
|
|
- $SQL .= " AND (('".db_string(trim($Properties['Year']))."' BETWEEN FromYear AND ToYear)
|
|
755
|
+if ($T['Year']) {
|
|
756
|
+ $SQL .= " AND (('".db_string(trim($T['Year']))."' BETWEEN FromYear AND ToYear)
|
818
|
757
|
OR (FromYear = 0 AND ToYear = 0)) ";
|
819
|
758
|
} else {
|
820
|
759
|
$SQL .= " AND (FromYear = 0 AND ToYear = 0) ";
|