PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
This is a new support thread for the PDF Attachment in Product Description Mod v2.2.0 and specifically for Zen Cart version 1.5.7c
Versions of Zen Cart prior to 1.5.7c are NOT supported by this mod or this thread.
When approved, the files will be found at https://www.zen-cart.com/downloads.php?do=file&id=1642.
The files are also available on GitHub at https://github.com/dbltoe/PDF-Attach...ct-Description.
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
Approved. Strong suggestion: also add a .htaccess file to the pdf-attachments folder. You can use the one from /download.
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
THANX Scott.
The .htaccess file is available on GitHub at https://github.com/dbltoe/PDF-Attach...ct-Description
or...
create your own.
Code:
## @copyright Copyright 2003-2020 Zen Cart Development Team
# @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
# @version $Id: DrByte 2020 Oct 29 Modified in v1.5.7a $
#
AuthType Basic
AuthName "No access"
AuthUserFile .htnopasswd
AuthGroupFile /dev/null
#Require valid-user
###############################
#
# This is used with Apache WebServers
#
# The following blocks direct HTTP requests to all filetypes in this directory recursively, except certain approved exceptions
# It also prevents the ability of any scripts to run. No type of script, be it PHP, PERL or whatever, can normally be executed if ExecCGI is disabled.
# Will also prevent people from seeing what is in the dir. and any sub-directories
#
# For this to work, you must include either 'All' or at least: 'Limit' and 'Indexes' parameters to the AllowOverride configuration in your apache/conf/httpd.conf file.
# Additionally, if you want the added protection offered by the OPTIONS directive below, you'll need to add 'Options' to the AllowOverride list, if 'All' is not specified.
# Example:
#<Directory "/usr/local/apache/htdocs">
# AllowOverride Limit Options Indexes
#</Directory>
###############################
# deny *everything*
<FilesMatch ".*">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order Allow,Deny
Deny from all
</IfModule>
</FilesMatch>
# but now allow just *certain* necessary files:
<FilesMatch "(?i).*\.(pdf)$">
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order Allow,Deny
Allow from all
</IfModule>
</FilesMatch>
<IfModule mod_headers.c>
<FilesMatch "(?i).*\.(zip|pdf|mp3|swf|wma|wmv|wav|epub|ogg|m4v|m4a)$">
# tell all downloads to automatically be treated as "save as" instead of launching in an application directly
# ALERT: ForceType requires Apache2 or later. If using older version of Apache, it will need mod_mime installed. Or just comment out the ForceType line below
# (to disable, just comment the next 2 lines by adding a '#' at the beginning of each):
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
</IfModule>
IndexIgnore */*
## NOTE: If you want even greater security to prevent hackers from running scripts in this folder, uncomment the following line (if your hosting company will allow you to use OPTIONS):
# OPTIONS -Indexes -ExecCGI
This will allow ONLY PDF files to be uploaded.
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
When creating or updating a product, the PDF Attachment options will appear between the Product Images and the inputs for URL, Shipping Weight, and Sort Order.
It should look like the following:
Attachment 19540
It's operation is very similar to the process used for Product Images.
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
Just found a glitch that occurred when adding the hidden file/author/version information at the top of New_Files/ YOUR_ADMIN/includes/functions/extra_functions/pdf_attachments_functions.php.
Operation of the mod is not affected but the portion that should be commented out is shown at the top of all admin pages.
I will be submitting version 2.2.1 to the Plugins
You can either grab the repaired file from GitHub at https://github.com/dbltoe/PDF-Attach...ct-Description
Or...
Change
Code:
// | http://www.zen-cart.com/index.php |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
//-Last updated for PDF Attachment v2.2.0, 20210430 (dbltoe)
//
<?php
To
Code:
<?php
// | http://www.zen-cart.com/index.php |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// Last updated for PDF Attachment v2.2.1, 20210430 (dbltoe)
//
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
I think that the addition of $sql in ./includes/modules/pages/product_info/main_template_vars.php is not required. You get this data above already. (See "includes/modules/pages/product_info/main_template_vars.php" line 18)
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
Suggestions / Bug Fixes:
- rather than having people modify their configure.php files, just create
includes/languages/english/extra_definitions/pdf_attachment.php
with define('DIR_FS_CATALOG_PDF_ATTACHMENTS', DIR_FS_CATALOG . 'pdf-attachments/');
- admin/includes/modules/product/preview_info.php line 97 not needed.
$pInfo->products_name = $products_image_name;
- admin/includes/modules/copy_product_confirm.php line 112 you are missing the field name pdf_attachment_name, which should be added after products_name. As coded, the line would give a SQL error.
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
Re: the last item - just updated this file admin/includes/modules/copy_product_confirm.php in 1.5.8 to use zen_db_perform on an array, so it will be easier to add the setting for PDF attachements.
https://github.com/zencart/zencart/p...ent-4898788954
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
while i admire the intent of ALL plugins (and their writers) to help store owners, i would change a few things with this one:
- i would not preface any function name with zen_. it makes it seem that it is part of the ZC base code, of which it is not.
- i am also not a fan of whole sale replacement of existing scripts. the ZC notifier system should be able to handle what this plugin does without any modification of ZC core files.
- if it can not be done using the ZC notifier system (of which i am not convinced), then i would create a PR to add needed notifiers.
- barring that, i would create a standalone plugin using the new zc_plugins for the admin side to add needed pdfs.
just my 2 cents.
best.
Re: PDF Attachment in Product Description v2.2.0 for 1.5.7c [Support Thread]
I suspect moving the PDF information out of the products / products_description tables into its own table would make decoupling this change from the core even easier. Perhaps in a future version.