Jump to content

Automatic Forum account creation


mark1million

Recommended Posts

  • Moderators

This is what you need to do,

Create a folder in your core/modules called ForumRegister, in that folder create a new php file and past Nabeels code in and save.

That should be it....

Ah and dont forget if your forum db is not in your vms install then you need to add a connect statement before the insert. :)

Link to comment
Share on other sites

  • Moderators

I have gone back to look at this and i hope some one can help, presently the code inserts the username and pilot id with out spaces between,

$pilot_id = $fname.$lname.$code.$pilot_id; would result in FirstnameLastnamePilotid,

How can i change this to get Firstname Lastname Pilotid. with the space in between?

Link to comment
Share on other sites

  • Moderators

So, does this ForumRegister module automatically add a user when they register?

My phpbb tables are in the same location as my phpVMS tables.

Theres no include() or similar that I need to have in the register module?

I will give that a go, thanks, and yes no include is needed because your not using the forum registration, your directly putting in values to the users table collected from the registration page of phpvms.

Link to comment
Share on other sites

<?php
class ForumRegister extends CodonModule
{
   
   public function __construct()
   {
      CodonEvent::addListener('ForumRegister');
   }
   
   public function EventListener($eventinfo)
   {
      if($eventinfo[0] == 'registration_complete')
      {
echo 'Receiving You!';

         $userinfo = $eventinfo[2];

         $fname = $userinfo['firstname'];
         $lname = $userinfo['lastname'];
         $pass = $userinfo['password1'];
         $email = $userinfo['email'];
         $code = $userinfo['code'];

      
         $uinfo = PilotData::GetPilotByEmail($userinfo['email']);
                              
         $code = PilotData::GetPilotCode($uinfo->code, $uinfo->pilotid);
         $pilot_id = $fname. '' .$lname. '' .$code.$pilot_id;
         $pilot_id_klein = strtolower($pilot_id);
         
         $passMD5 = md5($pass);

         $tm = time();

DB::Query("INSERT INTO phpbb_users (username, username_clean, user_password, user_email, group_id, user_timezone, user_dst, user_rank, user_lang, user_colour, user_type, user_dateformat, user_style, user_regdate) VALUES ('".$pilot_id."', '".$pilot_id_klein."', '".$passMD5."', '".$email."', '2','0.0', '0', '2','en_us','0099FF','1','1', jS F Y g:i:s A', '1', '".$tm."')");         


      }
   }

}
?>

Is My script. It Displays 'Receivng You' but doesn't put anything into the Database?

My phpbb_users is in the same directory as my phpVMS database :S

Link to comment
Share on other sites

  • Administrators

Try changing the last few lines around your query to this->


$query = "INSERT INTO phpbb_users (username, username_clean, user_password, user_email, group_id, user_timezone, user_dst, user_rank, user_lang, user_colour, user_type, user_dateformat, user_style, user_regdate) 
            VALUES ('$pilot_id', '$pilot_id_klein', '$passMD5', '$email', '2','0.0', '0', '2','en_us','0099FF','1','1', 'S F Y g:i:s A', '1', '$tm')";         

            DB::query($query);

also - not sure if it makes a difference but for time I use ->

$tm = NOW();

Link to comment
Share on other sites

  • Administrators

Nabeel

Thanks for the code for phpbb3 , after the change on phpvms forum system , I'm thinking about changing our forum

from phpbb to ip.board too , do you have the same integration code but for ip.board ?

Thanks

IP.Board has an addin called "Converge" for single-sign in, so it will probably involve that. I don't know any specifics though

phpBB uses a special user_add() function and a different method of encryption to MD5, now.

At the moment, I am coding an automatic forum account module that uses the proper API calls from phpVMS and phpBB.

Will let everyone know when it is finished!

Cool, this is what I was saying earlier in the thread, to use the phpBB functions for doing to, to ensure things don't break going forward.

  • Like 1
Link to comment
Share on other sites

Is there an event for when a user is approved? I don't want to create the forum account on registration if the user has to be approved first.

