The drop is always movingYou know that saying about standing on the shoulders of giants? Drupal is standing on a huge pile of midgetsAll content management systems suck, Drupal just happens to suck less.Popular open source software is more secure than unpopular open source software, because insecure software becomes unpopular fast. [That doesn't happen for proprietary software.]Drupal makes sandwiches happen.There is a module for that

Rapidshare premium account download script

Submitted by nk on Tue, 2010-01-26 08:57

Although the web is full of scripts to help downloading from rapidshare with a premium account, none of them seemed to work for me. First, create a cookie file: curl -k -c .rapidshare -d 'login=USERID&password=PASSWORD' 'https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi'. In the browser first you click the "premium user" button, second you click "download". We download these pages because the first contains the number of the rapidshare server actually containing the file, like rs123.rapidshare.com and then the mirror like rs123gc3 for Global Crossing.

<?php
define
('COOKIEFILE', '.rapidshare');
$url = $argv[1];
if (!
$url) {echo "One argument needed\n";exit;}
$parts = parse_url($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$step1 = curl_exec($ch);
preg_match('|"(http://rs\d+[^"]+)"|', $step1, $match);
$url = $match[1];
$rs = preg_quote('.rapidshare.com');
// Create a preg based on the URL.
$mirror_mask = str_replace(preg_quote($url), $rs, 'action=\'([^.]+' . $rs) .'[^\']+)\'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'dl.start=PREMIUM&submit=Premium%20user');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEFILE);
$step2 = curl_exec($ch);
preg_match("/$mirror_mask/", $step2, $masks);
$fh = fopen(basename($parts['path']), 'wb');
// It might not be necessary to re-init curl. But it certainly does not hurt.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $masks[1]);
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEFILE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
curl_setopt($ch, CURLOPT_FILE, $fh);
curl_exec($ch);
fclose($fh);
?>

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options