Jump to content

Recommended Posts

  • 1 month later...
Posted

This code is for the phpBB forums and it does work but it leaves the user inactive and they're username is [first name][lastname][pilot no.]. How can I put gaps between that stuff and get the user active?

This is the code I have in the ForumRegister module as ForumRegister.php

<?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);

         


      }
   }

}
?>

cheers,

roboa

p.s I have phpBB and phpVMS in the same db if it helps

  • Administrators
Posted

Replace

$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 );

with:

$uinfo = PilotData::GetPilotByEmail($email);

And replace:

$str = $uinfo['pilotid'];
$pilot_id = str_pad ($str,4,"0",STR_PAD_LEFT);

With

$pilot_id = PilotData::GetPilotCode($uinfo->code, $uinfo->pilotid);

And then:

$pilot_id = "{$uinfo->firstname} {$uinfo->lastname} {$pilot_id}";

Enclose { } around variables, and you can move things around. This way it's using the proper API functions

Posted

Just made a new module called ForumRegister, with the ForumRegister.php file located in it...have the following code in the ForumRegister.php file:

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

$uinfo = PilotData::GetPilotByEmail($email);


//echo "Uinfo: ".$uinfo['pilotid'];
$pilot_id = "{$uinfo->firstname} {$uinfo->lastname} {$pilot_id}";
$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);

         


      }
   }

}
?>

Not entirely sure what has gone wrong, but it isn't working...any advice would be greatly appreciated. Have Accepted the registration and all, but still no luck.

  • 3 months later...
Posted

Trying to get this to work with SMF... and well it does to a point. When the user joins I get the following error.

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

Here is line 26

$uinfo = mysql_fetch_array( $get_uinfo );

Posted

I'm new to this stuff haha, I think this is what you are asking.

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

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

}
?>

Posted

OK, I feel really stupid sorry for wasting your time haha.

SELECT * FROM phpvms_pilots,  I forgot I am using a different prefix for the tables.

My bad, thanks anyhow.

Chad C.

  • 1 month later...
Posted

Hello,

I tried the below code on beta 823 and my site goes down with the below error.  I'm using SMF 2 RC 2

Warning: Unexpected character in input: '' (ASCII=92) state=1 in /home/www/flypatriotva.com/core/modules/ForumRegister/ForumRegister.php on line 2

Parse error: syntax error, unexpected T_STRING in /home/www/flypatriotva.com/core/modules/ForumRegister/ForumRegister.php on line 2

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

      }

  }

}

?>

Any ideas?  This is all greek to me.

  • 2 weeks later...
Posted

Hi guys,

iam playing around with the forum integration and SMF2.0 RC2.

I have the same database for phpvms and smf with different prefixes. smf_ for the forum and phpvms_ for the phpvms.

i created a folder under core/modules called ForumRegister

there i placed a php file called ForumRegister.php with those content:

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

}
?>

But whats next? How can i logon to the forum?

When i load the Module with /phpvms/index.php/ForumRegister

i get this error:

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'ForumRegister::index' was given in /volume1/web/Markus/phpvms/core/classes/MainController.class.php on line 292

any ideas how to get those running that the pilot can be loggin into the forum with his pilot id and password.

Need there be anything changed also in the Forum config?

Thanks for help,

Mark

Posted

i have now:

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

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

}
?>

and this error:

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'ForumRegister::index' was given in /volume1/web/Markus/phpvms/core/classes/MainController.class.php on line 292

when trying to open:

/phpvms/index.php/ForumRegister

  • Administrators
Posted

Oh, you're trying to visit it. It won't work that way. It's using the even listener, so it will automatically run when someone registers

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