SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
-
Oct 27, 2008, 09:38 #1
- Join Date
- Apr 2008
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Help me with wget: Get a FREE Rapidshare Premium Account
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; ?>
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"); } ?>
-
Oct 27, 2008, 14:39 #2
- Join Date
- Jan 2005
- Location
- heaven
- Posts
- 953
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Oct 27, 2008, 14:47 #3
- Join Date
- Apr 2008
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for the response. However, there is no javascript in either file. Nice try.
Any other ideas?
-
Oct 27, 2008, 15:11 #4
- Join Date
- Jan 2005
- Location
- heaven
- Posts
- 953
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ah, sorry. I misunderstood what you were asking. Can you post a sample of the two outputs and what exactly is wrong.
-
Oct 28, 2008, 01:26 #5
- Join Date
- Apr 2008
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've left comments in the code to show you what I think is happening. What's funny is the first query in the action page seems to be working correctly with both wget and browser. The second query (see below) only works within a browser for some reason. You can see on the calling page that I'm passing the $username value in the URL, so that shouldn't be the problem. I've confirmed that it's passing the correct url by printing the url to screen before passing via wget. Still not working right with wget.
// When the action page is executed via browswer, the query is finding the current user.
// With wget it seems to be returning nothing (see below)...I can't confirm this theory.
$rspremium = mysql_query ("select * from users where `username` = '".$username."'");
$rsrow = mysql_fetch_array($rspremium);
$login = $rsrow['rsid'];
$password = $rsrow['rspass'];
// HERE's where the problem lies.
// Since the $login variable is empty with wget, the account is set the backup account.
// This problem does not happen when I call the action page directly in a browser.
if ($login == "")
{
// Backup Rapidshare Premium Login Details
$login = "backupuser"; // << Username here
$password = "backuppass"; // << Password here
}
-
Oct 28, 2008, 09:50 #6
- Join Date
- Apr 2008
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I may just have to find another solution. Users are filling up my premium accounts like gangbusters...
-
Oct 28, 2008, 10:11 #7
- Join Date
- Oct 2008
- Posts
- 72
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
could be cookie problems?
the only thing i can suggest at this point is to create a server that listens on say port 8080 and change the URLs to point to this local server and see what the differences are between the wget request and your browser request.
it might provide a hint.
-
Oct 28, 2008, 15:48 #8
- Join Date
- Apr 2008
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm not using cookies...I'm passing variables via url query string
the only thing i can suggest at this point is to create a server that listens on say port 8080 and change the URLs to point to this local server and see what the differences are between the wget request and your browser request.
-
Oct 28, 2008, 17:41 #9
- Join Date
- Feb 2007
- Posts
- 251
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
try escapeshellarg() or escapeshellcmd()
-
Oct 29, 2008, 01:27 #10
- Join Date
- Apr 2008
- Posts
- 36
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Cuberoot.....You're right on!
Thank you!!!!
escapeshellcmd fixed it
Let me know how I can send the rapidshare account to you!
Bookmarks