$r_filename = basename($indfile); $r_filename = explode("?", $r_filename); $r_filename = $r_filename[0]; wpdm_download_file($indfile, $r_filename, $speed, 1, $package); } die; } if (file_exists(UPLOAD_DIR . $indfile)) { $filepath = UPLOAD_DIR . $indfile; } else { if (file_exists($indfile)) { $filepath = $indfile; } else { if (file_exists(WP_CONTENT_DIR . end($tmp = explode("wp-content", $indfile)))) { //path fix on site move $filepath = WP_CONTENT_DIR . end($tmp = explode("wp-content", $indfile)); } else { wpdm_download_data('file-not-found.txt', 'File not found or deleted from server'); die; } } } //$plock = get_wpdm_meta($file['id'],'password_lock',true); //$fileinfo = get_wpdm_meta($package['id'],'fileinfo'); $filename = basename($filepath); $filename = preg_replace("/([0-9]+)[wpdm]+_/", "", $filename); wpdm_download_file($filepath, $filename, $speed, 1, $package); //@unlink($filepath); } do_action("after_download", $package); die;
/** * Process Download Request * */ function wpdm_downloadnow() { global $wpdb, $current_user, $wp_query; get_currentuserinfo(); if (!isset($wp_query->query_vars['wpdmdl']) && !isset($_GET['wpdmdl'])) { return; } $id = isset($_GET['wpdmdl']) ? (int) $_GET['wpdmdl'] : (int) $wp_query->query_vars['wpdmdl']; if ($id <= 0) { return; } $key = array_key_exists('_wpdmkey', $_GET) ? $_GET['_wpdmkey'] : ''; $key = $key == '' && array_key_exists('_wpdmkey', $wp_query->query_vars) ? $wp_query->query_vars['_wpdmkey'] : $key; $key = preg_replace("/[^_a-z|A-Z|0-9]/i", "", $key); $key = "__wpdmkey_" . $key; $package = get_post($id, ARRAY_A); $package['ID'] = $package['ID']; $package = array_merge($package, wpdm_custom_data($package['ID'])); if (isset($package['files'])) { $package['files'] = maybe_unserialize($package['files']); } else { $package['files'] = array(); } //$package = wpdm_setup_package_data($package); if (is_array($package)) { $role = @array_shift(@array_keys($current_user->caps)); $cpackage = apply_filters('before_download', $package); $lock = ''; $package = $cpackage ? $cpackage : $package; if (isset($package['email_lock']) && $package['email_lock'] == 1) { $lock = 'locked'; } if (isset($package['password_lock']) && $package['password_lock'] == 1) { $lock = 'locked'; } if (isset($package['gplusone_lock']) && $package['gplusone_lock'] == 1) { $lock = 'locked'; } if (isset($package['facebooklike_lock']) && $package['facebooklike_lock'] == 1) { $lock = 'locked'; } if (isset($package['tweet_lock']) && $package['tweet_lock'] == 1) { $lock = 'locked'; } if ($lock !== 'locked') { $lock = apply_filters('wpdm_check_lock', $id, $lock); } if (isset($_GET['masterkey']) && esc_attr($_GET['masterkey']) == $package['masterkey']) { $lock = 0; } $limit = $key ? (int) trim(get_post_meta($package['ID'], $key, true)) : 0; if ($limit <= 0 && $key != '') { delete_post_meta($package['ID'], $key); } else { if ($key != '') { update_post_meta($package['ID'], $key, $limit - 1); } } $matched = is_array(@maybe_unserialize($package['access'])) && is_user_logged_in() ? array_intersect($current_user->roles, @maybe_unserialize($package['access'])) : array(); if ($id != '' && is_user_logged_in() && count($matched) < 1 && !@in_array('guest', $package['access']) || !is_user_logged_in() && !@in_array('guest', $package['access']) && $id != '') { wpdm_download_data("permission-denied.txt", __("You don't have permission to download this file", 'wpdmpro')); die; } else { if ($lock === 'locked' && $limit <= 0) { if ($key != '') { wpdm_download_data("link-expired.txt", __("Download link is expired. Please get new download link ( {$key} " . print_r(get_post_meta($id), 1) . " ).", 'wpdmpro')); } else { wpdm_download_data("invalid-link.txt", __("Download link is expired or not valid. Please get new download link.", 'wpdmpro')); } die; } else { if ($package['ID'] > 0) { include "process.php"; } } } } else { wpdm_notice(__("Invalid download link.", 'wpdmpro')); } }