huggys Posted December 5, 2008 Share Posted December 5, 2008 Hello, I didn't know where else to put this, so please forgive me if I am posting in the wrong area. I sell hosting and I use WHMCS (which I absolutely love!!! I am thinking of purchasing a license for a landscaping business too, lol) With my hosting, I install a script for each of my customers. I have most of the script files in the cpanel3-skel folder so that they are automatically uploaded to a client's site upon creation. After that, I password protect 2 folders (one with no password and the other with the user and pass they choose while signing up through whmcs), manually create a database, upload a sql file to the database, modify 3 files (with website and db info), and change the permissions on one of those files through cPanel (it is a config file, so I can't change the permissions through FTP). Is there anyway I can automate this process so that it is all done when a client signs up? Either in or out of WHMCS? Thank you for any help on this! 0 Quote Link to comment Share on other sites More sharing options...
GORF Posted December 7, 2008 Share Posted December 7, 2008 I actually did this for osCommerce - using osCommerce as the cart and setting up osCommerce for the customer. I even had a domain checker and registrar module. It definately was involved, but it worked. I like WHMCS better, but haven't got back to automating script installs. I found file permissions set in the cpanel3-skel folder get set on the copy in the customer's folder. This helps. What I used was a form/post class that grabbed variables from the checkout process and posted commands to cPanel to create a database, db user/pass, grant db permissions, run the SQL (file copied from skel), create user/pass, apply to folder to protect, write config files, CHMOD some files, etc. One step at a time and there were some timing issues as you don't have feedback if each step is completed. I had to sleep the script between steps. As this was for a new domain/hosting account, the domain did not resolve yet. The commands had to be posted to my server's IP with the new user/pass. When cPanel was upgraded from 10 to 11, most of the commands changed. If a customer changes their theme, the commands won't work either. I had to mimic the URLs as if you were logged into cPanel performing various tasks. I can share the class file and some sample script if you want. 0 Quote Link to comment Share on other sites More sharing options...
brianoz Posted December 8, 2008 Share Posted December 8, 2008 I think the correct way to do this is probably through cPanel's /scripts/postwwwacct script; it's how we've done similar automation. There's a heap of doco on the cpanel site, but I can also help a little with some scripts if needed; PM me ... 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted December 8, 2008 Share Posted December 8, 2008 and also the /scripts/postwwwacctuser script 0 Quote Link to comment Share on other sites More sharing options...
huggys Posted December 8, 2008 Author Share Posted December 8, 2008 (edited) Thank you all for replying. Brianoz, I can't figure out how to PM. I've checked the forum help file and it says to click on the email button below a post, but that isn't showing up for me. I don't even see a place in my user cp where I would check messages. I was able to add you to my contacts in the user cp, but I'm not sure what that does. I've just updated my signature to include my hosting link, so please feel free to contact me through that. I would love the help. TonsOfStores, the script I use is osCommerce too, so what you wrote sounds perfect! Any help you could provide would be great! Edited December 8, 2008 by huggys add signature 0 Quote Link to comment Share on other sites More sharing options...
GORF Posted December 8, 2008 Share Posted December 8, 2008 Is that the script you are installing for the customers? bianoz and sparky are correct to use those, what I did was quite some time ago. I can still share some of the specific stuff to get osC setup. 0 Quote Link to comment Share on other sites More sharing options...
huggys Posted December 8, 2008 Author Share Posted December 8, 2008 Yes, I am installing osCommerce for my customers. I have made a lot of revisions to it to make it more user friendly. I would love it if you could share the specific osC stuff. I'm afraid I have no idea what I am doing. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
routerboy Posted December 10, 2008 Share Posted December 10, 2008 Hello - Not sure how to do it exactly with osCommerce populating the WHMCS tables, but when I needed to populate a custom database and custom table after a client created a user account on WHMCS, I used the actionhooks php file. Worked like a champ! RB 0 Quote Link to comment Share on other sites More sharing options...
LemonBarley Posted December 10, 2008 Share Posted December 10, 2008 (edited) routerboy: please share the file or the codes in actionhooks if you have made it work ha Edited December 10, 2008 by LemonBarley 0 Quote Link to comment Share on other sites More sharing options...
routerboy Posted December 11, 2008 Share Posted December 11, 2008 Sure...But first: *** Attempt on a non-live production machine first. *** I removed out the custom fields I use to populate my table to keep some parts private, but I think you'll get the idea: function actionhook_ClientSignup($vars) { # This function runs when a new client is added # $vars["ClientID"] # $vars["FirstName"] # $vars["LastName"] # $vars["CompanyName"] # $vars["Email"] # $vars["Address1"] # $vars["Address2"] # $vars["City"] # $vars["State"] # $vars["Postcode"] # $vars["Country"] # $vars["PhoneNumber"] # $vars["Password"] $vars["custom1"]; $vars["custom2"]; $vars["custom4"]; if ($_POST["custom4"] == "2"){ // do nothing } else{ ### Setting up to send custom email and insert ### // The Group ID to insert the user as belonging to. Leave as zero for no group. $ttgid = 0; // The Database name $ttdb_db = "put your db name here"; // The MySQL username with access to this database $ttdb_user = "user name here"; // The MySQL user's password $ttdb_pass = "password"; // The host the database is on - most of the time - its localhost; other wise add IP:Port $ttdb_host = "localhost"; ##################### $ttdb = mysql_connect($ttdb_host, $ttdb_user, $ttdb_pass); mysql_select_db($ttdb_db, $ttdb); $query = mysql_query(("insert into MY CUSTOM TABLE set firstname = '".$_POST["firstname"]."', lastname = '".$_POST["lastname"]."', custom1 = '".$_POST["custom1"]."', custom2 = '".intval($_POST["custom2"])."', custom4 = '".intval($_POST["custom4"])."', zipcode = '".$_POST["postcode"]."', email = '".$_POST["email"].'"), $ttdb); // prep to send email $to = $_POST["email"]; $subject = "Registration Complete"; $message = ''; $message .= '<br>'; $message .= '<br>'; $message .= '<p>Hello '.$_POST["firstname"].' '.$_POST["lastname"].'.'; $message .= '<br>'; $message .= '<br>'; $message .= '<p>First name: '.$_POST["firstname"]; $message .= '<p>Last name: '.$_POST["lastname"]; $message .= '<p>Email: '.$_POST["email"]; $message .= '<br>'; $message .= '<br>'; $message .= '<br><p>Regards,<br>'; $message .= 'Support Team'; $message .= '<br>'; $message .= '<br>'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=windows-1251\r\n"; $headers .= "From: Registration Team <registration@yourdomain.com>\n"; $headers .= "Bcc: you@yourdomain.com\n"; mail($to, $subject, $message, $headers); mysql_query($query, $ttdb); mysql_close($ttdb); } } RB 0 Quote Link to comment Share on other sites More sharing options...
huggys Posted December 11, 2008 Author Share Posted December 11, 2008 Hi, thank you so much for posting. I contacted my host (I resell hosting) and they say that I can't do anything through cPanel's /scripts/postwwwacct script because of the way that their servers are setup. So, going through WHMCS is the way I need to do this. Unfortunatley, I was not able to get this to work. I use dreamweaver and the line: $ttdb = mysql_connect($ttdb_host, $ttdb_user, $ttdb_pass); mysql_select_db($ttdb_db, $ttdb); $query = mysql_query(("insert into MY CUSTOM TABLE set firstname = '".$_POST["firstname"]."', lastname = '".$_POST["lastname"]."', custom1 = '".$_POST["custom1"]."', custom2 = '".intval($_POST["custom2"])."', custom4 = '".intval($_POST["custom4"])."', zipcode = '".$_POST["postcode"]."', email = '".$_POST["email"].'"), $ttdb); Seems to be missing a ' (of course, I'm not sure where, dreamweaver just pointed out the error). All of this is greek to me. I really just copied/pasted this into WHMCS where the function actionhook_ClientSignup($vars) left off. I'm assuming that the ### Setting up to send custom email and insert ### // The Group ID to insert the user as belonging to. Leave as zero for no group. $ttgid = 0; // The Database name $ttdb_db = "put your db name here"; // The MySQL username with access to this database $ttdb_user = "user name here"; // The MySQL user's password $ttdb_pass = "password"; // The host the database is on - most of the time - its localhost; other wise add IP:Port $ttdb_host = "localhost"; is where I enter the database information for where I uploaded my sql file that I want on everyone's account. Am I correct? I'm not worried about the automated email since WHMCS already sends an automated email with my custom message when an account is created. Also, I'm not sure what all the [custom] stuff is. Thank you everyone for all of your help so far! I really appreciate this. 0 Quote Link to comment Share on other sites More sharing options...
Zorro67 Posted December 11, 2008 Share Posted December 11, 2008 re the missing " ' ", It would appear to be email = '".$_POST["email"].'"), $ttdb); s/be email = '".$_POST["email"]."'), $ttdb); (note the reversed order of the last pair of quotes. 0 Quote Link to comment Share on other sites More sharing options...
huggys Posted December 12, 2008 Author Share Posted December 12, 2008 Thanks, that does look better. However, it is still not working. I am now thinking that it is missing a " because of the beginning: (("insert into shouldn't that have another " at the end somewhere? Also, for the: insert into MY CUSTOM TABLE set firstname should I leave that as it is or should I be replacing the MY CUSTOM TABLE for something? Thanks again for helping me with this! I'm sorry I'm such a newbie. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted June 30, 2009 Share Posted June 30, 2009 shouldn't that have another " at the end somewhere? Yes. email = ' ".$_POST["email"].' "), Should be (spaces addes for clarity) email = ' ".$_POST["email"]." ' "), Change is at the end: Double quote, single then double. 0 Quote Link to comment Share on other sites More sharing options...
Zorro67 Posted June 30, 2009 Share Posted June 30, 2009 Bear, are you trolling to get your post rate up? The previous post was 7 months ago 0 Quote Link to comment Share on other sites More sharing options...
bear Posted June 30, 2009 Share Posted June 30, 2009 Bear, are you trolling to get your post rate up? The previous post was 7 months ago Definitely. Weird, I'd hit new posts, and this one was there. Never looked at the date, but why the heck would that happen? 0 Quote Link to comment Share on other sites More sharing options...
Zorro67 Posted July 1, 2009 Share Posted July 1, 2009 I dunno! You're the FA. If you don't know, we're all in trouble. 0 Quote Link to comment Share on other sites More sharing options...
huggys Posted July 1, 2009 Author Share Posted July 1, 2009 I'm still subscribed to the forum though and I really appreciate the help. I haven't tried this since I last posted 7 months ago and I can't wait to try it again. I don't know if I'll be able to try it today though because I am trying to decide if I want to stick with the reseller hosting I am doing or if I should go with a dedicated server. I know if I went with a dedicated server, I would be able to automate this another way. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.