Jump to content

Licensing addon question


scorpionoir009

Recommended Posts

I have a problem after that followed the explanation

 

I do the following

 

store1.up-00.com/2015-10/14456014361.jpg

 

 

store1.up-00.com/2015-10/1445601436122.jpg

 

 

 

store1.up-00.com/2015-10/1445601436223.jpg

 

 

 

store1.up-00.com/2015-10/1445601436294.jpg

 

 

 

In a program that gives whmcs a key contact Ergonomics

 

But in the program tells me that the key is incorrect

 

view this

store1.up-00.com/2015-10/1445601436385.jpg

 

Here, you must modify file check_code

 

I've lifting to whmcs

 

 

i upload check_sample_code to my whmcs

 

and rename check_sample_code to license.php

 

 

and edite this

 

store1.up-00.com/2015-10/1445602747312.jpg

 

 

 

store1.up-00.com/2015-10/1445602689591.jpg

 

 

prefix if they do not use

How do I modify it in the script

 

Please modify it to me to be able to activate the key correctly

Edited by Infopro
Please Attach Images to Your Posts.
Link to comment
Share on other sites

plz help me for this toto

 

markustenghamn.com/whmcs-licensing-addon-storing-the-local-key

 

ihave this - Removed -

 

MY check_code.PHP

 

<?php
/**
* WHMCS Licensing Addon - Integration Code Sample
* http://www.whmcs.com/addons/licensing-addon/
*
* The following code is a fully working code sample demonstrating how to
* perform license checks using the WHMCS Licensing Addon. It is PHP 4 and
* 5 compatible.  Requires the WHMCS Licensing Addon to be used.
*
* @package    WHMCS
* @author     WHMCS Limited <development@whmcs.com>
* @copyright  Copyright (c) WHMCS Limited 2005-2014
* @license    http://www.whmcs.com/license/ WHMCS Eula
* @version    $Id$
* @link       http://www.whmcs.com/
*/

/**
* This is just example code, and is not intended to be invoked directly.
*
* To ensure this code isn't unintentionally invoked on the command line or
* via the web interface, any attempt to actually execute this code will
* be exited:
*/
/**
* If you are using this file as a template for your own module, once
* you've modified the code for your use, remove the exit above.
*/

