/** * set sharekill of a transfer * * @param $transfer * @param $sharekill numeric (100 = 100%) * @param $autosend * @return boolean */ function setSharekill($transfer, $sharekill, $autosend = false) { // set sharekill $this->sharekill = round(floatval($sharekill) / 100, 2); $result = true; $msg = "{$sharekill}, autosend=" . serialize($autosend); if ($autosend) { $rpc = Transmission::getInstance(); if (isHash($transfer)) { $hash = $transfer; } else { $hash = getTransferHash($transfer); } $tid = getTransmissionTransferIdByHash($hash); if ($tid > 0) { $req = $rpc->set($tid, array('seedRatioLimit' => $this->sharekill, 'seedRatioMode' => 1)); if (!isset($req['result']) || $req['result'] != 'success') { $msg = $req['result']; $result = false; } else { //Check if setting is applied $req = $rpc->get($tid, array('seedRatioLimit')); if (!isset($req['result']) || $req['result'] != 'success') { $msg = $req['result']; $result = false; } elseif (!empty($req['arguments']['torrents'])) { $torrent = array_pop($req['arguments']['torrents']); if (round($torrent['seedRatioLimit'], 2) != round($this->sharekill, 2)) { // $msg = "sharekill not set correctly ".serialize($torrent->seedRatioLimit); //if fact, we always need to set it globally (vuze limitation) if (getTransmissionShareKill() < (int) $sharekill) { $msg = "sharekill set by session " . round($this->sharekill, 2); $req = $rpc->session_set(array('seedRatioLimit' => $this->sharekill)); } } } } } else { $msg = "bad tid {$hash} {$transfer} " . $req['result']; } $this->logMessage("setSharekill : " . $msg . "\n", true); } global $cfg; if ($cfg['debuglevel'] > 0) { AuditAction($cfg["constants"]["debug"], $this->client . "-setSharekill : {$msg}."); } return $result; }
/** * This method deletes the Transmission transfer with the matching hash, without removing the data * * @return void * TODO: test delete :) */ function deleteTransmissionTransfer($uid, $hash, $deleteData = false) { require_once 'inc/classes/Transmission.class.php'; $rpc = Transmission::getInstance(); if (isValidTransmissionTransfer($uid, $hash)) { $transmissionId = getTransmissionTransferIdByHash($hash); $response = $rpc->remove($transmissionId, $deleteData); if ($response['result'] != "success") { rpc_error("Delete failed", "", "", $response['result']); } } deleteTransmissionTransferFromDB($uid, $hash); }