PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.53
E2Pdf – Export Pdf Tool for WordPress v1.32.53
1.32.53 1.32.51 1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 All 74 releases
← All changes | classes/helper/e2pdf-filter.php +39 -9 1.07.11 → 1.32.53 View file →
@@ -1,14 +1,12 @@
1 1 <?php
2 2
3 3 /**
4 - * E2pdf Filter Helper
5 - *
6 - * @copyright Copyright 2017 https://e2pdf.com
7 - * @license GPL v2
8 - * @version 1
9 - * @link https://e2pdf.com
10 - * @since 1.07.09
4 + * File: /helper/e2pdf-filter.php
5 + *
6 + * @package E2Pdf
7 + * @license GPLv3
8 + * @link https://e2pdf.com
11 9 */
12 10 if (!defined('ABSPATH')) {
13 11 die('Access denied.');
14 12 }
@@ -14,12 +12,13 @@
14 12 }
15 13
16 14 class Helper_E2pdf_Filter {
17 15
16 + // is stream
18 17 public function is_stream($file_path) {
19 18 if (strpos($file_path, '://') > 0) {
20 19 $wrappers = array(
21 - 'phar'
20 + 'phar',
22 21 );
23 22 if (function_exists('stream_get_wrappers')) {
24 23 $wrappers = stream_get_wrappers();
25 24 }
@@ -24,9 +23,9 @@
24 23 $wrappers = stream_get_wrappers();
25 24 }
26 25
27 26 foreach ($wrappers as $wrapper) {
28 - if (in_array($wrapper, ['http', 'https', 'file'])) {
27 + if (in_array($wrapper, ['http', 'https', 'file'], true)) {
29 28 continue;
30 29 }
31 30 if (stripos($file_path, $wrapper . '://') === 0) {
32 31 return true;
@@ -35,5 +34,36 @@
35 34 }
36 35 return false;
37 36 }
38 37
38 + // is downloadable
39 + public function is_downloadable($file_path) {
40 + if (!$file_path || !$this->is_downloadable_ext($file_path)) {
41 + return false;
42 + }
43 + return true;
44 + }
45 +
46 + // is downlodable ext
47 + public function is_downloadable_ext($file_path) {
48 + $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
49 + $allowed = apply_filters(
50 + 'e2pdf_helper_filter_is_downloadable_allowed_extensions',
51 + ['pdf', 'jpg', 'doc', 'docx']
52 + );
53 + return in_array($ext, $allowed, true);
54 + }
55 +
56 + // filter html tags
57 + public function filter_html_tags($value) {
58 + if ($value) {
59 + $tags = array(
60 + 'script',
61 + 'style',
62 + );
63 + foreach ($tags as $tag) {
64 + $value = preg_replace('#<' . $tag . '(.*?)>(.*?)</' . $tag . '>#is', '', $value);
65 + }
66 + }
67 + return $value;
68 + }
39 69 }