当前位置: 首页>>代码示例>>PHP>>正文


PHP getAliasName函数代码示例

本文整理汇总了PHP中getAliasName函数的典型用法代码示例。如果您正苦于以下问题:PHP getAliasName函数的具体用法?PHP getAliasName怎么用?PHP getAliasName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getAliasName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: write_stat_file

function write_stat_file()
{
    global $_NAME, $_SIZE, $_COMPLETED, $_PERCENTAGE, $_SPEED, $_STATUS, $_REAL_NAME, $cfg, $_INT_SPEED, $_OWNER;
    // this is "something else" (wget). use tornado statfile
    $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . getAliasName($_NAME) . ".stat", $_OWNER, $cfg, 'tornado');
    $af->running = $_STATUS;
    $af->percent_done = $_PERCENTAGE;
    if ($_COMPLETED == $_SIZE) {
        $af->time_left = "Download Succeeded!";
        $af->down_speed = "0 kB/s";
    } else {
        if ($_INT_SPEED > 0) {
            // because size is 0 this wont work so lets put a fallback here now
            //$af->time_left = convert_time( (($_SIZE-$_COMPLETED)/1024)/$_INT_SPEED);
            $af->time_left = '?';
        } else {
            $af->time_left = "Inf" . $_INT_SPEED;
        }
        $af->down_speed = $_SPEED;
    }
    $af->up_speed = "N/a";
    $af->sharing = "0";
    $af->torrentowner = $_OWNER;
    $af->seeds = "1+0.00";
    $af->peers = "1+0.00";
    $af->seedlimit = "0";
    $af->uptotal = "0";
    $af->downtotal = $_COMPLETED;
    $af->size = $_SIZE;
    $af->WriteFile();
}
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:31,代码来源:wget.php

示例2: setPriority