I've got everything working using phpBB's functions, just need to do the phpVMS side of things now :)

A major problem I have is trying to include the phpBB files without codon/phpbb frameworks clashing.

Is there a way that phpVMS can find event listeners from external locations?

BTW Nabeel error with the forums I think, I've subscribed to this post and I get about 5 emails when somebody posts a message!

Link to comment
Share on other sites

  • Administrators

Is there an event for when a user is approved? I don't want to create the forum account on registration if the user has to be approved first.

I've got everything working using phpBB's functions, just need to do the phpVMS side of things now :)

A major problem I have is trying to include the phpBB files without codon/phpbb frameworks clashing.

Is there a way that phpVMS can find event listeners from external locations?

BTW Nabeel error with the forums I think, I've subscribed to this post and I get about 5 emails when somebody posts a message!

Check your subscriptions, maybe it's something wrong with that?

Hopefully the frameworks won't clash. From external locations, what do you mean? It's within the module, so I'm not sure how off the top of my head. It will need some modifications for sure. And a user approved event, there isn't since that's on the admin side. I guess if you reject the pilot, then you'd have to delete it from the forum admin side.

Link to comment
Share on other sites

Check your subscriptions, maybe it's something wrong with that?

Hopefully the frameworks won't clash. From external locations, what do you mean? It's within the module, so I'm not sure how off the top of my head. It will need some modifications for sure. And a user approved event, there isn't since that's on the admin side. I guess if you reject the pilot, then you'd have to delete it from the forum admin side.

When trying to include the files required from, it doesn't like the codon directory structure and shows an error message. I was thinking perhaps not registering the account automatically, but rather including a link in the 'registration complete' email that would create the account for them.

Link to comment
Share on other sites

  • Administrators

When trying to include the files required from, it doesn't like the codon directory structure and shows an error message. I was thinking perhaps not registering the account automatically, but rather including a link in the 'registration complete' email that would create the account for them.

Yes you could do that, or automatically do a POST request to another page which does it. But clicking a link or having a form with hidden fields and passing it all to the next page with the submit button that says "continue" will work.

What's the error it shows? If you include just /core/codon.config.php, does it give an error?

Link to comment
Share on other sites

I've just done the worst imaginable thing and deleted the contents of my home directory accidentally - Ive got a backup from last tuesday but this script might be delayed until the weekend :( Sorry guys...

However, on the bright side, I will be coding two things once I'm back up and running:

-A link in an email message that registers a forum account for people.

-A form with hidden fields and submit link that would go in the pilot center, for example.

The phpBB/phpVMS clash isn't really a problem anymore but decoding the Md5 passwords stored by phpVMS, and reencoding them using phpBBs new format will be a challenge.

Link to comment
Share on other sites

  • Moderators

I've just done the worst imaginable thing and deleted the contents of my home directory accidentally - Ive got a backup from last tuesday but this script might be delayed until the weekend :( Sorry guys...

However, on the bright side, I will be coding two things once I'm back up and running:

-A link in an email message that registers a forum account for people.

-A form with hidden fields and submit link that would go in the pilot center, for example.

The phpBB/phpVMS clash isn't really a problem anymore but decoding the Md5 passwords stored by phpVMS, and reencoding them using phpBBs new format will be a challenge.

Hi, im no coder but what i do know is you can use the phpbb3 user add with a plain text password and that api will do all your work, also its possible to get the plaintext password out of the phpvms registration and feed that in to the user add function.

Link to comment
Share on other sites

Hi, im no coder but what i do know is you can use the phpbb3 user add with a plain text password and that api will do all your work, also its possible to get the plaintext password out of the phpvms registration and feed that in to the user add function.

That's the thing, see.

I have everything sorted with the phpBB API, but this won't be an automatic forum account on registration script...

It will send a link via email to a script that will get the users info from the DB (using the phpvms api) and put it in accordingly.

I suppose one solution is to use a 'Default password' that the user can change themselves when they log in...

