Jump to content

Licensing Integration Sample Code?


WP-MLM

Recommended Posts

@ WP-MLM

 

I have a Wordpress plugin ready to sell and want to use WHMCS to take care of the licensing / upgrades and support.

 

Can you please offer any further guidance on what you did to integrate your plugin with WHMCS licensing system?

 

How hard is it really for the client to simply remove the check file and related calls to that ?

Presumably, you'd have to ioncube ALL of your app files?

 

Any insight appreciated !

 

My suggestion would be to add the licensing checks into one of your include files possibly one with your functions in it that cannot be removed or it will break the system completely.

 

Regards,

Ray

Link to comment
Share on other sites

Just for information, I have implemented the license manager but used ColdFusion to carry out the license checks. It took a bit of doing but works very well indeed.

 

The point is that the addon is not aimed at noobs or those who know nothing about coding otherwise why would you purchase it in the first place?

Link to comment
Share on other sites

  • 11 months later...

There is an additional check everyone should be checking for. You should be checking for a remote connection failure!!!!

 

if ( $results['status'] == "Remote Check Failed" )
{
   echo "Connection is temporarily interrupted!";
   break;
}

 

and or

 

} elseif ($results['status']=='Invalid') {
   # Show Invalid Message
} elseif ($results['status']=='Expired') {
   # Show Expired Message
} elseif ($results['status']=='Suspended') {
   # Show Suspended Message
[b]} elseif ($results['status'] == "Remote Check Failed") {
   # Show Remote Check Failure
}

[/b]

 

or

 

} elseif ($result["status"]=="Invalid") {
 die('License could not be verified, please contact us for assistance.');
} elseif ($result["status"]=="Expired") {
die('License could not be verified, please contact us for assistance.');
} elseif ($result["status"]=="Suspended") {
die('License could not be verified, please contact us for assistance.');
[b]} elseif ($result["status"]=="Remote Check Failed") {
die('License could not be verified, please contact us for assistance.');
}[/b]

 

Also, it amazes me how many people are trying to use this addon without knowing php. Seems very strange what people are trying to protect with a license check if they dont know php. Strange.

Edited by mikie
Link to comment
Share on other sites

<?php
# Get Settings from DB and put into variable
# Get License Key
$licensekey = get_option("license_key");
# Get WP-MLM local key
$localkey = get_option("local_key");

# The call below actually performs the license check. You need to pass in the license key and the local key data

$results = check_license($licensekey,$localkey);

# For Debugging, Echo Results
//echo '<textarea cols=100 rows=20>'; print_r($results); echo '</textarea>';

# Begin Section 
# Put this section in the function you DO NOT want to run unless active key is present
if ($results['status']=='Active') {
   # Allow Script to Run
   if ($results['localkey']) {
       # Save Updated Local Key to DB
       $localkeydata = $results["localkey"];
       save_local_key($localkeydata);
   }
} elseif ($results['status']=='Invalid') {
   # Show Invalid Message
   $licensedata = '';
} elseif ($results['status']=='Expired') {
   # Show Expired Message
   $licensedata = '';
} elseif ($results['status']=='Suspended') {
   # Show Suspended Message
   $licensedata = '';
}

}
# End of section

