Automatic Deletion and Creation (Email, Subdomains, FTP, Addon/Parked domains, MySQL)

Status
Not open for further replies.

KingDrew

Active Member
Oct 24, 2004
28
0
151
Paris, Texas
This morning I developed a PHP class that will do the following:
Create/Remove Addon Domains
Create/Remove Parked Domains
Create/Remove MySQL Databases
Create/Remove Mail Accounts
Create/Remove FTP Accounts
Create/Remove Subdomains
Generate Full Backup

I have not yet developed any documentation for it yet, but if you look at the code it is self-explanatory. Example usage to create a subdomain would be:
PHP:
<?php
include("class.cpanel.php");

$cuser = "username";
$cpass = "password";
$cdomain = "domain.com";

$cpanel = new cpanel($cuser,$cpass,$cdomain);
$cpanel->CreateSubDomain("sub",$cdomain);
?>
This will not output or return anything. It will just simply load the page that creates the subdomain on the server-side so the client will not see your username or password. It's actually that simple to create a subdomain automatically. I'm not sure if it will work on all servers but it's worth a try. The class file is attached to this post. Please rename it to class.cpanel.php.

Update: In case of an error, this script will not throw an error. If you are using this, please update it immediately.
 

Attachments

Last edited:

internetfab

Well-Known Member
PartnerNOC
Feb 20, 2003
336
0
166
Gothenburg, Sweden
cPanel Access Level
DataCenter Provider
Many thanks, been looking for a class like this to set up bulk emails for customers moving to our servers and having manually create 100+ email adresses ;)

Now they could just give us a list and we could do a while loop on the list using this class :)

*cheers*
 

Albertof

Registered
Oct 27, 2004
1
0
151
Not is more easy implement a solution to cpanel-email in perl?.

but i say perl.. but perl and suexec run the script as the user, so you can use:

cpanel-email addpop <popuser> <password> <quota> <domain>

Look this on my ssh shell, im running the user "prueba"

-bash-2.05b$ /usr/local/cpanel/cpanel-email addpop testeo password 10 prueba.com
<!---Doing Null Password Check-->
<!---Done Doing Null Password Check-->
<!---Doing Null Email Check-->
<!---Done Doing Null Email Check-->
<!---Doing Max Email Check-->
<!---Done Max Email Check-->
<!---Grabbing Salt-->
<!---Done Grabbing Salt-->
<!--crypting()-->
<!--done crypting()-->
<!--fetch pwnam info-->
<!--done fetch pwnam info-->
<!--recrecord-->
<!--done recrecord-->
<!--chown-->
<!--done chown-->
Sorry the account testeo already exists!
-bash-2.05b$ /usr/local/cpanel/cpanel-email addpop testeo1 password 10 prueba.com
<!---Doing Null Password Check-->
<!---Done Doing Null Password Check-->
<!---Doing Null Email Check-->
<!---Done Doing Null Email Check-->
<!---Doing Max Email Check-->
<!---Done Max Email Check-->
<!---Grabbing Salt-->
<!---Done Grabbing Salt-->
<!--crypting()-->
<!--done crypting()-->
<!--fetch pwnam info-->
<!--done fetch pwnam info-->
<!--recrecord-->
<!--done recrecord-->
<!--chown-->
<!--done chown-->
<!--open PASSWD-->
<!--open QUOTA-->
<!--open SHADOW-->
<!--close QUOTA-->
testeo1+prueba.com
-bash-2.05b$
 
Last edited:

PartieHonteuse

Registered
May 20, 2004
3
0
151
Ok, first of all I'd like to say thank you for creating this class. It's a great thing! One problem I'm having (since I'm such an intermediate user of php) I was wondering how I would be able to do something like this...

somefile.php

Code:
<?php
$cuname = "cpaneluname";
$cpass = "mypass";
$cdomain = "mydomain.net";
$euname = "testing1";
$epass = "testing";
include("class2.cpanel.php");


$cpanel = new cpanel('$cuname','$cpass','$cdomain');
$cpanel->CreateEmail('$euname','$epass','$cdomain');
?>
When I do that, it doesn't work but when I just use text for the cpanel username/pass/domain etc. it works and I've tried reading about variable scopes and all that good stuff but I can't figure it out for the life of me. Any help or pointers would be appreciated.

Partie™
 

smadeira

Registered
Dec 3, 2004
1
0
151
Get rid of the single quotes (as shown below) and it should work.

$cpanel = new cpanel($cuname,$cpass,$cdomain);
$cpanel->CreateEmail($euname,$epass,$cdomain);
 

PartieHonteuse

