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 +40 -43 1.2.3trunk 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,9 +132,8 @@
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)){
137 136 $pattern = "/({([a-z A-Z 0-9 | , _ -]+)(.*?)(}))/";
138 137 if(preg_match_all($pattern, $csv_value, $matches, PREG_PATTERN_ORDER)){
139 138 $csv_element = $csv_value;
140 139
@@ -148,21 +147,20 @@
148 147 }
149 148 }
150 149
151 150 $math = 'MATH(';
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 - }
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 + }
157 156
158 - $wp_element= trim($key);
159 - if(!empty($csv_element) && !empty($wp_element)){
160 - $post_values[$wp_element] = $csv_element;
161 - }
162 - //}
157 + $wp_element= trim($key);
158 + if(!empty($csv_element) && !empty($wp_element)){
159 + $post_values[$wp_element] = $csv_element;
160 + }
163 161 }
164 -
162 +
165 163 elseif(!in_array($csv_value , $header_array)){
166 164 $wp_element= trim($key);
167 165 $post_values[$wp_element] = $csv_value;
168 166 }
@@ -185,15 +183,14 @@
185 183 public function evalmath($equation) {
186 184
187 185 $result = 0;
188 186
189 - // sanitize input
187 + //input
190 188 $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation);
191 189
192 190 // convert percentages to decimal
193 191 $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation);
194 192 $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation);
195 - //$equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation);
196 193
197 194 if ( $equation != "" )
198 195 {
199 196 $result = @eval("return " . $equation . ";" );
@@ -216,17 +213,17 @@
216 213 global $wpdb;
217 214 $importlog_table_name = $wpdb->prefix ."import_log_detail";
218 215
219 216 $wpdb->insert($importlog_table_name, array(
220 - 'hash_key' => $hash_key,
221 - 'message' => "{$message}",
222 - 'status' => "{$status}",
223 - 'verify' => "{$verify}",
224 - 'post_id' => $post_id,
217 + 'hash_key' => $hash_key,
218 + 'message' => "{$message}",
219 + 'status' => "{$status}",
220 + 'verify' => "{$verify}",
221 + 'post_id' => $post_id,
225 222
226 - ),
227 - array('%s', '%s', '%s', '%s', '%d')
228 - );
223 + ),
224 + array('%s', '%s', '%s', '%s', '%d')
225 + );
229 226 }
230 227
231 228 public function update_error_log($message , $hash_key , $post_id){
232 229 global $wpdb;
@@ -232,42 +229,42 @@
232 229 global $wpdb;
233 230 $importlog_table_name = $wpdb->prefix ."import_log_detail";
234 231
235 232 $wpdb->insert($importlog_table_name, array(
236 - 'hash_key' => $hash_key,
237 - 'message' => "{$message}",
238 - 'post_id' => $post_id
233 + 'hash_key' => $hash_key,
234 + 'message' => "{$message}",
235 + 'post_id' => $post_id
239 236
240 - ),
241 - array('%s', '%s', '%d')
242 - );
237 + ),
238 + array('%s', '%s', '%d')
239 + );
243 240 }
244 241
245 242 public function update_category_log($category , $post_id){
246 243 global $wpdb;
247 244 $wpdb->update($wpdb->prefix.'import_log_detail', array(
248 - 'categories' => "{$category}"
249 - ),
250 - array('post_id' => $post_id)
251 - );
245 + 'categories' => "{$category}"
246 + ),
247 + array('post_id' => $post_id)
248 + );
252 249 }
253 250
254 251 public function update_tag_log($tag , $post_id){
255 252 global $wpdb;
256 253 $wpdb->update($wpdb->prefix.'import_log_detail', array(
257 - 'tags' => "{$tag}"
258 - ),
259 - array('post_id' => $post_id)
260 - );
254 + 'tags' => "{$tag}"
255 + ),
256 + array('post_id' => $post_id)
257 + );
261 258 }
262 259 public function update_status_log($status , $verify , $post_id){
263 260 global $wpdb;
264 261 $wpdb->update($wpdb->prefix.'import_log_detail', array(
265 - 'status' => "{$status}",
266 - 'verify' => "{$verify}"
267 - ),
268 - array('post_id' => $post_id)
269 - );
262 + 'status' => "{$status}",
263 + 'verify' => "{$verify}"
264 + ),
265 + array('post_id' => $post_id)
266 + );
270 267 }
271 268
272 269 public function formatSizeUnits($bytes)
273 270 {
@@ -302,9 +299,9 @@
302 299 public function update_count($hash_key){
303 300 $response = [];
304 301 global $wpdb;
305 302 $log_table_name = $wpdb->prefix ."import_detail_log";
306 - $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));
307 304 $skipped = $get_data[0]->skipped;
308 305 $response['skipped'] = $skipped + 1;
309 306 $created = $get_data[0]->created;
310 307 $response['created'] = $created + 1;