New ISPConfig module for WHMCS

Discussion in 'Tips/Tricks/Mods' started by cwispy, Dec 11, 2014.

  1. Timmy Oblatus

    Timmy Oblatus New Member

    Nice work cwispy! I'm not sure how it works with GIT yet, but i have a few ideas on how to deal with a few errors i've run into.

    1) As for your own reseller issue (i can't seem to grasp how ISPConfig differs between clients and resellers in the database) but i'm thinking that using the clients e-mail address from rather than then username from the order. Before adding the new client, you would do check if the client already exists by doing: $client->client_get_by_username($session_id, [e-mail address from WHMCS]) and reuse the client info - if it itsn't found, then continue creating the new client. The username should still the username value from WHMCS or maybe an option to use the domain name as FTP username? Ideally the client in ISPConfig should be created with same username and password (if it can be retrieved) as their WHMCS account, and the username/password data from the order itself should be used for the FTP account only.

    2) In my test, after creating the first site, all sites on the ISPConfig server crashed with an error 500 - probably because the 'pm' setting was left out when creating the website, this would be ideal to have an option for this in WHMCS. Also stats_type should be configureable and stats_password (same as for the FTP account)

    The current client creation process prevents the same user from creating another order with the same product/server since the customer_no must be unique.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats quite esay, a reseller is a client that has "sub" clients. So a reseller is a client where max_clients is != 0.
     
  3. cwispy

    cwispy Active Member

    Thanks for the feedback Tim. Obviously I need to do more testing, but it is also hard to account for every possibility, so its good for others to test and provide feedback.
     
  4. cwispy

    cwispy Active Member

    I have been looking at the logic for creating users and have run into an issue that I would like others to comment on.

    After "Timmy Oblatus" mentioned the issues above about creating users with unique id's, I thought I could use the clients email address as the client username, but that is not allowed by the rules in ISPConfig, so instead I did a replace on the @ with an underscore for the client username. So [email protected] became user_example.tld. However this then presents another issue of how to sync the password of the client in WHMCS with ISPConfig.

    So at the moment, the only way I can see to do it, is to create a new client in ISPConfig for each service in WHMCS.

    Thoughts anyone?

    Edit: I have just committed updates to GIT which seems to be working with multiple services for the same client. I have now created numerous client accounts on my dev setup and it seems to be happy now.
     
    Last edited: Dec 17, 2014
  5. webguyz

    webguyz Active Member HowtoForge Supporter

    I guess it depends on what kind of packages you want to sell but I think you will have to create a new client in WHMCS which will create the ISPConfig account

    I would like to sell unlimited plans, kind of like a reseller where the customer can create unlimited websites,mail,dbs and the only limitation is the disk space

    In that case a single account in WHMCS is fine, Customer is responsible for creating his own websites and he never needs more then 1 whmcs / iscponfig account

    But I also want to sell individual websites with 1 website, 1 db and say 10 emails for a very low price. I would setup a master reseller account and and then add that any of these single users who sign up to my master reseller account. so there has to be an option field in the back end to add a reseller account id

    If a end user wants to manage multiple single accounts then you have to create a reseller account and then manually add these single accounts. That's what I was thinking about account creation.
     
  6. nokia80

    nokia80 Member

    nice i wait a long time fore this function
     
  7. MasteRTriX

    MasteRTriX Member

    I installed a new ispconfig to test this module but I'm having an issue.
    The module creates the client ok but after that I get the error
    Code:
    SOAP Error: no_server_error<br /> 
    The response in the log of whmcs is
    Code:
    Array
    (
        [accountid] => 46
        [serviceid] => 46
        [userid] => 25
        [domain] => testing.com.ar
        [username] => testing
        [password] => ******
        [packageid] => 21
        [pid] => 21
        [serverid] => 9
        [type] => other
        [producttype] => other
        [moduletype] => ispcfg3
        [configoption1] => ispconfig
        [configoption2] => ***********
        [configoption3] => 200.61.*.*:8080
        [configoption4] => on
        [configoption5] => 1
        [configoption6] => default
        [configoption7] => no,fast-cgi,php-fpm
        [configoption8] => no
        [configoption9] => on
        [configoption10] => on
        [configoption11] => 
        [configoption12] => 1024
        [configoption13] => -1
        [configoption14] => 
        [configoption15] => none
        [configoption16] => php-fpm
        [configoption17] => on
        [configoption18] => 
        [configoption19] => 
        [configoption20] => en
        [configoption21] => on
        [configoption22] => on
        [configoption23] => 
        [configoption24] => 
        [customfields] => Array
            (
            )
    
        [configoptions] => Array
            (
            )
    
        [clientsdetails] => Array
            (
                [userid] => 25
                [id] => 25
                [firstname] => Test
                [lastname] => Ting
                [fullname] => Test Ting
                [companyname] => testing
                [email] => [email protected]
                [address1] => asdlfk
                [address2] => asldkj
                [city] => laksjd
                [fullstate] => laksjd
                [state] => laksjd
                [postcode] => 1155
                [countrycode] => AR
                [country] => AR
                [statecode] => laksjd
                [countryname] => Argentina
                [phonecc] => 54
                [phonenumber] => 1234123
                [phonenumberformatted] => +54.1234123
                [billingcid] => 0
                [notes] => 
                [password] => 6e89f4eaesdf03eacb129cc36fe9a4f8:FJVq%
                [twofaenabled] => 
                [currency] => 1
                [defaultgateway] => 
                [cctype] => 
                [cclastfour] => 
                [securityqid] => 1
                [securityqans] => 12345678
                [groupid] => 0
                [status] => Active
                [credit] => 0.00
                [taxexempt] => 
                [latefeeoveride] => 
                [overideduenotices] => 
                [separateinvoices] => 
                [disableautocc] => 
                [emailoptout] => 0
                [overrideautoclose] => 0
                [language] => spanish
                [lastlogin] => Date: 17/01/2014 01:28<br>IP Address: 186.23.53.***<br>Host: cpe-186-23-53-***.telecentro-reversos.com.ar
                [customfields1] => 
                [customfields] => Array
                    (
                        [0] => Array
                            (
                                [id] => 1
                                [value] => 
                            )
    
                    )
    
            )
    
        [server] => 1
        [serverip] => 200.61.*.*
        [serverhostname] => ispconfig.*******.com.ar
        [serverusername] => ispconfig
        [serverpassword] => ********
        [serveraccesshash] => 
        [serversecure] => on
        [action] => create
    )
    
     
  8. cwispy

    cwispy Active Member

    Did you create a server group of the ISPConfig servers?
     
  9. MasteRTriX

    MasteRTriX Member

    I did, but didn't select it in the module config of the product.
    Thanks!
     
  10. BenM

    BenM Member

    DNS template

    I tested the module and see that the DNS records are not created in accordance with the dns template. I have created the default setting and an additional template, but neither of them works.

    Does anyone have a tip?

    Good work.
     
  11. MasteRTriX

    MasteRTriX Member

    Seeing the same behaviour, module creates the zone ok, but doesn't create records inside it.

    I see nothing wrong in the module, looks exactly like the example of the api. I'll see the api source so see if something else should be in the module.

    Edit: the module is doing what is programmed so far to do. Add a dnz zone, the api from what I've seen in the examples, doesn't allow you to give it a templete to create records, you must create record by hand. So the plugin is just fine. Just needs more coding to do more things.

    This is the dns_zona_add function from the api. It's doing what it's supposed to
    Code:
    dns_zone_add($session_id, $client_id, $params);
    
    Description:
    
    Adds a new dns zone.
    
    Input Variables:
    
    $session_id, $client_id, $params
    
    Parameters (in $params):
    
    server_id  (int(11))
    
    origin  (varchar(255))
    
    ns  (varchar(255))
    
    mbox  (varchar(255))
    
    serial  (int(11))
    
    refresh  (int(11))
    
    retry  (retry(11))
    
    expire  (int(11))
    
    minimum  (int(11))
    
    ttl  (int(11))
    
    active  (enum('n','y'))
    
    xfer  (varchar(255))
    
    also_notify  (varchar(255))
    
    update_acl  (varchar(255))
    
    Output:
    
    Returns the ID of the newly added dns zone.
    
    Looking at the api source I see another function called dns_templatezone_add that's not documented, I'll try to make the module work with that function
     
    Last edited: Dec 22, 2014
  12. MasteRTriX

    MasteRTriX Member

    Just managed to make it work

    On line 175
    Add
    PHP:
    $zoneip<---><------>= $dnssettings[4];
    Below
    PHP:
    $dnstemplate        $dnssettings[3];
    And search for the line 490
    And replace
    PHP:
    $dns_id $client->dns_zone_add$session_id$client_id$ispcparams );
    with

    PHP:
    $dns_id $client->dns_templatezone_add$session_id$client_id$dnstemplate$domain$zoneip$nameserver1$nameserver2$soaemail );

    edit:
    Sorry forgot line 115
    PHP:
            'DNS Settings' => array(
                        
    'Type' => 'text',
                        
    'Size' => '20',
                        
    'Description' => 'Syntax: NS1,NS2,Emailname,Templateid,Zone IP Address',
                                        . 
    'eg: ns1.domain.tld,ns2.domain.tld,'
                                        
    'webmaster,1,123.123.123.123'
                
    ),
     
    Last edited: Dec 22, 2014
  13. BenM

    BenM Member

    Template is used

    The template is now being used, fine.

    Only the value of the a- records {IP} is empty and the e-mail adres in the zone has a dubble dot at the eind.

    Nice
     
  14. BenM

    BenM Member

    IP is fixed.
    only isseu is the extra dot in the soa email adres

    Thanks
     
  15. cwispy

    cwispy Active Member

    Try changing line 174 from

    $soaemail = $dnssettings[2] . '.' . $domain.'.';

    to

    $soaemail = $dnssettings[2] . '.' . $domain;
     
  16. cwispy

    cwispy Active Member

    Thanks MasteRTrix. I have submitted your patch to git.
     
  17. MasteRTriX

    MasteRTriX Member

    No cwispy thank you!!!! The difficult part is to start coding, now that you've done it, I think this module will only grow and get better!!!!

    In time I'll try to add functions to manage most basic functions from within whmcs (like email addressess, ftp accounts)
     
  18. nokia80

    nokia80 Member

    hi all

    I get this error when module make second website on same user:


    SOAP Error: customer_no_error_unique<br />
     
  19. nokia80

    nokia80 Member

    The client id is always 5 so no new client is make

    thanks
     
  20. cwispy

    cwispy Active Member

    This should fix the SOAP Error: customer_no_error_unique<br />
    PHP:
    @@ -142,+142,@@ function ispcfg3_ConfigOptions() {
    function 
    ispcfg3_CreateAccount$params ) {
    $productid $params['pid'];
    $accountid $params['accountid'];
    $domain strtolower$params['domain'] );
    $username $params['username'];
    $password $params['password'];
    @@ -
    362,+363,@@ function ispcfg3_CreateAccount$params ) {
    $ispcparams = array(
    'company_name' => $companyname,
    'contact_name' => $fullname,
    'customer_no' => $productid,
    'customer_no' => $accountid,
    'username' => $username,
    'password' => $password,
    'language' => $defaultlanguage,
     
    Last edited: Dec 25, 2014

Share This Page