Jump to content

Recommended Posts

Posted

Yeah I have given it a go and cant seem to get it to do anything. I feel some step by step instructions are needed for us not so PHP educated VA admins.

A forum is a big part of a VA, not just for help, but also for the particular VA community to share there experiances and offer there ideas for new routes, Hubs ect. ect. I feel the best scenario would be a very simple forum to be intergrated with PHPVMS but I dont think this is in the pipeline at all.

Posted

I am exacly the same. I am also wanting to make a custom template but I don't have any of the software in either tutorials to do it with, neither the experiance. Then I am not sure how much coding this is going to need. I just hope its either no coding after that part about making it writable or the template or not too much coding. lol I have hit a brick wall so far. At least I have another un-sucessful, stuipid project I am trying. lol

Posted

Hi guys,

I was having probs integrating the membership into SMF too, so one night last week I sat down with a mate who's a programmer and working from the original ForumRegister module code which Mark posted, we came up with the following code which seems to work ok.

[*]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




<?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'");
      }
  }

}
?>

Save everything and try a signup from your VA site and all being well a new account will also be created in SMF :)

We modified the code so that some different variables were inserted into the SMF database and also included the queries that perform an update to show the latest member. In addition, the password salt line has also been included, as otherwise without this the new user would need to login twice to SMF to begin with in order for the salt to be created. This is now generated automatically by the extra lines in the code above.

The other thing we tweaked was the way of logging into SMF, as originally it used the fullname and pilot code. The code now uses the email address, so the pilot can use the exact same login as on the VA site.

Hope this helps you all, as I know it was a huge relief to me to finally get the memberships working together :)

Posted

Dan, is your SMF running on a separate database, or the same one as phpvms ?

One of the things I forgot to mention is that I have both using the same database, so if you're using 2 databases, you would need to call the correct database from the code.

Posted

Not too sure about PHPBB, as I don't use that myself.

Theoretically you should just be able to create the ForumRegister module and use the code which Mark posted earlier in your ForumRegister.php file, as that was specifically for PHPBB.

  • 1 month later...
Posted

Hi everyone

I have followed all the posts and have implemented the forum registration and it all work perfectly.

I am using phpBB 2 and here is my problem. I want to be able to send the country name to the forum databse, I can get the country code in easy enough, but just not the actual country name

here is my code completed (without teh country thingy as I cannot get it to work)

<?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'];
$countries = $userinfo['countries'];

$get_uinfo = mysql_query("SELECT * FROM phpvms_pilots WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'");
//echo "Result Select: ".mysql_error()."<br>";
$uinfo = mysql_fetch_array( $get_uinfo );

$str = $uinfo['pilotid'];
$pilot_id = str_pad ($str,3,"0",STR_PAD_LEFT);
$pilot_id = $code.$pilot_id;
$pilot_id_klein = strtolower($pilot_id);
$passMD5 = md5($pass);
$tm = time();

$query = ("INSERT INTO phpbb_users (
              user_id, user_active, username, user_password, user_session_time, user_lastvisit, user_regdate, user_timezone, user_style,
              user_lang, user_dateformat, user_attachsig, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm,
              user_allow_viewonline, user_notify_pm, user_popup_pm, user_email, user_from)
              
		  VALUES($str, 1, '$pilot_id', '$passMD5', '$tm', '$tm', '$tm', 0.00, 2, 'english', 'D M d, Y g:i a',
		  1, 1, 1, 1, 1, 1, 1, 1, '$email', '$countries')");

$result = mysql_query($query) or die(mysql_error());


$query = ("INSERT INTO phpbb_groups
              (group_type, group_description, group_moderator, group_single_user)
               VALUES(1, 'Personal User', 0, 1)");

$result = mysql_query($query) or die(mysql_error());


$group_user_id = mysql_insert_id();

    $query = ("INSERT INTO phpbb_user_group
              (group_id, user_id, user_pending)
               VALUES('$group_user_id', '$str', 0)");
		   
    $result = mysql_query($query) or die(mysql_error());

//echo "Result: ".mysql_error()."<br>";
//print_r($userinfo);

      }
   }

}

Any help is greatly appreciated.

  • Administrators
Posted

Use:

<?php
$country_name = Countries::getCountryName($userinfo['location']);

