コード例 #1
0
<?php

$ExtraTorrentsInsert = array();
foreach ($ExtraTorrents as $ExtraTorrent) {
    $Name = $ExtraTorrent['Name'];
    $ExtraTorrentsInsert[$Name] = $ExtraTorrent;
    $ThisInsert =& $ExtraTorrentsInsert[$Name];
    $ExtraTor = new BencodeTorrent($Name, true);
    if (isset($ExtraTor->Dec['encrypted_files'])) {
        $Err = 'At least one of the torrents contain an encrypted file list which is not supported here';
        break;
    }
    if (!$ExtraTor->is_private()) {
        $ExtraTor->make_private();
        // The torrent is now private.
        $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);
コード例 #2
0
ファイル: upload_handle.php プロジェクト: Kufirc/Gazelle
}
ImageTools::blacklisted($Properties['Image']);
//******************************************************************************//
//--------------- Make variables ready for database input ----------------------//
// Shorten and escape $Properties for database input
$T = array();
foreach ($Properties as $Key => $Value) {
    $T[$Key] = "'" . db_string(trim($Value)) . "'";
    if (!$T[$Key]) {
        $T[$Key] = null;
    }
}
//******************************************************************************//
//--------------- Generate torrent file ----------------------------------------//
$Tor = new BencodeTorrent($TorrentName, true);
$PublicTorrent = $Tor->make_private();
// The torrent is now private.
$TorEnc = db_string($Tor->encode());
$InfoHash = pack('H*', $Tor->info_hash());
$DB->query("\n\tSELECT ID\n\tFROM torrents\n\tWHERE info_hash = '" . db_string($InfoHash) . "'");
if ($DB->has_results()) {
    list($ID) = $DB->next_record();
    $DB->query("\n\t\tSELECT TorrentID\n\t\tFROM torrents_files\n\t\tWHERE TorrentID = {$ID}");
    if ($DB->has_results()) {
        $Err = '<a href="torrents.php?torrentid=' . $ID . '">The exact same torrent file already exists on the site!</a>';
    } else {
        // A lost torrent
        $DB->query("\n\t\t\tINSERT INTO torrents_files (TorrentID, File)\n\t\t\tVALUES ({$ID}, '{$TorEnc}')");
        $Err = '<a href="torrents.php?torrentid=' . $ID . '">Thank you for fixing this torrent</a>';
    }
}