$PublicTorrent = true; } // File list and size list($ExtraTotalSize, $ExtraFileList) = $ExtraTor->file_list(); $ExtraDirName = isset($ExtraTor->Dec['info']['files']) ? Format::make_utf8($ExtraTor->get_name()) : ''; $ExtraTmpFileList = array(); foreach ($ExtraFileList as $ExtraFile) { list($ExtraSize, $ExtraName) = $ExtraFile; check_file($Type, $ExtraName); // Make sure the file name is not too long if (mb_strlen($ExtraName, 'UTF-8') + mb_strlen($ExtraDirName, 'UTF-8') + 1 > MAX_FILENAME_LENGTH) { $Err = "The torrent contained one or more files with too long of a name: <br />{$ExtraDirName}/{$ExtraName}"; break; } // Add file and size to array $ExtraTmpFileList[] = Torrents::filelist_format_file($ExtraFile); } // To be stored in the database $ThisInsert['FilePath'] = db_string($ExtraDirName); $ThisInsert['FileString'] = db_string(implode("\n", $ExtraTmpFileList)); $ThisInsert['InfoHash'] = pack('H*', $ExtraTor->info_hash()); $ThisInsert['NumFiles'] = count($ExtraFileList); $ThisInsert['TorEnc'] = db_string($ExtraTor->encode()); $ThisInsert['TotalSize'] = $ExtraTotalSize; $Debug->set_flag('upload: torrent decoded'); $DB->query("\n\t\tSELECT ID\n\t\tFROM torrents\n\t\tWHERE info_hash = '" . db_string($ThisInsert['InfoHash']) . "'"); if ($DB->has_results()) { list($ExtraID) = $DB->next_record(); $DB->query("\n\t\t\tSELECT TorrentID\n\t\t\tFROM torrents_files\n\t\t\tWHERE TorrentID = {$ExtraID}"); if ($DB->has_results()) { $Err = "<a href=\"torrents.php?torrentid={$ExtraID}\">The exact same torrent file already exists on the site!</a>";
// add +log to encoding if ($T['Encoding'] == "'Lossless'" && !in_array($Name, $IgnoredLogFileNames) && substr($Name, -4, 4) === '.log') { $HasLog = 1; } // add +cue to encoding if ($T['Encoding'] == "'Lossless'" && preg_match('/\\.cue$/i', $Name)) { $HasCue = 1; } // Check file name and extension against blacklist/whitelist check_file($Type, $Name); // Make sure the filename is not too long if (mb_strlen($Name, 'UTF-8') + mb_strlen($DirName, 'UTF-8') + 1 > MAX_FILENAME_LENGTH) { $TooLongPaths[] = "{$DirName}/{$Name}"; } // Add file info to array $TmpFileList[] = Torrents::filelist_format_file($File); } if (count($TooLongPaths) > 0) { $Names = implode(' <br />', $TooLongPaths); $Err = "The torrent contained one or more files with too long a name:<br /> {$Names}"; } $FilePath = db_string($DirName); $FileString = db_string(implode("\n", $TmpFileList)); $Debug->set_flag('upload: torrent decoded'); if ($Type == 'Music') { include SERVER_ROOT . '/sections/upload/generate_extra_torrents.php'; } if (!empty($Err)) { // Show the upload form, with the data the user entered $UploadForm = $Type; include SERVER_ROOT . '/sections/upload/upload.php';