diff options
author | ivan <ivan> | 2005-11-12 00:17:43 +0000 |
---|---|---|
committer | ivan <ivan> | 2005-11-12 00:17:43 +0000 |
commit | 0210b124f3ad13d42698682ed18c61858eb40ce5 (patch) | |
tree | 208c6066105bf8615ef117a1f0f249f3a32d3c05 | |
parent | be9a87ae0cc60259ca8d62047af6d2529b57a373 (diff) |
try using web interface scrape bullshit for adding pops instead of API, as per cpanel support [cPanel tickets ID# 116044]
-rw-r--r-- | FS/FS/part_export/cpanel.pm | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/FS/FS/part_export/cpanel.pm b/FS/FS/part_export/cpanel.pm index 9c1f60e16..278c80ff7 100644 --- a/FS/FS/part_export/cpanel.pm +++ b/FS/FS/part_export/cpanel.pm @@ -91,13 +91,50 @@ sub cpanel_queue { sub cpanel_insert { #subroutine, not method my( $machine, $user, $accesshash, $debug ) = splice(@_,0,4); - my $whm = cpanel_connect($machine, $user, $accesshash, $debug); - warn " cpanel->createacct ". join(', ', @_). "\n" - if $debug; - my $response = $whm->createacct(@_); - die $whm->{'error'} if $whm->{'error'}; - warn " cpanel response: $response\n" + +# my $whm = cpanel_connect($machine, $user, $accesshash, $debug); +# warn " cpanel->createacct ". join(', ', @_). "\n" +# if $debug; +# my $response = $whm->createacct(@_); +# die $whm->{'error'} if $whm->{'error'}; +# warn " cpanel response: $response\n" +# if $debug; + + warn "cpanel_insert: attempting web interface to add POP" if $debug; + + my($domain, $username, $password, $svc) = @_; + + use LWP::UserAgent; + use HTTP::Request::Common qw(POST); + + my $url = + "http://$user:$accesshash\@$domain:2082/frontend/x/mail/addpop2.html"; + + my $ua = LWP::UserAgent->new(); + + #$req->authorization_basic($user, $accesshash); + + my $res = $ua->request( + POST( 'http://$user:$accesshash@$domain:2082/frontend/x/mail/addpop2.html', + [ + 'email' => $username, + 'domain' => $domain, + 'password' => $password, + 'quota' => 10, #? + ] + ) + ); + + die "Error submitting data to $url: ". $res->status_line + unless $res->is_success; + + die "Username in use" + if $res->content =~ /exists/; + + die "Account not created: ". $res->content + if $res->content =~ /failure/; + } #sub cpanel_replace { #subroutine, not method |