Example #1
0
function verify_license($product_code, $name, $copies, $license)
{
    $signature = array();
    $license = str_replace('9', 'I', $license);
    $license = str_replace('8', 'O', $license);
    $license = str_replace('-', '', $license);
    $compositeLicenseCode = make_license_source($product_code, $name);
    // pad out the license key
    $padded_length = strlen($license) % 8;
    if ($padded_length == 0) {
        $padded_length = strlen($license);
    } else {
        $padded_length = (intval(strlen($license) / 8) + 1) * 8;
    }
    $padded = $license . str_repeat('=', $padded_length - strlen($license));
    $signature = base32_decode($padded, base32_decode_buffer_size(strlen($padded)));
    $key = file_get_contents("./lib/dsapub512.pem");
    $pukeyid = openssl_get_publickey($key);
    $valid = openssl_verify($compositeLicenseCode, $signature, $pukeyid, OPENSSL_ALGO_DSS1);
    return $valid == 1;
}
Example #2
0
 function generateLicenseCF()
 {
     $app = new Application($this->app_id);
     $priv = openssl_pkey_get_private($app->ap_pkey);
     $signedData = '';
     $product_code = $app->cf_product_code;
     $name = $this->first_name . ' ' . $this->last_name;
     $compositeLicenseCode = make_license_source($product_code, $name);
     error_log("[{$product_code}] - [{$name}] -- [{$compositeLicenseCode}]");
     $license = make_phpFob_license($compositeLicenseCode, $priv);
     $this->license = $license;
     $this->update();
 }
Example #3
0
* it to the order
* 
* Note: There are multiple security keys in FastSpring - the license request has a distinct key from the order
* notification request
*/
require 'includes/master.inc.php';
$app = new Application();
$app->select($_POST['item_number']);
// custom
if (!$app->ok()) {
    error_log("Application {$_POST['item_name']} {$_POST['item_number']} not found!");
    exit;
}
// FastSpring security check...
if (md5($_REQUEST['security_data'] . $app->fs_license_key) != $_REQUEST['security_hash']) {
    die('Security check failed.');
}
$name = $_POST['name'];
$quantity = $_POST['quantity'];
$product_code = $app->cf_product_code;
$compositeLicenseCode = make_license_source($product_code, $name);
error_log("[{$product_code}] - [{$name}] -- [{$compositeLicenseCode}]");
$priv = openssl_pkey_get_private($app->ap_pkey);
$license = make_phpFob_license($compositeLicenseCode, $priv);
echo $license;
// These are the fields and values you'll need to setup in FastSpring's
// license generation system.
// by default, 'name' comes through as a composite name
// quantity is also set.
// The following is a custom parameter setup on the parameter overrides page
// item_number          3 <-- this is the Shine ID number of your product -