FREE Rapidshare Premium Account to the first person that helps me fix this.

I'm having serious problems getting my php scripts to work correctly when calling via wget. I'm not getting errors, the results are just wrong.

When I take the URL below (see calling page) and just execute within a browser, it works correctly by retrieving the current users rapidshare account. Using wget doesn't obtain the users account for some reason and connects to the back up account (see action page).

Is there a reason why calling a script from your browser and using wget would provide different results? Is there something I'm doing wrong in the wget call?

Please help...if you can.

Thanks.

Calling Page

Code:
<?php

$key = "7928385";
$userid = "jpollar";

$result = exec("wget -b http://www.uploadjockey.com/~uploadin/rapidshare.com.php?key=".$key."&username=".$userid);
echo $result;
					
?>
Action Page

Code:
<?
//error_reporting(0);
ignore_user_abort(1);
set_time_limit(0);

include "admin/config.php";
include "conn.php";
include "function.php";
include "functions.php";

@ini_set('memory_limit', '1024M');
@ob_end_clean();
ob_implicit_flush(TRUE);

$key = ereg_replace("[^A-Za-z0-9]", "", $_REQUEST['key']);
$username = $_REQUEST['username'];

// MYSQL Connect
$conn = mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
@mysql_select_db(DB_DATABASE);

$files = mysql_query ("select * from files where `key` = '".$key."'");
$row = mysql_fetch_array($files);

if ($row['filename'] == "" || $row['rs'] != "")
{
	die();
}

//Check for user Rapidshare Account
$rspremium = mysql_query ("select * from users where `username` = '".$username."'");
$rsrow = mysql_fetch_array($rspremium);

$login = $rsrow['rsid'];
$password = $rsrow['rspass'];

if ($login == "")
{
// Backup Rapidshare Premium Login Details
$login = "backupuser"; // << Username here
$password = "backuppass"; // << Password here
}

$target = realpath(SITE_PATH . UPLOAD_FOLDER . $row['filename']);

$server = file_get_contents("http://www.rapidshare.com");
$rss =  cut_str($server,'action="','"'); // to choose available server given by rapidshare
if ($rss == "")
{
	$rss = "http://rs368l3.rapidshare.com/cgi-bin/upload.cgi";
}

			$post_data['filecontent']		= "@".$target;		
			$post_data['login'] = $login;
			$post_data['password'] = $password;			

			$ch = curl_init($rss);  
		  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
		  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		   
		  $postResult = curl_exec($ch);
		  curl_close($ch);
			   
		  echo $postResult;
			$download_link=cut_str($postResult,'<div class="downloadlink">','</div>');
// If sometime premium expired and you forget to renew account, it will start uploading without premium.

if($download_link == "")
{
	
	require('class.XMLHttpRequest.php');
	$req = new XMLHttpRequest();
	$req->open("POST","https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi");
	$req->setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	$req->send("login=".$login."&password=".$password);
	preg_match("/user=[^;]*/i", $req->getResponseHeader('Set-Cookie'), $cookie);
	$req->open("GET","https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi?export=1");
	$req->setRequestHeader("Cookie", $cookie[0]);
	$req->send(null);
	$data = implode("\n",array_reverse(explode("\n",$req->responseText)));
	$fn = '/http.*' .$row['filename']. '/i' ;
	preg_match($fn,$data,$res);
	$download_link = trim($res[0]);
}


if ($download_link !="")
{
	mysql_query ("UPDATE `files` SET `rs` = '" . $download_link . "' WHERE `key` =  '" . $key . "' LIMIT 1");
 	
}



?>