public function getTorrents($rss, $url, $isStart, $isAddPath, $directory, $label, $throttle, $ratio, $needFlush = true) { $thash = 'Failed'; $ret = $rss->getTorrent($url); if ($ret !== false) { $addition = array(); if (!empty($throttle)) { $addition[] = getCmd("d.set_throttle_name=") . $throttle; } if (!empty($ratio)) { $addition[] = getCmd("view.set_visible=") . $ratio; } global $saveUploadedTorrents; $thash = $ret === 'magnet' ? rTorrent::sendMagnet($url, $isStart, $isAddPath, $directory, $label, $addition) : rTorrent::sendTorrent($ret, $isStart, $isAddPath, $directory, $label, $saveUploadedTorrents, false, true, $addition); if ($thash === false) { $thash = 'Failed'; @unlink($ret); $ret = false; } } if ($ret === false) { $this->rssList->addError("theUILang.rssCantLoadTorrent", $url); } $this->history->add($url, $thash, $rss->getItemTimestamp($url)); if ($needFlush) { $this->saveHistory(); } }
public function getTorrents($engs, $urls, $isStart, $isAddPath, $directory, $label, $fast) { $ret = array(); $history = self::loadHistory(); for ($i = 0; $i < count($urls); $i++) { $url = $urls[$i]; $success = false; if (strpos($url, "magnet:") === 0) { if ($success = rTorrent::sendMagnet($url, $isStart, $isAddPath, $directory, $label)) { $history->add($url, $success); } } else { $object = $this->getObject($engs[$i]); $torrent = $object->getTorrent($url, $object); if ($torrent !== false) { global $saveUploadedTorrents; if (($success = rTorrent::sendTorrent($torrent, $isStart, $isAddPath, $directory, $label, $saveUploadedTorrents, $fast)) === false) { @unlink($torrent); } else { $history->add($url, $success); } } } $ret[] = $success; } self::saveHistory($history); return $ret; }
} foreach ($files as $file) { $ufile = $file['name']; if (pathinfo($ufile, PATHINFO_EXTENSION) != "torrent") { $ufile .= ".torrent"; } $ufile = getUniqueUploadedFilename($ufile); $ok = move_uploaded_file($file['tmp_name'], $ufile); $uploaded_files[] = array('name' => $file['name'], 'file' => $ufile, 'status' => $ok ? "Success" : "Failed"); } } else { if (isset($_REQUEST['url'])) { $url = trim($_REQUEST['url']); $uploaded_url = array('name' => $url, 'status' => "Failed"); if (strpos($url, "magnet:") === 0) { $uploaded_url['status'] = rTorrent::sendMagnet($url, !isset($_REQUEST['torrents_start_stopped']), !isset($_REQUEST['not_add_path']), $dir_edit, $label) ? "Success" : "Failed"; } else { $cli = new Snoopy(); if (@$cli->fetchComplex($url) && $cli->status >= 200 && $cli->status < 300) { $name = $cli->get_filename(); if ($name === false) { $name = md5($url) . ".torrent"; } $name = getUniqueUploadedFilename($name); $f = @fopen($name, "w"); if ($f !== false) { @fwrite($f, $cli->results, strlen($cli->results)); fclose($f); $uploaded_url['file'] = $name; $uploaded_url['status'] = "Success"; }