Example #1
0
  public static function do_validate_licence_key($key) {
    
    global $wf;
    
    // Please do not modify this code. 
    // Purchase a licence and help us support future development of this software. Thanks!

    $info = array();
    
    $current_key = MasterPress::licence_key();
    $cache_key = MPC_Settings::cache_key($current_key);

    // clear the current transient

    $wf->uncache($cache_key);
    
    if (self::valid_key_format($key)) {
      
      $args = array(
        "action" => "licence-check",
        "key" => $key,
        "domain" => $_SERVER['SERVER_NAME']
      );

      // Send the request to check for an update
    
      $response = MasterPress::update_request( $args );
      
      $result = $response->result;

      $info["error"] = $response->error;
      $info["valid"] = $result["valid"];
      $info["reason"] = $result["reason"];

      $wf->cache($cache_key, $info["valid"] ? "yes" : "no", "3d");
      
    } else {

      $info["error"] = __("Invalid licence key format", MASTERPRESS_DOMAIN);
      $info["valid"] = false;
      $info["reason"] = __("must be at least 33 characters long");
      
      $wf->cache($cache_key, $info["valid"] ? "yes" : "no", "3d");

    }
    
    return $info;
    
  }