PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.4
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
← All changes | includes/Core/Util/FileDownloadProvider.php +19 -10 2.02.21.4 View file →
@@ -1,15 +1,18 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Core\Util;
4 4
5 -final class FileDownloadProvider {
6 - public function register() {
5 +final class FileDownloadProvider
6 +{
7 + public function register()
8 + {
7 9 add_action('template_redirect', [$this, 'authCheckandFrceDownloadHelper']);
8 10 add_shortcode('bitforms-frontend-file', [$this, 'handleFileDownload']);
9 11 }
10 12
11 - public function handleFileDownload() {
13 + public function handleFileDownload()
14 + {
12 15 if (!isset($_GET['formID']) || !isset($_GET['entryID']) || !isset($_GET['fileID'])) {
13 16 global $wp_query;
14 17 $wp_query->set_404();
15 18 status_header(404);
@@ -18,15 +21,17 @@
18 21 }
19 22 $formID = intval(sanitize_text_field($_GET['formID']));
20 23 $entryID = intval(sanitize_text_field($_GET['entryID']));
21 24 $fileID = sanitize_file_name($_GET['fileID']);
22 - $filePath = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID . DIRECTORY_SEPARATOR . $entryID . DIRECTORY_SEPARATOR . $fileID;
25 + $filePath = FileHandler::getEntriesFileUploadDir($formID, $entryID) . DIRECTORY_SEPARATOR . $fileID;
26 +
23 27 if (is_readable($filePath)) {
24 28 $this->fileDownloadORView($filePath, true);
25 29 }
26 30 }
27 31
28 - public static function getBaseDownloadURL() {
32 + public static function getBaseDownloadURL()
33 + {
29 34 $routes = get_option('bitforms_routes');
30 35 if (isset($routes['file'])) {
31 36 $file_page = get_post($routes['file']);
32 37 if (empty($file_page)) {
@@ -65,9 +70,10 @@
65 70
66 71 return $file_page_slug;
67 72 }
68 73
69 - public function authCheckandFrceDownloadHelper() {
74 + public function authCheckandFrceDownloadHelper()
75 + {
70 76 if (!is_singular('bitforms')) {
71 77 return;
72 78 }
73 79 global $post;
@@ -86,9 +92,10 @@
86 92 }
87 93 }
88 94 }
89 95
90 - private function show404() {
96 + private function show404()
97 + {
91 98 global $wp_query;
92 99 $wp_query->set_404();
93 100 status_header(404);
94 101 get_template_part(404);
@@ -94,9 +101,10 @@
94 101 get_template_part(404);
95 102 exit();
96 103 }
97 104
98 - private function isRequestedFileExists() {
105 + private function isRequestedFileExists()
106 + {
99 107 if (!isset($_GET['formID']) || !isset($_GET['entryID']) || !isset($_GET['fileID'])) {
100 108 return false;
101 109 }
102 110 $formID = intval(sanitize_text_field($_GET['formID']));
@@ -101,9 +109,9 @@
101 109 }
102 110 $formID = intval(sanitize_text_field($_GET['formID']));
103 111 $entryID = intval(sanitize_text_field($_GET['entryID']));
104 112 $fileID = sanitize_file_name($_GET['fileID']);
105 - $filePath = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID . DIRECTORY_SEPARATOR . $entryID . DIRECTORY_SEPARATOR . $fileID;
113 + $filePath = FileHandler::getEntriesFileUploadDir($formID, $entryID) . DIRECTORY_SEPARATOR . $fileID;
106 114 if (is_readable($filePath)) {
107 115 return $filePath;
108 116 }
109 117
@@ -109,9 +117,10 @@
109 117
110 118 return false;
111 119 }
112 120
113 - private function fileDownloadORView($filePath, $forceDownload = false) {
121 + private function fileDownloadORView($filePath, $forceDownload = false)
122 + {
114 123 if ($forceDownload) {
115 124 header('Content-Type: application/force-download');
116 125 header('Content-Type: application/octet-stream');
117 126 header('Content-Type: application/download');