Or whichever variable holds the country code (pretty sure it's "location")

Posted

;D ;D

I would have said cheesy grin, if I could. I was so close yet so far.

Nabeel would the list of variables used be under the development documentation?

Admittedly I have not ready that very well.

  • Administrators
Posted

There isn't really a list, but it will be the same as the column names.

The quick trick that I still use for the variable names are var_dump or print_r...

print_r($userinfo);

And will give you a list of the members

  • 2 months later...
Posted

Could anyone be so kind as to paste a fully working phpBB script for the ForumRegsiter module? I tried using the phpBB listed codes but only got a series of errors back...

Posted

This is what I get upon registering a new account:

Confirmation Sent

Thanks for registering for Fly Melita, you will be notified via email of your registration status.

Warning: mysql_query() [function.mysql-query]: Access denied for user 'flymelit'@'localhost' (using password: NO) in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 26

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 26

Result Select: Access denied for user 'flymelit'@'localhost' (using password: NO)

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 28

PilotID:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'flymelit'@'localhost' (using password: NO) in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 43

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 43

And this is the code I used:

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

//mysql_query("INSERT INTO phpbb_users (username, user_password, group_id, user_timezone, user_dst, user_lang, user_type, user_actkey, user_dateformat, user_style, user_regdate) VALUES ($userr, $pass, '2','1.0', '0','en','0','','d M Y H:i', '1', time())");

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

echo "Result Select: ".mysql_error()."<br>";

$uinfo = mysql_fetch_array( $get_uinfo );

//echo "Uinfo: ".$uinfo['pilotid'];

$str = $uinfo['pilotid'];

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

$pilot_id = $fname.$lname.$code.$pilot_id;

$pilot_id_klein = strtolower($pilot_id);

//echo "Pass: ".$pass."<br>";

$passMD5 = md5($pass);

//echo "Pass MD5: ".$passMD5."<br>";

echo "PilotID: ".$str."<br>";

$tm = time();

mysql_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_actkey, user_dateformat, user_style, user_regdate) VALUES ('".$pilot_id."', '".$pilot_id_klein."', '".$passMD5."', '".$email."', '9','0.0', '0', '2','en','0099FF','1','5BN4938HB2','D M d, Y g:i a', '2', '".$tm."')");

//mysql_query("INSERT INTO phpbb_users (username, user_password) VALUES ('".$pilot_id."', '".md5($userinfo['password'])."')");

//echo "Result: ".mysql_error()."<br>";

//print_r($userinfo);

       

      }

  }

}

?>

  • Administrators
Posted

This should be a fixed up version, using the proper API calls

<?php
class ForumRegister extends CodonModule
{

public function __construct()
{
	parent::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'];


		$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_actkey, user_dateformat, user_style, user_regdate) VALUES ('".$pilot_id."', '".$pilot_id_klein."', '".$passMD5."', '".$email."', '9','0.0', '0', '2','en','0099FF','1','5BN4938HB2','D M d, Y g:i a', '2', '".$tm."')");			


	}
}

}
?>

Posted

Website won't even show up! This error is diplayed though:

Fatal error: Call to undefined method CodonModule::construct() in /home1/flymelit/public_html/core/modules/ForumRegister/ForumRegister.php on line 7

  • 2 months later...
Posted

This should be a fixed up version, using the proper API calls

<?php
class ForumRegister extends CodonModule
{

public function __construct()
{
	parent::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'];


		$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_actkey, user_dateformat, user_style, user_regdate) VALUES ('".$pilot_id."', '".$pilot_id_klein."', '".$passMD5."', '".$email."', '9','0.0', '0', '2','en','0099FF','1','5BN4938HB2','D M d, Y g:i a', '2', '".$tm."')");			


	}
}

}
?>

So this is the final answer to the phpBB3 integration? I really want to use something like this but I can wait until all the kinks have been worked out.

I really appreciate all the hard work everyone puts into phpVMS. I can mod the hell right out of phpBB2.x and 3.x but this phpVMS is REAL brand new to me.

If I do use this, I create that folder in the modules folder and insert the php doc that I create and then install a phpBB3 using the same database as phpVMS and thats it? When a new person registers it will create a phpBB3 account?

Or do I need to do something further in the Admin section of my phpVMS install? Sorry to sound like such a newb, but I really am here  ;D

  • Administrators
Posted

So this is the final answer to the phpBB3 integration? I really want to use something like this but I can wait until all the kinks have been worked out.

I really appreciate all the hard work everyone puts into phpVMS. I can mod the hell right out of phpBB2.x and 3.x but this phpVMS is REAL brand new to me.

If I do use this, I create that folder in the modules folder and insert the php doc that I create and then install a phpBB3 using the same database as phpVMS and thats it? When a new person registers it will create a phpBB3 account?

Or do I need to do something further in the Admin section of my phpVMS install? Sorry to sound like such a newb, but I really am here  ;D

Welcome! And yep, that should be it! It hooks in using the EventListener() function, so no core code has to be touched to extend.

It may break in phpBB updates, or something might be nulled or wrong with the user created - I'm not sure. To be sure, it has to use the phpBB API, but I haven't had the time to search that out. There was another post around here where I grabbed it from, it might be worth skimming through that

  • 3 months later...

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