Automatic Forum account creation

Hello,

i’m new with phpVMS and have problems with the automated forum registration in phpbb3.

i have the event registered but problems with this script here :

<?php

class ForumRegister extends CodonModule

{

public function __construct()

{

CodonEvent::addListener(‘ForumRegister’);

}

public function EventListener($eventinfo)

{

if($eventinfo[0] == ‘registration_complete’)

{

echo “include_path:::”.$include_path;

define(‘IN_PHPBB’, true);

$phpbb_root_path = ‘core/modules/forum/’;  // 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 = ‘test1’;

$password = ‘test1’; // Do NOT encrypt !

$email  = ‘[email protected]’; // 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;

}

}

}

?>

i become errors from php “cannot redeclare template”

Can anyone help here ?

Matthias

Can you paste the exact error?

Could be phpBB which is complaning

Hello,

yes here it is :

Fatal error: Cannot redeclare class template in /usr/export/www/vhosts/funnetwork/hosting/starflight/core/modules/forum/includes/template.php on line 24

Matthias

Ahh phpBB probably has a class named Template already.

Is there a way to do it just using SQL instead of using their code

as i sayd before .. i’m very new in phpCMS.

But i’m also new with phpbb3 and php…sorry.

Can you explain it to me ?

Thanks

Matthias

I have a class named template, and phpBB does too, and the :

include($phpbb_root_path . ‘common.php’);

Is probably also including their template class, conflicting with mine.

I’m gonna try to find a way (not sure if I’ll get time soon) to find a way to insert it directly into the database instead of using their code to do it, since it’s conflicting

if you know the sql syntax and can give it to me i can insert it between this lines in the forumregistration.php

<?php

class ForumRegister extends CodonModule

{

public function __construct()

{

CodonEvent::addListener(‘ForumRegister’);

}

public function EventListener($eventinfo)

{

if($eventinfo[0] == ‘registration_complete’)

{

                              /// YOUR SQL CODE HERE ?

}

}

}

?>

Matthias

Yeah, you need the phpBB SQL to insert a user to add into there

yes i have found it in another forum:

