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


PHP getTransferHash函数代码示例

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


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

示例1: getVuzeTransferRpcId

/**
 * get Vuze RPC torrent id (use it temporary, dont store it)
 *
 * @param $transfer
 * @return int
 */
function getVuzeTransferRpcId($transfer)
{
    global $cfg;
    require_once 'inc/classes/VuzeRPC.php';
    $rpc = VuzeRPC::getInstance();
    $hash = getTransferHash($transfer);
    $torrents = $rpc->torrent_get_hashids();
    $tid = false;
    if (array_key_exists(strtoupper($hash), $torrents)) {
        $tid = $torrents[strtoupper($hash)];
    }
    return $tid;
}
开发者ID:ThYpHo0n,项目名称:torrentflux,代码行数:19,代码来源:functions.rpc.vuze.php

示例2: getTorrentScrapeInfo

/**
 * gets scrape-info of a torrent as string
 *
 * @param $transfer name of the torrent
 * @return string with torrent-scrape-info
 */
function getTorrentScrapeInfo($transfer)
{
    global $cfg;
    $hasClient = false;
    // transmissioncli
    if (!$cfg["transmission_rpc_enable"]) {
        $hasClient = true;
        $retVal = "";
        $retVal = @shell_exec("HOME=" . tfb_shellencode($cfg["path"]) . "; export HOME; " . $cfg["btclient_transmission_bin"] . " -s " . tfb_shellencode($cfg["transfer_file_path"] . $transfer));
        if (isset($retVal) && $retVal != "" && !preg_match('/.*failed.*/i', $retVal)) {
            return trim($retVal);
        }
    } else {
        require_once 'inc/functions/functions.transfer.php';
        require_once 'inc/functions/functions.rpc.transmission.php';
        if (isHash($transfer)) {
            $hash = $transfer;
        } else {
            $hash = getTransferHash($transfer);
        }
        $a = getTransmissionTransfer($hash, array("trackerStats"));
        if (!empty($a['trackerStats'])) {
            $stats = $a['trackerStats'][0];
            return $stats['seederCount'] . ' seeder(s), ' . $stats['leecherCount'] . ' leecher(s).' . "\n";
        }
    }
    // ttools.pl
    if (is_executable($cfg["perlCmd"])) {
        $hasClient = true;
        $retVal = "";
        $retVal = @shell_exec($cfg["perlCmd"] . ' -I ' . tfb_shellencode($cfg["docroot"] . 'bin/ttools') . ' ' . tfb_shellencode($cfg["docroot"] . 'bin/ttools/ttools.pl') . ' -s ' . tfb_shellencode($cfg["transfer_file_path"] . $transfer));
        if (isset($retVal) && $retVal != "" && !preg_match('/.*failed.*/i', $retVal)) {
            return trim($retVal);
        }
    }
    // failed
    return $hasClient ? "Scrape failed" : "No Scrape-Client";
}
开发者ID:Ezerbeth,项目名称:torrentflux,代码行数:44,代码来源:functions.common.transfer.php

示例3: monitorTransfer

 /**
  * gets current status of one Transfer (realtime)
  * for transferStat popup
  *
  * @return array (stat) or Error String
  */
 function monitorTransfer($transfer, $format = "rpc")
 {
     //by default, monitoring not available.
     // set vars
     $this->_setVarsForTransfer($transfer);
     if (isHash($transfer)) {
         $hash = $transfer;
     } else {
         $hash = getTransferHash($transfer);
     }
     if (empty($hash)) {
         return "Hash for {$transfer} was not found";
     }
     //original rpc format, you can add fields here
     $fields = array('id', 'name', 'status', 'hashString', 'totalSize', 'downloadedEver', 'uploadedEver', 'percentDone', 'uploadRatio', 'peersConnected', 'peersGettingFromUs', 'peersSendingToUs', 'rateDownload', 'rateUpload', 'downloadLimit', 'uploadLimit', 'downloadLimited', 'uploadLimited', 'seedRatioLimit', 'seedRatioMode', 'downloadDir', 'eta', 'error', 'errorString');
     $stat_rpc = getTransmissionTransfer($hash, $fields);
     $rpc = Transmission::getInstance();
     if (is_array($stat_rpc)) {
         if ($format == "rpc") {
             return $stat_rpc;
         } else {
             return $rpc->rpc_to_tf($stat_rpc);
         }
     }
     return $rpc->lastError;
 }
