Web Analytics Made Easy -
StatCounter CURL saving content to file - CodingForum

Announcement

Collapse
No announcement yet.

CURL saving content to file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CURL saving content to file

    PHP Code:
    <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($crlCURLOPT_URL$url."/member.php");
        
    curl_setopt($crlCURLOPT_COOKIEFILE"/tmp/cookie.txt");
        
    curl_setopt($crlCURLOPT_COOKIEJAR"/tmp/cookie.txt");
        
    curl_setopt($crlCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt($crlCURLOPT_RETURNTRANSFER1);
        
    curl_setopt($crlCURLOPT_POST1);


        
    // 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 ($crlCURLOPT_POSTFIELDS$postdata);

        
    $result=curl_exec($crl);
        
    $find_key preg_match('/var my_post_key = "(.*?)"/',$result,$match);
        
    $my_post_key $match[1];
        
        
    curl_setopt($crlCURLOPT_URL$url."/private.php");
        
    curl_setopt($crlCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt($crlCURLOPT_RETURNTRANSFER1);
        
    curl_setopt($crlCURLOPT_POST1);
        
        
    // 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 ($crlCURLOPT_POSTFIELDS$postdata);

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

        }
        

    }
    ?>
    So , basically this code just opens the file where usernameassword 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.
Working...
X