PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
← All changes | functions/settlement_func.php +66 -24 2.11.352.12.4 View file →
@@ -576,8 +576,27 @@
576 576 return $res;
577 577 }
578 578
579 579 /**
580 + * Escape a settlement log field for HTML output.
581 + *
582 + * Log fields come from unauthenticated payment-gateway callbacks, so a field
583 + * may arrive as an array (e.g. `?rand[]=x`) or as an object. Flatten anything
584 + * non-scalar before escaping, because esc_html() cannot take an array.
585 + *
586 + * Use this for text nodes only. Attribute values need esc_attr().
587 + *
588 + * @param mixed $value Raw log field.
589 + * @return string Escaped, HTML-safe string.
590 + */
591 +function wel_esc_settlement_log( $value ) {
592 + if ( null === $value || is_scalar( $value ) ) {
593 + return esc_html( (string) $value );
594 + }
595 + return esc_html( wp_json_encode( $value ) );
596 +}
597 +
598 +/**
580 599 * 決済直前ログ一覧
581 600 *
582 601 * @param string $log_key Log key.
583 602 * @return void
@@ -604,15 +623,15 @@
604 623 $payment_structure = ( isset( $usces->payment_structure[ $settlement ] ) ) ? '[' . $usces->payment_structure[ $settlement ] . ']' : '';
605 624 $class = ( ! empty( $log['revival'] ) ) ? ' class="revival"' : '';
606 625 $ip = ( ! empty( $log['remote_addr'] ) ) ? $log['remote_addr'] : '';
607 626 $html .= '<tr' . $class . '>
608 - <td class="check"><input type="checkbox" class="log-check" value="' . $data['log_key'] . '"></td>
609 - <td class="detail"><input type="button" class="log-detail button" id="' . $data['log_key'] . '" value="' . __( 'Detail', 'usces' ) . '"></td>
610 - <td class="datetime">' . $data['datetime'] . '</td>
611 - <td class="key">' . $data['log_key'] . '</td>
627 + <td class="check"><input type="checkbox" class="log-check" value="' . esc_attr( $data['log_key'] ) . '"></td>
628 + <td class="detail"><input type="button" class="log-detail button" id="' . esc_attr( $data['log_key'] ) . '" value="' . esc_attr__( 'Detail', 'usces' ) . '"></td>
629 + <td class="datetime">' . esc_html( $data['datetime'] ) . '</td>
630 + <td class="key">' . esc_html( $data['log_key'] ) . '</td>
612 631 <td class="name">' . $name . '</td>
613 632 <td class="payment">' . $payment_name . $payment_structure . '</td>
614 - <td class="ip">' . $ip . '</td>
633 + <td class="ip">' . esc_html( $ip ) . '</td>
615 634 </tr>';
616 635 }
617 636 $html .= '</table>';
618 637 } else {
@@ -638,12 +657,12 @@
638 657 $order_data = usces_get_acting_data( $log_key );
639 658 $usces_entries = $order_data['usces_entry'];
640 659
641 660 $html = '<table class="detail-head">';
642 - $html .= '<tr><th>' . __( 'Register date', 'usces' ) . '</th><td>' . $order_data['datetime'] . '</td><td>
661 + $html .= '<tr><th>' . __( 'Register date', 'usces' ) . '</th><td>' . esc_html( $order_data['datetime'] ) . '</td><td>
643 662 <label for="register_date_1"><input type="radio" name="register_date" id="register_date_1" value="1" checked="checked" /><span>' . __( 'Set the Registered Date to the Order Date.', 'usces' ) . '</span></label><br />
644 663 <label for="register_date_0"><input type="radio" name="register_date" id="register_date_0" value="0" /><span>' . __( 'Set the current time to the Order Date.', 'usces' ) . '</span></label></td></tr>';
645 - $html .= '<tr><th>' . __( 'Link key', 'usces' ) . '</th><td colspan="2">' . $order_data['key'] . '</td></tr>';
664 + $html .= '<tr><th>' . __( 'Link key', 'usces' ) . '</th><td colspan="2">' . wel_esc_settlement_log( $order_data['key'] ) . '</td></tr>';
646 665 $html .= '</table>';
647 666
648 667 $html .= '<table class="detail-customer">';
649 668 $html .= '<tr class="title"><td colspan="2"><h3>' . __( 'Customer Information', 'usces' ) . '</h3></td></tr>';
@@ -669,10 +688,27 @@
669 688 $html .= '<tr><th>No</th><th>' . __( 'Items', 'usces' ) . '</th><th>' . __( 'Quantity', 'usces' ) . '</th><th>' . __( 'Unit price', 'usces' ) . '</th></tr>';
670 689 $html .= '</thead><tbody>';
671 690 $num = 1;
672 691 foreach ( $order_data['usces_cart'] as $serial => $row ) {
673 - $array = wel_safe_unserialize( $serial );
674 - $ids = array_keys( $array );
692 + $array = wel_safe_unserialize( $serial );
693 + $ids = ( is_array( $array ) && ! empty( $array ) ) ? array_keys( $array ) : array();
694 + if ( empty( $ids ) || ! is_array( $array[ $ids[0] ] ) || empty( $array[ $ids[0] ] ) ) {
695 + /*
696 + * The serial key is broken and the item cannot be identified.
697 + * When the cart in the session was empty, every posted row was
698 + * written to the same empty key and overwrote the previous one,
699 + * so the stored quantity and price cannot be attributed to a
700 + * particular item. Show the row without those figures.
701 + */
702 + $html .= '<tr>';
703 + $html .= '<td class="num">' . $num . '</td>';
704 + $html .= '<td class="item_name">' . esc_html( __( 'The cart data is broken and the item details cannot be restored. The original number of items is also unknown. This line is not included when the order data is recreated.', 'usces' ) ) . '</td>';
705 + $html .= '<td class="quantity">-</td>';
706 + $html .= '<td class="price">-</td>';
707 + $html .= '</tr>';
708 + $num++;
709 + continue;
710 + }
675 711 $skus = array_keys( $array[ $ids[0] ] );
676 712 $post_id = $ids[0];
677 713 $sku = $skus[0];
678 714 $options = $array[ $ids[0] ][ $skus[0] ];
@@ -729,9 +765,9 @@
729 765 $html .= '<tr><th colspan="3">' . __( 'Used points', 'usces' ) . '</th><td class="usedpoint">' . number_format( $usces_entries['order']['usedpoint'] ) . '</td></tr>';
730 766 }
731 767 $html .= '<tr><th colspan="3">' . __( 'Payment amount', 'usces' ) . '</th><td class="total_full_price">' . usces_crform( $usces_entries['order']['total_full_price'], true, false, 'return' ) . '</td></tr>';
732 768 $html .= '</tfoot></table>';
733 - $html .= '<input type="hidden" id="log_key" value="' . $order_data['key'] . '" />';
769 + $html .= '<input type="hidden" id="log_key" value="' . esc_attr( $order_data['key'] ) . '" />';
734 770
735 771 $resdata = array();
736 772 $resdata['status'] = 'OK';
737 773 $resdata['result'] = $html;
@@ -880,14 +916,14 @@
880 916 $log = wel_safe_unserialize( $data['log'] );
881 917 $result = ( ! empty( $log['result'] ) ) ? $log['result'] : '';
882 918 $acting = ( ! empty( $log['acting'] ) ) ? $log['acting'] : '';
883 919 $html .= '<tr>
884 - <td class="check"><input type="checkbox" class="error-log-check" value="' . $data['ID'] . '"></td>
885 - <td class="detail"><input type="button" class="error-log-detail button" id="' . $data['ID'] . '" value="' . __( 'Detail', 'usces' ) . '"></td>
886 - <td class="datetime">' . $data['datetime'] . '</td>
887 - <td class="key">' . $data['log_key'] . '</td>
888 - <td class="payment">' . $acting . '</td>
889 - <td class="status">' . $result . '</td>
920 + <td class="check"><input type="checkbox" class="error-log-check" value="' . esc_attr( $data['ID'] ) . '"></td>
921 + <td class="detail"><input type="button" class="error-log-detail button" id="' . esc_attr( $data['ID'] ) . '" value="' . esc_attr__( 'Detail', 'usces' ) . '"></td>
922 + <td class="datetime">' . esc_html( $data['datetime'] ) . '</td>
923 + <td class="key">' . esc_html( $data['log_key'] ) . '</td>
924 + <td class="payment">' . wel_esc_settlement_log( $acting ) . '</td>
925 + <td class="status">' . wel_esc_settlement_log( $result ) . '</td>
890 926 </tr>';
891 927 }
892 928 $html .= '</table>';
893 929 } else {
@@ -928,11 +964,11 @@
928 964 $data = $wpdb->get_row( $query, ARRAY_A );
929 965 if ( $data ) {
930 966 $log = wel_safe_unserialize( $data['log'] );
931 967 $html = '<table class="detail">';
932 - $html .= '<tr><th>' . __( 'Register date', 'usces' ) . '</th><td>' . $data['datetime'] . '</td></tr>';
933 - $html .= '<tr><th>' . __( 'Link key', 'usces' ) . '</th><td>' . $log['key'] . '</td></tr>';
934 - $html .= '<tr><th>' . __( 'Result', 'usces' ) . '</th><td>' . $log['result'] . '</td></tr>';
968 + $html .= '<tr><th>' . __( 'Register date', 'usces' ) . '</th><td>' . esc_html( $data['datetime'] ) . '</td></tr>';
969 + $html .= '<tr><th>' . __( 'Link key', 'usces' ) . '</th><td>' . wel_esc_settlement_log( $log['key'] ) . '</td></tr>';
970 + $html .= '<tr><th>' . __( 'Result', 'usces' ) . '</th><td>' . wel_esc_settlement_log( $log['result'] ) . '</td></tr>';
935 971 foreach ( (array) $log['data'] as $key => $value ) {
936 972 if ( in_array( $key, $exemption ) ) {
937 973 continue;
938 974 }
@@ -941,19 +977,19 @@
941 977 if ( in_array( $key2, $exemption ) ) {
942 978 continue;
943 979 }
944 980 if ( is_array( $value2 ) ) {
945 - $html .= '<tr><th>' . $key . ':' . $key2 . '</th><td>' . esc_html( serialize( $value2 ) ) . '</td></tr>';
981 + $html .= '<tr><th>' . esc_html( $key ) . ':' . esc_html( $key2 ) . '</th><td>' . esc_html( serialize( $value2 ) ) . '</td></tr>';
946 982 } else {
947 - $html .= '<tr><th>' . $key . ':' . $key2 . '</th><td>' . esc_html( $value2 ) . '</td></tr>';
983 + $html .= '<tr><th>' . esc_html( $key ) . ':' . esc_html( $key2 ) . '</th><td>' . esc_html( $value2 ) . '</td></tr>';
948 984 }
949 985 }
950 986 } else {
951 - $html .= '<tr><th>' . $key . '</th><td>' . esc_html( $value ) . '</td></tr>';
987 + $html .= '<tr><th>' . esc_html( $key ) . '</th><td>' . esc_html( $value ) . '</td></tr>';
952 988 }
953 989 }
954 990 $html .= '</table>';
955 - $html .= '<input type="hidden" id="log_id" value="' . $data['ID'] . '" />';
991 + $html .= '<input type="hidden" id="log_id" value="' . esc_attr( $data['ID'] ) . '" />';
956 992 }
957 993
958 994 $resdata = array();
959 995 $resdata['status'] = 'OK';
@@ -1007,9 +1043,15 @@
1007 1043 if ( ! current_user_can( 'wel_manage_order' ) ) {
1008 1044 return false;
1009 1045 }
1010 1046 $datetime = get_option( 'usces_settlement_notice' );
1011 - echo '<div class="message error"><p>' . sprintf( __( "Settlement error has occurred. Please check <a href=\"admin.php?page=usces_orderlist&order_action=settlement_notice\">the settlement error log</a>. The date of occurrence:[ %s ]", 'usces' ), $datetime ) . '</p></div>';
1047 + echo '<div class="message error"><p>' . wp_kses_post(
1048 + sprintf(
1049 + /* translators: %s: date and time when the settlement error occurred */
1050 + __( 'Settlement error has occurred. Please check <a href="admin.php?page=usces_orderlist&order_action=settlement_notice">the settlement error log</a>. The date of occurrence:[ %s ]', 'usces' ),
1051 + $datetime
1052 + )
1053 + ) . '</p></div>';
1012 1054 }
1013 1055
1014 1056 /**
1015 1057 * 決済エラーログダウンロード