NukeXchange Network

          

Nuke Sites Link Directory
Nuke Fixes · NukeForums · NukeZone Hosting · NukeUnited · Nuke Sites · Nuke Skins · NukeLance
Nuke Resources
 :: Home  :: Downloads  :: Your Account  :: Forums  :: Advertise :: 
Login or Register
Main Menu
General
 Main
 AvantGo
 Banner_Clients
 cfaq
 Donations
 Downloads
 Forums
 Members_List
 Private_Messages
 Search
 Stories_Archive
 Submit_News
 Surveys
 Topics
 Web_Links
 Your_Account

Your Account
 Login
 Register
 Lost Pass

Modules
Quick Links
· CMS Focus
· Domain Names
. Game Quest
· Learning Linux
. MateMaker
· NukeFixes
· NukeForums
· NukeLance
· Nuke Sites
· Nuke Skins
· NukeZone Hosting
. SearchDevil
Other Options

Download Resources
· Nuke Downloads
· Add a Link
· New Files
· Top Rated
· Most Popular

Web Site Resources
· Nuke Sites
· Add A Site
· New Sites
· Top Rated
· Most Popular

Support
· NukeZone Hosting
· NukeSkins.com
· NukeForums.com
· phpnuke.org
· NukeFixes.com
Information
NukeForums
·Creating a Gaming PHP Nuke Site - Newbie
·Issues with GIF Images
·Installation Issues
·Please Help Question about Siggy's
·Hi My name is Rukasuzu, where is the introduction?
·Include file as block?
·How Do I make a Website?
·Array of strings as parameter
·Theme Change, just white? :(
·How can i disable upload t download by other users?Php-Nuke8

read more...
Top10 Links
· 1: Nuke Forums
· 2: PHPNukeFiles
· 3: NukeSkins
· 4: Nuke Templates
· 5: EcomJunk
· 6: MDesign
· 7: Windows Installation: PHP
· 8: FLASH-FOR-NUKE
· 9: Dezina
· 10: Global Dream News Sharing Portal!
Site Visitors
User Login:

Nickname:
Password:
Security Code: Security Code
Type Security Code Here:

Members List Membership:
Latest: carlosmafud
Today: 0
Yesterday: 1
Overall: 15026

Visitation:
Guests: 398
Members: 0
Total: 398


You are Anonymous user. You can register for free by clicking here
Sponsor Links
Game Quest Online - Games and more!
Game Quest Online - Games and more!

NukeResources :: View topic - Posting to phpBB (PHP-Nuke integration version) from a Form
NukeResources Forum Index

NukeResources Forum Index -> Random Thoughts -> Posting to phpBB (PHP-Nuke integration version) from a Form
Post new topic  Reply to topic    View previous topic :: View next topic 
Posting to phpBB (PHP-Nuke integration version) from a Form
PostPosted: Wed Feb 27, 2008 9:08 am Reply with quote
Loper
Resource Seeker
Resource Seeker
 
Joined: Feb 21, 2008
Posts: 10




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):

Code:

   /*
      @ 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)
   {
      global $_SERVER;

      // 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,
      ));
      // Location
      $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 );
      echo $result;
      // 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;
      }
      else
      {
         $post_status = 0;
      }
      // Error handling
      if ( curl_errno ( $this->curl ) )
      {
         $this->error = array(
            curl_errno($this->curl),
            curl_error($this->curl),
         );
         curl_close ( $this->curl );
         return false;
      }

      // Close connection
      curl_close ( $this->curl );
      // Return result
      return $post_status;
   }

And I call the function (after the class is instantiated as $phpbbclass) like so:
Code:

$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.

Here is the main reference site where I've been looking at code, trying to hack it to work with Nuke, including the code examples above:
http://www.phpbb.com/community/viewtopic.php?f=71&t=735215

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.

Thanks!!
View user's profile Send private message
PostPosted: Wed Feb 27, 2008 10:21 am Reply with quote
Evaders99
Resource Master
Resource Master
 
Joined: May 25, 2004
Posts: 1785




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.

_________________
- Star Wars Rebellion Network - Evaders Squadron Coding -

Need help? Nuke Patched Core, Coding Services, Webmaster Services
View user's profile Send private message Visit poster's website AIM Address
PostPosted: Wed Feb 27, 2008 10:29 am Reply with quote
Loper
Resource Seeker
Resource Seeker
 
Joined: Feb 21, 2008
Posts: 10




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.
View user's profile Send private message
PostPosted: Wed Feb 27, 2008 3:49 pm Reply with quote
Evaders99
Resource Master
Resource Master
 
Joined: May 25, 2004
Posts: 1785




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.

_________________
- Star Wars Rebellion Network - Evaders Squadron Coding -

Need help? Nuke Patched Core, Coding Services, Webmaster Services
View user's profile Send private message Visit poster's website AIM Address
PostPosted: Thu Feb 28, 2008 8:32 am Reply with quote
Loper
Resource Seeker
Resource Seeker
 
Joined: Feb 21, 2008
Posts: 10




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.
View user's profile Send private message
PostPosted: Wed Aug 20, 2008 2:58 pm Reply with quote
Loper
Resource Seeker
Resource Seeker
 
Joined: Feb 21, 2008
Posts: 10




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!

EDIT:
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.
View user's profile Send private message
Posting to phpBB (PHP-Nuke integration version) from a Form
 NukeResources Forum Index -> Random Thoughts
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
All times are GMT - 4 Hours  
Page 1 of 1  

  
  
 Post new topic  Reply to topic     



Powered by phpBB © 2001-2005 phpBB Group.     Theme created by Vjacheslav Trushkin.
There have been 140 unique hit(s) in the past 24 hours.
Forums ©
Need to find your IP fast?


Best viewed with a Browser
All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2001 - 2007 by NukeResources.com
You can syndicate our news using the file .backend.php or ultramode.txt
PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 2.18 Seconds

:: Eos phpbb2 style by Cyberalien :: PHP-Nuke theme by www.nukemods.com ::