PenUltima Online

It is currently Fri Sep 05, 2008 1:55 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Auto Account Creation
PostPosted: Tue Apr 11, 2006 7:28 pm 
Offline

Joined: Mon Feb 20, 2006 6:58 pm
Posts: 7
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 ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 9:58 pm 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl