• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

define php variables upon account creation and run

#1
i got this script to issue commands to my server remotely,
How would i get this to define $xenusr as the username being registered

i want this script to run upon the successful creation of a new account.

example:

PHP:
// Send a command
var_dump($r->mcRconCommand('cp give '$xenusr' 1 '));
}
?>

Working code:

PHP:
<?php
 
include_once("rcon.class.php");
 
// Extend the rcon class to tweak it for minecraft.
class minecraftRcon extends rcon {
 
function mcSendCommand($Command) {
$this->_Write(SERVERDATA_EXECCOMMAND,$Command,'');
}
 
function mcRconCommand($Command) {
$this->mcSendcommand($Command);
 
$ret = $this->Read();
 
return $ret[$this->_Id]['S1'];
}
}
 
// Server connection varialbes
$server = "minecraft.example.com";
$rconPort = 123456;
$rconPass = "PASSWORD";
 
// Connect to the server
$r = new minecraftRcon($server, $rconPort, $rconPass);
 
// Authenticate, and if so, execute command(s)
if ( $r->Auth() ) {
 
echo "Authenticated\n";
PHP:
// Send a command
var_dump($r->mcRconCommand('say Hello World!'));
}
?>
 

Jake Bunce

XenForo moderator
Staff member
#2
i want this script to run upon the successful creation of a new account.
You can do that by creating an addon to extend this function:

XenForo_ControllerPublic_Register::actionRegister

That will allow you to execute your own PHP code when a new user registers.

Or you can edit the file directly if you aren't comfortable with the addon system. But a file edit is lost when you upgrade, unlike an addon.

library/XenForo/ControllerPublic/Register.php
 
#3
You can do that by creating an addon to extend this function:

XenForo_ControllerPublic_Register::actionRegister

That will allow you to execute your own PHP code when a new user registers.

Or you can edit the file directly if you aren't comfortable with the addon system. But a file edit is lost when you upgrade, unlike an addon.

library/XenForo/ControllerPublic/Register.php
How would i make the registration process auth a username as to first askthem their desired username then associate a small auth string and send it to the game server as a msg

PHP:
var_dump($r->mcRconCommand('msg $user Enter $auth to activate your username!'));
like if i make a new account "alobot" and hit next it does
PHP:
var_dump($r->mcRconCommand('msg alobot Enter DF3GE to activate your username!'));

Then it will prompt them to enter the correct auth string before they can add the rest of the information and email verification.
 
#6
I have actully decided to make a plugin for the game server that will register player usernames and issue them a code in game and save it to a db
then my xenforo site can just verify to the db values :D