Idealws Posted October 21, 2008 Share Posted October 21, 2008 Hello, First I would like to say I like the new licensing addon. I had started working on integrating PHP Audit with WHMCS and never finished it as I got to busy. I am glad I never finished it as this new addon is easy to use and integrate as well as expand on. With that said. I have created a function which will allow you to create trial accounts for your products. It is simple to add as it is a function you would put in your check license file or however you are using the current code. Basically this is how it works: 1. You enter the number of days you want the license to expire in. 2. Call the function using the date the script was registered and the expire days. 3. The function will return either FALSE which means it is past the days allotted or it will return the remaining days left. 4. From there you can either stop the script or show how many days there are left. Here is the code and how to use it: // Set the number os days until it expires $licexpires = "15"; // Let's create a function that locks the system out // for trial accounts based off the trial days function check_trial($keydate,$expdays) { // Lets get the reg date and format it as needed list($syear,$smon,$sday) = explode("-", $keydate); // Create the start date from the original reg date $startdate = gregoriantojd($smon, $sday, $syear); // Create the actual date so we can compair $currdate = gregoriantojd(date("m"),date("d"), date("Y")); // Lets see how many days it has been so far $daysdiff = $currdate - $startdate; // Lets see if there are any days left $daysleft = $expdays - $daysdiff; // Check if we are past the days expired if($daysdiff > $expdays) { $expired = FALSE; // if past days expired return expired return $expired; }else{ // If not past expired days send days left return $daysleft; } } // Lets check to see if the license is expired $isexpired = check_trial($results['regdate'], $licexpires); // If it is expired we need tro do something if($isexpired == FALSE) { // If expired print out error and exit script execution echo "Your $licexpires day trial license is expired"; exit; }else{ // If it is not expired lets print how many days are left echo $isexpired; } The way I suggest using it is setup a new product with the license the Key prefix of say Trial15- then you can test it against only license that start that way. If your not sure how to do that you can check it like so: $keyparts = explode("-", $results['licensekey']); if($keyparts['0'] == "Trial15") { // Process you trial checks here. } Hope this helps those of you who are using the new license module. Please let me know if you have any questions about this little hack. Best Regards, Ray 0 Quote Link to comment Share on other sites More sharing options...
atDev Posted October 22, 2008 Share Posted October 22, 2008 Did you do an import from audit to whmcs? 0 Quote Link to comment Share on other sites More sharing options...
Idealws Posted October 22, 2008 Author Share Posted October 22, 2008 I have not done a import yet from phpaudit to whmcs. Matt has given me the import script but I have not tested it. Regards, Ray 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.