Page 1 of 1
Auto Account Creation
Posted: Tue Apr 11, 2006 7:28 pm
by Gestener
Hi, We are launching our shard on the weekend and I'd love to have an autoaccount creation for pol 095 on the web page, without using php nuke for obvious reasons. Anyone know how this is done ?
I understand it is not possible to setup 095 to just add an account if the username is not in use due to no packethooks. IF there was a way around this that would be better, if not does anyone have something which can automaticly create accounts via the web ?
Posted: Tue Apr 11, 2006 9:58 pm
by tekproxy
It's not that hard to create accounts using the web. You just create a package (or add this to an existing package) and put it in a directory called "www" inside of the package directory. You'd access it something like this:
Here's some example code to get you started. It might not compile because I just threw it together, but it should give you the general idea:
Code: Select all
use http;
use uo;
program CreateAccount( )
// Make a password check
// The URL should look like this: http://tribulation.sytes.net/pkg/webadmin/create.ecl?admin=YourPasswordHere
// You can replace "YourPasswordHere" with a function to get a password from a config file if you like
if ( QueryParam( "admin" ) != "YourPasswordHere" )
// More bark than bite
print( "Warning: Unauthorized account creation attempt." );
WriteHeader( );
WriteHtml( "Warning: Your IP has been logged and the Admin has been notified!");
WriteFooter( );
return;
endif
// Setup the variables
var name := QueryParam( "name" );
var pass := QueryParam( "pass" );
var email := QueryParam( "email" );
var lbr := QueryParam( "LBR" );
WriteHeader( );
// Check to see that we have all three fields
if( !name or !pass or !email )
WriteHtml( "Error: The name, password or e-mail address field was blank.<br>\n" );
WriteFooter( );
return;
endif
// Do a little illegal character checking
while ( name["+"] )
name["+"] := " ";
endwhile
while ( pass["+"] )
pass["+"] := " ";
endwhile
while ( email["+"] )
email["+"] := " ";
endwhile
// Create the account & set e-mail address
var ret := CreateAccount( name, pass, 1 );
ret.setprop( "email", email );
// Uncomment this if you want to see this on the console
//print( "Account: " + name + " created. LBR value: " + lbr );
// Set account as LBR if requested
if ( lbr )
ret.setprop( "LBR", 1 );
endif
if ( ret == error )
WriteHtml( "Error: Account creation failed.<br>\n" );
WriteHtml( "Details: " + ret.errortext + "<br>\n" );
else
WriteHtml( "Account added successfully!" );
endif
WriteFooter( );
endprogram
function WriteHeader( )
WriteHtml( "<html>\n<head>\n<title>Account Creation</title>\n\n<body>\n\n" );
endfunction
function WriteFooter( )
WriteHtml( "\n\n</body>\n</html>" );
endfunction