Community Forums
Connect with us on LinkedIn
Closed Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 15 of 58
  1. #1
    Member
    Join Date
    Oct 2004
    Location
    Paris, Texas
    Posts
    28

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

    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 Code:
    <?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.
    Attached Files
    Last edited by KingDrew; 08-14-2006 at 10:00 AM.

  2. #2
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    324

    Default

    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*

    twitter: oderland_david

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    1

    Smile

    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 by Albertof; 10-27-2004 at 06:31 AM.

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    3

    Default

    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™

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    1

    Default

    Get rid of the single quotes (as shown below) and it should work.

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

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    3

    Default

    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™

  7. #7
    Member
    Join Date
    Dec 2004
    Posts
    21

    Default Problem...

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

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

    include(
    "config.php"); 

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

  8. #8
    Registered User
    Join Date
    May 2004
    Posts
    3

    Default ....

    look at smadeiras post. the same will apply to you.

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    4

    Default

    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?

  10. #10
    Member
    Join Date
    Jul 2004
    Posts
    5

    Default

    Superb !
    This is just what I am looking for.
    Hoping to adapt it to let me administrate autoresponder messages etc

    Thanks

  11. #11
    Member
    Join Date
    Jul 2004
    Posts
    5

    Default

    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 ?

  12. #12
    Member Rafaelfpviana's Avatar
    Join Date
    Mar 2004
    Location
    Brazil
    Posts
    142

    Default

    will this script work if the user's password has special characters on it?
    like @

  13. #13
    Member Shane_F's Avatar
    Join Date
    Jan 2005
    Posts
    23

    Default

    Quote Originally Posted by KingDrew
    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 Code:
    <?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.

  14. #14
    Member
    Join Date
    Oct 2004
    Location
    Paris, Texas
    Posts
    28

    Default

    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.
    Drew Tempelmeyer
    Provihost

  15. #15
    Registered User
    Join Date
    Apr 2005
    Posts
    1

    Smile 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!!!!

Closed Thread
Page 1 of 4 1 2 3 ... LastLast
Similar Threads & Tags
Similar threads

  1. Replies: 4
    Last Post: 09-11-2010, 07:27 AM
  2. Parked / Addon domains & email address's dissapearing.
    By HH-Steven in forum cPanel and WHM Discussions
    Replies: 14
    Last Post: 09-28-2009, 10:17 PM
  3. Automatic Subdomains and Parked Domains
    By arharp in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 09-04-2008, 12:05 PM
  4. FTP accounts with @domain using parked/addon domains
    By alapalme in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 04-24-2006, 04:55 PM
  5. Email with domains that are parked on subdomains
    By PeterL in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 06-02-2002, 01:32 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube