| @@ -4,55 +4,61 @@ | ||
| 4 | 4 | { |
| 5 | 5 | if($email!=null||$key!=null) |
| 6 | 6 | { |
| 7 | 7 | if(get_transient("smart_forms_check_again")) |
| 8 | - return array("is_valid"=>true); | |
| 9 | - | |
| 10 | - $result=smart_forms_license_is_valid($email,$key,$error); | |
| 11 | - if($result["is_valid"]) | |
| 8 | + return true; | |
| 9 | + if(smart_forms_license_is_valid($email,$key,$error)) | |
| 12 | 10 | { |
| 13 | 11 | update_option('smart_forms_email',$email); |
| 14 | 12 | update_option('smart_forms_key',$key); |
| 15 | - update_option('smart_forms_license',$result['licenseType']); | |
| 16 | 13 | |
| 17 | 14 | set_transient("smart_forms_check_again",1,60*60*24*7); |
| 18 | - return $result; | |
| 15 | + return true; | |
| 19 | 16 | } |
| 20 | 17 | } |
| 21 | 18 | |
| 22 | - return array("is_valid"=>false); | |
| 19 | + return false; | |
| 23 | 20 | } |
| 24 | 21 | |
| 25 | 22 | function smart_forms_check_license_with_options(&$error) |
| 26 | 23 | { |
| 27 | - $result=apply_filters("smart_forms_lc_is_valid_with_options",array()); | |
| 28 | - $error=$result["error"]; | |
| 29 | - return $result; | |
| 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); | |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | 34 | function smart_forms_license_is_valid($email,$key,&$error) |
| 33 | 35 | { |
| 34 | - $result = apply_filters( "smart_forms_lc_is_valid", array( | |
| 35 | - "email"=>$email, | |
| 36 | - "key"=>$key, | |
| 37 | - "is_valid"=>false, | |
| 38 | - "error"=>"" | |
| 39 | - ) ); | |
| 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 | + } | |
| 40 | 45 | |
| 41 | - $error=$result["error"]; | |
| 42 | - return $result; | |
| 46 | + if(strcmp ($response['body'], "valid") == 0) | |
| 47 | + return true; | |
| 48 | + else{ | |
| 49 | + return false; | |
| 50 | + } | |
| 43 | 51 | |
| 44 | 52 | } |
| 45 | 53 | |
| 46 | 54 | function smart_forms_load_license_manager($errorMessage) |
| 47 | 55 | { |
| 48 | - $result=apply_filters("smart_forms_lc_is_valid_with_options",array()); | |
| 49 | - if($result["is_valid"]) | |
| 56 | + if(smart_forms_check_license_with_options($error)) | |
| 50 | 57 | { |
| 51 | 58 | ?><script language="javascript"> |
| 52 | 59 | var RedNaoSmartFormLicenseIsValid=true; |
| 53 | 60 | var RedNaoSmartFormLicenseErrorMessage=""; |
| 54 | - var RedNaoLicenseType=<?php echo json_encode($result["licenseType"]);?>; | |
| 55 | 61 | </script><?php |
| 56 | 62 | }else |
| 57 | 63 | { |
| 58 | 64 | wp_enqueue_script('jquery'); |
| @@ -61,9 +67,8 @@ | ||
| 61 | 67 | |
| 62 | 68 | ?> |
| 63 | 69 | <script language="javascript"> |
| 64 | 70 | var RedNaoSmartFormLicenseIsValid=false; |
| 65 | - var RedNaoLicenseType=""; | |
| 66 | 71 | var RedNaoSmartFormLicenseErrorMessage="<?php echo $errorMessage?>"; |
| 67 | 72 | </script> |
| 68 | 73 | |
| 69 | 74 | |