function setPriority($torrent)
{
    global $cfg;
    // we will use this to determine if we should create a prio file.
    // if the user passes all 1's then they want the whole thing.
    // so we don't need to create a prio file.
    // if there is a -1 in the array then they are requesting
    // to skip a file. so we will need to create the prio file.
    $okToCreate = false;
    if (!empty($torrent)) {
        $alias = getAliasName($torrent);
        $fileName = $cfg["torrent_file_path"] . $alias . ".prio";
        $result = array();
        // b4rt-4
        //$files = array_filter($_REQUEST['files'],"getFile");
        $files = array();
        if (isset($_REQUEST['files'])) {
            $files = array_filter($_REQUEST['files'], "getFile");
        }
        // b4rt-4
        // if there are files to get then process and create a prio file.
        if (count($files) > 0) {
            for ($i = 0; $i < getRequestVar('count'); $i++) {
                if (in_array($i, $files)) {
                    array_push($result, 1);
                } else {
                    $okToCreate = true;
                    array_push($result, -1);
                }
            }
            $alias = getAliasName($torrent);
            if ($okToCreate) {
                $fp = fopen($fileName, "w");
                fwrite($fp, getRequestVar('filecount') . ",");
                fwrite($fp, implode($result, ','));
                fclose($fp);
            } else {
                // No files to skip so must be wanting them all.
                // So we will remove the prio file.
                @unlink($fileName);
            }
        } else {
            // No files selected so must be wanting them all.
            // So we will remove the prio file.
            @unlink($fileName);
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:48,代码来源:setpriority.php

示例3: switch

 switch ($torrentAction) {
     case "0":
         // Torrents-main
         $htmlTitle = "Torrents";
         break;
     case "1":
         // Torrents-Stop
         include_once "ClientHandler.php";
         $htmlTitle = "Torrents-Stop";
         $htmlMain .= '<br><strong>Torrents Stopped :</strong><br>';
         $htmlMain .= '<pre>';
         $torrents = getTorrentListFromFS();
         foreach ($torrents as $torrent) {
             $torrentRunningFlag = isTorrentRunning($torrent);
             if ($torrentRunningFlag != 0) {
                 $alias = getAliasName($torrent) . ".stat";
                 $btclient = getTorrentClient($torrent);
                 $clientHandler = ClientHandler::getClientHandlerInstance($cfg, $btclient);
                 $clientHandler->stopTorrentClient($torrent, $alias);
                 $htmlMain .= ' - ' . $torrent . "";
                 $htmlMain .= "\n";
                 // just 2 sec..
                 sleep(2);
             }
         }
         $htmlMain .= '</pre>';
         $htmlMain .= '<hr><br>';
         break;
     case "2":
         // Torrents-Start
         include_once "ClientHandler.php";
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:31,代码来源:superadmin.php

示例4: formattedQueueList

 /**
  * formattedQueueList. dont want to rewrite more tf-mvc-"issues"...
  * @return html-snip
  */
 function formattedQueueList()
 {
     if ($this->isQueueManagerRunning()) {
         $output = "";
         $torrentList = trim($this->getQueuedTorrents());
         $torrentAry = explode("\n", $torrentList);
         foreach ($torrentAry as $torrent) {
             if ($torrent != "") {
                 $output .= "<tr>";
                 $output .= "<td><div class=\"tiny\">";
                 $output .= getOwner($torrent);
                 $output .= "</div></td>";
                 $output .= "<td><div align=center><div class=\"tiny\" align=\"left\">" . $torrent . "</div></td>";
                 $output .= "<td><div class=\"tiny\" align=\"center\">" . date(_DATETIMEFORMAT, strval(filemtime($this->cfg["torrent_file_path"] . getAliasName($torrent) . ".stat"))) . "</div></td>";
                 $output .= "</tr>";
                 $output .= "\n";
             }
         }
         if (strlen($output) == 0) {
             return "<tr><td colspan=3><div class=\"tiny\" align=center>Queue is Empty</div></td></tr>";
         } else {
             return $output;
         }
     } else {
         return "";
     }
 }
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:31,代码来源:QueueManager.Qmgr.php

示例5: getDirList

function getDirList($dirName)
{
    global $cfg, $db;
    include_once "AliasFile.php";
    $lastUser = "";
    $arUserTorrent = array();
    $arListTorrent = array();
    // sortOrder
    $sortOrder = getRequestVar("so");
    if ($sortOrder == "") {
        $sortOrder = $cfg["index_page_sortorder"];
    }
    // t-list
    $arList = getTransferArray($sortOrder);
    foreach ($arList as $entry) {
        $output = "";
        $displayname = $entry;
        $show_run = true;
        $torrentowner = getOwner($entry);
        $owner = IsOwner($cfg["user"], $torrentowner);
        $kill_id = "";
        $estTime = "&nbsp;";
        // alias / stat
        $alias = getAliasName($entry) . ".stat";
        if (substr(strtolower($entry), -8) == ".torrent") {
            // this is a torrent-client
            $btclient = getTorrentClient($entry);
            $af = AliasFile::getAliasFileInstance($dirName . $alias, $torrentowner, $cfg, $btclient);
        } else {
            if (substr(strtolower($entry), -4) == ".url") {
                // this is wget. use tornado statfile
                $alias = str_replace(".url", "", $alias);
                $af = AliasFile::getAliasFileInstance($dirName . $alias, $cfg['user'], $cfg, 'tornado');
            } else {
                // this is "something else". use tornado statfile as default
                $af = AliasFile::getAliasFileInstance($dirName . $alias, $cfg['user'], $cfg, 'tornado');
            }
        }
        //XFER: add upload/download stats to the xfer array
        if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) {
            $torrentTotalsCurrent = getTorrentTotalsCurrentOP($entry, $btclient, $af->uptotal, $af->downtotal);
            $sql = 'SELECT 1 FROM tf_xfer WHERE date = ' . $db->DBDate(time());
            $newday = !$db->GetOne($sql);
            showError($db, $sql);
            sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'total');
            sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'month');
            sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'week');
            sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'day');
            //XFER: if new day add upload/download totals to last date on record and subtract from today in SQL
            if ($newday) {
                $newday = 2;
                $sql = 'SELECT date FROM tf_xfer ORDER BY date DESC';
                $lastDate = $db->GetOne($sql);
                showError($db, $sql);
                // MySQL 4.1.0 introduced 'ON DUPLICATE KEY UPDATE' to make this easier
                $sql = 'SELECT 1 FROM tf_xfer WHERE user_id = "' . $torrentowner . '" AND date = "' . $lastDate . '"';
                if ($db->GetOne($sql)) {
                    $sql = 'UPDATE tf_xfer SET download = download+' . ($torrentTotalsCurrent["downtotal"] + 0) . ', upload = upload+' . ($torrentTotalsCurrent["uptotal"] + 0) . ' WHERE user_id = "' . $torrentowner . '" AND date = "' . $lastDate . '"';
                    $db->Execute($sql);
                    showError($db, $sql);
                } else {
                    showError($db, $sql);
                    $sql = 'INSERT INTO tf_xfer (user_id,date,download,upload) values ("' . $torrentowner . '","' . $lastDate . '",' . ($torrentTotalsCurrent["downtotal"] + 0) . ',' . ($torrentTotalsCurrent["uptotal"] + 0) . ')';
                    $db->Execute($sql);
                    showError($db, $sql);
                }
                $sql = 'SELECT 1 FROM tf_xfer WHERE user_id = "' . $torrentowner . '" AND date = ' . $db->DBDate(time());
                if ($db->GetOne($sql)) {
                    $sql = 'UPDATE tf_xfer SET download = download-' . ($torrentTotalsCurrent["downtotal"] + 0) . ', upload = upload-' . ($torrentTotalsCurrent["uptotal"] + 0) . ' WHERE user_id = "' . $torrentowner . '" AND date = ' . $db->DBDate(time());
                    $db->Execute($sql);
                    showError($db, $sql);
                } else {
                    showError($db, $sql);
                    $sql = 'INSERT INTO tf_xfer (user_id,date,download,upload) values ("' . $torrentowner . '",' . $db->DBDate(time()) . ',-' . ($torrentTotalsCurrent["downtotal"] + 0) . ',-' . ($torrentTotalsCurrent["uptotal"] + 0) . ')';
                    $db->Execute($sql);
                    showError($db, $sql);
                }
            }
        }
        $timeStarted = "";
        $torrentfilelink = "";
        if (!file_exists($dirName . $alias)) {
            $af->running = "2";
            // file is new
            $af->size = getDownloadSize($dirName . $entry);
            $af->WriteFile();
        }
        if (strlen($entry) >= 47) {
            // needs to be trimmed
            $displayname = substr($entry, 0, 44);
            $displayname .= "...";
        }
        if ($cfg["enable_torrent_download"]) {
            $torrentfilelink = "<a href=\"maketorrent.php?download=" . urlencode($entry) . "\"><img src=\"images/down.gif\" width=9 height=9 title=\"Download Torrent File\" border=0 align=\"absmiddle\"></a>";
        }
        //
        $hd = getStatusImage($af);
        $output .= "<tr>";
        $detailsLinkString = "<a style=\"font-size:9px; text-decoration:none;\" href=\"JavaScript:ShowDetails('downloaddetails.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\">";
        // ========================================================== led + meta
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:101,代码来源:functions.tf.php

示例6: enqueueTorrent

 /**
  * enqueueTorrent
  * @param $torrent name of the torrent
  */
 function enqueueTorrent($torrent)
 {
     $alias = getAliasName($torrent);
     $this->writeQinfo($this->cfg["torrent_file_path"] . "queue/" . $alias . ".stat", $this->command);
 }
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:9,代码来源:QueueManager.tfQManager.php

示例7: getTorrentTransferTotal

 /**
  * gets total transfer-vals of a torrent
  *
  * @param $torrent
  * @return array with downtotal and uptotal
  */
 function getTorrentTransferTotal($torrent)
 {
     $retVal = array();
     // transfer from stat-file
     $aliasName = getAliasName($torrent);
     $owner = getOwner($torrent);
     $af = AliasFile::getAliasFileInstance($this->cfg["torrent_file_path"] . $aliasName . ".stat", $owner, $this->cfg, $this->handlerName);
     $retVal["uptotal"] = $af->uptotal + 0;
     $retVal["downtotal"] = $af->downtotal + 0;
     return $retVal;
 }
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:17,代码来源:ClientHandler.transmission.php

示例8: getDirList

function getDirList($dirName)
{
    global $cfg, $db;
    include_once "AliasFile.php";
    include_once "RunningTorrent.php";
    $runningTorrents = getRunningTorrents();
    $arList = array();
    $file_filter = getFileFilter($cfg["file_types_array"]);
    if (is_dir($dirName)) {
        $handle = opendir($dirName);
    } else {
        // nothing to read
        if (IsAdmin()) {
            echo "<b>ERROR:</b> " . $dirName . " Path is not valid. Please edit <a href='admin.php?op=configSettings'>settings</a><br>";
        } else {
            echo "<b>ERROR:</b> Contact an admin the Path is not valid.<br>";
        }
        return;
    }
    $lastUser = "";
    $arUserTorrent = array();
    $arListTorrent = array();
    while ($entry = readdir($handle)) {
        if ($entry != "." && $entry != "..") {
            if (is_dir($dirName . "/" . $entry)) {
                // don''t do a thing
            } else {
                if (ereg($file_filter, $entry)) {
                    $key = filemtime($dirName . "/" . $entry) . md5($entry);
                    $arList[$key] = $entry;
                }
            }
        }
    }
    // sort the files by date
    krsort($arList);
    foreach ($arList as $entry) {
        $output = "";
        $displayname = $entry;
        $show_run = true;
        $torrentowner = getOwner($entry);
        $owner = IsOwner($cfg["user"], $torrentowner);
        $kill_id = "";
        $estTime = "&nbsp;";
        $alias = getAliasName($entry) . ".stat";
        $af = new AliasFile($dirName . $alias, $torrentowner);
        $timeStarted = "";
        $torrentfilelink = "";
        if (!file_exists($dirName . $alias)) {
            $af->running = "2";
            // file is new
            $af->size = getDownloadSize($dirName . $entry);
            $af->WriteFile();
        }
        if (strlen($entry) >= 47) {
            // needs to be trimmed
            $displayname = substr($entry, 0, 44);
            $displayname .= "...";
        }
        // find out if any screens are running and take their PID and make a KILL option
        foreach ($runningTorrents as $key => $value) {
            $rt = new RunningTorrent($value);
            if ($rt->statFile == $alias) {
                if ($kill_id == "") {
                    $kill_id = $rt->processId;
                } else {
                    // there is more than one PID for this torrent
                    // Add it so it can be killed as well.
                    $kill_id .= "|" . $rt->processId;
                }
            }
        }
        // Check to see if we have a pid without a process.
        if (is_file($cfg["torrent_file_path"] . $alias . ".pid") && empty($kill_id)) {
            // died outside of tf and pid still exists.
            @unlink($cfg["torrent_file_path"] . $alias . ".pid");
            if ($af->percent_done < 100 && $af->percent_done >= 0) {
                // The file is not running and the percent done needs to be changed
                $af->percent_done = ($af->percent_done + 100) * -1;
            }
            $af->running = "0";
            $af->time_left = "Torrent Died";
            $af->up_speed = "";
            $af->down_speed = "";
            // write over the status file so that we can display a new status
            $af->WriteFile();
        }
        if ($cfg["enable_torrent_download"]) {
            $torrentfilelink = "<a href=\"maketorrent.php?download=" . urlencode($entry) . "\"><img src=\"images/down.gif\" width=9 height=9 title=\"Download Torrent File\" border=0 align=\"absmiddle\"></a>";
        }
        $hd = getStatusImage($af);
        $output .= "<tr><td class=\"tiny\"><img src=\"images/" . $hd->image . "\" width=16 height=16 title=\"" . $hd->title . $entry . "\" border=0 align=\"absmiddle\">" . $torrentfilelink . $displayname . "</td>";
        $output .= "<td align=\"right\"><font class=\"tiny\">" . formatBytesToKBMGGB($af->size) . "</font></td>";
        $output .= "<td align=\"center\"><a href=\"message.php?to_user=" . $torrentowner . "\"><font class=\"tiny\">" . $torrentowner . "</font></a></td>";
        $output .= "<td valign=\"bottom\"><div align=\"center\">";
        if ($af->running == "2") {
            $output .= "<i><font color=\"#32cd32\">" . _NEW . "</font></i>";
        } elseif ($af->running == "3") {
            $estTime = "Waiting...";
            $qDateTime = '';
//.........这里部分代码省略.........
开发者ID:aungthiha-richard,项目名称:torrentflux,代码行数:101,代码来源:functions.php

示例9: cliWipeTorrent

function cliWipeTorrent($torrent = "")
{
    global $cfg;
    if (isset($torrent) && $torrent != "") {
        echo "Wipe " . $torrent . " ...";
        $torrentRunningFlag = isTorrentRunning($torrent);
        $btclient = getTorrentClient($torrent);
        $cfg["user"] = getOwner($torrent);
        $alias = getAliasName($torrent) . ".stat";
        if ($torrentRunningFlag == 1) {
            // stop torrent first
            $clientHandler = ClientHandler::getClientHandlerInstance($cfg, $btclient);
            $clientHandler->stopTorrentClient($torrent, $alias);
            // give the torrent some time to die
            sleep(6);
        }
        deleteTorrentData($torrent);
        resetTorrentTotals($torrent, true);
        echo "done\n";
    } else {
        printUsage();
    }
    exit;
}
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:24,代码来源:fluxcli.php

示例10: prepareStartTorrentClient


//.........这里部分代码省略.........
         if ($this->maxuploads == '') {
             $this->maxuploads = $this->cfg["max_uploads"];
         }
         if ($this->minport == '') {
             $this->minport = $this->cfg["minport"];
         }
         if ($this->maxport == '') {
             $this->maxport = $this->cfg["maxport"];
         }
         if ($this->maxcons == '') {
             $this->maxcons = $this->cfg["maxcons"];
         }
         if ($this->sharekill == '') {
             $this->sharekill = $this->cfg["sharekill"];
         }
     }
     // queue
     if ($this->cfg["AllowQueing"]) {
         if (IsAdmin()) {
             $this->queue = getRequestVar('queue');
             if ($this->queue == 'on') {
                 $this->queue = "1";
             } else {
                 $this->queue = "0";
             }
         } else {
             $this->queue = "1";
         }
     } else {
         $this->queue = "0";
     }
     //
     $this->torrent = urldecode($torrent);
     $this->alias = getAliasName($this->torrent);
     $this->owner = getOwner($this->torrent);
     if (empty($this->savepath)) {
         $this->savepath = $this->cfg['path'] . $this->owner . "/";
     }
     // ensure path has trailing slash
     $this->savepath = checkDirPathString($this->savepath);
     // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca
     // This is to help manage user downloads by their user names
     // if the user's path doesnt exist, create it
     if (!is_dir($this->cfg["path"] . "/" . $this->owner)) {
         if (is_writable($this->cfg["path"])) {
             mkdir($this->cfg["path"] . "/" . $this->owner, 0777);
         } else {
             AuditAction($this->cfg["constants"]["error"], "Error -- " . $this->cfg["path"] . " is not writable.");
             if (IsAdmin()) {
                 $this->status = -1;
                 header("location: admin.php?op=configSettings");
                 return;
             } else {
                 $this->status = -1;
                 $this->messages .= "Error. TorrentFlux settings are not correct (path is not writable) -- please contact an admin.";
             }
         }
     }
     // create AliasFile object and write out the stat file
     include_once "AliasFile.php";
     $this->af = AliasFile::getAliasFileInstance($this->cfg["torrent_file_path"] . $this->alias . ".stat", $this->owner, $this->cfg, $this->handlerName);
     //XFER: before a torrent start/restart save upload/download xfer to SQL
     $torrentTotals = getTorrentTotalsCurrent($this->torrent);
     saveXfer($this->owner, $torrentTotals["downtotal"] + 0, $torrentTotals["uptotal"] + 0);
     // update totals for this torrent
     updateTorrentTotals($this->torrent);
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:67,代码来源:ClientHandler.php

示例11: AuditAction

        AuditAction($cfg["constants"]["error"], $cfg["constants"]["file_upload"] . " :: " . $ext_msg . $file_name);
    }
}
// End File Upload
// if a file was set to be deleted then delete it
$delfile = SecurityClean(getRequestVar('delfile'));
if (!$delfile == '') {
    $alias_file = SecurityClean(getRequestVar('alias_file'));
    if ($cfg["user"] == getOwner($delfile) || IsAdmin()) {
        @unlink($cfg["torrent_file_path"] . $delfile);
        @unlink($cfg["torrent_file_path"] . $alias_file);
        // try to remove the QInfo if in case it was queued.
        @unlink($cfg["torrent_file_path"] . "queue/" . $alias_file . ".Qinfo");
        // try to remove the pid file
        @unlink($cfg["torrent_file_path"] . $alias_file . ".pid");
        @unlink($cfg["torrent_file_path"] . getAliasName($delfile) . ".prio");
        AuditAction($cfg["constants"]["delete_torrent"], $delfile);
        header("location: index.php");
        exit;
    } else {
        AuditAction($cfg["constants"]["error"], $cfg["user"] . " attempted to delete " . $delfile);
    }
}
// Did the user select the option to kill a running torrent?
$kill = getRequestVar('kill');
if (!$kill == '' && is_numeric($kill)) {
    include_once "AliasFile.php";
    include_once "RunningTorrent.php";
    $kill_torrent = getRequestVar('kill_torrent');
    $alias_file = SecurityClean(getRequestVar('alias_file'));
    // We are going to write a '0' on the front of the stat file so that
开发者ID:aungthiha-richard,项目名称:torrentflux,代码行数:31,代码来源:index.php

示例12: sendRss

function sendRss()
{
    global $cfg, $sendAsAttachment, $arList;
    $content = "";
    $run = 0;
    // build content
    $content .= "<?xml version='1.0' ?>\n\n";
    //$content .= '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">'."\n";
    $content .= "<rss version=\"0.91\">\n";
    $content .= "<channel>\n";
    $content .= "<title>TorrentFlux Status</title>\n";
    // transfer-list
    foreach ($arList as $entry) {
        $torrentowner = getOwner($entry);
        $torrentTotals = getTorrentTotals($entry);
        // alias / stat
        $alias = getAliasName($entry) . ".stat";
        if (substr(strtolower($entry), -8) == ".torrent") {
            // this is a torrent-client
            $btclient = getTorrentClient($entry);
            $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias, $torrentowner, $cfg, $btclient);
        } else {
            if (substr(strtolower($entry), -4) == ".url") {
                // this is wget. use tornado statfile
                $alias = str_replace(".url", "", $alias);
                $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias, $cfg['user'], $cfg, 'tornado');
            } else {
                // this is "something else". use tornado statfile as default
                $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias, $cfg['user'], $cfg, 'tornado');
            }
        }
        // increment the totals
        if (!isset($cfg["total_upload"])) {
            $cfg["total_upload"] = 0;
        }
        if (!isset($cfg["total_download"])) {
            $cfg["total_download"] = 0;
        }
        $cfg["total_upload"] = $cfg["total_upload"] + GetSpeedValue($af->up_speed);
        $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($af->down_speed);
        // xml-string
        $remaining = str_replace('&#8734', 'Unknown', $af->time_left);
        if ($af->running == 1) {
            $run++;
        } else {
            $remaining = "Torrent Not Running";
        }
        $sharing = number_format($torrentTotals['uptotal'] / ($af->size + 0), 2);
        $content .= "<item>\n";
        $content .= "<title>" . $entry . " (" . $remaining . ")</title>\n";
        $content .= "<description>Down Speed: " . $af->down_speed . " || Up Speed: " . $af->up_speed . " || Size: " . @formatBytesToKBMGGB($af->size) . " || Percent: " . $af->percent_done . " || Sharing: " . $sharing . " || Remaining: " . $remaining . " || Transfered Down: " . @formatBytesToKBMGGB($torrentTotals['downtotal']) . " || Transfered Up: " . @formatBytesToKBMGGB($torrentTotals['uptotal']) . "</description>\n";
        $content .= "</item>\n";
    }
    $content .= "<item>\n";
    $content .= "<title>Total (" . $run . ")</title>\n";
    $content .= "<description>Down Speed: " . @number_format($cfg["total_download"], 2) . " || Up Speed: " . @number_format($cfg["total_upload"], 2) . " || Free Space: " . @formatFreeSpace($cfg['free_space']) . "</description>\n";
    $content .= "</item>\n";
    $content .= "</channel>\n";
    $content .= "</rss>";
    // send content
    header("Cache-Control: ");
    header("Pragma: ");
    header("Content-Type: text/xml");
    if ($sendAsAttachment != 0) {
        header("Content-Length: " . strlen($content));
        header('Content-Disposition: attachment; filename="stats.xml"');
    }
    echo $content;
}
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:69,代码来源:stats.php

