homer09001 Posted May 27, 2009 Report Posted May 27, 2009 Well done Nige, perfect script. Works fine with latest build of PHPVMS and SMF 2.0 Quote
roboa Posted July 4, 2009 Author Report Posted July 4, 2009 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 Quote
Administrators Nabeel Posted July 5, 2009 Administrators Report Posted July 5, 2009 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 Quote
roboa Posted July 5, 2009 Author Report Posted July 5, 2009 cheers Nabeel! I really appreciate it Quote
G-NEWC Posted July 10, 2009 Report Posted July 10, 2009 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. Quote
Administrators Nabeel Posted July 10, 2009 Administrators Report Posted July 10, 2009 What do you mean not working? Is ther an error or anything Quote
G-NEWC Posted July 10, 2009 Report Posted July 10, 2009 Sorry, i meant that there is no forum member being created on phpBB. Quote
Administrators Nabeel Posted July 10, 2009 Administrators Report Posted July 10, 2009 Put an echo after if($eventinfo[0] == 'registration_complete') { so you know if it's being called or not Quote
piper338 Posted November 5, 2009 Report Posted November 5, 2009 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 ); Quote
Administrators Nabeel Posted November 6, 2009 Administrators Report Posted November 6, 2009 What's $get_uinfo? It's expecting a return value from a mysql_query() Quote
piper338 Posted November 6, 2009 Report Posted November 6, 2009 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'"); } } } ?> Quote
piper338 Posted November 6, 2009 Report Posted November 6, 2009 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. Quote
Administrators Nabeel Posted November 6, 2009 Administrators Report Posted November 6, 2009 You don't need to use mysql_query, use $results = DB::get_results("QUERY"); Quote
TennShadow Posted December 27, 2009 Report Posted December 27, 2009 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 2Parse error: syntax error, unexpected T_STRING in /home/www/flypatriotva.com/core/modules/ForumRegister/ForumRegister.php on line 2 <?phpclass 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. Quote
Moderators mark1million Posted December 27, 2009 Moderators Report Posted December 27, 2009 I am using phpbb 3.6 all works fine here, but the user goes inactive but thats OK as nasty things can happen otherwise ..... Quote
TennShadow Posted December 27, 2009 Report Posted December 27, 2009 Never mind. I pasted it in Worpad instead of notepad. It does work great but it creates the username as the email address. Is there any way to make the username the Pilot ID? Quote
markusr Posted January 10, 2010 Report Posted January 10, 2010 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 Quote
Administrators Nabeel Posted January 10, 2010 Administrators Report Posted January 10, 2010 Above CodonEvent::addListener('ForumRegister'); Add: parent::__construct(); Quote
markusr Posted January 10, 2010 Report Posted January 10, 2010 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 Quote
Administrators Nabeel Posted January 10, 2010 Administrators Report Posted January 10, 2010 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 Quote
markusr Posted January 11, 2010 Report Posted January 11, 2010 Oh, thanks for the hint. Yes, its working now perfect Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.