Author Topic: [Direct Admin] Auto User Signup  (Read 3898 times)

Offline Tam2

  • Newbie
  • *
  • Posts: 2
[Direct Admin] Auto User Signup
« on: November 27, 2006, 11:05:52 AM »
I Have the following perl script that i currently use to make accouts for direct admin you can view this in action @

Code: [Select]
#!/usr/bin/perl -w

# Read the standard input (sent by the form):
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
# Get the name and value for each form input:
@pairs = split(/&/, $FormData);
# Then for each name/value pair....
foreach $pair (@pairs) {
# Separate the name and value:
($name, $value) = split(/=/, $pair);
# Convert + signs to spaces:
$value =~ tr/+/ /;
# Convert hex pairs (%HH) to ASCII characters:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Store values in a hash called %FORM:
$FORM{$name} = $value;

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

print "Content-type: text/html\n\n";

foreach $line (@QUERY_STRING) {
( $var, $val ) = split (/\=/,$line);
$val =~ s/(\@|\%40)/\\\@/g;
eval &quot;\$&quot; . $var . &quot; = \&quot;&quot; . $val . &quot;\&quot;\n&quot;; print &quot;<br />&quot;;
$browser = LWP::UserAgent->new();
$browser->agent('Mozilla/4.76 [en] (Win98; U)');
push @{ $browser->requests_redirectable }, 'POST';

# change the username, password and ip address to your server information.
$response = $browser->post( $url,
action => 'create',
add => 'Submit',
user => &quot;$FORM{'user'}&quot;,
passwd => &quot;$FORM{'passwd'}&quot;,
passwd2 =>&quot;$FORM{'passwd2'}&quot;,
quota => '$FORM{'quota}',

die &quot;Can't access admin tool -- &quot;, $response->status_line
unless $response->is_success;

print $response->content;

I'm not a coder and was woundering if someone can mod the cpanel script to work with direct admin. I can also get the php version of this script from the Direct Admins API.