Jump to content

CURL saving content problem


n0isy

Recommended Posts

<html>
<title>MyBB PM Exporter</title>
<body>
<form action ="<?php $_SERVER['PHP_SELF'] ?>" method="post">
URL to site: <input type ="text" name="site" value='community.mybb.com' /><br>
Full path to user:pwd list: <input type ="text" name="path" value='/home/www/list.txt' /><br>
<input type = "submit" value="Export"  />
</form>
</body>
</html>

<?php


if(isset($_POST['path']) && isset($_POST['site']))
{
$list = $_POST['path'];
$url = $_POST['site'];

$file = file($list);
foreach($file as $line){
	$explode = explode(":",$line);
	$username = $explode[0];
	$password = $explode[1];



   $crl = curl_init();

    curl_setopt($crl, CURLOPT_URL, $url."/member.php");
    curl_setopt($crl, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
    curl_setopt($crl, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
    curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($crl, CURLOPT_POST, 1);


    // This array will hold the field names and values.
    $postdata=array(
      "username"=>"$username", 
      "password"=>"$password",
      "remember"=>"no", 
      "submit"=>"Login",
  "action"=>"do_login", 
  "url"=>$url."/member.php"
    );
    // Tell curl we're going to send $postdata as the POST data
    curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata);

    $result=curl_exec($crl);
$find_key = preg_match('/var my_post_key = "(.*?)"/',$result,$match);
$my_post_key = $match[1];

curl_setopt($crl, CURLOPT_URL, $url."/private.php");
curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($crl, CURLOPT_POST, 1);

    // This array will hold the field names and values.	
$postdata=array(
"my_post_key" => $my_post_key,
"exportfolders[]" => "all",
"dayway" => "disregard",
"exportunread" => "1",
"deletepms" => "0",
"exporttype" => "html",
"action" => "do_export",
"submit" => "Export Private Messages"
);
curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata);

    
$fh = fopen($username.".html", 'w');
curl_setopt($crl, CURLOPT_FILE, $fh);
curl_exec($crl);
fclose($fh);
curl_close($crl);


}


}
?>

 

So , basically this code just opens the file where username:password is located and then it logins to community.mybb.com with each combination in that file and saves the content of pm's of logged in user.

Problem is that this script allways saves pm's of only one user and it saves other usernames pm's but with the same content of the first user.

Link to comment
Share on other sites

  • 2 years later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.