/**
  * 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 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;
 }
                $ch->setRateUpload($transfer, $settingsNew['max_upload_rate']);
            }
            // upload-rate
            if ($settingsNew['max_download_rate'] != $settingsCurrent['max_download_rate']) {
                $ch->setRateDownload($transfer, $settingsNew['max_download_rate']);
            }
            // runtime
            if ($settingsNew['die_when_done'] != $settingsCurrent['die_when_done']) {
                $ch->setRuntime($transfer, $settingsNew['die_when_done']);
            }
            // sharekill
            if ($settingsNew['sharekill'] != $settingsCurrent['sharekill']) {
                $ch->setSharekill($transfer, $settingsNew['sharekill']);
            }
            // send command-buffer to client
            CommandHandler::send($transfer);
            // set message-var
            $tmpl->setvar('message', "settings saved + changes sent to client");
        } else {
            /* don't send changes or no changes to send */
            // set message-var
            $tmpl->setvar('message', "settings saved");
        }
    }
} else {
    /* display */
    // set save-var
    $tmpl->setvar('isSave', 0);
    // client-chooser
    if ($ch->type == "torrent") {
        $tmpl->setvar('enableClientChooser', 1);
 /**
  * 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);
     }
 }
 /**
  * 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");
     }
 }