/** * set sharekill of a transfer * * @param $transfer * @param $sharekill * @param $autosend * @return boolean */ function setSharekill($transfer, $sharekill, $autosend = false) { // set sharekill $this->sharekill = intval($sharekill); // recalc sharekill if ($this->_recalcSharekill() === false) { return false; } // add command CommandHandler::add($transfer, "s" . $this->sharekill_param); // send command to client if ($autosend) { CommandHandler::send($transfer); } // return return true; }
/** * set download rate of a transfer * * @param $transfer * @param $downrate * @param $autosend */ function setRateDownload($transfer, $downrate, $autosend = false) { // set rate-field $this->drate = $downrate; // add command CommandHandler::add($transfer, "d" . $downrate); // send command to client if ($autosend) { CommandHandler::send($transfer); } }
/** * set sharekill of a transfer * * @param $transfer * @param $sharekill * @param $autosend * @return boolean */ function setSharekill($transfer, $sharekill, $autosend = false) { // set sharekill $this->sharekill = $sharekill; // add command CommandHandler::add($transfer, "s" . $this->sharekill); // send command to client if ($autosend) { CommandHandler::send($transfer); } // return return true; }
/** * stop a client * * @param $kill kill-param (optional) * @param $transferPid transfer Pid (optional) */ function _stop($kill = false, $transferPid = 0) { global $cfg; // log AuditAction($cfg["constants"]["stop_transfer"], $this->transfer); // send quit-command to client CommandHandler::add($this->transfer, "q"); CommandHandler::send($this->transfer); // wait until transfer is down waitForTransfer($this->transfer, false, 25); // one more second sleep(1); // flag the transfer as stopped (in db) stopTransferSettings($this->transfer); // set transfers-cache cacheTransfersSet(); // see if the transfer process is hung. $running = $this->runningProcesses(); $isHung = false; foreach ($running as $rng) { $rt = RunningTransfer::getInstance($rng['pinfo'], $this->client); if ($rt->transferFile == $this->transfer) { $isHung = true; AuditAction($cfg["constants"]["error"], "Possible Hung Process for " . $rt->transferFile . " (" . $rt->processId . ")"); } } // kill-request if ($kill && $isHung) { AuditAction($cfg["constants"]["kill_transfer"], $this->transfer); // set pid if (!empty($transferPid)) { // test for valid pid-var if (preg_match('/^[0-9]+$/D', $transferPid)) { $this->pid = $transferPid; } else { $this->state = CLIENTHANDLER_STATE_ERROR; AuditAction($cfg["constants"]["error"], "INVALID PID: " . $transferPid); array_push($this->messages, "INVALID PID: " . $transferPid); return false; } } else { $this->pid = getTransferPid($this->transfer); } // kill it require_once 'inc/defines/defines.signals.php'; if ($this->pid > 0) { $this->callResult = posix_kill($this->pid, SIGKILL); } // try to remove the pid file @unlink($this->transferFilePath . ".pid"); } }