I'm using a nice web form module/block called "Application" on my site that is for guild membership application (the site is for a warcraft guild) and it works great. Potential applicants fill out the form and a mail is generated as expected.
However, I'd like to take this to the next level and have it not only generate and send the mail but also create a forum post containing the details of the application, not unlike the mail generated. Most of that is easy enough for me to hack, and I don't want to do anything fancy with the formatting. Also worth noting is that the user must already be logged into the CMS to have access to the module, so I don't think that authentication should be an issue.
I've played around some with a php class file written for Drupal called phpbb.php that contains, among others, a function called "new_topic" that uses cUrl to insert a post into phpBB. Thing is, this doesn't seem to be working right with the Nuke integration. Anyone happen to have done something like this before? or have some idea of what variables I may need to set or includes I need to call in my "other" php files to get CMS auth to work in the background and get this to post?
Here is the one function out of the class that I'm most interested in; if helpeful I can post the whole class (I didn't write this):
@ Function : new_topic() - New Topic
@ About : Remotely posts a topic to the target phpBB forum.
@ Type : Public
function new_topic($forum_id, $message, $topic_title)
// Generate post string
$post_fields = $this->array_to_http(array(
'post' => 'Submit',
'mode' => 'post',
'message' => $message,
'f' => $forum_id,
'subject' => $topic_title,
'disable_bbcode' => 0,
'disable_smilies' => 0,
'attach_sig' => 0,
'topictype' => 0,
$url_vars = $this->array_to_http(array(
'mode' => 'post',
'f' => $forum_id,
// Init curl
$this->curl = curl_init();
// Set options
curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . $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_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
// Execute request
$result = curl_exec ( $this->curl );
// Get the result
if ( preg_match ( '#<td><span>Your message has been entered successfully.<br><br>#is', $result, $match ) )
$post_status = 1;
else if ( preg_match ( '#<td><span>You cannot make another post so soon after your last; please try again in a short while.</span></td>>#is', $result, $match ) )
$post_status = 0;
$post_status = 0;
// Error handling
if ( curl_errno ( $this->curl ) )
$this->error = array(
curl_close ( $this->curl );
// Close connection
curl_close ( $this->curl );
// Return result
And I call the function (after the class is instantiated as $phpbbclass) like so:
$phpbbclass = new curl_phpbb('modules.php?name=Forums&file=posting');
$phpbbclass->new_topic( 2, $msg, $subject );
2 is the forum ID I'd like to post to and both $msg and $subject contain non-array data that are correct.
I've been wrestling with this for nearly 2 weeks now and am ready to ask for some help. Hopefully someone has done this for Nuke.
On a note: I'd have no objections to doing a direct insert to MySQL if that'd be easier if someone could point me in the proper direction as to which files I'd need to be sure to include to get all the Nuke CMS contants etc.
My guess is that this no longer works due to the "sid" parameter being passed. This is set for all forms so that automated processes can't post to your forums. You'd have to read this value somewhere before sending the cURL POST.
Thanks! I'll look into that for sure. Do you know if this value is accessible to PHP out of the environment (such as $_POST['sid'])? or will I need to perform a phpBB login first (there is actually a function for that as well, but I didn't want to inadvertently start a new session to avoid server load if this wasn't required) and use that connection.
Really, the goal here is to try to be as "integrated" as possible, so I'm trying really hard to avoid direct SQL inserts and instead use the Nuke API, and this is all from the same site with a logged-in user, not a remote call as the class was originally intended to be used for.
It is sent as a $_POST['sid'] variable. phpBB assigns a 'sid' for all logged in users as well as guests. However, the forum you are posting to must allow guest posts for this to work. Otherwise your script will have to setup a valid phpBB user session before trying to post.
Ok.. after that information and some research of my own, I'm starting to get close. I've decided to re-write the class, based on the existing older version that doesn't pass SID -- at least for now I'm planning that. I may end up with a ground-up re-write that uses a different method other than cURL to pass to the site.
What I've not been able to find, however, is a mostly complete API specification or documentation on the phpBB interface, or at least what it expects. Of course, something that is specific to Nuke would be even better. If anyone has any reference sites or books to recommend, that'd be a great help.
What I've been doing so far is going through some other module code (including Forums) to try to find the session management calls so I can reuse code rather than re-inventing the wheel, if possible, by including those files.
Ok.. put this down for a while and picked it back up a couple days ago. Still no love.
What I'd like, if someone has a link or some advice, is some how-to on how to initiate or tap into an existing session of PHP-Nuke so I could gain access to things like the user's ID, sid, etc. And what those variables are.. I did look a bit at some of the source for Nuke and played with some (such as the $user variable seems to be the SID, but simply passing it as $_POST['sid'] did not work.
Of course, I could be over-thinking this. Most recently, the problem I've had is I pass everything I think I need and all it does is send me to the normal "New Topic" form rather than insert the topic for me. Again, I'm pretty sure this is because I'm not using the posting.php API correctly.
What I'm thinking now is that I could "manually" insert what I need into the database, but in order to do that correctly/safely I'll need to know how to access certain Nuke internals, such as the current userid (numberic) as well as understand how the post ids are generated (although I expect this last is an incremented value).
Any help would be welcome!
If anyone wants to see the code I've got let me know. It's got a lot of HTML in it so I can't post, even in a code block. It's broken, of course, so not that huge a deal. But if interested I could mail it to someone (drop me a line at sirloper at gmail dot com.
Bacteria originate from faecal matter and pollute streams and groundwater. Most bacteria are only 1 micrometer in diameter, but some bacteria range in size from 0.1 to 10 micrometers. Bacteria of the coliform group are considered the primary indicators of fecal contamination and are often used to assess water quality. Coliform is used to describe a group of Gram-negative, facultative, anaerobic, rod-shaped, get complete information mcts practice tests
Many people dislike to wash the dishes, and I particularly like washing the dishes. On one hand, see a bunch of oily dirty dishes were gradually washed very rewarding, on the other hand, the side of the bowl to wash hands while brains have all kinds of daydream, like daydreaming. Introduce the current way. In a foreign work before the last seven years, financial crises affect in Shanghai, was sent. When the land held ambitious start their own business, but a few months, now also very hard down the road in the dark. But every day and wife still very happy, happy family gave me the courage and the strength to fight.
good stuff !!!
I could be over-thinking this. Most recently, the problem I've had is I pass everything I think I need and all it does is send me to the normal "New Topic" form rather than insert the topic for me. Again, I'm pretty sure this is because I'm not using the posting.php API correctly.
Microsoft Office 2007 Onlineoutlook 2010Office Pro 2010
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum