PluginProbe
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on / 1.3
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on v1.3
2.0 1.7.1 1.2.9 1.3 1.4 1.4.1 1.4.2 1.4.3 1.5 1.6 1.7 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8
← All changes | importExtensions/ImportHelpers.php +43 -40 trunk1.3 View file →
@@ -7,9 +7,9 @@
7 7
8 8 namespace Smackcoders\SMUSERS;
9 9
10 10 if ( ! defined( 'ABSPATH' ) )
11 - exit; // Exit if accessed directly
11 +exit; // Exit if accessed directly
12 12
13 13 class ImportHelpers {
14 14 private static $helpers_instance = null;
15 15
@@ -132,8 +132,9 @@
132 132 foreach($map as $key => $value){
133 133 $csv_value= trim($map[$key]);
134 134
135 135 if(!empty($csv_value)){
136 + //if(preg_match_all('/{(\w+)}/', $csv_value, $matches)){
136 137 $pattern = "/({([a-z A-Z 0-9 | , _ -]+)(.*?)(}))/";
137 138 if(preg_match_all($pattern, $csv_value, $matches, PREG_PATTERN_ORDER)){
138 139 $csv_element = $csv_value;
139 140
@@ -147,20 +148,21 @@
147 148 }
148 149 }
149 150
150 151 $math = 'MATH(';
151 - if (strpos($csv_element, $math) !== false) {
152 - $equation = str_replace('MATH(', '', $csv_element);
153 - $equation = str_replace(')', '', $equation);
154 - $csv_element = $this->evalmath($equation);
155 - }
152 + if (strpos($csv_element, $math) !== false) {
153 + $equation = str_replace('MATH(', '', $csv_element);
154 + $equation = str_replace(')', '', $equation);
155 + $csv_element = $this->evalmath($equation);
156 + }
156 157
157 - $wp_element= trim($key);
158 - if(!empty($csv_element) && !empty($wp_element)){
159 - $post_values[$wp_element] = $csv_element;
160 - }
158 + $wp_element= trim($key);
159 + if(!empty($csv_element) && !empty($wp_element)){
160 + $post_values[$wp_element] = $csv_element;
161 + }
162 + //}
161 163 }
162 -
164 +
163 165 elseif(!in_array($csv_value , $header_array)){
164 166 $wp_element= trim($key);
165 167 $post_values[$wp_element] = $csv_value;
166 168 }
@@ -183,14 +185,15 @@
183 185 public function evalmath($equation) {
184 186
185 187 $result = 0;
186 188
187 - //input
189 + // sanitize input
188 190 $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation);
189 191
190 192 // convert percentages to decimal
191 193 $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation);
192 194 $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation);
195 + //$equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation);
193 196
194 197 if ( $equation != "" )
195 198 {
196 199 $result = @eval("return " . $equation . ";" );
@@ -213,17 +216,17 @@
213 216 global $wpdb;
214 217 $importlog_table_name = $wpdb->prefix ."import_log_detail";
215 218
216 219 $wpdb->insert($importlog_table_name, array(
217 - 'hash_key' => $hash_key,
218 - 'message' => "{$message}",
219 - 'status' => "{$status}",
220 - 'verify' => "{$verify}",
221 - 'post_id' => $post_id,
220 + 'hash_key' => $hash_key,
221 + 'message' => "{$message}",
222 + 'status' => "{$status}",
223 + 'verify' => "{$verify}",
224 + 'post_id' => $post_id,
222 225
223 - ),
224 - array('%s', '%s', '%s', '%s', '%d')
225 - );
226 + ),
227 + array('%s', '%s', '%s', '%s', '%d')
228 + );
226 229 }
227 230
228 231 public function update_error_log($message , $hash_key , $post_id){
229 232 global $wpdb;
@@ -229,42 +232,42 @@
229 232 global $wpdb;
230 233 $importlog_table_name = $wpdb->prefix ."import_log_detail";
231 234
232 235 $wpdb->insert($importlog_table_name, array(
233 - 'hash_key' => $hash_key,
234 - 'message' => "{$message}",
235 - 'post_id' => $post_id
236 + 'hash_key' => $hash_key,
237 + 'message' => "{$message}",
238 + 'post_id' => $post_id
236 239
237 - ),
238 - array('%s', '%s', '%d')
239 - );
240 + ),
241 + array('%s', '%s', '%d')
242 + );
240 243 }
241 244
242 245 public function update_category_log($category , $post_id){
243 246 global $wpdb;
244 247 $wpdb->update($wpdb->prefix.'import_log_detail', array(
245 - 'categories' => "{$category}"
246 - ),
247 - array('post_id' => $post_id)
248 - );
248 + 'categories' => "{$category}"
249 + ),
250 + array('post_id' => $post_id)
251 + );
249 252 }
250 253
251 254 public function update_tag_log($tag , $post_id){
252 255 global $wpdb;
253 256 $wpdb->update($wpdb->prefix.'import_log_detail', array(
254 - 'tags' => "{$tag}"
255 - ),
256 - array('post_id' => $post_id)
257 - );
257 + 'tags' => "{$tag}"
258 + ),
259 + array('post_id' => $post_id)
260 + );
258 261 }
259 262 public function update_status_log($status , $verify , $post_id){
260 263 global $wpdb;
261 264 $wpdb->update($wpdb->prefix.'import_log_detail', array(
262 - 'status' => "{$status}",
263 - 'verify' => "{$verify}"
264 - ),
265 - array('post_id' => $post_id)
266 - );
265 + 'status' => "{$status}",
266 + 'verify' => "{$verify}"
267 + ),
268 + array('post_id' => $post_id)
269 + );
267 270 }
268 271
269 272 public function formatSizeUnits($bytes)
270 273 {
@@ -299,9 +302,9 @@
299 302 public function update_count($hash_key){
300 303 $response = [];
301 304 global $wpdb;
302 305 $log_table_name = $wpdb->prefix ."import_detail_log";
303 - $get_data = $wpdb->get_results($wpdb->prepare("SELECT skipped , created , updated FROM $log_table_name WHERE hash_key = %s", $hash_key));
306 + $get_data = $wpdb->get_results("SELECT skipped , created , updated FROM $log_table_name WHERE hash_key = '$hash_key' ");
304 307 $skipped = $get_data[0]->skipped;
305 308 $response['skipped'] = $skipped + 1;
306 309 $created = $get_data[0]->created;
307 310 $response['created'] = $created + 1;