function uri_parse($uri_in, &$scheme, &$apr_resource) { // Returns TRUE if $uri_in is a parsable APRTP URI. // A parsable URI is of the form described in RFC 3986: Scheme://Resource // Supported scheme names are: "aprtp" or "aprtps" // Resource identifies a loadable browser page. // If $uri_in is parsable, the following variables are filled in: // $scheme = Transliterated APRTP URI scheme that is supported: "aprtp" --> "http" or "aprtps" --> "https" // $apr_resource = The target browser page. // -- The Assurer, 2011-07-16. if (!eStore_aprtp::is_aprtp_scheme($uri_in)) { return FALSE; } // Qualify the scheme. // Parse the scheme and resource names... $uri_regex = '/^apr(.+):\\/\\/(.+)/i'; if (preg_match_all($uri_regex, $uri_in, $uri_matches) != 1) { return FALSE; } // Parse URI elements. $scheme = 'ht' . strtolower($uri_matches[1][0]); // URI scheme. $apr_resource = str_replace('%2F', '/', rawurlencode($uri_matches[2][0])); // Resource name. // Undo URL encoding for query strings, in case "Ugly" permalinks are being used... $apr_resource = str_replace('%3F', '?', $apr_resource); $apr_resource = str_replace('%3D', '=', $apr_resource); return TRUE; // No parsing errors occurred. }
} // If the encrypted link did not contain a file URL, use the product download URL instead. $file_path = !empty($url) ? $url : $retrieved_product->product_download_url; //Update the access count if this feature is enabled if ($current_access_count != -1) { $cond = " download_key = '{$file_key}'"; $fields = array(); $fields['access_count'] = $current_access_count + 1; $result = WP_eStore_Db_Access::update(WP_ESTORE_DOWNLOAD_LINKS_TABLE_NAME, $cond, $fields); } $clientip = $_SERVER['REMOTE_ADDR']; $eStore_debug_manager->downloads("Handing download request from IP Address: " . $clientip, ESTORE_LEVEL_STATUS); if (eStore_aprtp::is_aprtp_scheme($file_path)) { // Authenticated Page Redirect (APR) URL request... $eStore_debug_manager->downloads("APRTP URI request = {$file_path}", ESTORE_LEVEL_STATUS); $retVal = eStore_aprtp::generate_url_request($file_path, $apr_file_path); switch ($retVal) { case -1: // Authenticated Page Redirect (APR) URL request... $eStore_debug_manager->downloads("Dispatching APRTP URL = {$apr_file_path}", ESTORE_LEVEL_STATUS); header("Location: {$apr_file_path}"); exit; case FALSE: // Malformed URI request... $eStore_debug_manager->downloads("Malformed or misconfigured APRTP URI request!", ESTORE_LEVEL_FALURE); eStore_dlvs::error(ESTORE_DLVS_APM); exit; default: // Unrecognized URI request... $eStore_debug_manager->downloads("Unrecognized eStore_aprtp::generate_url_request() return = {$retVal}", ESTORE_LEVEL_FALURE); eStore_dlvs::error(ESTORE_DLVS_APC);