Jump to content

Recommended Posts

  • Moderators
Posted

Nabeel what im trying to do is once a pilot is approved then a forum account is created, I have the creation script i just need to put it in to the trigger which i want to be the approve button, or thinking on further maybe when you click the pilots name i could add a button to create a forum account as well.

The easiest option would be to get the script to fire reading the profile name email etc when the approve pilot button is hit, so i suppose the question is what happens now when you double click the accept pilot.

Hope i make some kind of sence,

Thanks

  • Like 1
  • Administrators
Posted

Well, you can create a module with events, but I haven't hashed out an events system for the admin. You can use the "register_complete" event when they actually register to create the profile:

http://www.phpvms.net/docs/development:02_events_list#registration_complete

Scroll up a bit to see how to create the module, and then the event. Hopefully that makes sense. You can use "registration_precomplete" even to get the user info, but in this next build I fixed it to postcomplete includes the user info.

That will 'fire' when they create a profile, but before it's approved. The next update will have an events subsystem for the admin panel; I haven't done it uptil now because no one is really using it.

  • Moderators
Posted

Hi guys, i feel a bit cheeky asking this but i have been trying to get this to work and i keep hitting a brick wall, im no coder but i have the code that works to directly create accounts i just need the code to pass it the details from the registration data ie firstname lastname and pilotid passwird and email.

If anyone has the time to explain to an old man who should have learnt coding years ago i would be grateful.

Thanks

  • Administrators
Posted

Hey no prob,

First you have to create a module:

So, create a folder in /core/modules called "ForumRegister"

Then create a file: ForumRegister.php

Inside that, paste:

<?php
class ForumRegister extends CodonModule
{

public function __construct()
{
	CodonEvent::addListener('ForumRegister');
}

public function EventListener($eventinfo)
{
	if($eventinfo[0] == 'registration_complete')
	{ 
		// Place your forum registration code here

		// You'll need their user information, so
		$userinfo = $eventinfo[2];

		$userinfo->firstname;
		$userinfo->lastname;
		//etc

		// do :

		print_r($userinfo);

		// to show all the options
	}
}	
}
?>

This creates the module and sets up the event listener, and then when the registration_complete event is fired, that bit of code will run.

Now, I think you're running the latest beta build, which fixes a bug where that user info wasn't passed.

I hope that helps!

  • Moderators
Posted

No prob! Lemme know if you need any other help/if that worked. Kinda just banged it out, didn't really test it ;)

You make it seem so easy :)

Thanks for that will give it a try later when i finish work.

  • Moderators
Posted

Thats what im using bb3, here is the code for phpbb3. as you are taking the data from a sanitised source all of the safe guards have been removed, valid email etc.... This code takes the data from the existing redistration page and puts it directly in to bb3 db. I have not had chance to check fully but will be testing tonight.

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

?>

Let me know if you get it working  ;D  hopefully find the time tonight fingers crossed.....

  • Moderators
Posted

still not magaged to get it to work with phpbb3, this is a good feature so if we can get this working on A forum then that would be good, i suppose add to the list lol. can someone ask for more hours in the day....

  • Moderators
Posted

OK i have tried and tried and i have no hair left. So i have switched to SMF, i had the thing working as a test but then i tried messing about and wrecked it lol....

Here is what i started with so it will give you some idea if you know what your doing unlike me lol.....

Good luck :)

<?php
include "forum/SSI.php"; //your forum path
include "forum/Sources/Subs-Members.php";
?>

<script language="JavaScript" type="text/javascript" src="/forum/Themes/default/script.js?fin11"></script>

<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function verifyAgree()
{
if (document.forms.registrationForm.passwrd1.value != document.forms.registrationForm.passwrd2.value)
{
	alert("The two passwords you entered are not the same!");
	return false;
}
if (!document.forms.registrationForm.regagree.checked)
{
	alert("Please read and accept the agreement before registering.");
	return false;
}
return true;
}
function checkAgree()
{
document.forms.registrationForm.regSubmit.disabled = isEmptyText(document.forms.registrationForm.user) || isEmptyText(document.forms.registrationForm.email) || isEmptyText(document.forms.registrationForm.passwrd1) || !document.forms.registrationForm.regagree.checked;
setTimeout("checkAgree();", 1000);
}
setTimeout("checkAgree();", 1000);
// ]]></script>

<?php
if (!isset($_POST['regSubmit'])) {
?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td style="width: 600px;">

	<form action="<?php echo $PHP_SELF; ?>" method="post" accept-charset="ISO-8859-1" name="registrationForm" onsubmit="return verifyAgree();">
	<table cellspacing="0" cellpadding="5" border="0">

	<tr>
	<td>
		<b>Choose username:</b>
	</td>
	<td>
		<input type="text" name="user" size="20" tabindex="1" maxlength="25" />
	</td>
	</tr>

	<tr>
	<td>
		<b>Email:</b>
	</td>
	<td>
		<input type="text" name="email" size="30" tabindex="2" />
			<label for="hideEmail">
				<input type="checkbox" name="hideEmail" id="hideEmail" class="check" />
				 Hide email address from public?
			</label>
	</td>
	</tr>

	<tr>
	<td>
		<b>Choose password:</b>
	</td>
	<td>
		<input type="password" name="passwrd1" size="30" tabindex="3" />
	</td>
	</tr>

	<tr>
	<td>
		<b>Verify password:</b>
	</td>
	<td>
		<input type="password" name="passwrd2" size="30" tabindex="4" />
	</td>
	</tr>

	<tr>
	<td colspan="2"><?php
	$agreement = fopen("forum/agreement.txt", "r"); while(!feof($agreement)) { $line = fgets($agreement); echo $line; } fclose($agreement);
	?>
	</td>
	</tr>

	<tr>
	<td colspan="2" align="center">
		<label for="regagree">
			<input type="checkbox" name="regagree" onclick="checkAgree();" id="regagree" class="check" />
			 <b>I Agree</b>
		</label>
	</td>
	</tr>

	<tr>
	<td colspan="2">
		<div align="center">
			<input type="submit" name="regSubmit" value="Register" />
		</div>
	</td>
	</tr>

	</table>
	</form>
	<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
		document.forms.registrationForm.regagree.checked = false;
		document.forms.registrationForm.regSubmit.disabled = !document.forms.registrationForm.regagree.checked;
	// ]]></script>
</td>
</tr>
</table>
<?php
} else {

$password = sha1(strtolower($_POST['user']) . $_POST['passwrd1']);
$password2 = sha1(strtolower($_POST['user']) . $_POST['passwrd2']);
$regOptions = array(
	'interface' => 'guest',
	'username' => $_POST['user'],
	'password' => $password,
	'password_check' => $password2,
	'email' => $_POST['email'],
	'check_reserved_name' => true,
	'check_email_ban' => true,
	'send_welcome_email' => false,
	'require' => 'nothing',
	'auth_method' => 'password',
);

registerMember($regOptions);
}	
?>

Posted

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  = 'test1@test1.de'; // 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

Posted

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

  • Administrators
Posted

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

Posted

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

Posted

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

  • Moderators
Posted

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  = 'you@yourdomain.com'; // Please validate this email yourself ! Phpbb will accept non-valid emails.

That would be enough to create the new account

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