Пример #1
0
 function decrypt($pwd, $data)
 {
     return RC4Crypt::encrypt($pwd, $data);
 }
function eStore_check_stamping_flag_and_generate_download_key($retrieved_product, $product_id, $url = '', $payment_data = '')
{
    if ($retrieved_product->use_pdf_stamper == 1 && !empty($payment_data)) {
        if (WP_ESTORE_STAMP_PDF_FILE_AT_DOWNLOAD_TIME === '1') {
            //Check if file sould be stamped at download time option is enabled
            $download_key = eStore_generate_download_key($product_id, $url);
            return $download_key;
        }
        if (!empty($url)) {
            $src_file = $url;
        } else {
            $src_file = $retrieved_product->product_download_url;
        }
        eStore_payment_debug('Stamping request for product ID: ' . $product_id, true);
        //Check if it is a multiple file URL product
        $multi_file_product = false;
        $product_urls = explode(',', $retrieved_product->product_download_url);
        if (sizeof($product_urls) > 1) {
            $multi_file_product = true;
        }
        $txn_id = $payment_data['txn_id'];
        $force_restamp = false;
        if (isset($payment_data['force_restamp']) && $payment_data['force_restamp'] == '1') {
            //Don't lookup cached copy
            eStore_payment_debug('Force restamping is enabled in the request.', true);
            $force_restamp = true;
        }
        if (!empty($txn_id) && !$multi_file_product && !$force_restamp) {
            eStore_payment_debug('Checking for a reference to the stamped copy of the file for this transaction before invoking another stamp request:' . $txn_id, true);
            $cond = " txn_id = '{$txn_id}'";
            $result = WP_eStore_Db_Access::findAll(WP_ESTORE_DOWNLOAD_LINKS_TABLE_NAME, $cond);
            if ($result) {
                eStore_payment_debug('Found a reference to the stamped copy of a file. Performing an indepth check...', true);
                $random_key = get_option('eStore_random_code');
                foreach ($result as $download_item) {
                    $download_key = $download_item->download_key;
                    eStore_payment_debug('Decrypting download key: ' . $download_key, true);
                    $decrypted_data = RC4Crypt::decrypt($random_key, base64_decode(rawurldecode($download_key)));
                    list($product_id_of_stamped_file, $timestamp, $stamped_file_url) = explode('|', $decrypted_data);
                    eStore_payment_debug('Decrypted data... Product ID: ' . $product_id_of_stamped_file . ', Stamped File URL:' . $stamped_file_url, true);
                    if ($product_id == $product_id_of_stamped_file) {
                        eStore_payment_debug('Product IDs match. Using the existing stamped copy of the file.', true);
                        $new_download_key = eStore_generate_download_key($product_id_of_stamped_file, $stamped_file_url);
                        eStore_payment_debug('New Download Key: ' . $new_download_key, true);
                        return $new_download_key;
                    }
                }
                eStore_payment_debug('Product IDs do not match. Need to proceed with a fresh stamping.', true);
            } else {
                eStore_payment_debug('Could not find a reference to the stamped copy of a file', true);
            }
        }
        $stamped_file_url = eStore_stamp_pdf_file($payment_data, $src_file);
        if ($stamped_file_url === 'Error!') {
            eStore_payment_debug('PDF Stamping did not finish correctly!', false);
            $download_key = "Error with PDF stamping (Error code: PDF01). Perform a manual stamping and make sure the PDF stamper is working on your server.";
            return $download_key;
        }
        $download_key = eStore_generate_download_key($product_id, $stamped_file_url);
    } else {
        $download_key = eStore_generate_download_key($product_id, $url);
    }
    return $download_key;
}
Пример #3
0
if (!is_object($eStore_debug_manager)) {
    //Initialize debug mgr if it is not loaded yet
    $eStore_debug_manager = new eStore_dbgmgr(WP_ESTORE_PATH);
}
$time = time();
// Time download script was invoked.
global $wpdb;
$products_table_name = $wpdb->prefix . "wp_eStore_tbl";
$product_meta_table_name = WP_ESTORE_PRODUCTS_META_TABLE_NAME;
$data = $_GET['file'];
$file_key = $data;
$current_access_count = -1;
$random_key = get_option('eStore_random_code');
$download_url_life = get_option('eStore_download_url_life');
$download_url_limit_count = get_option('eStore_download_url_limit_count');
$id_time = RC4Crypt::decrypt($random_key, base64_decode(rawurldecode($data)));
$product_id = "";
$timestamp = "";
$url = "";
$encrypted_args_array = explode('|', $id_time);
if (count($encrypted_args_array) > 2) {
    list($product_id, $timestamp, $url) = $encrypted_args_array;
} else {
    list($product_id, $timestamp) = $encrypted_args_array;
}
$theid = strip_tags($product_id);
$retrieved_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$theid}'", OBJECT);
if ($retrieved_product->id != $product_id) {
    eStore_dlvs::error(ESTORE_DLVS_PID, FALSE);
    exit;
}
Пример #4
0
 function cookie_test($cookie_timeout = 0, $cookie_name = '')
 {
     // Test for valid APR cookie.
     // Returns TRUE if a valid APR cookie, derived from $cookie_name exists.  If $cookie_name is an empty string, then
     // $cookie_name will be assigned the URL of the current browser page.  Returns FALSE if the named APR cookie does not
     // exist.  If $cookie_timeout is greater than zero, then FALSE will be returned if the APR cookie is older than
     // $cookie_timeout minutes.
     // -- The Assurer, 2012-04-30.
     global $eStore_debug_manager;
     // Need access to debug manager.
     if ($cookie_name == '') {
         $cookie_name = eStore_aprtp::curPageURL();
     }
     // Use URL of current browser page.
     $eStore_debug_manager->downloads("Authenticating APR request for: {$cookie_name}", ESTORE_LEVEL_STATUS);
     $random_key = get_option('eStore_random_code');
     $cookie_flavor = md5(RC4Crypt::encrypt($random_key, $cookie_name));
     // Derive the APR cookie name.
     if (!isset($_COOKIE["{$cookie_flavor}"])) {
         $eStore_debug_manager->downloads("\$_COOKIE[{$cookie_flavor}] not found.", ESTORE_LEVEL_STATUS);
         return FALSE;
         // No cookie for you!
     }
     if ($cookie_timeout > 0) {
         // Test for age of APR cookie, if $cookie_timeout is at least 1 minute...
         $cookie_time = (int) RC4Crypt::decrypt($random_key, base64_decode(rawurldecode($_COOKIE[$cookie_flavor])));
         $cookie_timeout = (int) ($cookie_timeout * 60 + $cookie_time);
         if ($cookie_timeout <= (int) time()) {
             $eStore_debug_manager->downloads("\$_COOKIE[{$cookie_flavor}] expired.", ESTORE_LEVEL_STATUS);
             return FALSE;
             // APR cookie has expired.
         }
     }
     return TRUE;
 }
echo '<h4 align="center">' . $lang['download_title'] . '</h4><br>';
echo '<strong>' . $lang['download_trouble_title'] . '</strong><br>';
echo $lang['download_trouble_text'];
echo '<p>&nbsp;</p>';
if (file_exists("download_sessions/{$product_id}.dat")) {
    $download_file = "download_sessions/{$product_id}.dat";
} elseif (file_exists("sessions/{$product_id}.dat")) {
    $download_file = "sessions/{$product_id}.dat";
} elseif (!empty($module) && file_exists("modules/{$mod}/sessions/{$product_id}.dat")) {
    $download_file = "modules/{$mod}/sessions/{$product_id}.dat";
}
if (file_exists($download_file)) {
    $lines = array();
    $lines = file($download_file);
    $i = 1;
    foreach ($lines as $thisline) {
        $thisline = trim($thisline);
        if (!empty($thisline)) {
            list($id, $id_item, $category, $subcategory, $title, $filename, $digital, $folder1, $currency, $weight, $price, $quantity, $option1, $option2, $tax, $ship, $discount1, $discount2, $ip_name) = explode('|', $thisline);
        }
        if ($digital == 1) {
            @($folder = $subcategory == 'ProductModule' ? 'medias/' . $mod . '/' . $folder1 : $upload_folder);
            $download_product = $folder . '|' . $filename . '|' . $timestamp;
            $download_cart_link = 'resume_download.php?file=' . rawurlencode(base64_encode(RC4Crypt::encrypt($secret, $download_product)));
            echo '<li>' . $lang['download_your_file'] . '&nbsp;' . $i . '&nbsp;:&nbsp;&nbsp;&nbsp;<input class="download" type="button" name="download" value="' . $lang['button_download'] . '" onClick="location.href=\'' . $download_cart_link . '\'">&nbsp;&nbsp;&nbsp;<a href="' . $download_cart_link . '">' . $title . '</a></li><br><br>' . "\n";
            $i++;
        }
    }
} else {
    echo "<div align=\"left\">" . $lang['download_error'] . "</div><br>\n";
}