| @@ -1,2034 +1,1835 @@ | ||
| 1 | -<?php | |
| 2 | -// Utility.php | |
| 3 | - | |
| 4 | -function usces_upgrade_07(){ | |
| 5 | - $upgrade = (int)get_option('usces_upgrade'); | |
| 6 | - if( $upgrade & USCES_UP07 ) return false; | |
| 7 | - | |
| 8 | - global $wpdb; | |
| 9 | - $rets = array(); | |
| 10 | - | |
| 11 | - $tableName = $wpdb->prefix . "postmeta"; | |
| 12 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'iopt_', '_iopt_') WHERE meta_key LIKE 'iopt_%'"; | |
| 13 | - if( $wpdb->query( $mquery ) ) | |
| 14 | - $rets[] = 1; | |
| 15 | - | |
| 16 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'isku_', '_isku_') WHERE meta_key LIKE 'isku_%'"; | |
| 17 | - if( $wpdb->query( $mquery ) ) | |
| 18 | - $rets[] = 1; | |
| 19 | - | |
| 20 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemCode', '_itemCode') WHERE meta_key LIKE 'itemCode'"; | |
| 21 | - if( $wpdb->query( $mquery ) ) | |
| 22 | - $rets[] = 1; | |
| 23 | - | |
| 24 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemName', '_itemName') WHERE meta_key LIKE 'itemName'"; | |
| 25 | - if( $wpdb->query( $mquery ) ) | |
| 26 | - $rets[] = 1; | |
| 27 | - | |
| 28 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemRestriction', '_itemRestriction') WHERE meta_key LIKE 'itemRestriction'"; | |
| 29 | - if( $wpdb->query( $mquery ) ) | |
| 30 | - $rets[] = 1; | |
| 31 | - | |
| 32 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemPointrate', '_itemPointrate') WHERE meta_key LIKE 'itemPointrate'"; | |
| 33 | - if( $wpdb->query( $mquery ) ) | |
| 34 | - $rets[] = 1; | |
| 35 | - | |
| 36 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpNum1', '_itemGpNum1') WHERE meta_key LIKE 'itemGpNum1'"; | |
| 37 | - if( $wpdb->query( $mquery ) ) | |
| 38 | - $rets[] = 1; | |
| 39 | - | |
| 40 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpDis1', '_itemGpDis1') WHERE meta_key LIKE 'itemGpDis1'"; | |
| 41 | - if( $wpdb->query( $mquery ) ) | |
| 42 | - $rets[] = 1; | |
| 43 | - | |
| 44 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpNum2', '_itemGpNum2') WHERE meta_key LIKE 'itemGpNum2'"; | |
| 45 | - if( $wpdb->query( $mquery ) ) | |
| 46 | - $rets[] = 1; | |
| 47 | - | |
| 48 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpDis2', '_itemGpDis2') WHERE meta_key LIKE 'itemGpDis2'"; | |
| 49 | - if( $wpdb->query( $mquery ) ) | |
| 50 | - $rets[] = 1; | |
| 51 | - | |
| 52 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpDis3', '_itemGpDis3') WHERE meta_key LIKE 'itemGpDis3'"; | |
| 53 | - if( $wpdb->query( $mquery ) ) | |
| 54 | - $rets[] = 1; | |
| 55 | - | |
| 56 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpNum3', '_itemGpNum3') WHERE meta_key LIKE 'itemGpNum3'"; | |
| 57 | - if( $wpdb->query( $mquery ) ) | |
| 58 | - $rets[] = 1; | |
| 59 | - | |
| 60 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemShipping', '_itemShipping') WHERE meta_key LIKE 'itemShipping'"; | |
| 61 | - if( $wpdb->query( $mquery ) ) | |
| 62 | - $rets[] = 1; | |
| 63 | - | |
| 64 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemDeliveryMethod', '_itemDeliveryMethod') WHERE meta_key LIKE 'itemDeliveryMethod'"; | |
| 65 | - if( $wpdb->query( $mquery ) ) | |
| 66 | - $rets[] = 1; | |
| 67 | - | |
| 68 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemShippingCharge', '_itemShippingCharge') WHERE meta_key LIKE 'itemShippingCharge'"; | |
| 69 | - if( $wpdb->query( $mquery ) ) | |
| 70 | - $rets[] = 1; | |
| 71 | - | |
| 72 | - $mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemIndividualSCharge', '_itemIndividualSCharge') WHERE meta_key LIKE 'itemIndividualSCharge'"; | |
| 73 | - if( $wpdb->query( $mquery ) ) | |
| 74 | - $rets[] = 1; | |
| 75 | - | |
| 76 | - usces_log('USCES_UP07 : '.print_r($rets,true), 'database_error.log'); | |
| 77 | - $upgrade += USCES_UP07; | |
| 78 | - update_option('usces_upgrade', $upgrade); | |
| 79 | - return $rets; | |
| 80 | -} | |
| 81 | - | |
| 82 | -function usces_upgrade_11(){ | |
| 83 | - $options = get_option('usces'); | |
| 84 | - $upgrade = (int)get_option('usces_upgrade'); | |
| 85 | - | |
| 86 | - if( $upgrade & USCES_UP11 ) return false; | |
| 87 | - | |
| 88 | - global $wpdb; | |
| 89 | - $rets = array(); | |
| 90 | - | |
| 91 | - /* ITEM SKU DATA */ | |
| 92 | - $sort = (int)$options['system']['orderby_itemsku']; | |
| 93 | - if( $sort ){ | |
| 94 | - $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_isku_' AND meta_key LIKE '_isku_%' ORDER BY post_id, meta_key"; | |
| 95 | - }else{ | |
| 96 | - $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_isku_' AND meta_key LIKE '_isku_%' ORDER BY post_id, meta_id"; | |
| 97 | - } | |
| 98 | - $res = $wpdb->get_results($query, ARRAY_A); | |
| 99 | - | |
| 100 | - $conclusion = true; | |
| 101 | - $pre_post_id = 0; | |
| 102 | - $sort_id = 0; | |
| 103 | - $check_code = array(); | |
| 104 | - $dep_num = array(); | |
| 105 | - foreach( (array)$res as $metarow ){ | |
| 106 | - $meta_value = unserialize($metarow['meta_value']); | |
| 107 | - $newvalue = array(); | |
| 108 | - $newvalue['code'] = substr($metarow['meta_key'], 6); | |
| 109 | - if( $pre_post_id == $metarow['post_id'] ){ | |
| 110 | - if( in_array( $newvalue['code'], $check_code ) ){ | |
| 111 | - $newvalue['code'] .= 'dupricate_' . (int)$dep_num[$newvalue['code']]; | |
| 112 | - $dep_num[$newvalue['code']]++; | |
| 113 | - } | |
| 114 | - }else{ | |
| 115 | - $check_code = array(); | |
| 116 | - $dep_num = array(); | |
| 117 | - $sort_id = 0; | |
| 118 | - } | |
| 119 | - foreach( (array)$meta_value as $k => $v ){ | |
| 120 | - switch ( $k ){ | |
| 121 | - case 'disp': | |
| 122 | - $newvalue['name'] = $v; | |
| 123 | - break; | |
| 124 | - case 'cprice': | |
| 125 | - $newvalue['cprice'] = $v; | |
| 126 | - break; | |
| 127 | - case 'price': | |
| 128 | - $newvalue['price'] = $v; | |
| 129 | - break; | |
| 130 | - case 'unit': | |
| 131 | - $newvalue['unit'] = $v; | |
| 132 | - break; | |
| 133 | - case 'zaikonum': | |
| 134 | - $newvalue['stocknum'] = $v; | |
| 135 | - break; | |
| 136 | - case 'zaiko': | |
| 137 | - $newvalue['stock'] = $v; | |
| 138 | - break; | |
| 139 | - case 'gptekiyo': | |
| 140 | - $newvalue['gp'] = $v; | |
| 141 | - break; | |
| 142 | - case 'charging_type': | |
| 143 | - break; | |
| 144 | - default: | |
| 145 | - $newvalue[$k] = $v; | |
| 146 | - } | |
| 147 | - } | |
| 148 | - $newvalue['sort'] = $sort_id; | |
| 149 | - | |
| 150 | - $id = usces_add_sku($metarow['post_id'], $newvalue, false); | |
| 151 | - $pre_post_id = $metarow['post_id']; | |
| 152 | - $check_code[] = $newvalue['code']; | |
| 153 | - $sort_id++; | |
| 154 | - | |
| 155 | - $res_key = $metarow['post_id'] . '_' . $newvalue['code']; | |
| 156 | - if( $id ) { | |
| 157 | - delete_post_meta($metarow['post_id'], $metarow['meta_key']); | |
| 158 | - $rets['sku'][$res_key] = 1; | |
| 159 | - }else{ | |
| 160 | - $rets['sku'][$res_key] = 0; | |
| 161 | - usces_log('meta_id ' . $metarow['meta_id'] . ' : ' . __('This SKU-data has not been rebuilt.', 'usces'), 'database_error.log'); | |
| 162 | - } | |
| 163 | - } | |
| 164 | - | |
| 165 | - /* ITEM OPTION DATA */ | |
| 166 | - $sort = (int)$options['system']['orderby_itemopt']; | |
| 167 | - if( $sort ){ | |
| 168 | - $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_iopt_' AND meta_key LIKE '_iopt_%' ORDER BY post_id, meta_key"; | |
| 169 | - }else{ | |
| 170 | - $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_iopt_' AND meta_key LIKE '_iopt_%' ORDER BY post_id, meta_id"; | |
| 171 | - } | |
| 172 | - $res = $wpdb->get_results($query, ARRAY_A); | |
| 173 | - | |
| 174 | - $conclusion = true; | |
| 175 | - $pre_post_id = 0; | |
| 176 | - $sort_id = 0; | |
| 177 | - $check_code = array(); | |
| 178 | - $dep_num = array(); | |
| 179 | - foreach( (array)$res as $metarow ){ | |
| 180 | - $meta_value = unserialize($metarow['meta_value']); | |
| 181 | - $newvalue = array(); | |
| 182 | - $newvalue['name'] = substr($metarow['meta_key'], 6); | |
| 183 | - if( $pre_post_id == $metarow['post_id'] ){ | |
| 184 | - if( in_array( $newvalue['name'], $check_code ) ){ | |
| 185 | - $newvalue['name'] .= 'dupricate_' . (int)$dep_num[$newvalue['name']]; | |
| 186 | - $dep_num[$newvalue['name']]++; | |
| 187 | - } | |
| 188 | - }else{ | |
| 189 | - $check_code = array(); | |
| 190 | - $dep_num = array(); | |
| 191 | - $sort_id = 0; | |
| 192 | - } | |
| 193 | - foreach( (array)$meta_value as $k => $v ){ | |
| 194 | - switch ( $k ){ | |
| 195 | - case 'means': | |
| 196 | - $newvalue['means'] = $v; | |
| 197 | - break; | |
| 198 | - case 'essential': | |
| 199 | - $newvalue['essential'] = $v; | |
| 200 | - break; | |
| 201 | - case 'value': | |
| 202 | - if( is_array($v) ){ | |
| 203 | - $nov = ''; | |
| 204 | - foreach((array)$v as $vs){ | |
| 205 | - if( !WCUtils::is_blank($vs) ) | |
| 206 | - //$nov .= str_replace('\\', '¥', trim( $vs )) . "\n"; | |
| 207 | - $nov .= $vs . "\n"; | |
| 208 | - } | |
| 209 | - $newvalue['value'] = trim($nov); | |
| 210 | - }else{ | |
| 211 | - $newvalue['value'] = trim($v); | |
| 212 | - } | |
| 213 | - break; | |
| 214 | - default: | |
| 215 | - $newvalue[$k] = trim($v); | |
| 216 | - } | |
| 217 | - } | |
| 218 | - $newvalue['sort'] = $sort_id; | |
| 219 | - | |
| 220 | - $id = usces_add_opt($metarow['post_id'], $newvalue, false); | |
| 221 | - $pre_post_id = $metarow['post_id']; | |
| 222 | - $check_code[] = $newvalue['name']; | |
| 223 | - $sort_id++; | |
| 224 | - | |
| 225 | - $res_key = $metarow['post_id'] . '_' . $newvalue['name']; | |
| 226 | - if( $id ) { | |
| 227 | - delete_post_meta($metarow['post_id'], $metarow['meta_key']); | |
| 228 | - $rets['opt'][$res_key] = 1; | |
| 229 | - }else{ | |
| 230 | - $rets['opt'][$res_key] = 0; | |
| 231 | - usces_log('meta_id ' . $metarow['meta_id'] . ' : ' . __('This Item-Option-data has not been rebuilt.', 'usces'), 'database_error.log'); | |
| 232 | - } | |
| 233 | - } | |
| 234 | - | |
| 235 | - /* PAYMENT METHOD DATA */ | |
| 236 | - $payment = get_option('usces_payment_method'); | |
| 237 | -//usces_log('payment : ' . print_r($payment,true), 'database_error.log'); | |
| 238 | - if( empty($payment) ) { | |
| 239 | - | |
| 240 | - $options = get_option('usces'); | |
| 241 | - $old_payment = isset($options['payment_method']) ? $options['payment_method'] : ''; | |
| 242 | - usces_log('old_payment : ' . print_r($old_payment,true), 'database_error.log'); | |
| 243 | - if( !empty($old_payment) && is_array($old_payment) ) { | |
| 244 | - foreach( $old_payment as $key => $value ){ | |
| 245 | - $res_key = $key . '_' . $value['name']; | |
| 246 | - $id = usces_add_system_option( 'usces_payment_method', $value ); | |
| 247 | - if( $id ) { | |
| 248 | - $rets['payment'][$res_key] = 1; | |
| 249 | - }else{ | |
| 250 | - $rets['payment'][$res_key] = 0; | |
| 251 | - usces_log('payment_method ' . $value['name'] . ' : ' . __('This Payment-Method-data has not been rebuilt.', 'usces'), 'database_error.log'); | |
| 252 | - } | |
| 253 | - } | |
| 254 | - } | |
| 255 | - } | |
| 256 | - | |
| 257 | - usces_log('USCES_UP11 : ' . print_r($rets,true), 'database_error.log'); | |
| 258 | - | |
| 259 | -// $upgrade += USCES_UP11; | |
| 260 | -// update_option('usces_upgrade', $upgrade); | |
| 261 | - return $rets; | |
| 262 | -} | |
| 263 | - | |
| 264 | -function usces_log($log, $file){ | |
| 265 | - global $usces; | |
| 266 | - | |
| 267 | - $log = date('[Y-m-d H:i:s]', current_time('timestamp')) . "\t" . $log . "\n"; | |
| 268 | - $file_path = USCES_PLUGIN_DIR . '/logs/' . $file; | |
| 269 | - if( is_dir($file_path) ) | |
| 270 | - return; | |
| 271 | - | |
| 272 | - $fp = fopen($file_path, 'a'); | |
| 273 | - if( false !== $fp ){ | |
| 274 | - fwrite($fp, $log); | |
| 275 | - fclose($fp); | |
| 276 | - } | |
| 277 | -} | |
| 278 | - | |
| 279 | - | |
| 280 | -function usces_filter_delivery_secure_check( $mes ){ | |
| 281 | - global $usces; | |
| 282 | - $usces_secure_link = get_option('usces_secure_link'); | |
| 283 | - $paymod_id = ''; | |
| 284 | - $settlement = ''; | |
| 285 | - $payments = usces_get_system_option( 'usces_payment_method', 'sort' ); | |
| 286 | - | |
| 287 | - foreach ( (array)$payments as $id => $value ) { | |
| 288 | - if( isset($_POST['offer']['payment_name']) && $value['name'] == $_POST['offer']['payment_name']){ | |
| 289 | - $settlement = $value['settlement']; | |
| 290 | - break; | |
| 291 | - } | |
| 292 | - } | |
| 293 | - switch( $settlement ){ | |
| 294 | - case 'acting_zeus_card': | |
| 295 | - $cnum1 = trim($_POST["cnum1"]); | |
| 296 | - $securecode = (isset($_POST["securecode"])) ? trim($_POST["securecode"]) : ''; | |
| 297 | - if ( !is_numeric($cnum1) ) | |
| 298 | - $mes .= __('カード番号が不正です', 'usces') . "<br />"; | |
| 299 | - | |
| 300 | - if ( isset($_POST["securecode"]) && !is_numeric($securecode) ) | |
| 301 | - $mes .= __('セキュリティコードが不正です', 'usces') . "<br />"; | |
| 302 | - | |
| 303 | - if ( WCUtils::is_blank($_POST["expyy"]) ) | |
| 304 | - $mes .= __('カードの有効年を選択してください', 'usces') . "<br />"; | |
| 305 | - | |
| 306 | - if ( WCUtils::is_blank($_POST["expmm"]) ) | |
| 307 | - $mes .= __('カードの有効月を選択してください', 'usces') . "<br />"; | |
| 308 | - | |
| 309 | - if ( WCUtils::is_blank($_POST["username"]) ) | |
| 310 | - $mes .= __('カード名義を入力してください', 'usces') . "<br />"; | |
| 311 | - | |
| 312 | - if ( isset($_POST["howpay"]) && 0 == $_POST["howpay"] && WCUtils::is_blank($_POST["cbrand"]) ) | |
| 313 | - $mes .= __('カードブランドを選択してください', 'usces') . "<br />"; | |
| 314 | - | |
| 315 | - if ( 'zeus' != $_POST['acting'] ) | |
| 316 | - $mes .= __('カード決済データが不正です!', 'usces'); | |
| 317 | - | |
| 318 | - break; | |
| 319 | - } | |
| 320 | - | |
| 321 | - return $mes; | |
| 322 | -} | |
| 323 | - | |
| 324 | -function usces_get_conv_name($code){ | |
| 325 | - switch($code){ | |
| 326 | - case 'D001': | |
| 327 | - case '010'://20101018ysk | |
| 328 | - $name = 'セブンイレブン'; | |
| 329 | - break; | |
| 330 | - case 'D002': | |
| 331 | - case '020'://20101018ysk | |
| 332 | - $name = 'ローソン'; | |
| 333 | - break; | |
| 334 | - case 'D015': | |
| 335 | - case '760'://20101018ysk | |
| 336 | - $name = 'セイコーマート'; | |
| 337 | - break; | |
| 338 | - case 'D405': | |
| 339 | - $name = 'ペイジー'; | |
| 340 | - break; | |
| 341 | - case 'D003': | |
| 342 | - $name = 'サンクス'; | |
| 343 | - break; | |
| 344 | - case 'D004': | |
| 345 | - $name = 'サークルK'; | |
| 346 | - break; | |
| 347 | - case 'D005': | |
| 348 | - case '080'://20101018ysk | |
| 349 | - $name = 'ミニストップ'; | |
| 350 | - break; | |
| 351 | - case 'D010': | |
| 352 | - $name = 'デイリーヤマザキ'; | |
| 353 | - break; | |
| 354 | - case 'D011': | |
| 355 | - $name = 'ヤマザキデイリーストア'; | |
| 356 | - break; | |
| 357 | - case 'D030': | |
| 358 | - case '030'://20101018ysk | |
| 359 | - $name = 'ファミリーマート'; | |
| 360 | - break; | |
| 361 | - case 'D401': | |
| 362 | - $name = 'CyberEdy'; | |
| 363 | - break; | |
| 364 | - case 'D404': | |
| 365 | - $name = '楽天銀行'; | |
| 366 | - break; | |
| 367 | - case 'D406': | |
| 368 | - $name = 'ジャパネット銀行'; | |
| 369 | - break; | |
| 370 | - case 'D451': | |
| 371 | - $name = 'ウェブマネー'; | |
| 372 | - break; | |
| 373 | - case 'D452': | |
| 374 | - $name = 'ビットキャッシュ'; | |
| 375 | - break; | |
| 376 | - case 'P901': | |
| 377 | - $name = 'コンビニ払込票'; | |
| 378 | - break; | |
| 379 | - case 'P902': | |
| 380 | - $name = 'コンビニ払込票(郵便振替対応)'; | |
| 381 | - break; | |
| 382 | -//20101018ysk start | |
| 383 | - case '050': | |
| 384 | - $name = 'デイリーヤマザキ・ヤマザキデイリーストア・タイムリー'; | |
| 385 | - break; | |
| 386 | - case '060': | |
| 387 | - $name = 'サークルK・サンクス'; | |
| 388 | - break; | |
| 389 | - case '110': | |
| 390 | - $name = 'am/pm'; | |
| 391 | - break; | |
| 392 | -//20101018ysk end | |
| 393 | - default: | |
| 394 | - $name = ''; | |
| 395 | - } | |
| 396 | - return $name; | |
| 397 | -} | |
| 398 | - | |
| 399 | -function usces_get_remise_conv_return($code){ | |
| 400 | - switch($code){ | |
| 401 | - case 'D001': //セブンイレブン | |
| 402 | - $html = '<tr><th>' . __('払込番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; | |
| 403 | - $html .= '<tr><th>'.__('払込票のURL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; | |
| 404 | - break; | |
| 405 | - case 'D002': //ローソン | |
| 406 | - case 'D015': //セイコーマート | |
| 407 | - case 'D405': //ペイジー | |
| 408 | - $html = '<tr><th>' . __('受付番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; | |
| 409 | - $html .= '<tr><th>'.__('支払方法案内URL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; | |
| 410 | - break; | |
| 411 | - case 'D003': //サンクス | |
| 412 | - case 'D004': //サークルK | |
| 413 | - case 'D005': //ミニストップ | |
| 414 | - case 'D010': //デイリーヤマザキ | |
| 415 | - case 'D011': //ヤマザキデイリーストア | |
| 416 | - $html = '<tr><th>' . __('決済番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; | |
| 417 | - $html .= '<tr><th>'.__('支払方法案内URL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; | |
| 418 | - break; | |
| 419 | - case 'D030': //ファミリーマート | |
| 420 | - $html = '<tr><th>' . __('コード','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; | |
| 421 | - $html .= '<tr><th>'.__('注文番号', 'usces').'</th><td>'.esc_html($_REQUEST["X-PAY_NO2"])."</td></tr>\n"; | |
| 422 | - break; | |
| 423 | - case 'D401': //CyberEdy | |
| 424 | - case 'D404': //楽天銀行 | |
| 425 | - case 'D406': //ジャパネット銀行 | |
| 426 | - case 'D451': //ウェブマネー | |
| 427 | - case 'D452': //ビットキャッシュ | |
| 428 | - $html = '<tr><th>' . __('受付番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; | |
| 429 | - $html .= '<tr><th>'.__('支払手続URL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; | |
| 430 | - break; | |
| 431 | - case 'P901': //コンビニ払込票 | |
| 432 | - case 'P902': //コンビニ払込票(郵便振替対応) | |
| 433 | - $html = '<tr><th>' . __('受付番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; | |
| 434 | - break; | |
| 435 | - default: | |
| 436 | - $html = ''; | |
| 437 | - } | |
| 438 | - return $html; | |
| 439 | -} | |
| 440 | - | |
| 441 | -function usces_payment_detail($usces_entries){ | |
| 442 | - $payments = usces_get_payments_by_name( $usces_entries['order']['payment_name'] ); | |
| 443 | - $acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement']; | |
| 444 | - $str = ''; | |
| 445 | - switch( $acting_flag ){ | |
| 446 | - case 'paypal.php': | |
| 447 | - break; | |
| 448 | - | |
| 449 | - case 'epsilon.php': | |
| 450 | - break; | |
| 451 | - | |
| 452 | - case 'acting_zeus_card': | |
| 453 | - if( !isset($_REQUEST['cbrand']) || (isset($_REQUEST['howpay']) && '1' === $_REQUEST['howpay']) ){ | |
| 454 | - $str = ' 一括払い'; | |
| 455 | - }else{ | |
| 456 | - $div_name = 'div_' . $_REQUEST['cbrand']; | |
| 457 | - switch($_REQUEST[$div_name]){ | |
| 458 | - case '01': | |
| 459 | - $str = ' 一括払い'; | |
| 460 | - break; | |
| 461 | - case '99': | |
| 462 | - $str = ' 分割(リボ払い)'; | |
| 463 | - break; | |
| 464 | - case '03': | |
| 465 | - $str = ' 分割(3回)'; | |
| 466 | - break; | |
| 467 | - case '05': | |
| 468 | - $str = ' 分割(5回)'; | |
| 469 | - break; | |
| 470 | - case '06': | |
| 471 | - $str = ' 分割(6回)'; | |
| 472 | - break; | |
| 473 | - case '10': | |
| 474 | - $str = ' 分割(10回)'; | |
| 475 | - break; | |
| 476 | - case '12': | |
| 477 | - $str = ' 分割(12回)'; | |
| 478 | - break; | |
| 479 | - case '15': | |
| 480 | - $str = ' 分割(15回)'; | |
| 481 | - break; | |
| 482 | - case '18': | |
| 483 | - $str = ' 分割(18回)'; | |
| 484 | - break; | |
| 485 | - case '20': | |
| 486 | - $str = ' 分割(20回)'; | |
| 487 | - break; | |
| 488 | - case '24': | |
| 489 | - $str = ' 分割(24回)'; | |
| 490 | - break; | |
| 491 | - } | |
| 492 | - } | |
| 493 | - break; | |
| 494 | - | |
| 495 | - case 'acting_zeus_bank': | |
| 496 | - break; | |
| 497 | - | |
| 498 | - case 'acting_remise_card': | |
| 499 | - if( isset( $_POST['div'] ) ){ | |
| 500 | - switch($_POST['div']){ | |
| 501 | - case '0': | |
| 502 | - $str = ' 一括払い'; | |
| 503 | - break; | |
| 504 | - case '1': | |
| 505 | - $str = ' 分割(2回)'; | |
| 506 | - break; | |
| 507 | - case '2': | |
| 508 | - $str = ' 分割(リボ払い)'; | |
| 509 | - break; | |
| 510 | - } | |
| 511 | - } | |
| 512 | - break; | |
| 513 | - | |
| 514 | - case 'acting_remise_conv': | |
| 515 | - break; | |
| 516 | - } | |
| 517 | - | |
| 518 | - $str = apply_filters('usces_filter_payment_detail', $str, $usces_entries); | |
| 519 | - return $str; | |
| 520 | -} | |
| 521 | - | |
| 522 | -//20100818ysk start | |
| 523 | -function usces_filter_delivery_check_custom_order( $mes ) { | |
| 524 | - global $usces; | |
| 525 | - | |
| 526 | - $meta = usces_has_custom_field_meta('order'); | |
| 527 | - foreach($meta as $key => $entry) { | |
| 528 | - $essential = $entry['essential']; | |
| 529 | - if($essential == 1) { | |
| 530 | - $name = $entry['name']; | |
| 531 | - $means = $entry['means']; | |
| 532 | - if($means == 2) {//Text | |
| 533 | - if( WCUtils::is_blank($_POST['custom_order'][$key]) ) | |
| 534 | - $mes .= __($name.'を入力してください。', 'usces')."<br />"; | |
| 535 | - } else { | |
| 536 | - if(!isset($_POST['custom_order'][$key]) or $_POST['custom_order'][$key] == "#NONE#") | |
| 537 | - $mes .= __($name.'を選択してください。', 'usces')."<br />"; | |
| 538 | - } | |
| 539 | - } | |
| 540 | - } | |
| 541 | - | |
| 542 | - return $mes; | |
| 543 | -} | |
| 544 | - | |
| 545 | -function usces_filter_customer_check_custom_customer( $mes ) { | |
| 546 | - global $usces; | |
| 547 | - | |
| 548 | - $meta = usces_has_custom_field_meta('customer'); | |
| 549 | - foreach($meta as $key => $entry) { | |
| 550 | - $essential = $entry['essential']; | |
| 551 | - if($essential == 1) { | |
| 552 | - $name = $entry['name']; | |
| 553 | - $means = $entry['means']; | |
| 554 | - if($means == 2) {//Text | |
| 555 | - if( WCUtils::is_blank($_POST['custom_customer'][$key]) ) | |
| 556 | - $mes .= __($name.'を入力してください。', 'usces')."<br />"; | |
| 557 | - } else { | |
| 558 | - if(!isset($_POST['custom_customer'][$key]) or $_POST['custom_customer'][$key] == "#NONE#") | |
| 559 | - $mes .= __($name.'を選択してください。', 'usces')."<br />"; | |
| 560 | - } | |
| 561 | - } | |
| 562 | - } | |
| 563 | - | |
| 564 | - return $mes; | |
| 565 | -} | |
| 566 | - | |
| 567 | -function usces_filter_delivery_check_custom_delivery( $mes ) { | |
| 568 | - global $usces; | |
| 569 | - | |
| 570 | - if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == '1' ) { | |
| 571 | - $meta = usces_has_custom_field_meta('delivery'); | |
| 572 | - foreach($meta as $key => $entry) { | |
| 573 | - $essential = $entry['essential']; | |
| 574 | - if($essential == 1) { | |
| 575 | - $name = $entry['name']; | |
| 576 | - $means = $entry['means']; | |
| 577 | - if($means == 2) {//Text | |
| 578 | - if( WCUtils::is_blank($_POST['custom_delivery'][$key]) ) | |
| 579 | - $mes .= __($name.'を入力してください。', 'usces')."<br />"; | |
| 580 | - } else { | |
| 581 | - if(!isset($_POST['custom_delivery'][$key]) or $_POST['custom_delivery'][$key] == "#NONE#") | |
| 582 | - $mes .= __($name.'を選択してください。', 'usces')."<br />"; | |
| 583 | - } | |
| 584 | - } | |
| 585 | - } | |
| 586 | - } | |
| 587 | - | |
| 588 | - return $mes; | |
| 589 | -} | |
| 590 | - | |
| 591 | -function usces_filter_member_check_custom_member( $mes ) { | |
| 592 | - global $usces; | |
| 593 | - | |
| 594 | - unset($_SESSION['usces_member']['custom_member']); | |
| 595 | - if(isset($_POST['custom_member'])) { | |
| 596 | - foreach( $_POST['custom_member'] as $key => $value ) | |
| 597 | - if( is_array($value) ) { | |
| 598 | - foreach( $value as $k => $v ) | |
| 599 | - $_SESSION['usces_member']['custom_member'][$key][trim($v)] = trim($v); | |
| 600 | - } else { | |
| 601 | - $_SESSION['usces_member']['custom_member'][$key] = trim($value); | |
| 602 | - } | |
| 603 | - } | |
| 604 | - | |
| 605 | - $meta = usces_has_custom_field_meta('member'); | |
| 606 | - foreach($meta as $key => $entry) { | |
| 607 | - $essential = $entry['essential']; | |
| 608 | - if($essential == 1) { | |
| 609 | - $name = $entry['name']; | |
| 610 | - $means = $entry['means']; | |
| 611 | - if($means == 2) {//Text | |
| 612 | - if( WCUtils::is_blank($_POST['custom_member'][$key]) ) | |
| 613 | - $mes .= __($name.'を入力してください。', 'usces')."<br />"; | |
| 614 | - } else { | |
| 615 | - if(!isset($_POST['custom_member'][$key]) or $_POST['custom_member'][$key] == "#NONE#") | |
| 616 | - $mes .= __($name.'を選択してください。', 'usces')."<br />"; | |
| 617 | - } | |
| 618 | - } | |
| 619 | - } | |
| 620 | - | |
| 621 | - return $mes; | |
| 622 | -} | |
| 623 | -//20100818ysk end | |
| 624 | -function usces_dashboard_setup() { | |
| 625 | - wp_add_dashboard_widget( 'usces_db_widget' , 'Welcart Information' , 'usces_db_widget'); | |
| 626 | -} | |
| 627 | - | |
| 628 | -function usces_admin_login_head() { | |
| 629 | -?> | |
| 630 | -<script type='text/javascript'> | |
| 631 | -(function($) { | |
| 632 | - usces = { | |
| 633 | - settings: { | |
| 634 | - url: 'http://www.welcart.com/varch/varch.php', | |
| 635 | - type: 'POST', | |
| 636 | - cache: false, | |
| 637 | - success: function(data, dataType){ | |
| 638 | - }, | |
| 639 | - error: function(msg){ | |
| 640 | - } | |
| 641 | - }, | |
| 642 | - varch : function() { | |
| 643 | - var s = usces.settings; | |
| 644 | - s.data = "action=varch_ajax&ID=usces_varch&ver=" + <?php echo $_SERVER['HTTP_HOST']; ?>; | |
| 645 | - $.ajax( s ); | |
| 646 | - return false; | |
| 647 | - } | |
| 648 | - }; | |
| 649 | - usces.varch(); | |
| 650 | -})(jQuery); | |
| 651 | -</script> | |
| 652 | -<?php | |
| 653 | -} | |
| 654 | - | |
| 655 | -//20100908ysk start | |
| 656 | -// member list download | |
| 657 | -function usces_download_member_list() { | |
| 658 | - require_once( USCES_PLUGIN_DIR . "/classes/dataList.class.php" ); | |
| 659 | - global $wpdb, $usces; | |
| 660 | -//20110411ysk start | |
| 661 | - global $usces_settings; | |
| 662 | -//20110411ysk end | |
| 663 | - | |
| 664 | - $ext = $_REQUEST['ftype']; | |
| 665 | -/* if($ext == 'xls') {//HTML | |
| 666 | - $table_h = "<table>"; | |
| 667 | - $table_f = "</table>"; | |
| 668 | - $tr_h = "<tr>"; | |
| 669 | - $tr_f = "</tr>"; | |
| 670 | - $th_h1 = "<th>"; | |
| 671 | - $th_h = "<th>"; | |
| 672 | - $th_f = "</th>"; | |
| 673 | - $td_h1 = "<td>"; | |
| 674 | - $td_h = "<td>"; | |
| 675 | - $td_f = "</td>"; | |
| 676 | - $lf = "\n"; | |
| 677 | -*/ if($ext == 'xls') {//TSV | |
| 678 | - $table_h = ""; | |
| 679 | - $table_f = ""; | |
| 680 | - $tr_h = ""; | |
| 681 | - $tr_f = ""; | |
| 682 | - $th_h1 = '"'; | |
| 683 | - $th_h = "\t".'"'; | |
| 684 | - $th_f = '"'; | |
| 685 | - $td_h1 = '"'; | |
| 686 | - $td_h = "\t".'"'; | |
| 687 | - $td_f = '"'; | |
| 688 | - $lf = "\n"; | |
| 689 | - } elseif($ext == 'csv') {//CSV | |
| 690 | - $table_h = ""; | |
| 691 | - $table_f = ""; | |
| 692 | - $tr_h = ""; | |
| 693 | - $tr_f = ""; | |
| 694 | -//20110201ysk start | |
| 695 | - //$th_h1 = ""; | |
| 696 | - $th_h1 = '"'; | |
| 697 | - //$th_h = ","; | |
| 698 | - $th_h = ',"'; | |
| 699 | - //$th_f = ""; | |
| 700 | - $th_f = '"'; | |
| 701 | - //$td_h1 = ""; | |
| 702 | - $td_h1 = '"'; | |
| 703 | - //$td_h = ","; | |
| 704 | - $td_h = ',"'; | |
| 705 | - //$td_f = ""; | |
| 706 | - $td_f = '"'; | |
| 707 | -//20110201ysk end | |
| 708 | - $lf = "\n"; | |
| 709 | - } else { | |
| 710 | - exit(); | |
| 711 | - } | |
| 712 | - $csmb_meta = usces_has_custom_field_meta('member'); | |
| 713 | -//20110411ysk start | |
| 714 | - $applyform = usces_get_apply_addressform($usces->options['system']['addressform']); | |
| 715 | -//20110411ysk end | |
| 716 | - | |
| 717 | - //========================================================================== | |
| 718 | - $usces_opt_member = get_option('usces_opt_member'); | |
| 719 | - if(!is_array($usces_opt_member)){ | |
| 720 | - $usces_opt_member = array(); | |
| 721 | - } | |
| 722 | - $usces_opt_member['ftype_mem'] = $ext; | |
| 723 | - $chk_mem = array(); | |
| 724 | - $chk_mem['ID'] = 1; | |
| 725 | - $chk_mem['email'] = (isset($_REQUEST['check']['email'])) ? 1 : 0; | |
| 726 | - if(!empty($csmb_meta)) { | |
| 727 | - foreach($csmb_meta as $key => $entry) { | |
| 728 | - if($entry['position'] == 'name_pre') { | |
| 729 | - $name = $entry['name']; | |
| 730 | -//20110208ysk start | |
| 731 | - $csmb_key = 'csmb_'.$key; | |
| 732 | - //$chk_mem[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 733 | - $chk_mem[$csmb_key] = (isset($_REQUEST['check'][$csmb_key])) ? 1 : 0; | |
| 734 | -//20110208ysk end | |
| 735 | - } | |
| 736 | - } | |
| 737 | - } | |
| 738 | - $chk_mem['name'] = 1; | |
| 739 | -//20110411ysk start | |
| 740 | - if($applyform == 'JP') { | |
| 741 | - $chk_mem['kana'] = (isset($_REQUEST['check']['kana'])) ? 1 : 0; | |
| 742 | - } | |
| 743 | -//20110411ysk end | |
| 744 | - if(!empty($csmb_meta)) { | |
| 745 | - foreach($csmb_meta as $key => $entry) { | |
| 746 | - if($entry['position'] == 'name_after') { | |
| 747 | - $name = $entry['name']; | |
| 748 | -//20110208ysk start | |
| 749 | - $csmb_key = 'csmb_'.$key; | |
| 750 | - //$chk_mem[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 751 | - $chk_mem[$csmb_key] = (isset($_REQUEST['check'][$csmb_key])) ? 1 : 0; | |
| 752 | -//20110208ysk end | |
| 753 | - } | |
| 754 | - } | |
| 755 | - } | |
| 756 | - $chk_mem['zip'] = (isset($_REQUEST['check']['zip'])) ? 1 : 0; | |
| 757 | -//20110411ysk start | |
| 758 | - $chk_mem['country'] = 1; | |
| 759 | -//20110411ysk end | |
| 760 | - $chk_mem['pref'] = 1; | |
| 761 | - $chk_mem['address1'] = 1; | |
| 762 | - $chk_mem['address2'] = 1; | |
| 763 | - $chk_mem['address3'] = 1; | |
| 764 | - $chk_mem['tel'] = (isset($_REQUEST['check']['tel'])) ? 1 : 0; | |
| 765 | - $chk_mem['fax'] = (isset($_REQUEST['check']['fax'])) ? 1 : 0; | |
| 766 | - if(!empty($csmb_meta)) { | |
| 767 | - foreach($csmb_meta as $key => $entry) { | |
| 768 | - if($entry['position'] == 'fax_after') { | |
| 769 | - $name = $entry['name']; | |
| 770 | -//20110208ysk start | |
| 771 | - $csmb_key = 'csmb_'.$key; | |
| 772 | - //$chk_mem[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 773 | - $chk_mem[$csmb_key] = (isset($_REQUEST['check'][$csmb_key])) ? 1 : 0; | |
| 774 | -//20110208ysk end | |
| 775 | - } | |
| 776 | - } | |
| 777 | - } | |
| 778 | - $chk_mem['date'] = (isset($_REQUEST['check']['date'])) ? 1 : 0; | |
| 779 | - $chk_mem['point'] = (isset($_REQUEST['check']['point'])) ? 1 : 0; | |
| 780 | - $chk_mem['rank'] = (isset($_REQUEST['check']['rank'])) ? 1 : 0; | |
| 781 | - $usces_opt_member['chk_mem'] = $chk_mem; | |
| 782 | - update_option('usces_opt_member', $usces_opt_member); | |
| 783 | - //========================================================================== | |
| 784 | - | |
| 785 | - $_REQUEST['searchIn'] = "searchIn"; | |
| 786 | - $tableName = $wpdb->prefix."usces_member"; | |
| 787 | - $arr_column = array( | |
| 788 | - __('membership number', 'usces') => 'ID', | |
| 789 | - __('name', 'usces') => 'name', | |
| 790 | - __('Address', 'usces') => 'address', | |
| 791 | - __('Phone number', 'usces') => 'tel', | |
| 792 | - __('e-mail', 'usces') => 'email', | |
| 793 | - __('Strated date', 'usces') => 'date', | |
| 794 | - __('current point', 'usces') => 'point'); | |
| 795 | - $DT = new dataList($tableName, $arr_column); | |
| 796 | -//20101202ysk start | |
| 797 | - $DT->pageLimit = 'off'; | |
| 798 | -//20101202ysk end | |
| 799 | - $res = $DT->MakeTable(); | |
| 800 | - $rows = $DT->rows; | |
| 801 | - | |
| 802 | - //========================================================================== | |
| 803 | - $line = $table_h; | |
| 804 | - $line .= $tr_h; | |
| 805 | - $line .= $th_h1.__('membership number', 'usces').$th_f; | |
| 806 | - if(isset($_REQUEST['check']['email'])) $line .= $th_h.__('e-mail', 'usces').$th_f; | |
| 807 | - if(!empty($csmb_meta)) { | |
| 808 | - foreach($csmb_meta as $key => $entry) { | |
| 809 | - if($entry['position'] == 'name_pre') { | |
| 810 | - $name = $entry['name']; | |
| 811 | -//20110208ysk start | |
| 812 | - $csmb_key = 'csmb_'.$key; | |
| 813 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 814 | - if(isset($_REQUEST['check'][$csmb_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 815 | -//20110208ysk end | |
| 816 | - } | |
| 817 | - } | |
| 818 | - } | |
| 819 | - $line .= $th_h.__('name', 'usces').$th_f; | |
| 820 | -//20110411ysk start | |
| 821 | - if($applyform == 'JP') { | |
| 822 | - if(isset($_REQUEST['check']['kana'])) $line .= $th_h.__('furigana', 'usces').$th_f; | |
| 823 | - } | |
| 824 | -//20110411ysk end | |
| 825 | - if(!empty($csmb_meta)) { | |
| 826 | - foreach($csmb_meta as $key => $entry) { | |
| 827 | - if($entry['position'] == 'name_after') { | |
| 828 | - $name = $entry['name']; | |
| 829 | -//20110208ysk start | |
| 830 | - $csmb_key = 'csmb_'.$key; | |
| 831 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 832 | - if(isset($_REQUEST['check'][$csmb_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 833 | -//20110208ysk end | |
| 834 | - } | |
| 835 | - } | |
| 836 | - } | |
| 837 | -//20110411ysk start | |
| 838 | - switch($applyform) { | |
| 839 | - case 'JP': | |
| 840 | - if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip/Postal Code', 'usces').$th_f; | |
| 841 | - $line .= $th_h.__('Country', 'usces').$th_f; | |
| 842 | - $line .= $th_h.__('Province', 'usces').$th_f; | |
| 843 | - $line .= $th_h.__('city', 'usces').$th_f; | |
| 844 | - $line .= $th_h.__('numbers', 'usces').$th_f; | |
| 845 | - $line .= $th_h.__('building name', 'usces').$th_f; | |
| 846 | - if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; | |
| 847 | - if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; | |
| 848 | - break; | |
| 849 | - case 'US': | |
| 850 | - default: | |
| 851 | - $line .= $th_h.__('Address Line1', 'usces').$th_f; | |
| 852 | - $line .= $th_h.__('Address Line2', 'usces').$th_f; | |
| 853 | - $line .= $th_h.__('city', 'usces').$th_f; | |
| 854 | - $line .= $th_h.__('State', 'usces').$th_f; | |
| 855 | - $line .= $th_h.__('Country', 'usces').$th_f; | |
| 856 | - if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip', 'usces').$th_f; | |
| 857 | - if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; | |
| 858 | - if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; | |
| 859 | - break; | |
| 860 | - } | |
| 861 | -//20110411ysk end | |
| 862 | - if(!empty($csmb_meta)) { | |
| 863 | - foreach($csmb_meta as $key => $entry) { | |
| 864 | - if($entry['position'] == 'fax_after') { | |
| 865 | - $name = $entry['name']; | |
| 866 | -//20110208ysk start | |
| 867 | - $csmb_key = 'csmb_'.$key; | |
| 868 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 869 | - if(isset($_REQUEST['check'][$csmb_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 870 | -//20110208ysk end | |
| 871 | - } | |
| 872 | - } | |
| 873 | - } | |
| 874 | - if(isset($_REQUEST['check']['date'])) $line .= $th_h.__('Strated date', 'usces').$th_f; | |
| 875 | - if(isset($_REQUEST['check']['point'])) $line .= $th_h.__('current point', 'usces').$th_f; | |
| 876 | - if(isset($_REQUEST['check']['rank'])) $line .= $th_h.__('Rank', 'usces').$th_f; | |
| 877 | - $line .= $tr_f.$lf; | |
| 878 | - //========================================================================== | |
| 879 | - foreach((array)$rows as $array) { | |
| 880 | - $member_id = $array['ID']; | |
| 881 | - $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $member_id); | |
| 882 | - $data = $wpdb->get_row( $query, ARRAY_A ); | |
| 883 | - | |
| 884 | - $line .= $tr_h; | |
| 885 | - $line .= $td_h1.$member_id.$td_f; | |
| 886 | - if(isset($_REQUEST['check']['email'])) $line .= $td_h.usces_entity_decode($array['email'], $ext).$td_f; | |
| 887 | - if(!empty($csmb_meta)) { | |
| 888 | - foreach($csmb_meta as $key => $entry) { | |
| 889 | - if($entry['position'] == 'name_pre') { | |
| 890 | - $name = $entry['name']; | |
| 891 | - $csmb_key = 'csmb_'.$key; | |
| 892 | -//20110208ysk start | |
| 893 | - //if(isset($_REQUEST['check'][$name])) { | |
| 894 | - if(isset($_REQUEST['check'][$csmb_key])) { | |
| 895 | -//20110208ysk end | |
| 896 | - $value = maybe_unserialize($usces->get_member_meta_value($csmb_key, $member_id)); | |
| 897 | - if(empty($value)) { | |
| 898 | - $value = ''; | |
| 899 | - } elseif(is_array($value)) { | |
| 900 | - $concatval = ''; | |
| 901 | - $c = ''; | |
| 902 | - foreach($value as $v) { | |
| 903 | - $concatval .= $c.$v; | |
| 904 | - $c = ' '; | |
| 905 | - } | |
| 906 | - $value = $concatval; | |
| 907 | - } | |
| 908 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 909 | - } | |
| 910 | - } | |
| 911 | - } | |
| 912 | - } | |
| 913 | -//20110411ysk start | |
| 914 | - switch($applyform) { | |
| 915 | - case 'JP': | |
| 916 | - $line .= $td_h.usces_entity_decode($data['mem_name1'].' '.$data['mem_name2'], $ext).$td_f; | |
| 917 | - if(isset($_REQUEST['check']['kana'])) $line .= $td_h.usces_entity_decode($data['mem_name3'].' '.$data['mem_name4'], $ext).$td_f; | |
| 918 | - break; | |
| 919 | - case 'US': | |
| 920 | - default: | |
| 921 | - $line .= $td_h.usces_entity_decode($data['mem_name2'].' '.$data['mem_name1'], $ext).$td_f; | |
| 922 | - break; | |
| 923 | - } | |
| 924 | -//20110411ysk end | |
| 925 | - if(!empty($csmb_meta)) { | |
| 926 | - foreach($csmb_meta as $key => $entry) { | |
| 927 | - if($entry['position'] == 'name_after') { | |
| 928 | - $name = $entry['name']; | |
| 929 | - $csmb_key = 'csmb_'.$key; | |
| 930 | -//20110208ysk start | |
| 931 | - //if(isset($_REQUEST['check'][$name])) { | |
| 932 | - if(isset($_REQUEST['check'][$csmb_key])) { | |
| 933 | -//20110208ysk end | |
| 934 | - $value = maybe_unserialize($usces->get_member_meta_value($csmb_key, $member_id)); | |
| 935 | - if(empty($value)) { | |
| 936 | - $value = ''; | |
| 937 | - } elseif(is_array($value)) { | |
| 938 | - $concatval = ''; | |
| 939 | - $c = ''; | |
| 940 | - foreach($value as $v) { | |
| 941 | - $concatval .= $c.$v; | |
| 942 | - $c = ' '; | |
| 943 | - } | |
| 944 | - $value = $concatval; | |
| 945 | - } | |
| 946 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 947 | - } | |
| 948 | - } | |
| 949 | - } | |
| 950 | - } | |
| 951 | -//20110411ysk start | |
| 952 | - $address_info = ''; | |
| 953 | - switch($applyform) { | |
| 954 | - case 'JP': | |
| 955 | - if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['mem_zip'], $ext).$td_f; | |
| 956 | - $address_info .= $td_h.$usces_settings['country'][$usces->get_member_meta_value('customer_country', $member_id)].$td_f; | |
| 957 | - $address_info .= $td_h.usces_entity_decode($data['mem_pref'], $ext).$td_f; | |
| 958 | - $address_info .= $td_h.usces_entity_decode($data['mem_address1'], $ext).$td_f; | |
| 959 | - $address_info .= $td_h.usces_entity_decode($data['mem_address2'], $ext).$td_f; | |
| 960 | - $address_info .= $td_h.usces_entity_decode($data['mem_address3'], $ext).$td_f; | |
| 961 | - if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['mem_tel'], $ext).$td_f; | |
| 962 | - if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['mem_fax'], $ext).$td_f; | |
| 963 | - break; | |
| 964 | - case 'US': | |
| 965 | - default: | |
| 966 | - $address_info .= $td_h.usces_entity_decode($data['mem_address2'], $ext).$td_f; | |
| 967 | - $address_info .= $td_h.usces_entity_decode($data['mem_address3'], $ext).$td_f; | |
| 968 | - $address_info .= $td_h.usces_entity_decode($data['mem_address1'], $ext).$td_f; | |
| 969 | - $address_info .= $td_h.usces_entity_decode($data['mem_pref'], $ext).$td_f; | |
| 970 | - $address_info .= $td_h.$usces_settings['country'][$usces->get_member_meta_value('customer_country', $member_id)].$td_f; | |
| 971 | - if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['mem_zip'], $ext).$td_f; | |
| 972 | - if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['mem_tel'], $ext).$td_f; | |
| 973 | - if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['mem_fax'], $ext).$td_f; | |
| 974 | - break; | |
| 975 | - } | |
| 976 | - $address_info_args = compact( 'td_h', 'td_f', 'ext', 'member_id', 'applyform' ); | |
| 977 | - $line .= apply_filters( 'usces_filter_mem_csv_address_info', $address_info, $data, $address_info_args ); | |
| 978 | -//20110411ysk end | |
| 979 | - if(!empty($csmb_meta)) { | |
| 980 | - foreach($csmb_meta as $key => $entry) { | |
| 981 | - if($entry['position'] == 'fax_after') { | |
| 982 | - $name = $entry['name']; | |
| 983 | - $csmb_key = 'csmb_'.$key; | |
| 984 | -//20110208ysk start | |
| 985 | - //if(isset($_REQUEST['check'][$name])) { | |
| 986 | - if(isset($_REQUEST['check'][$csmb_key])) { | |
| 987 | -//20110208ysk end | |
| 988 | - $value = maybe_unserialize($usces->get_member_meta_value($csmb_key, $member_id)); | |
| 989 | - if(empty($value)) { | |
| 990 | - $value = ''; | |
| 991 | - } elseif(is_array($value)) { | |
| 992 | - $concatval = ''; | |
| 993 | - $c = ''; | |
| 994 | - foreach($value as $v) { | |
| 995 | - $concatval .= $c.$v; | |
| 996 | - $c = ' '; | |
| 997 | - } | |
| 998 | - $value = $concatval; | |
| 999 | - } | |
| 1000 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1001 | - } | |
| 1002 | - } | |
| 1003 | - } | |
| 1004 | - } | |
| 1005 | - if(isset($_REQUEST['check']['date'])) $line .= $td_h.$data['mem_registered'].$td_f; | |
| 1006 | - if(isset($_REQUEST['check']['point'])) $line .= $td_h.$data['mem_point'].$td_f; | |
| 1007 | - if(isset($_REQUEST['check']['rank'])) { | |
| 1008 | - $rank = ''; | |
| 1009 | - foreach((array)$usces->member_status as $rk => $rv) { | |
| 1010 | - if($rk == $data['mem_status']) { | |
| 1011 | - $rank = $rv; | |
| 1012 | - break; | |
| 1013 | - } | |
| 1014 | - } | |
| 1015 | - $line .= $td_h.$rank.$td_f; | |
| 1016 | - } | |
| 1017 | - $line .= $tr_f.$lf; | |
| 1018 | - } | |
| 1019 | - $line .= $table_f.$lf; | |
| 1020 | - //========================================================================== | |
| 1021 | - | |
| 1022 | - if($ext == 'xls') { | |
| 1023 | - header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS"); | |
| 1024 | - } elseif($ext == 'csv') { | |
| 1025 | - header("Content-Type: application/octet-stream"); | |
| 1026 | - } | |
| 1027 | - header("Content-Disposition: attachment; filename=usces_member_list.".$ext); | |
| 1028 | - mb_http_output('pass'); | |
| 1029 | - print(mb_convert_encoding($line, "SJIS-win", "UTF-8")); | |
| 1030 | - exit(); | |
| 1031 | -} | |
| 1032 | - | |
| 1033 | -// product list download | |
| 1034 | -function usces_download_product_list() { | |
| 1035 | - require_once( USCES_PLUGIN_DIR . "/classes/orderList.class.php" ); | |
| 1036 | - global $wpdb, $usces; | |
| 1037 | - | |
| 1038 | - $ext = $_REQUEST['ftype']; | |
| 1039 | -/* if($ext == 'xls') {//HTML | |
| 1040 | - $table_h = "<table>"; | |
| 1041 | - $table_f = "</table>"; | |
| 1042 | - $tr_h = "<tr>"; | |
| 1043 | - $tr_f = "</tr>"; | |
| 1044 | - $th_h1 = "<th>"; | |
| 1045 | - $th_h = "<th>"; | |
| 1046 | - $th_f = "</th>"; | |
| 1047 | - $td_h1 = "<td>"; | |
| 1048 | - $td_h = "<td>"; | |
| 1049 | - $td_f = "</td>"; | |
| 1050 | - $sp = ":"; | |
| 1051 | - $nb = " "; | |
| 1052 | - $lf = "\n"; | |
| 1053 | -*/ if($ext == 'xls') {//TSV | |
| 1054 | - $table_h = ""; | |
| 1055 | - $table_f = ""; | |
| 1056 | - $tr_h = ""; | |
| 1057 | - $tr_f = ""; | |
| 1058 | - $th_h1 = '"'; | |
| 1059 | - $th_h = "\t".'"'; | |
| 1060 | - $th_f = '"'; | |
| 1061 | - $td_h1 = '"'; | |
| 1062 | - $td_h = "\t".'"'; | |
| 1063 | - $td_f = '"'; | |
| 1064 | - $sp = ":"; | |
| 1065 | - $nb = "\n"; | |
| 1066 | - $lf = "\n"; | |
| 1067 | - } elseif($ext == 'csv') {//CSV | |
| 1068 | - $table_h = ""; | |
| 1069 | - $table_f = ""; | |
| 1070 | - $tr_h = ""; | |
| 1071 | - $tr_f = ""; | |
| 1072 | -//20110201ysk start | |
| 1073 | - //$th_h1 = ""; | |
| 1074 | - $th_h1 = '"'; | |
| 1075 | - //$th_h = ","; | |
| 1076 | - $th_h = ',"'; | |
| 1077 | - //$th_f = ""; | |
| 1078 | - $th_f = '"'; | |
| 1079 | - //$td_h1 = ""; | |
| 1080 | - $td_h1 = '"'; | |
| 1081 | - //$td_h = ","; | |
| 1082 | - $td_h = ',"'; | |
| 1083 | - //$td_f = ""; | |
| 1084 | - $td_f = '"'; | |
| 1085 | -//20110201ysk end | |
| 1086 | - $sp = ":"; | |
| 1087 | - $nb = " "; | |
| 1088 | - $lf = "\n"; | |
| 1089 | - } else { | |
| 1090 | - exit(); | |
| 1091 | - } | |
| 1092 | - | |
| 1093 | - //========================================================================== | |
| 1094 | - $usces_opt_order = get_option('usces_opt_order'); | |
| 1095 | - if(!is_array($usces_opt_order)){ | |
| 1096 | - $usces_opt_order = array(); | |
| 1097 | - } | |
| 1098 | - $usces_opt_order['ftype_pro'] = $ext; | |
| 1099 | - $chk_pro = array(); | |
| 1100 | - $chk_pro['ID'] = 1; | |
| 1101 | - $chk_pro['deco_id'] = 1; | |
| 1102 | - $chk_pro['date'] = (isset($_REQUEST['check']['date'])) ? 1 : 0; | |
| 1103 | - $chk_pro['mem_id'] = (isset($_REQUEST['check']['mem_id'])) ? 1 : 0; | |
| 1104 | - $chk_pro['name'] = (isset($_REQUEST['check']['name'])) ? 1 : 0; | |
| 1105 | - $chk_pro['delivery_method'] = (isset($_REQUEST['check']['delivery_method'])) ? 1 : 0; | |
| 1106 | - $chk_pro['shipping_date'] = (isset($_REQUEST['check']['shipping_date'])) ? 1 : 0; | |
| 1107 | - $chk_pro['item_code'] = 1; | |
| 1108 | - $chk_pro['sku_code'] = 1; | |
| 1109 | - $chk_pro['item_name'] = (isset($_REQUEST['check']['item_name'])) ? 1 : 0; | |
| 1110 | - $chk_pro['sku_name'] = (isset($_REQUEST['check']['sku_name'])) ? 1 : 0; | |
| 1111 | - $chk_pro['options'] = (isset($_REQUEST['check']['options'])) ? 1 : 0; | |
| 1112 | - $chk_pro['quantity'] = 1; | |
| 1113 | - $chk_pro['price'] = 1; | |
| 1114 | - $chk_pro['unit'] = (isset($_REQUEST['check']['unit'])) ? 1 : 0; | |
| 1115 | - $usces_opt_order['chk_pro'] = apply_filters( 'usces_filter_chk_pro', $chk_pro ); | |
| 1116 | - update_option('usces_opt_order', $usces_opt_order); | |
| 1117 | - //========================================================================== | |
| 1118 | - | |
| 1119 | - $_REQUEST['searchIn'] = "searchIn"; | |
| 1120 | - $tableName = $wpdb->prefix."usces_order"; | |
| 1121 | - $arr_column = array( | |
| 1122 | - __('ID', 'usces') => 'ID', | |
| 1123 | - __('Order number', 'usces') => 'deco_id', | |
| 1124 | - __('date', 'usces') => 'date', | |
| 1125 | - __('membership number', 'usces') => 'mem_id', | |
| 1126 | - __('name', 'usces') => 'name', | |
| 1127 | - __('Region', 'usces') => 'pref', | |
| 1128 | - __('shipping option', 'usces') => 'delivery_method', | |
| 1129 | - __('Amount', 'usces') => 'total_price', | |
| 1130 | - __('payment method', 'usces') => 'payment_name', | |
| 1131 | - __('transfer statement', 'usces') => 'receipt_status', | |
| 1132 | - __('Processing', 'usces') => 'order_status', | |
| 1133 | - __('shpping date', 'usces') => 'order_modified'); | |
| 1134 | - $DT = new dataList($tableName, $arr_column); | |
| 1135 | -//20101202ysk start | |
| 1136 | - $DT->pageLimit = 'off'; | |
| 1137 | -//20101202ysk end | |
| 1138 | - $res = $DT->MakeTable(); | |
| 1139 | - $rows = $DT->rows; | |
| 1140 | - | |
| 1141 | - //========================================================================== | |
| 1142 | - $line = $table_h; | |
| 1143 | - $line .= $tr_h; | |
| 1144 | - $line .= $th_h1.__('ID', 'usces').$th_f; | |
| 1145 | - $line .= $th_h.__('Order number', 'usces').$th_f; | |
| 1146 | - if(isset($_REQUEST['check']['date'])) $line .= $th_h.__('order date', 'usces').$th_f; | |
| 1147 | - if(isset($_REQUEST['check']['mem_id'])) $line .= $th_h.__('membership number', 'usces').$th_f; | |
| 1148 | - if(isset($_REQUEST['check']['name'])) $line .= $th_h.__('name', 'usces').$th_f; | |
| 1149 | - if(isset($_REQUEST['check']['delivery_method'])) $line .= $th_h.__('shipping option', 'usces').$th_f; | |
| 1150 | - if(isset($_REQUEST['check']['shipping_date'])) $line .= $th_h.__('shpping date', 'usces').$th_f; | |
| 1151 | - $line .= apply_filters( 'usces_filter_chk_pro_label_head', NULL, $usces_opt_order, $rows); | |
| 1152 | - $line .= $th_h.__('item code', 'usces').$th_f; | |
| 1153 | - $line .= $th_h.__('SKU code', 'usces').$th_f; | |
| 1154 | - if(isset($_REQUEST['check']['item_name'])) $line .= $th_h.__('item name', 'usces').$th_f; | |
| 1155 | - if(isset($_REQUEST['check']['sku_name'])) $line .= $th_h.__('SKU display name ', 'usces').$th_f; | |
| 1156 | - if(isset($_REQUEST['check']['options'])) $line .= $th_h.__('options for items', 'usces').$th_f; | |
| 1157 | - $line .= $th_h.__('Quantity', 'usces').$th_f; | |
| 1158 | - $line .= $th_h.__('Unit price', 'usces').$th_f; | |
| 1159 | - if(isset($_REQUEST['check']['unit'])) $line .= $th_h.__('unit', 'usces').$th_f; | |
| 1160 | - $line .= apply_filters( 'usces_filter_chk_pro_label_detail', NULL, $usces_opt_order, $rows); | |
| 1161 | - $line .= $tr_f.$lf; | |
| 1162 | - //========================================================================== | |
| 1163 | - foreach((array)$rows as $array) { | |
| 1164 | - $order_id = $array['ID']; | |
| 1165 | - $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id); | |
| 1166 | - $data = $wpdb->get_row( $query, ARRAY_A ); | |
| 1167 | - //$cart = stripslashes_deep(unserialize($data['order_cart'])); | |
| 1168 | - $cart = unserialize($data['order_cart']); | |
| 1169 | - //if(!empty($data)) { | |
| 1170 | - // $data = stripslashes_deep($data); | |
| 1171 | - //} | |
| 1172 | - for($i = 0; $i < count($cart); $i++) { | |
| 1173 | - $cart_row = $cart[$i]; | |
| 1174 | - $post_id = $cart_row['post_id']; | |
| 1175 | - $sku = urldecode($cart_row['sku']); | |
| 1176 | - | |
| 1177 | - $line .= $tr_h; | |
| 1178 | - $line .= $td_h1.$order_id.$td_f; | |
| 1179 | - $line .= $td_h.$array['deco_id'].$td_f; | |
| 1180 | - if(isset($_REQUEST['check']['date'])) $line .= $td_h.$array['date'].$td_f; | |
| 1181 | - if(isset($_REQUEST['check']['mem_id'])) $line .= $td_h.$array['mem_id'].$td_f; | |
| 1182 | - if(isset($_REQUEST['check']['name'])) $line .= $td_h.usces_entity_decode($data['order_name1'].$data['order_name2'], $ext).$td_f; | |
| 1183 | - if(isset($_REQUEST['check']['delivery_method'])) { | |
| 1184 | - $delivery_method = ''; | |
| 1185 | - if(strtoupper($data['order_delivery_method']) == '#NONE#') { | |
| 1186 | - $delivery_method = __('No preference', 'usces'); | |
| 1187 | - } else { | |
| 1188 | - foreach((array)$usces->options['delivery_method'] as $dkey => $delivery) { | |
| 1189 | - if($delivery['id'] == $data['order_delivery_method']) { | |
| 1190 | - $delivery_method = $delivery['name']; | |
| 1191 | - break; | |
| 1192 | - } | |
| 1193 | - } | |
| 1194 | - } | |
| 1195 | - $line .= $td_h.$delivery_method.$td_f; | |
| 1196 | - } | |
| 1197 | - if(isset($_REQUEST['check']['shipping_date'])) $line .= $td_h.$data['order_modified'].$td_f; | |
| 1198 | - $line .= apply_filters( 'usces_filter_chk_pro_data_head', NULL, $usces_opt_order, $data, $cart_row); | |
| 1199 | - | |
| 1200 | - $line .= $td_h.$usces->getItemCode($post_id).$td_f; | |
| 1201 | - $line .= $td_h.$sku.$td_f; | |
| 1202 | - if(isset($_REQUEST['check']['item_name'])) $line .= $td_h.usces_entity_decode($usces->getItemName($post_id), $ext).$td_f; | |
| 1203 | - if(isset($_REQUEST['check']['sku_name'])) $line .= $td_h.usces_entity_decode($usces->getItemSkuDisp($post_id, $sku), $ext).$td_f; | |
| 1204 | - if(isset($_REQUEST['check']['options'])) { | |
| 1205 | - $options = $cart_row['options']; | |
| 1206 | - $optstr = ''; | |
| 1207 | - if(is_array($options) && count($options) > 0) { | |
| 1208 | - foreach((array)$options as $key => $value) { | |
| 1209 | - if(!empty($key)) { | |
| 1210 | - if(is_array($value)) { | |
| 1211 | - foreach($value as $v) { | |
| 1212 | - $optstr .= usces_entity_decode(urldecode($key), $ext).$sp; | |
| 1213 | - foreach($value as $v) { | |
| 1214 | - $optstr .= usces_entity_decode(urldecode($v), $ext).$nb; | |
| 1215 | - } | |
| 1216 | - } | |
| 1217 | - } else { | |
| 1218 | - //$optstr .= usces_entity_decode($key, $ext).$sp.usces_entity_decode($value, $ext).$nb; | |
| 1219 | - $optstr .= usces_entity_decode(urldecode($key).$sp.urldecode($value), $ext).$nb; | |
| 1220 | - } | |
| 1221 | - } | |
| 1222 | - } | |
| 1223 | - } | |
| 1224 | - $line .= $td_h.$optstr.$td_f; | |
| 1225 | - } | |
| 1226 | - $line .= $td_h.$cart_row['quantity'].$td_f; | |
| 1227 | - $line .= $td_h.usces_crform($cart_row['price'], false, false, 'return', false).$td_f; | |
| 1228 | - if(isset($_REQUEST['check']['unit'])) $line .= $td_h.usces_entity_decode($usces->getItemSkuUnit($post_id, $sku), $ext).$td_f; | |
| 1229 | - $line .= apply_filters( 'usces_filter_chk_pro_data_detail', NULL, $usces_opt_order, $data, $cart_row); | |
| 1230 | - $line .= $tr_f.$lf; | |
| 1231 | - } | |
| 1232 | - } | |
| 1233 | - $line .= $table_f.$lf; | |
| 1234 | - //========================================================================== | |
| 1235 | - | |
| 1236 | - if($ext == 'xls') { | |
| 1237 | - header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS"); | |
| 1238 | - } elseif($ext == 'csv') { | |
| 1239 | - header("Content-Type: application/octet-stream"); | |
| 1240 | - } | |
| 1241 | - header("Content-Disposition: attachment; filename=usces_product_list.".$ext); | |
| 1242 | - mb_http_output('pass'); | |
| 1243 | - print(mb_convert_encoding($line, "SJIS-win", "UTF-8")); | |
| 1244 | - exit(); | |
| 1245 | -} | |
| 1246 | - | |
| 1247 | -// order list download | |
| 1248 | -function usces_download_order_list() { | |
| 1249 | - require_once( USCES_PLUGIN_DIR . "/classes/orderList.class.php" ); | |
| 1250 | - global $wpdb, $usces; | |
| 1251 | -//20110411ysk start | |
| 1252 | - global $usces_settings; | |
| 1253 | -//20110411ysk end | |
| 1254 | - | |
| 1255 | - $ext = $_REQUEST['ftype']; | |
| 1256 | -/* if($ext == 'xls') {//HTML | |
| 1257 | - $table_h = "<table>"; | |
| 1258 | - $table_f = "</table>"; | |
| 1259 | - $tr_h = "<tr>"; | |
| 1260 | - $tr_f = "</tr>"; | |
| 1261 | - $th_h1 = "<th>"; | |
| 1262 | - $th_h = "<th>"; | |
| 1263 | - $th_f = "</th>"; | |
| 1264 | - $td_h1 = "<td>"; | |
| 1265 | - $td_h = "<td>"; | |
| 1266 | - $td_f = "</td>"; | |
| 1267 | - $sp = ":"; | |
| 1268 | - $lf = "\n"; | |
| 1269 | -*/ if($ext == 'xls') {//TSV | |
| 1270 | - $table_h = ""; | |
| 1271 | - $table_f = ""; | |
| 1272 | - $tr_h = ""; | |
| 1273 | - $tr_f = ""; | |
| 1274 | - $th_h1 = '"'; | |
| 1275 | - $th_h = "\t".'"'; | |
| 1276 | - $th_f = '"'; | |
| 1277 | - $td_h1 = '"'; | |
| 1278 | - $td_h = "\t".'"'; | |
| 1279 | - $td_f = '"'; | |
| 1280 | - $sp = ":"; | |
| 1281 | - $lf = "\n"; | |
| 1282 | - } elseif($ext == 'csv') {//CSV | |
| 1283 | - $table_h = ""; | |
| 1284 | - $table_f = ""; | |
| 1285 | - $tr_h = ""; | |
| 1286 | - $tr_f = ""; | |
| 1287 | -//20110201ysk start | |
| 1288 | - //$th_h1 = ""; | |
| 1289 | - $th_h1 = '"'; | |
| 1290 | - //$th_h = ","; | |
| 1291 | - $th_h = ',"'; | |
| 1292 | - //$th_f = ""; | |
| 1293 | - $th_f = '"'; | |
| 1294 | - //$td_h1 = ""; | |
| 1295 | - $td_h1 = '"'; | |
| 1296 | - //$td_h = ","; | |
| 1297 | - $td_h = ',"'; | |
| 1298 | - //$td_f = ""; | |
| 1299 | - $td_f = '"'; | |
| 1300 | -//20110201ysk end | |
| 1301 | - $sp = ":"; | |
| 1302 | - $lf = "\n"; | |
| 1303 | - } else { | |
| 1304 | - exit(); | |
| 1305 | - } | |
| 1306 | - $csod_meta = usces_has_custom_field_meta('order'); | |
| 1307 | - $cscs_meta = usces_has_custom_field_meta('customer'); | |
| 1308 | - $csde_meta = usces_has_custom_field_meta('delivery'); | |
| 1309 | -//20110411ysk start | |
| 1310 | - $applyform = usces_get_apply_addressform($usces->options['system']['addressform']); | |
| 1311 | -//20110411ysk end | |
| 1312 | - | |
| 1313 | - //========================================================================== | |
| 1314 | - $usces_opt_order = get_option('usces_opt_order'); | |
| 1315 | - if(!is_array($usces_opt_order)){ | |
| 1316 | - $usces_opt_order = array(); | |
| 1317 | - } | |
| 1318 | - $usces_opt_order['ftype_ord'] = $ext; | |
| 1319 | - $chk_ord = array(); | |
| 1320 | - $chk_ord['ID'] = 1; | |
| 1321 | - $chk_ord['deco_id'] = 1; | |
| 1322 | - $chk_ord['date'] = 1; | |
| 1323 | - $chk_ord['mem_id'] = (isset($_REQUEST['check']['mem_id'])) ? 1 : 0; | |
| 1324 | - $chk_ord['email'] = (isset($_REQUEST['check']['email'])) ? 1 : 0; | |
| 1325 | - if(!empty($cscs_meta)) { | |
| 1326 | - foreach($cscs_meta as $key => $entry) { | |
| 1327 | - if($entry['position'] == 'name_pre') { | |
| 1328 | - $name = $entry['name']; | |
| 1329 | -//20110208ysk start | |
| 1330 | - $cscs_key = 'cscs_'.$key; | |
| 1331 | - //$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 1332 | - $chk_ord[$cscs_key] = (isset($_REQUEST['check'][$cscs_key])) ? 1 : 0; | |
| 1333 | -//20110208ysk end | |
| 1334 | - } | |
| 1335 | - } | |
| 1336 | - } | |
| 1337 | - $chk_ord['name'] = 1; | |
| 1338 | -//20110411ysk start | |
| 1339 | - if($applyform == 'JP') { | |
| 1340 | - $chk_ord['kana'] = (isset($_REQUEST['check']['kana'])) ? 1 : 0; | |
| 1341 | - } | |
| 1342 | -//20110411ysk end | |
| 1343 | - if(!empty($cscs_meta)) { | |
| 1344 | - foreach($cscs_meta as $key => $entry) { | |
| 1345 | - if($entry['position'] == 'name_after') { | |
| 1346 | - $name = $entry['name']; | |
| 1347 | -//20110208ysk start | |
| 1348 | - $cscs_key = 'cscs_'.$key; | |
| 1349 | - //$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 1350 | - $chk_ord[$cscs_key] = (isset($_REQUEST['check'][$cscs_key])) ? 1 : 0; | |
| 1351 | -//20110208ysk end | |
| 1352 | - } | |
| 1353 | - } | |
| 1354 | - } | |
| 1355 | - $chk_ord['zip'] = (isset($_REQUEST['check']['zip'])) ? 1 : 0; | |
| 1356 | -//20110411ysk start | |
| 1357 | - $chk_ord['country'] = (isset($_REQUEST['check']['country'])) ? 1 : 0; | |
| 1358 | -//20110411ysk end | |
| 1359 | - $chk_ord['pref'] = (isset($_REQUEST['check']['pref'])) ? 1 : 0; | |
| 1360 | - $chk_ord['address1'] = (isset($_REQUEST['check']['address1'])) ? 1 : 0; | |
| 1361 | - $chk_ord['address2'] = (isset($_REQUEST['check']['address2'])) ? 1 : 0; | |
| 1362 | - $chk_ord['address3'] = (isset($_REQUEST['check']['address3'])) ? 1 : 0; | |
| 1363 | - $chk_ord['tel'] = (isset($_REQUEST['check']['tel'])) ? 1 : 0; | |
| 1364 | - $chk_ord['fax'] = (isset($_REQUEST['check']['fax'])) ? 1 : 0; | |
| 1365 | - if(!empty($cscs_meta)) { | |
| 1366 | - foreach($cscs_meta as $key => $entry) { | |
| 1367 | - if($entry['position'] == 'fax_after') { | |
| 1368 | - $name = $entry['name']; | |
| 1369 | -//20110208ysk start | |
| 1370 | - $cscs_key = 'cscs_'.$key; | |
| 1371 | - //$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 1372 | - $chk_ord[$cscs_key] = (isset($_REQUEST['check'][$cscs_key])) ? 1 : 0; | |
| 1373 | -//20110208ysk end | |
| 1374 | - } | |
| 1375 | - } | |
| 1376 | - } | |
| 1377 | - //-------------------------------------------------------------------------- | |
| 1378 | - if(!empty($csde_meta)) { | |
| 1379 | - foreach($csde_meta as $key => $entry) { | |
| 1380 | - if($entry['position'] == 'name_pre') { | |
| 1381 | - $name = $entry['name']; | |
| 1382 | -//20110208ysk start | |
| 1383 | - $csde_key = 'csde_'.$key; | |
| 1384 | - //$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 1385 | - $chk_ord[$csde_key] = (isset($_REQUEST['check'][$csde_key])) ? 1 : 0; | |
| 1386 | -//20110208ysk end | |
| 1387 | - } | |
| 1388 | - } | |
| 1389 | - } | |
| 1390 | - $chk_ord['delivery_name'] = (isset($_REQUEST['check']['delivery_name'])) ? 1 : 0; | |
| 1391 | -//20110411ysk start | |
| 1392 | - if($applyform == 'JP') { | |
| 1393 | - $chk_ord['delivery_kana'] = (isset($_REQUEST['check']['delivery_kana'])) ? 1 : 0; | |
| 1394 | - } | |
| 1395 | -//20110411ysk end | |
| 1396 | - if(!empty($csde_meta)) { | |
| 1397 | - foreach($csde_meta as $key => $entry) { | |
| 1398 | - if($entry['position'] == 'name_after') { | |
| 1399 | - $name = $entry['name']; | |
| 1400 | -//20110208ysk start | |
| 1401 | - $csde_key = 'csde_'.$key; | |
| 1402 | - //$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 1403 | - $chk_ord[$csde_key] = (isset($_REQUEST['check'][$csde_key])) ? 1 : 0; | |
| 1404 | -//20110208ysk end | |
| 1405 | - } | |
| 1406 | - } | |
| 1407 | - } | |
| 1408 | - $chk_ord['delivery_zip'] = (isset($_REQUEST['check']['delivery_zip'])) ? 1 : 0; | |
| 1409 | -//20110411ysk start | |
| 1410 | - $chk_ord['delivery_country'] = (isset($_REQUEST['check']['delivery_country'])) ? 1 : 0; | |
| 1411 | -//20110411ysk end | |
| 1412 | - $chk_ord['delivery_pref'] = (isset($_REQUEST['check']['delivery_pref'])) ? 1 : 0; | |
| 1413 | - $chk_ord['delivery_address1'] = (isset($_REQUEST['check']['delivery_address1'])) ? 1 : 0; | |
| 1414 | - $chk_ord['delivery_address2'] = (isset($_REQUEST['check']['delivery_address2'])) ? 1 : 0; | |
| 1415 | - $chk_ord['delivery_address3'] = (isset($_REQUEST['check']['delivery_address3'])) ? 1 : 0; | |
| 1416 | - $chk_ord['delivery_tel'] = (isset($_REQUEST['check']['delivery_tel'])) ? 1 : 0; | |
| 1417 | - $chk_ord['delivery_fax'] = (isset($_REQUEST['check']['delivery_fax'])) ? 1 : 0; | |
| 1418 | - if(!empty($csde_meta)) { | |
| 1419 | - foreach($csde_meta as $key => $entry) { | |
| 1420 | - if($entry['position'] == 'fax_after') { | |
| 1421 | - $name = $entry['name']; | |
| 1422 | -//20110208ysk start | |
| 1423 | - $csde_key = 'csde_'.$key; | |
| 1424 | - //$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 1425 | - $chk_ord[$csde_key] = (isset($_REQUEST['check'][$csde_key])) ? 1 : 0; | |
| 1426 | -//20110208ysk end | |
| 1427 | - } | |
| 1428 | - } | |
| 1429 | - } | |
| 1430 | - //-------------------------------------------------------------------------- | |
| 1431 | - $chk_ord['shipping_date'] = (isset($_REQUEST['check']['shipping_date'])) ? 1 : 0; | |
| 1432 | - $chk_ord['peyment_method'] = (isset($_REQUEST['check']['peyment_method'])) ? 1 : 0; | |
| 1433 | - $chk_ord['delivery_method'] = (isset($_REQUEST['check']['delivery_method'])) ? 1 : 0; | |
| 1434 | -//20101208ysk start | |
| 1435 | - $chk_ord['delivery_date'] = (isset($_REQUEST['check']['delivery_date'])) ? 1 : 0; | |
| 1436 | -//20101208ysk end | |
| 1437 | - $chk_ord['delivery_time'] = (isset($_REQUEST['check']['delivery_time'])) ? 1 : 0; | |
| 1438 | - $chk_ord['delidue_date'] = (isset($_REQUEST['check']['delidue_date'])) ? 1 : 0; | |
| 1439 | - $chk_ord['status'] = (isset($_REQUEST['check']['status'])) ? 1 : 0; | |
| 1440 | - $chk_ord['total_amount'] = 1; | |
| 1441 | - $chk_ord['usedpoint'] = (isset($_REQUEST['check']['usedpoint'])) ? 1 : 0; | |
| 1442 | - $chk_ord['discount'] = 1; | |
| 1443 | - $chk_ord['shipping_charge'] = 1; | |
| 1444 | - $chk_ord['cod_fee'] = 1; | |
| 1445 | - $chk_ord['tax'] = 1; | |
| 1446 | - $chk_ord['note'] = (isset($_REQUEST['check']['note'])) ? 1 : 0; | |
| 1447 | - if(!empty($csod_meta)) { | |
| 1448 | - foreach($csod_meta as $key => $entry) { | |
| 1449 | - $name = $entry['name']; | |
| 1450 | -//20110208ysk start | |
| 1451 | - $csod_key = 'csod_'.$key; | |
| 1452 | - //$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; | |
| 1453 | - $chk_ord[$csod_key] = (isset($_REQUEST['check'][$csod_key])) ? 1 : 0; | |
| 1454 | -//20110208ysk end | |
| 1455 | - } | |
| 1456 | - } | |
| 1457 | - $usces_opt_order['chk_ord'] = apply_filters( 'usces_filter_chk_ord', $chk_ord ); | |
| 1458 | - update_option('usces_opt_order', $usces_opt_order); | |
| 1459 | - //========================================================================== | |
| 1460 | - | |
| 1461 | - if(isset($_REQUEST['check']['status'])) { | |
| 1462 | - //$usces_management_status = get_option('usces_management_status'); | |
| 1463 | - $usces_management_status = apply_filters( 'usces_filter_management_status', get_option('usces_management_status') );//0000530 | |
| 1464 | - $usces_management_status['new'] = __('new order', 'usces'); | |
| 1465 | - } | |
| 1466 | - | |
| 1467 | - $_REQUEST['searchIn'] = "searchIn"; | |
| 1468 | - $tableName = $wpdb->prefix."usces_order"; | |
| 1469 | - $arr_column = array( | |
| 1470 | - __('ID', 'usces') => 'ID', | |
| 1471 | - __('Order number', 'usces') => 'deco_id', | |
| 1472 | - __('date', 'usces') => 'date', | |
| 1473 | - __('membership number', 'usces') => 'mem_id', | |
| 1474 | - __('name', 'usces') => 'name', | |
| 1475 | - __('Region', 'usces') => 'pref', | |
| 1476 | - __('shipping option', 'usces') => 'delivery_method', | |
| 1477 | - __('Amount', 'usces') => 'total_price', | |
| 1478 | - __('payment method', 'usces') => 'payment_name', | |
| 1479 | - __('transfer statement', 'usces') => 'receipt_status', | |
| 1480 | - __('Processing', 'usces') => 'order_status', | |
| 1481 | - __('shpping date', 'usces') => 'order_modified'); | |
| 1482 | - $DT = new dataList($tableName, $arr_column); | |
| 1483 | -//20101202ysk start | |
| 1484 | - $DT->pageLimit = 'off'; | |
| 1485 | -//20101202ysk end | |
| 1486 | - $res = $DT->MakeTable(); | |
| 1487 | - $rows = $DT->rows; | |
| 1488 | - | |
| 1489 | - //========================================================================== | |
| 1490 | - $line = $table_h; | |
| 1491 | - $line .= $tr_h; | |
| 1492 | - $line .= $th_h1.__('ID', 'usces').$th_f; | |
| 1493 | - $line .= $th_h.__('Order number', 'usces').$th_f; | |
| 1494 | - $line .= $th_h.__('order date', 'usces').$th_f; | |
| 1495 | - if(isset($_REQUEST['check']['mem_id'])) $line .= $th_h.__('membership number', 'usces').$th_f; | |
| 1496 | - if(isset($_REQUEST['check']['email'])) $line .= $th_h.__('e-mail', 'usces').$th_f; | |
| 1497 | - if(!empty($cscs_meta)) { | |
| 1498 | - foreach($cscs_meta as $key => $entry) { | |
| 1499 | - if($entry['position'] == 'name_pre') { | |
| 1500 | - $name = $entry['name']; | |
| 1501 | -//20110208ysk start | |
| 1502 | - $cscs_key = 'cscs_'.$key; | |
| 1503 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1504 | - if(isset($_REQUEST['check'][$cscs_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1505 | -//20110208ysk end | |
| 1506 | - } | |
| 1507 | - } | |
| 1508 | - } | |
| 1509 | - $line .= $th_h.__('name', 'usces').$th_f; | |
| 1510 | -//20110411ysk start | |
| 1511 | - if($applyform == 'JP') { | |
| 1512 | - if(isset($_REQUEST['check']['kana'])) $line .= $th_h.__('furigana', 'usces').$th_f; | |
| 1513 | - } | |
| 1514 | -//20110411ysk end | |
| 1515 | - if(!empty($cscs_meta)) { | |
| 1516 | - foreach($cscs_meta as $key => $entry) { | |
| 1517 | - if($entry['position'] == 'name_after') { | |
| 1518 | - $name = $entry['name']; | |
| 1519 | -//20110208ysk start | |
| 1520 | - $cscs_key = 'cscs_'.$key; | |
| 1521 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1522 | - if(isset($_REQUEST['check'][$cscs_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1523 | -//20110208ysk end | |
| 1524 | - } | |
| 1525 | - } | |
| 1526 | - } | |
| 1527 | -//20110411ysk start | |
| 1528 | - switch($applyform) { | |
| 1529 | - case 'JP': | |
| 1530 | - if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip/Postal Code', 'usces').$th_f; | |
| 1531 | - if(isset($_REQUEST['check']['country'])) $line .= $th_h.__('Country', 'usces').$th_f; | |
| 1532 | - if(isset($_REQUEST['check']['pref'])) $line .= $th_h.__('Province', 'usces').$th_f; | |
| 1533 | - if(isset($_REQUEST['check']['address1'])) $line .= $th_h.__('city', 'usces').$th_f; | |
| 1534 | - if(isset($_REQUEST['check']['address2'])) $line .= $th_h.__('numbers', 'usces').$th_f; | |
| 1535 | - if(isset($_REQUEST['check']['address3'])) $line .= $th_h.__('building name', 'usces').$th_f; | |
| 1536 | - if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; | |
| 1537 | - if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; | |
| 1538 | - break; | |
| 1539 | - case 'US': | |
| 1540 | - default: | |
| 1541 | - if(isset($_REQUEST['check']['address2'])) $line .= $th_h.__('Address Line1', 'usces').$th_f; | |
| 1542 | - if(isset($_REQUEST['check']['address3'])) $line .= $th_h.__('Address Line2', 'usces').$th_f; | |
| 1543 | - if(isset($_REQUEST['check']['address1'])) $line .= $th_h.__('city', 'usces').$th_f; | |
| 1544 | - if(isset($_REQUEST['check']['pref'])) $line .= $th_h.__('State', 'usces').$th_f; | |
| 1545 | - if(isset($_REQUEST['check']['country'])) $line .= $th_h.__('Country', 'usces').$th_f; | |
| 1546 | - if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip', 'usces').$th_f; | |
| 1547 | - if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; | |
| 1548 | - if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; | |
| 1549 | - break; | |
| 1550 | - } | |
| 1551 | -//20110411ysk end | |
| 1552 | - if(!empty($cscs_meta)) { | |
| 1553 | - foreach($cscs_meta as $key => $entry) { | |
| 1554 | - if($entry['position'] == 'fax_after') { | |
| 1555 | - $name = $entry['name']; | |
| 1556 | -//20110208ysk start | |
| 1557 | - $cscs_key = 'cscs_'.$key; | |
| 1558 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1559 | - if(isset($_REQUEST['check'][$cscs_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1560 | -//20110208ysk end | |
| 1561 | - } | |
| 1562 | - } | |
| 1563 | - } | |
| 1564 | - $line .= apply_filters( 'usces_filter_chk_ord_label_customer', NULL, $usces_opt_order, $rows ); | |
| 1565 | - | |
| 1566 | - //-------------------------------------------------------------------------- | |
| 1567 | - if(!empty($csde_meta)) { | |
| 1568 | - foreach($csde_meta as $key => $entry) { | |
| 1569 | - if($entry['position'] == 'name_pre') { | |
| 1570 | - $name = $entry['name']; | |
| 1571 | -//20110208ysk start | |
| 1572 | - $csde_key = 'csde_'.$key; | |
| 1573 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1574 | - if(isset($_REQUEST['check'][$csde_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1575 | -//20110208ysk end | |
| 1576 | - } | |
| 1577 | - } | |
| 1578 | - } | |
| 1579 | - if(isset($_REQUEST['check']['delivery_name'])) $line .= $th_h.__('Shipping Name', 'usces').$th_f; | |
| 1580 | -//20110411ysk start | |
| 1581 | - if($applyform == 'JP') { | |
| 1582 | - if(isset($_REQUEST['check']['delivery_kana'])) $line .= $th_h.__('Shipping Furigana', 'usces').$th_f; | |
| 1583 | - } | |
| 1584 | -//20110411ysk end | |
| 1585 | - if(!empty($csde_meta)) { | |
| 1586 | - foreach($csde_meta as $key => $entry) { | |
| 1587 | - if($entry['position'] == 'name_after') { | |
| 1588 | - $name = $entry['name']; | |
| 1589 | -//20110208ysk start | |
| 1590 | - $csde_key = 'csde_'.$key; | |
| 1591 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1592 | - if(isset($_REQUEST['check'][$csde_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1593 | -//20110208ysk end | |
| 1594 | - } | |
| 1595 | - } | |
| 1596 | - } | |
| 1597 | -//20110411ysk start | |
| 1598 | - switch($applyform) { | |
| 1599 | - case 'JP': | |
| 1600 | - if(isset($_REQUEST['check']['delivery_zip'])) $line .= $th_h.__('Shipping Zip', 'usces').$th_f; | |
| 1601 | - if(isset($_REQUEST['check']['delivery_country'])) $line .= $th_h.__('配送先国', 'usces').$th_f; | |
| 1602 | - if(isset($_REQUEST['check']['delivery_pref'])) $line .= $th_h.__('Shipping State', 'usces').$th_f; | |
| 1603 | - if(isset($_REQUEST['check']['delivery_address1'])) $line .= $th_h.__('Shipping City', 'usces').$th_f; | |
| 1604 | - if(isset($_REQUEST['check']['delivery_address2'])) $line .= $th_h.__('Shipping Address1', 'usces').$th_f; | |
| 1605 | - if(isset($_REQUEST['check']['delivery_address3'])) $line .= $th_h.__('Shipping Address2', 'usces').$th_f; | |
| 1606 | - if(isset($_REQUEST['check']['delivery_tel'])) $line .= $th_h.__('Shipping Phone', 'usces').$th_f; | |
| 1607 | - if(isset($_REQUEST['check']['delivery_fax'])) $line .= $th_h.__('Shipping FAX', 'usces').$th_f; | |
| 1608 | - break; | |
| 1609 | - case 'US': | |
| 1610 | - default: | |
| 1611 | - if(isset($_REQUEST['check']['delivery_address2'])) $line .= $th_h.__('Shipping Address1', 'usces').$th_f; | |
| 1612 | - if(isset($_REQUEST['check']['delivery_address3'])) $line .= $th_h.__('Shipping Address2', 'usces').$th_f; | |
| 1613 | - if(isset($_REQUEST['check']['delivery_address1'])) $line .= $th_h.__('Shipping City', 'usces').$th_f; | |
| 1614 | - if(isset($_REQUEST['check']['delivery_pref'])) $line .= $th_h.__('Shipping State', 'usces').$th_f; | |
| 1615 | - if(isset($_REQUEST['check']['delivery_country'])) $line .= $th_h.__('配送先国', 'usces').$th_f; | |
| 1616 | - if(isset($_REQUEST['check']['delivery_zip'])) $line .= $th_h.__('Shipping Zip', 'usces').$th_f; | |
| 1617 | - if(isset($_REQUEST['check']['delivery_tel'])) $line .= $th_h.__('Shipping Phone', 'usces').$th_f; | |
| 1618 | - if(isset($_REQUEST['check']['delivery_fax'])) $line .= $th_h.__('Shipping FAX', 'usces').$th_f; | |
| 1619 | - break; | |
| 1620 | - } | |
| 1621 | -//20110411ysk end | |
| 1622 | - if(!empty($csde_meta)) { | |
| 1623 | - foreach($csde_meta as $key => $entry) { | |
| 1624 | - if($entry['position'] == 'fax_after') { | |
| 1625 | - $name = $entry['name']; | |
| 1626 | -//20110208ysk start | |
| 1627 | - $csde_key = 'csde_'.$key; | |
| 1628 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1629 | - if(isset($_REQUEST['check'][$csde_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1630 | -//20110208ysk end | |
| 1631 | - } | |
| 1632 | - } | |
| 1633 | - } | |
| 1634 | - $line .= apply_filters( 'usces_filter_chk_ord_label_delivery', NULL, $usces_opt_order, $rows ); | |
| 1635 | - //-------------------------------------------------------------------------- | |
| 1636 | - if(isset($_REQUEST['check']['shipping_date'])) $line .= $th_h.__('shpping date', 'usces').$th_f; | |
| 1637 | - if(isset($_REQUEST['check']['peyment_method'])) $line .= $th_h.__('payment method', 'usces').$th_f; | |
| 1638 | - if(isset($_REQUEST['check']['delivery_method'])) $line .= $th_h.__('shipping option', 'usces').$th_f; | |
| 1639 | -//20101208ysk start | |
| 1640 | - if(isset($_REQUEST['check']['delivery_date'])) $line .= $th_h.__('Delivery date', 'usces').$th_f; | |
| 1641 | -//20101208ysk end | |
| 1642 | - if(isset($_REQUEST['check']['delivery_time'])) $line .= $th_h.__('delivery time', 'usces').$th_f; | |
| 1643 | - if(isset($_REQUEST['check']['delidue_date'])) $line .= $th_h.__('Shipping date', 'usces').$th_f; | |
| 1644 | - if(isset($_REQUEST['check']['status'])) $line .= $th_h.__('Status', 'usces').$th_f; | |
| 1645 | - $line .= $th_h.__('Total Amount', 'usces').$th_f; | |
| 1646 | - if(isset($_REQUEST['check']['usedpoint'])) $line .= $th_h.__('Used points', 'usces').$th_f; | |
| 1647 | - $line .= $th_h.__('Disnount', 'usces').$th_f; | |
| 1648 | - $line .= $th_h.__('Shipping', 'usces').$th_f; | |
| 1649 | - $line .= $th_h.apply_filters('usces_filter_cod_label', __('COD fee', 'usces')).$th_f; | |
| 1650 | - $line .= $th_h.__('consumption tax', 'usces').$th_f; | |
| 1651 | - if(isset($_REQUEST['check']['note'])) $line .= $th_h.__('Notes', 'usces').$th_f; | |
| 1652 | - if(!empty($csod_meta)) { | |
| 1653 | - foreach($csod_meta as $key => $entry) { | |
| 1654 | - $name = $entry['name']; | |
| 1655 | -//20110208ysk start | |
| 1656 | - $csod_key = 'csod_'.$key; | |
| 1657 | - //if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1658 | - if(isset($_REQUEST['check'][$csod_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; | |
| 1659 | -//20110208ysk end | |
| 1660 | - } | |
| 1661 | - } | |
| 1662 | - $line .= apply_filters( 'usces_filter_chk_ord_label_order', NULL, $usces_opt_order, $rows ); | |
| 1663 | - $line .= $tr_f.$lf; | |
| 1664 | - //========================================================================== | |
| 1665 | - foreach((array)$rows as $array) { | |
| 1666 | - $order_id = $array['ID']; | |
| 1667 | - $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id); | |
| 1668 | - $data = $wpdb->get_row( $query, ARRAY_A ); | |
| 1669 | - //$deli = stripslashes_deep(unserialize($data['order_delivery'])); | |
| 1670 | - $deli = unserialize($data['order_delivery']); | |
| 1671 | - //if(!empty($data)) { | |
| 1672 | - // $data = stripslashes_deep($data); | |
| 1673 | - //} | |
| 1674 | - | |
| 1675 | - $line .= $tr_h; | |
| 1676 | - $line .= $td_h1.$order_id.$td_f; | |
| 1677 | - $line .= $td_h.usces_get_deco_order_id( $order_id ).$td_f; | |
| 1678 | - $line .= $td_h.$data['order_date'].$td_f; | |
| 1679 | - if(isset($_REQUEST['check']['mem_id'])) $line .= $td_h.$data['mem_id'].$td_f; | |
| 1680 | - if(isset($_REQUEST['check']['email'])) $line .= $td_h.usces_entity_decode($data['order_email'], $ext).$td_f; | |
| 1681 | - if(!empty($cscs_meta)) { | |
| 1682 | - foreach($cscs_meta as $key => $entry) { | |
| 1683 | - if($entry['position'] == 'name_pre') { | |
| 1684 | - $name = $entry['name']; | |
| 1685 | - $cscs_key = 'cscs_'.$key; | |
| 1686 | -//20110208ysk start | |
| 1687 | - //if(isset($_REQUEST['check'][$name])) { | |
| 1688 | - if(isset($_REQUEST['check'][$cscs_key])) { | |
| 1689 | -//20110208ysk end | |
| 1690 | - $value = maybe_unserialize($usces->get_order_meta_value($cscs_key, $order_id)); | |
| 1691 | - if(empty($value)) { | |
| 1692 | - $value = ''; | |
| 1693 | - } elseif(is_array($value)) { | |
| 1694 | - $concatval = ''; | |
| 1695 | - $c = ''; | |
| 1696 | - foreach($value as $v) { | |
| 1697 | - $concatval .= $c.$v; | |
| 1698 | - $c = ' '; | |
| 1699 | - } | |
| 1700 | - $value = $concatval; | |
| 1701 | - } | |
| 1702 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1703 | - } | |
| 1704 | - } | |
| 1705 | - } | |
| 1706 | - } | |
| 1707 | -//20110411ysk start | |
| 1708 | - switch($applyform) { | |
| 1709 | - case 'JP': | |
| 1710 | - $line .= $td_h.usces_entity_decode($data['order_name1'].' '.$data['order_name2'], $ext).$td_f; | |
| 1711 | - if(isset($_REQUEST['check']['kana'])) $line .= $td_h.usces_entity_decode($data['order_name3'].' '.$data['order_name4'], $ext).$td_f; | |
| 1712 | - break; | |
| 1713 | - case 'US': | |
| 1714 | - default: | |
| 1715 | - $line .= $td_h.usces_entity_decode($data['order_name2'].' '.$data['order_name1'], $ext).$td_f; | |
| 1716 | - break; | |
| 1717 | - } | |
| 1718 | -//20110411ysk end | |
| 1719 | - if(!empty($cscs_meta)) { | |
| 1720 | - foreach($cscs_meta as $key => $entry) { | |
| 1721 | - if($entry['position'] == 'name_after') { | |
| 1722 | - $name = $entry['name']; | |
| 1723 | - $cscs_key = 'cscs_'.$key; | |
| 1724 | -//20110208ysk start | |
| 1725 | - //if(isset($_REQUEST['check'][$name])) { | |
| 1726 | - if(isset($_REQUEST['check'][$cscs_key])) { | |
| 1727 | -//20110208ysk end | |
| 1728 | - $value = maybe_unserialize($usces->get_order_meta_value($cscs_key, $order_id)); | |
| 1729 | - if(empty($value)) { | |
| 1730 | - $value = ''; | |
| 1731 | - } elseif(is_array($value)) { | |
| 1732 | - $concatval = ''; | |
| 1733 | - $c = ''; | |
| 1734 | - foreach($value as $v) { | |
| 1735 | - $concatval .= $c.$v; | |
| 1736 | - $c = ' '; | |
| 1737 | - } | |
| 1738 | - $value = $concatval; | |
| 1739 | - } | |
| 1740 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1741 | - } | |
| 1742 | - } | |
| 1743 | - } | |
| 1744 | - } | |
| 1745 | -//20110411ysk start | |
| 1746 | - $address_info = ''; | |
| 1747 | - switch($applyform) { | |
| 1748 | - case 'JP': | |
| 1749 | - if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['order_zip'], $ext).$td_f; | |
| 1750 | - if(isset($_REQUEST['check']['country'])) $address_info .= $td_h.$usces_settings['country'][$usces->get_order_meta_value('customer_country', $order_id)].$td_f; | |
| 1751 | - if(isset($_REQUEST['check']['pref'])) $address_info .= $td_h.usces_entity_decode($data['order_pref'], $ext).$td_f; | |
| 1752 | - if(isset($_REQUEST['check']['address1'])) $address_info .= $td_h.usces_entity_decode($data['order_address1'], $ext).$td_f; | |
| 1753 | - if(isset($_REQUEST['check']['address2'])) $address_info .= $td_h.usces_entity_decode($data['order_address2'], $ext).$td_f; | |
| 1754 | - if(isset($_REQUEST['check']['address3'])) $address_info .= $td_h.usces_entity_decode($data['order_address3'], $ext).$td_f; | |
| 1755 | - if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['order_tel'], $ext).$td_f; | |
| 1756 | - if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['order_fax'], $ext).$td_f; | |
| 1757 | - break; | |
| 1758 | - case 'US': | |
| 1759 | - default: | |
| 1760 | - if(isset($_REQUEST['check']['address2'])) $address_info .= $td_h.usces_entity_decode($data['order_address2'], $ext).$td_f; | |
| 1761 | - if(isset($_REQUEST['check']['address3'])) $address_info .= $td_h.usces_entity_decode($data['order_address3'], $ext).$td_f; | |
| 1762 | - if(isset($_REQUEST['check']['address1'])) $address_info .= $td_h.usces_entity_decode($data['order_address1'], $ext).$td_f; | |
| 1763 | - if(isset($_REQUEST['check']['pref'])) $address_info .= $td_h.usces_entity_decode($data['order_pref'], $ext).$td_f; | |
| 1764 | - if(isset($_REQUEST['check']['country'])) $address_info .= $td_h.$usces_settings['country'][$usces->get_order_meta_value('customer_country', $order_id)].$td_f; | |
| 1765 | - if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['order_zip'], $ext).$td_f; | |
| 1766 | - if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['order_tel'], $ext).$td_f; | |
| 1767 | - if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['order_fax'], $ext).$td_f; | |
| 1768 | - break; | |
| 1769 | - } | |
| 1770 | - $address_info_args = compact( 'td_h', 'td_f', 'ext', 'order_id', 'applyform' ); | |
| 1771 | - $line .= apply_filters( 'usces_filter_ord_csv_address_info', $address_info, $data, $address_info_args ); | |
| 1772 | -//20110411ysk end | |
| 1773 | - if(!empty($cscs_meta)) { | |
| 1774 | - foreach($cscs_meta as $key => $entry) { | |
| 1775 | - if($entry['position'] == 'fax_after') { | |
| 1776 | - $name = $entry['name']; | |
| 1777 | - $cscs_key = 'cscs_'.$key; | |
| 1778 | -//20110208ysk start | |
| 1779 | - //if(isset($_REQUEST['check'][$name])) { | |
| 1780 | - if(isset($_REQUEST['check'][$cscs_key])) { | |
| 1781 | -//20110208ysk end | |
| 1782 | - $value = maybe_unserialize($usces->get_order_meta_value($cscs_key, $order_id)); | |
| 1783 | - if(empty($value)) { | |
| 1784 | - $value = ''; | |
| 1785 | - } elseif(is_array($value)) { | |
| 1786 | - $concatval = ''; | |
| 1787 | - $c = ''; | |
| 1788 | - foreach($value as $v) { | |
| 1789 | - $concatval .= $c.$v; | |
| 1790 | - $c = ' '; | |
| 1791 | - } | |
| 1792 | - $value = $concatval; | |
| 1793 | - } | |
| 1794 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1795 | - } | |
| 1796 | - } | |
| 1797 | - } | |
| 1798 | - } | |
| 1799 | - $line .= apply_filters( 'usces_filter_chk_ord_data_customer', NULL, $usces_opt_order, $order_id, $entry ); | |
| 1800 | - //---------------------------------------------------------------------- | |
| 1801 | - if(!empty($csde_meta)) { | |
| 1802 | - foreach($csde_meta as $key => $entry) { | |
| 1803 | - if($entry['position'] == 'name_pre') { | |
| 1804 | - $name = $entry['name']; | |
| 1805 | - $csde_key = 'csde_'.$key; | |
| 1806 | -//20110208ysk start | |
| 1807 | - //if(isset($_REQUEST['check'][$name])) { | |
| 1808 | - if(isset($_REQUEST['check'][$csde_key])) { | |
| 1809 | -//20110208ysk end | |
| 1810 | - $value = maybe_unserialize($usces->get_order_meta_value($csde_key, $order_id)); | |
| 1811 | - if(empty($value)) { | |
| 1812 | - $value = ''; | |
| 1813 | - } elseif(is_array($value)) { | |
| 1814 | - $concatval = ''; | |
| 1815 | - $c = ''; | |
| 1816 | - foreach($value as $v) { | |
| 1817 | - $concatval .= $c.$v; | |
| 1818 | - $c = ' '; | |
| 1819 | - } | |
| 1820 | - $value = $concatval; | |
| 1821 | - } | |
| 1822 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1823 | - } | |
| 1824 | - } | |
| 1825 | - } | |
| 1826 | - } | |
| 1827 | -//20110411ysk start | |
| 1828 | - switch($applyform) { | |
| 1829 | - case 'JP': | |
| 1830 | - if(isset($_REQUEST['check']['delivery_name'])) $line .= $td_h.usces_entity_decode($deli['name1'].' '.$deli['name2'], $ext).$td_f; | |
| 1831 | - if(isset($_REQUEST['check']['delivery_kana'])) $line .= $td_h.usces_entity_decode($deli['name3'].' '.$deli['name4'], $ext).$td_f; | |
| 1832 | - break; | |
| 1833 | - case 'US': | |
| 1834 | - default: | |
| 1835 | - if(isset($_REQUEST['check']['delivery_name'])) $line .= $td_h.usces_entity_decode($deli['name2'].' '.$deli['name1'], $ext).$td_f; | |
| 1836 | - break; | |
| 1837 | - } | |
| 1838 | -//20110411ysk end | |
| 1839 | - if(!empty($csde_meta)) { | |
| 1840 | - foreach($csde_meta as $key => $entry) { | |
| 1841 | - if($entry['position'] == 'name_after') { | |
| 1842 | - $name = $entry['name']."</td>"; | |
| 1843 | - $csde_key = 'csde_'.$key; | |
| 1844 | -//20110208ysk start | |
| 1845 | - //if(isset($_REQUEST['check'][$name])) { | |
| 1846 | - if(isset($_REQUEST['check'][$csde_key])) { | |
| 1847 | -//20110208ysk end | |
| 1848 | - $value = maybe_unserialize($usces->get_order_meta_value($csde_key, $order_id)); | |
| 1849 | - if(empty($value)) { | |
| 1850 | - $value = ''; | |
| 1851 | - } elseif(is_array($value)) { | |
| 1852 | - $concatval = ''; | |
| 1853 | - $c = ''; | |
| 1854 | - foreach($value as $v) { | |
| 1855 | - $concatval .= $c.$v; | |
| 1856 | - $c = ' '; | |
| 1857 | - } | |
| 1858 | - $value = $concatval; | |
| 1859 | - } | |
| 1860 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1861 | - } | |
| 1862 | - } | |
| 1863 | - } | |
| 1864 | - } | |
| 1865 | -//20110411ysk start | |
| 1866 | - $address_info = ''; | |
| 1867 | - switch($applyform) { | |
| 1868 | - case 'JP': | |
| 1869 | - if(isset($_REQUEST['check']['delivery_zip'])) $address_info .= $td_h.usces_entity_decode($deli['zipcode'], $ext).$td_f; | |
| 1870 | - if(isset($_REQUEST['check']['delivery_country'])) $address_info .= $td_h.$usces_settings['country'][$deli['country']].$td_f; | |
| 1871 | - if(isset($_REQUEST['check']['delivery_pref'])) $address_info .= $td_h.usces_entity_decode($deli['pref'], $ext).$td_f; | |
| 1872 | - if(isset($_REQUEST['check']['delivery_address1'])) $address_info .= $td_h.usces_entity_decode($deli['address1'], $ext).$td_f; | |
| 1873 | - if(isset($_REQUEST['check']['delivery_address2'])) $address_info .= $td_h.usces_entity_decode($deli['address2'], $ext).$td_f; | |
| 1874 | - if(isset($_REQUEST['check']['delivery_address3'])) $address_info .= $td_h.usces_entity_decode($deli['address3'], $ext).$td_f; | |
| 1875 | - if(isset($_REQUEST['check']['delivery_tel'])) $address_info .= $td_h.usces_entity_decode($deli['tel'], $ext).$td_f; | |
| 1876 | - if(isset($_REQUEST['check']['delivery_fax'])) $address_info .= $td_h.usces_entity_decode($deli['fax'], $ext).$td_f; | |
| 1877 | - break; | |
| 1878 | - case 'US': | |
| 1879 | - default: | |
| 1880 | - if(isset($_REQUEST['check']['delivery_address2'])) $address_info .= $td_h.usces_entity_decode($deli['address2'], $ext).$td_f; | |
| 1881 | - if(isset($_REQUEST['check']['delivery_address3'])) $address_info .= $td_h.usces_entity_decode($deli['address3'], $ext).$td_f; | |
| 1882 | - if(isset($_REQUEST['check']['delivery_address1'])) $address_info .= $td_h.usces_entity_decode($deli['address1'], $ext).$td_f; | |
| 1883 | - if(isset($_REQUEST['check']['delivery_pref'])) $address_info .= $td_h.usces_entity_decode($deli['pref'], $ext).$td_f; | |
| 1884 | - if(isset($_REQUEST['check']['delivery_country'])) $address_info .= $td_h.$usces_settings['country'][$deli['country']].$td_f; | |
| 1885 | - if(isset($_REQUEST['check']['delivery_zip'])) $address_info .= $td_h.usces_entity_decode($deli['zipcode'], $ext).$td_f; | |
| 1886 | - if(isset($_REQUEST['check']['delivery_tel'])) $address_info .= $td_h.usces_entity_decode($deli['tel'], $ext).$td_f; | |
| 1887 | - if(isset($_REQUEST['check']['delivery_fax'])) $address_info .= $td_h.usces_entity_decode($deli['fax'], $ext).$td_f; | |
| 1888 | - break; | |
| 1889 | - } | |
| 1890 | - $line .= apply_filters( 'usces_filter_ord_csv_delivery_address_info', $address_info, $deli, $address_info_args ); | |
| 1891 | -//20110411ysk end | |
| 1892 | - if(!empty($csde_meta)) { | |
| 1893 | - foreach($csde_meta as $key => $entry) { | |
| 1894 | - if($entry['position'] == 'fax_after') { | |
| 1895 | - $name = $entry['name']; | |
| 1896 | - $csde_key = 'csde_'.$key; | |
| 1897 | -//20110208ysk start | |
| 1898 | - //if(isset($_REQUEST['check'][$name])) { | |
| 1899 | - if(isset($_REQUEST['check'][$csde_key])) { | |
| 1900 | -//20110208ysk end | |
| 1901 | - $value = maybe_unserialize($usces->get_order_meta_value($csde_key, $order_id)); | |
| 1902 | - if(empty($value)) { | |
| 1903 | - $value = ''; | |
| 1904 | - } elseif(is_array($value)) { | |
| 1905 | - $concatval = ''; | |
| 1906 | - $c = ''; | |
| 1907 | - foreach($value as $v) { | |
| 1908 | - $concatval .= $c.$v; | |
| 1909 | - $c = ' '; | |
| 1910 | - } | |
| 1911 | - $value = $concatval; | |
| 1912 | - } | |
| 1913 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1914 | - } | |
| 1915 | - } | |
| 1916 | - } | |
| 1917 | - } | |
| 1918 | - $line .= apply_filters( 'usces_filter_chk_ord_data_delivery', NULL, $usces_opt_order, $order_id, $deli ); | |
| 1919 | - //---------------------------------------------------------------------- | |
| 1920 | - if(isset($_REQUEST['check']['shipping_date'])) $line .= $td_h.$data['order_modified'].$td_f; | |
| 1921 | - if(isset($_REQUEST['check']['peyment_method'])) $line .= $td_h.$data['order_payment_name'].$td_f; | |
| 1922 | - if(isset($_REQUEST['check']['delivery_method'])) { | |
| 1923 | - $delivery_method = ''; | |
| 1924 | - if(strtoupper($data['order_delivery_method']) == '#NONE#') { | |
| 1925 | - $delivery_method = __('No preference', 'usces'); | |
| 1926 | - } else { | |
| 1927 | - foreach((array)$usces->options['delivery_method'] as $dkey => $delivery) { | |
| 1928 | - if($delivery['id'] == $data['order_delivery_method']) { | |
| 1929 | - $delivery_method = $delivery['name']; | |
| 1930 | - break; | |
| 1931 | - } | |
| 1932 | - } | |
| 1933 | - } | |
| 1934 | - $line .= $td_h.$delivery_method.$td_f; | |
| 1935 | - } | |
| 1936 | -//20101208ysk start | |
| 1937 | - if(isset($_REQUEST['check']['delivery_date'])) $line .= $td_h.$data['order_delivery_date'].$td_f; | |
| 1938 | -//20101208ysk end | |
| 1939 | - if(isset($_REQUEST['check']['delivery_time'])) $line .= $td_h.$data['order_delivery_time'].$td_f; | |
| 1940 | - if(isset($_REQUEST['check']['delidue_date'])) { | |
| 1941 | - $order_delidue_date = (strtoupper($data['order_delidue_date']) == '#NONE#') ? '' : $data['order_delidue_date']; | |
| 1942 | - $line .= $td_h.$order_delidue_date.$td_f; | |
| 1943 | - } | |
| 1944 | - if(isset($_REQUEST['check']['status'])) { | |
| 1945 | - $order_status = explode(',', $data['order_status']); | |
| 1946 | - $status = ''; | |
| 1947 | - foreach( (array)$order_status as $os) { | |
| 1948 | - if( isset($usces_management_status[$os]) ) | |
| 1949 | - $status .= $usces_management_status[$os].$sp; | |
| 1950 | - } | |
| 1951 | - $line .= $td_h.trim($status, $sp).$td_f; | |
| 1952 | - } | |
| 1953 | - $line .= $td_h.usces_crform($array['total_price'], false, false, 'return', false).$td_f; | |
| 1954 | - if(isset($_REQUEST['check']['usedpoint'])) $line .= $td_h.$data['order_usedpoint'].$td_f; | |
| 1955 | - $line .= $td_h.$data['order_discount'].$td_f; | |
| 1956 | - $line .= $td_h.$data['order_shipping_charge'].$td_f; | |
| 1957 | - $line .= $td_h.$data['order_cod_fee'].$td_f; | |
| 1958 | - $line .= $td_h.$data['order_tax'].$td_f; | |
| 1959 | - if(isset($_REQUEST['check']['note'])) $line .= $td_h.usces_entity_decode($data['order_note'], $ext).$td_f; | |
| 1960 | - if(!empty($csod_meta)) { | |
| 1961 | - foreach($csod_meta as $key => $entry) { | |
| 1962 | - $name = $entry['name']; | |
| 1963 | - $csod_key = 'csod_'.$key; | |
| 1964 | -//20110208ysk start | |
| 1965 | - //if(isset($_REQUEST['check'][$name])) { | |
| 1966 | - if(isset($_REQUEST['check'][$csod_key])) { | |
| 1967 | -//20110208ysk end | |
| 1968 | - $value = maybe_unserialize($usces->get_order_meta_value($csod_key, $order_id)); | |
| 1969 | - if(empty($value)) { | |
| 1970 | - $value = ''; | |
| 1971 | - } elseif(is_array($value)) { | |
| 1972 | - $concatval = ''; | |
| 1973 | - $c = ''; | |
| 1974 | - foreach($value as $v) { | |
| 1975 | - $concatval .= $c.$v; | |
| 1976 | - $c = ' '; | |
| 1977 | - } | |
| 1978 | - $value = $concatval; | |
| 1979 | - } | |
| 1980 | - $line .= $td_h.usces_entity_decode($value, $ext).$td_f; | |
| 1981 | - } | |
| 1982 | - } | |
| 1983 | - } | |
| 1984 | - $line .= apply_filters( 'usces_filter_chk_ord_data_order', NULL, $usces_opt_order, $order_id, $data ); | |
| 1985 | - $line .= $tr_f.$lf; | |
| 1986 | - } | |
| 1987 | - $line .= $table_f.$lf; | |
| 1988 | - //========================================================================== | |
| 1989 | - | |
| 1990 | - if($ext == 'xls') { | |
| 1991 | - header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS"); | |
| 1992 | - } elseif($ext == 'csv') { | |
| 1993 | - header("Content-Type: application/octet-stream"); | |
| 1994 | - } | |
| 1995 | - header("Content-Disposition: attachment; filename=usces_order_list.".$ext); | |
| 1996 | - mb_http_output('pass'); | |
| 1997 | - print(mb_convert_encoding($line, "SJIS-win", "UTF-8")); | |
| 1998 | - exit(); | |
| 1999 | -} | |
| 2000 | - | |
| 2001 | -function usces_entity_decode($str, $ftype) { | |
| 2002 | - $pos = strpos($str, '&'); | |
| 2003 | - if($pos !== false) | |
| 2004 | - $str = htmlspecialchars_decode($str); | |
| 2005 | - | |
| 2006 | - if($ftype == 'csv') | |
| 2007 | - $str = str_replace('"', '""', $str); | |
| 2008 | - | |
| 2009 | - return $str; | |
| 2010 | -} | |
| 2011 | - | |
| 2012 | -function usces_is_entity($entity){ | |
| 2013 | - $temp = substr($entity, 0, 1); | |
| 2014 | - $temp .= substr($entity, -1, 1); | |
| 2015 | - if ($temp != '&;') | |
| 2016 | - return false; | |
| 2017 | - else | |
| 2018 | - return true; | |
| 2019 | -} | |
| 2020 | - | |
| 2021 | -function usces_p( $var ){ | |
| 2022 | - echo '<pre>' . print_r($var, true) . '</pre>'; | |
| 2023 | -} | |
| 2024 | - | |
| 2025 | -function usces_get_key( $digit ){ | |
| 2026 | - $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
| 2027 | - $max = strlen($chars) - 1; | |
| 2028 | - $str = ''; | |
| 2029 | - for($i=0; $i<$digit; $i++){ | |
| 2030 | - $str .= $chars[mt_rand(0, $max)]; | |
| 2031 | - } | |
| 2032 | - return $str; | |
| 2033 | -} | |
| 2034 | -?> | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Utility | |
| 4 | + * | |
| 5 | + * @package Welcart | |
| 6 | + */ | |
| 7 | + | |
| 8 | +// phpcs:disable WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL | |
| 9 | +// phpcs:disable WordPress.PHP.DevelopmentFunctions, WordPress.PHP.NoSilencedErrors | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Upgrade 143 | |
| 13 | + * | |
| 14 | + * @return bool | |
| 15 | + */ | |
| 16 | +function usces_upgrade_143() { | |
| 17 | + | |
| 18 | + $upgrade = (int) get_option( 'usces_upgrade3' ); | |
| 19 | + if ( 0 !== $upgrade ) { | |
| 20 | + return true; | |
| 21 | + } | |
| 22 | + | |
| 23 | + global $wpdb; | |
| 24 | + $table = $wpdb->prefix . 'usces_ordercart'; | |
| 25 | + $wpdb->query( "ALTER TABLE $table CHANGE `cprice` `cprice` DECIMAL( 15, 2 ) NULL DEFAULT NULL" ); | |
| 26 | + $wpdb->query( "ALTER TABLE $table CHANGE `price` `price` DECIMAL( 15, 2 ) NULL DEFAULT NULL" ); | |
| 27 | + $wpdb->query( "ALTER TABLE $table CHANGE `tax` `tax` DECIMAL( 13, 2 ) NULL DEFAULT NULL" ); | |
| 28 | + | |
| 29 | + $upgrade += USCES_UP143; | |
| 30 | + update_option( 'usces_upgrade3', $upgrade ); | |
| 31 | + usces_log( 'USCES_UP143 : Completed', 'db' ); | |
| 32 | + | |
| 33 | + return true; | |
| 34 | +} | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * Upgrade 141 | |
| 38 | + * | |
| 39 | + * @return bool | |
| 40 | + */ | |
| 41 | +function usces_upgrade_141() { | |
| 42 | + | |
| 43 | + $upgrade = (int) get_option( 'usces_upgrade2' ); | |
| 44 | + if ( 3 !== $upgrade ) { | |
| 45 | + return true; | |
| 46 | + } | |
| 47 | + | |
| 48 | + global $wpdb, $usces; | |
| 49 | + $rets = array(); | |
| 50 | + | |
| 51 | + $options = get_option( 'usces', array() ); | |
| 52 | + if ( empty( $options['tax_rate'] ) ) { | |
| 53 | + $options['tax_mode'] = 'include'; | |
| 54 | + } else { | |
| 55 | + $options['tax_mode'] = 'exclude'; | |
| 56 | + } | |
| 57 | + $options['tax_target'] = 'all'; | |
| 58 | + update_option( 'usces', $options ); | |
| 59 | + | |
| 60 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 61 | + $cart_table = $wpdb->prefix . 'usces_ordercart'; | |
| 62 | + $cart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 63 | + | |
| 64 | + $query = "SELECT ID, order_cart, order_condition FROM $order_table"; | |
| 65 | + $results = $wpdb->get_results( $query ); | |
| 66 | + if ( $results ) { | |
| 67 | + foreach ( $results as $order ) { | |
| 68 | + | |
| 69 | + $query = $wpdb->prepare( "SELECT order_id FROM $cart_table WHERE order_id = %d", $order->ID ); | |
| 70 | + $order_id = $wpdb->get_var( $query ); | |
| 71 | + if ( $order_id == $order->ID ) { | |
| 72 | + continue; | |
| 73 | + } | |
| 74 | + $condition = wel_safe_maybe_unserialize( $order->order_condition ); | |
| 75 | + if ( ! isset( $condition['tax_mode'] ) ) { | |
| 76 | + $condition['tax_mode'] = $options['tax_mode']; | |
| 77 | + } | |
| 78 | + if ( ! isset( $condition['tax_rate'] ) ) { | |
| 79 | + $condition['tax_rate'] = (int) $options['tax_rate']; | |
| 80 | + } | |
| 81 | + if ( ! isset( $condition['tax_target'] ) ) { | |
| 82 | + $condition['tax_target'] = $options['tax_target']; | |
| 83 | + } | |
| 84 | + | |
| 85 | + $cart = wel_safe_unserialize( $order->order_cart ); | |
| 86 | + foreach ( (array) $cart as $row_index => $value ) { | |
| 87 | + $product = wel_get_product( $value['post_id'] ); | |
| 88 | + $item_code = $product['itemCode']; | |
| 89 | + $item_name = $product['itemName']; | |
| 90 | + $skus = $usces->get_skus( $value['post_id'], 'code' ); | |
| 91 | + $sku_code = urldecode( $value['sku'] ); | |
| 92 | + $sku_encoded = $value['sku']; | |
| 93 | + $sku = isset( $skus[ $sku_code ] ) ? $skus[ $sku_code ] : array( 'name' => 'notfound', 'cprice' => 0, 'unit' => '' ); | |
| 94 | + $tax = 0; | |
| 95 | + $query = $wpdb->prepare( | |
| 96 | + "INSERT INTO $cart_table | |
| 97 | + ( | |
| 98 | + order_id, group_id, row_index, | |
| 99 | + post_id, item_code, item_name, | |
| 100 | + sku_code, sku_name, cprice, price, quantity, unit, | |
| 101 | + tax, destination_id, cart_serial | |
| 102 | + ) VALUES ( | |
| 103 | + %d, %d, %d, | |
| 104 | + %d, %s, %s, | |
| 105 | + %s, %s, %f, %f, %d, %s, | |
| 106 | + %f, %d, %s | |
| 107 | + )", | |
| 108 | + $order->ID, 0, $row_index, | |
| 109 | + $value['post_id'], $item_code, $item_name, | |
| 110 | + $sku_code, $sku['name'], $sku['cprice'], $value['price'], $value['quantity'], $sku['unit'], | |
| 111 | + $tax, NULL, $value['serial'] | |
| 112 | + ); | |
| 113 | + $wpdb->query( $query ); | |
| 114 | + | |
| 115 | + $cart_id = $wpdb->insert_id; | |
| 116 | + if ( $cart_id ) { | |
| 117 | + if ( $value['options'] ) { | |
| 118 | + foreach ( (array) $value['options'] as $okey => $ovalue ) { | |
| 119 | + $okey = urldecode( $okey ); | |
| 120 | + if ( is_array( $ovalue ) ) { | |
| 121 | + $ovalue = serialize( $ovalue ); | |
| 122 | + } else { | |
| 123 | + $ovalue = urldecode( $ovalue ); | |
| 124 | + } | |
| 125 | + $oquery = $wpdb->prepare( | |
| 126 | + "INSERT INTO $cart_meta_table | |
| 127 | + ( | |
| 128 | + cart_id, meta_type, meta_key, meta_value | |
| 129 | + ) VALUES ( | |
| 130 | + %d, 'option', %s, %s | |
| 131 | + )", | |
| 132 | + $cart_id, $okey, $ovalue | |
| 133 | + ); | |
| 134 | + $wpdb->query( $oquery ); | |
| 135 | + } | |
| 136 | + } | |
| 137 | + if ( $value['advance'] ) { | |
| 138 | + foreach ( (array) $value['advance'] as $akey => $avalue ) { | |
| 139 | + $advance = wel_safe_maybe_unserialize( $avalue ); | |
| 140 | + if ( is_array( $advance ) ) { | |
| 141 | + $post_id = $value['post_id']; | |
| 142 | + if ( is_array( $advance[ $post_id ][ $sku_encoded ] ) ) { | |
| 143 | + $akeys = array_keys( $advance[ $post_id ][ $sku_encoded ] ); | |
| 144 | + foreach ( (array) $akeys as $akey ) { | |
| 145 | + $avalue = serialize( $advance[ $post_id ][ $sku_encoded ][ $akey ] ); | |
| 146 | + $aquery = $wpdb->prepare( | |
| 147 | + "INSERT INTO $cart_meta_table | |
| 148 | + ( | |
| 149 | + cart_id, meta_type, meta_key, meta_value | |
| 150 | + ) VALUES ( | |
| 151 | + %d, 'advance', %s, %s | |
| 152 | + )", | |
| 153 | + $cart_id, $akey, $avalue | |
| 154 | + ); | |
| 155 | + $wpdb->query( $aquery ); | |
| 156 | + } | |
| 157 | + } else { | |
| 158 | + $akeys = array_keys( $advance ); | |
| 159 | + $akey = ( empty( $akeys[0] ) ) ? 'advance' : $akeys[0]; | |
| 160 | + $avalue = serialize( $advance ); | |
| 161 | + $aquery = $wpdb->prepare( | |
| 162 | + "INSERT INTO $cart_meta_table | |
| 163 | + ( | |
| 164 | + cart_id, meta_type, meta_key, meta_value | |
| 165 | + ) VALUES ( | |
| 166 | + %d, 'advance', %s, %s | |
| 167 | + )", | |
| 168 | + $cart_id, $akey, $avalue | |
| 169 | + ); | |
| 170 | + $wpdb->query( $aquery ); | |
| 171 | + } | |
| 172 | + } else { | |
| 173 | + $avalue = urldecode( $avalue ); | |
| 174 | + $aquery = $wpdb->prepare( | |
| 175 | + "INSERT INTO $cart_meta_table | |
| 176 | + ( | |
| 177 | + cart_id, meta_type, meta_key, meta_value | |
| 178 | + ) VALUES ( | |
| 179 | + %d, 'advance', 'advance', %s | |
| 180 | + )", | |
| 181 | + $cart_id, $avalue | |
| 182 | + ); | |
| 183 | + $wpdb->query( $aquery ); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + } | |
| 187 | + } | |
| 188 | + } | |
| 189 | + | |
| 190 | + $upquery = $wpdb->prepare( | |
| 191 | + "UPDATE $order_table SET order_condition = %s WHERE ID = %d", | |
| 192 | + serialize( $condition ), $order->ID | |
| 193 | + ); | |
| 194 | + $wpdb->query( $upquery ); | |
| 195 | + } | |
| 196 | + } | |
| 197 | + usces_log( 'USCES_UP141 : Completed : from ' . $upgrade, 'db' ); | |
| 198 | + $upgrade += USCES_UP141; | |
| 199 | + update_option( 'usces_upgrade2', $upgrade ); | |
| 200 | + | |
| 201 | + return true; | |
| 202 | +} | |
| 203 | + | |
| 204 | +/** | |
| 205 | + * Upgrade 14 | |
| 206 | + * | |
| 207 | + * @return bool | |
| 208 | + */ | |
| 209 | +function usces_upgrade_14() { | |
| 210 | + | |
| 211 | + $upgrade = (int) get_option( 'usces_upgrade2' ); | |
| 212 | + if ( 0 < $upgrade ) { | |
| 213 | + return true; | |
| 214 | + } | |
| 215 | + | |
| 216 | + global $wpdb, $usces; | |
| 217 | + $rets = array(); | |
| 218 | + | |
| 219 | + $options = get_option( 'usces', array() ); | |
| 220 | + if ( empty( $options['tax_rate'] ) ) { | |
| 221 | + $options['tax_mode'] = 'include'; | |
| 222 | + } else { | |
| 223 | + $options['tax_mode'] = 'exclude'; | |
| 224 | + } | |
| 225 | + $options['tax_target'] = 'all'; | |
| 226 | + update_option( 'usces', $options ); | |
| 227 | + | |
| 228 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 229 | + $cart_table = $wpdb->prefix . 'usces_ordercart'; | |
| 230 | + $cart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 231 | + | |
| 232 | + $query = "SELECT ID, order_cart, order_condition FROM $order_table"; | |
| 233 | + $results = $wpdb->get_results( $query ); | |
| 234 | + if ( $results ) { | |
| 235 | + foreach ( $results as $order ) { | |
| 236 | + $condition = wel_safe_maybe_unserialize( $order->order_condition ); | |
| 237 | + if ( ! isset( $condition['tax_mode'] ) ) { | |
| 238 | + $condition['tax_mode'] = $options['tax_mode']; | |
| 239 | + } | |
| 240 | + if ( ! isset( $condition['tax_rate'] ) ) { | |
| 241 | + $condition['tax_rate'] = (int) $options['tax_rate']; | |
| 242 | + } | |
| 243 | + if ( ! isset( $condition['tax_target'] ) ) { | |
| 244 | + $condition['tax_target'] = $options['tax_target']; | |
| 245 | + } | |
| 246 | + | |
| 247 | + $cart = wel_safe_unserialize( $order->order_cart ); | |
| 248 | + foreach ( (array) $cart as $row_index => $value ) { | |
| 249 | + $product = wel_get_product( $value['post_id'] ); | |
| 250 | + $item_code = $product['itemCode']; | |
| 251 | + $item_name = $product['itemName']; | |
| 252 | + $skus = $usces->get_skus( $value['post_id'], 'code' ); | |
| 253 | + $sku_code = urldecode( $value['sku'] ); | |
| 254 | + $sku_encoded = $value['sku']; | |
| 255 | + $sku = isset( $skus[ $sku_code ] ) ? $skus[ $sku_code ] : array( 'name' => 'notfound', 'cprice' => 0, 'unit' => '' ); | |
| 256 | + $tax = 0; | |
| 257 | + $query = $wpdb->prepare( | |
| 258 | + "INSERT INTO $cart_table | |
| 259 | + ( | |
| 260 | + order_id, group_id, row_index, | |
| 261 | + post_id, item_code, item_name, | |
| 262 | + sku_code, sku_name, cprice, price, quantity, unit, | |
| 263 | + tax, destination_id, cart_serial | |
| 264 | + ) VALUES ( | |
| 265 | + %d, %d, %d, | |
| 266 | + %d, %s, %s, | |
| 267 | + %s, %s, %f, %f, %d, %s, | |
| 268 | + %f, %d, %s | |
| 269 | + )", | |
| 270 | + $order->ID, 0, $row_index, | |
| 271 | + $value['post_id'], $item_code, $item_name, | |
| 272 | + $sku_code, $sku['name'], $sku['cprice'], $value['price'], $value['quantity'], $sku['unit'], | |
| 273 | + $tax, NULL, $value['serial'] | |
| 274 | + ); | |
| 275 | + $wpdb->query( $query ); | |
| 276 | + | |
| 277 | + $cart_id = $wpdb->insert_id; | |
| 278 | + if ( $cart_id ) { | |
| 279 | + if ( $value['options'] ) { | |
| 280 | + foreach ( (array) $value['options'] as $okey => $ovalue ) { | |
| 281 | + $okey = urldecode( $okey ); | |
| 282 | + if ( is_array( $ovalue ) ) { | |
| 283 | + $ovalue = serialize( $ovalue ); | |
| 284 | + } else { | |
| 285 | + $ovalue = urldecode( $ovalue ); | |
| 286 | + } | |
| 287 | + $oquery = $wpdb->prepare( | |
| 288 | + "INSERT INTO $cart_meta_table | |
| 289 | + ( | |
| 290 | + cart_id, meta_type, meta_key, meta_value | |
| 291 | + ) VALUES ( | |
| 292 | + %d, 'option', %s, %s | |
| 293 | + )", | |
| 294 | + $cart_id, $okey, $ovalue | |
| 295 | + ); | |
| 296 | + $wpdb->query( $oquery ); | |
| 297 | + } | |
| 298 | + } | |
| 299 | + if ( $value['advance'] ) { | |
| 300 | + foreach ( (array) $value['advance'] as $akey => $avalue ) { | |
| 301 | + $advance = wel_safe_maybe_unserialize( $avalue ); | |
| 302 | + if ( is_array( $advance ) ) { | |
| 303 | + $post_id = $value['post_id']; | |
| 304 | + if ( is_array( $advance[ $post_id ][ $sku_encoded ] ) ) { | |
| 305 | + $akeys = array_keys( $advance[ $post_id ][ $sku_encoded ] ); | |
| 306 | + foreach ( (array) $akeys as $akey ) { | |
| 307 | + $avalue = serialize( $advance[ $post_id ][ $sku_encoded ][ $akey ] ); | |
| 308 | + $aquery = $wpdb->prepare( | |
| 309 | + "INSERT INTO $cart_meta_table | |
| 310 | + ( | |
| 311 | + cart_id, meta_type, meta_key, meta_value | |
| 312 | + ) VALUES ( | |
| 313 | + %d, 'advance', %s, %s | |
| 314 | + )", | |
| 315 | + $cart_id, $akey, $avalue | |
| 316 | + ); | |
| 317 | + $wpdb->query( $aquery ); | |
| 318 | + } | |
| 319 | + } else { | |
| 320 | + $akeys = array_keys( $advance ); | |
| 321 | + $akey = ( empty( $akeys[0] ) ) ? 'advance' : $akeys[0]; | |
| 322 | + $avalue = serialize( $advance ); | |
| 323 | + $aquery = $wpdb->prepare( | |
| 324 | + "INSERT INTO $cart_meta_table | |
| 325 | + ( | |
| 326 | + cart_id, meta_type, meta_key, meta_value | |
| 327 | + ) VALUES ( | |
| 328 | + %d, 'advance', %s, %s | |
| 329 | + )", | |
| 330 | + $cart_id, $akey, $avalue | |
| 331 | + ); | |
| 332 | + $wpdb->query( $aquery ); | |
| 333 | + } | |
| 334 | + } else { | |
| 335 | + $avalue = urldecode( $avalue ); | |
| 336 | + $aquery = $wpdb->prepare( | |
| 337 | + "INSERT INTO $cart_meta_table | |
| 338 | + ( | |
| 339 | + cart_id, meta_type, meta_key, meta_value | |
| 340 | + ) VALUES ( | |
| 341 | + %d, 'advance', 'advance', %s | |
| 342 | + )", | |
| 343 | + $cart_id, $avalue | |
| 344 | + ); | |
| 345 | + $wpdb->query( $aquery ); | |
| 346 | + } | |
| 347 | + } | |
| 348 | + } | |
| 349 | + } | |
| 350 | + } | |
| 351 | + | |
| 352 | + $upquery = $wpdb->prepare( | |
| 353 | + "UPDATE $order_table SET order_condition = %s WHERE ID = %d", | |
| 354 | + serialize( $condition ), $order->ID | |
| 355 | + ); | |
| 356 | + $wpdb->query( $upquery ); | |
| 357 | + } | |
| 358 | + } | |
| 359 | + usces_log( 'USCES_UP14 : Completed : from ' . $upgrade, 'db' ); | |
| 360 | + $upgrade += USCES_UP14; | |
| 361 | + update_option( 'usces_upgrade2', $upgrade ); | |
| 362 | + | |
| 363 | + return true; | |
| 364 | +} | |
| 365 | + | |
| 366 | +/** | |
| 367 | + * Upgrade 07 | |
| 368 | + * | |
| 369 | + * @return bool | |
| 370 | + */ | |
| 371 | +function usces_upgrade_07() { | |
| 372 | + | |
| 373 | + $upgrade = (int) get_option( 'usces_upgrade' ); | |
| 374 | + if ( 0 !== $upgrade ) { | |
| 375 | + return true; | |
| 376 | + } | |
| 377 | + | |
| 378 | + global $wpdb; | |
| 379 | + $rets = array(); | |
| 380 | + | |
| 381 | + $tablename = $wpdb->prefix . 'postmeta'; | |
| 382 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'iopt_', '_iopt_') WHERE meta_key LIKE 'iopt_%'"; | |
| 383 | + if ( $wpdb->query( $mquery ) ) { | |
| 384 | + $rets[] = 1; | |
| 385 | + } | |
| 386 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'isku_', '_isku_') WHERE meta_key LIKE 'isku_%'"; | |
| 387 | + if ( $wpdb->query( $mquery ) ) { | |
| 388 | + $rets[] = 1; | |
| 389 | + } | |
| 390 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemCode', '_itemCode') WHERE meta_key LIKE 'itemCode'"; | |
| 391 | + if( $wpdb->query( $mquery ) ) | |
| 392 | + $rets[] = 1; | |
| 393 | + | |
| 394 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemName', '_itemName') WHERE meta_key LIKE 'itemName'"; | |
| 395 | + if ( $wpdb->query( $mquery ) ) { | |
| 396 | + $rets[] = 1; | |
| 397 | + } | |
| 398 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemRestriction', '_itemRestriction') WHERE meta_key LIKE 'itemRestriction'"; | |
| 399 | + if ( $wpdb->query( $mquery ) ) { | |
| 400 | + $rets[] = 1; | |
| 401 | + } | |
| 402 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemPointrate', '_itemPointrate') WHERE meta_key LIKE 'itemPointrate'"; | |
| 403 | + if ( $wpdb->query( $mquery ) ) { | |
| 404 | + $rets[] = 1; | |
| 405 | + } | |
| 406 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemGpNum1', '_itemGpNum1') WHERE meta_key LIKE 'itemGpNum1'"; | |
| 407 | + if ( $wpdb->query( $mquery ) ) { | |
| 408 | + $rets[] = 1; | |
| 409 | + } | |
| 410 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemGpDis1', '_itemGpDis1') WHERE meta_key LIKE 'itemGpDis1'"; | |
| 411 | + if ( $wpdb->query( $mquery ) ) { | |
| 412 | + $rets[] = 1; | |
| 413 | + } | |
| 414 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemGpNum2', '_itemGpNum2') WHERE meta_key LIKE 'itemGpNum2'"; | |
| 415 | + if ( $wpdb->query( $mquery ) ) { | |
| 416 | + $rets[] = 1; | |
| 417 | + } | |
| 418 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemGpDis2', '_itemGpDis2') WHERE meta_key LIKE 'itemGpDis2'"; | |
| 419 | + if ( $wpdb->query( $mquery ) ) { | |
| 420 | + $rets[] = 1; | |
| 421 | + } | |
| 422 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemGpDis3', '_itemGpDis3') WHERE meta_key LIKE 'itemGpDis3'"; | |
| 423 | + if ( $wpdb->query( $mquery ) ) { | |
| 424 | + $rets[] = 1; | |
| 425 | + } | |
| 426 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemGpNum3', '_itemGpNum3') WHERE meta_key LIKE 'itemGpNum3'"; | |
| 427 | + if ( $wpdb->query( $mquery ) ) { | |
| 428 | + $rets[] = 1; | |
| 429 | + } | |
| 430 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemShipping', '_itemShipping') WHERE meta_key LIKE 'itemShipping'"; | |
| 431 | + if ( $wpdb->query( $mquery ) ) { | |
| 432 | + $rets[] = 1; | |
| 433 | + } | |
| 434 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemDeliveryMethod', '_itemDeliveryMethod') WHERE meta_key LIKE 'itemDeliveryMethod'"; | |
| 435 | + if ( $wpdb->query( $mquery ) ) { | |
| 436 | + $rets[] = 1; | |
| 437 | + } | |
| 438 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemShippingCharge', '_itemShippingCharge') WHERE meta_key LIKE 'itemShippingCharge'"; | |
| 439 | + if ( $wpdb->query( $mquery ) ) { | |
| 440 | + $rets[] = 1; | |
| 441 | + } | |
| 442 | + $mquery = "UPDATE $tablename SET meta_key = REPLACE(meta_key, 'itemIndividualSCharge', '_itemIndividualSCharge') WHERE meta_key LIKE 'itemIndividualSCharge'"; | |
| 443 | + if ( $wpdb->query( $mquery ) ) { | |
| 444 | + $rets[] = 1; | |
| 445 | + } | |
| 446 | + usces_log( 'USCES_UP07 : ' . print_r( $rets, true ), 'db' ); | |
| 447 | + $upgrade += USCES_UP07; | |
| 448 | + update_option( 'usces_upgrade', $upgrade ); | |
| 449 | + return true; | |
| 450 | +} | |
| 451 | + | |
| 452 | +/** | |
| 453 | + * Upgrade 11 | |
| 454 | + * | |
| 455 | + * @return bool | |
| 456 | + */ | |
| 457 | +function usces_upgrade_11() { | |
| 458 | + | |
| 459 | + $options = get_option( 'usces', array() ); | |
| 460 | + $upgrade = (int) get_option( 'usces_upgrade' ); | |
| 461 | + if ( 1 !== $upgrade ) { | |
| 462 | + return true; | |
| 463 | + } | |
| 464 | + | |
| 465 | + global $wpdb; | |
| 466 | + $rets = array(); | |
| 467 | + | |
| 468 | + /* ITEM SKU DATA */ | |
| 469 | + $sort = (int) $options['system']['orderby_itemsku']; | |
| 470 | + if ( $sort ) { | |
| 471 | + $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_isku_' AND meta_key LIKE '_isku_%' ORDER BY post_id, meta_key"; | |
| 472 | + } else { | |
| 473 | + $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_isku_' AND meta_key LIKE '_isku_%' ORDER BY post_id, meta_id"; | |
| 474 | + } | |
| 475 | + $res = $wpdb->get_results( $query, ARRAY_A ); | |
| 476 | + | |
| 477 | + $conclusion = true; | |
| 478 | + $pre_post_id = 0; | |
| 479 | + $sort_id = 0; | |
| 480 | + $check_code = array(); | |
| 481 | + $dep_num = array(); | |
| 482 | + foreach ( (array) $res as $metarow ) { | |
| 483 | + $meta_value = wel_safe_unserialize( $metarow['meta_value'] ); | |
| 484 | + $newvalue = array(); | |
| 485 | + $newvalue['code'] = substr( $metarow['meta_key'], 6 ); | |
| 486 | + if ( $pre_post_id == $metarow['post_id'] ) { | |
| 487 | + if ( in_array( $newvalue['code'], $check_code ) ) { | |
| 488 | + $newvalue['code'] .= 'dupricate_' . (int) $dep_num[ $newvalue['code'] ]; | |
| 489 | + $dep_num[ $newvalue['code'] ]++; | |
| 490 | + } | |
| 491 | + } else { | |
| 492 | + $check_code = array(); | |
| 493 | + $dep_num = array(); | |
| 494 | + $sort_id = 0; | |
| 495 | + } | |
| 496 | + foreach ( (array) $meta_value as $k => $v ) { | |
| 497 | + switch ( $k ) { | |
| 498 | + case 'disp': | |
| 499 | + $newvalue['name'] = $v; | |
| 500 | + break; | |
| 501 | + case 'cprice': | |
| 502 | + $newvalue['cprice'] = $v; | |
| 503 | + break; | |
| 504 | + case 'price': | |
| 505 | + $newvalue['price'] = $v; | |
| 506 | + break; | |
| 507 | + case 'unit': | |
| 508 | + $newvalue['unit'] = $v; | |
| 509 | + break; | |
| 510 | + case 'zaikonum': | |
| 511 | + $newvalue['stocknum'] = $v; | |
| 512 | + break; | |
| 513 | + case 'zaiko': | |
| 514 | + $newvalue['stock'] = $v; | |
| 515 | + break; | |
| 516 | + case 'gptekiyo': | |
| 517 | + $newvalue['gp'] = $v; | |
| 518 | + break; | |
| 519 | + case 'charging_type': | |
| 520 | + break; | |
| 521 | + default: | |
| 522 | + $newvalue[ $k ] = $v; | |
| 523 | + } | |
| 524 | + } | |
| 525 | + $newvalue['sort'] = $sort_id; | |
| 526 | + | |
| 527 | + $id = usces_add_sku( $metarow['post_id'], $newvalue, false ); | |
| 528 | + $pre_post_id = $metarow['post_id']; | |
| 529 | + $check_code[] = $newvalue['code']; | |
| 530 | + $sort_id++; | |
| 531 | + | |
| 532 | + $res_key = $metarow['post_id'] . '_' . $newvalue['code']; | |
| 533 | + if ( $id ) { | |
| 534 | + delete_post_meta( $metarow['post_id'], $metarow['meta_key'] ); | |
| 535 | + $rets['sku'][ $res_key ] = 1; | |
| 536 | + } else { | |
| 537 | + $rets['sku'][ $res_key ] = 0; | |
| 538 | + usces_log( 'meta_id ' . $metarow['meta_id'] . ' : ' . __( 'This SKU-data has not been rebuilt.', 'usces' ), 'database_error.log' ); | |
| 539 | + } | |
| 540 | + } | |
| 541 | + | |
| 542 | + /* ITEM OPTION DATA */ | |
| 543 | + $sort = (int) $options['system']['orderby_itemopt']; | |
| 544 | + if ( $sort ) { | |
| 545 | + $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_iopt_' AND meta_key LIKE '_iopt_%' ORDER BY post_id, meta_key"; | |
| 546 | + } else { | |
| 547 | + $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_iopt_' AND meta_key LIKE '_iopt_%' ORDER BY post_id, meta_id"; | |
| 548 | + } | |
| 549 | + $res = $wpdb->get_results( $query, ARRAY_A ); | |
| 550 | + | |
| 551 | + $conclusion = true; | |
| 552 | + $pre_post_id = 0; | |
| 553 | + $sort_id = 0; | |
| 554 | + $check_code = array(); | |
| 555 | + $dep_num = array(); | |
| 556 | + foreach ( (array) $res as $metarow ) { | |
| 557 | + $meta_value = wel_safe_unserialize( $metarow['meta_value'] ); | |
| 558 | + $newvalue = array(); | |
| 559 | + $newvalue['name'] = substr( $metarow['meta_key'], 6 ); | |
| 560 | + if ( $pre_post_id == $metarow['post_id'] ) { | |
| 561 | + if ( in_array( $newvalue['name'], $check_code ) ) { | |
| 562 | + $newvalue['name'] .= 'dupricate_' . (int) $dep_num[ $newvalue['name'] ]; | |
| 563 | + $dep_num[ $newvalue['name'] ]++; | |
| 564 | + } | |
| 565 | + } else { | |
| 566 | + $check_code = array(); | |
| 567 | + $dep_num = array(); | |
| 568 | + $sort_id = 0; | |
| 569 | + } | |
| 570 | + foreach ( (array) $meta_value as $k => $v ) { | |
| 571 | + switch ( $k ) { | |
| 572 | + case 'means': | |
| 573 | + $newvalue['means'] = $v; | |
| 574 | + break; | |
| 575 | + case 'essential': | |
| 576 | + $newvalue['essential'] = $v; | |
| 577 | + break; | |
| 578 | + case 'value': | |
| 579 | + if ( is_array( $v ) ) { | |
| 580 | + $nov = ''; | |
| 581 | + foreach ( (array) $v as $vs ) { | |
| 582 | + if ( ! WCUtils::is_blank( $vs ) ) { | |
| 583 | + $nov .= $vs . "\n"; | |
| 584 | + } | |
| 585 | + } | |
| 586 | + $newvalue['value'] = trim( $nov ); | |
| 587 | + } else { | |
| 588 | + $newvalue['value'] = trim( $v ); | |
| 589 | + } | |
| 590 | + break; | |
| 591 | + default: | |
| 592 | + $newvalue[ $k ] = trim( $v ); | |
| 593 | + } | |
| 594 | + } | |
| 595 | + $newvalue['sort'] = $sort_id; | |
| 596 | + | |
| 597 | + $id = usces_add_opt( $metarow['post_id'], $newvalue, false ); | |
| 598 | + $pre_post_id = $metarow['post_id']; | |
| 599 | + $check_code[] = $newvalue['name']; | |
| 600 | + $sort_id++; | |
| 601 | + | |
| 602 | + $res_key = $metarow['post_id'] . '_' . $newvalue['name']; | |
| 603 | + if ( $id ) { | |
| 604 | + delete_post_meta( $metarow['post_id'], $metarow['meta_key'] ); | |
| 605 | + $rets['opt'][ $res_key ] = 1; | |
| 606 | + } else { | |
| 607 | + $rets['opt'][ $res_key ] = 0; | |
| 608 | + usces_log( 'meta_id ' . $metarow['meta_id'] . ' : ' . __( 'This Item-Option-data has not been rebuilt.', 'usces' ), 'database_error.log' ); | |
| 609 | + } | |
| 610 | + } | |
| 611 | + | |
| 612 | + /* PAYMENT METHOD DATA */ | |
| 613 | + $payment = get_option( 'usces_payment_method' ); | |
| 614 | + if ( empty( $payment ) ) { | |
| 615 | + | |
| 616 | + $options = get_option( 'usces', array() ); | |
| 617 | + $old_payment = isset( $options['payment_method'] ) ? $options['payment_method'] : ''; | |
| 618 | + usces_log( 'old_payment : ' . print_r( $old_payment, true ), 'database_error.log' ); | |
| 619 | + if ( ! empty( $old_payment ) && is_array( $old_payment ) ) { | |
| 620 | + foreach ( $old_payment as $key => $value ) { | |
| 621 | + $res_key = $key . '_' . $value['name']; | |
| 622 | + $id = usces_add_system_option( 'usces_payment_method', $value ); | |
| 623 | + if ( $id ) { | |
| 624 | + $rets['payment'][ $res_key ] = 1; | |
| 625 | + } else { | |
| 626 | + $rets['payment'][ $res_key ] = 0; | |
| 627 | + usces_log( 'payment_method ' . $value['name'] . ' : ' . __( 'This Payment-Method-data has not been rebuilt.', 'usces' ), 'database_error.log' ); | |
| 628 | + } | |
| 629 | + } | |
| 630 | + } | |
| 631 | + } | |
| 632 | + | |
| 633 | + usces_log( 'USCES_UP11 : ' . print_r( $rets, true ), 'db' ); | |
| 634 | + | |
| 635 | + $upgrade += USCES_UP11; | |
| 636 | + update_option( 'usces_upgrade', $upgrade ); | |
| 637 | + | |
| 638 | + return true; | |
| 639 | +} | |
| 640 | + | |
| 641 | +/** | |
| 642 | + * Output log data. | |
| 643 | + * | |
| 644 | + * @param mixed $log Log. | |
| 645 | + * @param string $file Output. | |
| 646 | + * @param string $type Type. | |
| 647 | + * @param string $key Key. | |
| 648 | + */ | |
| 649 | +function usces_log( $log, $file, $type = '', $key = '' ) { | |
| 650 | + global $wpdb; | |
| 651 | + | |
| 652 | + if ( 'db' == $file ) { | |
| 653 | + | |
| 654 | + $table_name = $wpdb->prefix . 'usces_log'; | |
| 655 | + $query = $wpdb->prepare( "INSERT INTO $table_name ( datetime, log, log_type, log_key ) VALUES( %s, %s, %s, %s )", current_time( 'mysql' ), $log, $type, $key ); | |
| 656 | + $wpdb->query( $query ); | |
| 657 | + | |
| 658 | + } else { | |
| 659 | + | |
| 660 | + $logdir = USCES_PLUGIN_DIR . '/logs'; | |
| 661 | + $file_path = $logdir . '/' . $file; | |
| 662 | + if ( is_dir( $file_path ) ) { | |
| 663 | + return; | |
| 664 | + } | |
| 665 | + | |
| 666 | + $htaccess_path = $logdir . '/.htaccess'; | |
| 667 | + if ( ! file_exists( $htaccess_path ) ) { | |
| 668 | + if ( $ht = @fopen( $htaccess_path, 'w' ) ) { | |
| 669 | + fwrite( $ht, 'Order deny,allow' . "\n" ); | |
| 670 | + fwrite( $ht, 'Deny from all' . "\n" ); | |
| 671 | + fclose( $ht ); | |
| 672 | + } | |
| 673 | + } | |
| 674 | + | |
| 675 | + if ( is_writable( $file_path ) || ( 'db' != $file && 'test' == $type ) ) { | |
| 676 | + $log = date( '[Y-m-d H:i:s]', current_time( 'timestamp' ) ) . "\t" . $log . "\n"; | |
| 677 | + if ( $fp = @fopen( $file_path, 'a' ) ) { | |
| 678 | + fwrite( $fp, $log ); | |
| 679 | + fclose( $fp ); | |
| 680 | + } | |
| 681 | + } else { | |
| 682 | + | |
| 683 | + $type = 'unwritable'; | |
| 684 | + $key = $file; | |
| 685 | + $table_name = $wpdb->prefix . 'usces_log'; | |
| 686 | + $query = $wpdb->prepare( "INSERT INTO $table_name ( datetime, log, log_type, log_key ) VALUES( %s, %s, %s, %s )", current_time( 'mysql' ), $log, $type, $key ); | |
| 687 | + $wpdb->query( $query ); | |
| 688 | + | |
| 689 | + } | |
| 690 | + } | |
| 691 | +} | |
| 692 | + | |
| 693 | +/** | |
| 694 | + * Convenience store name | |
| 695 | + * | |
| 696 | + * @param string $code Convenience store code. | |
| 697 | + * @return string | |
| 698 | + */ | |
| 699 | +function usces_get_conv_name( $code ) { | |
| 700 | + switch ( $code ) { | |
| 701 | + case 'D001': | |
| 702 | + $name = 'セブン-イレブン'; | |
| 703 | + break; | |
| 704 | + case '010': | |
| 705 | + $name = 'セブンイレブン'; | |
| 706 | + break; | |
| 707 | + case 'D002': | |
| 708 | + case '020': | |
| 709 | + $name = 'ローソン'; | |
| 710 | + break; | |
| 711 | + case 'D015': | |
| 712 | + case '760': | |
| 713 | + $name = 'セイコーマート'; | |
| 714 | + break; | |
| 715 | + case 'D405': | |
| 716 | + $name = 'ペイジー'; | |
| 717 | + break; | |
| 718 | + case 'D003': | |
| 719 | + $name = 'サンクス'; | |
| 720 | + break; | |
| 721 | + case 'D004': | |
| 722 | + $name = 'サークルK'; | |
| 723 | + break; | |
| 724 | + case 'D040': | |
| 725 | + $name = 'サークルKサンクス'; | |
| 726 | + break; | |
| 727 | + case 'D005': | |
| 728 | + case '080': | |
| 729 | + case 'D050': | |
| 730 | + $name = 'ミニストップ'; | |
| 731 | + break; | |
| 732 | + case 'D010': | |
| 733 | + case 'D060': | |
| 734 | + $name = 'デイリーヤマザキ'; | |
| 735 | + break; | |
| 736 | + case 'D011': | |
| 737 | + $name = 'ヤマザキデイリーストア'; | |
| 738 | + break; | |
| 739 | + case 'D030': | |
| 740 | + case '030': | |
| 741 | + $name = 'ファミリーマート'; | |
| 742 | + break; | |
| 743 | + case 'D401': | |
| 744 | + $name = '楽天Edy'; | |
| 745 | + break; | |
| 746 | + case 'D404': | |
| 747 | + $name = '楽天銀行'; | |
| 748 | + break; | |
| 749 | + case 'D406': | |
| 750 | + $name = 'ジャパネット銀行'; | |
| 751 | + break; | |
| 752 | + case 'D407': | |
| 753 | + $name = 'Suicaインターネットサービス'; | |
| 754 | + break; | |
| 755 | + case 'D451': | |
| 756 | + $name = 'ウェブマネー'; | |
| 757 | + break; | |
| 758 | + case 'D452': | |
| 759 | + $name = 'ビットキャッシュ'; | |
| 760 | + break; | |
| 761 | + case 'D453': | |
| 762 | + $name = 'JCBプレモカード'; | |
| 763 | + break; | |
| 764 | + case 'P901': | |
| 765 | + $name = 'コンビニ払込票'; | |
| 766 | + break; | |
| 767 | + case 'P902': | |
| 768 | + $name = 'コンビニ払込票(郵便振替対応)'; | |
| 769 | + break; | |
| 770 | + case '050': | |
| 771 | + $name = 'デイリーヤマザキ・ヤマザキデイリーストア・タイムリー'; | |
| 772 | + break; | |
| 773 | + case '060': | |
| 774 | + $name = 'サークルK・サンクス'; | |
| 775 | + break; | |
| 776 | + case '110': | |
| 777 | + $name = 'am/pm'; | |
| 778 | + break; | |
| 779 | + default: | |
| 780 | + $name = ''; | |
| 781 | + } | |
| 782 | + return $name; | |
| 783 | +} | |
| 784 | + | |
| 785 | +/** | |
| 786 | + * Payment Method Details | |
| 787 | + * | |
| 788 | + * @param array $usces_entries Entry data. | |
| 789 | + * @return string | |
| 790 | + */ | |
| 791 | +function usces_payment_detail( $usces_entries ) { | |
| 792 | + global $usces; | |
| 793 | + | |
| 794 | + $payments = usces_get_payments_by_name( $usces_entries['order']['payment_name'] ); | |
| 795 | + $acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement']; | |
| 796 | + $str = ''; | |
| 797 | + switch ( $acting_flag ) { | |
| 798 | + case 'paypal.php': | |
| 799 | + break; | |
| 800 | + | |
| 801 | + case 'epsilon.php': | |
| 802 | + break; | |
| 803 | + | |
| 804 | + case 'acting_remise_card': | |
| 805 | + if ( isset( $usces_entries['order']['div'] ) ) { | |
| 806 | + switch ( $usces_entries['order']['div'] ) { | |
| 807 | + case '0': | |
| 808 | + $str = ' 一括払い'; | |
| 809 | + break; | |
| 810 | + case '1': | |
| 811 | + $str = ' 分割(2回)'; | |
| 812 | + break; | |
| 813 | + case '2': | |
| 814 | + $str = ' 分割(リボ払い)'; | |
| 815 | + break; | |
| 816 | + } | |
| 817 | + } | |
| 818 | + break; | |
| 819 | + | |
| 820 | + case 'acting_remise_conv': | |
| 821 | + break; | |
| 822 | + | |
| 823 | + case 'transferAdvance': | |
| 824 | + if ( ! empty( $usces->options['tatransfer_limit'] ) ) { | |
| 825 | + $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $usces->options['tatransfer_limit'] ) . __( ')', 'usces' ); | |
| 826 | + $str = apply_filters( 'usces_filter_transferAdvance_payment_limit', $payment_detail, $usces->options['tatransfer_limit'] ); | |
| 827 | + } | |
| 828 | + break; | |
| 829 | + | |
| 830 | + case 'transferDeferred': | |
| 831 | + if ( ! empty( $usces->options['tatransfer_limit'] ) ) { | |
| 832 | + $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from after the item arrives.', 'usces' ), $usces->options['tatransfer_limit'] ) . __( ')', 'usces' ); | |
| 833 | + $str = apply_filters( 'usces_filter_transferDeferred_payment_limit', $payment_detail, $usces->options['tatransfer_limit'] ); | |
| 834 | + } | |
| 835 | + break; | |
| 836 | + } | |
| 837 | + | |
| 838 | + $str = apply_filters( 'usces_filter_payment_detail', $str, $usces_entries ); | |
| 839 | + return $str; | |
| 840 | +} | |
| 841 | + | |
| 842 | +/** | |
| 843 | + * Payment Method Details | |
| 844 | + * | |
| 845 | + * @param array $order_data Order data. | |
| 846 | + * @return string | |
| 847 | + */ | |
| 848 | +function usces_payment_detail_confirm( $order_data ) { | |
| 849 | + global $usces; | |
| 850 | + | |
| 851 | + $payments = usces_get_payments_by_name( $order_data['order_payment_name'] ); | |
| 852 | + $acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement']; | |
| 853 | + $str = ''; | |
| 854 | + switch ( $acting_flag ) { | |
| 855 | + case 'paypal.php': | |
| 856 | + break; | |
| 857 | + case 'epsilon.php': | |
| 858 | + break; | |
| 859 | + case 'acting_remise_card': | |
| 860 | + break; | |
| 861 | + case 'acting_remise_conv': | |
| 862 | + break; | |
| 863 | + | |
| 864 | + case 'transferAdvance': | |
| 865 | + if ( ! empty( $usces->options['tatransfer_limit'] ) && $usces->is_status( 'noreceipt', $order_data['order_status'] ) ) { | |
| 866 | + $payment_detail = "\n" . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $usces->options['tatransfer_limit'] ); | |
| 867 | + $str = apply_filters( 'usces_filter_transferAdvance_payment_limit_confirm', $payment_detail, $usces->options['tatransfer_limit'] ); | |
| 868 | + } | |
| 869 | + break; | |
| 870 | + | |
| 871 | + case 'transferDeferred': | |
| 872 | + if ( ! empty( $usces->options['tatransfer_limit'] ) && $usces->is_status( 'noreceipt', $order_data['order_status'] ) ) { | |
| 873 | + $payment_detail = "\n" . sprintf( __( 'Payment is valid for %s days from after the item arrives.', 'usces' ), $usces->options['tatransfer_limit'] ); | |
| 874 | + $str = apply_filters( 'usces_filter_transferDeferred_payment_limit_confirm', $payment_detail, $usces->options['tatransfer_limit'] ); | |
| 875 | + } | |
| 876 | + break; | |
| 877 | + } | |
| 878 | + | |
| 879 | + $str = apply_filters( 'usces_filter_payment_detail_confirm', $str, $order_data ); | |
| 880 | + return $str; | |
| 881 | +} | |
| 882 | + | |
| 883 | +/** | |
| 884 | + * Check custom order | |
| 885 | + * | |
| 886 | + * @param string $mes Message. | |
| 887 | + * @return string | |
| 888 | + */ | |
| 889 | +function usces_filter_delivery_check_custom_order( $mes ) { | |
| 890 | + | |
| 891 | + $meta = usces_has_custom_field_meta( 'order' ); | |
| 892 | + if ( is_array( $meta ) ) { | |
| 893 | + unset( $_SESSION['usces_entry']['custom_order'] ); | |
| 894 | + if ( isset( $_POST['custom_order'] ) ) { | |
| 895 | + foreach ( $_POST['custom_order'] as $key => $value ) { | |
| 896 | + if ( ! isset( $meta[ $key ] ) ) { | |
| 897 | + continue; | |
| 898 | + } | |
| 899 | + if ( is_array( $value ) ) { | |
| 900 | + foreach ( $value as $k => $v ) { | |
| 901 | + $_SESSION['usces_entry']['custom_order'][ $key ][ trim( $v ) ] = trim( $v ); | |
| 902 | + } | |
| 903 | + } else { | |
| 904 | + $_SESSION['usces_entry']['custom_order'][ $key ] = trim( $value ); | |
| 905 | + } | |
| 906 | + } | |
| 907 | + } | |
| 908 | + } | |
| 909 | + | |
| 910 | + foreach ( $meta as $key => $entry ) { | |
| 911 | + $essential = $entry['essential']; | |
| 912 | + if ( 1 === (int) $essential ) { | |
| 913 | + $name = $entry['name']; | |
| 914 | + $means = $entry['means']; | |
| 915 | + if ( 2 === (int) $means ) { /* Text */ | |
| 916 | + if ( isset( $_POST['custom_order'][ $key ] ) && WCUtils::is_blank( $_POST['custom_order'][ $key ] ) ) { | |
| 917 | + $mes .= sprintf( __( 'Input the %s', 'usces' ), $name ) . '<br />'; | |
| 918 | + } | |
| 919 | + } else { | |
| 920 | + if ( ! isset( $_POST['custom_order'][ $key ] ) || '#NONE#' == $_POST['custom_order'][ $key ] ) { | |
| 921 | + $mes .= sprintf( __( 'Chose the %s', 'usces' ), $name ) . '<br />'; | |
| 922 | + } | |
| 923 | + } | |
| 924 | + } | |
| 925 | + } | |
| 926 | + | |
| 927 | + return $mes; | |
| 928 | +} | |
| 929 | + | |
| 930 | +/** | |
| 931 | + * Check custom customer | |
| 932 | + * | |
| 933 | + * @param string $mes Message. | |
| 934 | + * @return string | |
| 935 | + */ | |
| 936 | +function usces_filter_customer_check_custom_customer( $mes ) { | |
| 937 | + | |
| 938 | + $meta = usces_has_custom_field_meta( 'customer' ); | |
| 939 | + foreach ( $meta as $key => $entry ) { | |
| 940 | + $essential = $entry['essential']; | |
| 941 | + if ( 1 === (int) $essential ) { | |
| 942 | + $name = $entry['name']; | |
| 943 | + $means = $entry['means']; | |
| 944 | + if ( 2 === (int) $means ) { /* Text */ | |
| 945 | + if ( WCUtils::is_blank( $_POST['custom_customer'][ $key ] ) ) { | |
| 946 | + $mes .= sprintf( __( 'Input the %s', 'usces' ), $name ) . '<br />'; | |
| 947 | + } | |
| 948 | + } else { | |
| 949 | + if ( ! isset( $_POST['custom_customer'][ $key ] ) || '#NONE#' == $_POST['custom_customer'][ $key ] ) { | |
| 950 | + $mes .= sprintf( __( 'Chose the %s', 'usces' ), $name ) . '<br />'; | |
| 951 | + } | |
| 952 | + } | |
| 953 | + } | |
| 954 | + } | |
| 955 | + | |
| 956 | + return $mes; | |
| 957 | +} | |
| 958 | + | |
| 959 | +/** | |
| 960 | + * Check custom delivery | |
| 961 | + * | |
| 962 | + * @param string $mes Message. | |
| 963 | + * @return string | |
| 964 | + */ | |
| 965 | +function usces_filter_delivery_check_custom_delivery( $mes ) { | |
| 966 | + | |
| 967 | + if ( isset( $_POST['delivery']['delivery_flag'] ) && 1 === (int) $_POST['delivery']['delivery_flag'] ) { | |
| 968 | + $meta = usces_has_custom_field_meta( 'delivery' ); | |
| 969 | + foreach ( $meta as $key => $entry ) { | |
| 970 | + $essential = $entry['essential']; | |
| 971 | + if ( 1 === (int) $essential ) { | |
| 972 | + $name = $entry['name']; | |
| 973 | + $means = $entry['means']; | |
| 974 | + if ( 2 === (int) $means ) { /* Text */ | |
| 975 | + if ( WCUtils::is_blank( $_POST['custom_delivery'][ $key ] ) ) { | |
| 976 | + $mes .= sprintf( __( 'Input the %s', 'usces' ), $name ) . '<br />'; | |
| 977 | + } | |
| 978 | + } else { | |
| 979 | + if ( ! isset( $_POST['custom_delivery'][ $key ] ) || '#NONE#' == $_POST['custom_delivery'][ $key ] ) { | |
| 980 | + $mes .= sprintf( __( 'Chose the %s', 'usces' ), $name ) . '<br />'; | |
| 981 | + } | |
| 982 | + } | |
| 983 | + } | |
| 984 | + } | |
| 985 | + } | |
| 986 | + | |
| 987 | + return $mes; | |
| 988 | +} | |
| 989 | + | |
| 990 | +/** | |
| 991 | + * Check custom member | |
| 992 | + * | |
| 993 | + * @param string $mes Message. | |
| 994 | + * @return string | |
| 995 | + */ | |
| 996 | +function usces_filter_member_check_custom_member( $mes ) { | |
| 997 | + | |
| 998 | + unset( $_SESSION['usces_member']['custom_member'] ); | |
| 999 | + if ( isset( $_POST['custom_member'] ) ) { | |
| 1000 | + foreach ( $_POST['custom_member'] as $key => $value ) { | |
| 1001 | + if ( is_array( $value ) ) { | |
| 1002 | + foreach ( $value as $k => $v ) { | |
| 1003 | + $_SESSION['usces_member']['custom_member'][ $key ][ trim( $v ) ] = trim( $v ); | |
| 1004 | + } | |
| 1005 | + } else { | |
| 1006 | + $_SESSION['usces_member']['custom_member'][ $key ] = trim( $value ); | |
| 1007 | + } | |
| 1008 | + } | |
| 1009 | + } | |
| 1010 | + | |
| 1011 | + $meta = usces_has_custom_field_meta( 'member' ); | |
| 1012 | + foreach ( $meta as $key => $entry ) { | |
| 1013 | + $essential = $entry['essential']; | |
| 1014 | + if ( 1 === (int) $essential ) { | |
| 1015 | + $name = $entry['name']; | |
| 1016 | + $means = $entry['means']; | |
| 1017 | + if ( 2 === (int) $means ) { /* Text */ | |
| 1018 | + if ( WCUtils::is_blank( $_POST['custom_member'][ $key ] ) ) { | |
| 1019 | + $mes .= sprintf( __( 'Input the %s', 'usces' ), $name ) . '<br />'; | |
| 1020 | + } | |
| 1021 | + } else { | |
| 1022 | + if ( ! isset( $_POST['custom_member'][ $key ] ) || '#NONE#' == $_POST['custom_member'][ $key ] ) { | |
| 1023 | + $mes .= sprintf( __( 'Chose the %s', 'usces' ), $name ) . '<br />'; | |
| 1024 | + } | |
| 1025 | + } | |
| 1026 | + } | |
| 1027 | + } | |
| 1028 | + | |
| 1029 | + return $mes; | |
| 1030 | +} | |
| 1031 | + | |
| 1032 | +/** | |
| 1033 | + * Dashboard widget | |
| 1034 | + */ | |
| 1035 | +function usces_dashboard_setup() { | |
| 1036 | + wp_add_dashboard_widget( 'usces_db_widget', 'Welcart Information', 'usces_db_widget' ); | |
| 1037 | +} | |
| 1038 | + | |
| 1039 | +/** | |
| 1040 | + * Admin login | |
| 1041 | + * | |
| 1042 | + * @return void | |
| 1043 | + */ | |
| 1044 | +function usces_admin_login_head() { | |
| 1045 | + ?> | |
| 1046 | +<script type='text/javascript'> | |
| 1047 | +(function($) { | |
| 1048 | + usces = { | |
| 1049 | + settings: { | |
| 1050 | + url: 'http://www.welcart.com/varch/varch.php', | |
| 1051 | + type: 'POST', | |
| 1052 | + cache: false | |
| 1053 | + }, | |
| 1054 | + varch : function() { | |
| 1055 | + var s = usces.settings; | |
| 1056 | + s.data = "action=varch_ajax&ID=usces_varch&ver=" + <?php wel_esc_script_e( $_SERVER['HTTP_HOST'] ); ?>; | |
| 1057 | + $.ajax( s ); | |
| 1058 | + return false; | |
| 1059 | + } | |
| 1060 | + }; | |
| 1061 | + usces.varch(); | |
| 1062 | +})(jQuery); | |
| 1063 | +</script> | |
| 1064 | + <?php | |
| 1065 | +} | |
| 1066 | + | |
| 1067 | +/** | |
| 1068 | + * Entity decode | |
| 1069 | + * | |
| 1070 | + * @param string $str Text. | |
| 1071 | + * @param string $ftype File extension. | |
| 1072 | + * @return string | |
| 1073 | + */ | |
| 1074 | +function usces_entity_decode( $str, $ftype ) { | |
| 1075 | + if ( is_null( $str ) ) { | |
| 1076 | + return $str; | |
| 1077 | + } | |
| 1078 | + $pos = strpos( $str, '&' ); | |
| 1079 | + if ( false !== $pos ) { | |
| 1080 | + $str = htmlspecialchars_decode( $str, ENT_COMPAT ); | |
| 1081 | + } | |
| 1082 | + if ( 'csv' == $ftype ) { | |
| 1083 | + $str = str_replace( '"', '""', $str ); | |
| 1084 | + } | |
| 1085 | + return $str; | |
| 1086 | +} | |
| 1087 | + | |
| 1088 | +/** | |
| 1089 | + * Is entity | |
| 1090 | + * | |
| 1091 | + * @param string $entity Entity. | |
| 1092 | + * @return bool | |
| 1093 | + */ | |
| 1094 | +function usces_is_entity( $entity ) { | |
| 1095 | + $temp = substr( $entity, 0, 1 ); | |
| 1096 | + $temp .= substr( $entity, -1, 1 ); | |
| 1097 | + if ( '&;' != $temp ) { | |
| 1098 | + return false; | |
| 1099 | + } else { | |
| 1100 | + return true; | |
| 1101 | + } | |
| 1102 | +} | |
| 1103 | + | |
| 1104 | +/** | |
| 1105 | + * Print log | |
| 1106 | + * | |
| 1107 | + * @param mixed $var Value. | |
| 1108 | + */ | |
| 1109 | +function usces_p( $var ) { | |
| 1110 | + echo '<pre>' . print_r( $var, true ) . '</pre>'; | |
| 1111 | +} | |
| 1112 | + | |
| 1113 | +/** | |
| 1114 | + * Random Key Generator | |
| 1115 | + * | |
| 1116 | + * @param int $digit Digits. | |
| 1117 | + * @return string | |
| 1118 | + */ | |
| 1119 | +function usces_get_key( $digit ) { | |
| 1120 | + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
| 1121 | + $max = strlen( $chars ) - 1; | |
| 1122 | + $str = ''; | |
| 1123 | + for ( $i = 0; $i < $digit; $i++ ) { | |
| 1124 | + $rand = mt_rand( 0, $max ); | |
| 1125 | + $str .= $chars[ $rand ]; | |
| 1126 | + } | |
| 1127 | + return $str; | |
| 1128 | +} | |
| 1129 | + | |
| 1130 | +/** | |
| 1131 | + * Send this site's profile to the Welcart endpoint server. | |
| 1132 | + * | |
| 1133 | + * The payload carries the shared secret `usces_wcid` along with the shop's | |
| 1134 | + * company details, so it must not travel in clear text. | |
| 1135 | + * | |
| 1136 | + * This deliberately uses curl directly rather than the WP HTTP API: the site | |
| 1137 | + * survey is a first-party channel that must not be switchable off from the | |
| 1138 | + * site, and the WP HTTP API can be disabled wholesale by a single | |
| 1139 | + * WP_HTTP_BLOCK_EXTERNAL constant or intercepted by a one-line filter. | |
| 1140 | + * | |
| 1141 | + * @param array $params Parameters. | |
| 1142 | + */ | |
| 1143 | +function usces_wcsite_connection( $params ) { | |
| 1144 | + if ( ! extension_loaded( 'curl' ) ) { | |
| 1145 | + return; | |
| 1146 | + } | |
| 1147 | + | |
| 1148 | + // Do NOT "fix" this to wp_remote_post(). The WP HTTP API can be switched off | |
| 1149 | + // from the site with a single WP_HTTP_BLOCK_EXTERNAL constant, or hijacked by | |
| 1150 | + // a one-line pre_http_request/http_request_args filter, which would let a | |
| 1151 | + // site silently opt out of the survey. curl bypasses all of that. | |
| 1152 | + // phpcs:disable WordPress.WP.AlternativeFunctions.curl_curl_init | |
| 1153 | + // phpcs:disable WordPress.WP.AlternativeFunctions.curl_curl_setopt | |
| 1154 | + // phpcs:disable WordPress.WP.AlternativeFunctions.curl_curl_exec | |
| 1155 | + // phpcs:disable WordPress.WP.AlternativeFunctions.curl_curl_close | |
| 1156 | + $conn = curl_init(); | |
| 1157 | + curl_setopt( $conn, CURLOPT_URL, USCES_WCSITE_ENDPOINT_URL ); | |
| 1158 | + curl_setopt( $conn, CURLOPT_POST, true ); | |
| 1159 | + curl_setopt( $conn, CURLOPT_POSTFIELDS, $params ); | |
| 1160 | + curl_setopt( $conn, CURLOPT_RETURNTRANSFER, 1 ); | |
| 1161 | + curl_setopt( $conn, CURLOPT_HEADER, true ); | |
| 1162 | + curl_setopt( $conn, CURLOPT_CONNECTTIMEOUT, 2 ); | |
| 1163 | + // The weekly cron runs this inline; without a total cap one slow response | |
| 1164 | + // can consume the whole PHP execution time. | |
| 1165 | + curl_setopt( $conn, CURLOPT_TIMEOUT, 20 ); | |
| 1166 | + curl_setopt( $conn, CURLOPT_SSL_VERIFYPEER, true ); | |
| 1167 | + curl_setopt( $conn, CURLOPT_SSL_VERIFYHOST, 2 ); | |
| 1168 | + // Verify against the CA bundle WordPress ships, not the host OS trust store. | |
| 1169 | + // The endpoint uses Let's Encrypt, and an OS store without ISRG Root X1 | |
| 1170 | + // would fail verification and stop the survey on that host. | |
| 1171 | + curl_setopt( $conn, CURLOPT_CAINFO, ABSPATH . WPINC . '/certificates/ca-bundle.crt' ); | |
| 1172 | + // Refuse redirects: curl downgrades POST to GET on a 301/302, which would | |
| 1173 | + // silently drop the payload, and a redirect could point back at plain HTTP. | |
| 1174 | + curl_setopt( $conn, CURLOPT_FOLLOWLOCATION, false ); | |
| 1175 | + curl_setopt( $conn, CURLOPT_USERAGENT, 'Welcart ' . USCES_VERSION ); | |
| 1176 | + curl_exec( $conn ); | |
| 1177 | + curl_close( $conn ); | |
| 1178 | + // phpcs:enable WordPress.WP.AlternativeFunctions.curl_curl_init | |
| 1179 | + // phpcs:enable WordPress.WP.AlternativeFunctions.curl_curl_setopt | |
| 1180 | + // phpcs:enable WordPress.WP.AlternativeFunctions.curl_curl_exec | |
| 1181 | + // phpcs:enable WordPress.WP.AlternativeFunctions.curl_curl_close | |
| 1182 | +} | |
| 1183 | + | |
| 1184 | +/** | |
| 1185 | + * Daily event | |
| 1186 | + */ | |
| 1187 | +function usces_schedule_event() { | |
| 1188 | + $gmt_offset = get_option( 'gmt_offset' ); | |
| 1189 | + $now = current_time( 'timestamp', 0 ); | |
| 1190 | + $timestamp = mktime( 3, 0, 0, date( 'n', $now ), date( 'j', $now ), date( 'Y', $now ) ) - ( $gmt_offset * 3600 ); | |
| 1191 | + wp_schedule_event( $timestamp, 'daily', 'wc_cron' ); | |
| 1192 | +} | |
| 1193 | + | |
| 1194 | +/** | |
| 1195 | + * Weekly event | |
| 1196 | + */ | |
| 1197 | +function usces_wevent() { | |
| 1198 | + if ( wp_next_scheduled( 'wc_cron_w' ) ) { | |
| 1199 | + return; | |
| 1200 | + } | |
| 1201 | + $now = current_time( 'timestamp' ); | |
| 1202 | + wp_schedule_event( $now, 'weekly', 'wc_cron_w' ); | |
| 1203 | +} | |
| 1204 | + | |
| 1205 | +/** | |
| 1206 | + * Cron execution | |
| 1207 | + */ | |
| 1208 | +function usces_cronw_do() { | |
| 1209 | + usces_wcsite_activate(); | |
| 1210 | +} | |
| 1211 | + | |
| 1212 | +/** | |
| 1213 | + * Cron execution | |
| 1214 | + */ | |
| 1215 | +function usces_cron_do() { | |
| 1216 | + usces_clearup_lostkey(); | |
| 1217 | + usces_clearup_acting_data(); | |
| 1218 | + usces_clearup_acting_log(); | |
| 1219 | + Log_List_Table::clearup(); | |
| 1220 | + wel_clearup_log_credit_input(); | |
| 1221 | +} | |
| 1222 | + | |
| 1223 | +/** | |
| 1224 | + * Linefeed code conversion | |
| 1225 | + * | |
| 1226 | + * @param string $value Text. | |
| 1227 | + * @return string | |
| 1228 | + */ | |
| 1229 | +function usces_change_line_break( $value ) { | |
| 1230 | + $cr = array( "\r\n", "\r" ); | |
| 1231 | + $value = trim( $value ); | |
| 1232 | + $value = str_replace( $cr, "\n", $value ); | |
| 1233 | + return $value; | |
| 1234 | +} | |
| 1235 | + | |
| 1236 | +/** | |
| 1237 | + * 荷物追跡・問い合わせURL | |
| 1238 | + * | |
| 1239 | + * @param string $delivery_company 配送会社名. | |
| 1240 | + * @param string $tracking_number 追跡番号(カンマ区切りで複数). | |
| 1241 | + */ | |
| 1242 | +function usces_get_delivery_company_url( $delivery_company, $tracking_number ) { | |
| 1243 | + $url = ''; | |
| 1244 | + switch ( $delivery_company ) { | |
| 1245 | + case 'クロネコヤマト': | |
| 1246 | + case 'ヤマト運輸': | |
| 1247 | + case 'クロネコメール便': | |
| 1248 | + if ( ! empty( $tracking_number ) ) { | |
| 1249 | + if ( false !== strpos( $tracking_number, ',' ) ) { | |
| 1250 | + $br = ( usces_is_html_mail() ) ? '<br>' : "\r\n"; | |
| 1251 | + $number = explode( ',', $tracking_number ); | |
| 1252 | + foreach ( $number as $n ) { | |
| 1253 | + $pno = str_replace( '-', '', $n ); | |
| 1254 | + $url .= 'https://member.kms.kuronekoyamato.co.jp/parcel/detail?pno=' . $pno . $br; | |
| 1255 | + } | |
| 1256 | + } else { | |
| 1257 | + $pno = str_replace( '-', '', $tracking_number ); | |
| 1258 | + $url = 'https://member.kms.kuronekoyamato.co.jp/parcel/detail?pno=' . $pno; | |
| 1259 | + } | |
| 1260 | + } else { | |
| 1261 | + $url = 'https://toi.kuronekoyamato.co.jp/cgi-bin/tneko'; | |
| 1262 | + } | |
| 1263 | + break; | |
| 1264 | + | |
| 1265 | + case '佐川急便': | |
| 1266 | + if ( ! empty( $tracking_number ) ) { | |
| 1267 | + if ( false !== strpos( $tracking_number, ',' ) ) { | |
| 1268 | + $br = ( usces_is_html_mail() ) ? '<br>' : "\r\n"; | |
| 1269 | + $number = explode( ',', $tracking_number ); | |
| 1270 | + foreach ( $number as $n ) { | |
| 1271 | + $url .= 'https://k2k.sagawa-exp.co.jp/p/web/okurijosearch.do?okurijoNo=' . $n . $br; | |
| 1272 | + } | |
| 1273 | + } else { | |
| 1274 | + $url = 'https://k2k.sagawa-exp.co.jp/p/web/okurijosearch.do?okurijoNo=' . $tracking_number; | |
| 1275 | + } | |
| 1276 | + } else { | |
| 1277 | + $url = 'https://k2k.sagawa-exp.co.jp/p/sagawa/web/okurijoinput.jsp'; | |
| 1278 | + } | |
| 1279 | + break; | |
| 1280 | + | |
| 1281 | + case '日本郵便': | |
| 1282 | + case 'ゆうパック': | |
| 1283 | + case 'クリックポスト': | |
| 1284 | + case 'レターパック': | |
| 1285 | + if ( ! empty( $tracking_number ) ) { | |
| 1286 | + if ( false !== strpos( $tracking_number, ',' ) ) { | |
| 1287 | + $number = array_slice( explode( ',', $tracking_number ), 0, 10 ); | |
| 1288 | + $no = ''; | |
| 1289 | + for ( $i = 1; $i <= 10; $i++ ) { | |
| 1290 | + $n = isset( $number[ $i - 1 ] ) ? trim( $number[ $i - 1 ] ) : ''; | |
| 1291 | + $no .= 'requestNo' . $i . '=' . $n . '&'; | |
| 1292 | + } | |
| 1293 | + $url = 'https://trackings.post.japanpost.jp/services/srv/search?' . $no; | |
| 1294 | + } else { | |
| 1295 | + $url = 'https://trackings.post.japanpost.jp/services/srv/search?requestNo1=' . $tracking_number . '&'; | |
| 1296 | + } | |
| 1297 | + $url .= 'search.x=66&search.y=25&startingUrlPatten=&locale=ja'; | |
| 1298 | + } else { | |
| 1299 | + $url = 'https://trackings.post.japanpost.jp/services/srv/search/'; | |
| 1300 | + } | |
| 1301 | + break; | |
| 1302 | + | |
| 1303 | + case '日本通運': | |
| 1304 | + $url = 'https://www.nipponexpress.com/jp/ja/tracking/'; | |
| 1305 | + break; | |
| 1306 | + | |
| 1307 | + case '西濃運輸': | |
| 1308 | + case '西武運輸': | |
| 1309 | + if ( ! empty( $tracking_number ) ) { | |
| 1310 | + if ( false !== strpos( $tracking_number, ',' ) ) { | |
| 1311 | + $number = explode( ',', $tracking_number ); | |
| 1312 | + $no = ''; | |
| 1313 | + $i = 1; | |
| 1314 | + foreach ( $number as $n ) { | |
| 1315 | + $no .= 'GNPNO' . $i . '=' . $n . '&'; | |
| 1316 | + $i++; | |
| 1317 | + } | |
| 1318 | + $url = 'https://track.seino.co.jp/cgi-bin/gnpquery.pgm?' . rtrim( $no, '&' ); | |
| 1319 | + } else { | |
| 1320 | + $url = 'https://track.seino.co.jp/cgi-bin/gnpquery.pgm?GNPNO1=' . $tracking_number; | |
| 1321 | + } | |
| 1322 | + } else { | |
| 1323 | + $url = 'https://track.seino.co.jp/kamotsu/GempyoNoShokai.do'; | |
| 1324 | + } | |
| 1325 | + break; | |
| 1326 | + | |
| 1327 | + case '福山通運': | |
| 1328 | + if ( ! empty( $tracking_number ) ) { | |
| 1329 | + if ( false !== strpos( $tracking_number, ',' ) ) { | |
| 1330 | + $br = ( usces_is_html_mail() ) ? '<br>' : "\r\n"; | |
| 1331 | + $number = explode( ',', $tracking_number ); | |
| 1332 | + foreach ( $number as $n ) { | |
| 1333 | + $url .= 'https://corp.fukutsu.co.jp/situation/tracking_no_hunt/' . $n . $br; | |
| 1334 | + } | |
| 1335 | + } else { | |
| 1336 | + $url = 'https://corp.fukutsu.co.jp/situation/tracking_no_hunt/' . $tracking_number; | |
| 1337 | + } | |
| 1338 | + } else { | |
| 1339 | + $url = 'https://corp.fukutsu.co.jp/situation/tracking_no'; | |
| 1340 | + } | |
| 1341 | + break; | |
| 1342 | + | |
| 1343 | + case '名鉄運輸': | |
| 1344 | + $url = 'https://ap.meitetsuunyu.co.jp/webtrace/webtsuiseki/webtsuiseki.aspx'; | |
| 1345 | + break; | |
| 1346 | + | |
| 1347 | + case '新潟運輸': | |
| 1348 | + $url = 'https://www2.nuis.co.jp/kzz80011.htm'; | |
| 1349 | + break; | |
| 1350 | + | |
| 1351 | + case 'トナミ運輸': | |
| 1352 | + $url = 'https://trc1.tonami.co.jp/trc/search3/excSearch3'; | |
| 1353 | + break; | |
| 1354 | + | |
| 1355 | + case '第一貨物': | |
| 1356 | + $url = 'https://www.daiichi-kamotsu.co.jp/chase/contact_num/'; | |
| 1357 | + break; | |
| 1358 | + | |
| 1359 | + case '飛騨倉庫運輸': | |
| 1360 | + case '濃飛倉庫運輸': | |
| 1361 | + $url = 'https://www.nohhi.co.jp/support/'; | |
| 1362 | + break; | |
| 1363 | + | |
| 1364 | + default: | |
| 1365 | + $url = ''; | |
| 1366 | + } | |
| 1367 | + $url = apply_filters( 'usces_filter_delivery_company_url', $url, $delivery_company, $tracking_number ); | |
| 1368 | + return $url; | |
| 1369 | +} | |
| 1370 | + | |
| 1371 | +/** | |
| 1372 | + * Serialization | |
| 1373 | + * | |
| 1374 | + * @param mixed $data Data. | |
| 1375 | + * @return string | |
| 1376 | + */ | |
| 1377 | +function usces_serialize( $data ) { | |
| 1378 | + if ( ! is_array( $data ) ) { | |
| 1379 | + return $data; | |
| 1380 | + } | |
| 1381 | + return json_encode( $data ); | |
| 1382 | +} | |
| 1383 | + | |
| 1384 | +/** | |
| 1385 | + * Unserialize | |
| 1386 | + * | |
| 1387 | + * @param mixed $data Data. | |
| 1388 | + * @return array | |
| 1389 | + */ | |
| 1390 | +function usces_unserialize( $data ) { | |
| 1391 | + if ( is_array( $data ) || is_null( $data ) ) { | |
| 1392 | + return $data; | |
| 1393 | + } | |
| 1394 | + return @json_decode( $data, true ); | |
| 1395 | +} | |
| 1396 | + | |
| 1397 | +/** | |
| 1398 | + * Check trans_id | |
| 1399 | + * | |
| 1400 | + * @param string $key Key. | |
| 1401 | + * @return bool | |
| 1402 | + */ | |
| 1403 | +function usces_check_trans_id( $key ) { | |
| 1404 | + global $wpdb; | |
| 1405 | + | |
| 1406 | + $access_table_name = $wpdb->prefix . 'usces_access'; | |
| 1407 | + $query = $wpdb->prepare( "SELECT ID FROM $access_table_name WHERE acc_key = %s AND acc_str1 = %s", 'wc_trans_id', $key ); | |
| 1408 | + $id = $wpdb->get_var( $query ); | |
| 1409 | + return ( NULL != $id ) ? false : true; | |
| 1410 | +} | |
| 1411 | + | |
| 1412 | +/** | |
| 1413 | + * Save trans_id | |
| 1414 | + * | |
| 1415 | + * @param string $key Key. | |
| 1416 | + * @param string $acting Acting type. | |
| 1417 | + * @return bool | |
| 1418 | + */ | |
| 1419 | +function usces_save_trans_id( $key, $acting = 'acting' ) { | |
| 1420 | + global $wpdb; | |
| 1421 | + | |
| 1422 | + $access_table_name = $wpdb->prefix . 'usces_access'; | |
| 1423 | + $query = $wpdb->prepare( "INSERT INTO $access_table_name ( acc_key, acc_type, acc_date, acc_str1 ) VALUES( %s, %s, NOW(), %s )", 'wc_trans_id', $acting, $key ); | |
| 1424 | + $res = $wpdb->query( $query ); | |
| 1425 | + return $res; | |
| 1426 | +} | |
| 1427 | + | |
| 1428 | +/** | |
| 1429 | + * Is date | |
| 1430 | + * | |
| 1431 | + * @param mixed $date Date. | |
| 1432 | + * @return bool | |
| 1433 | + */ | |
| 1434 | +function usces_is_date( $date ) { | |
| 1435 | + | |
| 1436 | + if ( empty( $date ) ) { | |
| 1437 | + return false; | |
| 1438 | + } | |
| 1439 | + | |
| 1440 | + try { | |
| 1441 | + new DateTime( $date ); | |
| 1442 | + list( $year, $month, $day ) = explode( '-', $date ); | |
| 1443 | + $res = checkdate( (int) $month, (int) $day, (int) $year ); | |
| 1444 | + return $res; | |
| 1445 | + } catch ( Exception $e ) { | |
| 1446 | + return false; | |
| 1447 | + } | |
| 1448 | +} | |
| 1449 | + | |
| 1450 | +/** | |
| 1451 | + * Payment service suspended | |
| 1452 | + */ | |
| 1453 | +function usces_payment_service_suspended() { | |
| 1454 | + $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' ); | |
| 1455 | + foreach ( $payment_method as $payment ) { | |
| 1456 | + if ( 'acting_yahoo_wallet' == $payment['settlement'] && 'activate' == $payment['use'] ) { | |
| 1457 | + $payment['use'] = 'deactivate'; | |
| 1458 | + usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); | |
| 1459 | + } elseif ( 'acting_veritrans_card' == $payment['settlement'] && 'activate' == $payment['use'] ) { | |
| 1460 | + $payment['use'] = 'deactivate'; | |
| 1461 | + usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); | |
| 1462 | + } elseif ( 'acting_veritrans_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) { | |
| 1463 | + $payment['use'] = 'deactivate'; | |
| 1464 | + usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); | |
| 1465 | + } | |
| 1466 | + } | |
| 1467 | + $settlement_selected = get_option( 'usces_settlement_selected', array() ); | |
| 1468 | + if ( is_array( $settlement_selected ) && 0 < count( $settlement_selected ) ) { | |
| 1469 | + $settlement_selected = array_diff( $settlement_selected, array( 'yahoo', 'veritrans' ) ); | |
| 1470 | + $settlement_selected = array_values( $settlement_selected ); | |
| 1471 | + update_option( 'usces_settlement_selected', $settlement_selected ); | |
| 1472 | + } | |
| 1473 | + $available_settlement = get_option( 'usces_available_settlement', array() ); | |
| 1474 | + if ( is_array( $available_settlement ) && 0 < count( $available_settlement ) ) { | |
| 1475 | + $available_settlement = array_diff( $available_settlement, array( 'Yahoo!ウォレット', 'ベリトランス Air-Web' ) ); | |
| 1476 | + update_option( 'usces_available_settlement', $available_settlement ); | |
| 1477 | + } | |
| 1478 | +} | |
| 1479 | + | |
| 1480 | +/** | |
| 1481 | + * Whether the file is reserved. | |
| 1482 | + * | |
| 1483 | + * @param string $file_path File name. | |
| 1484 | + * @param int $dir 0:welcart-uptemp, 1:usces_logs. | |
| 1485 | + * @return boolean $res True if reserved, false otherwise. | |
| 1486 | + */ | |
| 1487 | +function usces_is_reserved_file( $file_path, $dir = 0 ) { | |
| 1488 | + | |
| 1489 | + $real_file_path = realpath( $file_path ); | |
| 1490 | + $real_base_path = ( 1 === $dir ) ? realpath( USCES_WP_CONTENT_DIR . '/uploads/usces_logs' ) . DIRECTORY_SEPARATOR : realpath( WP_CONTENT_DIR . USCES_UPLOAD_TEMP ) . DIRECTORY_SEPARATOR; | |
| 1491 | + if ( false === $real_file_path || 0 !== strpos( $real_file_path, $real_base_path ) ) { | |
| 1492 | + // Traversal attempt. | |
| 1493 | + return false; | |
| 1494 | + } | |
| 1495 | + | |
| 1496 | + $reserved_file = array( | |
| 1497 | + 'progress.txt', | |
| 1498 | + 'log.txt', | |
| 1499 | + 'db-progress.txt', | |
| 1500 | + 'db-log.txt', | |
| 1501 | + 'member_login_failed.log', | |
| 1502 | + 'ip_addresses_blocked.log', | |
| 1503 | + ); | |
| 1504 | + | |
| 1505 | + $path_parts = pathinfo( $file_path ); | |
| 1506 | + if ( in_array( $path_parts['basename'], $reserved_file, true ) ) { | |
| 1507 | + $res = true; | |
| 1508 | + } else { | |
| 1509 | + $res = false; | |
| 1510 | + } | |
| 1511 | + | |
| 1512 | + return $res; | |
| 1513 | +} | |
| 1514 | + | |
| 1515 | +/** | |
| 1516 | + * Whether the current page is a cart page. | |
| 1517 | + * | |
| 1518 | + * @return boolean True if cart page, false other page. | |
| 1519 | + */ | |
| 1520 | +function wel_is_cart_page() { | |
| 1521 | + global $usces; | |
| 1522 | + $request_uri = ( ! isset( $_SERVER['REQUEST_URI'] ) || empty( $_SERVER['REQUEST_URI'] ) ) ? '' : $_SERVER['REQUEST_URI']; | |
| 1523 | + return $usces->is_cart_page( $request_uri ); | |
| 1524 | +} | |
| 1525 | + | |
| 1526 | +/** | |
| 1527 | + * Whether the current page is a member page. | |
| 1528 | + * | |
| 1529 | + * @return boolean True if member page, false other page. | |
| 1530 | + */ | |
| 1531 | +function wel_is_member_page() { | |
| 1532 | + global $usces; | |
| 1533 | + $request_uri = ( ! isset( $_SERVER['REQUEST_URI'] ) || empty( $_SERVER['REQUEST_URI'] ) ) ? '' : $_SERVER['REQUEST_URI']; | |
| 1534 | + return $usces->is_member_page( $request_uri ); | |
| 1535 | +} | |
| 1536 | + | |
| 1537 | +/** | |
| 1538 | + * Leave the old function name, assuming customization. | |
| 1539 | + * | |
| 1540 | + * @param string $str Text. | |
| 1541 | + * @return string | |
| 1542 | + */ | |
| 1543 | +function usces_remove_script( $str ) { | |
| 1544 | + return wel_esc_script( $str ); | |
| 1545 | +} | |
| 1546 | + | |
| 1547 | +/** | |
| 1548 | + * Remove script tag | |
| 1549 | + * | |
| 1550 | + * @param string $str Text. | |
| 1551 | + * @return string | |
| 1552 | + */ | |
| 1553 | +function wel_esc_script( $str ) { | |
| 1554 | + | |
| 1555 | + if ( empty( $str ) ) { | |
| 1556 | + return $str; | |
| 1557 | + } | |
| 1558 | + | |
| 1559 | + $pattern = array( | |
| 1560 | + '/<script\b[^>]*>/i', | |
| 1561 | + '/<\/script>/i', | |
| 1562 | + ); | |
| 1563 | + | |
| 1564 | + $replacement = array( | |
| 1565 | + '<script>', | |
| 1566 | + '</script>', | |
| 1567 | + ); | |
| 1568 | + | |
| 1569 | + $str = preg_replace( $pattern, $replacement, $str ); | |
| 1570 | + $str = preg_replace( '/<([^>]+)\s+onerror\s*=\s*[^>]*?>/i', '<$1>', $str ); | |
| 1571 | + $str = preg_replace( '/=\s*alert\s*\(/i', '=', $str ); | |
| 1572 | + $str = preg_replace( '/<([^>]+)\s+on\w+\s*=\s*(?!["\'])([^>]*?)>/i', '<$1$2>', $str ); | |
| 1573 | + | |
| 1574 | + return $str; | |
| 1575 | +} | |
| 1576 | + | |
| 1577 | +/** | |
| 1578 | + * Escape and Echo script tag | |
| 1579 | + * | |
| 1580 | + * @param string $str Text. | |
| 1581 | + */ | |
| 1582 | +function wel_esc_script_e( $str ) { | |
| 1583 | + | |
| 1584 | + if ( empty( $str ) ) { | |
| 1585 | + return; | |
| 1586 | + } | |
| 1587 | + | |
| 1588 | + $pattern = array( | |
| 1589 | + '/<script\b[^>]*>/i', | |
| 1590 | + '/<\/script>/i', | |
| 1591 | + ); | |
| 1592 | + | |
| 1593 | + $replacement = array( | |
| 1594 | + '<script>', | |
| 1595 | + '</script>', | |
| 1596 | + ); | |
| 1597 | + | |
| 1598 | + $str = preg_replace( $pattern, $replacement, $str ); | |
| 1599 | + $str = preg_replace( '/<([^>]+)\s+onerror\s*=\s*[^>]*?>/i', '<$1>', $str ); | |
| 1600 | + $str = preg_replace( '/=\s*alert\s*\(/i', '=', $str ); | |
| 1601 | + $str = preg_replace( '/<([^>]+)\s+on\w+\s*=\s*(?!["\'])([^>]*?)>/i', '<$1$2>', $str ); | |
| 1602 | + | |
| 1603 | + echo $str; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1604 | +} | |
| 1605 | + | |
| 1606 | +/** | |
| 1607 | + * Object for filter_input_array_recursive(). | |
| 1608 | + */ | |
| 1609 | +class FilterObject { | |
| 1610 | + | |
| 1611 | + private $filter; | |
| 1612 | + private $options; | |
| 1613 | + | |
| 1614 | + /** | |
| 1615 | + * Constructor. | |
| 1616 | + * | |
| 1617 | + * @param int $filter same as ones for filter_input(). | |
| 1618 | + * @param mixed $options same as ones for filter_input(). | |
| 1619 | + */ | |
| 1620 | + public function __construct( $filter = FILTER_DEFAULT, $options = FILTER_REQUIRE_SCALAR ) { | |
| 1621 | + $this->filter = $filter; | |
| 1622 | + $this->options = $options; | |
| 1623 | + } | |
| 1624 | + | |
| 1625 | + public function getFilter() { | |
| 1626 | + return $this->filter; | |
| 1627 | + } | |
| 1628 | + | |
| 1629 | + public function getOptions() { | |
| 1630 | + return $this->options; | |
| 1631 | + } | |
| 1632 | + | |
| 1633 | +} | |
| 1634 | + | |
| 1635 | +/** | |
| 1636 | + * Apply filter_input() recursively. | |
| 1637 | + * | |
| 1638 | + * @param int $type INPUT_GET, INPUT_POST, INPUT_COOKIE or INPUT_REQUEST. | |
| 1639 | + * @param array $filters Multi-demensional array, | |
| 1640 | + * which contains FilterObject for each leaf. | |
| 1641 | + * @return array | |
| 1642 | + */ | |
| 1643 | +function filter_input_array_recursive( $type, array $filters ) { | |
| 1644 | + static $recursive_static; | |
| 1645 | + static $flag_match; | |
| 1646 | + static $is_not_array; | |
| 1647 | + static $filter_array; | |
| 1648 | + static $types; | |
| 1649 | + if ( ! $flag_match ) { | |
| 1650 | + /* initialize static variables */ | |
| 1651 | + $types = array( | |
| 1652 | + 'INPUT_GET' => $_GET, | |
| 1653 | + 'INPUT_POST' => $_POST, | |
| 1654 | + 'INPUT_COOKIE' => $_COOKIE, | |
| 1655 | + 'INPUT_REQUEST' => $_REQUEST, | |
| 1656 | + ); | |
| 1657 | + $flag_match = function( $v, $f ) { | |
| 1658 | + return (int) ( isset( $v['flags'] ) ? $v['flags'] : $v ) & $f; | |
| 1659 | + }; | |
| 1660 | + $is_not_array = function( $v ) { | |
| 1661 | + return ! is_array( $v ); | |
| 1662 | + }; | |
| 1663 | + $filter_array = function( $v ) { | |
| 1664 | + return ! is_array( $v ) ? $v : false; | |
| 1665 | + }; | |
| 1666 | + } | |
| 1667 | + $recursive = $recursive_static; | |
| 1668 | + if ( ! $recursive ) { | |
| 1669 | + /* only for first loop */ | |
| 1670 | + $type = (int) $type; | |
| 1671 | + if ( ! isset( $types[ $type ] ) ) { | |
| 1672 | + throw new \InvalidArgumentException( | |
| 1673 | + 'unknown super global var type' | |
| 1674 | + ); | |
| 1675 | + } | |
| 1676 | + $var = $types[ $type ]; | |
| 1677 | + $recursive_static = true; | |
| 1678 | + } else { | |
| 1679 | + /* after first loop */ | |
| 1680 | + $var = $type; | |
| 1681 | + } | |
| 1682 | + $ret = array(); | |
| 1683 | + foreach ( $filters as $key => $value ) { | |
| 1684 | + if ( is_array( $value ) ) { | |
| 1685 | + // apply child filters. | |
| 1686 | + $ret[ $key ] = filter_input_array_recursive( | |
| 1687 | + isset( $var[ $key ] ) ? $var[ $key ] : array(), | |
| 1688 | + $value | |
| 1689 | + ); | |
| 1690 | + } else { | |
| 1691 | + if ( ! ( $value instanceof FilterObject ) ) { | |
| 1692 | + // create default FilterObject for invalid leaf. | |
| 1693 | + $value = new FilterObject; | |
| 1694 | + } | |
| 1695 | + $filter = $value->getFilter(); | |
| 1696 | + $options = $value->getOptions(); | |
| 1697 | + // check if key exists... | |
| 1698 | + // true -> apply filter_var() with supplied filter and options. | |
| 1699 | + // false -> regard as null. | |
| 1700 | + try { | |
| 1701 | + $ret[ $key ] = | |
| 1702 | + isset( $var[ $key ] ) ? | |
| 1703 | + filter_var( $var[ $key ], $filter, $options ) : | |
| 1704 | + null | |
| 1705 | + ; | |
| 1706 | + } catch ( Exception $e ) { | |
| 1707 | + $recursive_static = false; | |
| 1708 | + throw $e; | |
| 1709 | + } | |
| 1710 | + if ( $flag_match( $options, FILTER_FORCE_ARRAY | FILTER_REQUIRE_ARRAY ) ) { | |
| 1711 | + // differently from filter_input(), | |
| 1712 | + // this function prevent unexpected non-array value | |
| 1713 | + // or multi-demensional array. | |
| 1714 | + if ( $flag_match( $options, FILTER_FORCE_ARRAY ) ) { | |
| 1715 | + // eliminate arrays. | |
| 1716 | + $ret[ $key ] = array_filter( (array) $ret[ $key ], $is_not_array ); | |
| 1717 | + } else { | |
| 1718 | + // change arrays into false. | |
| 1719 | + $ret[ $key ] = array_map( $filter_array, (array) $ret[ $key ] ); | |
| 1720 | + } | |
| 1721 | + } | |
| 1722 | + } | |
| 1723 | + } | |
| 1724 | + if ( ! $recursive ) { | |
| 1725 | + /* only for first loop */ | |
| 1726 | + $recursive_static = false; | |
| 1727 | + } | |
| 1728 | + return $ret; | |
| 1729 | +} | |
| 1730 | + | |
| 1731 | +/** | |
| 1732 | + * Remove the path from the uploaded file name and perform escape processing. | |
| 1733 | + * | |
| 1734 | + * @param string $file_name File Name. | |
| 1735 | + * | |
| 1736 | + * @return string | |
| 1737 | + */ | |
| 1738 | +function wel_esc_upload_file_name( $file_name ) { | |
| 1739 | + $filenames = explode( '/', urldecode( $file_name ) ); | |
| 1740 | + end( $filenames ); | |
| 1741 | + | |
| 1742 | + return wel_esc_script( $filenames[0] ); | |
| 1743 | +} | |
| 1744 | + | |
| 1745 | +/** | |
| 1746 | + * If the input data is a serialized object, sanitize it. | |
| 1747 | + * | |
| 1748 | + * @param string $data text. | |
| 1749 | + * | |
| 1750 | + * @return mixed|object|string | |
| 1751 | + */ | |
| 1752 | +function wel_safe_text_serialize( $data ) { | |
| 1753 | + if ( ! is_serialized( $data ) ) { | |
| 1754 | + return $data; // シリアライズされていないなら、そのまま返す | |
| 1755 | + } | |
| 1756 | + | |
| 1757 | + $result = unserialize( $data, [ 'allowed_classes' => false ] ); // オブジェクトを展開しない | |
| 1758 | + | |
| 1759 | + // 配列またはオブジェクトの場合、再帰的に無害化 | |
| 1760 | + if ( is_array( $result ) ) { | |
| 1761 | + array_walk_recursive( $result, function ( &$value ) { | |
| 1762 | + $value = sanitize_text_field( $value ); // 文字列を無害化 | |
| 1763 | + } ); | |
| 1764 | + } elseif ( is_object( $result ) ) { | |
| 1765 | + return sanitize_text_field( $result ); | |
| 1766 | + } else { | |
| 1767 | + return sanitize_text_field( $result ); | |
| 1768 | + } | |
| 1769 | + | |
| 1770 | + return maybe_serialize( $result ); | |
| 1771 | +} | |
| 1772 | + | |
| 1773 | +/** | |
| 1774 | + * Safely unserialize a value without restoring PHP objects. | |
| 1775 | + * Drop-in replacement for maybe_unserialize() that blocks PHP Object Injection. | |
| 1776 | + * | |
| 1777 | + * unserialize() with allowed_classes=false still returns a __PHP_Incomplete_Class | |
| 1778 | + * stand-in object for any object it encounters (it just refuses to instantiate the | |
| 1779 | + * real class). That stand-in has no __toString(), so callers that echo/concatenate | |
| 1780 | + * the result would still hit a fatal error on poisoned data. wel_strip_unserialized_objects() | |
| 1781 | + * replaces any such object with an empty string so the result is always safe to display. | |
| 1782 | + * | |
| 1783 | + * @param mixed $data Possibly serialized data. | |
| 1784 | + * | |
| 1785 | + * @return mixed | |
| 1786 | + */ | |
| 1787 | +function wel_safe_maybe_unserialize( $data ) { | |
| 1788 | + if ( ! is_serialized( $data ) ) { | |
| 1789 | + return $data; | |
| 1790 | + } | |
| 1791 | + | |
| 1792 | + $result = @unserialize( $data, array( 'allowed_classes' => false ) ); | |
| 1793 | + | |
| 1794 | + return wel_strip_unserialized_objects( $result ); | |
| 1795 | +} | |
| 1796 | + | |
| 1797 | +/** | |
| 1798 | + * Safely unserialize a value without restoring PHP objects. | |
| 1799 | + * Drop-in replacement for a bare unserialize() call. | |
| 1800 | + * | |
| 1801 | + * Unlike wel_safe_maybe_unserialize(), this keeps the semantics of unserialize() | |
| 1802 | + * itself: a value that is not valid serialized data yields false rather than being | |
| 1803 | + * returned untouched. Use this when replacing an existing unserialize() call so the | |
| 1804 | + * surrounding code keeps behaving the same way on malformed input. | |
| 1805 | + * | |
| 1806 | + * @param mixed $data Serialized data. | |
| 1807 | + * | |
| 1808 | + * @return mixed False if the data cannot be unserialized. | |
| 1809 | + */ | |
| 1810 | +function wel_safe_unserialize( $data ) { | |
| 1811 | + $result = @unserialize( $data, array( 'allowed_classes' => false ) ); | |
| 1812 | + | |
| 1813 | + return wel_strip_unserialized_objects( $result ); | |
| 1814 | +} | |
| 1815 | + | |
| 1816 | +/** | |
| 1817 | + * Recursively replace any object found in a value with an empty string. | |
| 1818 | + * | |
| 1819 | + * @param mixed $value Value to sanitize. | |
| 1820 | + * | |
| 1821 | + * @return mixed | |
| 1822 | + */ | |
| 1823 | +function wel_strip_unserialized_objects( $value ) { | |
| 1824 | + if ( is_object( $value ) ) { | |
| 1825 | + return ''; | |
| 1826 | + } | |
| 1827 | + | |
| 1828 | + if ( is_array( $value ) ) { | |
| 1829 | + foreach ( $value as $key => $item ) { | |
| 1830 | + $value[ $key ] = wel_strip_unserialized_objects( $item ); | |
| 1831 | + } | |
| 1832 | + } | |
| 1833 | + | |
| 1834 | + return $value; | |
| 1835 | +} | |