RPS Posted February 14, 2008 Share Posted February 14, 2008 I just finished creating one of two parts for this license key manager program. The end result will be a complete way to use WHMCS to manage products that will send out a license key via e-mail, 100% automated. This addon contains the backend required to insert license keys, as well as mark the license keys as in use (basically, once you send out a license key, you will want to set the license you sent out, to no longer be available). Please test this out and let me know what you think. After I get some feedback, I'll post the full version. Installation Step 1) Extract the attached file to the root of your WHMCS directory. So if your WHMCS directory is http://www.domain.com/whmcs/ then you will extract the files to that whmcs directory. Step 2) Login to WHMCS, go to Utilities > Addon Modules. Click the License Keys link on the left menu. Step 3) Click the install button to install the module Step 4) You can view the source code of the page and modify the table on line 97 to set the products you wish to sell. In this example, there is a single product named Kaspersky, with multiple license options (OEM, Promo, Retail, etc..) I've had Matt review the source code really quick, and he didn't mention anything wrong. Keep in mind, this doesn't mean he supports this, he was just a nice guy and did a quick look over the module. Once I get some feedback, I'll post the full version of everything. Here's the full source code if you just want to look at the code: <style> <!-- tr.heading{font-weight:bold;text-align: center; background-color:#efefef} .success{color:#00CC00} .error{color:#FF0000} --> </style> <?php if(!mysql_num_rows( mysql_query("SHOW TABLES LIKE 'mod_license_keys'"))) { if (!$_GET["install"]) { echo ' <h2>Not Yet Installed</h2> <p>This addon module allows you to manage a database of license keys.</p> <p>To install it, click on the button below.</p> <p><input type="button" value="Install License Key Manager" onclick="window.location=\''.$modulelink.'&install=true\'"></p> '; } else { $query = "CREATE TABLE `mod_license_keys` ( `id` int(11) NOT NULL auto_increment, `company` text NOT NULL, `product` text NOT NULL, `key` text NOT NULL, `type` text NOT NULL, `avail` tinyint(1) NOT NULL default '1', KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"; $result=mysql_query($query); header("Location: $modulelink"); exit; } } // Toggle the availability if ($_GET["toggle"]) { $_id = $_GET["id"];// id of license key to toggle $_id = mysql_real_escape_string($_id); $toggle = mysql_query("SELECT avail FROM mod_license_keys WHERE id='".$_id."' ORDER BY id DESC"); while($data = mysql_fetch_array($toggle)) { if($data[0] == "1") { mysql_query("UPDATE mod_license_keys SET avail='0' WHERE id='".$_id."'"); } else { mysql_query("UPDATE mod_license_keys SET avail='1' WHERE id='".$_id."'"); } echo 'License ID: <font class="succes">'.$_id.'</font> has been updated.'; } } // Insert the new License Key if($_POST["action"]=='insert') { $company = $_POST['Company']; $licensekey = $_POST['LicenseKey']; $licensetype = $_POST['LicenseType']; $product = $_POST['Product']; $avail = $_POST['IsAvail']; $exists = 0; // added for security $company = mysql_real_escape_string($company); $licensekey = mysql_real_escape_string($licensekey); $licensetype = mysql_real_escape_string($licensetype); $product = mysql_real_escape_string($product); $avail = mysql_real_escape_string($avail); echo 'Grab license key...................................'; echo ' <font class="succes">found input key</font> '.$licensekey.' <font color="#00CC00">for '.$company.'</font>'; echo '<br />Establishing connection to database...........'; // Make a MySQL Connection echo ' <font class="succes">success</font>'; echo '<br />Insert license......................................'; $result2 = mysql_query("SELECT * FROM mod_license_keys WHERE key='".$licensekey."' ORDER BY id DESC"); while($data = mysql_fetch_array($result2)) { $exists = 1; echo ' <font class="error">ERROR</font>'; $display = '<br /><br /><br /><b>License <font class="error">'.$licensekey.'</font> already exists and thus was NOT inserted.</b>'; } if(!$exists && $licensekey!='') { // Insert a row of information into the table "example" mysql_query("INSERT INTO mod_license_keys( `id` , `company` , `product` , `key` , `type` , `avail` ) VALUES(NULL, '".$company."', '".$product."', '".$licensekey."', '".$licensetype."', '".$avail."' ) ") or die(mysql_error()); echo ' <font class="succes">success</font>'; $display = '<br /><br /><br /><b>License <font class="succes">'.$licensekey.'</font> has been inserted.</b>'; } echo $display; } ?> <h2>Insert License Key</h2> <p><?php echo '<form name="licenses" method="post" action="'.$modulelink.'">'?> <table width="99%" cellspacing="1" bgcolor="#cccccc"> <tr class="heading"><td>Company</td><td>Product</td><td>License Key</td><td>Type</td><td>Available?</td></tr> <tr bgcolor="#ffffff" align="center"> <td> <select name="Company"> <option value="Kaspersky">Kaspersky</option> </select> <input type="hidden" name="action" value="insert" /> <input type="hidden" name="module" value="license_keys" /> </td> <td> <select name="Product"> <option value="AntiVirus">Anti-Virus</option> <option value="InternetSecurity">Internet Security</option> </td> <td><input type="text" name="LicenseKey" size="40" /></td> <td> <select name="LicenseType"> <option value="OEM">OEM</option> <option value="Preload">Preload</option> <option value="Retail1User">Retail 1 User</option> <option value="Retail3User">Retail 3 User</option> <option value="Renewal">Renewal</option> <option value="Promo">Promo</option></select></td> <td> <select name="IsAvail"> <option value="1">Yes</option> <option value="0">No</option> </select></td> </tr> <tr bgcolor="#ffffff" align="right"><td colspan="7"><input type="submit" name="submit" value="Insert License" /></td></tr> </table> </form> </p> <h2>View License Keys</h2> <script language="JavaScript"> function toggleAvailability(id) { if (confirm("Are you sure you want to toggle the availability of license ID: "+id+"?")) { window.location="<?php echo $modulelink; ?>&toggle=true&id="+id; }} </script> <table width="99%" cellspacing="1" bgcolor="#cccccc"> <tr class="heading"><td>Ref #</td><td>Company</td><td>Product</td><td>License Key</td><td>License Type</td><td>Available?</td></tr> <?php $result = mysql_query("SELECT * FROM mod_license_keys WHERE avail='0' ORDER BY company,product,type ASC"); while($data = mysql_fetch_array($result)) { echo "<tr bgcolor=\"#ffffff\"><td>".$data['id']."</td><td>".$data['company']."</td><td>".$data['product']."</td><td>".$data['key']."</td><td>".$data['type']."</td><td>No (<a href=\"#\" onClick=\"toggleAvailability(".$data['id'].");return false\">toggle<!--<img src=\"images/delete.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Delete\">--></a>)</td></tr>"; } ?> <tr bgcolor="#ffffff" align="center"><td colspan="7"> </td></tr> <?php $result = mysql_query("SELECT * FROM mod_license_keys WHERE avail='1' ORDER BY company,product,type ASC"); while($data = mysql_fetch_array($result)) { echo "<tr bgcolor=\"#ffffff\"><td>".$data['id']."</td><td>".$data['company']."</td><td>".$data['product']."</td><td>".$data['key']."</td><td>".$data['type']."</td><td>Yes (<a href=\"#\" onClick=\"toggleAvailability(".$data['id'].");return false\">toggle<!--<img src=\"images/delete.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Delete\">--></a>)</td></tr>"; } ?> </table> modules.zip 0 Quote Link to comment Share on other sites More sharing options...
Chrisw Posted February 14, 2008 Share Posted February 14, 2008 Seems to work as described GJ! 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 14, 2008 Author Share Posted February 14, 2008 Any suggestions for it? 0 Quote Link to comment Share on other sites More sharing options...
Tech Entrance Posted February 14, 2008 Share Posted February 14, 2008 I didn't use it yet but does it generate licenses ? I mean how useful it can be. 0 Quote Link to comment Share on other sites More sharing options...
Chrisw Posted February 14, 2008 Share Posted February 14, 2008 I'm kinda confused .. "Once I get some feedback, I'll post the full version of everything." Do you have more to it? I quickly messed with it. These things came to mind. 1.) Mass toggle on or off - maybe a check box foreach? 2.) License statuses - live, suspended... etc 3.) associate a license to a client via custom fields? 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 14, 2008 Author Share Posted February 14, 2008 I didn't use it yet but does it generate licenses ? I mean how useful it can be. - You input licenses, which will then allow you integrate it even more within WHMCS. The end result will be a pool of licenses, and everything else will be 100% automated. You enter the licenses into whmcs, then specify the quantity within whmcs, and it will handle the rest. Do you have more to it? - I have an api file and a modified actionhooks.php file that will connect to the db and grab the license file, then apply the license file to the client's account. 1.) Mass toggle on or off - maybe a check box foreach? - So a checkbox instead of a link? 2.) License statuses - live, suspended... etc - There is the availability part, to see if the license can be used. Why would you need to know live/suspended? What licenses do you think you would be using? 3.) associate a license to a client via custom fields? - That's a good idea, I thought that may have been kind of a pain at first, but I think it should be pretty easy to do now. Just a link to the product within the client's account? Or link to the client itself? 0 Quote Link to comment Share on other sites More sharing options...
PPH Posted February 14, 2008 Share Posted February 14, 2008 This sounds nice and I will try it on our twst install as soon as I can find a break. Glad to see someone working on this and would love to see it part of the WHMCS system. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 15, 2008 Author Share Posted February 15, 2008 Here's the next part for anyone that wants to see how the API works to issue a license. So you have the license key manager installed, and now you want to connect to it, so that it issues a license, and updates the database so that the license is no longer available. You can test the script by going to: http://www.your-domain.com/order.php?key=SomeRandomKeyThatAllowsAccessToAPI&company=Kaspersky&product=AntiVirus&type=OEM You will need to update the Company, Product, and Type variables that are passed, to line up with a license that is in your database (look at an entry on the license key mod page). <?php // location for WHMCS configuration file require('../../../../configuration.php'); $key = $_GET['key']; $company = $_GET['company']; $product = $_GET['product']; $type = $_GET['type']; // http://www.your-domain.com/order.php?key=SomeRandomKeyThatAllowsAccessToAPI&company=Kaspersky&product=AntiVirus&type=OEM if($key == "SomeRandomKeyThatAllowsAccessToAPI") { mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); mysql_select_db($db_name) or die(mysql_error()); # Let's grab the ID and License Key for the first license that is available $result = mysql_query("SELECT `id`,`key` FROM mod_license_keys WHERE avail='1' AND company='".$company."' AND product='".$product."' AND type='".$type."' LIMIT 1"); $grab_fieldname = mysql_fetch_row($result); $id = $grab_fieldname[0]; $licensekey = $grab_fieldname[1]; // License is sold out, send error message if(!$licensekey){ echo "SOLD OUT";} else{ // output the id (location) and serial number echo "SUCCESS,".$id.",".$licensekey;} // set serial number to be no longer available mysql_query("UPDATE mod_license_keys SET avail='0' WHERE id='".$id."'"); } ?> 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 16, 2008 Author Share Posted February 16, 2008 If anyone else plans to use this, I'll keep updating this post. In order to modify the company, product, and license type options, you will need to modify the configuration.php file. If you install the script, and then make a change to the configuration.php file, you will need to update the database by clicking the "Update Tables" button. Also, if you plan to use the API, you will need to update your IP and add it into the list. Add the following to your configuration.php file: # ################################################ # added for license module # ################################################ // these are the only IPs allowed to make an API call $license_mod_allowed_ips = "72.46.52.25,78.54.45.25"; // if the following are updated after you have installed the license module, // then you will need to click the Update Tables button to update the table $license_mod_companies_list = "Kaspersky,NOD32"; // list all companies $license_mod_products_list = "AntiVirus,InternetSecurity"; // list all products $license_mod_types_list = "OEM,Preload,Retail1User,Retail3User,Renewal,Promo"; // list all product license types // turn on test mode if you do not want to update the DB after the API issues a license; 0 = off, 1 = on $license_mod_test_mode = 0; Here's an updated version of the license_keys.php file <style> <!-- tr.heading{font-weight:bold;text-align: center; background-color:#efefef} .success{color:#00CC00} .error{color:#FF0000} --> </style> <script language="JavaScript"> function toggleAvailability(id) { if (confirm("Are you sure you want to toggle the availability of license ID: "+id+"?")) { window.location="<?php echo $modulelink; ?>&toggle=true&id="+id; } } function updateTable(table) { if (confirm("Are you sure you want to update the "+table+" table?")) { window.location="<?php echo $modulelink; ?>&update="+table; } } </script> <?php // used to display the different companies, products, and types function display_list($_list){ $parts = explode(",", $_list); for($i = 0; $i < count($parts); $i++){ echo '<option value="'.$parts[$i].'">'.$parts[$i].'</option> '; } } // used to display the correct values for when creating the table function display_string($_list){ $parts = explode(",", $_list); for($i = 0; $i < count($parts)-1; $i++){ $s .= "'".$parts[$i]."', "; } $s .= "'".$parts[count($parts)-1]."'"; $s .= $parts[count($parts)]; return $s; } // used to display the first element in the list (used for setting the default value within the database) function display_first($_list){ $parts = explode(",", $_list); return $parts[0]; } if(!mysql_num_rows( mysql_query("SHOW TABLES LIKE 'mod_license_keys'"))) { if (!$_GET["install"]) { echo ' <h2>Not Yet Installed</h2> <p>This addon module allows you to manage a database of license keys.</p> <p>To install it, click on the button below.</p> <p><input type="button" value="Install License Key Manager" onclick="window.location=\''.$modulelink.'&install=true\'"></p> '; } else { $query = "CREATE TABLE `mod_license_keys` ( `id` int(11) NOT NULL auto_increment, `company` enum(".display_string($license_mod_companies_list).") NOT NULL default '".display_first($license_mod_companies_list)."', `product` enum(".display_string($license_mod_products_list).") NOT NULL default '".display_first($license_mod_products_list)."', `key` text NOT NULL, `type` enum(".display_string($license_mod_types_list).") NOT NULL default '".display_first($license_mod_types_list)."', `avail` tinyint(1) NOT NULL default '1', KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"; $result=mysql_query($query); header("Location: $modulelink"); exit; } } // if the table has been installed, then we can update the companies, products, and types if(mysql_num_rows( mysql_query("SHOW TABLES LIKE 'mod_license_keys'"))) { echo '<input type="button" value="Update All Tables" onClick="window.location=\''.$modulelink.'&update=true\'" /><br />'; if ($_GET["update"]) { mysql_query("ALTER TABLE `mod_license_keys` CHANGE `company` `company` ENUM( ".display_string($license_mod_companies_list)." ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '".display_first($license_mod_companies_list)."'"); mysql_query("ALTER TABLE `mod_license_keys` CHANGE `product` `product` ENUM( ".display_string($license_mod_products_list)." ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '".display_first($license_mod_products_list)."'"); mysql_query("ALTER TABLE `mod_license_keys` CHANGE `type` `type` ENUM( ".display_string($license_mod_types_list)." ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '".display_first($license_mod_types_list)."'"); echo '<br />All tables are up to date!<br />'; } } // toggle the availability if ($_GET["toggle"]) { $_id = $_GET["id"];// id of license key to toggle $_id = mysql_real_escape_string($_id); $toggle = mysql_query("SELECT avail FROM mod_license_keys WHERE id='".$_id."' ORDER BY id DESC"); while($data = mysql_fetch_array($toggle)) { if($data[0] == "1") { mysql_query("UPDATE mod_license_keys SET avail='0' WHERE id='".$_id."'"); } else { mysql_query("UPDATE mod_license_keys SET avail='1' WHERE id='".$_id."'"); } echo 'License ID: <font class="succes">'.$_id.'</font> has been updated.'; } } // insert the new License Key if($_POST["action"]=='insert') { $company = $_POST['Company']; $licensekey = $_POST['LicenseKey']; $licensetype = $_POST['LicenseType']; $product = $_POST['Product']; $avail = $_POST['IsAvail']; $exists = 0; // added for security $company = mysql_real_escape_string($company); $licensekey = mysql_real_escape_string($licensekey); $licensetype = mysql_real_escape_string($licensetype); $product = mysql_real_escape_string($product); $avail = mysql_real_escape_string($avail); echo 'Grab license key...................................'; echo ' <span class="success">found input key</span> '.$licensekey.' <span class="success">for '.$company.'</span>'; echo '<br />Insert license......................................'; // check for blank license key, user may have accidentally submitted the form if($licensekey == '') { echo ' <span class="error">ERROR: Please input a valid license.</span>'; } // let's find out if the license already exists else { $result2 = mysql_query("SELECT * FROM mod_license_keys WHERE `key`='".$licensekey."' ORDER BY id DESC"); while($data = mysql_fetch_array($result2)) { // looks like we found a key, so return an error $exists = 1; echo ' <span class="error">ERROR:</span> '.$licensekey.' <span class="error">already exists and thus was NOT inserted.</span><br />'; } // if we didn't find a key, then let's insert the new license into the database if(!$exists) { // Insert a row of information into the table "example" mysql_query("INSERT INTO mod_license_keys( `id` , `company` , `product` , `key` , `type` , `avail` ) VALUES(NULL, '".$company."', '".$product."', '".$licensekey."', '".$licensetype."', '".$avail."' ) ") or die(mysql_error()); echo ' <span class="success">success!</span>'; echo '<br /><br /><b>License '.$licensekey.' has been inserted.</b>'; } } } ?> <h2>Insert License Key</h2> <p><?php echo '<form name="licenses" method="post" action="'.$modulelink.'">'?> <table width="99%" cellspacing="1" bgcolor="#cccccc"> <tr class="heading"><td>Company</td><td>Product</td><td>License Key</td><td>Type</td><td>Available?</td></tr> <tr bgcolor="#ffffff" align="center"> <td> <select name="Company"> <?php display_list($license_mod_companies_list); ?> </select> <input type="hidden" name="action" value="insert" /> <input type="hidden" name="module" value="license_keys" /> </td> <td> <select name="Product"> <?php display_list($license_mod_products_list); ?> </select> </td> <td><input type="text" name="LicenseKey" size="40" /></td> <td> <select name="LicenseType"> <?php display_list($license_mod_types_list); ?> </select> </td> <td> <select name="IsAvail"> <option value="1">Yes</option> <option value="0">No</option> </select></td> </tr> <tr bgcolor="#ffffff" align="right"><td colspan="7"><input type="submit" name="submit" value="Insert License" /></td></tr> </table> </form> </p> <h2>View License Keys</h2> <table width="99%" cellspacing="1" bgcolor="#cccccc"> <tr class="heading"><td>Ref #</td><td>Company</td><td>Product</td><td>License Key</td><td>License Type</td><td>Available?</td></tr> <?php $result = mysql_query("SELECT * FROM mod_license_keys WHERE avail='0' ORDER BY company,product,type ASC"); while($data = mysql_fetch_array($result)) { echo "<tr bgcolor=\"#ffffff\"><td>".$data['id']."</td><td>".$data['company']."</td><td>".$data['product']."</td><td>".$data['key']."</td><td>".$data['type']."</td><td>No (<a href=\"#\" onClick=\"toggleAvailability(".$data['id'].");return false\">toggle<!--<img src=\"images/delete.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Delete\">--></a>)</td></tr>"; } ?> <tr bgcolor="#ffffff" align="center"><td colspan="7"> </td></tr> <?php $result = mysql_query("SELECT * FROM mod_license_keys WHERE avail='1' ORDER BY company,product,type ASC"); while($data = mysql_fetch_array($result)) { echo "<tr bgcolor=\"#ffffff\"><td>".$data['id']."</td><td>".$data['company']."</td><td>".$data['product']."</td><td>".$data['key']."</td><td>".$data['type']."</td><td>Yes (<a href=\"#\" onClick=\"toggleAvailability(".$data['id'].");return false\">toggle<!--<img src=\"images/delete.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Delete\">--></a>)</td></tr>"; } ?> </table> 0 Quote Link to comment Share on other sites More sharing options...
mysmallbizu Posted February 19, 2008 Share Posted February 19, 2008 I'd love to use this type of setup to protect my streaming videos. This way they could be used or made available to resellers as well as end users. Any ideas on how this could be implemented? Right now I had a script written that checks for a valid account and requires the user to enter their whmcs email address and password. It would be even better if the script checked for the valid license key in the background on the first view and then always played the videos if the licesene was valid in the whmcs. Possible? 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 19, 2008 Author Share Posted February 19, 2008 Yes that's possible. You will use this script to manage your licenses. Then you setup a product in WHMCS of type Other. Then insert some code into your actionhooks.php file that will check if the product is ordered, then insert the custom field value into the database, while making sure that it is a license type that is available. At the end, it will set that license to no longer be available. Then you're script can do a db lookup based on client e-mail address. Check the product table based on client user id, then check for the custom field license key. I have the actionhooks.php code that does this, but I was hoping to get some more feedback before I took the time to clean it up and release it. If you want what I have right now to test it, send me the product id of the item you created, and then I will PM you the actionhooks code. 0 Quote Link to comment Share on other sites More sharing options...
HostRW Posted February 21, 2008 Share Posted February 21, 2008 Great addon! Thank you for your time to work on this!! I would like to use the script to sell Anti-Virus and other licenses. Just starting my business so any help in the form of addon's is greatly appreciated. But I don't have a lot of experience in writing PHP scripts, so I really would like to encourage you to continue working on this great script! 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 21, 2008 Author Share Posted February 21, 2008 Great addon! Thank you for your time to work on this!! I would like to use the script to sell Anti-Virus and other licenses. Just starting my business so any help in the form of addon's is greatly appreciated. But I don't have a lot of experience in writing PHP scripts, so I really would like to encourage you to continue working on this great script! - What AntiVirus licenses are you planning to sell? This is exactly what I am using it for 0 Quote Link to comment Share on other sites More sharing options...
HostRW Posted February 21, 2008 Share Posted February 21, 2008 - What AntiVirus licenses are you planning to sell? This is exactly what I am using it for I am going to start with AVG as they have a great reseller program. Also want to sell some PCtools products. Which AV licenses are you selling? 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 21, 2008 Author Share Posted February 21, 2008 Send me a PM. I can set you up as a Kaspersky distributor. 0 Quote Link to comment Share on other sites More sharing options...
jnet Posted March 7, 2008 Share Posted March 7, 2008 I am interested in reselling those anti virus too where to get it? 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted March 7, 2008 Author Share Posted March 7, 2008 I am interested in reselling those anti virus toowhere to get it? - I don't want this thread to deviate from the original topic of being an addon for handling license keys. Please keep those requests in a new thread. 0 Quote Link to comment Share on other sites More sharing options...
lowridertj Posted March 13, 2008 Share Posted March 13, 2008 Here's the next part for anyone that wants to see how the API works to issue a license. So you have the license key manager installed, and now you want to connect to it, so that it issues a license, and updates the database so that the license is no longer available. You can test the script by going to: http://www.your-domain.com/order.php?key=SomeRandomKeyThatAllowsAccessToAPI&company=Kaspersky&product=AntiVirus&type=OEM You will need to update the Company, Product, and Type variables that are passed, to line up with a license that is in your database (look at an entry on the license key mod page). <?php // location for WHMCS configuration file require('../../../../configuration.php'); $key = $_GET['key']; $company = $_GET['company']; $product = $_GET['product']; $type = $_GET['type']; // http://www.your-domain.com/order.php?key=SomeRandomKeyThatAllowsAccessToAPI&company=Kaspersky&product=AntiVirus&type=OEM if($key == "SomeRandomKeyThatAllowsAccessToAPI") { mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); mysql_select_db($db_name) or die(mysql_error()); # Let's grab the ID and License Key for the first license that is available $result = mysql_query("SELECT `id`,`key` FROM mod_license_keys WHERE avail='1' AND company='".$company."' AND product='".$product."' AND type='".$type."' LIMIT 1"); $grab_fieldname = mysql_fetch_row($result); $id = $grab_fieldname[0]; $licensekey = $grab_fieldname[1]; // License is sold out, send error message if(!$licensekey){ echo "SOLD OUT";} else{ // output the id (location) and serial number echo "SUCCESS,".$id.",".$licensekey;} // set serial number to be no longer available mysql_query("UPDATE mod_license_keys SET avail='0' WHERE id='".$id."'"); } ?> how is this api tied into everything. sorry bit new to the keys but would like to try it out \ 0 Quote Link to comment Share on other sites More sharing options...
atDev Posted March 13, 2008 Share Posted March 13, 2008 Why not do this more like phpaudit? This way there is a tighter integration between licenses and clients. A product can have a license, which gives the user a license key to use. Check out phpaudit.com. WHMCS already has the client/payment management all you need is a way to show the user their license along with the product, and do the remote verification. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted March 14, 2008 Author Share Posted March 14, 2008 Why not do this more like phpaudit? - Because this script should be fine for most people, and most people don't want to shove out $100/year for phpaudit... how is this api tied into everything. sorry bit new to the keys but would like to try it out - Here's an example: $kaspersky_response = file_get_contents("http://www.your-domain.com/order.php?key=SomeRandomKeyThatAllowsAccessToAPI&company=Kaspersky&product=AntiVirus&type=OEM"); $kaspersky_response_parts = explode(",", $kaspersky_response); // grab serial number $serialnumber = $kaspersky_response_parts[2]; if(trim($kaspersky_response_parts[0]) == "SUCCESS") { // we received a serial number! $serialnumber = $kaspersky_response_parts[2]; } else{ // there was an error, licenses are possibly sold out $serialnumber = "There has been an error generating a license, please contact support."; } 0 Quote Link to comment Share on other sites More sharing options...
atDev Posted March 18, 2008 Share Posted March 18, 2008 This integration is too basic and tedious. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted March 18, 2008 Author Share Posted March 18, 2008 This integration is too basic and tedious. - It does the job and it should only take a couple minutes to implement. What part took you a long time? 0 Quote Link to comment Share on other sites More sharing options...
Nick Posted March 18, 2008 Share Posted March 18, 2008 This integration is too basic and tedious. It's nice when people appreciate your effort, isn't it RPS? This is provided for free - you are acting as though you have paid for something and have been delivered something under-spec. 0 Quote Link to comment Share on other sites More sharing options...
PPH Posted March 18, 2008 Share Posted March 18, 2008 Well I would like to thank you for your efforts and have it installed on our site. You help make WHMCS a better place for others and please keep up the great work. 0 Quote Link to comment Share on other sites More sharing options...
SilverNodashi Posted April 4, 2008 Share Posted April 4, 2008 So, is this something you would / could use to store cPanel, Fantastico, RVSite Builder, WHMCS, etc licenses in, and then issue them to your dedicated & VPS clients as needed? OR am I missing the boat somewhere? 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.