# Inserts local key into DB
function save_local_key($localkeydata) {
 update_option("local_key", $localkeydata);
 return;
 die;

# Inserts license key into DB
# Call this function on submission of form you use to enter license key to store in DB
function save_license_key($licensekeydata) {
 update_option("license_key", $licensekeydata);
 return;
 die;
?> 

 

I 'dumbed' this down a lot, just as an example of one method you can use, I personally used this to integrate for my WordPress plugin and it works PERFECTO!

 

A far more effective method of this should be placing the licensekey and local key into an array and storing it as one field instead of adding more fields to the options table thus reducing reads and accesses.

Link to comment
Share on other sites

  • 11 months later...

Hi Guys

I have the same issues here.

1 I have a script ( php & MySQL ) which clients at present pay me then download then upload to there servers. They then install and run on there servers.

 

So I wanted to get some sort of licensing program to stop the thief's so I bought the WHMCS LICENSE ADDON :) get I thought seems like I just load to my admin/whmcs files and quick config and go.???

 

oh no it seems I have to make a DB table or something to store these keys??? I was under the thought process that once its configured in my admin /whmcs and then I add the sample code provided ( with my server changes) to my script im selling and all done??

 

Im totally confused here and all support do is say " you need a programmer "?

 

Basically I want my clients to ( when bought and uploaded my sales script) to be the first place where they copy and past the auto key that was given at the checkout?

 

why are we having to add extra code to make it work and no real explanations.

 

I thought at least all keys for bought products are help in the whmcs DB ( license section) and this script calls from there to check?

 

have I got this completely wrong or what??

 

im sure its very simple and can do some coding but this is getting beyond a joke now.

 

thanks if some one can help

Link to comment
Share on other sites

Im still baffled it really is not good that you still have to pay some one or do extra coding to get it too work..

 

This is just funny to me. You're paying for the module, the ability to license php software. The integration / sample code is provided as a starting point or a sample. A way to get you on the right track.

 

If you have no idea how to work with it or make it work for you, you clearly don't know anything about php and have no business buying a module like this or doing any php dev work for that matter.

Link to comment
Share on other sites

This is just funny to me. You're paying for the module, the ability to license php software. The integration / sample code is provided as a starting point or a sample. A way to get you on the right track.

 

If you have no idea how to work with it or make it work for you, you clearly don't know anything about php and have no business buying a module like this or doing any php dev work for that matter.

 

What!!!..... I don't know what work you offer or do but over here if you sell something then it is best to make it clear that you need to know or get extra help.

Rather than critise why don't you help out and if your not able to then leave your non productive comments at your own door

Link to comment
Share on other sites

What!!!..... I don't know what work you offer or do but over here if you sell something then it is best to make it clear that you need to know or get extra help.

Rather than critise why don't you help out and if your not able to then leave your non productive comments at your own door

I have contributed plenty on this topic and have a clue what I'm talking about. See my posts on the first page of this thread. ;)

 

As a consumer, you shouldn't buy a product that is targeted at consumers with a specific skill set unless you have that skill set or are prepared to pay someone with that skill set to complete a task for you.

 

If you understand and are able to code in php, this module is perfect and requires no explanation on how to use it.

Link to comment
Share on other sites

I have contributed plenty on this topic and have a clue what I'm talking about. See my posts on the first page of this thread. ;)

 

As a consumer, you shouldn't buy a product that is targeted at consumers with a specific skill set unless you have that skill set or are prepared to pay someone with that skill set to complete a task for you.

 

If you understand and are able to code in php, this module is perfect and requires no explanation on how to use it.

 

Well i have already looked at your input and others It was whmcs tech support tickets that sent me here and another place.

 

I can do some coding but not what is required and have connected with others on here and elsewhere to help and even pay to get sorted. I just find it amazing that whmcs don't actually provide or give an example working for beginners as you can see others have and are in the same boat as me and you weren't so brash with them i always thought a forum was there to help each other not comment on what they should buy and not buy . My main business is marketing not programming.

 

As im sure if you're maybe a qualified car mechanic like myself you wouldn't offer a spare new tyre and ask the customer to fit it them self's would you..... i think we best leave these comments from now on and concentrate of the issue.. but thanks for your input.

Link to comment
Share on other sites

The licensing addon was designed for developers to integrate licenses into the applications they develop. So, it is assumed you have some programming knowledge when using this addon. Writing the local key and/or license key to a text file is not ideal. You can do it, but it is not ideal. You would have to consider file permissions for the client installing the module depending on their web server configuration (they would need to set permissions on the file to allow the module to read and write the local key). The best way to handle this is to write the local key to the database.

 

If developing WHMCS modules, there is a table called tbladdonmodules where settings of your module get written. Within the configuration function, of the module, you would create a "field" called "licensekey". There you will allow the user to enter the license key for the module. Within the activate function, of the module, you would do a SQL insert to add a "localkey" field to the tbladdonmodules table for your module (make sure within the deactivate function, you remove the "localkey", for the module, using a SQL delete). Within the license checking code, you would have it query the licensekey and localkey fields (SQL select), within tbladdonmodules, and do a SQL update to the localkey if it needs to be updated.

Edited by SeanP
Link to comment
Share on other sites

The licensing addon was designed for developers to integrate licenses into the applications they develop.

 

I guess I should have just emphasized this...

 

@Spytron, I really meant no offense!

 

It's a tool for developers, not marketing and sales people or customer service or server admins. It's for Developers. If you're not a developer, you need to hire one. There is no reason why WHMCS would need to release a fully working piece of code since it will not fit for everyone.

 

What I use in my apps is completely different than what WHMCS provided for an example.

Link to comment
Share on other sites

  • 6 years later...

Hello group!
I have integrated the licensing code into a PHP project and the license information is only displayed with a command

'<textarea cols="100" rows="20">' . print_r($results, true) . '</textarea>';


 

this unfortunately results in a lot of information and a slightly uglier design.

Does anyone know how I can get license information that I can integrate into an html design?
below I will post the license information displayed in the original.

 

verifylicense.PNG

Link to comment
Share on other sites

Instead of printing it in a textarea create an HTML interface and echo variables as follows:

Your license key for <? echo $results['productname']; ?> is <strong><? echo $results['status']; ?></strong>:
<ul>
  <li>IP: <? echo $results['validip']; ?></li>
  <li>Valid Domains: <? echo $results['validdomain']; ?></li>
  <li>Valid Directory: <? echo $results['validdirectory']; ?></li>
</ul>

 

Link to comment
Share on other sites

4 hours ago, Kian said:

Instead of printing it in a textarea create an HTML interface and echo variables as follows:


Your license key for <? echo $results['productname']; ?> is <strong><? echo $results['status']; ?></strong>:
<ul>
  <li>IP: <? echo $results['validip']; ?></li>
  <li>Valid Domains: <? echo $results['validdomain']; ?></li>
  <li>Valid Directory: <? echo $results['validdirectory']; ?></li>
</ul>

 

Thanks for example, i tried to integrate the code in my page but unfortunately i always get only one white page, 

This is my complete code that displays license information. (this is an experimental project and I would like to learn as much as possible)

If you could modify my code so that you integrate your code for example, it would be great (so I would understand better)

 

// Raw output of results for debugging purpose

if ($results["status"] == 'Active')
{
	print_r("<br>");
	print_r('<b style="font-size: 22px;">This license key is active </b>');
	print_r("<br>");
echo '<textarea cols="100" rows="20">' . print_r($results, true) . '</textarea>';
} else{
if (isset($_GET['key'])){
print_r("<br>");
print_r('<b style="font-size: 22px;">This license key is ' . $results["status"] . '</b>');
print_r("<br>");
}
}
//echo '<textarea cols="100" rows="20">' . print_r($results, true) . '</textarea>';
function redirect($url)
{
    $string = '<script type="text/javascript">';
    $string .= 'window.location = "' . $url . '"';
    $string .= '</script>';

    echo $string;
}
// Interpret response
switch ($results['status']) {
    case "Active":
        // get new local key and save it somewhere
        $localkeydata = $results['localkey'];
        break;
    case "Invalid":
	//redirect('./license.php?&key='.$licensekey);
        //die("License key is Invalid");
        break;
    case "Expired":
	//redirect('./license.php?&key='.$licensekey);
        //die("License key is Expired");
        break;
    case "Suspended":
	//redirect('./license.php?&key='.$licensekey);
        //die("License key is Suspended");
        break;
    default:
        //die("Invalid Response");
        break;

if ($results['status'] !== 'Active')
{
if (isset($_GET["ref"]))
{
redirect('./'.$_GET["ref"].'.php?&key='.$licensekey);
} else {

redirect('./license.php?&key='.$licensekey);
}
}
}
?>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated