Changeset 3356768
- Timestamp:
- 09/05/2025 02:57:13 PM (6 months ago)
- Location:
- waterwoo-pdf/trunk
- Files:
-
- 8 edited
-
classes/wwpdf-file-handler.php (modified) (4 diffs)
-
classes/wwpdf-settings-edd.php (modified) (1 diff)
-
classes/wwpdf-settings-woo.php (modified) (1 diff)
-
classes/wwpdf-watermark.php (modified) (3 diffs)
-
lib/tcpdi/tcpdi.php (modified) (1 diff)
-
lib/tcpdi/tcpdi_parser.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
-
waterwoo-pdf.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
waterwoo-pdf/trunk/classes/wwpdf-file-handler.php
r3334629 r3356768 10 10 * @var string 11 11 */ 12 private $watermarked_file ;12 private $watermarked_file = ''; 13 13 14 14 /** 15 15 * @var string 16 16 */ 17 protected $email ;17 protected $email = ''; 18 18 19 19 /** … … 21 21 */ 22 22 public function __construct() { 23 24 $this->watermarked_file = '';25 23 26 24 // Filter the file download path - WooCommerce … … 168 166 $file_array = apply_filters( 'wwpdf_filter_file_list', array_filter( array_map( 'trim', explode( PHP_EOL, $file_list ) ) ), $args ); 169 167 $file_listed = in_array( $requested_filename, $file_array ); 168 $this->email = $args['email'] ?? ''; 170 169 171 170 if ( ( $global_on == true && $file_listed ) || ( $global_on == false && ! $file_listed ) ) { … … 585 584 586 585 } elseif ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], [ 'http', 'https', 'ftp' ], true ) ) 587 && isset( $parsed_file_path['path'] )586 && isset( $parsed_file_path['path'] ) 588 587 ) { // We have an absolute path 589 588 $remote_file = false; -
waterwoo-pdf/trunk/classes/wwpdf-settings-edd.php
r3334629 r3356768 363 363 'id' => 'eddimark_pw', 364 364 'name' => __( 'User Password (optional)', 'waterwoo-pdf' ), 365 'desc' => '<br>' . __( 'This is a password your end user will need to enter before viewing the PDF file.', 'waterwoo-pdf' ) 366 . '<br>' . __( 'Enter <code>email</code> to set the password automagically as the user\'s checkout email address.', 'waterwoo-pdf' ), 367 'type' => 'text', 365 'desc' => '<br>' . __( 'This is a password your end user will need to enter before viewing the PDF file.', 'waterwoo-pdf' ), 366 'type' => 'text', 368 367 'std' => '', 369 368 ], -
waterwoo-pdf/trunk/classes/wwpdf-settings-woo.php
r3334629 r3356768 485 485 'type' => 'text', 486 486 'title' => __( 'User Password (optional)', 'waterwoo-pdf' ), 487 'desc' => __( 'This is a password your end user will need to enter before viewing the PDF file.', 'waterwoo-pdf' ) 488 . '<br>' . __( 'Enter <code>email</code> to set the password automagically as the user\'s checkout email address.', 'waterwoo-pdf' ), 489 'autoload' => false, 487 'desc' => __( 'This is a password your end user will need to enter before viewing the PDF file.', 'waterwoo-pdf' ), 488 'autoload' => false, 490 489 ], 491 490 [ -
waterwoo-pdf/trunk/classes/wwpdf-watermark.php
r3334629 r3356768 52 52 // for more styling, and marking chosen pages) 53 53 // please support the work of WordPress developers 54 // and buy the full version of this plugin at www.pdfink.com!54 // and buy the full version of this plugin at ** www.pdfink.com! ** 55 55 $pagecount = $this->pdf->setSourceFile( $this->origfile ); 56 56 57 57 if ( ! $pagecount ) { 58 throw new Exception( 'Unable to parse PDF into memory, possibly due to a PDF version >= 2.0 ' );58 throw new Exception( 'Unable to parse PDF into memory, possibly due to a PDF version >= 2.0, or incrementation, or a syntax issue.' ); 59 59 } 60 60 … … 178 178 179 179 // Passwording 180 $pwd_enabled = false;181 180 $user_pwd = $this->settings['password'] ?? ''; 182 if ( ! empty( $user_pwd ) ) {183 if ( 'email' === $user_pwd ) {184 $user_pwd = sanitize_email( $this->email );185 }186 if ( ! empty( $user_pwd ) ) { // if still valid after sanitization187 $pwd_enabled = true;188 }189 }190 181 191 182 // Adding file protections in this list removes them … … 207 198 // Higher encryption allows selective blocking blocking of 'extract', 'fill-forms', 'assemble', and 'print-high' 208 199 // Get these protections with higher encryption by using PDF Ink (pdfink.com) 209 if ( $pwd_enabled|| array_filter( $permissions ) ) {200 if ( ! empty( $user_pwd ) || array_filter( $permissions ) ) { 210 201 $this->pdf->SetProtection( 211 202 $permissions, -
waterwoo-pdf/trunk/lib/tcpdi/tcpdi.php
r3315732 r3356768 123 123 } 124 124 125 $currentFilename = $this->current_filename ;126 $currentParser = $this->current_parser ;125 $currentFilename = $this->current_filename ?? ''; 126 $currentParser = $this->current_parser ?? ''; 127 127 128 128 try { -
waterwoo-pdf/trunk/lib/tcpdi/tcpdi_parser.php
r3334629 r3356768 4 4 // Version : 1.2 5 5 // Begin : 2024-10-18 6 // Last Update : 2025-0 2-286 // Last Update : 2025-07-11 7 7 // Author : Little Package - https://github.com/littlepackage 8 8 // License : GNU-LGPL v3 (https://www.gnu.org/licenses/lgpl-3.0.en.html) … … 249 249 $this->pdfdata = $data; 250 250 } 251 // error_log( '$pdf_data: ' . print_r( str_replace("\x00", "[NULL]", $data ), true ) );252 251 253 252 // initialize class for decoding filters … … 469 468 $obj_num = 0; 470 469 $offset = $xoffset; 471 // @todo the [.|\W?] syntax seems wrong. (Originally it was [.?|\W?] which is more wrong.) 472 while (preg_match('/^[.|\W?]([0-9]+)[\s]([0-9]+)[\s]?([nf]?)/im', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { 470 while (preg_match('/^[.\W?]([0-9]+)[\s]([0-9]+)[\s]?([nf]?)/im', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { 473 471 // while ( preg_match('/^([0-9]+)[\s]([0-9]+)[\s]?([nf]?)/im', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0 ) { 474 472 $offset = ( strlen( $matches[0][0] ) + $matches[0][1] ); … … 588 586 foreach ( $keys as $key ) { 589 587 $v = $sarr[ $key ]; 590 if ( ( $key == '/Type' )&& ( $v[0] == PDF_TYPE_TOKEN && ( $v[1] == 'XRef' ) ) ) {588 if ( $key === '/Type' && ( $v[0] == PDF_TYPE_TOKEN && ( $v[1] == 'XRef' ) ) ) { 591 589 $valid_crs = true; 592 // } elseif ( ( $key == '/Index' ) && ( $v[0] == PDF_TYPE_ARRAY && count( $v[1] >= 2 ) ) ) { 593 } elseif ( ( $key == '/Index' ) && ( $v[0] == PDF_TYPE_ARRAY && count( $v[1] ) >= 2 ) ) { 590 } elseif ( $key === '/Index' && ( $v[0] == PDF_TYPE_ARRAY && count( $v[1] ) >= 2 ) ) { 594 591 // first object number in the subsection 595 592 $index_first = intval( $v[1][0][1] ); 596 593 // number of entries in the subsection 597 594 // $index_entries = intval( $v[1][1][1] ); 598 } elseif ( ( $key == '/Prev' ) && ( $v[0] == PDF_TYPE_NUMERIC )) {595 } elseif ( $key === '/Prev' && $v[0] == PDF_TYPE_NUMERIC ) { 599 596 // get previous xref offset 600 597 $prevxref = intval( $v[1] ); 601 } elseif ( ( $key == '/W' ) && ( $v[0] == PDF_TYPE_ARRAY )) {598 } elseif ( $key === '/W' && $v[0] == PDF_TYPE_ARRAY ) { 602 599 // number of bytes (in the decoded stream) of the corresponding field 603 600 $wb = []; … … 605 602 $wb[1] = intval( $v[1][1][1] ); 606 603 $wb[2] = intval( $v[1][2][1] ); 607 } elseif ( ( $key == '/DecodeParms' ) && ( $v[0] == PDF_TYPE_DICTIONARY )) {604 } elseif ( $key === '/DecodeParms' && $v[0] == PDF_TYPE_DICTIONARY ) { 608 605 $decpar = $v[1]; 609 606 foreach ( $decpar as $kdc => $vdc ) { 610 if ( ( $kdc == '/Columns' ) && ( $vdc[0] == PDF_TYPE_NUMERIC )) {607 if ( $kdc === '/Columns' && $vdc[0] == PDF_TYPE_NUMERIC ) { 611 608 $columns = intval( $vdc[1] ); 612 } elseif ( ( $kdc == '/Predictor' ) && ( $vdc[0] == PDF_TYPE_NUMERIC )) {609 } elseif ( $kdc === '/Predictor' && $vdc[0] == PDF_TYPE_NUMERIC ) { 613 610 $predictor = intval( $vdc[1] ); 614 611 } … … 817 814 // skip initial white space (control) chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP) 818 815 $offset += strspn($data, "\x00\x09\x0a\x0c\x0d\x20", $offset); 819 820 // tcpdi_parser can really get stuck here if char is null or otherwise; bail821 816 if ( ! isset( $data[ $offset ] ) ) { 822 817 return; … … 1478 1473 return false; 1479 1474 } 1480 $obj = $this->getObjectVal( $obj ); // @todo is this redundant?1481 1475 1482 1476 /** … … 1660 1654 $boxes = []; 1661 1655 1662 // @todo if all boxes are the same, should we give them all or just stick to CropBox or BleedBox only?1663 1656 foreach ( $this->availableBoxes as $box ) { 1664 1657 if ( $_box = $this->getPageBox( $page, $box, $k ) ) { -
waterwoo-pdf/trunk/readme.txt
r3334629 r3356768 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.2 8 Stable tag: 4.0. 38 Stable tag: 4.0.4 9 9 License: GPLv3 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 201 201 == Changelog == 202 202 203 = 4.0.4 - 4 September 2025 = 204 * Fix for new email as password feature 205 * Bump minimum WC version to 6.5 (to match plugin PHP 7.2 requirement) 206 203 207 = 4.0.3 - 26 July 2025 = 204 208 * Tweak for TCPDI parser to reach more PDFs -
waterwoo-pdf/trunk/waterwoo-pdf.php
r3334629 r3356768 4 4 * Plugin URI: https://wordpress.org/plugins/waterwoo-pdf/ 5 5 * Description: Custom watermark your PDF files upon WooCommerce, Download Monitor, and Easy Digital Download customer download. Since 2014. FKA "WaterWoo" 6 * Version: 4.0. 36 * Version: 4.0.4 7 7 * Author: Little Package 8 8 * Author URI: https://pdfink.com/ 9 9 * Donate link: https://paypal.me/littlepackage 10 * WC requires at least: 4.011 * WC tested up to: 10. 010 * WC requires at least: 6.5 11 * WC tested up to: 10.1 12 12 * 13 13 * License: GPLv3 or later … … 50 50 51 51 if ( ! defined( 'WWPDF_FREE_VERSION' ) ) { 52 define( 'WWPDF_FREE_VERSION', '4.0. 3' );52 define( 'WWPDF_FREE_VERSION', '4.0.4' ); 53 53 } 54 54 55 55 if ( ! defined( 'WWPDF_FREE_MIN_PHP' ) ) { 56 define( 'WWPDF_FREE_MIN_PHP', '7. 0' );56 define( 'WWPDF_FREE_MIN_PHP', '7.4' ); 57 57 } 58 58
Note: See TracChangeset
for help on using the changeset viewer.