Registered
May 20, 2004
3
0
151
Thanks for the response but for some reason it doesn't work. I've actually tried a NUMBER of things before posting. I really don't like posting questions until I've exhausted my resources. I'll try it again real quick, i guess maybe I could've done something dumb.

Partie™
 

zaggs

Member
Dec 5, 2004
21
0
151
Problem...

Hi,
Great class! However, when executing the CreatParked function - it does not work for me...

Here is the code I am using:
PHP:
$user = "user";
$pass = "pass";
$domain = "domain";

include("config.php"); 

$cpanel = new cpanel('$user','$pass','$domain'); 
$cpanel->CreateParked('domain.com');
Any help is appreciated...
 

Blue Dot Labs

Registered
Jan 1, 2005
4
0
151
would i need to alter the class to include my reseller account login or anything in order to let it create accounts and function properly? or would just running it from my reseller domain be enough?
 

NoMercy

Member
Jul 23, 2004
5
0
151
Superb !
This is just what I am looking for.
Hoping to adapt it to let me administrate autoresponder messages etc

Thanks
 

NoMercy

Member
Jul 23, 2004
5
0
151
OK I managed to make a function to add and delete autoresponders..... is there a way I can get it to view existing ones or will i need to store the autoresponder in an accessible mysql table for instance, as well as adding to cpanel ?
 

Shane_F

Member
Jan 21, 2005
23
0
151
KingDrew said:
This morning I developed a PHP class that will do the following:
Create/Remove Addon Domains
Create/Remove Parked Domains
Create/Remove MySQL Databases
Create/Remove Mail Accounts
Create/Remove FTP Accounts
Create/Remove Subdomains
Generate Full Backup

I have not yet developed any documentation for it yet but if you look at the code it is self-explanitory. Example usage to create a subdomain would be:
PHP:
<?php
include("class.cpanel.php");
$cpanel = new cpanel('username','password','domain.com');
$cpanel->CreateSubDomain('sub','domain.com');
?>
This will not output or return anything. It will just simply load the page that creates the subdomain on the server-side so the client will not see your username or password. It's actually that simple to create a subdomain automatically. I'm not sure if it will work on all servers but it's worth a try. The class file is attached to this post. Please rename it to class.cpanel.php.

Update: In case of an error, this script will not through an error. If you are using this, please update it immediately.

This is great! :) GOod for those "free" host and "free" email accounts. :)
 

KingDrew

Active Member
Oct 24, 2004
28
0
151
Paris, Texas
I'd like to thank you everyone for their comments. I've updated the code sample to use quotes instead of single quotes as smadeira suggested (thanks). If anyone is interested in adding code to this, PM me with the code and I will add it if it is legit.
 

baryk

Registered
Apr 30, 2005
1
0
151
Thank you Thank you Thank you!

Thank you sooo much for developing such a great class!!

I was looking for a solution to create a subdomain without having to logon to cPanel and did a lot of search on Google for 3 days and couldn't find anything and then I registered on this forum hoping to find something..... WOW!!!! this is exactly what I wanted!!!

Thank you!!!! :)
 

BrooksBridges

Well-Known Member
Sep 2, 2004
50
0
156
Is there anything that could be added to this to set quotas of ftp accounts? Curious for a project I've got going.

Thanks!
-Brooks
 

germanette

Active Member
Jul 26, 2003
28
0
151
A Perl rendition

These are just the functions I needed for my program, but the general idea can be adapted to other functions also.
 

Attachments

internetfab

Well-Known Member
PartnerNOC
Feb 20, 2003
336
0
166
Gothenburg, Sweden
cPanel Access Level
DataCenter Provider
The only problem is when the cpanel theme varies for different accounts and you don't know which one they're using (yes, you could check but then what's the point of this script).

Guess an array with available cpanel themes and go through it til you get access..
 

prixone

Well-Known Member
Mar 4, 2004
111
3
168
cPanel Access Level
Root Administrator
germanette said:
These are just the functions I needed for my program, but the general idea can be adapted to other functions also.
only problem at your script is, you cant know if you did create with success once the module you are using just receive the code;
return like code 200, code 404

so you cant know if create success or errors were found.

but if there is no erro for sure it will create.
 

lastprotocol

Registered
Feb 4, 2006
2
0
151
As a novice with php can someone help me out here, I know that this is exactly what I need to use for a project I working on, but I have little or no idea how to implement it :confused:

I would like to have a simple form, which will include prefered username/password etc - when submitted the form autogenerates a sub-domain and ftp account based on the username/password selected - the form checks for duplicates and returns "name already in use" if necessary etc.

Can someone help me out?
 
Status
Not open for further replies.