示例13: getTorrentTransferTotal

 /**
  * gets total transfer-vals of a torrent
  *
  * @param $torrent
  * @return array with downtotal and uptotal
  */
 function getTorrentTransferTotal($torrent)
 {
     global $db;
     $retVal = array();
     // transfer from db
     $torrentId = getTorrentHash($torrent);
     $sql = "SELECT uptotal,downtotal FROM tf_torrent_totals WHERE tid = '" . $torrentId . "'";
     $result = $db->Execute($sql);
     showError($db, $sql);
     $row = $result->FetchRow();
     if (!empty($row)) {
         $retVal["uptotal"] = $row["uptotal"];
         $retVal["downtotal"] = $row["downtotal"];
     } else {
         $retVal["uptotal"] = 0;
         $retVal["downtotal"] = 0;
     }
     // transfer from stat-file
     $aliasName = getAliasName($torrent);
     $owner = getOwner($torrent);
     $af = AliasFile::getAliasFileInstance($this->cfg["torrent_file_path"] . $aliasName . ".stat", $owner, $this->cfg, $this->handlerName);
     $retVal["uptotal"] += $af->uptotal + 0;
     $retVal["downtotal"] += $af->downtotal + 0;
     return $retVal;
 }
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:31,代码来源:ClientHandler.tornado.php

示例14: prepareStartTorrentClient


//.........这里部分代码省略.........
         if ($this->maxuploads == '') {
             $this->maxuploads = $this->cfg["max_uploads"];
         }
         if ($this->minport == '') {
             $this->minport = $this->cfg["minport"];
         }
         if ($this->maxport == '') {
             $this->maxport = $this->cfg["maxport"];
         }
         if ($this->maxcons == '') {
             $this->maxcons = $this->cfg["maxcons"];
         }
         if ($this->sharekill == '') {
             $this->sharekill = $this->cfg["sharekill"];
         }
     }
     // queue
     if ($this->cfg["AllowQueing"]) {
         if (IsAdmin()) {
             $this->queue = getRequestVar('queue');
             if ($this->queue == 'on') {
                 $this->queue = "1";
             } else {
                 $this->queue = "0";
             }
         } else {
             $this->queue = "1";
         }
     } else {
         $this->queue = "0";
     }
     //
     $this->torrent = urldecode($torrent);
     $this->alias = getAliasName($this->torrent);
     $this->owner = getOwner($this->torrent);
     if (empty($this->savepath)) {
         $this->savepath = $this->cfg['path'] . $this->owner . "/";
     }
     // ensure path has trailing slash
     $this->savepath = checkDirPathString($this->savepath);
     // check target-directory, create if not present
     if (!checkDirectory($this->savepath, 0777)) {
         AuditAction($this->cfg["constants"]["error"], "Error checking " . $this->savepath . ".");
         $this->state = -1;
         $this->messages .= "Error. TorrentFlux settings are not correct (path-setting).";
         global $argv;
         if (isset($argv)) {
             die($this->messages);
         } else {
             if (IsAdmin()) {
                 @header("location: admin.php?op=configSettings");
                 exit;
             } else {
                 $this->messages .= " please contact an admin.";
                 showErrorPage($this->messages);
             }
         }
     }
     // create AliasFile object and write out the stat file
     include_once "AliasFile.php";
     $this->af = AliasFile::getAliasFileInstance($this->cfg["torrent_file_path"] . $this->alias . ".stat", $this->owner, $this->cfg, $this->handlerName);
     // set param for sharekill
     $this->sharekill = intval($this->sharekill);
     if ($this->sharekill == 0) {
         // nice, we seed forever
         $this->sharekill_param = 0;
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:67,代码来源:ClientHandler.php

示例15: showMetaInfo

function showMetaInfo($torrent, $allowSave = false)
{
    global $cfg;
    if (empty($torrent) || !file_exists($cfg["torrent_file_path"] . $torrent)) {
        echo _NORECORDSFOUND;
    } elseif ($cfg["enable_file_priority"]) {
        $prioFileName = $cfg["torrent_file_path"] . getAliasName($torrent) . ".prio";
        require_once 'BDecode.php';
        echo '<link rel="StyleSheet" href="dtree.css" type="text/css" /><script type="text/javascript" src="dtree.js"></script>';
        $ftorrent = $cfg["torrent_file_path"] . $torrent;
        $fp = fopen($ftorrent, "rd");
        if (!$fp) {
            // Not able to open file
            echo _NORECORDSFOUND;
        } else {
            $alltorrent = fread($fp, filesize($ftorrent));
            fclose($fp);
            $btmeta = BDecode($alltorrent);
            $torrent_size = $btmeta["info"]["piece length"] * (strlen($btmeta["info"]["pieces"]) / 20);
            if (array_key_exists('files', $btmeta['info'])) {
                $dirnum = count($btmeta['info']['files']);
            } else {
                $dirnum = 0;
            }
            if (is_readable($prioFileName)) {
                $prio = split(',', file_get_contents($prioFileName));
                $prio = array_splice($prio, 1);
            } else {
                $prio = array();
                for ($i = 0; $i < $dirnum; $i++) {
                    $prio[$i] = -1;
                }
            }
            $tree = new dir("/", $dirnum, isset($prio[$dirnum]) ? $prio[$dirnum] : -1);
            if (array_key_exists('files', $btmeta['info'])) {
                foreach ($btmeta['info']['files'] as $filenum => $file) {
                    $depth = count($file['path']);
                    $branch =& $tree;
                    for ($i = 0; $i < $depth; $i++) {
                        if ($i != $depth - 1) {
                            $d =& $branch->findDir($file['path'][$i]);
                            if ($d) {
                                $branch =& $d;
                            } else {
                                $dirnum++;
                                $d =& $branch->addDir(new dir($file['path'][$i], $dirnum, isset($prio[$dirnum]) ? $prio[$dirnum] : -1));
                                $branch =& $d;
                            }
                        } else {
                            $branch->addFile(new file($file['path'][$i] . " (" . $file['length'] . ")", $filenum, $file['length'], $prio[$filenum]));
                        }
                    }
                }
            }
            echo "<table><tr>";
            echo "<tr><td width=\"110\">Metainfo File:</td><td>" . $torrent . "</td></tr>";
            echo "<tr><td>Directory Name:</td><td>" . htmlentities($btmeta['info']['name'], ENT_QUOTES) . "</td></tr>";
            echo "<tr><td>Announce URL:</td><td>" . htmlentities($btmeta['announce'], ENT_QUOTES) . "</td></tr>";
            if (array_key_exists('comment', $btmeta)) {
                echo "<tr><td valign=\"top\">Comment:</td><td>" . htmlentities($btmeta['comment'], ENT_QUOTES) . "</td></tr>";
            }
            echo "<tr><td>Created:</td><td>" . date("F j, Y, g:i a", $btmeta['creation date']) . "</td></tr>";
            echo "<tr><td>Torrent Size:</td><td>" . $torrent_size . " (" . formatBytesToKBMGGB($torrent_size) . ")</td></tr>";
            echo "<tr><td>Chunk size:</td><td>" . $btmeta['info']['piece length'] . " (" . formatBytesToKBMGGB($btmeta['info']['piece length']) . ")</td></tr>";
            if (array_key_exists('files', $btmeta['info'])) {
                echo "<tr><td>Selected size:</td><td id=\"sel\">0</td></tr>";
                echo "</table><br>\n";
                if ($allowSave) {
                    echo "<form name=\"priority\" action=\"index.php\" method=\"POST\" >";
                    echo "<input type=\"hidden\" name=\"torrent\" value=\"" . $torrent . "\" >";
                    echo "<input type=\"hidden\" name=\"setPriorityOnly\" value=\"true\" >";
                }
                echo "<script type=\"text/javascript\">\n";
                echo "var sel = 0;\n";
                echo "d = new dTree('d');\n";
                $tree->draw(-1);
                echo "document.write(d);\n";
                echo "sel = getSizes();\n";
                echo "drawSel();\n";
                echo "</script>\n";
                echo "<input type=\"hidden\" name=\"filecount\" value=\"" . count($btmeta['info']['files']) . "\">";
                echo "<input type=\"hidden\" name=\"count\" value=\"" . $dirnum . "\">";
                echo "<br>";
                if ($allowSave) {
                    echo '<input type="submit" value="Save" >';
                    echo "<br>";
                }
                echo "</form>";
            } else {
                echo "</table><br>";
                echo htmlentities($btmeta['info']['name'] . $torrent_size . " (" . formatBytesToKBMGGB($torrent_size) . ")", ENT_QUOTES);
            }
        }
    } else {
        $result = shell_exec("cd " . $cfg["torrent_file_path"] . "; " . $cfg["pythonCmd"] . " -OO " . $cfg["btshowmetainfo"] . " " . escapeshellarg($torrent));
        echo "<pre>";
        echo htmlentities($result, ENT_QUOTES);
        echo "</pre>";
    }
}
开发者ID:aungthiha-richard,项目名称:torrentflux,代码行数:100,代码来源:metaInfo.php


注:本文中的getAliasName函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。