Jump to content

Forum intergration


roboa

Recommended Posts

  • 3 weeks later...

Roboa,

These are the steps I posted in a different thread (possibly the one you found the code in) and it all worked fine for my SMF integration (assuming you are using the same database for the forum and PHPVMS)

    * Step 1: Create a new folder in /core/modules called ForumRegister

    * Step 2: In that folder create a new php file called ForumRegister.php

    * Step 3: Copy and paste in the following code

Code: [select]

<?php

class ForumRegister extends CodonModule

{

 

  public function __construct()

  {

      CodonEvent::addListener('ForumRegister');

  }

 

  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'];

$get_uinfo = mysql_query("SELECT * FROM phpvms_pilots WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'");

$uinfo = mysql_fetch_array( $get_uinfo );

$str = $uinfo['pilotid'];

$pilot_id = str_pad ($str,4,"0",STR_PAD_LEFT);

$pilot_id = $code.$pilot_id;

$pilot_name = mysql_escape_string ($fname. ' ' .$lname);

$passsha1 = mysql_escape_string (sha1(strtolower($email) . $pass));

$passsalt = substr(md5(mt_rand()), 0, 4);

$email = mysql_escape_string($email);

$tm = time();

mysql_query("INSERT INTO smf_members (member_name, real_name, passwd, email_address, hide_email, id_group, time_offset, location, lngfile, validation_code, id_theme, is_activated, id_msg_last_visit, date_registered, password_salt) VALUES ('".$email."', '".$pilot_name."', '".$passsha1."', '".$email."', '1', '4', '', '', '', '', '0', '1', '1', '".$tm."', '".$passsalt."')");

$member_id = mysql_insert_id();

     

mysql_query("update smf_settings set value = '$pilot_name' where variable='latestRealName'");

mysql_query("update smf_settings set value = '$member_id' where variable='latestMember'");

      }

  }

}

?>

Regarding the registration issue, are you using the latest build which contains the captcha ?

I was having a similar issue until I realised I was still using an older version without the captcha :)

Link to comment
Share on other sites

Guys, just to clarify, the integration code does work fine with SMF (at least with the version of SMF that I'm using anyway, which is SMF 2.0 RC1 Public Released on February 04, 2009), but not sure about PHPBB integration as I don't use that. Having said that, all I did was take the original PHPBB code posted by Mark and change the variables to those used by SMF, then tweaked it for creating a password salt and running the latest member query etc and it works a treat.

Surely, someone using PHPBB must also have got this to work by now ?

Link to comment
Share on other sites

Hi Roger,

It's possible that there's a version conflict in that case then.

Oh btw, that last reply is much better than your original, as detailed info is preferable to simply saying it doesn't work and asking me to stop telling people it does, when it's clearly working 100% for me ;)

Working together is the way to get things achieved, so we need to find out what the differences are between various setups.

OK, first things first, are the tables in your version of SMF named exactly as those in the query ?

Secondly, what field type is member_name (assuming it's called that in your version) ?

Mine is set to varchar(80)

Link to comment
Share on other sites

I have been trying a script in a different topic and it was made for phpBB which I am using. But I am having trouble making it work. So I contacted somebody who I know and he has been helping me alot with my site, but he updated the registration in the phpVMS thing and I tried to put it in and my sites down. I am going to tell him that it didn't work and see what happens from there. But I am not a good person at programming at all.

Link to comment
Share on other sites

To add, I have now sorted two problems which were there but there is another one which the person couldn't help me with. Its this message:

Parse error: syntax error, unexpected '/' in /home/goldenair/domains/goldenairways.co.uk/public_html/core/modules/ForumRegister/ForumRegister.php on line 44

Please could somebody help me with it as I have no idea how to do it. Thanks.

Link to comment
Share on other sites

Apologies accepted Roger, thanks dude.

I actually have my registration set to disabled, since I want to restrict forum membership to those on my V.A. Since the code essentially updates the SMF database, I don't think that the setting should be an issue.

I've downloaded and installed 1.18 now, so once I've applied the same changes as I did with version 2.0 the investigation can begin :D

Link to comment
Share on other sites

Looks like the problem is down to changes of field names in the smf_members table. I've amended the code accordingly and tested it out with the 1.18 version I installed and it appears to be doing the job, adding the member to the database and updating the latest member.

For those of you using SMF 1.18, the following code for your ForumRegister.php file should now work ok.

<?php
class ForumRegister extends CodonModule
{
   
   public function __construct()
   {
      CodonEvent::addListener('ForumRegister');
   }
   
   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'];

$get_uinfo = mysql_query("SELECT * FROM phpvms_pilots WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'");

$uinfo = mysql_fetch_array( $get_uinfo );


$str = $uinfo['pilotid'];
$pilot_id = str_pad ($str,4,"0",STR_PAD_LEFT);
$pilot_id = $code.$pilot_id; 
$pilot_name = mysql_escape_string ($fname. ' ' .$lname);
$passsha1 = mysql_escape_string (sha1(strtolower($email) . $pass));
$passsalt = substr(md5(mt_rand()), 0, 4);
$email = mysql_escape_string($email);
$tm = time();

mysql_query("INSERT INTO smf_members (memberName, realName, passwd, emailAddress, hideEmail, ID_GROUP, timeOffset, location, lngfile, validation_code, ID_THEME, is_activated, ID_MSG_LAST_VISIT, dateRegistered, passwordSalt) VALUES ('".$email."', '".$pilot_name."', '".$passsha1."', '".$email."', '1', '4', '', '', '', '', '0', '1', '1', '".$tm."', '".$passsalt."')");

$member_id = mysql_insert_id();
      
mysql_query("update smf_settings set value = '$pilot_name' where variable='latestRealName'");
mysql_query("update smf_settings set value = '$member_id' where variable='latestMember'");
      }
   }

}
?>

Let me know how it goes.

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