Last active
March 8, 2020 14:33
-
-
Save wowthemesnet/1efa13e8fbaa6c1150513d441b23b8e7 to your computer and use it in GitHub Desktop.
Check license in Software Manager License
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function check_license(){ | |
$sml_url = 'https://domain.com/'; | |
$slm_action = 'slm_check'; | |
$secret_key = 'xxx'; | |
$license_key = get_license_key(); | |
$api_call = $sml_url . '?secret_key=' . $secret_key . '&slm_action=' . $slm_action . '&license_key=' . $license_key; | |
define('URL_SERVICE', $api_call); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, URL_SERVICE); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$json = curl_exec($ch); | |
curl_close($ch); | |
$response = json_decode($json, true); | |
$result = $response["result"]; | |
$message = $response["message"]; | |
$status = $response["status"]; | |
$registered_devices = ((is_array($response["registered_devices"]) ? count($response["registered_devices"]) : 0)); | |
$email = $response["email"]; | |
$max_allowed_devices = $response["max_allowed_devices"]; | |
$date_created = $response["date_created"]; | |
$date_renewed = $response["date_renewed"]; | |
$date_expiry = $response["date_expiry"]; | |
$usr_email = preg_replace('/%40/', '@', $email); | |
$expire = strtotime($date_expiry); | |
$today = strtotime("today midnight"); | |
//var_dump($response ); | |
if($result == 'success' && $status == 'pending'){ | |
if($today >= $expire){ | |
return 'Error'; | |
} | |
else { | |
return 'Success'; | |
} | |
} | |
else { | |
if ($result !== 'success') { | |
return 'Error'; | |
} | |
else { | |
if ($registered_devices < $max_allowed_devices && $status == 'act'.'ive') { | |
if($today >= $expire){ | |
return 'Error'; | |
} | |
else { | |
return 'Success'; | |
} | |
} | |
elseif ($registered_devices > $max_allowed_devices) { | |
return 'Error'; | |
} | |
else { | |
return 'Error'; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment