Skip to content

Instantly share code, notes, and snippets.

@smallfri
Created March 3, 2016 11:58
Show Gist options
  • Save smallfri/c0dd005ff11f0d833c8b to your computer and use it in GitHub Desktop.
Save smallfri/c0dd005ff11f0d833c8b to your computer and use it in GitHub Desktop.
class AdminInit
{
function adminInit()
{
if(isset($_POST) AND array_key_exists('license_key', $_POST)!='')
{
$url
= 'http://www.licenseengine.com/licenses/a/?action=get_product&item_name=make-contest-1&license='.$_POST['license_key'].'&domain='.$_SERVER['SERVER_NAME'];
$json = file_get_contents($url);
$get_product = json_decode($json);
$product_id = $get_product->product_id;
$url
= 'http://www.licenseengine.com/licenses/a/?action=activate_license&item_name=make-contest-1&product_id='.$product_id.'&license='.$_POST['license_key'].'&domain='.$_SERVER['SERVER_NAME'];
$json = file_get_contents($url);
$check_license = json_decode($json);
$myfile = fopen("data.txt", "w") or die("Unable to open file!");
$txt = array('license_key' => $_POST['license_key'], 'product_id' => $product_id);
fwrite($myfile, json_encode($txt));
fclose($myfile);
}
else
{
echo "here";
$myfile = fopen("data.txt", "r") or die("Unable to open file!");
$txt = fread($myfile, filesize("data.txt"));
fclose($myfile);
$data = json_decode($txt);
$url
= 'http://www.licenseengine.com/licenses/a/?action=check_license&item_name=make-contest-1&product_id='.$data->product_id.'&license='.$data->license_key.'&domain='.$_SERVER['SERVER_NAME'];
$json = file_get_contents($url);
print_r($json);
$check_license = json_decode($json);
}
if(empty($check_license) OR $check_license->license!='valid')
{
?>
<div style="padding: 15px;font-size: 14px;width: 400px;border: 1px solid #cccccc;border-radius: 5px;margin:25px auto;text-align:center">
<div style="text-align: center">
<img src="http://www.licenseengine.com/assets3/images/License-Engine-Lock-TransBG.png" alt="LicenseEngine.com Logo">
</div>
<h4>MakeContest Design Contest Script</h4>
<p>Please register your copy to get updates and support.</p>
<p><a href="https://makecontest.freshdesk.com/support/home">Support Desk</a></p>
<form method="post" action="" enctype="multipart/form-data" id="license_key">
<div class="button-container">
<input id="license_key" name="license_key" type="text" class="input-xlarge" placeholder="Enter Your License Key" value=""/>
<input type="submit" value="Save" id="save_button" class="button action"/>
<p>Can't find your key? Login to
<a href="//www.licenseengine.com/my-keys" target="_blank">License Engine</a> to retrieve your key.
</p>
</div>
</form>
<div style="float:right"><img src="//www.licenseengine.com/assets2/img/licensingpoweredbyLE.png"></div>
<div style="clear: both"></div>
<?php
die();
}
else
{
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment