...

View Full Version : Having issue in login via cURL to phpbb



Dshah
11-03-2009, 02:32 AM
Hi i am working on a script what it does is it will login to my phpbb forum and i will just enter the data and it will be get submitted, now i can see when i run the script i am in login list and displaying starting a post in the forum id i describe but not posting anything. please any help here is my code of processing form function.


function posting($title,$content,$tweb,$fnum,$tuser,$tpass,$bad_words)
{


foreach ($bad_words as $naughty)
{

$content = str_ireplace($naugty, "*****", $content);
}

$forumid = $fnum;

$post_fields =array(
'username' => $tuser,
'password' => $tpass,
'autologin' => 0,
'redirect' => 'index.php',
'login' => 'Log In',
);
$lurl = $tweb."ucp.php";
// echo $lurl;
$curl_url = $tweb."posting.php?mode=post&f=".$forumid;
// echo $curl_url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$lurl);
curl_setopt($ch, CURLOPT_POST, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_COOKIEJAR,"cookie1.txt");
$result= curl_exec ($ch);
curl_close ($ch);
// echo $result;
$sid1 = explode("sid=",$result);

$sid2 = explode('&',$sid1[1]);
$sid = $sid2[0];

$ch3 = curl_init();
curl_setopt($ch3,CURLOPT_URL,$curl_url);
curl_setopt($ch3,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch3,CURLOPT_CONNECTTIMEOUT,"120");
curl_setopt ($ch3, CURLOPT_HEADER, false );
curl_setopt($ch3,CURLOPT_COOKIEFILE,"cookie1.txt");
$souvik12345 = curl_exec($ch3);
$error=curl_error($ch3);
curl_close($ch3);
preg_match('%name="form_token" value="(.*)"\ /\>%',$souvik12345,$security123);
preg_match('%name="lastclick" value="(.*)"\ /\>%',$souvik12345,$lastclick);
preg_match('%name="creation_time" value="(.*)"\ /\>%',$souvik12345,$ctime1);
$lclick = explode('" />',$lastclick[1]);
$post_fields123 = array(

'subject' => $title,
'message' => nl2br(htmlspecialchars_decode($content)),
'f' => $forumid,
'icon' => 0,
'disable_bbcode' => 0,
'disable_smilies' => 0,
'disable_magic_url' => 0,
'attach_sig' => 1,
'notify' => 0,
'topic_type' => 0,
'topic_time_limit' => "",
'creation_time' => $ctime1[1],
'lastclick' => $lclick[0],
'form_token' => $security123[1],
'sid' => $sid,
'post' => 'Submit',
);
/*

'post' => 'Submit',
'mode' => 'post',
'message' => nl2br(htmlspecialchars_decode($content)),
'f' => $forumid,
'subject' => $title,
'disable_bbcode' => 0,
'disable_smilies' => 0,
'attach_sig' => 1,
'topictype' => 0,
);
*/

$ch2 = curl_init();
curl_setopt($ch2,CURLOPT_URL,$curl_url);
curl_setopt($ch2,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2,CURLOPT_CONNECTTIMEOUT,"120");
curl_setopt($ch2, CURLOPT_POSTFIELDS, $post_fields123);
curl_setopt ( $ch2, CURLOPT_HEADER, false );
curl_setopt($ch2,CURLOPT_COOKIEFILE,"cookie1.txt");
$souvik1234 = curl_exec($ch2);
$error=curl_error($ch2);
curl_close($ch2);
// echo $souvik1234;


}

thanks for any support.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum