[freeside-commits] freeside/FS/FS/part_export cpanel.pm,1.3,1.4
Ivan,,,
ivan at wavetail.420.am
Fri Nov 11 16:17:46 PST 2005
Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail:/tmp/cvs-serv20699
Modified Files:
cpanel.pm
Log Message:
try using web interface scrape bullshit for adding pops instead of API, as per cpanel support [cPanel tickets ID# 116044]
Index: cpanel.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/cpanel.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cpanel.pm 12 Oct 2005 08:57:54 -0000 1.3
+++ cpanel.pm 12 Nov 2005 00:17:43 -0000 1.4
@@ -91,13 +91,50 @@
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
More information about the freeside-commits
mailing list