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:
Quote:
http://www.yoursite.com:5002/pkg/package_name/add_account.ecl
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:
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