1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <?php
//WP Function Like: get_option('stpopup-license');, Joomla! Function Like: $this->params->get('license');, OR $_POST['key'];.
$licensekey = $_POST['key'];
$prod_id = "MY-GREAT-PRODUCT"; //Must same with product registered stored on DataBase
if (substr($domain, 0, 4) == "www.") { $domain = substr($domain, 4);}
$userip = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$validdir = dirname(__FILE__);
$website = $domain;
$validdomain = $domain;
$key_info['key'] = $licensekey;
$key_info['domain'] = $validdomain;
$key_info['validip'] = $userip;
$key_info['validdir'] = $validdir;
$key_info['product'] = $prod_id;
$serverurl = "http://yourblogurl.com/"; // Your Blog URL Where WLGS Installed
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $serverurl."wp-content/plugins/wp-licensing/auth/verify.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $key_info);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result, true);
if($result['valid'] == "true"){
// key is valid so run it
echo "<p>Your license key is valid,<br>Thank you"; // Place your protected code function here
} else {
// key is not valid so stop it
echo "<p>Your license key is Invalid!";
}
?>
You must Change code bellow:
$licensekey = $_POST['key']; // How to you get license key
$prod_id = "MY-GREAT-PRODUCT"; // Your license product name and it's must same with registered product in WLGS Product manager.
$serverurl = "http://yourblogurl.com/"; // Where Your License Guard System Installed
- Create form for license key like this:
<form action="" method="post">
<input id="license" name="license" type="text" value="" />
<input type="submit" value="Validate" />
</form> |
Partager