Пример #1
0
 public static function makeClient($url, $method = "GET", $content_type = "", $body = "")
 {
     $client = new Snoopy();
     $client->read_timeout = 5;
     $client->_fp_timeout = 5;
     @$client->fetchComplex($url, $method, $content_type, $body);
     return $client;
 }
Пример #2
0
    $tracker = rawurldecode($_REQUEST["tracker"]);
    $name = dirname(__FILE__) . "/trackers/" . $tracker . ".png";
    if (is_readable($name)) {
        sendFile($name, "image/png");
        exit;
    }
    $name = getSettingsPath() . '/trackers';
    if (!is_dir($name)) {
        makeDirectory($name);
    }
    $name .= '/';
    if (strlen($tracker)) {
        $name .= $tracker;
        $name .= '.ico';
        if (!is_readable($name)) {
            $url = Snoopy::linkencode("http://" . $tracker . "/favicon.ico");
            $client = new Snoopy();
            @$client->fetchComplex($url);
            if ($client->status == 200) {
                file_put_contents($name, $client->results);
            }
        }
        if (is_readable($name)) {
            sendFile($name, "image/x-icon");
            exit;
        }
    }
}
header("HTTP/1.0 302 Moved Temporarily");
header("Location: " . dirname($_SERVER['PHP_SELF']) . '/trackers/unknown.png');
exit;
Пример #3
0
 protected static function fetchURL($url, $cookies = null, $headers = null)
 {
     $client = new Snoopy();
     if (is_array($headers) && count($headers)) {
         $client->rawheaders = $headers;
     }
     if (is_array($cookies) && count($cookies)) {
         $client->cookies = $cookies;
     }
     @$client->fetchComplex($url);
     return $client;
 }
Пример #4
0
         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";
                 }
             } else {
                 $uploaded_url['status'] = "FailedURL";
             }