$result = mysql_query("INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)

VALUES ($user_id, ‘" . str_replace("’“, “‘’”, $username) . “', " . time() . “, '” . str_replace(”'”, “‘’”, $new_password) . “', '” . str_replace(“'”, “‘’”, $email) . “', '” . str_replace(“'”, “‘’”, $icq) . “', '” . str_replace(“'”, “‘’”, $website) . “', '” . str_replace(“'”, “‘’”, $occupation) . “', '” . str_replace(“'”, “‘’”, $location) . “', '” . str_replace(“'”, “‘’”, $interests) . “', '” . str_replace(“'”, “‘’”, $signature) . “', ‘$signature_bbcode_uid’, $avatar_sql, $viewemail, '” . str_replace(“'”, “‘’”, str_replace(’ ‘, ‘+’, $aim)) . "’, ‘" . str_replace("’“, “‘’”, $yim) . “', '” . str_replace(”‘", "’‘", $msn) . "’, $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popup_pm, $user_timezone, ‘" . str_replace("’“, “‘’”, $user_dateformat) . “', '” . str_replace(”‘", "’‘", $user_lang) . "’, $user_style, 0, 1, 1, ‘’)");

but i dont know if the syntax s correct

Have a look on the phpbb3 forums, it is possible but not easy, you have to use their routine because its links to all other settings and stuff, if you fill in a username and email in this template code it does work the password files is the tricky one however you can register new users without password and they can use the forgot / reset password to set a new one.

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

So you can see above that all that needs to be filled in is the,

$username = ‘’;

$password = ‘’; // Do NOT encrypt !

$email  = ‘’; // Please validate this email yourself ! Phpbb will accept non-valid emails.

Presto new account created, so if you manually typed in

$username = ‘username’;

$password = ‘’; // Do NOT encrypt !

$email  = ‘[email protected]’; // Please validate this email yourself ! Phpbb will accept non-valid emails.

That would be enough to create the new account

There’s a conflict with class names in using their routine

I hate PHPBB, I use SMF…did you guys get this working?

Have a look on the phpbb3 forums, it is possible but not easy, you have to use their routine because its links to all other settings and stuff, if you fill in a username and email in this template code it does work the password files is the tricky one however you can register new users without password and they can use the forgot / reset password to set a new one.

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

So you can see above that all that needs to be filled in is the,

$username = ‘’;

$password = ‘’; // Do NOT encrypt !

$email  = ‘’; // Please validate this email yourself ! Phpbb will accept non-valid emails.

Presto new account created, so if you manually typed in

$username = ‘username’;

$password = ‘’; // Do NOT encrypt !

$email  = ‘[email protected]’; // Please validate this email yourself ! Phpbb will accept non-valid emails.

That would be enough to create the new account

Hello,

thanks for the Answer, but when i use this code inside the ForumRegistration.php there is a conflict with the template classe i think.

I will say if i copy and paste this code inside the registered Module i become a error.

Can you help pls ?

Matthias

Yes it does thats because as Nabeel siad there’s a conflict with class names in using their routine.

I think its a bit unfair to ask for support here on this matter, Nabeel has done a fantastic job in creation of this VA admin software which is ongoing and you have to agree its fantastic.

Im sure its possible but i dont have the answers and im sure Nabeel hasn’t got the time to develop this at the moment as well, but if he has a chance then im sure he will but its not a priority.

Yes it does thats because as Nabeel siad there’s a conflict with class names in using their routine.

I think its a bit unfair to ask for support here on this matter, Nabeel has done a fantastic job in creation of this VA admin software which is ongoing and you have to agree its fantastic.

Im sure its possible but i dont have the answers and im sure Nabeel hasn’t got the time to develop this at the moment as well, but if he has a chance then im sure he will but its not a priority.

Wowwowwow…yes, i’m absolutely with you !!!

He has done a absolutely fantastic job with phpVMS !!!

But i only need to find a solution, not only from hm, also from other users here. I think here are other user using the phpBB3 with an automatic user registration.

I think its also possible to open a new connection to the phpBB3 Database and then fill in the UserData or not ?

I only not have the expirience about php and sql.

Matthias

Why open a new connection when you could just use the same one. merging the DB’s is no trouble at all…The table name im sure are different than that of phpvms…just use the same database.

ok, ihave reinstalled the phpBB3 and it uses now the same database as phpVMS.

But as i sayd before, i am not the crack of php and so on.

So can you please give me an example of code how i can add a user in phpBB3’s user table and

how i can find the name of the registering user from phpVMS ?

Thanks

Matthias

Table names do differ, that’s why there’s the table prefixes also.

To get the name etc of the registered user in the event:

if($eventinfo[0] == 'registration_complete')
      {

$userinfo = $eventinfo[2];

$userinfo->firstname;

$userinfo->lastname;

$userinfo->password;

$userinfo->email

etc,

That’s probably all you need, but do print_r($userinfo) to get all the fields.

You can open a new DB connection if phpBB is a different DB. That’s not a problem. I usually keep different apps on different DBs.

Hello,

ok, i have found a solution to create a user for the phpBB3.

<?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 = $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_lang, user_type, user_actkey, user_dateformat, user_style, user_regdate) VALUES ('”.$pilot_id.“', '”.$pilot_id_klein.“', '”.$passMD5.“', '”.$email.“‘, ‘2’,‘1.0’, ‘0’,‘de’,‘0’,’',‘d M Y H:i’, ‘1’, '”.$tm.“')”);

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

echo “Result: “.mysql_error().”<br>”;

print_r($userinfo);

}

}

}

Sorry, i will sort the code later.

For them moment i need a code that a user ( i have created or alway is in the phpBB3 Database ) is automaticly logged in after he clicked a link to reach the Forum.

I have searched in the php Forum , but nothin found.

Can anyone help about this ?

Matthias

I’m not sure if you can automatically log-in, since phpBB does send a confirmation link until they are activated