I want to adjust this class that is written for phpBB2 into phpBB3 forums.

Here is curl_phpbb.class.php complete code:

http://www.phpkode.com/projects/item/curl-phpbb-functions/


I am working at this function: function new_topic($forum_id, $message, $topic_title)

As I can see, GET and POST params are different for phpBB3 and that is my main problem: to send all form params to server as POST and GET.

Here is html form and submit code:

html form:

<form action="./posting.php?mode=post&amp;f=2&amp;sid=82570fbc6c23aaefb641c86970cfd8a1" method="post" name="postform" enctype="multipart/form-data">

submit button:

<input class="btnmain" type="submit" accesskey="s" tabindex="6" name="post" value="Submit" />

hidden fields:

<td class="cat" colspan="2" align="center"><input type="hidden" name="lastclick" value="1318882908" />
<input type="hidden" name="creation_time" value="1318882908" /> 
<input type="hidden" name="form_token" value="dab9ab1feac70af2eb0a52ce2c86d8bd1c63849b"/>

And here is php code that should send data and match the htmlform:

function new_topic($forum_id, $message, $topic_title)
   {
      global $_SERVER;
   $session_id = "40893d611693d3b32a465d19aa71daa6";
      // Generate post string
      $post_fields = $this->array_to_http(array(
         'post'            => 'Submit',
         'mode'            => 'postform',
         'message'         => $message,
         'f'               => $forum_id,
         'subject'         => $topic_title,
         'disable_bbcode'   => 0,
         'disable_smilies'   => 0,
         'attach_sig'      => 1,
         'topictype'         => 0,
		 'lastclick'    => '1318882908',
		 'creation_time' => '1318882908',
		 'form_token'   =>   'dab9ab1feac70af2eb0a52ce2c86d8bd1c63849b',
      ));
      // Location
      $url_vars = $this->array_to_http(array(
         'mode'   => 'post',
         'f'      => $forum_id,
		 'sid'    => $session_id,
      ));
      // Init curl
      $this->curl = curl_init();
      // Set options
      curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'posting.php?' . $url_vars );
      curl_setopt ( $this->curl, CURLOPT_FOLLOWLOCATION, 0); 
      curl_setopt ( $this->curl, CURLOPT_POST, true );
      curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
      curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
      curl_setopt ( $this->curl, CURLOPT_HEADER, false );
      curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
      curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
      curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
      curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
      // Execute request
      $result = curl_exec ( $this->curl );

Here is complete post new topic html code:

http://codepad.org/VtbU7X7A

And here is complete php class code:

http://www.phpkode.com/projects/item/curl-phpbb-functions/


Help me match POST and GET data to send according the html form, so submitting new topic can be successful.

Member Avatar

diafol

You'd be better off going to the phpbb forum...

Member Avatar

diafol

THis is a general php help forum. You're seeking help with a specific product version upgrade. The phpBB forum will have experts with regard to that product. I don't see why you don't go there.