开发者ID:mladenb,项目名称:torrentflux,代码行数:32,代码来源:ClientHandler.transmissionrpc.php

示例4: tmplInitializeInstance

    @header("location: ../../index.php");
    exit;
}
/******************************************************************************/
// transfer functions
require_once 'inc/functions/functions.transfer.php';
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.transferHosts.tmpl");
// init transfer
transfer_init();
$isTransmissionTransfer = false;
if ($cfg["transmission_rpc_enable"] > 0) {
    if (isHash($transfer)) {
        $hash = $transfer;
    } else {
        $hash = getTransferHash($transfer);
    }
    require_once 'inc/functions/functions.rpc.transmission.php';
    $isTransmissionTransfer = isTransmissionTransfer($hash);
    if (!$isTransmissionTransfer && $cfg["transmission_rpc_enable"] == 1) {
        $isTransmissionTransfer = getTransferClient($transfer) == 'transmissionrpc';
    }
}
$list_host = array();
if ($isTransmissionTransfer) {
    $options = array('peers');
    $transfer = getTransmissionTransfer($hash, $options);
    $isRunning = true;
    //TODO make this actually determine if the torrent is running
    if ($isRunning) {
        foreach ($transfer['peers'] as $peer) {
开发者ID:Ezerbeth,项目名称:torrentflux,代码行数:31,代码来源:transferHosts.php

示例5: _maintenanceDatabase

 /**
  * _maintenanceDatabase
  */
 function _maintenanceDatabase()
 {
     global $cfg, $db;
     // output
     $this->_outputMessage("database-maintenance...\n");
     /* tf_transfers */
     $this->_countProblems = 0;
     $this->_countFixed = 0;
     // output
     $this->_outputMessage("table-maintenance : tf_transfers\n");
     // running-flag
     $sql = "SELECT transfer FROM tf_transfers WHERE running = '1'";
     $recordset = $db->Execute($sql);
     if ($db->ErrorNo() != 0) {
         dbError($sql);
     }
     $rc = $recordset->RecordCount();
     if ($rc > 0) {
         while (list($tname) = $recordset->FetchRow()) {
             if (!isTransferRunning($tname)) {
                 $this->_countProblems++;
                 // t is not running, reset running-flag
                 $this->_outputMessage("reset of running-flag for transfer which is not running : " . $tname . "\n");
                 $sql = "UPDATE tf_transfers SET running = '0' WHERE transfer = " . $db->qstr($tname);
                 $db->Execute($sql);
                 $this->_countFixed++;
                 // output
                 $this->_outputMessage("done.\n");
             }
         }
     }
     // empty hash
     $sql = "SELECT transfer FROM tf_transfers WHERE hash = ''";
     $recordset = $db->Execute($sql);
     if ($db->ErrorNo() != 0) {
         dbError($sql);
     }
     $rc = $recordset->RecordCount();
     if ($rc > 0) {
         $this->_countProblems += $rc;
         while (list($tname) = $recordset->FetchRow()) {
             // t has no hash, update
             $this->_outputMessage("updating transfer which has empty hash : " . $tname . "\n");
             // get hash
             $thash = getTransferHash($tname);
             // update
             if (!empty($thash)) {
                 $sql = "UPDATE tf_transfers SET hash = " . $db->qstr($thash) . " WHERE transfer = " . $db->qstr($tname);
                 $db->Execute($sql);
                 $this->_countFixed++;
                 // output
                 $this->_outputMessage("done.\n");
             }
         }
     }
     // empty datapath
     $sql = "SELECT transfer FROM tf_transfers WHERE datapath = ''";
     $recordset = $db->Execute($sql);
     if ($db->ErrorNo() != 0) {
         dbError($sql);
     }
     $rc = $recordset->RecordCount();
     if ($rc > 0) {
         $this->_countProblems += $rc;
         while (list($tname) = $recordset->FetchRow()) {
             // t has no datapath, update
             $this->_outputMessage("updating transfer which has empty datapath : " . $tname . "\n");
             // get datapath
             $tDatapath = getTransferDatapath($tname);
             // update
             if ($tDatapath != "") {
                 $sql = "UPDATE tf_transfers SET datapath = " . $db->qstr($tDatapath) . " WHERE transfer = " . $db->qstr($tname);
                 $db->Execute($sql);
                 $this->_countFixed++;
                 // output
                 $this->_outputMessage("done.\n");
             } else {
                 // output
                 $this->_outputMessage("cannot get datapath for " . $tname . ".\n");
             }
         }
     }
     // output + log
     if ($this->_countProblems == 0) {
         // output
         $this->_outputMessage("no problems found.\n");
     } else {
         // DEBUG : log
         $msg = "found and fixed problems in tf_transfers : " . $this->_countFixed . "/" . $this->_countProblems;
         if ($cfg['debuglevel'] > 0) {
             AuditAction($cfg["constants"]["debug"], "database-maintenance : table-maintenance : " . $msg);
         }
         // output
         $this->_outputMessage($msg . "\n");
     }
     /* tf_transfer_totals */
     $this->_countProblems = 0;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:101,代码来源:MaintenanceAndRepair.php

示例6: sa_maintenance


//.........这里部分代码省略.........
                    }
                }
                closedir($dirHandle);
            }
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted stale PID files: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>No stale PID files found.<br><br>';
            }
            break;
        case "32":
            // Maintenance-Clean: tornado-clean
            $htmlTitle = "Maintenance - Clean - BitTornado";
            $htmlMain .= '<br><strong>Cleaning BitTornado cache:</strong><br>';
            $result = "";
            $result .= cleanDir($cfg["path"] . '.BitTornado/datacache');
            $result .= cleanDir($cfg["path"] . '.BitTornado/torrentcache');
            $result .= cleanDir($cfg["path"] . '.BitTornado/piececache');
            $result .= cleanDir($cfg["path"] . '.BitTornado/icons');
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted cache: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>Nothing found.<br><br>';
            }
            break;
        case "33":
            // Maintenance-Clean: transmission-clean
            $htmlTitle = "Maintenance - Clean - Transmission";
            $htmlMain .= '<br><strong>Cleaning Transmission cache:</strong><br>';
            $result = "";
            $hashes = array();
            $transferList = getTransferArray();
            foreach ($transferList as $transfer) {
                array_push($hashes, getTransferHash($transfer));
            }
            if ($dirHandle = @opendir($cfg["path"] . ".transmission/cache/")) {
                while (false !== ($file = readdir($dirHandle))) {
                    if ($file[0] == "r") {
                        $thash = substr($file, -40);
                        if (!in_array($thash, $hashes)) {
                            // torrent not in db. delete cache-file.
                            $result .= tfb_htmlencode($file) . "\n";
                            @unlink($cfg["path"] . ".transmission/cache/resume." . $thash);
                        }
                    }
                }
                closedir($dirHandle);
            }
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted cache: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>Nothing found.<br><br>';
            }
            break;
        case "34":
            // Maintenance-Clean: mainline-clean
            $htmlTitle = "Maintenance - Clean - BitTorrent Mainline";
            $htmlMain .= '<br><strong>Cleaning BitTorrent Mainline cache:</strong><br>';
            $result = "";
            $result .= cleanDir($cfg["path"] . '.bittorrent/console/resume');
            $result .= cleanDir($cfg["path"] . '.bittorrent/console/metainfo');
            $result .= cleanDir($cfg["path"] . '.bittorrent/console/torrents');
            $result .= cleanDir($cfg["path"] . '.bittorrent/mutex');
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted cache: <br><pre>' . $result . '</pre><br>';
            } else {
开发者ID:sulaweyo,项目名称:torrentflux-b4rt-php7,代码行数:67,代码来源:functions.superadmin.php

示例7: AuditAction

             $settingsAry['type'] = "wget";
             $settingsAry['client'] = "wget";
         } else {
             if (substr($transfer, -4) == ".nzb") {
                 // this is nzbperl.
                 $settingsAry['type'] = "nzb";
                 $settingsAry['client'] = "nzbperl";
             } else {
                 AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $transfer);
                 @error("Invalid Transfer", "", "", array($transfer));
             }
         }
     }
 }
 if (empty($settingsAry['hash'])) {
     $settingsAry['hash'] = getTransferHash($transfer);
     $transfers['settings'][$transfer] = $settingsAry;
 }
 if (empty($settingsAry['datapath'])) {
     $settingsAry["datapath"] = getTransferSavepath($transfer);
     $transfers['settings'][$transfer] = $settingsAry;
 }
 if (empty($settingsAry['savepath'])) {
     $settingsAry["savepath"] = getTransferSavepath($transfer);
     $transfers['settings'][$transfer] = $settingsAry;
 }
 if ($settingsAry["client"] == "") {
     // Fix FluAzu progression 100% (client to check, not set to "azureus", solved by mysql column enum to varchar ?)
     if (!$sf->seedlimit) {
         $sf->seedlimit = $settingsAry["sharekill"];
     }
开发者ID:Ezerbeth,项目名称:torrentflux,代码行数:31,代码来源:index.php

示例8: getTransferCurrent

 /**
  * gets current transfer-vals of a transfer
  *
  * @param $transfer
  * @return array with downtotal and uptotal
  */
 function getTransferCurrent($transfer)
 {
     global $db, $transfers;
     $retVal = array();
     // transfer from stat-file
     $sf = new StatFile($transfer);
     $retVal["uptotal"] = $sf->uptotal;
     $retVal["downtotal"] = $sf->downtotal;
     // transfer from db
     $torrentId = getTransferHash($transfer);
     $sql = "SELECT uptotal,downtotal FROM tf_transfer_totals WHERE tid = " . $db->qstr($torrentId);
     $result = $db->Execute($sql);
     $row = $result->FetchRow();
     if (!empty($row)) {
         $retVal["uptotal"] -= $row["uptotal"];
         $retVal["downtotal"] -= $row["downtotal"];
     }
     return $retVal;
 }
开发者ID:sulaweyo,项目名称:torrentflux-b4rt-php7,代码行数:25,代码来源:ClientHandler.azureus.php

示例9: changeOwner

/**
 * change torrent Owner (download same torrent again from another user)
 *
 * @param $transfer, $user
 * @return none
 */
function changeOwner($transfer, $user)
{
    global $cfg, $db, $transfers;
    $oldowner = getOwner($transfer);
    if ($oldowner != $user) {
        if (file_exists($cfg["transfer_file_path"] . $transfer . ".stat")) {
            $sf = new StatFile($transfer, $user);
            $sf->transferowner = $user;
            $sf->write();
        }
        $hash = getTransferHash($transfer);
        $uid = (int) GetUID($user);
        $sql = "INSERT INTO tf_transfer_totals(tid, uid, uptotal,downtotal) values (" . $db->qstr($hash) . "," . $uid . "," . "0,0" . ")";
        $result = $db->Execute($sql);
        if ($db->ErrorNo() != 0) {
            dbError($sql);
        }
        resetOwner($transfer);
    }
}
开发者ID:ThYpHo0n,项目名称:torrentflux,代码行数:26,代码来源:functions.core.transfer.php

示例10: getTransferCurrent

 /**
  * gets current transfer-vals of a transfer
  *
  * @param $transfer
  * @return array with downtotal and uptotal
  */
 function getTransferCurrent($transfer)
 {
     global $db, $transfers;
     $retVal = array();
     // set vars
     $this->_setVarsForTransfer($transfer);
     // transfer from stat-file
     $sf = new StatFile($transfer);
     $retVal["uptotal"] = $sf->uptotal;
     $retVal["downtotal"] = $sf->downtotal;
     // transfer from db
     $torrentId = getTransferHash($transfer);
     $uid = (int) GetUID($this->owner);
     $sql = "SELECT uptotal,downtotal FROM tf_transfer_totals WHERE tid = " . $db->qstr($torrentId) . " AND uid IN(0, {$uid}) ORDER BY uid DESC";
     $result = $db->Execute($sql);
     $row = $result->FetchRow();
     if (!empty($row)) {
         $retVal["uptotal"] -= $row["uptotal"];
         $retVal["downtotal"] -= $row["downtotal"];
     }
     return $retVal;
 }
开发者ID:Ezerbeth,项目名称:torrentflux,代码行数:28,代码来源:ClientHandler.azureus.php

示例11: settingsDefault

 /**
  * sets fields from default-vals
  *
  * @param $transfer
  */
 function settingsDefault($transfer = "")
 {
     global $cfg;
     // transfer vars
     if ($transfer != "") {
         $this->_setVarsForTransfer($transfer);
     }
     // common vars
     $this->hash = getTransferHash($this->transfer);
     $this->datapath = getTransferDatapath($this->transfer);
     $this->savepath = getTransferSavepath($this->transfer);
     $this->running = 0;
     $this->rate = 0;
     $this->drate = $cfg["nzbperl_rate"];
     $this->maxuploads = 1;
     $this->superseeder = 0;
     $this->runtime = "True";
     $this->sharekill = 0;
     $this->minport = 1;
     $this->maxport = 65535;
     $this->maxcons = $cfg["nzbperl_conn"];
     $this->rerequest = 1;
 }
开发者ID:ThYpHo0n,项目名称:torrentflux,代码行数:28,代码来源:ClientHandler.nzbperl.php

示例12: image_pieTransferPeers

/**
 * pieTransferPeers
 */
function image_pieTransferPeers()
{
    global $cfg;
    // transfer-id
    $transfer = tfb_getRequestVar('transfer');
    if (empty($transfer)) {
        Image::paintNoOp();
    }
    // validate transfer
    $validTransfer = false;
    if (isHash($transfer)) {
        $hash = $transfer;
    } else {
        $hash = getTransferHash($transfer);
    }
    if ($cfg["transmission_rpc_enable"]) {
        require_once 'inc/functions/functions.rpc.transmission.php';
        $options = array('trackerStats', 'peers');
        $transTransfer = getTransmissionTransfer($hash, $options);
        // false if not found; TODO check if transmission enabled
        if (is_array($transTransfer)) {
            $validTransfer = true;
            $client = "transmissionrpc";
        }
    }
    if (!$validTransfer) {
        // If not found in transmission transfer
        if (tfb_isValidTransfer($transfer)) {
            // stat
            $sf = new StatFile($transfer);
            $seeds = trim($sf->seeds);
            $peers = trim($sf->peers);
            // client-switch + get peer-data
            $peerData = array();
            $peerData['seeds'] = 0;
            $peerData['peers'] = 0;
            $peerData['seedsLabel'] = $seeds != "" ? $seeds : 0;
            $peerData['peersLabel'] = $peers != "" ? $peers : 0;
            $client = getTransferClient($transfer);
            $validTransfer = true;
        }
    }
    if (!$validTransfer) {
        AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $transfer);
        Image::paintNoOp();
    }
    switch ($client) {
        case "tornado":
            if ($seeds != "") {
                if (strpos($seeds, "+") !== false) {
                    $seeds = preg_replace('/(\\d+)\\+.*/i', '${1}', $seeds);
                }
                if (is_numeric($seeds)) {
                    $peerData['seeds'] = $seeds;
                }
                $peerData['seedsLabel'] = $seeds;
            }
            if ($peers != "") {
                if (strpos($peers, "+") !== false) {
                    $peers = preg_replace('/(\\d+)\\+.*/i', '${1}', $peers);
                }
                if (is_numeric($peers)) {
                    $peerData['peers'] = $peers;
                }
                $peerData['peersLabel'] = $peers;
            }
            break;
        case "transmission":
        case "transmissionrpc":
            $peers = sizeof($transTransfer['peers']);
            $seeds = 0;
            foreach ($transTransfer['trackerStats'] as $tracker) {
                $seeds += $tracker['seederCount'] == -1 ? 0 : $tracker['seederCount'];
            }
            $peerData['seedsLabel'] = $seeds;
            $peerData['seeds'] = $seeds;
            $peerData['peersLabel'] = $peers;
            $peerData['peers'] = $peers;
            break;
        case "vuzerpc":
            if (empty($seeds) || empty($peers)) {
                $ch = ClientHandler::getInstance($client);
                $running = $ch->monitorRunningTransfers();
                $hash = strtoupper(getTransferHash($transfer));
                if (!empty($running[$hash])) {
                    $t = $running[$hash];
                    $peerData['seeds'] = $t['seeds'];
                    $peerData['seedsLabel'] = $t['seeds'];
                    $peerData['peers'] = $t['peers'];
                    $peerData['peersLabel'] = $t['peers'];
                }
            }
            break;
        case "azureus":
            if ($seeds != "") {
                if (strpos($seeds, "(") !== false) {
                    $seeds = preg_replace('/.*(\\d+) .*/i', '${1}', $seeds);
//.........这里部分代码省略.........
开发者ID:Ezerbeth,项目名称:torrentflux,代码行数:101,代码来源:functions.image.php

示例13: _updateTotals

 /**
  * updates totals of a transfer
  */
 function _updateTotals()
 {
     global $db;
     $tid = getTransferHash($this->transfer);
     $transferTotals = $this->getTransferTotal($this->transfer);
     $sql = $db->GetOne("SELECT 1 FROM tf_transfer_totals WHERE tid = " . $db->qstr($tid)) ? "UPDATE tf_transfer_totals SET uptotal = " . $db->qstr($transferTotals["uptotal"]) . ", downtotal = " . $db->qstr($transferTotals["downtotal"]) . " WHERE tid = " . $db->qstr($tid) : "INSERT INTO tf_transfer_totals (tid,uptotal,downtotal) VALUES (" . $db->qstr($tid) . "," . $db->qstr($transferTotals["uptotal"]) . "," . $db->qstr($transferTotals["downtotal"]) . ")";
     $db->Execute($sql);
     // set transfers-cache
     cacheTransfersSet();
 }
开发者ID:sulaweyo,项目名称:torrentflux-b4rt-php7,代码行数:13,代码来源:ClientHandler.php

示例14: resetTransferTotals

/**
 * resets totals of a transfer
 *
 * @param $transfer name of the transfer
 * @param $delete boolean if to delete meta-file
 * @return array
 */
function resetTransferTotals($transfer, $delete = false)
{
    global $cfg, $db, $transfers;
    $msgs = array();
    $tid = getTransferHash($transfer);
    // delete meta-file
    if ($delete) {
        $ch = ClientHandler::getInstance(getTransferClient($transfer));
        $ch->delete($transfer);
        if (count($ch->messages) > 0) {
            $msgs = array_merge($msgs, $ch->messages);
        }
    } else {
        // reset in stat-file
        $sf = new StatFile($transfer, getOwner($transfer));
        $sf->uptotal = 0;
        $sf->downtotal = 0;
        $sf->write();
    }
    // reset in db
    $sql = "DELETE FROM tf_transfer_totals WHERE tid = " . $db->qstr($tid);
    $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        dbError($sql);
    }
    // set transfers-cache
    cacheTransfersSet();
    return $msgs;
}
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:36,代码来源:functions.common.transfer.php

示例15: _maintenanceDatabase

 /**
  * _maintenanceDatabase
  */
 function _maintenanceDatabase()
 {
     global $cfg, $db;
     // output
     $this->_outputMessage("database-maintenance...\n");
     /* tf_transfers */
     $this->_countProblems = 0;
     $this->_countFixed = 0;
     // output
     $this->_outputMessage("table-maintenance : tf_transfers\n");
     // running-flag
     $sql = "SELECT transfer FROM tf_transfers WHERE running = '1'";
     $recordset = $db->Execute($sql);
     if ($db->ErrorNo() != 0) {
         dbError($sql);
     }
     $rc = $recordset->RecordCount();
     if ($rc > 0) {
         while (list($tname) = $recordset->FetchRow()) {
             if (!isTransferRunning($tname)) {
                 $this->_countProblems++;
                 // t is not running, reset running-flag
                 $this->_outputMessage("reset of running-flag for transfer which is not running : " . $tname . "\n");
                 $sql = "UPDATE tf_transfers SET running = '0' WHERE transfer = " . $db->qstr($tname);
                 $db->Execute($sql);
                 $this->_countFixed++;
                 // output
                 $this->_outputMessage("done.\n");
             }
         }
     }
     // empty hash
     $sql = "SELECT transfer FROM tf_transfers WHERE hash = ''";
     $recordset = $db->Execute($sql);
     if ($db->ErrorNo() != 0) {
         dbError($sql);
     }
     $rc = $recordset->RecordCount();
     if ($rc > 0) {
         $this->_countProblems += $rc;
         while (list($tname) = $recordset->FetchRow()) {
             // t has no hash, update
             $this->_outputMessage("updating transfer which has empty hash : " . $tname . "\n");
             // get hash
             $thash = getTransferHash($tname);
             // update
             if (!empty($thash)) {
                 $sql = "UPDATE tf_transfers SET hash = " . $db->qstr($thash) . " WHERE transfer = " . $db->qstr($tname);
                 $db->Execute($sql);
                 $this->_countFixed++;
                 // output
                 $this->_outputMessage("done.\n");
             }
         }
     }
     // empty datapath
     $sql = "SELECT transfer FROM tf_transfers WHERE datapath = ''";
     $recordset = $db->Execute($sql);
     if ($db->ErrorNo() != 0) {
         dbError($sql);
     }
     $rc = $recordset->RecordCount();
     if ($rc > 0) {
         $this->_countProblems += $rc;
         while (list($tname) = $recordset->FetchRow()) {
             // t has no datapath, update
             $this->_outputMessage("updating transfer which has empty datapath : " . $tname . "\n");
             // get datapath
             $tDatapath = getTransferDatapath($tname);
             // update
             if ($tDatapath != "") {
                 $sql = "UPDATE tf_transfers SET datapath = " . $db->qstr($tDatapath) . " WHERE transfer = " . $db->qstr($tname);
                 $db->Execute($sql);
                 $this->_countFixed++;
                 // output
                 $this->_outputMessage("done.\n");
             } else {
                 // output
                 $this->_outputMessage("cannot get datapath for " . $tname . ".\n");
             }
         }
     }
     // output + log
     if ($this->_countProblems == 0) {
         // output
         $this->_outputMessage("no problems found.\n");
     } else {
         // DEBUG : log
         $msg = "found and fixed problems in tf_transfers : " . $this->_countFixed . "/" . $this->_countProblems;
         if ($cfg['debuglevel'] > 0) {
             AuditAction($cfg["constants"]["debug"], "database-maintenance : table-maintenance : " . $msg);
         }
         // output
         $this->_outputMessage($msg . "\n");
     }
     /* tf_transfer_totals */
     $this->_countProblems = 0;
//.........这里部分代码省略.........
开发者ID:Ezerbeth,项目名称:torrentflux,代码行数:101,代码来源:MaintenanceAndRepair.php


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