예제 #1
0
 protected function passed_token_validation(array $url_query)
 {
     $query = array_map('urlencode', $url_query);
     $result = edd_validate_url_token(add_query_arg($query, untrailingslashit(home_url())));
     return apply_filters('edd_tickets_passed_token_validation', $result);
 }
/**
 * Used to process a signed URL for processing downloads
 *
 * @since  2.3
 * @param  array $args Arguments provided to download a file
 * @return array       Same arguments, with the status of verification added
 */
function edd_process_signed_download_url($args)
{
    $parts = parse_url(add_query_arg(array()));
    wp_parse_str($parts['query'], $query_args);
    $url = add_query_arg($query_args, site_url());
    $valid_token = edd_validate_url_token($url);
    // Bail if the token isn't valid.
    // The request should pass through EDD, or custom handling can be enabled with the action.
    if (!$valid_token) {
        $args['payment'] = false;
        $args['has_access'] = false;
        return $args;
    }
    $order_parts = explode(':', rawurldecode($_GET['eddfile']));
    // Check to make sure not at download limit
    if (edd_is_file_at_download_limit($order_parts[1], $order_parts[0], $order_parts[2], $order_parts[3])) {
        wp_die(apply_filters('edd_download_limit_reached_text', __('Sorry but you have hit your download limit for this file.', 'easy-digital-downloads')), __('Error', 'easy-digital-downloads'), array('response' => 403));
    }
    $args['expire'] = $_GET['ttl'];
    $args['download'] = $order_parts[1];
    $args['payment'] = $order_parts[0];
    $args['file_key'] = $order_parts[2];
    $args['price_id'] = $order_parts[3];
    $args['email'] = get_post_meta($order_parts[0], '_edd_payment_user_email', true);
    $args['key'] = get_post_meta($order_parts[0], '_edd_payment_purchase_key', true);
    $payment = new EDD_Payment($args['payment']);
    $args['has_access'] = 'publish' === $payment->status ? true : false;
    return $args;
}