PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.39
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.39
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
← All changes | Inc/Core/Controllers/BoxImport.php +31 -34 1.0.92.1.39 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 1.0.9 Free
4 + * @version 2.1.39 Free
5 5 *
6 6 * @author FirePlugins <info@fireplugins.com>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2021 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2025 FirePlugins All Rights Reserved
9 9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 10 */
11 11
12 12 namespace FireBox\Core\Controllers;
@@ -49,14 +49,25 @@
49 49 * @return void
50 50 */
51 51 public function processBoxesImport($input)
52 52 {
53 - $file = $this->getUploadedFile();
53 + // run a quick security check
54 + if (!check_admin_referer('fpf_form_nonce_firebox_import', 'fpf_form_nonce_firebox_import'))
55 + {
56 + return; // get out if we didn't click the Activate button
57 + }
54 58
59 + if (!isset($_FILES['file']))
60 + {
61 + return;
62 + }
63 +
64 + $file = $_FILES['file'];
65 +
55 66 // ensure a file was given
56 67 if (!is_array($file) || !isset($file['name']) || empty($file['name']))
57 68 {
58 - add_settings_error( self::settings_name, 'settings_updated', fpframework()->_('FPF_PLEASE_SELECT_A_FILE_TO_UPLOAD'), 'error');
69 + \FPFramework\Libs\AdminNotice::displayError(fpframework()->_('FPF_PLEASE_SELECT_A_FILE_TO_UPLOAD'));
59 70 return;
60 71 }
61 72
62 73 $ext = explode('.', $file['name']);
@@ -63,9 +74,9 @@
63 74
64 75 // ensure given file plugin was given
65 76 if (!in_array($ext[count($ext) - 1], ['fbox']))
66 77 {
67 - add_settings_error( self::settings_name, 'settings_updated', fpframework()->_('FPF_PLEASE_CHOOSE_A_VALID_FILE'), 'error');
78 + \FPFramework\Libs\AdminNotice::displayError(fpframework()->_('FPF_PLEASE_CHOOSE_A_VALID_FILE'));
68 79 return;
69 80 }
70 81
71 82 $publish_all = isset($input['publish_all']) ? $input['publish_all'] : 0;
@@ -70,20 +81,21 @@
70 81
71 82 $publish_all = isset($input['publish_all']) ? $input['publish_all'] : 0;
72 83
73 84 // read file contents
74 - $data = $this->getUploadedFileContents($file['tmp_name']);
85 + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
86 + $data = file_get_contents($file['tmp_name']);
75 87
76 88 // if empty data file then abort
77 89 if (empty($data))
78 90 {
79 - add_settings_error( self::settings_name, 'settings_updated', fpframework()->_('FPF_FILE_EMPTY'), 'error');
91 + \FPFramework\Libs\AdminNotice::displayError(fpframework()->_('FPF_FILE_EMPTY'));
80 92 return;
81 93 }
82 94
83 95 if (!$items = json_decode($data, true))
84 96 {
85 - add_settings_error( self::settings_name, 'settings_updated', firebox()->_('FB_POPUP_IMPORT_CONTENTS_ERROR'), 'error');
97 + \FPFramework\Libs\AdminNotice::displayError(firebox()->_('FB_CAMPAIGN_IMPORT_CONTENTS_ERROR'));
86 98 return;
87 99 }
88 100
89 101 if (is_null($items))
@@ -90,43 +102,25 @@
90 102 {
91 103 $items = [];
92 104 }
93 105
106 + if (!$items)
107 + {
108 + return;
109 + }
110 +
94 111 // import all boxes
95 112 if (!$new_box_id = $this->importBoxes($items, $publish_all))
96 113 {
97 - add_settings_error( self::settings_name, 'settings_updated', firebox()->_('FB_POPUP_IMPORT_CONTENTS_ERROR'), 'error');
114 + \FPFramework\Libs\AdminNotice::displayError(firebox()->_('FB_CAMPAIGN_IMPORT_CONTENTS_ERROR'));
98 115 return;
99 116 }
100 117
101 - add_settings_error( self::settings_name, 'settings_updated', fpframework()->_('FPF_ITEMS_SAVED'), 'success');
118 + \FPFramework\Libs\AdminNotice::displaySuccess(fpframework()->_('FPF_ITEMS_SAVED'));
102 119 return $new_box_id;
103 120 }
104 121
105 122 /**
106 - * Returns the uploaded file
107 - *
108 - * @return mixed
109 - */
110 - protected function getUploadedFile()
111 - {
112 - $file = isset($_FILES['file']) ? $_FILES['file'] : '';
113 - return $file;
114 - }
115 -
116 - /**
117 - * Returns the contents of the file
118 - *
119 - * @param string $tmp_name
120 - *
121 - * @return string
122 - */
123 - protected function getUploadedFileContents($tmp_name)
124 - {
125 - return file_get_contents($tmp_name);
126 - }
127 -
128 - /**
129 123 * Imports boxes data
130 124 *
131 125 * @param array $items
132 126 * @param int $publish_all
@@ -170,8 +164,10 @@
170 164
171 165 $box['post_date'] = $date_with_tz->format('Y-m-d H:i:s');
172 166 $box['post_date_gmt'] = $date_without_tz->format('Y-m-d H:i:s');
173 167
168 + \FireBox\Core\Helpers\Form\Form::ensureUniqueFormIDs($box['post_content']);
169 +
174 170 // set publish status
175 171 if (in_array($publish_all, [0, 1]))
176 172 {
177 173 $box['post_status'] = ($publish_all == 0) ? 'draft' : 'publish';
@@ -204,7 +200,8 @@
204 200 'section_name' => self::settings_name,
205 201 'class' => 'settings-ui-inner-fields',
206 202 'button_label' => 'FPF_IMPORT'
207 203 ]);
208 - $form->render();
204 +
205 + echo $form->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
209 206 }
210 207 }