コード例 #1
0
ファイル: hoster.default.php プロジェクト: TheFox/phpdl
function hosterExec($thisHoster, $packet, $packetDownloadDir, $file)
{
    global $CONFIG;
    $retval = '';
    $url = $file->get('uri');
    $filename = basename($url);
    #printd("hoster.default.php hosterExec '$url'\n");
    $file->save('size', wgetHeaderSize($url, $packet->get('httpUser'), $packet->get('httpPassword')));
    $tmpfile = $packetDownloadDir . '/.' . $filename;
    wget($url, $tmpfile, null, $packet->get('httpUser'), $packet->get('httpPassword'));
    $error = 0;
    if (file_exists($tmpfile)) {
        $size = filesize($tmpfile);
        $newfilePath = $packetDownloadDir . '/' . $filename;
        rename($tmpfile, $newfilePath);
        if (file_exists($newfilePath)) {
            $retval = $newfilePath;
        }
        if ($error) {
            $retval = (int) $error;
        }
    }
    return $retval;
}
コード例 #2
0
function hosterExec($thisHoster, $packet, $packetDownloadDir, $file)
{
    global $CONFIG;
    $retval = '';
    $rapidpro = $thisHoster['user'] != '' && $thisHoster['password'] != '';
    print "hoster.rapidshare-com.php hosterExec '" . $file->get('uri') . "'\n";
    if (preg_match('/files\\/([^\\/]*)\\/(.*)/i', $file->get('uri'), $res)) {
        #var_export($res);
        $fileid = $res[1];
        $filename = $res[2];
        $protocol = 'http' . ($thisHoster['ssl'] && $rapidpro ? 's' : '');
        $path = "cgi-bin/rsapi.cgi?sub=download_v1&fileid={$fileid}&filename={$filename}&withmd5hex=1";
        if ($rapidpro) {
            $path .= "&login="******"&password="******"{$protocol}://api.rapidshare.com/{$path}";
        print "link '{$url}'\n";
        $tmp = './tmp/' . $filename . '.tmp';
        wget($url, $tmp);
        if (preg_match('/DL:([^,]*),([^,]*),([^,]*),(.*)/', file_get_contents($tmp), $res)) {
            $hostname = $res[1];
            $dlauth = $res[2];
            $countdown = (int) $res[3] + 5;
            $md5 = strtolower($res[4]);
            print "host: '{$hostname}'\n";
            print "auth: '{$dlauth}'\n";
            print "ct: '{$countdown}'\n";
            print "md5: '{$md5}'\n";
            $url = "{$protocol}://" . $hostname . "/{$path}";
            if (!$rapidpro) {
                $url .= "&dlauth=" . $dlauth;
                # lol
                # RS docu:
                #	Downloading as a free user: It IS allowed to create tools,
                #	which download ONE file as a free user from RapidShare.
                #	It is NOT allowed to implement queuing mechanisms.
                print "wait {$countdown}\n";
                sleep($countdown);
            }
            print "link '{$url}'\n";
            $file->set('size', wgetHeaderSize($url));
            $file->set('md5', $md5);
            $file->save();
            $tmpfile = $packetDownloadDir . '/.' . $filename;
            wget($url, $tmpfile);
            $error = 0;
            if (file_exists($tmpfile)) {
                $size = filesize($tmpfile);
                if ($size <= 10000) {
                    if (preg_match('/All free download slots are full/s', @file_get_contents($tmpfile))) {
                        $error = $DLFILE_ERROR['ERROR_NO_FREE_SLUTS'];
                    }
                }
                if ($md5 == strtolower(md5_file($tmpfile))) {
                    $file->save('md5Verified', 1);
                }
                $newfilePath = $packetDownloadDir . '/' . $filename;
                rename($tmpfile, $newfilePath);
                if (file_exists($newfilePath)) {
                    $retval = $newfilePath;
                }
            }
            if ($error) {
                $retval = (int) $error;
            }
        }
        unlink($tmp);
    }
    return $retval;
}