function netstatHosts($torrentAlias)
{
    return netstatHostsByPid(getTorrentPid($torrentAlias));
}
/**
 * netstatHosts
 *
 * @param $transfer
 * @return array
 */
function netstatHosts($transfer)
{
    return netstatHostsByPid(getTransferPid($transfer));
}
Beispiel #3
0
    $transfer = getTransmissionTransfer($hash, $options);
    $isRunning = true;
    //TODO make this actually determine if the torrent is running
    if ($isRunning) {
        foreach ($transfer['peers'] as $peer) {
            array_push($list_host, array('host' => @gethostbyaddr($peer['address']), 'port' => $peer['port']));
        }
    }
} else {
    // stat
    $sf = new StatFile($transfer);
    // set vars
    if ($sf->running == 1) {
        $transfer_pid = getTransferPid($transfer);
        $transfer_cons = netstatConnectionsByPid($transfer_pid);
        $transfer_hosts = netstatHostsByPid($transfer_pid);
        $hostAry = array_keys($transfer_hosts);
        foreach ($hostAry as $host) {
            $host = @trim($host);
            $port = @trim($transfer_hosts[$host]);
            if ($cfg["transferHosts"] == 1) {
                $host = @gethostbyaddr($host);
            }
            if ($host != "") {
                $tmpl->setvar('hosts', 1);
                array_push($list_host, array('host' => $host, 'port' => $port));
            }
        }
    }
}
$transfer_cons = sizeof($list_host);
$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");
}
$torrent_cons = "";
if ($af->running == 1 && $alias != "") {
    $torrent_pid = getTorrentPid($alias);
    $torrent_cons = netstatConnectionsByPid($torrent_pid);
    $torrent_hosts = netstatHostsByPid($torrent_pid);
}
$torrentLabel = htmlentities($torrent, ENT_QUOTES);
if (strlen($torrentLabel) >= 39) {
    $torrentLabel = substr($torrent, 0, 35) . "...";
}
$hd = getStatusImage($af);
DisplayHead(_ID_HOSTS, false, "15", $af->percent_done . "% ");
?>
    <div align="center">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td align="center">
<?php 
if ($error != "") {
    echo "<img src=\"images/error.gif\" width=16 height=16 border=0 title=\"ERROR\" align=\"absmiddle\">";