PluginProbe
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on / trunk
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on vtrunk
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 +45 -49 1.2trunk View file →
@@ -1,16 +1,15 @@
1 1 <?php
2 -/******************************************************************************************
3 - * Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
4 - * Unauthorized copying of this file, via any medium is strictly prohibited
5 - * Proprietary and confidential
6 - * You can contact Smackcoders at email address info@smackcoders.com.
7 - *******************************************************************************************/
2 +/**
3 + * Import Users plugin file.
4 + *
5 + * Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
6 + */
8 7
9 8 namespace Smackcoders\SMUSERS;
10 9
11 10 if ( ! defined( 'ABSPATH' ) )
12 -exit; // Exit if accessed directly
11 + exit; // Exit if accessed directly
13 12
14 13 class ImportHelpers {
15 14 private static $helpers_instance = null;
16 15
@@ -133,9 +132,8 @@
133 132 foreach($map as $key => $value){
134 133 $csv_value= trim($map[$key]);
135 134
136 135 if(!empty($csv_value)){
137 - //if(preg_match_all('/{(\w+)}/', $csv_value, $matches)){
138 136 $pattern = "/({([a-z A-Z 0-9 | , _ -]+)(.*?)(}))/";
139 137 if(preg_match_all($pattern, $csv_value, $matches, PREG_PATTERN_ORDER)){
140 138 $csv_element = $csv_value;
141 139
@@ -149,21 +147,20 @@
149 147 }
150 148 }
151 149
152 150 $math = 'MATH(';
153 - if (strpos($csv_element, $math) !== false) {
154 - $equation = str_replace('MATH(', '', $csv_element);
155 - $equation = str_replace(')', '', $equation);
156 - $csv_element = $this->evalmath($equation);
157 - }
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 + }
158 156
159 - $wp_element= trim($key);
160 - if(!empty($csv_element) && !empty($wp_element)){
161 - $post_values[$wp_element] = $csv_element;
162 - }
163 - //}
157 + $wp_element= trim($key);
158 + if(!empty($csv_element) && !empty($wp_element)){
159 + $post_values[$wp_element] = $csv_element;
160 + }
164 161 }
165 -
162 +
166 163 elseif(!in_array($csv_value , $header_array)){
167 164 $wp_element= trim($key);
168 165 $post_values[$wp_element] = $csv_value;
169 166 }
@@ -186,15 +183,14 @@
186 183 public function evalmath($equation) {
187 184
188 185 $result = 0;
189 186
190 - // sanitize input
187 + //input
191 188 $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation);
192 189
193 190 // convert percentages to decimal
194 191 $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation);
195 192 $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation);
196 - //$equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation);
197 193
198 194 if ( $equation != "" )
199 195 {
200 196 $result = @eval("return " . $equation . ";" );
@@ -217,17 +213,17 @@
217 213 global $wpdb;
218 214 $importlog_table_name = $wpdb->prefix ."import_log_detail";
219 215
220 216 $wpdb->insert($importlog_table_name, array(
221 - 'hash_key' => $hash_key,
222 - 'message' => "{$message}",
223 - 'status' => "{$status}",
224 - 'verify' => "{$verify}",
225 - 'post_id' => $post_id,
217 + 'hash_key' => $hash_key,
218 + 'message' => "{$message}",
219 + 'status' => "{$status}",
220 + 'verify' => "{$verify}",
221 + 'post_id' => $post_id,
226 222
227 - ),
228 - array('%s', '%s', '%s', '%s', '%d')
229 - );
223 + ),
224 + array('%s', '%s', '%s', '%s', '%d')
225 + );
230 226 }
231 227
232 228 public function update_error_log($message , $hash_key , $post_id){
233 229 global $wpdb;
@@ -233,42 +229,42 @@
233 229 global $wpdb;
234 230 $importlog_table_name = $wpdb->prefix ."import_log_detail";
235 231
236 232 $wpdb->insert($importlog_table_name, array(
237 - 'hash_key' => $hash_key,
238 - 'message' => "{$message}",
239 - 'post_id' => $post_id
233 + 'hash_key' => $hash_key,
234 + 'message' => "{$message}",
235 + 'post_id' => $post_id
240 236
241 - ),
242 - array('%s', '%s', '%d')
243 - );
237 + ),
238 + array('%s', '%s', '%d')
239 + );
244 240 }
245 241
246 242 public function update_category_log($category , $post_id){
247 243 global $wpdb;
248 244 $wpdb->update($wpdb->prefix.'import_log_detail', array(
249 - 'categories' => "{$category}"
250 - ),
251 - array('post_id' => $post_id)
252 - );
245 + 'categories' => "{$category}"
246 + ),
247 + array('post_id' => $post_id)
248 + );
253 249 }
254 250
255 251 public function update_tag_log($tag , $post_id){
256 252 global $wpdb;
257 253 $wpdb->update($wpdb->prefix.'import_log_detail', array(
258 - 'tags' => "{$tag}"
259 - ),
260 - array('post_id' => $post_id)
261 - );
254 + 'tags' => "{$tag}"
255 + ),
256 + array('post_id' => $post_id)
257 + );
262 258 }
263 259 public function update_status_log($status , $verify , $post_id){
264 260 global $wpdb;
265 261 $wpdb->update($wpdb->prefix.'import_log_detail', array(
266 - 'status' => "{$status}",
267 - 'verify' => "{$verify}"
268 - ),
269 - array('post_id' => $post_id)
270 - );
262 + 'status' => "{$status}",
263 + 'verify' => "{$verify}"
264 + ),
265 + array('post_id' => $post_id)
266 + );
271 267 }
272 268
273 269 public function formatSizeUnits($bytes)
274 270 {
@@ -303,9 +299,9 @@
303 299 public function update_count($hash_key){
304 300 $response = [];
305 301 global $wpdb;
306 302 $log_table_name = $wpdb->prefix ."import_detail_log";
307 - $get_data = $wpdb->get_results("SELECT skipped , created , updated FROM $log_table_name WHERE hash_key = '$hash_key' ");
303 + $get_data = $wpdb->get_results($wpdb->prepare("SELECT skipped , created , updated FROM $log_table_name WHERE hash_key = %s", $hash_key));
308 304 $skipped = $get_data[0]->skipped;
309 305 $response['skipped'] = $skipped + 1;
310 306 $created = $get_data[0]->created;
311 307 $response['created'] = $created + 1;