thebizbuilder
Member-
Posts
22 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Hotfixes
Everything posted by thebizbuilder
-
Apache rebooter when creating account for plesk 10
thebizbuilder replied to jambon's topic in Using WHMCS
This is the same problem im having since upgrading to plesk 10. Ill follow the instructions and post my results. Thanks for pointing me in the right direction! -
Just to update, it appears that its giving 504 error when trying to run plesk10 module commands. Really frustrating because it effect signups and cancellations etc etc! Anyone else having this issue with plesk 10? Apparantly its really buggy and im regretting upgrading to plesk 10 now! Grr!
-
Hi, I have not long upgraded to the new WHMCS control panel and plesk 10. Prior to this everything seemed to be working fine(I had the old WHMCS and Plesk 9.5) I have made the changes in plesk and WHMCS to ensure that it would be possible to create and terminate accounts, however whenever I go into a test client to try and create, terminate etc their product it just loads forever and then shows a white screen. This also in the process crashes my apache server which I then have to restart!? I'm really confused. Any help would be most appreciated!
-
I was wondering if anyone knows of a way to have a hook based on when an invoice becomes over due??? I have tried using "invoiceunpaid" however this does not seem to have the desired effect as it does not perform the hook when an invoice becomes OVERDUE, which is quite an important time to be running certain tasks. Also it only seems to work when the invoice is set to unpaid in the admin panel and doesn't run automatically!? Any ideas would be greatly appreciated! Thanks in advance!
-
Sorry but better than the aftermodule create would be the action hook named "addonactivation" duuh! Lol
-
Hi Tom. Ill give u a few pointers. Im no expert but i have done a bit of work with whmcs! Firstly you will want to look at action hook. You can find them in the documentation on this site. You will likely use something like "aftermodulecreate" which basically will allow you to execute any php code u like when someones hosting package becomes active. Here you will be sent a set of variables mentioned in the documentation as $params this holds all you variables passed from whmcs. There is a list in the module creation documentation, in the template file. Then you have the task of posting the variables in your form. I suggest you do some reading on curl and php, and do a simple curl post execution. Its used everywhere over the web and there is plenty of info about it. I think paypal uses curl. There will be tutorials online about posting forms etc. I think that would be the best route to go down. If you have any other questions. Send them through!
-
Module to Create email Account in cPanel
thebizbuilder replied to rnathaniel's topic in Developer Corner
I am loving this question and would like to know myself if there are any modules or plugins or whatever that will allow automatic or whmcs client area email creation on plesk for me though! -
A new problem with hooks and FTP {{{HELP!}}}
thebizbuilder replied to thebizbuilder's topic in Developer Corner
LMAO, sorry in the in the frustration of it not working and me being an idiot and changing all different things to get it to work I had deleted the GLOBALS from the ftpRec function, I just put them back in and now its working!!! :D:D:D this is GREEAT thank you for all your help bdigitalstudios ur a star! :D:D:D -
A new problem with hooks and FTP {{{HELP!}}}
thebizbuilder replied to thebizbuilder's topic in Developer Corner
no wait, actually I lied its not even doing the css directory! Its not doing anything!? -
A new problem with hooks and FTP {{{HELP!}}}
thebizbuilder replied to thebizbuilder's topic in Developer Corner
Hi, Thank you so much for your reply. That seems to have worked however there is another problem and again I have no idea why its doing this! My file structure inside the '"/var/www/vhosts/********/httpdocs/sites/".$dir' is like: /testsite/ index.html thankyou.html /css/style.css /css/style2.css /images/blah.jpg /images/blah.jpg /images/blah.jpg /images/blah.jpg The script seems to be creating and uploading everything in the CSS directory perfectly but doesn't do anything else However its heading in the right direction. I don't get any syntax errors or anything but I get a lot of php WARNING errors, so many that it crashes my browser lol! I'm trying to see if they are stored in the log on the server to put them here! OOOoo here are the warnings I am getting...well some of them, there are LOADS!!! [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: chdir() [<a href='function.chdir'>function.chdir</a>]: open_basedir restriction in effect. File(../) is not within the allowed path(s): (/var/www/vhosts/******/httpdocs:.:/php:/usr:/tmp:/etc:/var) in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 99, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: chdir() [<a href='function.chdir'>function.chdir</a>]: open_basedir restriction in effect. File(../) is not within the allowed path(s): (/var/www/vhosts/******/httpdocs:.:/php:/usr:/tmp:/etc:/var) in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 99, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: ftp_put() expects parameter 1 to be resource, null given in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 86, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate [Fri Dec 10 19:45:54 2010] [error] [client 81.97.91.187] PHP Warning: chdir() [<a href='function.chdir'>function.chdir</a>]: open_basedir restriction in effect. File(../) is not within the allowed path(s): (/var/www/vhosts/******/httpdocs:.:/php:/usr:/tmp:/etc:/var) in /var/www/vhosts/******/httpdocs/whmcs/includes/hooks/uploadpackage.php on line 99, referer: http://www.******/whmcs/admin/clientshosting.php?userid=4&id=69&modop=terminate I hope you can help me on this. Thank you so much again, you are the first person to help me -
Hi all, I'm looking for some quick help on this problem that I'm having. What I want is a hook that transfers certain files to a newly created hosting package once it has been created. This is the code that I have so far and there is some additional code that I have used to test the ftp functions I have, these work fine on their own, however when I use them in the hook they fail to transfer the files over ftp to the newly created hosting package. Please take a look and see if you can spot anything and let me know... My appolagies for the messy code I have been changing and mixing things up trying to get it work and it has left it in a right state! <?php /* ******************************************** * Hook file that will detect when a client * * has paid and activated their account and * * uploads their selected site to their * * hosting. * ******************************************** */ function install_package($params) { #sleep has been put in because maybe this script was running too quickly after creation of module sleep(10); #THIS FUNCTION INSTALL THE PACKAGE THAT WAS REQUESTED AT TIME OF ORDERING. #FIRST GET THE PACKAGE THAT IS NEEDING INSTALLING $dir = getSiteDir($params['params']["customfields"]); #TRANSFER ALL FILES TO NEW DOMAIN // set the various variables $ftproot = "/httpdocs/"; $srcroot = "/var/www/vhosts/********/httpdocs/sites/".$dir; $srcrela = "/"; // connect to the destination FTP & enter appropriate directories both locally and remotely $ftpc = ftp_connect($params['params']['serverip']); $ftpr = ftp_login($ftpc,$params['params']['username'],$params['params']['password']); if ((!$ftpc) || (!$ftpr)) { echo "FTP connection not established!"; die(); } if (!chdir($srcroot)) { echo "Could not enter local source root directory."; die(); } if (!ftp_chdir($ftpc,$ftproot)) { echo "Could not enter FTP root directory."; die(); } // start ftp'ing over the directory recursively ftpRec ($srcrela); // close the FTP connection ftp_close($ftpc); #CREATE AND UPLOAD CONFIG FILE FOR USERNAME AND PASSWORD FOR CONTROL PANEL ETC } add_hook("AfterModuleCreate",1,"install_package"); // -------------------------------------------------------------------- // THE ACTUAL FUNCTION // -------------------------------------------------------------------- function ftpRec ($srcrela) { global $srcroot; global $ftproot; global $ftpc; global $ftpr; // enter the local directory to be recursed through chdir($srcroot.$srcrela); // check if the directory exists & change to it on the destination if (!ftp_chdir($ftpc,$ftproot.$srcrela)) { // remote directory doesn't exist so create & enter it ftp_mkdir ($ftpc,$ftproot.$srcrela); ftp_chdir ($ftpc,$ftproot.$srcrela); } if ($handle = opendir(".")) { while (false !== ($fil = readdir($handle))) { if ($fil != "." && $fil != "..") { // check if it's a file or directory if (!is_dir($fil)) { // it's a file so upload it $res .= ftp_put($ftpc, $ftproot.$srcrela.$fil, $fil, FTP_BINARY); } else { // it's a directory so recurse through it if ($fil == "templates") { // I want the script to ignore any directories named "templates" // and therefore, not recurse through them and upload their contents } else { ftpRec ($srcrela.$fil."/"); chdir ("../"); } } } } closedir($handle); } } function getSiteDir($customfields) { #FUNCTION TO GET THE DIRECTORY OF THE SELECTED SITE AND RETURN IT #FOR TESTING PURPOSES THIS WILL BE SET TO RETURN TESTSITE $dir = 'testsite'; return $dir; } ?>
-
Action Hook - phpBB3 User Registration
thebizbuilder replied to FrostByte's topic in Developer Corner
great to hear that you got it working . Yes that is a good suggestion, another option would have been to use the same username and password that are generated for your hosting creation(if you have one) But well done! its a challenge at times especially if you are not getting any error messages which is the issue I am having at the moment. I have a script that is being called using the hooks, its running fine but not doing what I want it to!!! GRRR I'm getting close to posing it on the forum here for advice! -
Action Hook - phpBB3 User Registration
thebizbuilder replied to FrostByte's topic in Developer Corner
WOAH I did post another message before that but it never showed up!, Basically I said that in the API documentation it say you cannot use decryptpassword API call to get the clients password. So maybe that supposed to be used for the hosting password or something? http://wiki.whmcs.com/API:Decrypt_Password -
Action Hook - phpBB3 User Registration
thebizbuilder replied to FrostByte's topic in Developer Corner
just a note....the Get_Clients_Password API actually returns the MD5 hash, so couldn't you just use this straight away instead of decrypting and re-encrypting the password? I dunno just a thought, might not work -
Action Hook - phpBB3 User Registration
thebizbuilder replied to FrostByte's topic in Developer Corner
Hey i just reviewed the documentation and the API call you are using to decrypt the users password doesn'tactually decrypt the clients password from whmcs. I'm guessing its used to decrypt the password stored for the server password, that your client would use to log-in to plesk or c-panel for example. http://wiki.whmcs.com/API:Decrypt_Password However I am new to this also and am not very experienced! Just a hunch. -
Yeh it is difficult, however I don't even get php errors in my plesk logs for the API call. It is the same with the action hooks, any code that errors when the action hooks are called don't seem to produce errors that get logged on the server. It would be great if there could be some form of simple debug log that shows any issues with modules, action hooks and API calls that logs into the admin panel! That would be an amazing feature that would make development much easier. Also I'm not sure if anyone else has found this but when you first create an action hook it seems like it takes a bit of time for the hook to actually start working, I usually find it begins working after the next cron run. This is obviously a problem if this is true because it doesn't seem to be documented anywhere. Has anyone else found this? Its like the hook has to propogate or something!? Generally though I am happy with the results I am getting through this system, and there are a few tweaks that would make life easier as a developer! But oh well, no product or system ever is 100% what you want!
-
Appeard to be a small error in my api call, i was calling 'suspendunmodule' instead of the real one or something. One issue is with action hooks and api writing is error logging. Although my code was wrong there were no errors and i had to go through very carefully to find the errors! Oh well!.....thanks for all your help
-
I still haven't managed to get the action hooks to work. To the action hooks get called even if u set an invoice to paid/unpaid in the admin panel?? I would assume that they do. Is there anything else that needs to be set to allow the action hooks to work, like in automation setting or something?? Thanks in advance
-
Hi I am trying to create action hooks that run when invoice is set to paid or unpaid... I am testing this in the admin panel by simply generating an invoice and then setting it to paid or unpaid to trigger the action log. I have included my code here, if anyone would be so kind as to have a look that would be great. p.s. I have tested all the individual functions and they seem to be working correctly!? Thanks in advance! <?php /* ******************************************** * Hook file that will suspend all services * * connected to an account with an unpaid * * invoice. And will reactivate when invoice* * has been paid. * ******************************************** */ #Function that suspends all modules associated with an account. function suspend_all($vars) { #$vars['invoiceid'] is passed, must first get account number and then get any services/products associated with the account and suspend them using the WHMCS API //write function to get userid $userid = getUserid($vars['invoiceid']); //write function to get array of services/products (API POSSIBLY CAN USE action="getclientproducts") //includes suspention suspendAllservices($userid); } #Function that will unsuspend account when invoice payment has been made and no other outstanding invoices are existing function unsuspend_all($vars) { #$vars['invoiceid'] is passed, must check for any other unpaid outstanding invoices before continuing to unsuspend account //GET USERID $userid = getUserid($vars['invoiceid']); //USE API TO GET INVOICES, USE XML TO SELECT ONLY UNPAID THEN IF 0 CONTINUE TO UNSUSPEND if(getUnpaidInvoices($userid)==0){ //USE GET ALL SERVICES FUNCTION unsuspendAllservices($userid); } else { #function to send out all unpaid invoice emails? } } add_hook("InvoiceUnpaid",1,"suspend_all"); add_hook("InvoicePaid",1,"unsuspend_all"); function getUserid($invoiceid) { #FUNCTION TO RETURN USERID USING THE INVOICE ID mysql_connect('localhost', '*******', '*****'); mysql_select_db('whmcs'); $query = 'select * FROM `tblinvoices` WHERE `id` = "'.$invoiceid.'"'; $result = mysql_query($query)or die(mysql_error()); $row = mysql_fetch_array($result); return $row['userid']; } function suspendAllservices($userid) { #FUNCTION THAT USES THE WHMCS API TO GET ALL THE SERVICES $url = "http://*******/whmcs/includes/api.php"; # URL to WHMCS API file $username = "******"; # Admin username goes here $password = "******"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "getclientsproducts"; #action performed by the API:Functions $postfields["clientid"] = $userid; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); $dom = new DOMDocument(); $dom->loadHTML($data); $services = $dom->getElementsByTagName('product'); foreach ($services as $elem) { $url = "*****/whmcs/includes/api.php"; # URL to WHMCS API file $username = "*****"; # Admin username goes here $password = "******"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "modulesuspend"; #action performed by the API:Functions $postfields["accountid"] = $elem->getElementsByTagName('id') ->item(0) ->nodeValue; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); } } function unsuspendAllservices($userid) { #FUNCTION THAT USES THE WHMCS API TO GET ALL THE SERVICES $url = "*****/whmcs/includes/api.php"; # URL to WHMCS API file $username = "*****"; # Admin username goes here $password = "******"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "getclientsproducts"; #action performed by the API:Functions $postfields["clientid"] = $userid; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); $dom = new DOMDocument(); $dom->loadHTML($data); $services = $dom->getElementsByTagName('product'); foreach ($services as $elem) { $url = "*****/whmcs/includes/api.php"; # URL to WHMCS API file $username = "****"; # Admin username goes here $password = "****"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "unmodulesuspend"; #action performed by the API:Functions $postfields["accountid"] = $elem->getElementsByTagName('id') ->item(0) ->nodeValue; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); } } function getUnpaidInvoices($userid) { #function that gets all unpaid invoices returns qty of unpaid invoices mysql_connect('localhost', '******', '******'); mysql_select_db('whmcs'); $query = 'select * FROM `tblinvoices` WHERE `status` = "Unpaid"'; $result = mysql_query($query); return mysql_num_rows($result); } ?>
-
Hi everyone, first post here and I have a little question. I not sure that this is already possible using the current admin area in whmcs. However let me explain my situation and what I would like: I have a product that sets up hosting and domain on my dedicated server, it works great and all thats fine. However I use billable items to add invoices to peoples accounts for various things that they may want. Which generates them a separate invoice through which they pay using a different system to the origional sign up, which also works great. Here's where I need the help, if my client fails to pay the invoice generated by my billable items(which use a different service as they need a different payment gateway) can I setup whmcs to suspend ALL the services linked with that account? I was thinking that if it was not possible through existing admin options I might have to write an action-hook?? to pick up when an invoice becomes overdue then suspend all services and products connected with that account right? Just one final question, I run this all through a plesk server, one aditional thing I would like todo is, when someone misses a payment of any kind, when the accounts become suspended I would like to show some form of page on their website saying like, this account has been suspended due to missed invoices or something. without deleting their site obviously. Any ideas with regards to this? I really appreciate all your time thank you in advance!
