Esempio n. 1
0
 To read the license please visit http://www.gnu.org/copyleft/gpl.html

*******************************************************************************/
include_once "config.php";
include_once "functions.php";
require_once "metaInfo.php";
// is enabled ?
if ($cfg["advanced_start"] != 1) {
    AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to use advanced start");
    showErrorPage("advanced start is disabled.");
}
$torrent = getRequestVar('torrent');
// Load saved settings
$btclient_default = $cfg["btclient"];
$torrentExists = loadTorrentSettingsToConfig($torrent);
// savepath
if (!isset($cfg["savepath"]) || empty($cfg["savepath"])) {
    $cfg["savepath"] = $cfg["path"] . getOwner($torrent) . '/';
}
// torrent exists ?
$torrentExists = getTorrentDataSize($torrent) > 0;
// display name
$displayName = htmlentities($torrent, ENT_QUOTES);
if (strlen($displayName) >= 55) {
    $displayName = substr($displayName, 0, 52) . "...";
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
/**
 * gets size of data of a torrent
 *
 * @param $torrent name of the torrent
 * @return int with size of data of torrent.
 *         -1 if error
 *         4096 if dir (lol ~)
 *         string with file/dir-name if doesnt exist. (lol~)
 */
function getTorrentDataSize($torrent)
{
    global $cfg;
    require_once 'BDecode.php';
    $ftorrent = $cfg["torrent_file_path"] . $torrent;
    $fd = fopen($ftorrent, "rd");
    $alltorrent = fread($fd, filesize($ftorrent));
    $btmeta = BDecode($alltorrent);
    $name = $btmeta['info']['name'];
    if (trim($name) != "") {
        // load torrent-settings from db to get data-location
        loadTorrentSettingsToConfig($torrent);
        if (!isset($cfg["savepath"]) || empty($cfg["savepath"])) {
            $cfg["savepath"] = $cfg["path"] . getOwner($torrent) . '/';
        }
        $name = $cfg["savepath"] . $name;
        # this is from dir.php - its not a function, and we need to call it several times
        $tData = stripslashes(stripslashes($name));
        if (!ereg("(\\.\\.\\/)", $tData)) {
            $fileSize = file_size($tData);
            return $fileSize;
        }
    }
    return -1;
}
$error = "";
$torrentowner = getOwner($torrent);
$graph_width = "";
$background = "#000000";
$alias = getRequestVar('alias');
if (!empty($alias)) {
    // create AliasFile object
    $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias, $torrentowner, $cfg);
    for ($inx = 0; $inx < sizeof($af->errors); $inx++) {
        $error .= "<li style=\"font-size:10px;color:#ff0000;\">" . $af->errors[$inx] . "</li>";
    }
} else {
    die("fatal error torrent file not specified");
}
// Load saved settings
loadTorrentSettingsToConfig($torrent);
// TOTALS =======================================================================================================================
$torrentTotals = getTorrentTotals($torrent);
$torrentTotalsCurrent = getTorrentTotalsCurrent($torrent);
$upTotalCurrent = $torrentTotalsCurrent["uptotal"] + 0;
$downTotalCurrent = $torrentTotalsCurrent["downtotal"] + 0;
$upTotal = $torrentTotals["uptotal"] + 0;
$downTotal = $torrentTotals["downtotal"] + 0;
// TOTALS =======================================================================================================================
// seeding-%
$torrentSize = $af->size + 0;
$sharing = number_format($upTotal / $torrentSize * 100, 2);
$torrent_port = "";
$torrent_cons = "";
$label_max_download_rate = "";
$label_max_upload_rate = "";