PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.9
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.9
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
← All changes | classes/Visualizer/Source/Csv/Remote.php +21 -28 4.0.73.7.9 View file →
@@ -29,14 +29,14 @@
29 29 */
30 30 class Visualizer_Source_Csv_Remote extends Visualizer_Source_Csv {
31 31
32 32 /**
33 - * Path to the safely downloaded temporary file.
33 + * Temporary file name used when allow_url_fopen option is disabled.
34 34 *
35 35 * @since 1.4.2
36 36 *
37 37 * @access private
38 - * @var string|false
38 + * @var string
39 39 */
40 40 private $_tmpfile = false;
41 41
42 42 /**
@@ -73,9 +73,9 @@
73 73
74 74 // if filename is empty, extract it from chart content
75 75 if ( empty( $this->_filename ) ) {
76 76 $chart = get_post( $chart_id );
77 - $data = Visualizer_Module::decode_content( html_entity_decode( $chart->post_content ) );
77 + $data = unserialize( html_entity_decode( $chart->post_content ) );
78 78 if ( ! isset( $data['source'] ) ) {
79 79 return false;
80 80 }
81 81
@@ -129,44 +129,37 @@
129 129 return __CLASS__;
130 130 }
131 131
132 132 /**
133 - * Fetches the remote file and removes its temporary copy.
134 - *
135 - * @access public
136 - * @return boolean TRUE on success, otherwise FALSE.
137 - */
138 - public function fetch() {
139 - $result = parent::fetch();
140 -
141 - if ( $this->_tmpfile && is_file( $this->_tmpfile ) ) {
142 - wp_delete_file( $this->_tmpfile );
143 - $this->_tmpfile = false;
144 - }
145 -
146 - return $result;
147 - }
148 -
149 - /**
150 133 * Returns file handle to fetch data from.
151 134 *
152 135 * @since 1.4.2
153 136 *
154 137 * @access protected
138 + * @staticvar boolean $allow_url_fopen Determines whether or not allow_url_fopen option is enabled.
155 139 * @param string $filename Optional file name to get handle. If omitted, $_filename is used.
156 - * @return resource|false File handle resource on success, otherwise FALSE.
140 + * @return resource File handle resource on success, otherwise FALSE.
157 141 */
158 142 protected function _get_file_handle( $filename = false ) {
159 - if ( $this->_tmpfile && is_readable( $this->_tmpfile ) ) {
143 + static $allow_url_fopen = null;
144 +
145 + if ( ! is_wp_error( $this->_tmpfile ) && $this->_tmpfile && is_readable( $this->_tmpfile ) ) {
160 146 return parent::_get_file_handle( $this->_tmpfile );
161 147 }
162 148
163 - $tmpfile = Visualizer_Remote_Fetch::download( $this->_filename );
164 - if ( is_wp_error( $tmpfile ) ) {
165 - $this->_error = esc_html__( 'Could not download the file. Please check the URL and try again.', 'visualizer' );
166 - return false;
149 + if ( is_null( $allow_url_fopen ) ) {
150 + $allow_url_fopen = filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN );
167 151 }
168 152
169 - $this->_tmpfile = $tmpfile;
170 - return parent::_get_file_handle( $this->_tmpfile );
153 + $scheme = parse_url( $this->_filename, PHP_URL_SCHEME );
154 + if ( $allow_url_fopen && in_array( $scheme, stream_get_wrappers(), true ) ) {
155 + return parent::_get_file_handle( $filename );
156 + }
157 +
158 + require_once ABSPATH . 'wp-admin/includes/file.php';
159 +
160 + $this->_tmpfile = download_url( $this->_filename );
161 +
162 + return ! is_wp_error( $this->_tmpfile ) ? parent::_get_file_handle( $this->_tmpfile ) : false;
171 163 }
164 +
172 165 }