// Replace "yourprefix" with your own unique prefix to avoid conflicts with
// other instances of the licensing addon included within the same scope
function check_license($licensekey,$localkey='') {

   // -----------------------------------
   //  -- Configuration Values --
   // -----------------------------------

   // Enter the url to your WHMCS installation here
   $whmcsurl = 'http://prohdvision.ddns.net/';
   // Must match what is specified in the MD5 Hash Verification field
   // of the licensing product that will be used with this check.
   $licensing_secret_key = '285669285669';
   // The number of days to wait between performing remote license checks
   $localkeydays = 15;
   // The number of days to allow failover for after local key expiry
   $allowcheckfaildays = 5;

   // -----------------------------------
   //  -- Do not edit below this line --
   // -----------------------------------

   $check_token = time() . md5(mt_rand(1000000000, 9999999999) . $licensekey);
   $checkdate = date("Ymd");
   $domain = $_SERVER['SERVER_NAME'];
   $usersip = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
   $dirpath = dirname(__FILE__);
   $verifyfilepath = 'modules/servers/licensing/verify.php';
   $localkeyvalid = false;
   if ($localkey) {
       $localkey = str_replace("\n", '', $localkey); # Remove the line breaks
       $localdata = substr($localkey, 0, strlen($localkey) - 32); # Extract License Data
       $md5hash = substr($localkey, strlen($localkey) - 32); # Extract MD5 Hash
       if ($md5hash == md5($localdata . $licensing_secret_key)) {
           $localdata = strrev($localdata); # Reverse the string
           $md5hash = substr($localdata, 0, 32); # Extract MD5 Hash
           $localdata = substr($localdata, 32); # Extract License Data
           $localdata = base64_decode($localdata);
           $localkeyresults = unserialize($localdata);
           $originalcheckdate = $localkeyresults['checkdate'];
           if ($md5hash == md5($originalcheckdate . $licensing_secret_key)) {
               $localexpiry = date("Ymd", mktime(0, 0, 0, date("m"), date("d") - $localkeydays, date("Y")));
               if ($originalcheckdate > $localexpiry) {
                   $localkeyvalid = true;
                   $results = $localkeyresults;
                   $validdomains = explode(',', $results['validdomain']);
                   if (!in_array($_SERVER['SERVER_NAME'], $validdomains)) {
                       $localkeyvalid = false;
                       $localkeyresults['status'] = "Invalid";
                       $results = array();
                   }
                   $validips = explode(',', $results['validip']);
                   if (!in_array($usersip, $validips)) {
                       $localkeyvalid = false;
                       $localkeyresults['status'] = "Invalid";
                       $results = array();
                   }
                   $validdirs = explode(',', $results['validdirectory']);
                   if (!in_array($dirpath, $validdirs)) {
                       $localkeyvalid = false;
                       $localkeyresults['status'] = "Invalid";
                       $results = array();
                   }
               }
           }
       }
   }
   if (!$localkeyvalid) {
       $responseCode = 0;
       $postfields = array(
           'licensekey' => $licensekey,
           'domain' => $domain,
           'ip' => $usersip,
           'dir' => $dirpath,
       );
       if ($check_token) $postfields['check_token'] = $check_token;
       $query_string = '';
       foreach ($postfields AS $k=>$v) {
           $query_string .= $k.'='.urlencode($v).'&';
       }
       if (function_exists('curl_exec')) {
           $ch = curl_init();
           curl_setopt($ch, CURLOPT_URL, $whmcsurl . $verifyfilepath);
           curl_setopt($ch, CURLOPT_POST, 1);
           curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
           curl_setopt($ch, CURLOPT_TIMEOUT, 30);
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
           $data = curl_exec($ch);
           $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
           curl_close($ch);
       } else {
           $responseCodePattern = '/^HTTP\/\d+\.\d+\s+(\d+)/';
           $fp = @fsockopen($whmcsurl, 80, $errno, $errstr, 5);
           if ($fp) {
               $newlinefeed = "\r\n";
               $header = "POST ".$whmcsurl . $verifyfilepath . " HTTP/1.0" . $newlinefeed;
               $header .= "Host: ".$whmcsurl . $newlinefeed;
               $header .= "Content-type: application/x-www-form-urlencoded" . $newlinefeed;
               $header .= "Content-length: ".@strlen($query_string) . $newlinefeed;
               $header .= "Connection: close" . $newlinefeed . $newlinefeed;
               $header .= $query_string;
               $data = $line = '';
               @stream_set_timeout($fp, 20);
               @fputs($fp, $header);
               $status = @socket_get_status($fp);
               while (!@feof($fp)&&$status) {
                   $line = @fgets($fp, 1024);
                   $patternMatches = array();
                   if (!$responseCode
                       && preg_match($responseCodePattern, trim($line), $patternMatches)
                   ) {
                       $responseCode = (empty($patternMatches[1])) ? 0 : $patternMatches[1];
                   }
                   $data .= $line;
                   $status = @socket_get_status($fp);
               }
               @fclose ($fp);
           }
       }
       if ($responseCode != 200) {
           $localexpiry = date("Ymd", mktime(0, 0, 0, date("m"), date("d") - ($localkeydays + $allowcheckfaildays), date("Y")));
           if ($originalcheckdate > $localexpiry) {
               $results = $localkeyresults;
           } else {
               $results = array();
               $results['status'] = "Invalid";
               $results['description'] = "Remote Check Failed";
               return $results;
           }
       } else {
           preg_match_all('/<(.*?)>([^<]+)<\/\\1>/i', $data, $matches);
           $results = array();
           foreach ($matches[1] AS $k=>$v) {
               $results[$v] = $matches[2][$k];
           }
       }
       if (!is_array($results)) {
           die("Invalid License Server Response");
       }
       if ($results['md5hash']) {
           if ($results['md5hash'] != md5($licensing_secret_key . $check_token)) {
               $results['status'] = "Invalid";
               $results['description'] = "MD5 Checksum Verification Failed";
               return $results;
           }
       }
       if ($results['status'] == "Active") {
           $results['checkdate'] = $checkdate;
           $data_encoded = serialize($results);
           $data_encoded = base64_encode($data_encoded);
           $data_encoded = md5($checkdate . $licensing_secret_key) . $data_encoded;
           $data_encoded = strrev($data_encoded);
           $data_encoded = $data_encoded . md5($data_encoded . $licensing_secret_key);
           $data_encoded = wordwrap($data_encoded, 80, "\n", true);
           $results['localkey'] = $data_encoded;
       }
       $results['remotecheck'] = true;
   }
   unset($postfields,$data,$matches,$whmcsurl,$licensing_secret_key,$checkdate,$usersip,$localkeydays,$allowcheckfaildays,$md5hash);
   return $results;
}

$licensekey = mysql_result(mysql_query("SELECT license_key FROM keys LIMIT 1"), 0); //Gets the license key from the database
$localkey = mysql_result(mysql_query("SELECT local_key FROM keys LIMIT 1"), 0); //Gets the local key from the database

// Validate the license key information
$results = check_license($licensekey, $localkey);

// Raw output of results for debugging purpose
echo '<textarea cols="100" rows="20">' . print_r($results, true) . '</textarea>';

// Interpret response

if ($results["status"]=="Active") {
   # Allow Script to Run
   if ($results["localkey"]) {
       # Save Updated Local Key to DB or File
       $localkeydata = $results["localkey"];
       mysql_query("UPDATE keys SET local_key = '$localkeydata'");
   }
} elseif ($results["status"]=="Invalid") {
   # Show Invalid Message
} elseif ($results["status"]=="Expired") {
   # Show Expired Message
} elseif ($results["status"]=="Suspended") {
   # Show Suspended Message
}

002.jpg

001.jpg

003.jpg

004.jpg

005.jpg

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