Will keep everyone posted, my host has just restored a backup from last tuesday, but I lost a lot of work.

BE CAREFUL WITH SSH AND DO REGULAR BACKUPS! Is what I learnt the hard way from this!

Link to comment
Share on other sites

  • 5 months later...

Onde eu ponho isso?

Thats what im using bb3, here is the code for phpbb3. as you are taking the data from a sanitised source all of the safe guards have been removed, valid email etc.... This code takes the data from the existing redistration page and puts it directly in to bb3 db. I have not had chance to check fully but will be testing tonight.

<?php
/**
* Created on 22-nov-2008 17:10:39
*
* Phpbb3 -- register_extern.php
* @author   Ramon Fincken http://www.ramonfincken.com/permalink/topic82.html
* @author   Mr Kirkland      http://www.mrkirkland.com/adding-a-user-to-phpbb3-from-an-external-script/
*/
define('IN_PHPBB', true);
$phpbb_root_path = '';  // Your path here
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.php');

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

require($phpbb_root_path .'includes/functions_user.php');


$username = '';
$password = ''; // Do NOT encrypt !
$email  = ''; // Please validate this email yourself ! Phpbb will accept non-valid emails.


// Do a check if username is allready there, same for email, otherwhise a nasty error will occur

$user_row = array(
'username' => $username,
'user_password' => md5($password), 'user_email' => $email,
'group_id' => 2, #Registered users group
'user_timezone' => '1.00',
'user_dst' => 0,
'user_lang' => 'en',
'user_type' => '0',
'user_actkey' => '',
'user_dateformat' => 'd M Y H:i',
'user_style' => 1,
'user_regdate' => time(),
);

$phpbb_user_id = user_add($user_row); 
echo "New user id = ".$phpbb_user_id; /code]

?>

Let me know if you get it working  ;D  hopefully find the time tonight fingers crossed.....

Link to comment
Share on other sites

  • 5 years later...

I realize this is a very old thread. I am wondering does anyone have any recent examples of integrations they have done with phpVMS and phpBB? Is the information that Nabeel provided in this thread still valid today? Is thre any type of security issue as it relates to the "connect statement" as mentioned in a couple of responses?

Regards,

Nat

Link to comment
Share on other sites

I haven't used this in a while (hence why I'm not sure if it will work)

But you could try using this

<?php
class PHPBBRegister extends CodonModule
{
public function __construct()
    {
		    CodonEvent::addListener('PHPBBRegister');
    }

 public function EventListener($eventinfo)
{
  if($eventinfo[0] == 'registration_complete')
  {
 $userinfo = $eventinfo[2];
 $fname = $userinfo['firstname'];
 $lname = $userinfo['lastname'];
 $pass = $userinfo['password1'];
 $email = $userinfo['email'];
 $code = $userinfo['code'];

 $uinfo = PilotData::GetPilotByEmail($userinfo['email']);

 $code = PilotData::GetPilotCode($uinfo->code, $uinfo->pilotid);
 $pilot_id = $fname.' '.$lname;
 $pilot_id_klein = strtolower($pilot_id);

 $passMD5 = md5($pass);
 $tm = time();

  $query = "INSERT INTO phpbb_users (
   user_type,
   group_id,
   user_regdate,
					    username,
   username_clean,
					    user_password,
   user_passchg,
   user_email,
   user_posts,
   user_lang,
   user_dateformat,
   user_style,
   user_rank
					    )
			    VALUES (
  '1',
  '2',
  '$tm',
				    '$pilot_id',
  '$pilot_id_klein',
				    '$passMD5',
  '0',
				    '$email',
				    '0',
  'en',
  'D M d, Y g:i a',
  '1',
  '0'
				    )";
  DB::query($query);			  

  }
}
}

Just put it in a folder called PHPBBRegister inside core/modules

so

core

modules

PHPBBRegister

PHPBBRegister.php (is the file above)

Otherwise you can check out Dave's version for SMF here https://github.com/D...MS-SMF_Register and change a few table names

Which I guess is more up-to-date

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...