| 1 |
<?php |
| 2 |
|
| 3 |
function smart_forms_check_license($email,$key,&$error) |
| 4 |
{ |
| 5 |
if($email!=null||$key!=null) |
| 6 |
{ |
| 7 |
if(get_transient("smart_forms_check_again")) |
| 8 |
return true; |
| 9 |
if(smart_forms_license_is_valid($email,$key,$error)) |
| 10 |
{ |
| 11 |
update_option('smart_forms_email',$email); |
| 12 |
update_option('smart_forms_key',$key); |
| 13 |
|
| 14 |
set_transient("smart_forms_check_again",1,60*60*24*7); |
| 15 |
return true; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
return false; |
| 20 |
} |
| 21 |
|
| 22 |
function smart_forms_check_license_with_options(&$error) |
| 23 |
{ |
| 24 |
if(get_transient("smart_forms_check_again")) |
| 25 |
return true; |
| 26 |
$email=get_option('smart_forms_email'); |
| 27 |
$key=get_option('smart_forms_key'); |
| 28 |
|
| 29 |
if($email==false||$key==false) |
| 30 |
return false; |
| 31 |
return smart_forms_check_license(($email?$email:""), ($key?$key:""),$error,false); |
| 32 |
} |
| 33 |
|
| 34 |
function smart_forms_license_is_valid($email,$key,&$error) |
| 35 |
{ |
| 36 |
$email=trim($email); |
| 37 |
$key=trim($key); |
| 38 |
delete_transient("smart_forms_check_again"); |
| 39 |
$response=wp_remote_post(SMART_FORMS_REDNAO_URL.'smart_donations_license_validation.php',array('body'=> array( 'email'=>$email,'key'=>$key,'product'=>'sf'),'timeout'=>10)); |
| 40 |
if($response instanceof WP_Error) |
| 41 |
{ |
| 42 |
$error= $response->get_error_message(); |
| 43 |
return false; |
| 44 |
} |
| 45 |
|
| 46 |
if(strcmp ($response['body'], "valid") == 0) |
| 47 |
return true; |
| 48 |
else{ |
| 49 |
return false; |
| 50 |
} |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
function smart_forms_load_license_manager($errorMessage) |
| 55 |
{ |
| 56 |
if(smart_forms_check_license_with_options($error)) |
| 57 |
{ |
| 58 |
?><script language="javascript"> |
| 59 |
var RedNaoSmartFormLicenseIsValid=true; |
| 60 |
var RedNaoSmartFormLicenseErrorMessage=""; |
| 61 |
</script><?php |
| 62 |
}else |
| 63 |
{ |
| 64 |
wp_enqueue_script('jquery'); |
| 65 |
wp_enqueue_script('isolated-slider',SMART_FORMS_DIR_URL.'js/rednao-isolated-jq.js',array('jquery')); |
| 66 |
wp_enqueue_style('smart-forms-Slider',SMART_FORMS_DIR_URL.'css/smartFormsSlider/jquery-ui-1.10.2.custom.min.css'); |
| 67 |
|
| 68 |
?> |
| 69 |
<script language="javascript"> |
| 70 |
var RedNaoSmartFormLicenseIsValid=false; |
| 71 |
var RedNaoSmartFormLicenseErrorMessage="<?php echo $errorMessage?>"; |
| 72 |
</script> |
| 73 |
|
| 74 |
|
| 75 |
<?php |
| 76 |
} |
| 77 |
wp_enqueue_script('rednao-smart-forms-licensing-manager',SMART_FORMS_DIR_URL.'js/licensing/rednao-licensing-manager.js',array('isolated-slider')); |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
|