Download button problem :/

Hi experts,

I made some changes in module for my needs. I delete ’’free download’’ module from it. Now I put two pdf buttons for download before purchase. http://uzar.com.tr/digishop/ Grey button works for adding into cart and green buttons for product specifications.

Now I create a new column for filename2(second green button) I can upload two pdf files w?thout any problem but when I click on them I got same pdfs getting downloaded. You can verify the problem by trying on first and second green buttons.

The changes I made in download.php: http://www.ipaste.org/nQj

I will appreciate If you can tell my faults in this file or if any additional changes in other files required.

ps: upload works flawless, download just works for one pdf.

Experts told to solve the problem;

The problem is you are using the same url token for both files

free=acc68c9b5c372e34950b7fad3abf20cb

Create another token field within mod_digishop table, than assign unique token to your second file. After that you would need to modify download.php in /modules/digishop/. See modified section of download.php file here: http://pastebin.com/2GKmxJZw
Once done, make sure that your second file url starts with download.php?free2=$token.
You can of course change get variable free2 to something else.

[php] if (isset($_GET[‘free’]) or isset($_GET[‘free2’])) {

      $freefile = isset($_GET['free']) ? $_GET['free'] : $_GET['free2'];
      $row = $digishop->getFreeDownload($freefile);

… All remain the same…[/php]

How can I make my download.php file above?

download.php
[php]<?php
/**

  • Download
  • @package CMS Pro
  • @author wojoscripts.com
  • @copyright 2014
  • @version $Id: download.php, v4.00 2014-01-10 10:12:05 gewa Exp $
    */
    define("_VALID_PHP", true);

require_once ("…/…/init.php");
require_once (MODPATH . “digishop/admin_class.php”);

Registry::set(‘Digishop’, new Digishop());
$digishop = Registry::get(“Digishop”);

define(‘BASE_DIR’, $digishop->filedir);

$allowed_ext = array(
‘zip’ => ‘application/zip’,
‘rar’ => ‘application/x-rar-compressed’,
‘pdf’ => ‘application/pdf’,
‘doc’ => ‘application/msword’,
‘xls’ => ‘application/vnd.ms-excel’,
‘ppt’ => ‘application/vnd.ms-powerpoint’,
‘exe’ => ‘application/octet-stream’,
‘gif’ => ‘image/gif’,
‘png’ => ‘image/png’,
‘jpg’ => ‘image/jpeg’,
‘jpeg’ => ‘image/jpeg’,
‘mp3’ => ‘audio/mpeg’,
‘wav’ => ‘audio/x-wav’,
‘mpeg’ => ‘video/mpeg’,
‘mpg’ => ‘video/mpeg’,
‘mpe’ => ‘video/mpeg’,
‘mov’ => ‘video/quicktime’,
‘avi’ => ‘video/x-msvideo’);

set_time_limit(0);

if (ini_get(‘zlib.output_compression’)) {
ini_set(‘zlib.output_compression’, ‘Off’);
}
?>

<?php // Free Downloads if (isset($_GET['free'])) { $row = $digishop->getFreeDownload($_GET['free']); if ($row) { $fext = strtolower(substr(strrchr($row->filename, "."), 1)); if (!file_exists(BASE_DIR . $row->filename) || !is_file(BASE_DIR . $row->filename)) { redirect_to(doUrl(false, false, "digishop", "?msg=1")); exit; } if (!array_key_exists($fext, $allowed_ext)) { redirect_to(doUrl(false, false, "digishop", "?msg=2")); exit; } if ($digishop->allow_free == '1' && !$user->logged_in) { redirect_to(doUrl(false, false, "digishop", "?msg=3")); exit; } downloadFile(BASE_DIR . $row->filename, $row->filename); } else { redirect_to(doUrl(false, false, "digishop")); } // Membership Downloads } elseif (isset($_GET['member']) && $user->logged_in) { $row = $digishop->getMembershipDownload($_GET['member']); if ($row) { $m_arr = explode(",", $row->membership_id); reset($m_arr); $fext = strtolower(substr(strrchr($row->filename, "."), 1)); if (!file_exists(BASE_DIR . $row->filename) || !is_file(BASE_DIR . $row->filename)) { redirect_to(doUrl(false, false, "digishop", "?msg=1")); exit; } if (!array_key_exists($fext, $allowed_ext)) { redirect_to(doUrl(false, false, "digishop", "?msg=2")); exit; } if ($user->validateMembership() and in_array($user->membership_id, $m_arr)) { downloadFile(BASE_DIR . $row->filename, $row->filename); } else { redirect_to(doUrl(false, false, "digishop", "?msg=4")); exit; } } else { redirect_to(doUrl(false, false, "digishop")); } // Paid Downloads } elseif (isset($_GET['fileid'])) { $row = $digishop->getPaidDownload($_GET['fileid']); $fext = strtolower(substr(strrchr($row->filename, "."), 1)); if ($row) { if (!file_exists(BASE_DIR . $row->filename) || !is_file(BASE_DIR . $row->filename)) { redirect_to(doUrl(false, false, "digishop", "?msg=1")); exit; } if (!array_key_exists($fext, $allowed_ext)) { redirect_to(doUrl(false, false, "digishop", "?msg=2")); exit; } downloadFile(BASE_DIR . $row->filename, $row->filename); } else { redirect_to(doUrl(false, false, "digishop")); } } else { redirect_to(doUrl(false, false, "digishop", "?msg=5")); exit; } ?>[/php]

admin_class.php They said that the problem in this file.

http://pastebin.com/HyXsWu7x

I am not sure what you are asking of us. I went to the digishop page and the first item is set up
correctly. Both buttons have different token numbers for the “free” argument. The rest have the
same token numbers for each button. That is what your experts were talking about. You must have
a loop somewhere that displays the list of items to download. They all have the same picture at the
moment. The first seems to be set up correctly. The rest have different token’s but, have the same
token for each button. So, they download the same file. Looking at the tinypic, you only show us
two items. So, perhaps it is an issue of not having enough test items in your database?

Also, while looking at the final live source of the digishop page, I noticed you have a bad error on it.
To view the source of a page, just RIGHT-CLICK on the page, in this case the digishop page and select
VIEW-SOURCE. (On Firefox, VIEW-PAGE-SOURCE) and you will see the code that the browser sees
after the PHP is completed and CSS is processed. In there I noticed you have a problem with ending
that do not exist. You start an , end it and then end it again … Here is one area of
the code to show where it is ened incorrectly:

class="wojo warning button mLeft5">MSDS
The should be removed or the previous instance of it should be removed depending on what you wanted to be 'd...

So, not sure if that helps, but, hope so! Good luck, let us know…

Sponsor our Newsletter | Privacy Policy | Terms of Service