options = get_option( 'usces', array() );
if ( ! isset( $this->options['smtp_hostname'] ) || empty( $this->options['smtp_hostname'] ) ) {
$this->options['smtp_hostname'] = 'localhost';
}
if ( ! isset( $this->options['delivery_method'] ) || ! is_array( $this->options['delivery_method'] ) ) {
$this->options['delivery_method'] = array();
}
if ( ! isset( $this->options['shipping_charge'] ) || ! is_array( $this->options['shipping_charge'] ) ) {
$this->options['shipping_charge'] = array();
}
if ( ! isset( $this->options['membersystem_state'] ) ) {
$this->options['membersystem_state'] = 'activate';
}
if ( ! isset( $this->options['membersystem_point'] ) ) {
$this->options['membersystem_point'] = 'activate';
}
if ( ! isset( $this->options['use_ssl'] ) ) {
$this->options['use_ssl'] = 0;
}
if ( ! isset( $this->options['point_coverage'] ) ) {
$this->options['point_coverage'] = 0;
}
if ( ! isset( $this->options['use_javascript'] ) ) {
$this->options['use_javascript'] = 1;
}
if ( ! isset( $this->options['privilege_discount'] ) ) {
$this->options['privilege_discount'] = '';
}
if ( ! isset( $this->options['privilege_point'] ) ) {
$this->options['privilege_point'] = '';
}
if ( ! isset( $this->options['campaign_privilege'] ) ) {
$this->options['campaign_privilege'] = '';
}
if ( ! isset( $this->options['campaign_category'] ) ) {
$this->options['campaign_category'] = 0;
}
if ( ! isset( $this->options['campaign_schedule']['start'] ) ) {
$this->options['campaign_schedule']['start'] = array();
}
if ( ! isset( $this->options['campaign_schedule']['end'] ) ) {
$this->options['campaign_schedule']['end'] = array();
}
if ( ! isset( $this->options['purchase_limit'] ) ) {
$this->options['purchase_limit'] = '';
}
if ( ! isset( $this->options['point_rate'] ) ) {
$this->options['point_rate'] = '';
}
if ( ! isset( $this->options['shipping_rule'] ) ) {
$this->options['shipping_rule'] = '';
}
if ( ! isset( $this->options['company_name'] ) ) {
$this->options['company_name'] = '';
}
if ( ! isset( $this->options['address1'] ) ) {
$this->options['address1'] = '';
}
if ( ! isset( $this->options['address2'] ) ) {
$this->options['address2'] = '';
}
if ( ! isset( $this->options['zip_code'] ) ) {
$this->options['zip_code'] = '';
}
if ( ! isset( $this->options['tel_number'] ) ) {
$this->options['tel_number'] = '';
}
if ( ! isset( $this->options['fax_number'] ) ) {
$this->options['fax_number'] = '';
}
if ( ! isset( $this->options['order_mail'] ) ) {
$this->options['order_mail'] = '';
}
if ( ! isset( $this->options['inquiry_mail'] ) ) {
$this->options['inquiry_mail'] = '';
}
if ( ! isset( $this->options['sender_mail'] ) ) {
$this->options['sender_mail'] = '';
}
if ( ! isset( $this->options['error_mail'] ) ) {
$this->options['error_mail'] = '';
}
if ( ! isset( $this->options['copyright'] ) ) {
$this->options['copyright'] = '';
}
if ( ! isset( $this->options['business_registration_number'] ) ) {
$this->options['business_registration_number'] = '';
}
if ( ! isset( $this->options['postage_privilege'] ) ) {
$this->options['postage_privilege'] = '';
}
if ( ! isset( $this->options['shipping_rule'] ) ) {
$this->options['shipping_rule'] = '';
}
if ( ! isset( $this->options['tax_display'] ) ) {
$this->options['tax_display'] = 'activate';
}
if ( ! isset( $this->options['applicable_taxrate'] ) || empty( $this->options['applicable_taxrate'] ) ) {
$this->options['applicable_taxrate'] = 'standard';
}
if ( ! isset( $this->options['tax_rate'] ) ) {
$this->options['tax_rate'] = '';
$this->options['tax_method'] = 'cutting';
$this->options['tax_mode'] = 'include';
$this->options['tax_target'] = 'products';
} else {
if ( ! isset( $this->options['tax_mode'] ) ) {
$this->options['tax_mode'] = empty( $this->options['tax_rate'] ) ? 'include' : 'exclude';
}
if ( ! isset( $this->options['tax_target'] ) ) {
$this->options['tax_target'] = 'all';
}
}
if ( ! isset( $this->options['tax_rate_reduced'] ) ) {
$this->options['tax_rate_reduced'] = '';
}
if ( ! isset( $this->options['transferee'] ) ) {
$this->options['transferee'] = '';
}
if ( ! isset( $this->options['tatransfer_limit'] ) ) {
$this->options['tatransfer_limit'] = '';
}
if ( ! isset( $this->options['membersystem_state'] ) ) {
$this->options['membersystem_state'] = 'activate';
}
if ( ! isset( $this->options['membersystem_point'] ) ) {
$this->options['membersystem_point'] = '';
}
if ( ! isset( $this->options['point_rate'] ) ) {
$this->options['point_rate'] = '';
}
if ( ! isset( $this->options['start_point'] ) ) {
$this->options['start_point'] = '';
}
if ( ! isset( $this->options['point_coverage'] ) ) {
$this->options['point_coverage'] = 1;
}
if ( ! isset( $this->options['point_assign'] ) ) {
$this->options['point_assign'] = 1;
}
if ( ! isset( $this->options['cod_type'] ) ) {
$this->options['cod_type'] = 'fix';
}
if ( ! isset( $this->options['fee_subject'] ) ) {
$this->options['fee_subject'] = 'all';
}
if ( ! isset( $this->options['address_search'] ) ) {
$this->options['address_search'] = 'deactivate';
}
if ( ! isset( $this->options['newmem_admin_mail'] ) ) {
$this->options['newmem_admin_mail'] = 0;
}
if ( ! isset( $this->options['updmem_admin_mail'] ) ) {
$this->options['updmem_admin_mail'] = 0;
}
if ( ! isset( $this->options['updmem_customer_mail'] ) ) {
$this->options['updmem_customer_mail'] = 0;
}
if ( ! isset( $this->options['delmem_admin_mail'] ) ) {
$this->options['delmem_admin_mail'] = 1;
}
if ( ! isset( $this->options['delmem_customer_mail'] ) ) {
$this->options['delmem_customer_mail'] = 1;
}
if ( ! isset( $this->options['put_customer_name'] ) ) {
$this->options['put_customer_name'] = '0';
}
if ( ! isset( $this->options['email_attach_feature'] ) ) {
$this->options['email_attach_feature'] = '0';
}
if ( ! isset( $this->options['email_attach_file_extension'] ) ) {
$this->options['email_attach_file_extension'] = 'jpg,png,pdf';
}
if ( ! isset( $this->options['email_attach_file_size'] ) ) {
$this->options['email_attach_file_size'] = 3;
}
if ( ! isset( $this->options['add_html_email_option'] ) ) {
$this->options['add_html_email_option'] = 0;
}
if ( ! isset( $this->options['mail_data']['title'] ) ) {
$this->options['mail_data']['title'] = array(
'thankyou' => '',
'order' => '',
'inquiry' => '',
'returninq' => '',
'membercomp' => '',
'completionmail' => '',
'ordermail' => '',
'changemail' => '',
'receiptmail' => '',
'mitumorimail' => '',
'cancelmail' => '',
'othermail' => '',
);
}
if ( ! isset( $this->options['mail_data']['header'] ) ) {
$this->options['mail_data']['header'] = array(
'thankyou' => '',
'order' => '',
'inquiry' => '',
'returninq' => '',
'membercomp' => '',
'completionmail' => '',
'ordermail' => '',
'changemail' => '',
'receiptmail' => '',
'mitumorimail' => '',
'cancelmail' => '',
'othermail' => '',
);
}
if ( ! isset( $this->options['mail_data']['footer'] ) ) {
$this->options['mail_data']['footer'] = array(
'thankyou' => '',
'order' => '',
'inquiry' => '',
'returninq' => '',
'membercomp' => '',
'completionmail' => '',
'ordermail' => '',
'changemail' => '',
'receiptmail' => '',
'mitumorimail' => '',
'cancelmail' => '',
'othermail' => '',
);
}
if ( ! isset( $this->options['cart_page_data']['header'] ) ) {
$this->options['cart_page_data']['header'] = array(
'cart' => '',
'customer' => '',
'delivery' => '',
'confirm' => '',
'completion' => '',
);
}
if ( ! isset( $this->options['cart_page_data']['footer'] ) ) {
$this->options['cart_page_data']['footer'] = array(
'cart' => '',
'customer' => '',
'delivery' => '',
'confirm' => '',
'completion' => '',
);
}
if ( ! isset( $this->options['cart_page_data']['confirm_notes'] ) ) {
$this->options['cart_page_data']['confirm_notes'] = '';
}
if ( ! isset( $this->options['member_page_data']['header'] ) ) {
$this->options['member_page_data']['header'] = array(
'login' => '',
'newmember' => '',
'newpass' => '',
'changepass' => '',
'memberinfo' => '',
'completion' => '',
);
}
if ( ! isset( $this->options['member_page_data']['footer'] ) ) {
$this->options['member_page_data']['footer'] = array(
'login' => '',
'newmember' => '',
'newpass' => '',
'changepass' => '',
'memberinfo' => '',
'completion' => '',
);
}
if ( ! isset( $this->options['member_page_data']['agree_member_exp'] ) ) {
$this->options['member_page_data']['agree_member_exp'] = '';
}
if ( ! isset( $this->options['member_page_data']['agree_member_cont'] ) ) {
$this->options['member_page_data']['agree_member_cont'] = '';
}
if ( ! isset( $this->options['agree_member'] ) ) {
$this->options['agree_member'] = '';
}
if ( ! isset( $this->options['shortest_delivery_time'] ) ) {
$this->options['shortest_delivery_time'] = '0';
}
if ( ! isset( $this->options['delivery_after_days'] ) ) {
$this->options['delivery_after_days'] = 15;
}
if ( ! isset( $this->options['delivery_days'] ) ) {
$this->options['delivery_days'] = array();
}
if ( ! isset( $this->options['delivery_time_limit']['hour'] ) ) {
$this->options['delivery_time_limit']['hour'] = '00';
}
if ( ! isset( $this->options['delivery_time_limit']['min'] ) ) {
$this->options['delivery_time_limit']['min'] = '00';
}
if ( ! isset( $this->options['divide_item'] ) ) {
$this->options['divide_item'] = 0;
}
if ( ! isset( $this->options['itemimg_anchor_rel'] ) ) {
$this->options['itemimg_anchor_rel'] = '';
}
if ( ! isset( $this->options['fukugo_category_orderby'] ) ) {
$this->options['fukugo_category_orderby'] = 'ID';
}
if ( ! isset( $this->options['fukugo_category_order'] ) ) {
$this->options['fukugo_category_order'] = 'ASC';
}
if ( ! isset( $this->options['settlement_path'] ) ) {
$this->options['settlement_path'] = USCES_PLUGIN_DIR . 'settlement/';
}
if ( ! isset( $this->options['logs_path'] ) ) {
$this->options['logs_path'] = '';
}
if ( ! isset( $this->options['use_ssl'] ) ) {
$this->options['use_ssl'] = 0;
}
if ( ! isset( $this->options['ssl_url'] ) ) {
$this->options['ssl_url'] = '';
}
if ( ! isset( $this->options['ssl_url_admin'] ) ) {
$this->options['ssl_url_admin'] = '';
}
if ( ! isset( $this->options['inquiry_id'] ) ) {
$this->options['inquiry_id'] = '';
}
if ( ! isset( $this->options['system']['orderby_itemsku'] ) ) {
$this->options['system']['orderby_itemsku'] = 0;
}
if ( ! isset( $this->options['system']['orderby_itemopt'] ) ) {
$this->options['system']['orderby_itemopt'] = 0;
}
if ( ! isset( $this->options['system']['front_lang'] ) ) {
$this->options['system']['front_lang'] = usces_get_local_language();
}
if ( ! isset( $this->options['system']['currency'] ) ) {
$this->options['system']['currency'] = usces_get_base_country();
}
if ( ! isset( $this->options['system']['addressform'] ) ) {
$this->options['system']['addressform'] = usces_get_local_addressform();
}
if ( ! isset( $this->options['system']['target_market'] ) ) {
$this->options['system']['target_market'] = usces_get_local_target_market();
}
if ( ! isset( $this->options['system']['no_cart_css'] ) ) {
$this->options['system']['no_cart_css'] = 0;
}
if ( ! isset( $this->options['system']['dec_orderID_flag'] ) ) {
$this->options['system']['dec_orderID_flag'] = 0;
}
if ( ! isset( $this->options['system']['dec_orderID_prefix'] ) ) {
$this->options['system']['dec_orderID_prefix'] = '';
}
if ( ! isset( $this->options['system']['dec_orderID_digit'] ) ) {
$this->options['system']['dec_orderID_digit'] = 8;
}
if ( ! isset( $this->options['system']['subimage_rule'] ) ) {
$this->options['system']['subimage_rule'] = 1;
}
if ( ! isset( $this->options['system']['pdf_delivery'] ) ) {
$this->options['system']['pdf_delivery'] = 0;
}
if ( ! isset( $this->options['system']['member_pass_rule_min'] ) || empty( $this->options['system']['member_pass_rule_min'] ) ) {
$this->options['system']['member_pass_rule_min'] = 6;
}
if ( ! isset( $this->options['system']['member_pass_rule_max'] ) || empty( $this->options['system']['member_pass_rule_max'] ) ) {
$this->options['system']['member_pass_rule_max'] = 30;
}
if ( ! isset( $this->options['system']['member_pass_rule_upercase'] ) || empty( $this->options['system']['member_pass_rule_upercase'] ) ) {
$this->options['system']['member_pass_rule_upercase'] = false;
}
if ( ! isset( $this->options['system']['csv_encode_type'] ) ) {
$this->options['system']['csv_encode_type'] = 0;
}
if ( ! isset( $this->options['system']['csv_category_format'] ) ) {
$this->options['system']['csv_category_format'] = 0;
}
if ( ! isset( $this->options['system']['settlement_backup'] ) ) {
$this->options['system']['settlement_backup'] = 0;
}
if ( ! isset( $this->options['system']['settlement_notice'] ) ) {
$this->options['system']['settlement_notice'] = 0;
}
if ( ! isset( $this->options['system']['order_list_delete_link'] ) ) {
$this->options['system']['order_list_delete_link'] = 0;
}
if ( ! isset( $this->options['system']['member_list_delete_link'] ) ) {
$this->options['system']['member_list_delete_link'] = 0;
}
$this->options['system']['base_country'] = usces_get_base_country();
if ( ! isset( $this->options['province'] ) ) {
$this->options['province'][ $this->options['system']['base_country'] ] = $usces_states[ $this->options['system']['base_country'] ];
}
if ( ! isset( $this->options['system']['pointreduction'] ) ) {
$this->options['system']['pointreduction'] = usces_get_pointreduction( $this->options['system']['currency'] );
}
if ( ! isset( $this->options['indi_item_name'] ) ) {
$this->options['indi_item_name']['item_name'] = 1;
$this->options['indi_item_name']['item_code'] = 1;
$this->options['indi_item_name']['sku_name'] = 1;
$this->options['indi_item_name']['sku_code'] = 1;
$this->options['pos_item_name']['item_name'] = 1;
$this->options['pos_item_name']['item_code'] = 2;
$this->options['pos_item_name']['sku_name'] = 3;
$this->options['pos_item_name']['sku_code'] = 4;
}
update_option( 'usces', $this->options );
$this->check_display_mode();
$this->error_message = '';
$this->login_mail = '';
// $this->get_current_member();
$this->page = '';
$this->payment_results = array();
$this->use_js = $this->options['use_javascript'];
// admin_ssl options.
$this->use_ssl = $this->options['use_ssl'];
define( 'USCES_CART_NUMBER', get_option( 'usces_cart_number' ) );
define( 'USCES_MEMBER_NUMBER', get_option( 'usces_member_number' ) );
if ( $this->use_ssl ) {
$ssl_url = $this->options['ssl_url'];
$ssl_url_admin = $this->options['ssl_url_admin'];
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
define( 'USCES_FRONT_PLUGIN_URL', $ssl_url_admin . '/wp-content/plugins/' . USCES_PLUGIN_FOLDER );
define( 'USCES_COOKIEPATH', preg_replace( '|https?://[^/]+|i', '', $ssl_url . '/' ) );
} else {
define( 'USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER );
define( 'USCES_COOKIEPATH', COOKIEPATH );
}
define( 'USCES_SSL_URL', $ssl_url );
define( 'USCES_SSL_URL_ADMIN', $ssl_url_admin );
} else {
define( 'USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER );
define( 'USCES_SSL_URL', home_url() );
define( 'USCES_SSL_URL_ADMIN', site_url() );
define( 'USCES_COOKIEPATH', COOKIEPATH );
}
define( 'USCES_ITEM_CAT_PARENT_ID', get_option( 'usces_item_cat_parent_id' ) );
$this->nonacting_settlements = array( 'COD', 'installment', 'transferAdvance', 'transferDeferred' );
$this->zaiko_status = get_option( 'usces_zaiko_status' );
$this->member_status = get_option( 'usces_customer_status' );
$this->payment_structure = get_option( 'usces_payment_structure' );
$this->display_mode = get_option( 'usces_display_mode' );
define( 'USCES_MYSQL_VERSION', $wpdb->db_version() );
define( 'USCES_JP', ( 'ja' === get_locale() ? true : false ) );
$this->settlement = new usces_settlement();
$this->settlement_notice = get_option( 'usces_settlement_notice' );
$this->usces_session_start();
}
/**
* Init.
*/
public function init() {
global $usces_settings;
if ( ! isset( $usces_settings['language']['others'] ) ) {
$usces_settings['language']['others'] = __( 'Follow config.php', 'usces' );
}
if ( ! isset( $this->options['order_acceptable_label'] ) ) {
$this->options['order_acceptable_label'] = __( 'Order acceptable', 'usces' );
update_option( 'usces', $this->options );
}
$this->get_current_member();
}
public function get_default_post_to_edit30( $post_type = 'post', $create_in_db = false ) {
global $wpdb;
$post_title = '';
if ( ! empty( $_REQUEST['post_title'] ) ) {
$post_title = esc_html( stripslashes( $_REQUEST['post_title'] ) );
}
$post_content = '';
if ( ! empty( $_REQUEST['content'] ) ) {
$post_content = esc_html( stripslashes( $_REQUEST['content'] ) );
}
$post_excerpt = '';
if ( ! empty( $_REQUEST['excerpt'] ) ) {
$post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ) );
}
if ( $create_in_db ) {
// Cleanup old auto-drafts more than 7 days old.
$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
foreach ( (array) $old_posts as $delete ) {
wp_delete_post( $delete, true ); // Force delete.
}
$post = get_post(
wp_insert_post(
array(
'post_title' => __( 'Auto Draft' ),
'post_type' => $post_type,
'post_status' => 'auto-draft',
)
)
);
} else {
$post->ID = 0;
$post->post_author = '';
$post->post_date = '';
$post->post_date_gmt = '';
$post->post_password = '';
$post->post_type = $post_type;
$post->post_status = 'draft';
$post->to_ping = '';
$post->pinged = '';
$post->comment_status = get_option( 'default_comment_status' );
$post->ping_status = get_option( 'default_ping_status' );
$post->post_pingback = get_option( 'default_pingback_flag' );
$post->post_category = get_option( 'default_category' );
$post->page_template = 'default';
$post->post_parent = 0;
$post->menu_order = 0;
}
$post->post_content = apply_filters( 'default_content', $post_content, $post );
$post->post_title = apply_filters( 'default_title', $post_title, $post );
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
$post->post_name = '';
return $post;
}
public function get_default_post_to_edit() {
global $post;
$post_title = '';
if ( ! empty( $_REQUEST['post_title'] ) ) {
$post_title = esc_html( stripslashes( $_REQUEST['post_title'] ) );
}
$post_content = '';
if ( ! empty( $_REQUEST['content'] ) ) {
$post_content = esc_html( stripslashes( $_REQUEST['content'] ) );
}
$post_excerpt = '';
if ( ! empty( $_REQUEST['excerpt'] ) ) {
$post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ) );
}
$post->ID = 0;
$post->post_name = '';
$post->post_author = '';
$post->post_date = '';
$post->post_date_gmt = '';
$post->post_password = '';
$post->post_status = 'draft';
$post->post_type = 'post';
$post->to_ping = '';
$post->pinged = '';
$post->comment_status = get_option( 'default_comment_status' );
$post->ping_status = get_option( 'default_ping_status' );
$post->post_pingback = get_option( 'default_pingback_flag' );
$post->post_category = get_option( 'default_category' );
$post->post_content = apply_filters( 'default_content', $post_content );
$post->post_title = apply_filters( 'default_title', $post_title );
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt );
$post->page_template = 'default';
$post->post_parent = 0;
$post->menu_order = 0;
return $post;
}
public function is_cart_or_member_page( $link ) {
$search = array(
( 'page_id=' . USCES_CART_NUMBER ),
'/usces-cart',
( 'page_id=' . USCES_MEMBER_NUMBER ),
'/usces-member',
);
$flag = false;
foreach ( $search as $value ) {
$parts = array();
if ( false !== strpos( $link, $value ) ) {
if ( $value == ( 'page_id=' . USCES_CART_NUMBER ) || $value == ( 'page_id=' . USCES_MEMBER_NUMBER ) ) {
$parts = parse_url( $link );
parse_str( $parts['query'], $query );
if ( isset( $query['page_id'] ) && ( $query['page_id'] == USCES_CART_NUMBER || $query['page_id'] == USCES_MEMBER_NUMBER ) ) {
$flag = true;
}
} else {
$flag = true;
}
}
}
return $flag;
}
public function is_cart_page( $link ) {
$search = array(
( 'page_id=' . USCES_CART_NUMBER ),
'/usces-cart',
);
$flag = false;
foreach ( $search as $value ) {
if ( false !== strpos( $link, $value ) ) {
if ( $value == ( 'page_id=' . USCES_CART_NUMBER ) ) {
$parts = parse_url( $link );
parse_str( $parts['query'], $query );
if ( isset( $query['page_id'] ) && $query['page_id'] == USCES_CART_NUMBER ) {
$flag = true;
}
} else {
$flag = true;
}
}
}
return $flag;
}
public function is_member_page( $link ) {
$search = array(
( 'page_id=' . USCES_MEMBER_NUMBER ),
'/usces-member',
);
$flag = false;
foreach ( $search as $value ) {
if ( false !== strpos( $link, $value ) ) {
if ( $value == ( 'page_id=' . USCES_MEMBER_NUMBER ) ) {
$parts = parse_url( $link );
parse_str( $parts['query'], $query );
if ( $query['page_id'] == USCES_MEMBER_NUMBER ) {
$flag = true;
}
} else {
$flag = true;
}
}
}
return $flag;
}
public function is_inquiry_page( $link ) {
if ( empty( $this->options['inquiry_id'] ) ) {
return false;
}
$search = array(
( 'page_id=' . $this->options['inquiry_id'] ),
'/usces-inquiry',
);
$flag = false;
foreach ( $search as $value ) {
if ( false !== strpos( $link, $value ) ) {
if ( $value == ( 'page_id=' . $this->options['inquiry_id'] ) ) {
$parts = parse_url( $link );
parse_str( $parts['query'], $query );
if ( $query['page_id'] == $this->options['inquiry_id'] ) {
$flag = true;
}
} else {
$flag = true;
}
}
}
return $flag;
}
public function usces_ssl_page_link( $link ) {
$parts = parse_url( $link );
if ( isset( $parts['query'] ) ) {
parse_str( $parts['query'], $query );
}
if ( false !== strpos( $link, '/usces-cart' ) || ( isset( $query['page_id'] ) && $query['page_id'] == USCES_CART_NUMBER ) ) {
$link = USCES_CART_URL;
} elseif ( false !== strpos( $link, '/usces-member' ) || ( isset( $query['page_id'] ) && $query['page_id'] == USCES_MEMBER_NUMBER ) ) {
$link = USCES_MEMBER_URL;
} elseif ( ! empty( $this->options['inquiry_id'] ) && ( false !== strpos( $link, '/usces-inquiry' ) || ( isset( $query['page_id'] ) && $query['page_id'] == $this->options['inquiry_id'] ) ) ) {
$link = USCES_INQUIRY_URL;
} else {
$link = str_replace( 'https://', 'http://', $link );
$link = apply_filters( 'usces_ssl_page_link', $link );
}
return $link;
}
public function usces_ssl_contents_link( $link ) {
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
$req = explode( '/wp-content/', $link );
$link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
} else {
$link = apply_filters( 'usces_ssl_contents_link', $link );
}
return $link;
}
public function ssl_admin_ajax_url() {
$path = '/wp-admin/admin-ajax.php';
if ( $this->use_ssl && ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) ) {
$link = USCES_SSL_URL_ADMIN . '/wp-admin/admin-ajax.php';
} else {
$link = site_url( $path );
}
$link = apply_filters( 'ssl_admin_ajax_url', $link );
return $link;
}
public function usces_ssl_attachment_link( $link ) {
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
$link = str_replace( site_url(), USCES_SSL_URL_ADMIN, $link );
} else {
$link = apply_filters( 'usces_ssl_attachment_link', $link );
}
return $link;
}
public function usces_ssl_icon_dir_uri( $uri ) {
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
$uri = USCES_SSL_URL_ADMIN . '/' . WPINC . '/images/crystal';
} else {
$uri = apply_filters( 'usces_ssl_icon_dir_uri', $uri );
}
return $uri;
}
public function usces_ssl_script_link( $link ) {
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
if ( strpos( $link, '/wp-content/' ) !== false ) {
$req = explode( '/wp-content/', $link, 2 );
$link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
} elseif ( strpos( $link, '/wp-includes/' ) !== false ) {
$req = explode( '/wp-includes/', $link, 2 );
$link = USCES_SSL_URL_ADMIN . '/wp-includes/' . $req[1];
} elseif ( strpos( $link, '/wp-admin/') !== false ) {
$req = explode( '/wp-admin/', $link, 2 );
$link = USCES_SSL_URL_ADMIN . '/wp-admin/' . $req[1];
}
} else {
$link = apply_filters( 'usces_ssl_script_link', $link );
}
return $link;
}
public function set_action_status( $status, $message ) {
$this->action_status = $status;
$this->action_message = $message;
}
public function add_pages() {
add_menu_page( 'Welcart Shop', 'Welcart Shop', 'wel_publish_products', USCES_PLUGIN_BASENAME, array( $this, 'admin_top_page' ), 'dashicons-cart', '3.0011060' );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Home', 'usces' ), __( 'Home', 'usces' ), 'wel_publish_products', USCES_PLUGIN_BASENAME, array( $this, 'admin_top_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Master Items', 'usces' ), __( 'Master Items', 'usces' ), 'wel_publish_products', 'usces_itemedit', array( $this, 'item_master_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Add New Item', 'usces' ), __( 'Add New Item', 'usces' ), 'wel_publish_products', 'usces_itemnew', array( $this, 'item_master_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'General Setting', 'usces' ), __( 'General Setting', 'usces' ), 'wel_manage_setting', 'usces_initial', array( $this, 'admin_setup_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Business Days Setting', 'usces' ), __( 'Business Days Setting', 'usces' ), 'wel_manage_setting', 'usces_schedule', array( $this, 'admin_schedule_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Shipping Setting', 'usces' ), __( 'Shipping Setting', 'usces' ), 'wel_manage_setting', 'usces_delivery', array( $this, 'admin_delivery_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'E-mail Setting', 'usces' ), __( 'E-mail Setting', 'usces' ), 'wel_manage_setting', 'usces_mail', array( $this, 'admin_mail_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Cart Page Setting', 'usces' ), __( 'Cart Page Setting', 'usces' ), 'wel_manage_setting', 'usces_cart', array( $this, 'admin_cart_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Member Page Setting', 'usces' ), __( 'Member Page Setting', 'usces' ), 'wel_manage_setting', 'usces_member', array( $this, 'admin_member_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'System Setting', 'usces' ), __( 'System Setting', 'usces' ), 'wel_manage_setting', 'usces_system', array( $this, 'admin_system_page' ) );
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Settlement Setting', 'usces' ), __( 'Settlement Setting', 'usces' ), 'wel_manage_setting', 'usces_settlement', array( $this, 'admin_settlement_page' ) );
do_action( 'usces_action_shop_admin_menue' );
add_menu_page( 'Welcart Management', 'Welcart Management', 'wel_manage_order', 'usces_orderlist', array( $this, 'order_list_page' ), 'dashicons-cart', '3.0011070' );
add_submenu_page( 'usces_orderlist', __( 'Order List', 'usces' ), __( 'Order List', 'usces' ), 'wel_manage_order', 'usces_orderlist', array( $this, 'order_list_page' ) );
add_submenu_page( 'usces_orderlist', __( 'New Order or Estimate', 'usces' ), __( 'New Order or Estimate', 'usces' ), 'wel_manage_order', 'usces_ordernew', array( $this, 'order_list_page' ) );
add_submenu_page( 'usces_orderlist', __( 'List of Members', 'usces' ), __( 'List of Members', 'usces' ), 'wel_manage_order', 'usces_memberlist', array( $this, 'member_list_page' ) );
add_submenu_page( 'usces_orderlist', __( 'New Membership Registration', 'usces' ), __( 'New Membership Registration', 'usces' ), 'wel_manage_order', 'usces_membernew', array( $this, 'member_list_page' ) );
Log_List_Table::add_submenu_page();
do_action( 'usces_action_management_admin_menue' );
}
/**
* Item Master Page.
*/
public function item_master_page() {
global $wpdb, $wp_locale;
global $wp_query;
if ( empty( $this->action_message ) || WCUtils::is_blank( $this->action_message ) ) {
$this->action_status = 'none';
$this->action_message = '';
}
if ( 'usces_itemnew' == $_REQUEST['page'] ) {
$action = 'new';
} else {
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
}
do_action( 'usces_action_item_master_page', $action );
switch ( $action ) {
case 'dlitemlist':
usces_download_item_list();
break;
case 'upload_register':
require_once USCES_PLUGIN_DIR . '/includes/usces_item_master_upload_register.php';
break;
case 'delete':
case 'new':
case 'editpost':
case 'edit':
global $current_user;
require_once USCES_PLUGIN_DIR . '/includes/usces_item_master_edit.php';
break;
default:
require_once USCES_PLUGIN_DIR . '/includes/usces_item_master_list.php';
break;
}
}
/**
* Order list page.
*/
public function order_list_page() {
$order_edit_form = apply_filters( 'usces_admin_order_edit_form', USCES_PLUGIN_DIR . '/includes/order_edit_form.php' );
$order_list = apply_filters( 'usces_admin_order_list', USCES_PLUGIN_DIR . '/includes/order_list.php' );
if ( empty( $this->action_message ) || WCUtils::is_blank( $this->action_message ) ) {
$this->action_status = 'none';
$this->action_message = '';
}
if ( 'usces_ordernew' == $_REQUEST['page'] ) {
$order_action = 'new';
} else {
$order_action = isset( $_REQUEST['order_action'] ) ? $_REQUEST['order_action'] : '';
}
do_action( 'usces_action_order_list_page', $order_action );
Log_List_Table::add_order_meta_box( $order_action );
switch ( $order_action ) {
case 'dlproductlist':
check_admin_referer( 'order_list', 'wc_nonce' );
usces_download_product_list();
break;
case 'dlorderlist':
check_admin_referer( 'order_list', 'wc_nonce' );
usces_download_order_list();
break;
case 'dlsettlementerrorlog':
check_admin_referer( 'order_list', 'wc_nonce' );
usces_download_settlement_error_log();
break;
case 'editpost':
check_admin_referer( 'order_edit', 'wc_nonce' );
$logger = Logger::start( $_REQUEST['order_id'], 'orderedit', 'update' );
do_action( 'usces_pre_update_orderdata', $_REQUEST['order_id'] );
$res = usces_update_orderdata();
if ( 1 === $res ) {
$backtolist = ( empty( $_POST['usces_referer'] ) || false !== strpos( $_POST['usces_referer'], 'order_action=editpost' ) ) ? admin_url( 'admin.php?page=usces_orderlist&returnList=1&wc_nonce=' . wp_create_nonce( 'order_list' ) ) : esc_url( stripslashes( $_POST['usces_referer'] ) );
$this->set_action_status( 'success', __( 'order date is updated', 'usces' ) . ' ' . __( 'back to the summary', 'usces' ) . '' );
} elseif ( 0 === $res ) {
$this->set_action_status( 'none', '' );
} else {
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in update', 'usces' ) );
}
$logger->flush();
do_action( 'usces_after_update_orderdata', $_REQUEST['order_id'], $res );
require_once $order_edit_form;
break;
case 'newpost':
check_admin_referer( 'order_edit', 'wc_nonce' );
do_action( 'usces_pre_new_orderdata' );
$res = usces_new_orderdata();
if ( 1 === $res ) {
$this->set_action_status( 'success', __( 'New date is add', 'usces' ) );
Logger::start( $_REQUEST['order_id'], 'ordernew', 'create' )->flush();
} elseif ( 0 === $res ) {
$this->set_action_status( 'none', '' );
} else {
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in addition', 'usces' ) );
}
do_action( 'usces_after_new_orderdata', $res );
$_REQUEST['order_action'] = 'edit';
$order_action = $_REQUEST['order_action'];
require_once $order_edit_form;
break;
case 'new':
case 'edit':
require_once $order_edit_form;
break;
case 'load_rich_editor':
wp_enqueue_style( 'colors' );
require_once USCES_PLUGIN_DIR . '/includes/order_detail_rich_editor.php';
break;
case 'delete':
check_admin_referer( 'order_list', 'wc_nonce' );
do_action( 'usces_pre_delete_orderdata', $_REQUEST['order_id'] );
$logger = Logger::start( $_REQUEST['order_id'], 'orderlist', 'delete' );
$res = usces_delete_orderdata();
if ( 1 === $res ) {
$this->set_action_status( 'success', __( 'the order date is deleted', 'usces' ) );
$logger->flush();
} elseif ( 0 === $res ) {
$this->set_action_status( 'none', '' );
} else {
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
}
do_action( 'usces_after_delete_orderdata', $_REQUEST['order_id'], $res );
default:
require_once $order_list;
}
}
/**
* Member list page.
*/
public function member_list_page() {
$member_edit_form = apply_filters( 'usces_admin_member_edit_form', USCES_PLUGIN_DIR . '/includes/member_edit_form.php' );
$member_list = apply_filters( 'usces_admin_member_list', USCES_PLUGIN_DIR . '/includes/member_list.php' );
if ( empty( $this->action_message ) || WCUtils::is_blank( $this->action_message ) ) {
$this->action_status = 'none';
$this->action_message = '';
}
if ( 'usces_membernew' == $_REQUEST['page'] ) {
$member_action = isset( $_REQUEST['member_action'] ) ? $_REQUEST['member_action'] : 'new';
} else {
$member_action = isset( $_REQUEST['member_action'] ) ? $_REQUEST['member_action'] : '';
}
do_action( 'usces_action_member_list_page', $member_action );
Log_List_Table::add_member_meta_box( $member_action );
switch ( $member_action ) {
case 'dlmemberlist':
check_admin_referer( 'post_member', 'wc_nonce' );
usces_download_member_list();
break;
case 'editpost':
check_admin_referer( 'post_member', 'wc_nonce' );
$logger = Logger::start( $_REQUEST['member_id'], 'memberedit', 'update' );
$this->error_message = $this->admin_member_check();
if ( WCUtils::is_blank( $this->error_message ) ) {
$res = usces_update_memberdata();
if ( 1 === $res ) {
$this->set_action_status( 'success', __( 'Membership information is updated', 'usces' ) );
$logger->flush();
} elseif ( 0 === $res ) {
$this->set_action_status( 'none', '' );
} else {
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in update', 'usces' ) );
}
} else {
$this->set_action_status( 'error', 'ERROR : ' . $this->error_message );
}
require_once $member_edit_form;
break;
case 'newpost':
check_admin_referer( 'post_member', 'wc_nonce' );
$this->error_message = $this->admin_new_member_check();
if ( WCUtils::is_blank( $this->error_message ) ) {
$res = usces_new_memberdata();
if ( 1 === $res ) {
$this->set_action_status( 'success', __( 'New member registration is complete.', 'usces' ) );
$_REQUEST['member_action'] = 'edit';
$member_action = $_REQUEST['member_action'];
Logger::start( $_REQUEST['member_id'], 'membernew', 'create' )->flush();
} elseif ( 0 === $res ) {
$this->set_action_status( 'none', '' );
} else {
$this->set_action_status( 'error', 'ERROR : ' . __( 'Failed to new member registration.', 'usces' ) );
}
} else {
$this->set_action_status( 'error', $this->error_message );
$member_action = 'new';
}
require_once $member_edit_form;
break;
case 'new':
require_once $member_edit_form;
break;
case 'edit':
check_admin_referer( 'member_list', 'wc_nonce' );
require_once $member_edit_form;
break;
case 'delete':
check_admin_referer( 'delete_member', 'wc_nonce' );
if ( ! isset( $_REQUEST['member_id'] ) || WCUtils::is_blank( $_REQUEST['member_id'] ) ) {
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
} else {
$logger = Logger::start( $_REQUEST['member_id'], 'memberlist', 'delete' );
$member_id = $_REQUEST['member_id'];
$del = usces_delete_member_check( $member_id );
if ( $del ) {
$res = usces_delete_memberdata( $member_id );
if ( 1 === $res ) {
$this->set_action_status( 'success', __( 'The member data is deleted', 'usces' ) );
} elseif ( 0 === $res ) {
$this->set_action_status( 'none', '' );
} else {
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
}
$logger->flush();
} else {
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
}
}
default:
require_once $member_list;
}
}
/**
* Shop Top Page.
*/
public function admin_top_page() {
$action = filter_input( INPUT_GET, 'wel_action', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR );
if ( ! wel_need_to_update_db() ) {
$action = '';
}
switch ( $action ) {
case 'update_db':
if ( ! current_user_can( 'wel_manage_setting' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
check_admin_referer( 'wel_update_database', '_welnonce' );
require_once USCES_PLUGIN_DIR . '/includes/database/db-progress-screen.php';
break;
default:
$path = apply_filters( 'usces_filter_admin_top_page', USCES_PLUGIN_DIR . '/includes/admin_top.php' );
require_once $path;
}
}
/**
* Shop Setup Page.
*/
public function admin_setup_page() {
$this->options = get_option( 'usces' );
if ( isset( $_POST['usces_option_update'] ) ) {
check_admin_referer( 'admin_setup', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$order_mail = '';
if ( isset( $_POST['order_mail'] ) ) {
$order_mails = array_map( 'trim', explode( ',', $_POST['order_mail'] ) );
$valid_mails = array();
foreach ( $order_mails as $mail ) {
if ( is_email( $mail ) ) {
$valid_mails[] = $mail;
}
}
$order_mail = implode( ',', $valid_mails );
} else {
$order_mail = '';
}
$this->options['display_mode'] = isset( $_POST['display_mode'] ) ? trim( $_POST['display_mode'] ) : '';
$this->options['campaign_category'] = empty( $_POST['cat'] ) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat'];
$this->options['campaign_privilege'] = isset( $_POST['cat_privilege'] ) ? trim( $_POST['cat_privilege'] ) : '';
$this->options['privilege_point'] = isset( $_POST['point_num'] ) ? (int) $_POST['point_num'] : '';
$this->options['privilege_discount'] = isset( $_POST['discount_num'] ) ? (int) $_POST['discount_num'] : '';
$this->options['company_name'] = isset( $_POST['company_name'] ) ? trim( $_POST['company_name'] ) : '';
$this->options['zip_code'] = isset( $_POST['zip_code'] ) ? trim( $_POST['zip_code'] ) : '';
$this->options['address1'] = isset( $_POST['address1'] ) ? trim( $_POST['address1'] ) : '';
$this->options['address2'] = isset( $_POST['address2'] ) ? trim( $_POST['address2'] ) : '';
$this->options['tel_number'] = isset( $_POST['tel_number'] ) ? trim( $_POST['tel_number'] ) : '';
$this->options['fax_number'] = isset( $_POST['fax_number'] ) ? trim( $_POST['fax_number'] ) : '';
$this->options['order_mail'] = $order_mail;
$this->options['inquiry_mail'] = isset( $_POST['inquiry_mail'] ) && is_email( trim( $_POST['inquiry_mail'] ) ) ? trim( $_POST['inquiry_mail'] ) : '';
$this->options['sender_mail'] = isset( $_POST['sender_mail'] ) && is_email( trim( $_POST['sender_mail'] ) ) ? trim( $_POST['sender_mail'] ) : '';
$this->options['error_mail'] = isset( $_POST['error_mail'] ) && is_email( trim( $_POST['error_mail'] ) ) ? trim( $_POST['error_mail'] ) : '';
$this->options['postage_privilege'] = isset( $_POST['postage_privilege'] ) ? trim( $_POST['postage_privilege'] ) : '';
$this->options['purchase_limit'] = isset( $_POST['purchase_limit'] ) ? trim( $_POST['purchase_limit'] ) : '';
$this->options['point_rate'] = isset( $_POST['point_rate'] ) ? (int) $_POST['point_rate'] : 1;
$this->options['start_point'] = isset( $_POST['start_point'] ) ? (int) $_POST['start_point'] : '';
$this->options['shipping_rule'] = isset( $_POST['shipping_rule'] ) ? trim( $_POST['shipping_rule'] ) : '';
$this->options['tax_display'] = isset( $_POST['tax_display'] ) ? trim( $_POST['tax_display'] ) : 'activate';
$this->options['tax_mode'] = isset( $_POST['tax_mode'] ) ? trim( $_POST['tax_mode'] ) : 'include';
$this->options['tax_target'] = isset( $_POST['tax_target'] ) ? trim( $_POST['tax_target'] ) : 'products';
$this->options['tax_rate'] = isset( $_POST['tax_rate'] ) ? (int) $_POST['tax_rate'] : '';
$this->options['tax_method'] = isset( $_POST['tax_method'] ) ? trim( $_POST['tax_method'] ) : '';
$this->options['applicable_taxrate'] = ( isset( $_POST['applicable_taxrate'] ) ) ? $_POST['applicable_taxrate'] : 'standard';
$this->options['tax_rate_reduced'] = ( isset( $_POST['tax_rate_reduced'] ) ) ? (int) $_POST['tax_rate_reduced'] : '';
$this->options['cod_type'] = isset( $this->options['cod_type'] ) ? $this->options['cod_type'] : 'fix';
$this->options['fee_subject'] = ( isset( $_POST['fee_subject'] ) ) ? trim( $_POST['fee_subject'] ) : 'all';
$this->options['transferee'] = isset( $_POST['transferee'] ) ? trim( $_POST['transferee'] ) : '';
$this->options['tatransfer_limit'] = isset( $_POST['tatransfer_limit'] ) ? trim( $_POST['tatransfer_limit'] ) : '';
$this->options['copyright'] = isset( $_POST['copyright'] ) ? trim( $_POST['copyright'] ) : '';
$this->options['business_registration_number'] = ( isset( $_POST['business_registration_number'] ) ) ? trim( $_POST['business_registration_number'] ) : '';
$this->options['membersystem_state'] = isset( $_POST['membersystem_state'] ) ? trim( $_POST['membersystem_state'] ) : '';
$this->options['membersystem_point'] = isset( $_POST['membersystem_point'] ) ? trim( $_POST['membersystem_point'] ) : '';
$this->options['point_coverage'] = isset( $_POST['point_coverage'] ) ? (int) $_POST['point_coverage'] : 0;
$this->options['point_assign'] = isset( $_POST['point_assign'] ) ? (int) $_POST['point_assign'] : 1;
$this->options['address_search'] = isset( $_POST['address_search'] ) ? trim( $_POST['address_search'] ) : 'deactivate';
$this->options['stock_status_label'] = ( isset( $_POST['stock_status_label'] ) ) ? $_POST['stock_status_label'] : array();
$this->options['order_acceptable_label'] = ( isset( $_POST['order_acceptable_label'] ) ) ? trim( $_POST['order_acceptable_label'] ) : '';
$this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options );
update_option( 'usces', $this->options );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} else {
$this->action_status = 'none';
$this->action_message = '';
}
require_once USCES_PLUGIN_DIR . '/includes/admin_setup.php';
}
/**
* Shop Schedule Page
*/
public function admin_schedule_page() {
$this->options = get_option( 'usces' );
if ( isset( $_POST['usces_option_update'] ) ) {
check_admin_referer( 'admin_schedule', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$this->options['campaign_schedule'] = isset( $_POST['campaign_schedule'] ) ? $_POST['campaign_schedule'] : '0';
if ( isset( $_POST['business_days'] ) ) {
$this->options['business_days'] = $_POST['business_days'];
}
update_option( 'usces', $this->options );
do_action( 'usces_action_admin_schedule_update' );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} else {
$this->action_status = 'none';
$this->action_message = '';
}
require_once USCES_PLUGIN_DIR . '/includes/admin_schedule.php';
}
/**
* Shop Delivery Page.
*/
public function admin_delivery_page() {
$this->options = get_option( 'usces' );
if ( isset( $_POST['usces_option_update'] ) ) {
check_admin_referer( 'admin_delivery', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
if ( isset( $_POST['delivery_time_limit'] ) ) {
$this->options['delivery_time_limit'] = $_POST['delivery_time_limit'];
}
if ( isset( $_POST['shortest_delivery_time'] ) ) {
$this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time'];
}
if ( isset( $_POST['delivery_after_days'] ) ) {
$this->options['delivery_after_days'] = $_POST['delivery_after_days'];
}
$this->options = apply_filters( 'usces_filter_admin_delivery_options', $this->options );
update_option( 'usces', $this->options );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} else {
$this->action_status = 'none';
$this->action_message = '';
}
require_once USCES_PLUGIN_DIR . '/includes/admin_delivery.php';
}
/**
* Shop Mail Page.
*/
public function admin_mail_page() {
global $allowedposttags;
if ( isset( $_POST['usces_option_update'] ) ) {
check_admin_referer( 'admin_mail', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$mail_othermail = get_option( 'usces_mail_othermail', array() );
foreach ( $_POST['title'] as $key => $value ) {
$value = wel_esc_script( $value );
if ( 'othermail' == $key ) {
if ( WCUtils::is_blank( $value ) ) {
if ( empty( $mail_othermail['title'] ) && isset( $this->options['mail_default']['title'][ $key ] ) ) {
$mail_othermail['title'] = $this->options['mail_default']['title'][ $key ];
$this->options['mail_data']['title'][ $key ] = $mail_othermail['title'];
}
} else {
$mail_othermail['title'] = trim( $value );
$this->options['mail_data']['title'][ $key ] = $mail_othermail['title'];
}
} else {
if ( WCUtils::is_blank( $value ) ) {
$this->options['mail_data']['title'][ $key ] = isset( $this->options['mail_default']['title'][ $key ] ) ? $this->options['mail_default']['title'][ $key ] : '';
} else {
$this->options['mail_data']['title'][ $key ] = trim( $value );
}
}
}
foreach ( $_POST['header'] as $key => $value ) {
$value = wel_esc_script( $value );
if ( 'othermail' == $key ) {
if ( WCUtils::is_blank( $value ) ) {
if ( empty( $mail_othermail['header'] ) && isset( $this->options['mail_default']['header'][ $key ] ) ) {
$mail_othermail['header'] = $this->options['mail_default']['header'][ $key ];
$this->options['mail_data']['header'][ $key ] = $mail_othermail['header'];
}
} else {
$mail_othermail['header'] = $value;
$this->options['mail_data']['header'][ $key ] = $mail_othermail['header'];
}
} else {
if ( WCUtils::is_blank( $value ) ) {
$this->options['mail_data']['header'][ $key ] = isset( $this->options['mail_default']['header'][ $key ] ) ? $this->options['mail_default']['header'][ $key ] : '';
} else {
$this->options['mail_data']['header'][ $key ] = $value;
}
}
}
foreach ( $_POST['footer'] as $key => $value ) {
$value = wel_esc_script( $value );
if ( 'othermail' == $key ) {
if ( WCUtils::is_blank( $value ) ) {
if ( empty( $mail_othermail['footer'] ) && isset( $this->options['mail_default']['footer'][ $key ] ) ) {
$mail_othermail['footer'] = $this->options['mail_default']['footer'][ $key ];
$this->options['mail_data']['footer'][ $key ] = $mail_othermail['footer'];
}
} else {
$mail_othermail['footer'] = $value;
$this->options['mail_data']['footer'][ $key ] = $mail_othermail['footer'];
}
} else {
if ( WCUtils::is_blank( $value ) ) {
$this->options['mail_data']['footer'][ $key ] = isset( $this->options['mail_default']['footer'][ $key ] ) ? $this->options['mail_default']['footer'][ $key ] : '';
} else {
$this->options['mail_data']['footer'][ $key ] = $value;
}
}
}
update_option( 'usces', $this->options );
update_option( 'usces_mail_othermail', $mail_othermail );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} elseif ( isset( $_POST['usces_option_update_top'] ) ) {
check_admin_referer( 'admin_mail', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$email_attach_file_extension = wel_email_attach_file_extension( explode( ',', trim( wel_esc_script( $_POST['email_attach_file_extension'] ) ) ) );
$this->options['smtp_hostname'] = esc_html( trim( $_POST['smtp_hostname'] ) );
$this->options['newmem_admin_mail'] = (int) $_POST['newmem_admin_mail'];
$this->options['updmem_admin_mail'] = (int) $_POST['updmem_admin_mail'];
$this->options['updmem_customer_mail'] = (int) $_POST['updmem_customer_mail'];
$this->options['delmem_admin_mail'] = (int) $_POST['delmem_admin_mail'];
$this->options['delmem_customer_mail'] = (int) $_POST['delmem_customer_mail'];
$this->options['put_customer_name'] = (int) $_POST['put_customer_name'];
$this->options['email_attach_feature'] = (int) $_POST['email_attach_feature'];
$this->options['email_attach_file_extension'] = implode( ',', $email_attach_file_extension );
$this->options['email_attach_file_size'] = (int) $_POST['email_attach_file_size'];
$this->options['add_html_email_option'] = (int) $_POST['add_html_email_option'];
update_option( 'usces', $this->options );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} elseif ( isset( $_POST['usces_option_update_auto'] ) ) {
check_admin_referer( 'admin_mail', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$mail_thankyou = get_option( 'usces_mail_thankyou', array() );
if ( WCUtils::is_blank( $_POST['title']['thankyou'] ) ) {
if ( empty( $mail_thankyou['title'] ) && isset( $this->options['mail_default']['title']['thankyou'] ) ) {
$mail_thankyou['title'] = $this->options['mail_default']['title']['thankyou'];
$this->options['mail_data']['title']['thankyou'] = $mail_thankyou['title'];
}
} else {
$mail_thankyou['title'] = trim( wel_esc_script( $_POST['title']['thankyou'] ) );
$this->options['mail_data']['title']['thankyou'] = $mail_thankyou['title'];
}
if ( WCUtils::is_blank( $_POST['header']['thankyou'] ) ) {
if ( empty( $mail_thankyou['header'] ) && isset( $this->options['mail_default']['header']['thankyou'] ) ) {
$mail_thankyou['header'] = $this->options['mail_default']['header']['thankyou'];
$this->options['mail_data']['header']['thankyou'] = $mail_thankyou['header'];
}
} else {
$mail_thankyou['header'] = trim( wel_esc_script( $_POST['header']['thankyou'] ) );
$this->options['mail_data']['header']['thankyou'] = $mail_thankyou['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['thankyou'] ) ) {
if ( empty( $mail_thankyou['footer'] ) && isset( $this->options['mail_default']['footer']['thankyou'] ) ) {
$mail_thankyou['footer'] = $this->options['mail_default']['footer']['thankyou'];
$this->options['mail_data']['footer']['thankyou'] = $mail_thankyou['footer'];
}
} else {
$mail_thankyou['footer'] = trim( wel_esc_script( $_POST['footer']['thankyou'] ) );
$this->options['mail_data']['footer']['thankyou'] = $mail_thankyou['footer'];
}
update_option( 'usces_mail_thankyou', $mail_thankyou );
$mail_order = get_option( 'usces_mail_order', array() );
if ( WCUtils::is_blank( $_POST['title']['order'] ) ) {
if ( empty( $mail_order['title'] ) && isset( $this->options['mail_default']['title']['order'] ) ) {
$mail_order['title'] = $this->options['mail_default']['title']['order'];
$this->options['mail_data']['title']['order'] = $mail_order['title'];
}
} else {
$mail_order['title'] = trim( wel_esc_script( $_POST['title']['order'] ) );
$this->options['mail_data']['title']['order'] = $mail_order['title'];
}
if ( WCUtils::is_blank( $_POST['header']['order'] ) ) {
if ( empty( $mail_order['header'] ) && isset( $this->options['mail_default']['header']['order'] ) ) {
$mail_order['header'] = $this->options['mail_default']['header']['order'];
$this->options['mail_data']['header']['order'] = $mail_order['header'];
}
} else {
$mail_order['header'] = trim( wel_esc_script( $_POST['header']['order'] ) );
$this->options['mail_data']['header']['order'] = $mail_order['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['order'] ) ) {
if ( empty( $mail_order['footer'] ) && isset( $this->options['mail_default']['footer']['order'] ) ) {
$mail_order['footer'] = $this->options['mail_default']['footer']['order'];
$this->options['mail_data']['footer']['order'] = $mail_order['footer'];
}
} else {
$mail_order['footer'] = trim( wel_esc_script( $_POST['footer']['order'] ) );
$this->options['mail_data']['footer']['order'] = $mail_order['footer'];
}
update_option( 'usces_mail_order', $mail_order );
$mail_inquiry = get_option( 'usces_mail_inquiry', array() );
if ( WCUtils::is_blank( $_POST['title']['inquiry'] ) ) {
if ( empty( $mail_inquiry['title'] ) && isset( $this->options['mail_default']['title']['inquiry'] ) ) {
$mail_inquiry['title'] = $this->options['mail_default']['title']['inquiry'];
$this->options['mail_data']['title']['inquiry'] = $mail_inquiry['title'];
}
} else {
$mail_inquiry['title'] = trim( wel_esc_script( $_POST['title']['inquiry'] ) );
$this->options['mail_data']['title']['inquiry'] = $mail_inquiry['title'];
}
if ( WCUtils::is_blank( $_POST['header']['inquiry'] ) ) {
if ( empty( $mail_inquiry['header'] ) && isset( $this->options['mail_default']['header']['inquiry'] ) ) {
$mail_inquiry['header'] = $this->options['mail_default']['header']['inquiry'];
$this->options['mail_data']['header']['inquiry'] = $mail_inquiry['header'];
}
} else {
$mail_inquiry['header'] = trim( wel_esc_script( $_POST['header']['inquiry'] ) );
$this->options['mail_data']['header']['inquiry'] = $mail_inquiry['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['inquiry'] ) ) {
if ( empty( $mail_inquiry['footer'] ) && isset( $this->options['mail_default']['footer']['inquiry'] ) ) {
$mail_inquiry['footer'] = $this->options['mail_default']['footer']['inquiry'];
$this->options['mail_data']['footer']['inquiry'] = $mail_inquiry['footer'];
}
} else {
$mail_inquiry['footer'] = trim( wel_esc_script( $_POST['footer']['inquiry'] ) );
$this->options['mail_data']['footer']['inquiry'] = $mail_inquiry['footer'];
}
update_option( 'usces_mail_inquiry', $mail_inquiry );
$mail_membercomp = get_option( 'usces_mail_membercomp', array() );
if ( WCUtils::is_blank( $_POST['title']['membercomp'] ) ) {
if ( empty( $mail_membercomp['title'] ) && isset( $this->options['mail_default']['title']['membercomp'] ) ) {
$mail_membercomp['title'] = $this->options['mail_default']['title']['membercomp'];
$this->options['mail_data']['title']['membercomp'] = $mail_membercomp['title'];
}
} else {
$mail_membercomp['title'] = trim( wel_esc_script( $_POST['title']['membercomp'] ) );
$this->options['mail_data']['title']['membercomp'] = $mail_membercomp['title'];
}
if ( WCUtils::is_blank( wel_esc_script( $_POST['header']['membercomp'] ) ) ) {
if ( empty( $mail_membercomp['header'] ) && isset( $this->options['mail_default']['header']['membercomp'] ) ) {
$mail_membercomp['header'] = $this->options['mail_default']['header']['membercomp'];
$this->options['mail_data']['header']['membercomp'] = $mail_membercomp['header'];
}
} else {
$mail_membercomp['header'] = trim( wel_esc_script( $_POST['header']['membercomp'] ) );
$this->options['mail_data']['header']['membercomp'] = $mail_membercomp['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['membercomp'] ) ) {
if ( empty( $mail_membercomp['footer'] ) && isset( $this->options['mail_default']['footer']['membercomp'] ) ) {
$mail_membercomp['footer'] = $this->options['mail_default']['footer']['membercomp'];
$this->options['mail_data']['footer']['membercomp'] = $mail_membercomp['footer'];
}
} else {
$mail_membercomp['footer'] = trim( wel_esc_script( $_POST['footer']['membercomp'] ) );
$this->options['mail_data']['footer']['membercomp'] = $mail_membercomp['footer'];
}
update_option( 'usces_mail_membercomp', $mail_membercomp );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} elseif ( isset( $_POST['usces_option_update_manual'] ) ) {
check_admin_referer( 'admin_mail', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$mail_completionmail = get_option( 'usces_mail_completionmail', array() );
if ( WCUtils::is_blank( $_POST['title']['completionmail'] ) ) {
if ( empty( $mail_completionmail['title'] ) && isset( $this->options['mail_default']['title']['completionmail'] ) ) {
$mail_completionmail['title'] = $this->options['mail_default']['title']['completionmail'];
$this->options['mail_data']['title']['completionmail'] = $mail_completionmail['title'];
}
} else {
$mail_completionmail['title'] = trim( wel_esc_script( $_POST['title']['completionmail'] ) );
$this->options['mail_data']['title']['completionmail'] = $mail_completionmail['title'];
}
if ( WCUtils::is_blank( $_POST['header']['completionmail'] ) ) {
if ( empty( $mail_completionmail['header'] ) && isset( $this->options['mail_default']['header']['completionmail'] ) ) {
$mail_completionmail['header'] = $this->options['mail_default']['header']['completionmail'];
$this->options['mail_data']['header']['completionmail'] = $mail_completionmail['header'];
}
} else {
$mail_completionmail['header'] = trim( wel_esc_script( $_POST['header']['completionmail'] ) );
$this->options['mail_data']['header']['completionmail'] = $mail_completionmail['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['completionmail'] ) ) {
if ( empty( $mail_completionmail['footer'] ) && isset( $this->options['mail_default']['footer']['completionmail'] ) ) {
$mail_completionmail['footer'] = $this->options['mail_default']['footer']['completionmail'];
$this->options['mail_data']['footer']['completionmail'] = $mail_completionmail['footer'];
}
} else {
$mail_completionmail['footer'] = trim( wel_esc_script( $_POST['footer']['completionmail'] ) );
$this->options['mail_data']['footer']['completionmail'] = $mail_completionmail['footer'];
}
update_option( 'usces_mail_completionmail', $mail_completionmail );
$mail_ordermail = get_option( 'usces_mail_ordermail', array() );
if ( WCUtils::is_blank( $_POST['title']['ordermail'] ) ) {
if ( empty( $mail_ordermail['title'] ) && isset( $this->options['mail_default']['title']['ordermail'] ) ) {
$mail_ordermail['title'] = $this->options['mail_default']['title']['ordermail'];
$this->options['mail_data']['title']['ordermail'] = $mail_ordermail['title'];
}
} else {
$mail_ordermail['title'] = trim( wel_esc_script( $_POST['title']['ordermail'] ) );
$this->options['mail_data']['title']['ordermail'] = $mail_ordermail['title'];
}
if ( WCUtils::is_blank( $_POST['header']['ordermail'] ) ) {
if ( empty( $mail_ordermail['header'] ) && isset( $this->options['mail_default']['header']['ordermail'] ) ) {
$mail_ordermail['header'] = $this->options['mail_default']['header']['ordermail'];
$this->options['mail_data']['header']['ordermail'] = $mail_ordermail['header'];
}
} else {
$mail_ordermail['header'] = trim( wel_esc_script( $_POST['header']['ordermail'] ) );
$this->options['mail_data']['header']['ordermail'] = $mail_ordermail['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['ordermail'] ) ) {
if ( empty( $mail_ordermail['footer'] ) && isset( $this->options['mail_default']['footer']['ordermail'] ) ) {
$mail_ordermail['footer'] = $this->options['mail_default']['footer']['ordermail'];
$this->options['mail_data']['footer']['ordermail'] = $mail_ordermail['footer'];
}
} else {
$mail_ordermail['footer'] = trim( wel_esc_script( $_POST['footer']['ordermail'] ) );
$this->options['mail_data']['footer']['ordermail'] = $mail_ordermail['footer'];
}
update_option( 'usces_mail_ordermail', $mail_ordermail );
$mail_changemail = get_option( 'usces_mail_changemail', array() );
if ( WCUtils::is_blank( $_POST['title']['changemail'] ) ) {
if ( empty( $mail_changemail['title'] ) && isset( $this->options['mail_default']['title']['changemail'] ) ) {
$mail_changemail['title'] = $this->options['mail_default']['title']['changemail'];
$this->options['mail_data']['title']['changemail'] = $mail_changemail['title'];
}
} else {
$mail_changemail['title'] = trim( wel_esc_script( $_POST['title']['changemail'] ) );
$this->options['mail_data']['title']['changemail'] = $mail_changemail['title'];
}
if ( WCUtils::is_blank( $_POST['header']['changemail'] ) ) {
if ( empty( $mail_changemail['header'] ) && isset( $this->options['mail_default']['header']['changemail'] ) ) {
$mail_changemail['header'] = $this->options['mail_default']['header']['changemail'];
$this->options['mail_data']['header']['changemail'] = $mail_changemail['header'];
}
} else {
$mail_changemail['header'] = trim( wel_esc_script( $_POST['header']['changemail'] ) );
$this->options['mail_data']['header']['changemail'] = $mail_changemail['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['changemail'] ) ) {
if ( empty( $mail_changemail['footer'] ) && isset( $this->options['mail_default']['footer']['changemail'] ) ) {
$mail_changemail['footer'] = $this->options['mail_default']['footer']['changemail'];
$this->options['mail_data']['footer']['changemail'] = $mail_changemail['footer'];
}
} else {
$mail_changemail['footer'] = trim( wel_esc_script( $_POST['footer']['changemail'] ) );
$this->options['mail_data']['footer']['changemail'] = $mail_changemail['footer'];
}
update_option( 'usces_mail_changemail', $mail_changemail );
$mail_receiptmail = get_option( 'usces_mail_receiptmail', array() );
if ( WCUtils::is_blank( $_POST['title']['receiptmail'] ) ) {
if ( empty( $mail_receiptmail['title'] ) && isset( $this->options['mail_default']['title']['receiptmail'] ) ) {
$mail_receiptmail['title'] = $this->options['mail_default']['title']['receiptmail'];
$this->options['mail_data']['title']['receiptmail'] = $mail_receiptmail['title'];
}
} else {
$mail_receiptmail['title'] = trim( wel_esc_script( $_POST['title']['receiptmail'] ) );
$this->options['mail_data']['title']['receiptmail'] = $mail_receiptmail['title'];
}
if ( WCUtils::is_blank( $_POST['header']['receiptmail'] ) ) {
if ( empty( $mail_receiptmail['header'] ) && isset( $this->options['mail_default']['header']['receiptmail'] ) ) {
$mail_receiptmail['header'] = $this->options['mail_default']['header']['receiptmail'];
$this->options['mail_data']['header']['receiptmail'] = $mail_receiptmail['header'];
}
} else {
$mail_receiptmail['header'] = trim( wel_esc_script( $_POST['header']['receiptmail'] ) );
$this->options['mail_data']['header']['receiptmail'] = $mail_receiptmail['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['receiptmail'] ) ) {
if ( empty( $mail_receiptmail['footer'] ) && isset( $this->options['mail_default']['footer']['receiptmail'] ) ) {
$mail_receiptmail['footer'] = $this->options['mail_default']['footer']['receiptmail'];
$this->options['mail_data']['footer']['receiptmail'] = $mail_receiptmail['footer'];
}
} else {
$mail_receiptmail['footer'] = trim( wel_esc_script( $_POST['footer']['receiptmail'] ) );
$this->options['mail_data']['footer']['receiptmail'] = $mail_receiptmail['footer'];
}
update_option( 'usces_mail_receiptmail', $mail_receiptmail );
$mail_mitumorimail = get_option( 'usces_mail_mitumorimail', array() );
if ( WCUtils::is_blank( $_POST['title']['mitumorimail'] ) ) {
if ( empty( $mail_mitumorimail['title'] ) && isset( $this->options['mail_default']['title']['mitumorimail'] ) ) {
$mail_mitumorimail['title'] = $this->options['mail_default']['title']['mitumorimail'];
$this->options['mail_data']['title']['mitumorimail'] = $mail_mitumorimail['title'];
}
} else {
$mail_mitumorimail['title'] = trim( wel_esc_script( $_POST['title']['mitumorimail'] ) );
$this->options['mail_data']['title']['mitumorimail'] = $mail_mitumorimail['title'];
}
if ( WCUtils::is_blank( $_POST['header']['mitumorimail'] ) ) {
if ( empty( $mail_mitumorimail['header'] ) && isset( $this->options['mail_default']['header']['mitumorimail'] ) ) {
$mail_mitumorimail['header'] = $this->options['mail_default']['header']['mitumorimail'];
$this->options['mail_data']['header']['mitumorimail'] = $mail_mitumorimail['header'];
}
} else {
$mail_mitumorimail['header'] = trim( wel_esc_script( $_POST['header']['mitumorimail'] ) );
$this->options['mail_data']['header']['mitumorimail'] = $mail_mitumorimail['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['mitumorimail'] ) ) {
if ( empty( $mail_mitumorimail['footer'] ) && isset( $this->options['mail_default']['footer']['mitumorimail'] ) ) {
$mail_mitumorimail['footer'] = $this->options['mail_default']['footer']['mitumorimail'];
$this->options['mail_data']['footer']['mitumorimail'] = $mail_mitumorimail['footer'];
}
} else {
$mail_mitumorimail['footer'] = trim( wel_esc_script( $_POST['footer']['mitumorimail'] ) );
$this->options['mail_data']['footer']['mitumorimail'] = $mail_mitumorimail['footer'];
}
update_option( 'usces_mail_mitumorimail', $mail_mitumorimail );
$mail_cancelmail = get_option( 'usces_mail_cancelmail', array() );
if ( WCUtils::is_blank( $_POST['title']['cancelmail'] ) ) {
if ( empty( $mail_cancelmail['title'] ) && isset( $this->options['mail_default']['title']['cancelmail'] ) ) {
$mail_cancelmail['title'] = $this->options['mail_default']['title']['cancelmail'];
$this->options['mail_data']['title']['cancelmail'] = $mail_cancelmail['title'];
}
} else {
$mail_cancelmail['title'] = trim( wel_esc_script( $_POST['title']['cancelmail'] ) );
$this->options['mail_data']['title']['cancelmail'] = $mail_cancelmail['title'];
}
if ( WCUtils::is_blank( $_POST['header']['cancelmail'] ) ) {
if ( empty( $mail_cancelmail['header'] ) && isset( $this->options['mail_default']['header']['cancelmail'] ) ) {
$mail_cancelmail['header'] = $this->options['mail_default']['header']['cancelmail'];
$this->options['mail_data']['header']['cancelmail'] = $mail_cancelmail['header'];
}
} else {
$mail_cancelmail['header'] = trim( wel_esc_script( $_POST['header']['cancelmail'] ) );
$this->options['mail_data']['header']['cancelmail'] = $mail_cancelmail['header'];
}
if ( WCUtils::is_blank( $_POST['footer']['cancelmail'] ) ) {
if ( empty( $mail_cancelmail['footer'] ) && isset( $this->options['mail_default']['footer']['cancelmail'] ) ) {
$mail_cancelmail['footer'] = $this->options['mail_default']['footer']['cancelmail'];
$this->options['mail_data']['footer']['cancelmail'] = $mail_cancelmail['footer'];
}
} else {
$mail_cancelmail['footer'] = trim( wel_esc_script( $_POST['footer']['cancelmail'] ) );
$this->options['mail_data']['footer']['cancelmail'] = $mail_cancelmail['footer'];
}
update_option( 'usces_mail_cancelmail', $mail_cancelmail );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} else {
$this->action_status = 'none';
$this->action_message = '';
}
do_action( 'usces_action_admin_mail_page' );
if ( isset( $this->options['add_html_email_option'] ) && 1 == $this->options['add_html_email_option'] ) {
wp_enqueue_script( 'jquery-ui-dialog' );
}
require_once USCES_PLUGIN_DIR . '/includes/admin_mail.php';
}
/**
* Admin Cart Page.
*/
public function admin_cart_page() {
global $allowedposttags;
$this->options = get_option( 'usces' );
if ( isset( $_POST['usces_option_update'] ) ) {
check_admin_referer( 'admin_cart', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
foreach ( $this->options['indi_item_name'] as $key => $value ) {
$this->options['indi_item_name'][ $key ] = isset( $_POST['indication'][ $key ] ) ? 1 : 0;
}
foreach ( $_POST['position'] as $key => $value ) {
$this->options['pos_item_name'][ $key ] = $value;
}
foreach ( $_POST['header'] as $key => $value ) {
$this->options['cart_page_data']['header'][ $key ] = wp_kses( $value, $allowedposttags );
}
foreach ( $_POST['footer'] as $key => $value ) {
$this->options['cart_page_data']['footer'][ $key ] = wp_kses( $value, $allowedposttags );
}
if ( isset( $_POST['confirm_notes'] ) ) {
$this->options['cart_page_data']['confirm_notes'] = wp_kses( $_POST['confirm_notes'], $allowedposttags );
}
update_option( 'usces', $this->options );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} else {
$this->action_status = 'none';
$this->action_message = '';
}
require_once USCES_PLUGIN_DIR . '/includes/admin_cart.php';
}
/**
* Admin Member Page.
*/
public function admin_member_page() {
global $allowedposttags;
$this->options = get_option( 'usces' );
if ( isset( $_POST['usces_option_update'] ) ) {
check_admin_referer( 'admin_member', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
foreach ( $_POST['header'] as $key => $value ) {
$this->options['member_page_data']['header'][ $key ] = wp_kses( $value, $allowedposttags );
}
foreach ( $_POST['footer'] as $key => $value ) {
$this->options['member_page_data']['footer'][ $key ] = wp_kses( $value, $allowedposttags );
}
$this->options['member_page_data']['agree_member_exp'] = isset( $_POST['agree_member_exp'] ) ? $_POST['agree_member_exp'] : '';
$this->options['member_page_data']['agree_member_cont'] = isset( $_POST['agree_member_cont'] ) ? $_POST['agree_member_cont'] : '';
$this->options['agree_member'] = isset( $_POST['agree_member'] ) ? $_POST['agree_member'] : 'deactivate';
update_option( 'usces', $this->options );
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
} else {
$this->action_status = 'none';
$this->action_message = '';
}
require_once USCES_PLUGIN_DIR . '/includes/admin_member.php';
}
/**
* Admin System Page.
*/
public function admin_system_page() {
global $usces_states;
$action_status = '';
$this->options = get_option( 'usces' );
if ( isset( $_POST['usces_system_option_update'] ) ) {
check_admin_referer( 'admin_system', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$this->options['divide_item'] = isset( $_POST['divide_item'] ) ? 1 : 0;
$this->options['itemimg_anchor_rel'] = isset( $_POST['itemimg_anchor_rel'] ) ? trim( $_POST['itemimg_anchor_rel'] ) : '';
$this->options['fukugo_category_orderby'] = isset( $_POST['fukugo_category_orderby'] ) ? $_POST['fukugo_category_orderby'] : '';
$this->options['fukugo_category_order'] = isset( $_POST['fukugo_category_order'] ) ? $_POST['fukugo_category_order'] : '';
$this->options['settlement_path'] = isset( $_POST['settlement_path'] ) ? $_POST['settlement_path'] : '';
if ( WCUtils::is_blank( $this->options['settlement_path'] ) ) {
$this->options['settlement_path'] = USCES_PLUGIN_DIR . 'settlement/';
}
$sl = substr( $this->options['settlement_path'], -1 );
if ( '/' != $sl && '\\' != $sl ) {
$this->options['settlement_path'] .= '/';
}
$this->options['logs_path'] = isset( $_POST['logs_path'] ) ? $_POST['logs_path'] : '';
if ( ! WCUtils::is_blank( $this->options['logs_path'] ) ) {
$sl = substr( $this->options['logs_path'], -1 );
if ( '/' == $sl || '\\' == $sl ) {
$this->options['logs_path'] = substr( $this->options['logs_path'], 0, -1 );
}
}
$this->options['use_ssl'] = isset( $_POST['use_ssl'] ) ? 1 : 0;
$this->options['ssl_url'] = isset( $_POST['ssl_url'] ) ? rtrim( $_POST['ssl_url'], '/' ) : '';
$this->options['ssl_url_admin'] = isset( $_POST['ssl_url_admin'] ) ? rtrim( $_POST['ssl_url_admin'], '/' ) : '';
if ( WCUtils::is_blank( $this->options['ssl_url'] ) || WCUtils::is_blank( $this->options['ssl_url_admin'] ) ) {
$this->options['use_ssl'] = 0;
}
$this->options['inquiry_id'] = isset( $_POST['inquiry_id'] ) ? esc_html( rtrim( $_POST['inquiry_id'] ) ) : '';
$this->options['use_javascript'] = isset( $_POST['use_javascript'] ) ? (int) $_POST['use_javascript'] : 1;
$this->options['system']['no_cart_css'] = isset( $_POST['no_cart_css'] ) ? 1 : 0;
$this->options['system']['dec_orderID_flag'] = isset( $_POST['dec_orderID_flag'] ) ? (int) $_POST['dec_orderID_flag'] : 0;
$this->options['system']['dec_orderID_prefix'] = isset( $_POST['dec_orderID_prefix'] ) ? esc_html( rtrim( $_POST['dec_orderID_prefix'] ) ) : '';
if ( isset( $_POST['dec_orderID_digit'] ) ) {
$dec_orderid_digit = (int) rtrim( $_POST['dec_orderID_digit'] );
if ( 6 > $dec_orderid_digit ) {
$this->options['system']['dec_orderID_digit'] = 6;
} else {
$this->options['system']['dec_orderID_digit'] = $dec_orderid_digit;
}
} else {
$this->options['system']['dec_orderID_digit'] = 6;
}
$this->options['system']['subimage_rule'] = isset( $_POST['subimage_rule'] ) ? (int) $_POST['subimage_rule'] : 0;
$this->options['system']['pdf_delivery'] = isset( $_POST['pdf_delivery'] ) ? (int) $_POST['pdf_delivery'] : 0;
$this->options['system']['member_pass_rule_min'] = isset( $_POST['member_pass_rule_min'] ) ? (int) $_POST['member_pass_rule_min'] : 6;
$this->options['system']['member_pass_rule_max'] = isset( $_POST['member_pass_rule_max'] ) && ! empty( $_POST['member_pass_rule_max'] ) ? (int) $_POST['member_pass_rule_max'] : 30;
$this->options['system']['member_pass_rule_upercase'] = isset( $_POST['member_pass_rule_upercase'] ) ? 1 : 0;
$this->options['system']['member_pass_rule_lowercase'] = isset( $_POST['member_pass_rule_lowercase'] ) ? 1 : 0;
$this->options['system']['member_pass_rule_digit'] = isset( $_POST['member_pass_rule_digit'] ) ? 1 : 0;
$this->options['system']['member_pass_rule_symbols'] = isset( $_POST['member_pass_rule_symbols'] ) ? 1 : 0;
$this->options['system']['member_pass_rule_number'] = isset( $_POST['member_pass_rule_number'] ) ? 1 : 0;
$this->options['system']['member_pass_rule_symbol'] = isset( $_POST['member_pass_rule_symbol'] ) ? 1 : 0;
$this->options['system']['csv_encode_type'] = isset( $_POST['csv_encode_type'] ) ? (int) $_POST['csv_encode_type'] : 0;
$this->options['system']['csv_category_format'] = ( isset( $_POST['csv_category_format'] ) ) ? (int) $_POST['csv_category_format'] : 0;
$this->options['system']['settlement_backup'] = ( isset( $_POST['settlement_backup'] ) ) ? (int) $_POST['settlement_backup'] : 0;
$this->options['system']['settlement_notice'] = ( isset( $_POST['settlement_notice'] ) ) ? (int) $_POST['settlement_notice'] : 0;
$this->options['system']['order_list_delete_link'] = ( isset( $_POST['order_list_delete_link'] ) ) ? (int) $_POST['order_list_delete_link'] : 0;
$this->options['system']['member_list_delete_link'] = ( isset( $_POST['member_list_delete_link'] ) ) ? (int) $_POST['member_list_delete_link'] : 0;
if ( '' != $action_status ) {
$this->action_status = 'error';
$this->action_message = __( 'Data have deficiency.', 'usces' );
} else {
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
}
} elseif ( isset( $_POST['usces_locale_option_update'] ) ) {
check_admin_referer( 'admin_system', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
$this->options['system']['front_lang'] = ( isset( $_POST['front_lang'] ) && 'others' != $_POST['front_lang'] ) ? $_POST['front_lang'] : usces_get_local_language();
$this->options['system']['currency'] = ( isset( $_POST['currency'] ) && 'others' != $_POST['currency'] ) ? $_POST['currency'] : usces_get_base_country();
$this->options['system']['addressform'] = ( isset( $_POST['addressform'] ) ) ? $_POST['addressform'] : usces_get_local_addressform();
$this->options['system']['target_market'] = ( isset( $_POST['target_market'] ) ) ? $_POST['target_market'] : usces_get_local_target_market();
unset ( $this->options['province'] );
foreach ( (array) $this->options['system']['target_market'] as $target_market ) {
$province = array();
if ( ! empty( $_POST[ 'province_' . $target_market ] ) ) {
$_province = usces_change_line_break( $_POST[ 'province_' . $target_market ] );
$temp_pref = explode( "\n", $_province );
$province[] = '-- Select --';
foreach ( $temp_pref as $pref ) {
if ( ! WCUtils::is_blank( $pref ) ) {
$validated = wel_validate_prefecture_name( wp_unslash( $pref ) );
if ( '' !== $validated ) {
$province[] = esc_html( $validated );
}
}
}
if ( 1 == count( $province ) ) {
$action_status = 'error';
}
} else {
if ( isset( $usces_states[ $target_market ] ) && is_array( $usces_states[ $target_market ] ) ) {
$province = $usces_states[ $target_market ];
} else {
$action_status = 'error';
}
}
$this->options['province'][ $target_market ] = $province;
}
if ( '' != $action_status ) {
$this->action_status = 'error';
$this->action_message = __( 'Data have deficiency.', 'usces' );
} else {
$this->action_status = 'success';
$this->action_message = __( 'options are updated', 'usces' );
}
} else {
if ( ! isset( $this->options['province'] ) || empty( $this->options['province'] ) ) {
$this->options['province'][ $this->options['system']['base_country'] ] = $usces_states[ $this->options['system']['base_country'] ];
}
$this->action_status = 'none';
$this->action_message = '';
}
if ( 'error' != $action_status ) {
update_option( 'usces', $this->options );
}
require_once USCES_PLUGIN_DIR . '/includes/admin_system.php';
}
/**
* Settlement Setting Page.
*/
public function admin_settlement_page() {
$this->action_status = 'none';
$this->action_message = '';
$options = get_option( 'usces' );
$mes = '';
if ( isset( $_POST['usces_option_update'] ) ) {
check_admin_referer( 'admin_settlement', 'wc_nonce' );
$_POST = $this->stripslashes_deep_post( $_POST );
switch ( $_POST['acting'] ) {
case 'settlement_selected':
if ( isset( $_POST['settlement_selected'] ) ) {
$settlement_selected = explode( ',', sanitize_text_field( wp_unslash( $_POST['settlement_selected'] ) ) );
$payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
$acting_payments = array();
foreach ( (array) $payments as $key => $payment ) {
if ( 'activate' == $payment['use'] && false !== strpos( $key, 'acting_' ) ) {
$acting = explode( '_', $key );
if ( ! empty( $acting[1] ) && 'paypal' == $acting[1] ) {
$acting_payments[] = $acting[1] . '_cp';
} else {
$acting_payments[] = apply_filters( 'usces_filter_acting_payment_slug', $acting[1], $acting );
}
}
}
$acting_payments = array_unique( $acting_payments );
$available_settlement = get_option( 'usces_available_settlement', array() );
$available = array_keys( $available_settlement );
foreach ( (array) $settlement_selected as $settlement ) {
if ( ! empty( $settlement ) && ! in_array( $settlement, $available ) ) {
$mes .= __( '* Failed to update payment module.', 'usces' ) . '
';
}
}
foreach ( (array) $acting_payments as $payment ) {
if ( ! in_array( $payment, $settlement_selected ) && isset( $available_settlement[ $payment ] ) ) {
$settlement_name = $available_settlement[ $payment ];
$mes .= sprintf( __( '* %s can not be unselected. Please "delete" or "stop" the payment method.', 'usces' ), $settlement_name ) . '
';
}
}
if ( WCUtils::is_blank( $mes ) ) {
$unavailable_activate = 0;
$unavailable_payments = apply_filters( 'usces_filter_unavailable_payments', get_option( 'usces_unavailable_settlement', array() ) );
foreach ( (array) $unavailable_payments as $payment ) {
if ( in_array( $payment, $settlement_selected ) ) {
$unavailable_activate++;
}
}
if ( 1 < $unavailable_activate ) {
$mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '
';
}
}
if ( WCUtils::is_blank( $mes ) ) {
update_option( 'usces_settlement_selected', $settlement_selected );
$this->settlement->setup();
$this->action_status = 'success';
$this->action_message = __( 'Updated.', 'usces' );
} else {
$this->action_status = 'error';
$this->action_message = __( 'Update failed.', 'usces' );
}
}
break;
}
do_action( 'usces_action_admin_settlement_update', $mes );
}
$this->options = get_option( 'usces' );
require_once USCES_PLUGIN_DIR . '/includes/admin_settlement.php';
}
public function selected( $selected, $current ) {
if ( $selected == $current ) {
echo ' selected="selected"';
}
}
public function usces_session_start() {
$options = get_option( 'usces' );
if ( ! isset( $options['usces_key'] ) || empty( $options['usces_key'] ) ) {
$options['usces_key'] = uniqid( 'uk' );
update_option( 'usces', $options );
}
if ( defined( 'USCES_KEY' ) ) {
if ( is_admin() || preg_match( '/\/wp-login\.php/', $_SERVER['REQUEST_URI'] ) ) {
@session_name( 'adm' . USCES_KEY );
} else {
@session_name( USCES_KEY );
}
} else {
if ( is_admin() || preg_match( '/\/wp-login\.php/', $_SERVER['REQUEST_URI'] ) ) {
@session_name( 'adm' . $options['usces_key'] );
} else {
@session_name( $options['usces_key'] );
}
}
if ( isset( $_GET['uscesid'] ) && ! WCUtils::is_blank( $_GET['uscesid'] ) ) {
$sessid = $_GET['uscesid'];
$sessid = $this->uscesdc( $sessid );
session_id( $sessid );
}
do_action( 'usces_action_session_start' );
$httponly = true;
$sitescheme = substr( get_option( 'siteurl' ), 0, 5 );
$homescheme = substr( get_option( 'home' ), 0, 5 );
if ( 'https' == $sitescheme && 'https' == $homescheme ) {
$sslonly = true;
$samesite = 'None';
} else {
$sslonly = false;
$samesite = '';
}
if ( version_compare( PHP_VERSION, '7.3.0', '>=' ) ) {
$cookie_options = array(
'lifetime' => 0,
'path' => USCES_COOKIEPATH,
'domain' => '',
'secure' => $sslonly,
'httponly' => $httponly,
'samesite' => $samesite,
);
session_set_cookie_params( $cookie_options );
} else {
session_set_cookie_params( 0, USCES_COOKIEPATH, '', $sslonly, $httponly );
}
@session_start();
if ( ! isset( $_SESSION['usces_member'] ) || 'activate' != $options['membersystem_state'] ) {
$_SESSION['usces_member'] = array();
}
if ( ! isset( $_SESSION['usces_checked_business_days'] ) ) {
$this->update_business_days();
}
}
public function usces_cookie() {
if ( is_admin() ) {
return;
}
$actionflag = false;
$sess = null;
$addr = null;
$rckid = null;
$none = null;
$cookie = $this->get_cookie();
if ( isset( $_GET['uscesid'] ) && ! WCUtils::is_blank( $_GET['uscesid'] ) ) {
$sessid = base64_decode( urldecode( $_GET['uscesid'] ) );
list( $sess, $addr, $rckid, $none ) = explode( '_', $sessid, 4 );
}
if ( 'acting' == $addr ) {
return;
}
if ( apply_filters( 'usces_filter_cookie', false ) ) {
return;
}
// We need to consider.
return;
if ( $this->use_ssl && ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) ) {
$refer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : null;
$sslid = isset( $cookie['sslid'] ) ? $cookie['sslid'] : null;
$option = get_option( 'usces' );
$parsed = parse_url( get_option( 'home' ) );
$home = $parsed['host'] . ( isset( $parsed['path'] ) ? $parsed['path'] : '' );
$parsed = parse_url( $option['ssl_url'] );
$sslhome = $parsed['host'] . ( isset( $parsed['path'] ) ? $parsed['path'] : '' );
if ( empty( $refer ) || ( false === strpos( $refer, $home ) && false === strpos( $refer, $sslhome ) ) ) {
if ( ! empty( $sslid ) && ! empty( $rckid ) && $sslid === $rckid ) {
$actionflag = true;
} else {
$actionflag = false;
}
} else {
if ( ! empty( $sslid ) && $sslid !== $rckid ) {
$actionflag = false;
} else {
$actionflag = true;
}
}
if ( $actionflag ) {
$values = array(
'id' => $rckid,
'sslid' => $rckid,
'name' => '',
'rme' => '',
);
if ( 'acting' !== $rckid ) {
$this->set_cookie( $values );
}
} else {
if ( 'acting' !== $rckid ) {
unset( $_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] );
wp_redirect( 'http://' . $home );
}
}
} else {
if ( ! isset( $cookie['id'] ) || WCUtils::is_blank( $cookie['id'] ) ) {
$values = array(
'id' => md5( uniqid( rand(), true ) ),
'name' => '',
'rme' => '',
);
$this->set_cookie( $values );
$_SESSION['usces_cookieid'] = $values['id'];
} else {
if ( ! isset( $_SESSION['usces_cookieid'] ) || $_SESSION['usces_cookieid'] != $cookie['id'] ) {
$_SESSION['usces_cookieid'] = $cookie['id'];
}
}
$actionflag = true;
}
}
public function set_cookie( $values, $key = 'usces_cookie' ) {
if ( ! isset( $_GET['uscesid'] ) || WCUtils::is_blank( $_GET['uscesid'] ) ) {
session_regenerate_id( true );
}
$value = usces_serialize( $values );
$timeout = time()+7*86400;
$timeout = apply_filters( 'usces_filter_set_cookie_timeout', $timeout, $values, $key );
$domain = $_SERVER['SERVER_NAME'];
$httponly = true;
$sitescheme = substr( get_option( 'siteurl' ), 0, 5 );
$homescheme = substr( get_option( 'home' ), 0, 5 );
if ( 'https' == $sitescheme && 'https' == $homescheme ) {
$sslonly = true;
$samesite = 'None';
} else {
$sslonly = false;
$samesite = '';
}
if ( version_compare( PHP_VERSION, '7.3.0', '>=' ) ) {
$cookie_options = array(
'expires' => $timeout,
'path' => USCES_COOKIEPATH,
'domain' => $domain,
'secure' => $sslonly,
'httponly' => $httponly,
'samesite' => $samesite,
);
$res = setcookie( $key, $value, $cookie_options );
} else {
$res = setcookie( $key, $value, $timeout, USCES_COOKIEPATH, $domain, true, true );
}
}
public function get_cookie( $key = 'usces_cookie' ) {
$values = isset( $_COOKIE[ $key ] ) ? usces_unserialize( stripslashes( $_COOKIE[ $key ] ) ) : null;
return $values;
}
public function get_access( $key, $type, $date ) {
global $wpdb;
$table_name = $wpdb->prefix . 'usces_access';
$query = $wpdb->prepare( "SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date );
$value = $wpdb->get_var( $query );
if ( ! $value ) {
$res = null;
} else {
$res = @unserialize( $value );
}
return $res;
}
public function get_access_piriod( $key, $type, $startday, $endday ) {
global $wpdb;
$table_name = $wpdb->prefix . 'usces_access';
$query = $wpdb->prepare( "SELECT acc_type, acc_value, acc_date FROM $table_name WHERE acc_key = %s AND acc_type = %s AND (acc_date >= %s AND acc_date <= %s)", $key, $type, $startday, $endday );
$res = $wpdb->get_results( $query, ARRAY_A );
return $res;
}
public function update_access( $array ) {
global $wpdb;
$table_name = $wpdb->prefix . 'usces_access';
$query = $wpdb->prepare( "SELECT ID FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $array['acc_key'], $array['acc_type'], $array['acc_date'] );
$res = $wpdb->get_var( $query );
if ( empty( $res ) ) {
$query = $wpdb->prepare( "INSERT INTO $table_name (acc_key, acc_type, acc_value, acc_date) VALUES(%s, %s, %s, %s)", $array['acc_key'], $array['acc_type'], serialize( $array['acc_value'] ), $array['acc_date'] );
$wpdb->query( $query );
} else {
$query = $wpdb->prepare( "UPDATE $table_name SET acc_value = %s WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", serialize( $array['acc_value'] ), $array['acc_key'], $array['acc_type'], $array['acc_date'] );
$wpdb->query( $query );
}
}
public function get_uscesid( $flag = true ) {
$sessname = session_name();
$sessid = session_id();
$sessid = $this->uscescv( $sessid, $flag );
return $sessid;
}
public function shop_head() {
global $post;
$this->item = $post;
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) ) {
echo "\n";
}
}
/**
* Caught by wp_footer action hook
*/
public function shop_foot() {
global $current_user;
$item = $this->item;
if ( empty( $item ) ) {
$item = new stdClass;
$item->ID = 0;
$item->post_mime_type = '';
}
wp_get_current_user();
// usces_cart.js is not used.
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
$javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js';
} else {
$javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js';
}
$this->previous_url = isset( $_SESSION['usces_previous_url'] ) ? $_SESSION['usces_previous_url'] : get_home_url();
// If the product object does't exists.
if ( $this->use_js && empty( $this->item ) ) {
?>
use_js && ! empty( $this->item ) ) {
$ioptkeys = $this->get_itemOptionKey( $item->ID );
$mes_opts_str = '';
$key_opts_str = '';
$opt_means = '';
$opt_esse = '';
if ( $ioptkeys ) {
foreach ( $ioptkeys as $key => $value ) {
$optValues = $this->get_itemOptions( $value, $item->ID );
if ( false === $optValues ) {
continue;
}
if ( $optValues['means'] < 2 || 3 == $optValues['means'] || 4 == $optValues['means'] ) {
$mes_opts_str .= "'" . sprintf( __( 'Chose the %s', 'usces' ), esc_js( apply_filters( 'usces_filter_uscesL10n_option_name', $value, $optValues ) ) ) . "',";
} else {
$mes_opts_str .= "'" . sprintf( __( 'Input the %s', 'usces' ), esc_js( apply_filters( 'usces_filter_uscesL10n_option_name', $value, $optValues ) ) ) . "',";
}
$key_opts_str .= "'" . urlencode( esc_js( $value ) ) . "',";
$opt_means .= "'" . esc_js( $optValues['means'] ) . "',";
$opt_esse .= "'" . esc_js( $optValues['essential'] ) . "',";
}
$mes_opts_str = rtrim( $mes_opts_str, ',' );
$key_opts_str = rtrim( $key_opts_str, ',' );
$opt_means = rtrim( $opt_means, ',' );
$opt_esse = rtrim( $opt_esse, ',' );
}
$product = wel_get_product( $item->ID );
$itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : '';
$wcpage = usces_page_name( 'return' );
$nonce_action = 'wc_confirm';
$itemOrderAcceptable = $this->getItemOrderAcceptable( $item->ID );
?>
use_js && ( is_singular() && 'item' == $item->post_mime_type ) ) {
?>
use_js && ( is_page( USCES_CART_NUMBER ) || $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) ) {
?>
$values ) {
$wcex_str .= "'" . esc_js( $key ) . '-' . esc_js( $values['version'] ) . "', ";
}
$wcex_str = rtrim( $wcex_str, ', ' );
$theme_ob = wp_get_theme();
if ( $theme_ob ) {
$theme = array(
'Name' => esc_js( $theme_ob->get( 'Name' ) ),
'Version' => esc_js( $theme_ob->get( 'Version' ) ),
);
} else {
$theme = array( 'Name' => '', 'Version' => '' );
}
$message = usces_get_admin_script_message();
?>
action_status || 'editpost' == $this->action_status ) {
?>
options['cod_type'] ) ? 'change' : 'fix';
?>
shipping_rule = get_option( 'usces_shipping_rule' );
if ( ! is_admin() ) {
$this->usces_cookie();
} else {
$this->user_level = usces_get_admin_user_level();
}
$this->make_url();
add_filter( 'cron_schedules', 'usces_schedules_intervals' );
add_action( 'wp', 'usces_wevent' );
do_action( 'usces_main' );
$this->update_table();
require_once USCES_PLUGIN_DIR . '/classes/cart.class.php';
$this->cart = new usces_cart();
do_action( 'usces_after_cart_instant' );
if ( isset( $_REQUEST['page'] ) && 'usces_itemedit' == $_REQUEST['page'] && isset( $_REQUEST['action'] ) && 'duplicate' == $_REQUEST['action'] ) {
$post_id = (int) $_GET['post'];
$new_id = usces_item_duplicate( $post_id );
$ref = isset( $_REQUEST['usces_referer'] ) ? urlencode( esc_url( $_REQUEST['usces_referer'] ) ) : '';
$url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref;
wp_redirect( $url );
exit;
} elseif ( isset( $_REQUEST['page'] ) && 'usces_itemedit' == $_REQUEST['page'] && isset( $_REQUEST['action'] ) && 'itemcsv' == $_REQUEST['action'] ) {
// $filename = usces_item_uploadcsv();
// $mode = ( isset( $_REQUEST['upload_mode'] ) ) ? $_REQUEST['upload_mode'] : 'all';
// $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&mode=' . $mode . '®file=' . $filename;
// wp_redirect( $url );
// exit;
}
$this->ad_controller();
if ( isset( $_GET['page'] ) && 'usces_itemnew' == $_GET['page'] ) {
$itemnew = 'new';
} else {
$itemnew = '';
}
wp_enqueue_script( 'jquery' );
if ( is_admin() && isset( $_REQUEST['page'] ) && ( ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] ) || 'new' == $itemnew || ( isset( $_REQUEST['action'] ) && 'editpost' == $_REQUEST['action'] ) ) ) {
if ( isset( $_REQUEST['action'] ) && 'editpost' != $_REQUEST['action'] && 'new' == $itemnew ) {
if ( version_compare( $wp_version, '3.0-beta', '>' ) ) {
if ( ! isset( $_GET['post_type'] ) ) {
$post_type = 'post';
} elseif ( in_array( $_GET['post_type'], get_post_types( array( 'public' => true ) ) ) ) {
$post_type = $_GET['post_type'];
} else {
wp_die( __( 'Invalid post type' ) );
}
$post_type_object = get_post_type_object( $post_type );
$editing = true;
$post = $this->get_default_post_to_edit30( $post_type, true );
$post_ID = $post->ID;
} else {
$post = $this->get_default_post_to_edit();
}
} else {
if ( version_compare( $wp_version, '3.0-beta', '>' ) ) {
if ( isset( $_GET['post'] ) ) {
$post_id = (int) $_GET['post'];
} elseif ( isset( $_POST['post_ID'] ) ) {
$post_id = (int) $_POST['post_ID'];
} else {
$post_id = 0;
}
$post_ID = $post_id;
$post = null;
$post_type_object = null;
$post_type = null;
if ( $post_id ) {
$product = wel_get_product( $post_id );
$post = $product['_pst'];
if ( $post ) {
$post_type_object = get_post_type_object( $post->post_type );
if ( $post_type_object ) {
$post_type = $post->post_type;
if ( ! isset( $current_screen ) ) {
$current_screen = new stdClass();
}
$current_screen->post_type = $post->post_type;
$current_screen->id = $current_screen->post_type;
}
}
} elseif ( isset( $_POST['post_type'] ) ) {
$post_type_object = get_post_type_object( $_POST['post_type'] );
if ( $post_type_object ) {
$post_type = $post_type_object->name;
$current_screen->post_type = $post_type;
$current_screen->id = $current_screen->post_type;
}
}
} else {
if ( isset( $_GET['post'] ) ) {
$post_ID = (int) $_GET['post'];
$product = wel_get_product( $post_ID );
$post = $product['_pst'];
} else {
$post_ID = isset( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0;
if ( ! empty( $post_ID ) ) {
$product = wel_get_product( $post_ID );
$post = $product['_pst'];
}
}
}
}
$editing = true;
wp_enqueue_script( 'autosave' );
wp_enqueue_script( 'post' );
add_thickbox();
wp_enqueue_script( 'media-upload' );
wp_enqueue_script( 'word-count' );
wp_enqueue_script( 'admin-comments' );
if ( version_compare( $wp_version, '3.3', '<' ) ) {
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
}
wp_enqueue_script( 'quicktags' );
}
if ( is_admin() && isset( $_REQUEST['page'] ) ) {
wp_enqueue_script( 'jquery-color' );
switch ( $_REQUEST['page'] ) {
case 'usces_initial':
$js = USCES_FRONT_PLUGIN_URL . '/js/usces_initial.js';
wp_enqueue_script( 'usces_initial.js', $js, array( 'jquery-ui-dialog', 'jquery-ui-sortable' ) );
break;
case 'usces_settlement':
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
$jquery_color_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/color/jscolor.js';
wp_enqueue_script( 'jquery-jscolor', $jquery_color_url, array( 'jquery-color' ) );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'jquery-ui-dialog' );
break;
case 'usces_cart':
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
break;
case 'usces_member':
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
break;
case 'usces_orderlist':
case 'usces_ordernew':
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'jquery-ui-dialog' );
break;
case 'usces_memberlist':
wp_enqueue_script( 'jquery-ui-dialog' );
break;
case 'usces_itemnew':
wp_enqueue_script( 'jquery-ui-sortable' );
break;
case 'usces_itemedit':
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
if ( isset( $_REQUEST['action'] ) && 'upload_register' == $_REQUEST['action'] ) {
// $upload_registerUrl = USCES_FRONT_PLUGIN_URL . '/js/usces-item-upload.js';
// wp_enqueue_script( 'upload_register', $upload_registerUrl, array( 'jquery' ), USCES_VERSION, true );
// @ob_end_clean();
// ob_start();
} else {
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'jquery-ui-dialog' );
}
break;
case 'usces_delivery':
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
break;
case 'usces_system':
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
break;
case 'usces_mail':
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
break;
}
}
if ( isset( $_REQUEST['order_action'] ) && 'pdfout' == $_REQUEST['order_action'] ) {
check_admin_referer( 'order_edit', 'wc_nonce' );
$oid = filter_input( INPUT_GET, 'order_id' );
if ( ! is_user_logged_in() ) {
$this->get_current_member();
$mid = $this->current_member['id'];
if ( 0 === (int) $mid || ! $this->is_order( $mid, $oid ) ) {
die( 'No permission' );
}
}
if ( ( isset( $this->options['tax_display'] ) && 'activate' == $this->options['tax_display'] ) && usces_is_reduced_taxrate( $oid ) ) {
require_once( apply_filters( 'usces_filter_orderpdf_path_ex', USCES_PLUGIN_DIR . '/includes/order_print_ex.php' ) );
} else {
require_once( apply_filters( 'usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php' ) );
}
}
if ( ! empty( $this->settlement_notice ) &&
( 1 === (int) $this->options['system']['settlement_notice'] || defined( 'WCEX_DLSELLER' ) || defined( 'WCEX_AUTO_DELIVERY' ) ) ) {
add_action( 'admin_notices', 'usces_display_settlement_notice' );
}
do_action( 'usces_after_main' );
}
public function stripslashes_deep_post( $array ) {
$res = array();
foreach ( $array as $key => $value ) {
$key = stripslashes( $key );
if ( is_array( $value ) ) {
$value = $this->stripslashes_deep_post( $value );
} else {
$value = is_null( $value ) ? $value : usces_erase_emoji( stripslashes( $value ) );
}
$res[ $key ] = $value;
}
return $res;
}
public function make_url() {
$permalink_structure = get_option( 'permalink_structure' );
if ( $this->use_ssl ) {
if ( $permalink_structure ) {
$this->delim = '&';
$home_perse = parse_url( get_option( 'home' ) );
$home_perse_path = isset( $home_perse['path'] ) ? $home_perse['path'] : '';
$home_path = $home_perse['host'] . $home_perse_path;
$ssl_perse = parse_url( $this->options['ssl_url'] );
$ssl_perse_path = isset( $ssl_perse['path'] ) ? $ssl_perse['path'] : '';
$ssl_path = $ssl_perse['host'] . $ssl_perse_path;
if ( $home_perse_path != $ssl_perse_path ) {
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
define( 'USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid() );
}
if ( ! defined( 'USCES_CART_URL' ) ) {
define( 'USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid() );
}
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
define( 'USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=lostmemberpassword' );
}
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
define( 'USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=newmember' );
}
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
define( 'USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=login' );
}
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
define( 'USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=logout' );
}
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
define( 'USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() );
}
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
define( 'USCES_INQUIRY_URL', $inquiry_url );
}
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
define( 'USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER );
}
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
define( 'USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
}
} else {
$ssl_plink_cart = str_replace( 'http://','https://', str_replace( $home_path, $ssl_path, get_page_link( USCES_CART_NUMBER ) ) );
$ssl_plink_member = str_replace( 'http://','https://', str_replace( $home_path, $ssl_path, get_page_link( USCES_MEMBER_NUMBER ) ) );
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
define( 'USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1' );
}
if ( ! defined( 'USCES_CART_URL' ) ) {
define( 'USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() );
}
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
define( 'USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=lostmemberpassword' );
}
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
define( 'USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=newmember' );
}
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
define( 'USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=login' );
}
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
define( 'USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=logout' );
}
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
define( 'USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() );
}
if ( ! isset( $this->options['inquiry_id'] ) || ! ( (int) $this->options['inquiry_id'] ) ) {
$inquiry_url = get_home_url();
} else {
$ssl_plink_inquiry = str_replace( 'http://', 'https://', str_replace( $home_path, $ssl_path, get_page_link( $this->options['inquiry_id'] ) ) );
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid();
}
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
define( 'USCES_INQUIRY_URL', $inquiry_url );
}
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
define( 'USCES_CART_NONSESSION_URL', $ssl_plink_cart );
}
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
define( 'USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
}
}
} else {
$this->delim = '&';
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
define( 'USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid() );
}
if ( ! defined( 'USCES_CART_URL' ) ) {
define( 'USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid() );
}
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
define( 'USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=lostmemberpassword' );
}
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
define( 'USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=newmember' );
}
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
define( 'USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=login' );
}
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
define( 'USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=logout' );
}
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
define( 'USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() );
}
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
define( 'USCES_INQUIRY_URL', $inquiry_url );
}
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
define( 'USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER );
}
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
define( 'USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
}
}
if ( ! is_admin() ) {
add_filter( 'home_url', array( $this, 'usces_ssl_page_link' ) );
add_filter( 'wp_get_attachment_url', array( $this, 'usces_ssl_attachment_link' ) );
add_filter( 'icon_dir_uri', array( $this, 'usces_ssl_icon_dir_uri' ) );
add_filter( 'stylesheet_directory_uri', array( $this, 'usces_ssl_contents_link' ) );
add_filter( 'template_directory_uri', array( $this, 'usces_ssl_contents_link' ) );
add_filter( 'script_loader_src', array( $this, 'usces_ssl_script_link' ) );
add_filter( 'style_loader_src', array( $this, 'usces_ssl_script_link' ) );
}
} else {
if ( $permalink_structure ) {
$this->delim = '?';
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
define( 'USCES_CUSTOMER_URL', get_page_link( USCES_CART_NUMBER ) . '?customerinfo=1' );
}
if ( ! defined( 'USCES_CART_URL' ) ) {
define( 'USCES_CART_URL', get_page_link( USCES_CART_NUMBER ) );
}
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
define( 'USCES_LOSTMEMBERPASSWORD_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=lostmemberpassword' );
}
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
define( 'USCES_NEWMEMBER_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=newmember' );
}
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
define( 'USCES_LOGIN_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=login' );
}
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
define( 'USCES_LOGOUT_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=logout' );
}
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
define( 'USCES_MEMBER_URL', get_page_link( USCES_MEMBER_NUMBER ) );
}
$inquiry_url = ( ! isset( $this->options['inquiry_id'] ) || ! ( (int) $this->options['inquiry_id'] ) ) ? get_home_url() : get_page_link( $this->options['inquiry_id'] );
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
define( 'USCES_INQUIRY_URL', $inquiry_url );
}
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
define( 'USCES_CART_NONSESSION_URL', get_page_link( USCES_CART_NUMBER ) );
}
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
define( 'USCES_PAYPAL_NOTIFY_URL', get_page_link( USCES_CART_NUMBER ) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
}
} else {
$this->delim = '&';
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
define( 'USCES_CUSTOMER_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1' );
}
if ( ! defined( 'USCES_CART_URL' ) ) {
define( 'USCES_CART_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER );
}
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
define( 'USCES_LOSTMEMBERPASSWORD_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=lostmemberpassword' );
}
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
define( 'USCES_NEWMEMBER_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=newmember' );
}
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
define( 'USCES_LOGIN_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=login' );
}
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
define( 'USCES_LOGOUT_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' );
}
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
define( 'USCES_CART_NONSESSION_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' );
}
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
define( 'USCES_MEMBER_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER );
}
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option( 'home' ) . '/?page_id=' . $this->options['inquiry_id'];
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
define( 'USCES_INQUIRY_URL', $inquiry_url );
}
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
define( 'USCES_CART_NONSESSION_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER );
}
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
define( 'USCES_PAYPAL_NOTIFY_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
}
}
}
}
public function regist_action() {
usces_register_action( 'inCart', 'post', 'inCart', null, 'inCart' );
usces_register_action( 'upButton', 'post', 'upButton', null, 'upButton' );
usces_register_action( 'delButton', 'post', 'delButton', null, 'delButton' );
usces_register_action( 'backCart', 'post', 'backCart', null, 'backCart' );
usces_register_action( 'customerinfo', 'request', 'customerinfo', null, 'customerinfo' );
usces_register_action( 'backCustomer', 'post', 'backCustomer', null, 'backCustomer' );
usces_register_action( 'customerlogin', 'post', 'customerlogin', null, 'customerlogin' );
usces_register_action( 'reganddeliveryinfo', 'post', 'reganddeliveryinfo', null, 'reganddeliveryinfo' );
usces_register_action( 'deliveryinfo', 'post', 'deliveryinfo', null, 'deliveryinfo' );
usces_register_action( 'backDelivery', 'request', 'backDelivery', null, 'backDelivery' );
usces_register_action( 'confirm', 'request', 'confirm', null, 'confirm' );
usces_register_action( 'use_point', 'post', 'use_point', null, 'use_point' );
usces_register_action( 'backConfirm', 'post', 'backConfirm', null, 'backConfirm' );
usces_register_action( 'purchase', 'request', 'purchase', null, 'purchase' );
usces_register_action( 'acting_return', 'request', 'acting_return', null, 'acting_return' );
usces_register_action( 'settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon' );
usces_register_action( 'inquiry_button', 'post', 'inquiry_button', null, 'inquiry_button' );
usces_register_action( 'member_login', 'request', 'member_login', null, 'member_login_page' );
usces_register_action( 'regmember', 'request', 'regmember', null, 'regmember' );
usces_register_action( 'editmember', 'request', 'editmember', null, 'editmember' );
usces_register_action( 'deletemember', 'request', 'deletemember', null, 'deletemember' );
usces_register_action( 'page_login', 'get', 'usces_page', 'login', 'member_login_page' );
usces_register_action( 'page_logout', 'get', 'usces_page', 'logout', 'page_logout' );
usces_register_action( 'page_lostmemberpassword', 'get', 'usces_page', 'lostmemberpassword', 'page_lostmemberpassword' );
usces_register_action( 'lostpassword', 'request', 'lostpassword', null, 'lostpassword' );
usces_register_action( 'uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword' );
usces_register_action( 'changepassword', 'request', 'changepassword', null, 'changepassword_page' );
usces_register_action( 'page_newmember', 'get', 'usces_page', 'newmember', 'page_newmember' );
usces_register_action( 'page_search_item', 'get', 'usces_page', 'search_item', 'page_search_item' );
usces_register_action( 'front_ajax', 'post', 'usces_ajax_action', null, 'front_ajax' );
}
public function ad_controller() {
global $usces_action;
ksort( $usces_action );
if ( $this->is_maintenance() && ! is_user_logged_in() ) {
$this->maintenance();
} else {
$action_array = array(
'inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer',
'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point',
'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login',
'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword',
'uscesmode_changepassword', 'changepassword', 'page_newmember',
'page_search_item', 'front_ajax',
);
$action_array = apply_filters( 'usces_filter_action_array', $action_array );
$flg = 0;
$res = true;
foreach ( $usces_action as $handle => $action ) {
extract( $action );
switch ( $type ) {
case 'post':
if ( empty( $value ) ) {
if ( isset( $_POST[ $key ] ) ) {
if ( in_array( $handle, $action_array ) ) {
$res = call_user_func( array( $this, $function ) );
} else {
$res = call_user_func( $function );
}
$flg = 1;
}
} else {
if ( isset( $_POST[ $key ] ) && $_POST[ $key ] == $value ) {
if ( in_array( $handle, $action_array ) ) {
$res = call_user_func( array( $this, $function ) );
} else {
$res = call_user_func( $function );
}
$flg = 1;
}
}
break;
case 'get':
if ( empty( $value ) ) {
if ( isset( $_GET[ $key ] ) ) {
if ( in_array( $handle, $action_array ) ) {
$res = call_user_func( array( $this, $function ) );
} else {
$res = call_user_func( $function );
}
$flg = 1;
}
} else {
if ( isset( $_GET[ $key ] ) && $_GET[ $key ] == $value ) {
if ( in_array( $handle, $action_array ) ) {
$res = call_user_func( array( $this, $function ) );
} else {
$res = call_user_func( $function );
}
$flg = 1;
}
}
break;
case 'request':
if ( empty( $value ) ) {
if ( isset( $_REQUEST[ $key ] ) ) {
if ( in_array( $handle, $action_array ) ) {
$res = call_user_func( array( $this, $function ) );
} else {
$res = call_user_func( $function );
}
$flg = 1;
}
} else {
if ( isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] == $value ) {
if ( in_array( $handle, $action_array ) ) {
$res = call_user_func( array( $this, $function ) );
} else {
$res = call_user_func( $function );
}
$flg = 1;
}
}
break;
}
if ( ! $res ) {
break;
}
}
if ( ! $flg ) {
$this->default_page();
}
}
}
/**
* Action function.
*/
public function front_ajax() {
switch ( $_POST['usces_ajax_action'] ) {
case 'change_states':
change_states_ajax();
break;
}
do_action( 'usces_front_ajax' );
}
public function maintenance() {
$this->page = 'maintenance';
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
}
public function inCart() {
global $wp_query;
$this->page = 'cart';
$this->incart_check();
$this->cart->inCart();
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function upButton() {
global $wp_query;
$this->page = 'cart';
$this->error_message = $this->cart->upCart();
if ( empty( $this->error_message ) ) {
$this->error_message = $this->zaiko_check();
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function delButton() {
global $wp_query;
$this->page = 'cart';
$this->cart->del_row();
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function backCart() {
global $wp_query;
$this->page = 'cart';
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function customerinfo() {
global $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
do_action( 'usces_action_customerinfo' );
$this->cart->entry();
$this->error_message = $this->zaiko_check();
$this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message );
if ( WCUtils::is_blank( $this->error_message ) ) {
if ( $this->is_member_logged_in() ) {
$this->error_message = has_custom_customer_field_essential();
$this->page = ( WCUtils::is_blank( $this->error_message ) ) ? 'delivery' : 'customer';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
} else {
$this->page = 'customer';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
}
} else {
$this->page = 'cart';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
}
if ( ! $this->cart->is_order_condition() ) {
$order_conditions = $this->get_condition();
$this->cart->set_order_condition( $order_conditions );
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function backCustomer() {
global $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
$this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' );
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function customerlogin() {
global $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
if ( 'member' == $this->member_login() ) {
do_action( 'usces_action_member_customer_logined' );
$this->cart->entry();
// $this->error_message = has_custom_customer_field_essential();
if ( WCUtils::is_blank( $this->error_message ) ) {
$this->page = 'delivery';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
} else {
$this->page = 'customer';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
}
} else {
$this->cart->entry();
$this->page = 'customer';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function reganddeliveryinfo() {
global $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
$noncekey = 'post_member' . $this->get_uscesid( false );
if ( ! wp_verify_nonce( $nonce, $noncekey ) && ! $this->is_member_logged_in() ) {
die( 'Security check2' );
}
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
if ( $check_verify_recaptcha ) {
$this->cart->entry();
if ( empty( $_POST['member_regmode'] ) || 'editmemberfromcart' != $_POST['member_regmode'] ) {
$_POST['member_regmode'] = 'newmemberfromcart';
}
$res = $this->regist_member();
} else {
// return back page register and show message.
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Failed to register member. Please try again.', 'usces' ), 'reganddeliveryinfo' );
$res = trim( $_POST['member_regmode'] );
}
if ( 'newcompletion' == $res ) {
$this->page = 'delivery';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
} elseif ( 'cartverifying' == $res ) {
$this->page = 'cartverifying';
} else {
$this->page = 'customer';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function deliveryinfo() {
global $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
if ( $check_verify_recaptcha ) {
// continue process.
$this->cart->entry();
$this->error_message = $this->customer_check();
} else {
// return back page register and show message.
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Could not send successfully. Please try again.', 'usces' ), 'deliveryinfo' );
}
if ( WCUtils::is_blank( $this->error_message ) ) {
$this->page = 'delivery';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
} else {
$this->page = 'customer';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function backDelivery() {
global $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
$this->page = 'delivery';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function confirm() {
global $wpdb, $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
if ( $check_verify_recaptcha ) {
// continue process.
$this->cart->entry();
$this->error_message = $this->zaiko_check();
} else {
// return back page register and show message.
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Could not send successfully. Please try again.', 'usces' ), 'confirm' );
}
if ( '' != $this->error_message ) {
$this->page = 'cart';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
return;
}
/*
$referrer = wp_get_referer();
$site_url = parse_url( home_url(), PHP_URL_HOST );
$referrer_host = parse_url( $referrer, PHP_URL_HOST );
if ( false === $referrer || $referrer_host !== $site_url ) {
$this->page = 'cart';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
return;
}
*/
$this->set_reserve_pre_order_id();
if ( isset( $_POST['confirm'] ) ) {
$this->error_message = $this->delivery_check();
}
$this->page = ( WCUtils::is_blank( $this->error_message ) ) ? 'confirm' : 'delivery';
if ( WCUtils::is_blank( $this->error_message ) ) {
if ( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) {
$member_table = usces_get_tablename( 'usces_member' );
$query = $wpdb->prepare( "SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID'] );
$mem_point = $wpdb->get_var( $query );
$_SESSION['usces_member']['point'] = $mem_point;
}
$this->page = 'confirm';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' );
} else {
$this->page = apply_filters( 'usces_filter_delivery_check_error_page', 'delivery', $this->error_message );
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function use_point() {
global $wp_query, $usces;
$noncekey = 'use_point' . $usces->get_uscesid( false );
if ( ! isset( $_REQUEST['wc_nonce'] ) || ! wp_verify_nonce( $_REQUEST['wc_nonce'], $noncekey ) ) {
die( 'Security check1' );
}
$this->error_message = $this->point_check( $this->cart->get_entry() );
if ( empty( $this->error_message ) ) {
$this->cart->entry();
}
$this->page = 'confirm';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' );
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function backConfirm() {
global $wp_query;
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
$this->page = 'confirm';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' );
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
/**
* Purchase
*/
public function purchase() {
global $wp_query;
do_action( 'usces_pre_purchase' );
if ( false === $this->cart->num_row() ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
if ( isset( $_POST['wc_purchase_nonce'] ) ) {
if ( ! wp_verify_nonce( $_POST['wc_purchase_nonce'], 'wc_purchase_nonce' ) ) {
$this->error_message = __( 'Security check failed. Please try again.', 'usces' );
$this->page = 'confirm';
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
return;
}
}
if ( ! apply_filters( 'usces_purchase_check', true ) ) {
return;
}
do_action( 'usces_purchase_validate' );
$entry = $this->cart->get_entry();
$this->error_message = $this->zaiko_check();
if ( WCUtils::is_blank( $this->error_message ) && 0 < $this->cart->num_row() ) {
$acting_status = '';
$payments = $this->getPayments( $entry['order']['payment_name'] );
if ( null === $payments['id'] && 0 < $entry['order']['total_full_price'] ) {
header( 'HTTP/1.0 400 Bad request' );
die();
}
$payment_settlement = $payments['settlement'] ?? '';
if ( substr( $payment_settlement, 0, 6 ) == 'acting' && $entry['order']['total_full_price'] > 0 ) {
$acting_flg = ( 'acting' == $payment_settlement ) ? $payments['module'] : $payment_settlement;
unset( $_POST['purchase'] );
$post_query = '&' . http_build_query( $_POST );
$acting_status = $this->acting_processing( $acting_flg, $post_query, $acting_status );
}
if ( 'error' == $acting_status ) {
$this->page = 'error';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
} else {
$res = $this->order_processing();
if ( 'ordercompletion' == $res ) {
$this->page = 'ordercompletion';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' );
} else {
$this->page = 'error';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
}
}
} else {
$this->page = 'cart';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
if ( ! $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
wp_redirect( USCES_CART_URL );
exit;
}
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function acting_return() {
global $wp_query;
do_action( 'usces_pre_acting_return' );
$entry = $this->cart->get_entry();
if ( isset( $_GET['acting'] ) && 'anotherlane_card' != $_GET['acting'] ) {
if ( false === $this->cart->num_row() && ( 'paypal' != $_GET['acting'] && 1 !== (int) $_GET['acting_return'] ) ) {
header( 'location: ' . get_option( 'home' ) );
exit;
}
}
$this->payment_results = usces_check_acting_return();
if ( isset( $this->payment_results[0] ) && 'duplicate' === $this->payment_results[0] ) {
header( 'location: ' . get_option( 'home' ) );
exit;
} elseif ( isset( $this->payment_results[0] ) && $this->payment_results[0] ) { // result OK.
if ( ! $this->payment_results['reg_order'] ) { // without Registration Order.
$this->page = 'ordercompletion';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' );
} else {
$res = $this->order_processing( $this->payment_results );
if ( 'ordercompletion' == $res ) {
$this->page = 'ordercompletion';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' );
} else {
$this->page = 'error';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
}
}
} else { // result NG.
$this->page = 'error';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
}
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function settlement_epsilon() {
global $wp_query;
require_once $this->options['settlement_path'] . 'epsilon.php';
}
public function inquiry_button() {
if ( ( isset( $_POST['kakuninyou'] ) && empty( $_POST['kakuninyou'] ) ) && isset( $_POST['inq_name'] ) && ! WCUtils::is_blank( $_POST['inq_name'] ) && isset( $_POST['inq_mailaddress'] ) && is_email( trim( $_POST['inq_mailaddress'] ) ) && ! WCUtils::is_blank( $_POST['inq_contents'] ) ) {
$res = $this->inquiry_processing();
} else {
$res = 'deficiency';
}
$this->page = $res;
}
public function member_login_page() {
global $wp_query;
if ( ! class_exists( 'RateLimiter' ) ) {
require USCES_PLUGIN_DIR . '/classes/rateLimiter.class.php';
}
$rateLimiter = new RateLimiter();
if ( $rateLimiter->checkBlockIP() ) {
$wp_query->set_403();
status_header( 403 );
exit();
}
if ( isset( $_GET['redirect_to'] ) ) {
$_SESSION['redirect_to'] = $_GET['redirect_to'];
}
$res = $this->member_login();
if ( 'member' == $res ) {
$this->page = 'member';
do_action( 'usces_action_member_logined' );
if ( isset( $_SESSION['redirect_to'] ) ) {
if ( wp_safe_redirect( esc_url( $_SESSION['redirect_to'] ) ) ) {
unset( $_SESSION['redirect_to'] );
exit;
}
}
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_member' );
} elseif ( 'login' == $res ) {
$this->page = 'login';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_login' );
}
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function regmember() {
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
$noncekey = 'post_member' . $this->get_uscesid( false );
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
die( 'Security check2' );
}
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
if ( $check_verify_recaptcha ) {
// continue register form.
global $wp_query;
$res = $this->regist_member();
} else {
// return back page register and show message.
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Failed to register member. Please try again.', 'usces' ), 'regmember' );
$res = trim( $_POST['member_regmode'] );
}
if ( 'editmemberform' == $res ) {
$this->page = 'editmemberform';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform' );
} elseif ( 'newcompletion' == $res ) {
$this->page = 'newcompletion';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion' );
} else {
$this->page = $res;
}
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function editmember() {
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
$noncekey = 'post_member' . $this->get_uscesid( false );
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
die( 'Security check3' );
}
global $wp_query;
$res = $this->regist_member();
if ( 'editmemberform' == $res ) {
$this->page = 'editmemberform';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform' );
} elseif ( 'newcompletion' == $res ) {
$this->page = 'newcompletion';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion' );
} elseif ( 'updatememberform' == $res ) {
$this->page = 'member_edit';
} else {
$this->page = $res;
}
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function deletemember() {
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
$noncekey = 'post_member' . $this->get_uscesid( false );
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
die( 'Security check4' );
}
$res = $this->delete_member();
if ( $res ) {
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember' );
$this->member_logout();
} else {
$this->page = 'editmemberform';
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
}
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function page_logout() {
global $wp_query;
$this->member_logout();
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function page_lostmemberpassword() {
global $wp_query;
$this->page = 'lostmemberpassword';
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function lostpassword() {
global $usces, $wp_query;
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
$noncekey = 'post_member' . $usces->get_uscesid( false );
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
$wp_query->set_403();
status_header( 403 );
exit();
}
$this->error_message = $this->lostpass_mailaddcheck();
if ( '' != $this->error_message ) {
$this->page = 'lostmemberpassword';
} else {
$res = $this->lostmail();
$this->page = $res; // 'lostcompletion';.
}
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function uscesmode_changepassword() {
global $wp_query;
if ( ! isset( $_REQUEST['mem'] ) || ! isset( $_REQUEST['key'] ) ) {
die( 'Invalid request 1' );
}
$mem_mail = $_REQUEST['mem'];
$lostkey = $_REQUEST['key'];
$res = usces_check_lostkey( $mem_mail, $lostkey );
if ( empty( $res ) ) {
die( 'Invalid request 2' );
}
$this->page = 'changepassword';
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function changepassword_page() {
global $usces;
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
$noncekey = 'post_member' . $usces->get_uscesid( false );
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
die( 'Security check6' );
}
$lostmail = $_POST['mem'];
$lostkey = $_POST['key'];
$res = usces_check_lostkey( $lostmail, $lostkey );
if ( empty( $res ) ) {
die( 'Invalid request 7' );
}
global $wp_query;
$this->error_message = $this->changepass_check();
if ( '' != $this->error_message ) {
$this->page = 'changepassword';
} else {
$res = $this->changepassword();
$this->page = $res; // 'changepasscompletion';.
}
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function page_newmember() {
global $wp_query;
$this->page = 'newmemberform';
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform' );
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function page_search_item() {
global $wp_query;
$this->page = 'search_item';
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function default_page() {
global $wp_query;
add_action( 'the_post', array( $this, 'goDefaultPage' ) );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
}
public function verifyGoogleRecapcha() {
// check google re-captcha v3.
$option = get_option( 'usces_ex' );
$is_human = true;
if ( isset( $option['system']['google_recaptcha']['status'] ) && $option['system']['google_recaptcha']['status'] && ! ( empty( $option['system']['google_recaptcha']['site_key'] ) ) && ! ( empty( $option['system']['google_recaptcha']['secret_key'] ) ) ) {
if ( isset( $_POST['recaptcha_response'] ) ) {
$secret = isset( $option['system']['google_recaptcha']['secret_key'] ) ? $option['system']['google_recaptcha']['secret_key'] : '';
$token = trim( $_POST['recaptcha_response'] );
$is_human = $this->google_recaptcha_v3_response( $token, $secret );
}
}
return $is_human;
}
/**
* Handle check google recaptcha v3 response.
*
* @param string $token string token.
* @param string $secret string secret key config.
*
* @return boolean $is_human.
*/
public function google_recaptcha_v3_response( $token, $secret ) {
$is_human = true;
if ( empty( $token ) || empty( $secret ) ) {
return $is_human;
}
$option = get_option( 'usces_ex' );
$threshold = isset( $option['system']['google_recaptcha']['score'] ) ? $option['system']['google_recaptcha']['score'] : 0.5;
$endpoint = 'https://www.google.com/recaptcha/api/siteverify';
$request = array(
'body' => array(
'secret' => $secret,
'response' => $token,
),
);
$response = wp_remote_post( esc_url_raw( $endpoint ), $request );
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
update_option( 'usces_recaptcha_condition', 'response_NG' );
return $is_human;
} else {
update_option( 'usces_recaptcha_condition', 'response_OK' );
}
$response_body = wp_remote_retrieve_body( $response );
$response_body = json_decode( $response_body, true );
$action = isset( $response_body['action'] ) ? $response_body['action'] : '';
$actions = array(
'create_new_member',
'customer_order_page',
'delivery_order_page',
'member_register_settlement',
'member_update_settlement',
);
if ( ! $response_body['success'] || ! in_array( $action, $actions ) ) {
update_option( 'usces_recaptcha_condition', 'response_ERROR' );
return $is_human;
} else {
update_option( 'usces_recaptcha_condition', 'response_OK' );
}
$score = isset( $response_body['score'] ) ? $response_body['score'] : 0;
$is_human = $threshold <= $score;
return $is_human;
}
public function goDefaultPage() {
global $post;
if ( is_object( $post ) && null !== $post && (int) $post->ID === (int) USCES_CART_NUMBER ) {
$this->page = 'cart';
add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 );
} elseif ( is_object( $post ) && null !== $post && (int) $post->ID === (int) USCES_MEMBER_NUMBER ) {
$this->page = 'member';
if ( $this->is_member_logged_in() ) {
$this->get_current_member();
$this->set_member_session_data( $this->current_member['id'] );
$this->page = 'member';
} else {
$this->page = 'login';
}
add_filter( 'the_content', array( $this, 'filter_memberContent' ), 20 );
add_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 );
} elseif ( ! is_singular() ) {
$this->page = 'wp_search';
add_filter( 'the_excerpt', array( $this, 'filter_cartContent' ), 20 );
add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 );
} else {
add_filter( 'the_content', array( &$this, 'filter_itemPage' ) );
}
}
public function template_redirect() {
global $wpdb, $wp_version, $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode;
if ( version_compare( $wp_version, '4.4-beta', '>' ) && is_embed() ) {
return;
}
if ( $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
if ( '' == $this->page && empty( $this->error_message ) ) {
$this->error_message = $this->zaiko_check();
if ( $this->error_message ) {
$this->page = 'cart';
}
}
}
if ( apply_filters( 'usces_action_template_redirect', false ) ) {
return; // Deprecated.
}
if ( apply_filters( 'usces_filter_template_redirect', false ) ) {
return;
}
$parent_path = get_template_directory() . '/wc_templates';
$child_path = get_stylesheet_directory() . '/wc_templates';
if ( is_single() && is_object( $post ) && 'item' === $post->post_mime_type ) {
if ( file_exists( $child_path . '/wc_item_single.php' ) ) {
if ( ! post_password_required( $post ) ) {
include $child_path . '/wc_item_single.php';
exit;
}
} elseif ( file_exists( $parent_path . '/wc_item_single.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
if ( ! post_password_required( $post ) ) {
include $parent_path . '/wc_item_single.php';
exit;
}
}
} elseif ( isset( $_REQUEST['usces_page'] ) && ( 'search_item' == $_REQUEST['usces_page'] || 'usces_search' == $_REQUEST['usces_page'] ) && $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
if ( file_exists( $child_path . '/wc_search_page.php' ) ) {
include $child_path . '/wc_search_page.php';
exit;
} elseif ( file_exists( $parent_path . '/wc_search_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/wc_search_page.php';
exit;
}
} elseif ( $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
switch ( $this->page ) {
case 'customer':
if ( file_exists( $child_path . '/cart/wc_customer_page.php' ) ) {
usces_get_entries();
usces_get_member_regmode();
include $child_path . '/cart/wc_customer_page.php';
exit;
} elseif ( file_exists( $parent_path . '/cart/wc_customer_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
usces_get_entries();
usces_get_member_regmode();
include $parent_path . '/cart/wc_customer_page.php';
exit;
}
break;
case 'delivery':
if ( file_exists( $child_path . '/cart/wc_delivery_page.php' ) ) {
usces_get_entries();
usces_get_carts();
include $child_path . '/cart/wc_delivery_page.php';
exit;
} elseif ( file_exists( $parent_path . '/cart/wc_delivery_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
usces_get_entries();
usces_get_carts();
include $parent_path . '/cart/wc_delivery_page.php';
exit;
}
break;
case 'confirm':
if ( file_exists( $child_path . '/cart/wc_confirm_page.php' ) ) {
usces_get_entries();
usces_get_carts();
usces_get_members();
include $child_path . '/cart/wc_confirm_page.php';
exit;
} elseif ( file_exists( $parent_path . '/cart/wc_confirm_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
usces_get_entries();
usces_get_carts();
usces_get_members();
include $parent_path . '/cart/wc_confirm_page.php';
exit;
}
break;
case 'ordercompletion':
if ( file_exists( $child_path . '/cart/wc_completion_page.php' ) ) {
usces_get_entries();
usces_get_carts();
include $child_path . '/cart/wc_completion_page.php';
exit;
} elseif ( file_exists( $parent_path . '/cart/wc_completion_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
usces_get_entries();
usces_get_carts();
include $parent_path . '/cart/wc_completion_page.php';
exit;
}
break;
case 'error':
if ( file_exists( $child_path . '/cart/wc_cart_error_page.php' ) ) {
include $child_path . '/cart/wc_cart_error_page.php';
exit;
} elseif ( file_exists( $parent_path . '/cart/wc_cart_error_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/cart/wc_cart_error_page.php';
exit;
}
break;
case 'cart':
default:
$this->page = 'cart';
if ( file_exists( $child_path . '/cart/wc_cart_page.php' ) ) {
include $child_path . '/cart/wc_cart_page.php';
exit;
} elseif ( file_exists( $parent_path . '/cart/wc_cart_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/cart/wc_cart_page.php';
exit;
}
}
} elseif ( $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
} elseif ( $this->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
if ( 'activate' != $this->options['membersystem_state'] ) {
return;
}
if ( $this->is_member_logged_in() ) {
if ( isset( $_SESSION['usces_member'] ) ) {
$member_table_name = usces_get_tablename( 'usces_member' );
$this->get_current_member();
$query = $wpdb->prepare( "SELECT mem_point FROM $member_table_name WHERE ID = %d", $this->current_member['id'] );
$point = $wpdb->get_var( $query );
$_SESSION['usces_member']['point'] = $point;
}
$member_regmode = 'editmemberform';
if ( file_exists( $child_path . '/member/wc_member_page.php' ) ) {
include $child_path . '/member/wc_member_page.php';
exit;
} elseif ( file_exists( $parent_path . '/member/wc_member_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/member/wc_member_page.php';
exit;
}
} else {
switch ( $this->page ) {
case 'login':
if ( file_exists( $child_path . '/member/wc_login_page.php' ) ) {
include $child_path . '/member/wc_login_page.php';
exit;
} elseif ( file_exists( $parent_path . '/member/wc_login_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/member/wc_login_page.php';
exit;
}
break;
case 'newmemberform':
if ( file_exists( $child_path . '/member/wc_new_member_page.php' ) ) {
$member_regmode = 'newmemberform';
include $child_path . '/member/wc_new_member_page.php';
exit;
} elseif ( file_exists( $parent_path . '/member/wc_new_member_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
$member_regmode = 'newmemberform';
include $parent_path . '/member/wc_new_member_page.php';
exit;
}
break;
case 'lostmemberpassword':
if ( file_exists( $child_path . '/member/wc_lostpassword_page.php' ) ) {
include $child_path . '/member/wc_lostpassword_page.php';
exit;
} elseif ( file_exists( $parent_path . '/member/wc_lostpassword_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/member/wc_lostpassword_page.php';
exit;
}
break;
case 'changepassword':
if ( file_exists( $child_path . '/member/wc_changepassword_page.php' ) ) {
include $child_path . '/member/wc_changepassword_page.php';
exit;
} elseif ( file_exists( $parent_path . '/member/wc_changepassword_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/member/wc_changepassword_page.php';
exit;
}
break;
case 'newcompletion':
case 'editcompletion':
case 'lostcompletion':
case 'changepasscompletion':
if ( file_exists( $child_path . '/member/wc_member_completion_page.php' ) ) {
include $child_path . '/member/wc_member_completion_page.php';
exit;
} elseif ( file_exists( $parent_path . '/member/wc_member_completion_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/member/wc_member_completion_page.php';
exit;
}
break;
default:
$this->page = 'login';
if ( file_exists( $child_path . '/member/wc_login_page.php' ) ) {
include $child_path . '/member/wc_login_page.php';
exit;
} elseif ( file_exists( $parent_path . '/member/wc_login_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
include $parent_path . '/member/wc_login_page.php';
exit;
}
}
}
}
}
public function changepassword() {
global $wpdb;
$lostmail = $_POST['mem'];
$lost_key = $_POST['key'];
$member_table = usces_get_tablename( 'usces_member' );
// $hash = usces_get_hash(trim($_POST['loginpass1']));
$salt = usces_get_salt( $lostmail );
$hash = usces_get_hash( trim( $_POST['loginpass1'] ), $salt );
$query = $wpdb->prepare( "UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s",
$hash, $lostmail
);
$res = $wpdb->query( $query );
if ( $res === false ) {
$this->error_message = __( 'Error: failure in updating password', 'usces' );
return 'login';
} else {
usces_remove_lostmail_key( $lostmail, $lost_key );
return 'changepasscompletion';
}
}
public function lostmail() {
$delim = apply_filters( 'usces_filter_delim', $this->delim );
$lostmail = trim( $_POST['loginmail'] );
if ( ! $this->is_member( $lostmail ) ) {
return 'lostcompletion';
}
$lost_key = usces_make_lost_key();
usces_store_lostmail_key( $lostmail, $lost_key );
$uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword&mem=' . urlencode( $lostmail ) . '&key=' . urlencode( $lost_key );
$res = usces_lostmail( $uri );
return $res;
}
public function regist_member() {
global $wpdb;
$_POST = $this->stripslashes_deep_post( $_POST );
$member = $this->get_member();
$mode = $_POST['member_regmode'];
$member_table = usces_get_tablename( 'usces_member' );
$member_meta_table = usces_get_tablename( 'usces_member_meta' );
$error_mes = ( 'newmemberfromcart' == $_POST['member_regmode'] || 'editmemberfromcart' == $_POST['member_regmode'] ) ? $this->member_check_fromcart() : $this->member_check();
if ( '' != $error_mes ) {
$this->error_message = $error_mes;
return $mode;
} elseif ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) {
$this->get_current_member();
$mem_id = $this->current_member['id'];
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
// $id = $wpdb->get_var( $query );
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
if ( ! empty( $id ) && $id != $mem_id ) {
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
return $mode;
}
do_action( 'usces_action_pre_edit_memberdata', $_POST['member'], $mem_id );
$query = $wpdb->prepare( "SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id );
$pass = $wpdb->get_var( $query );
// $password = ( !empty( $_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? usces_get_hash(trim($_POST['member']['password1'])) : $pass;
if ( ! empty( $_POST['member']['password1'] ) && trim( $_POST['member']['password1'] ) == trim( $_POST['member']['password2'] ) ) {
$salt = usces_get_salt( $mem_id );
$password = usces_get_hash( trim( $_POST['member']['password1'] ), $salt );
} else {
$password = $pass;
}
$name1 = ( isset( $_POST['member']['name1'] ) ) ? trim( $_POST['member']['name1'] ) : '';
$name2 = ( isset( $_POST['member']['name2'] ) ) ? trim( $_POST['member']['name2'] ) : '';
$name3 = ( isset( $_POST['member']['name3'] ) ) ? trim( $_POST['member']['name3'] ) : '';
$name4 = ( isset( $_POST['member']['name4'] ) ) ? trim( $_POST['member']['name4'] ) : '';
$zipcode = ( isset( $_POST['member']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['member']['zipcode'] ) ) : '';
$pref = ( isset( $_POST['member']['pref'] ) ) ? trim( $_POST['member']['pref'] ) : '';
$address1 = ( isset( $_POST['member']['address1'] ) ) ? trim( $_POST['member']['address1'] ) : '';
$address2 = ( isset( $_POST['member']['address2'] ) ) ? trim( $_POST['member']['address2'] ) : '';
$address3 = ( isset( $_POST['member']['address3'] ) ) ? trim( $_POST['member']['address3'] ) : '';
$tel = ( isset( $_POST['member']['tel'] ) ) ? trim( $_POST['member']['tel'] ) : '';
$fax = ( isset( $_POST['member']['fax'] ) ) ? trim( $_POST['member']['fax'] ) : '';
$country = ( isset( $_POST['member']['country'] ) ) ? trim( $_POST['member']['country'] ) : '';
$query = $wpdb->prepare(
"UPDATE $member_table SET
mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
$password,
$name1,
$name2,
$name3,
$name4,
$zipcode,
$pref,
$address1,
$address2,
$address3,
$tel,
$fax,
trim( $_POST['member']['mailaddress1'] ),
$mem_id
);
$res = $wpdb->query( $query );
if ( false !== $res ) {
$this->set_member_meta_value( 'customer_country', $country, $mem_id );
$res = $this->reg_custom_member( $mem_id );
unset( $_SESSION['usces_entry']['custom_customer'] );
$this->cart->entry();
do_action( 'usces_action_edit_memberdata', $_POST['member'], $mem_id );
$meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'remise_pcid', 'digitalcheck_ip_user_id'" );
$query = $wpdb->prepare( "DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )",
$mem_id
);
$res = $wpdb->query( $query );
$user = $_POST['member'];
$user['ID'] = $mem_id;
usces_send_updmembermail( $user );
$this->get_current_member();
// return 'editmemberform';
return $mode;
} else {
$this->error_message = __( 'Error:failure in update', 'usces' );
return $mode;
}
} elseif ( 'newmemberform' == $_POST['member_regmode'] ) {
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim( $_POST['member']['mailaddress1']));
// $id = $wpdb->get_var( $query );
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
if ( ! empty( $id ) ) {
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
return $mode;
} else {
$point = $this->options['start_point'];
// $pass = usces_get_hash(trim($_POST['member']['password1']));
$salt = usces_get_salt( '', 1 );
$pass = usces_get_hash( trim( $_POST['member']['password1'] ), $salt );
$name1 = ( isset( $_POST['member']['name1'] ) ) ? trim( $_POST['member']['name1'] ) : '';
$name2 = ( isset( $_POST['member']['name2'] ) ) ? trim( $_POST['member']['name2'] ) : '';
$name3 = ( isset( $_POST['member']['name3'] ) ) ? trim( $_POST['member']['name3'] ) : '';
$name4 = ( isset( $_POST['member']['name4'] ) ) ? trim( $_POST['member']['name4'] ) : '';
$zipcode = ( isset( $_POST['member']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['member']['zipcode'] ) ) : '';
$pref = ( isset( $_POST['member']['pref'] ) ) ? trim( $_POST['member']['pref'] ) : '';
$address1 = ( isset( $_POST['member']['address1'] ) ) ? trim( $_POST['member']['address1'] ) : '';
$address2 = ( isset( $_POST['member']['address2'] ) ) ? trim( $_POST['member']['address2'] ) : '';
$address3 = ( isset( $_POST['member']['address3'] ) ) ? trim( $_POST['member']['address3'] ) : '';
$tel = ( isset( $_POST['member']['tel'] ) ) ? trim( $_POST['member']['tel'] ) : '';
$fax = ( isset( $_POST['member']['fax'] ) ) ? trim( $_POST['member']['fax'] ) : '';
$country = ( isset( $_POST['member']['country'] ) ) ? trim( $_POST['member']['country'] ) : '';
$query = $wpdb->prepare(
"INSERT INTO $member_table
(mem_email, mem_pass, mem_status, mem_cookie, mem_point,
mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
trim( $_POST['member']['mailaddress1'] ),
$pass,
0,
'',
$point,
$name1,
$name2,
$name3,
$name4,
$zipcode,
$pref,
$address1,
$address2,
$address3,
$tel,
$fax,
'',
'',
get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ),
''
);
$res = $wpdb->query( $query );
if ( false !== $res ) {
$user = $_POST['member'];
$user['ID'] = $wpdb->insert_id;
$this->set_member_meta_value( 'customer_country', $country, $user['ID'] );
if ( ! empty( $salt ) ) {
$this->set_member_meta_value( 'mem_salt', $salt, $user['ID'] );
}
$res = $this->reg_custom_member( $user['ID'] );
if ( apply_filters( 'usces_filter_veirfyemail_newmemberform', false, $user ) ) {
return 'memberverifying';
}
do_action( 'usces_action_member_registered', $_POST['member'], $user['ID'] );
unset( $_SESSION['usces_member'] );
usces_send_regmembermail( $user );
return 'newcompletion';
} else {
$this->error_message = __( 'Error:failure in update', 'usces' );
return $mode;
}
}
} elseif ( 'newmemberfromcart' == $_POST['member_regmode'] ) {
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1']));
// $id = $wpdb->get_var( $query );
$id = $this->check_member_email( $_POST['customer']['mailaddress1'] );
if ( ! empty( $id ) ) {
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
return $mode;
} else {
$point = $this->options['start_point'];
// $pass = usces_get_hash(trim( $_POST['customer']['password1']));
$salt = usces_get_salt( '', 1 );
$pass = usces_get_hash( trim( $_POST['customer']['password1'] ), $salt );
$name1 = ( isset( $_POST['customer']['name1'] ) ) ? trim( $_POST['customer']['name1'] ) : '';
$name2 = ( isset( $_POST['customer']['name2'] ) ) ? trim( $_POST['customer']['name2'] ) : '';
$name3 = ( isset( $_POST['customer']['name3'] ) ) ? trim( $_POST['customer']['name3'] ) : '';
$name4 = ( isset( $_POST['customer']['name4'] ) ) ? trim( $_POST['customer']['name4'] ) : '';
$zipcode = ( isset( $_POST['customer']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['customer']['zipcode'] ) ) : '';
$pref = ( isset( $_POST['customer']['pref'] ) ) ? trim( $_POST['customer']['pref'] ) : '';
$address1 = ( isset( $_POST['customer']['address1'] ) ) ? trim( $_POST['customer']['address1'] ) : '';
$address2 = ( isset( $_POST['customer']['address2'] ) ) ? trim( $_POST['customer']['address2'] ) : '';
$address3 = ( isset( $_POST['customer']['address3'] ) ) ? trim( $_POST['customer']['address3'] ) : '';
$tel = ( isset( $_POST['customer']['tel'] ) ) ? trim( $_POST['customer']['tel'] ) : '';
$fax = ( isset( $_POST['customer']['fax'] ) ) ? trim( $_POST['customer']['fax'] ) : '';
$country = ( isset( $_POST['customer']['country'] ) ) ? trim( $_POST['customer']['country'] ) : '';
$query = $wpdb->prepare(
"INSERT INTO $member_table
(mem_email, mem_pass, mem_status, mem_cookie, mem_point,
mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
trim( $_POST['customer']['mailaddress1'] ),
$pass,
0,
'',
$point,
$name1,
$name2,
$name3,
$name4,
$zipcode,
$pref,
$address1,
$address2,
$address3,
$tel,
$fax,
'',
'',
get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ),
''
);
$res = $wpdb->query( $query );
if ( false !== $res ) {
$member_id = $wpdb->insert_id;
$user = $_POST['customer'];
$user['ID'] = $member_id;
$this->set_member_meta_value( 'customer_country', $country, $member_id );
if ( ! empty( $salt ) ) {
$this->set_member_meta_value( 'mem_salt', $salt, $member_id );
}
$res = $this->reg_custom_member( $member_id );
if ( apply_filters( 'usces_filter_veirfyemail_newmemberfromcart', false, $user ) ) {
return 'cartverifying';
}
do_action( 'usces_action_member_registered', $_POST['customer'], $member_id );
usces_send_regmembermail( $user );
$_POST['loginmail'] = trim( $_POST['customer']['mailaddress1'] );
$_POST['loginpass'] = trim( $_POST['customer']['password1'] );
if ( 'member' == $this->member_login() ) {
$_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart';
return 'newcompletion';
}
} else {
$this->error_message = __( 'Error:failure in update', 'usces' );
return $mode;
}
}
} elseif ( 'editmemberfromcart' == $_POST['member_regmode'] ) {
$this->get_current_member();
$mem_id = $this->current_member['id'];
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim( $_POST['customer']['mailaddress1']));
// $id = $wpdb->get_var( $query );
$id = $this->check_member_email( $_POST['customer']['mailaddress1'] );
if ( ! empty( $id ) && $id != $mem_id ) {
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
return $mode;
}
do_action( 'usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id );
$query = $wpdb->prepare( "SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id );
$pass = $wpdb->get_var( $query );
// $password = ( !empty( $_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? usces_get_hash(trim($_POST['customer']['password1'])) : $pass;
if ( ! empty( $_POST['customer']['password1'] ) && trim( $_POST['customer']['password1'] ) == trim( $_POST['customer']['password2'] ) ) {
$salt = usces_get_salt( $mem_id );
$password = usces_get_hash( trim( $_POST['customer']['password1'] ), $salt );
} else {
$password = $pass;
}
$name1 = ( isset( $_POST['customer']['name1'] ) ) ? trim( $_POST['customer']['name1'] ) : '';
$name2 = ( isset( $_POST['customer']['name2'] ) ) ? trim( $_POST['customer']['name2'] ) : '';
$name3 = ( isset( $_POST['customer']['name3'] ) ) ? trim( $_POST['customer']['name3'] ) : '';
$name4 = ( isset( $_POST['customer']['name4'] ) ) ? trim( $_POST['customer']['name4'] ) : '';
$zipcode = ( isset( $_POST['customer']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['customer']['zipcode'] ) ) : '';
$pref = ( isset( $_POST['customer']['pref'] ) ) ? trim( $_POST['customer']['pref'] ) : '';
$address1 = ( isset( $_POST['customer']['address1'] ) ) ? trim( $_POST['customer']['address1'] ) : '';
$address2 = ( isset( $_POST['customer']['address2'] ) ) ? trim( $_POST['customer']['address2'] ) : '';
$address3 = ( isset( $_POST['customer']['address3'] ) ) ? trim( $_POST['customer']['address3'] ) : '';
$tel = ( isset( $_POST['customer']['tel'] ) ) ? trim( $_POST['customer']['tel'] ) : '';
$fax = ( isset( $_POST['customer']['fax'] ) ) ? trim( $_POST['customer']['fax'] ) : '';
$country = ( isset( $_POST['customer']['country'] ) ) ? trim( $_POST['customer']['country'] ) : '';
$query = $wpdb->prepare(
"UPDATE $member_table SET
mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
$password,
$name1,
$name2,
$name3,
$name4,
$zipcode,
$pref,
$address1,
$address2,
$address3,
$tel,
$fax,
trim( $_POST['customer']['mailaddress1'] ),
$mem_id
);
$res = $wpdb->query( $query );
if ( false !== $res ) {
$this->set_member_meta_value( 'customer_country', $country, $mem_id );
$res = $this->reg_custom_member( $mem_id );
do_action( 'usces_action_edit_memberdata', $_POST['customer'], $mem_id );
unset( $_SESSION['usces_member'] );
$this->member_just_login( trim( $_POST['customer']['mailaddress1'] ), trim( $_POST['customer']['password1'] ) );
return 'newcompletion';
} else {
$this->error_message = __( 'Error:failure in update', 'usces' );
return $mode;
}
}
}
public function delete_member() {
$res = false;
if ( ! $this->is_member_logged_in() ) {
return $res;
}
$mem = $this->get_member();
if ( ! $mem['ID'] ) {
return $res;
}
$del = usces_delete_member_check_front( $mem['ID'] );
if ( $del ) {
$res = usces_delete_memberdata( $mem['ID'] );
if ( $res ) {
usces_send_delmembermail( $mem );
}
}
return $res;
}
public function is_member_logged_in( $id = false ) {
if ( false === $id ) {
if ( ! empty( $_SESSION['usces_member']['ID'] ) ) {
return true;
} else {
return false;
}
} else {
if ( ! empty( $_SESSION['usces_member']['ID'] ) && $_SESSION['usces_member']['ID'] == $id ) {
return true;
} else {
return false;
}
}
}
public function is_member( $email ) {
global $wpdb;
$member_table = usces_get_tablename( 'usces_member' );
$query = $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE mem_email = %s", $email );
$member = $wpdb->get_row( $query, ARRAY_A );
if ( empty( $member ) ) {
return false;
} else {
return true;
}
}
public function member_login() {
global $wpdb;
$_POST = $this->stripslashes_deep_post( $_POST );
$cookie = $this->get_cookie();
$metatable_name = usces_get_tablename( 'usces_member_meta' );
$member_table = usces_get_tablename( 'usces_member' );
if ( ! class_exists( 'RateLimiter' ) ) {
require USCES_PLUGIN_DIR . '/classes/rateLimiter.class.php';
}
$rateLimiter = new RateLimiter();
if ( isset( $cookie['rme'] ) && 'forever' == $cookie['rme'] && ! isset( $_POST['rememberme'] ) && ! isset( $_POST['loginmail'] ) ) {
$_forever = isset( $cookie['name'] ) ? $cookie['name'] : '';
if ( $_forever ) {
$query = $wpdb->prepare( "SELECT member_id FROM $metatable_name WHERE meta_value = %s AND meta_key = %s",
$_forever, '_forever'
);
$id = $wpdb->get_var( $query );
} else {
$id = '';
}
if ( ! $id ) {
$cookie['name'] = '';
$cookie['rme'] = '';
$this->set_cookie( $cookie );
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', '', 'auto_login' );
return 'login';
} else {
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE ID = %s", $id );
$member = $wpdb->get_row( $query, ARRAY_A );
if ( empty( $member ) ) {
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', '', 'auto_login' );
$this->error_message = __( 'Error: Your E-mail or password is incorrect.', 'usces' );
return 'login';
} else {
$_SESSION['usces_member']['ID'] = $member['ID'];
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
$_SESSION['usces_member']['point'] = $member['mem_point'];
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
$_SESSION['usces_member']['status'] = $member['mem_status'];
$this->set_session_custom_member( $member['ID'] );
$this->get_current_member();
do_action( 'usces_action_after_login' );
$this->set_cookie( $cookie );
return apply_filters( 'usces_filter_member_login', 'member', $member );
}
}
} elseif ( isset( $_POST['loginmail'] ) && WCUtils::is_blank( $_POST['loginmail'] ) && isset( $_POST['loginpass'] ) && WCUtils::is_blank( $_POST['loginpass'] ) && isset( $cookie['rme'] ) && 'forever' != $cookie['rme'] ) {
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', '', 'empty_credentials' );
return 'login';
} elseif ( isset( $_POST['loginmail'] ) && WCUtils::is_blank( $_POST['loginpass'] ) && isset( $cookie['rme'] ) && 'forever' != $cookie['rme'] ) {
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', trim( $_POST['loginmail'] ), 'empty_password' );
$this->error_message = __( 'Error: Enter the password.', 'usces' );
return 'login';
} elseif ( ! isset( $_POST['loginmail'] ) ) {
if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', '', 'no_login_id' );
}
return 'login';
} else {
if ( isset( $_POST['loginmail'] ) ) {
$nonce = isset( $_REQUEST['wel_nonce'] ) ? $_REQUEST['wel_nonce'] : '';
if ( ! $nonce ) {
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
}
$noncekey = 'post_member' . $this->get_uscesid( false );
if ( ! wp_verify_nonce( $nonce, $noncekey ) && ! $this->is_member_logged_in() ) {
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', trim( $_POST['loginmail'] ), 'invalid_nonce' );
die( 'Security check4' );
}
}
$email = isset( $_POST['loginmail'] ) ? trim( $_POST['loginmail'] ) : '';
// $pass = isset( $_POST['loginpass']) ? usces_get_hash(trim( $_POST['loginpass'])) : '';
$salt = usces_get_salt( $email );
$pass = usces_get_hash( trim( $_POST['loginpass'] ), $salt );
$member_table = usces_get_tablename( 'usces_member' );
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass );
$query = apply_filters( 'usces_filter_member_login_query', $query, $email, $pass );
$member = $wpdb->get_row( $query, ARRAY_A );
if ( empty( $member ) ) {
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', $email, 'invalid_credentials' );
$this->current_member['email'] = htmlspecialchars( $email, ENT_COMPAT );
$this->error_message = __( 'Error: Your E-mail or password is incorrect.', 'usces' );
return 'login';
} else {
if ( USCES_VERIFY_MEMBERS_EMAIL::$opts['switch_flag'] ) {
$verify_flag = $this->get_member_meta_value( '_verifying', $member['ID'] );
} else {
$verify_flag = '';
}
if ( ! empty( $verify_flag ) ) {
$rateLimiter->saveLoginFailed();
do_action( 'usces_action_member_login_failed', $email, 'unverified_email' );
$this->error_message = __( 'Error: Membership registration is not complete.', 'usces' );
return 'login';
}
$_SESSION['usces_member']['ID'] = $member['ID'];
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
$_SESSION['usces_member']['point'] = $member['mem_point'];
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
$_SESSION['usces_member']['status'] = $member['mem_status'];
$this->set_session_custom_member( $member['ID'] );
$this->get_current_member();
$rateLimiter->clear_login_failed();
if ( isset( $_POST['rememberme'] ) ) {
$_forever = $this->set_login_forever( $member['ID'] );
$cookie['name'] = $_forever;
$cookie['rme'] = 'forever';
$this->set_cookie( $cookie );
} else {
$cookie['name'] = '';
$cookie['rme'] = '';
$this->set_cookie( $cookie );
}
do_action( 'usces_action_after_login' );
return apply_filters( 'usces_filter_member_login', 'member', $member );
}
}
}
public function set_login_forever( $member_id ) {
if ( ! $member_id ) {
return false;
}
$_forever = wp_generate_password( 32, false, false );
$this->set_member_meta_value( '_forever', $_forever, $member_id );
return $_forever;
}
public function set_member_session_data( $member_id ) {
global $wpdb;
$member_table = usces_get_tablename( 'usces_member' );
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE ID = %s", $member_id );
$member = $wpdb->get_row( $query, ARRAY_A );
if ( ! empty( $member ) ) {
$_SESSION['usces_member']['ID'] = $member['ID'];
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
$_SESSION['usces_member']['point'] = $member['mem_point'];
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
$_SESSION['usces_member']['status'] = $member['mem_status'];
$this->set_session_custom_member( $member['ID'] );
$this->get_current_member();
}
return;
}
public function member_just_login( $email, $pass ) {
global $wpdb;
// $pass = usces_get_hash($pass);
$salt = usces_get_salt( $email );
$pass = usces_get_hash( $pass, $salt );
$member_table = usces_get_tablename( 'usces_member' );
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass );
$member = $wpdb->get_row( $query, ARRAY_A );
if ( empty( $member ) ) {
$this->current_member['email'] = htmlspecialchars( $email, ENT_COMPAT );
$this->error_message = __( 'Error: Password is not correct.', 'usces' );
return 'login';
} else {
$_SESSION['usces_member']['ID'] = $member['ID'];
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
$_SESSION['usces_member']['point'] = $member['mem_point'];
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
$_SESSION['usces_member']['status'] = $member['mem_status'];
$this->set_session_custom_member( $member['ID'] );
$this->get_current_member();
do_action( 'usces_action_after_login' );
return apply_filters( 'usces_filter_member_login', 'member', $member );
}
}
public function member_logout() {
do_action( 'usces_action_before_logout' );
$cookie = $this->get_cookie();
$cookie['name'] = '';
$cookie['rme'] = '';
$options = get_option( 'usces' );
$this->set_cookie( $cookie );
$fcookie = $this->get_cookie( $options['usces_key'] );
unset( $_SESSION['usces_member'], $_SESSION['usces_entry'] );
do_action( 'usces_action_member_logout' );
}
public function get_current_member() {
if ( isset( $_SESSION['usces_member']['ID'] ) ) {
$this->current_member['id'] = $_SESSION['usces_member']['ID'];
$this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return' );
} else {
$this->current_member['id'] = 0;
$this->current_member['name'] = __( 'guest', 'usces' );
}
}
public function get_member() {
$res = array(
'ID' => '',
'registered' => '',
'mailaddress1' => '',
'mailaddress2' => '',
'password1' => '',
'password2' => '',
'point' => '',
'name1' => '',
'name2' => '',
'name3' => '',
'name4' => '',
'zipcode' => '',
'address1' => '',
'address2' => '',
'address3' => '',
'tel' => '',
'fax' => '',
'country' => '',
'pref' => '',
'status' => '',
);
if ( ! empty( $_SESSION['usces_member'] ) ) {
foreach ( $_SESSION['usces_member'] as $key => $value ) {
if ( is_array( $_SESSION['usces_member'][ $key ] ) ) {
$res[ $key ] = stripslashes_deep( $value );
} else {
$res[ $key ] = null !== $value ? stripslashes( $value ) : '';
}
}
}
return $res;
}
public function get_member_info( $mid ) {
global $wpdb;
$infos = array();
$table = usces_get_tablename( 'usces_member' );
$query = $wpdb->prepare( "SELECT * FROM $table WHERE ID = %d", $mid );
$datas = $wpdb->get_results( $query, ARRAY_A );
if ( $datas ) {
$infos = $datas[0];
$table = usces_get_tablename( 'usces_member_meta' );
$query = $wpdb->prepare( "SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid );
$metas = $wpdb->get_results( $query, ARRAY_A );
foreach ( $metas as $meta ) {
$infos[ $meta['meta_key'] ] = maybe_unserialize( $meta['meta_value'] );
}
}
return $infos;
}
public function set_member_info( $data = array(), $mid = '' ) {
global $wpdb;
$table = usces_get_tablename( 'usces_member' );
$res = $wpdb->update( $table, $data, array( 'ID' => $mid ), null, array( '%d' ) );
return $res;
}
public function check_member_email( $email ) {
global $wpdb;
$member_table_name = usces_get_tablename( 'usces_member' );
$query = $wpdb->prepare( "SELECT ID FROM $member_table_name WHERE mem_email = %s", trim( $email ) );
$id = $wpdb->get_var( $query );
return $id;
}
public function is_order( $mid, $oid ) {
global $wpdb;
$mid = (int) $mid;
$oid = (int) $oid;
$table = $wpdb->prefix . 'usces_order';
$query = $wpdb->prepare( "SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid );
$mem_id = $wpdb->get_var( $query );
if ( empty( $mem_id ) ) {
return false;
} else {
return true;
}
}
public function is_purchased_item( $mid, $post_id, $sku = null, $order_id = null ) {
global $wpdb;
$res = false;
if ( empty( $order_id ) ) {
$history = $this->get_member_history( $mid, true );
foreach ( $history as $umhs ) {
$cart = $umhs['cart'];
$status = $umhs['order_status'];
$cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
for ( $i = 0; $i < $cart_count; $i++ ) {
$cart_row = $cart[ $i ];
$sku_code = urldecode( $cart_row['sku'] );
if ( empty( $sku ) ) {
if ( $cart_row['post_id'] == $post_id && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) ) ) {
$res = true;
break 2;
} elseif ( $cart_row['post_id'] == $post_id && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) ) ) {
$res = 'noreceipt';
break 2;
}
} else {
if ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) ) ) {
$res = true;
break 2;
} elseif ( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) ) ) {
$res = 'noreceipt';
break 2;
}
}
}
}
} else {
$order_table_name = $wpdb->prefix . 'usces_order';
$query = $wpdb->prepare( "SELECT order_status FROM $order_table_name WHERE ID = %d AND mem_id = %d",
$order_id, $mid
);
$order = $wpdb->get_row( $query );
if ( is_null( $order ) ) { // 該当の受注データが一件も見つからなかった場合、購入していないと判断する.
$res = false;
} else { // 該当の受注データが見つかった場合には受注ステータスを確認する処理を行う.
$status = $order->order_status;
$cart = usces_get_ordercartdata( $order_id );
foreach ( $cart as $cart_row ) {
$sku_code = urldecode( $cart_row['sku'] );
if ( empty( $sku ) ) {
if ( $cart_row['post_id'] == $post_id && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) && false === strpos( $status, 'cancel' ) ) ) {
$res = true;
break;
} elseif ( $cart_row['post_id'] == $post_id && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) || false !== strpos( $status, 'cancel' ) ) ) {
$res = 'noreceipt';
break;
}
} else {
if ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) && false === strpos( $status, 'cancel' ) ) ) {
$res = true;
break;
} elseif ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) || false !== strpos( $status, 'cancel' ) ) ) {
$res = 'noreceipt';
break;
}
}
}
}
}
return apply_filters( 'usces_filter_is_purchased_item', $res, $mid, $post_id, $sku, $order_id );
}
public function get_order_data( $order_id, $mode = '' ) {
global $wpdb;
$order_table = $wpdb->prefix . 'usces_order';
$query = $wpdb->prepare( "SELECT * FROM $order_table WHERE ID = %d", $order_id );
if ( 'direct' == $mode ) {
$value = $wpdb->get_row( $query, ARRAY_A );
return $value;
}
$value = $wpdb->get_row( $query );
if ( null == $value ) {
return false;
} else {
$res = array();
}
if ( strpos( $value->order_status, 'cancel' ) !== false || strpos( $value->order_status, 'estimate' ) !== false ) {
return false;
}
$total_price = $value->order_item_total_price - $value->order_usedpoint + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax;
if ( $total_price < 0 ) {
$total_price = 0;
}
$res = array(
'ID' => $value->ID,
'mem_id' => $value->mem_id,
'cart' => unserialize( $value->order_cart ),
'condition' => unserialize( $value->order_condition ),
'getpoint' => $value->order_getpoint,
'usedpoint' => $value->order_usedpoint,
'discount' => $value->order_discount,
'payment_name' => $value->order_payment_name,
'shipping_charge' => $value->order_shipping_charge,
'cod_fee' => $value->order_cod_fee,
'tax' => $value->order_tax,
'end_price' => $total_price,
'status' => $value->order_status,
'date' => mysql2date( __( 'Y/m/d' ), $value->order_date ),
'modified' => mysql2date( __( 'Y/m/d' ), $value->order_modified ),
);
return $res;
}
public function get_orderIDs_by_postID( $mem_id, $post_id ) {
global $wpdb;
$order_table = $wpdb->prefix . 'usces_order';
$query = $wpdb->prepare( "SELECT ID, order_cart, order_status FROM $order_table WHERE mem_id = %d ORDER BY order_modified DESC, order_date DESC", $mem_id );
$rows = $wpdb->get_query( $query, ARRAY_A );
if ( null == $value ) {
return false;
} else {
foreach ( $rows as $row ) {
if ( strpos( $row['order_status'], 'cancel' ) !== false || strpos( $row['order_status'], 'estimate' ) !== false ) {
continue;
} else {
$carts = unserialize( $row['order_cart'] );
foreach ( $carts as $cart ) {
if ( $post_id == $cart['post_id'] ) {
$res[] = $row['ID'];
break;
}
}
}
}
}
return $res;
}
public function incart_check() {
$mes = array();
$ids = array_keys( $_POST['inCart'] );
$post_id = $ids[0];
$skus = array_keys( $_POST['inCart'][ $post_id ] );
$sku = $skus[0];
$sku_code = urldecode( $sku );
$quant = isset( $_POST['quant'][ $post_id ][ $sku ] ) ? (int) $_POST['quant'][ $post_id ][ $sku ] : 1;
$stock = $this->getItemZaikoNum( $post_id, $sku );
$zaiko_id = (int) $this->getItemZaikoStatusId( $post_id, $sku );
$product = wel_get_product( $post_id );
$itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : '';
$itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id );
if ( 1 > $quant ) {
$mes[ $post_id ][ $sku ] = __( 'enter the correct amount', 'usces' ) . '
';
} elseif ( $quant > (int) $itemRestriction && ! WCUtils::is_blank( $itemRestriction ) && ! WCUtils::is_zero( $itemRestriction ) ) {
$mes[ $post_id ][ $sku ] = sprintf( __( 'This article is limited by %d at a time.', 'usces' ), $itemRestriction ) . '
';
} elseif ( 1 != $itemOrderAcceptable && $quant > (int) $stock && ! WCUtils::is_blank( $stock ) ) {
$mes[ $post_id ][ $sku ] = __( 'Sorry, stock is insufficient.', 'usces' ) . ' ' . __( 'Current stock', 'usces' ) . $stock . '
';
} elseif ( 1 != $itemOrderAcceptable && !$this->is_item_zaiko( $post_id, $sku_code ) ) {
$mes[ $post_id ][ $sku ] = __( 'Sorry, this item is sold out.', 'usces' ) . '
';
} else {
$mes[ $post_id ][ $sku ] = '';
}
$ioptkeys = $this->get_itemOptionKey( $post_id, true );
if ( $ioptkeys ) {
foreach ( $ioptkeys as $key => $value ) {
$optValues = $this->get_itemOptions( urldecode( $value ), $post_id );
if ( 0 == $optValues['means'] ) { // case of select.
if ( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) {
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '
';
}
} elseif ( 1 == $optValues['means'] ) { // case of multiselect.
if ( $optValues['essential'] ) {
$mselect = 0;
foreach ( (array) $_POST['itemOption'][ $post_id ][ $sku ][ $value ] as $mvalue ) {
if ( ! empty( $mvalue ) && '#NONE#' != $mvalue ) {
$mselect++;
}
}
if ( $mselect == 0 ) {
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '
';
}
}
} elseif ( in_array( $optValues['means'], array( 3, 4 ) ) ) { // case of radio & checkbox.
if ( $optValues['essential'] ) {
if ( ! isset( $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) ) {
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '
';
}
}
} else { // case of text.
if ( $optValues['essential'] && WCUtils::is_blank( $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) ) {
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Input the %s', 'usces' ), urldecode( $value ) ) . '
';
}
}
}
}
$mes = apply_filters( 'usces_filter_incart_check', $mes, $post_id, $sku );
if ( isset( $mes[ $post_id ] ) && is_array( $mes[ $post_id ] ) ) {
$rembr = array();
foreach ( $mes[ $post_id ] as $skukey => $skuvalue ) {
if ( ! empty( $skuvalue ) ) {
$rembr[ $post_id ][ $skukey ] = preg_replace( '/
\s*$/', '', $skuvalue );
}
}
$mes = $rembr;
}
if ( ! empty( $mes ) ) {
$_SESSION['usces_singleitem']['itemOption'] = isset( $_POST['itemOption'] ) ? $_POST['itemOption'] : array();
$_SESSION['usces_singleitem']['quant'] = isset( $_POST['quant'] ) ? (int) $_POST['quant'] : 1;
$_SESSION['usces_singleitem']['error_message'] = $mes;
if ( false === strpos( $_POST['usces_referer'], 'http' ) ) {
$parse_url = parse_url( get_home_url() );
$port = '';
if ( isset( $parse_url['port'] ) && ! empty( $parse_url['port'] ) ) {
$port = ':' . $parse_url['port'];
}
header( 'location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $port . esc_url( $_POST['usces_referer'] ) . apply_filters( 'usces_filter_incart_redirect', '#cart_button', $post_id, $sku ) );
} else {
header( 'location: ' . esc_url( $_POST['usces_referer'] ) . apply_filters( 'usces_filter_incart_redirect', '#cart_button', $post_id, $sku ) );
}
exit;
}
do_action( 'usces_action_incart_checked', $mes, $post_id, $sku );
}
public function zaiko_check() {
$logged_in_member = $this->get_member();
if ( ! empty( $logged_in_member['ID'] ) ) {
if ( ! $this->member_exists( $logged_in_member['ID'] ) ) {
$mes = __( 'Your membership information could not be verified.', 'usces' );
$this->error_message = $mes;
$this->member_logout();
return $mes;
}
}
$mes = '';
$cart = $this->cart->get_cart();
$stocks = array();
$cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
for ( $i = 0; $i < $cart_count; $i++ ) {
$cart_row = $cart[ $i ];
$post_id = $cart_row['post_id'];
$sku = $cart_row['sku'];
$sku_code = urldecode( $cart_row['sku'] );
$quant = ( isset( $_POST['quant'][ $i ][ $post_id ][ $sku ] ) ) ? trim( $_POST['quant'][ $i ][ $post_id ][ $sku ] ) : $cart_row['quantity'];
$zaiko_id = (int) $this->getItemZaikoStatusId( $post_id, $sku_code );
$stock = $this->getItemZaikoNum( $post_id, $sku_code );
if ( ! isset( $stocks[ $post_id ][ $sku ] ) ) {
if ( ! WCUtils::is_blank( $stock ) ) {
$stocks[ $post_id ][ $sku ] = $stock;
} else {
$stocks[ $post_id ][ $sku ] = null;
}
}
$checkstock = $stocks[ $post_id ][ $sku ];
$stocks[ $post_id ][ $sku ] = $stocks[ $post_id ][ $sku ] - $quant;
$product = wel_get_product( $post_id );
$itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : '';
$itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id );
$post_status = get_post_status( $post_id );
if ( 1 > (int) $quant ) {
$mes .= sprintf( __( 'Enter the correct amount for the No.%d item.', 'usces' ), ( $i + 1 ) ) . '
';
} elseif ( ! $this->is_item_zaiko( $post_id, $sku_code ) || ( 1 != $itemOrderAcceptable && WCUtils::is_zero( $stock ) ) || 'publish' != $post_status ) {
$mes .= sprintf( __( 'Sorry, No.%d item is sold out.', 'usces' ), ( $i + 1 ) ) . '
';
} elseif ( $quant > (int) $itemRestriction && ! WCUtils::is_blank( $itemRestriction ) && ! WCUtils::is_zero( $itemRestriction ) ) {
$mes .= sprintf( __( 'This article is limited by %1$d at a time for the No.%2$d item.', 'usces' ), $itemRestriction, ( $i + 1 ) ) . '
';
} elseif ( 1 != $itemOrderAcceptable && 0 > $stocks[ $post_id ][ $sku ] && ! WCUtils::is_blank( $stock ) ) {
$mes .= sprintf( __( 'Stock of No.%1$d item is remainder %2$d.', 'usces' ), ( $i + 1 ), $checkstock ) . '
';
}
}
$mes = apply_filters( 'usces_filter_zaiko_check', $mes, $cart);
return $mes;
}
/**
* Check if the member exists in the database or not.
*
* @param integer $member_id The id of the member.
* @return boolean true/false
*/
public function member_exists( $member_id ) {
$member_info = $this->get_member_info( $member_id );
if ( empty( $member_info ) ) {
return false;
} else {
return true;
}
}
public function get_pwd_errors( $password ) {
if ( WCUtils::is_blank( $password ) ) {
return __( 'Please enter a password.', 'usces' ) . '
';
}
$ret = '';
$system_option = $this->options['system'];
$pwd_rule_min = $system_option['member_pass_rule_min'];
$pwd_rule_max = empty( $system_option['member_pass_rule_max'] ) ? 30 : $system_option['member_pass_rule_max'];
if ( strlen( $password ) < $pwd_rule_min || strlen( $password ) > $pwd_rule_max ) {
if ( $pwd_rule_min === $pwd_rule_max ) {
$rule = sprintf( __( '%s characters long', 'usces' ), $pwd_rule_min );
} else {
$rule = sprintf( __( '%1$s characters and no more than %2$s characters', 'usces' ), $pwd_rule_min, $pwd_rule_max );
}
$ret .= sprintf( __( 'Password must be at least %s.', 'usces' ), $rule ) . '
';
}
if ( ! empty( $system_option['member_pass_rule_upercase'] ) && ! preg_match( '@[A-Z]@', $password ) ) {
$ret .= __( 'Password must contain at least one upper-case alphabetics character.', 'usces' ) . '
';
}
if ( ! empty( $system_option['member_pass_rule_lowercase'] ) && ! preg_match( '@[a-z]@', $password ) ) {
$ret .= __( 'Password must contain at least one lower-case alphabetics character.', 'usces' ) . '
';
}
if ( ! empty( $system_option['member_pass_rule_digit'] ) && ! preg_match( '@[0-9]@', $password ) ) {
$ret .= __( 'Password must contain at least one numeric character.', 'usces' ) . '
';
}
if ( ! empty( $system_option['member_pass_rule_symbol'] ) && ! preg_match( '@[\W]@', $password ) ) {
$ret .= __( 'Password must contain at least one symbolic character.', 'usces' ) . '
';
}
return $ret;
}
public function member_check() {
do_action( 'usces_action_before_member_check' );
$mes = '';
$usces_member_old = $_SESSION['usces_member'];
foreach ( $_POST['member'] as $key => $vlue ) {
if ( 'password1' !== $key && 'password2' !== $key && 'mailaddress2' !== $key ) {
$_SESSION['usces_member'][ $key ] = trim( $vlue );
}
}
if ( 'newmemberform' == $_POST['member_regmode'] ||
( 'editmemberform' === $_POST['member_regmode'] && ! ( WCUtils::is_blank( $_POST['member']['password1'] ) && WCUtils::is_blank( $_POST['member']['password2'] ) ) ) ||
( 'updatememberform' === $_POST['member_regmode'] && ! ( WCUtils::is_blank( $_POST['member']['password1'] ) && WCUtils::is_blank( $_POST['member']['password2'] ) ) ) ) {
$mes = $this->get_pwd_errors( $_POST['member']['password1'] );
}
if ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) {
if ( trim( $_POST['member']['password1'] ) != trim( $_POST['member']['password2'] ) ) {
$mes .= __( 'Password confirm does not match.', 'usces' ) . '
';
}
if ( ! is_email( $_POST['member']['mailaddress1'] ) || WCUtils::is_blank( $_POST['member']['mailaddress1'] ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
} else {
$this->get_current_member();
$mem_id = $this->current_member['id'];
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
if ( ! empty( $id ) && $id != $mem_id ) {
$mes .= __( 'This e-mail address can not be registered.', 'usces' ) . '
';
} else {
if ( isset( $_POST['member']['mailaddress2'] ) ) {
if ( WCUtils::is_blank( $_POST['member']['mailaddress2'] ) ) {
if ( $usces_member_old['mailaddress1'] !== $_POST['member']['mailaddress1'] ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
}
} else {
if ( trim( $_POST['member']['mailaddress1'] ) != trim( $_POST['member']['mailaddress2'] ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
}
}
}
}
}
} elseif ( 'newmemberform' == $_POST['member_regmode'] ) {
if ( trim( $_POST['member']['password1'] ) != trim( $_POST['member']['password2'] ) ) {
$mes .= __( 'Password confirm does not match.', 'usces' ) . '
';
}
if ( ! is_email( $_POST['member']['mailaddress1'] ) || WCUtils::is_blank( $_POST['member']['mailaddress1'] ) || WCUtils::is_blank( $_POST['member']['mailaddress2'] ) || trim( $_POST['member']['mailaddress1'] ) != trim( $_POST['member']['mailaddress2'] ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
} else {
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
if ( ! empty( $id ) ) {
$mes .= __( 'This e-mail address can not be registered.', 'usces' ) . '
';
}
}
} else {
$mes .= __( 'ERROR: I was not able to complete collective operation', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) {
$mes .= __( 'Name is not correct', 'usces' ) . '
';
}
$zip_check = false;
$addressform = $this->options['system']['addressform'];
$applyform = usces_get_apply_addressform( $addressform );
if ( 'JP' === $applyform ) {
if ( isset( $_POST['member']['country'] ) ) {
if ( 'JP' === $_POST['member']['country'] ) {
$zip_check = true;
}
} else {
$base = usces_get_base_country();
if ( 'JP' === $base ) {
$zip_check = true;
}
}
}
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
if ( WCUtils::is_blank( $_POST['member']['zipcode'] ) ) {
if ( usces_is_required_field('zipcode') ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
} else {
if ( $zip_check ) {
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['member']['zipcode'] ) ) {
$_SESSION['usces_member']['zipcode'] = usces_convert_zipcode( $_POST['member']['zipcode'] );
}
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_member']['zipcode'] ) ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
}
}
if ( __( '-- Select --', 'usces_dual' ) == $_POST['member']['pref'] && usces_is_required_field( 'states' ) ) {
$mes .= __( 'enter the prefecture', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['member']['address1'] ) && usces_is_required_field( 'address1' ) ) {
$mes .= __( 'enter the city name', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['member']['address2'] ) && usces_is_required_field( 'address2' ) ) {
$mes .= __( 'enter house numbers', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['member']['tel'] ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'enter phone numbers', 'usces' ) . '
';
}
if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '
';
}
if ( 'editmemberform' !== $_POST['member_regmode'] && 'updatememberform' !== $_POST['member_regmode'] && isset( $this->options['agree_member'] ) && 'activate' === $this->options['agree_member'] ) {
if ( ! isset( $_POST['agree_member_check'] ) ) {
$mes .= __( 'Please accept the membership agreement.', 'usces' ) . '
';
}
}
$mes = apply_filters( 'usces_filter_member_check', $mes );
if ( ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) && '' != $mes ) {
$_SESSION['usces_member'] = $usces_member_old;
}
return $mes;
}
public function member_check_fromcart() {
do_action( 'usces_action_before_member_check_fromcart' );
$mes = $this->get_pwd_errors( $_POST['customer']['password1'] );
if ( trim( $_POST['customer']['password1'] ) != trim( $_POST['customer']['password2'] ) ) {
$mes .= __( 'Password confirm does not match.', 'usces' ) . '
';
}
if ( ! is_email( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress2'] ) || trim( $_POST['customer']['mailaddress1'] ) != trim( $_POST['customer']['mailaddress2'] ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['name1'] ) ) {
$mes .= __( 'Name is not correct', 'usces' ) . '
';
}
$zip_check = false;
$addressform = $this->options['system']['addressform'];
$applyform = usces_get_apply_addressform( $addressform );
if ( 'JP' === $applyform ) {
if ( isset( $_POST['customer']['country'] ) ) {
if ( 'JP' === $_POST['customer']['country'] ) {
$zip_check = true;
}
} else {
$base = usces_get_base_country();
if ( 'JP' === $base ) {
$zip_check = true;
}
}
}
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
if ( WCUtils::is_blank( $_POST['customer']['zipcode'] ) ) {
if ( usces_is_required_field( 'zipcode' ) ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
} else {
if ( $zip_check ) {
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['customer']['zipcode'] ) ) {
$_SESSION['usces_entry']['customer']['zipcode'] = usces_convert_zipcode( $_POST['customer']['zipcode'] );
}
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['customer']['zipcode'] ) ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
}
}
if ( ( __( '-- Select --', 'usces' ) == $_POST['customer']['pref'] || '-- Select --' == $_POST['customer']['pref'] ) && usces_is_required_field( 'states' ) ) {
$mes .= __( 'enter the prefecture', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['address1'] ) && usces_is_required_field( 'address1' ) ) {
$mes .= __( 'enter the city name', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['address2'] ) && usces_is_required_field( 'address2' ) ) {
$mes .= __( 'enter house numbers', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['tel'] ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'enter phone numbers', 'usces' ) . '
';
}
if ( ! WCUtils::is_blank( $_POST['customer']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['customer']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '
';
}
if ( isset( $this->options['agree_member'] ) && 'activate' === $this->options['agree_member'] ) {
if ( ! isset( $_POST['agree_member_check'] ) ) {
$mes .= __( 'Please accept the membership agreement.', 'usces' ) . '
';
}
}
$mes = apply_filters( 'usces_filter_member_check_fromcart', $mes );
return $mes;
}
public function admin_member_check() {
global $wpdb;
$mes = '';
if ( ! is_email( trim( $_POST['member']['email'] ) ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
} else {
$member_table = usces_get_tablename( 'usces_member' );
$mem_email = $wpdb->get_var( $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim( $_POST['member_id'] ) ) );
if ( trim( $_POST['member']['email'] ) != $mem_email ) {
$mem_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim( $_POST['member']['email'] ) ) );
if ( ! empty( $mem_ID ) ) {
$mes .= __( 'This e-mail address has been already registered.', 'usces' ) . '
';
}
}
}
if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) {
$mes .= __( 'Name is not correct', 'usces' ) . '
';
}
if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) ) {
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '
';
}
$mes = apply_filters( 'usces_filter_admin_member_check', $mes );
return $mes;
}
public function customer_check() {
do_action( 'usces_action_before_customer_check' );
$mes = '';
if ( ! is_email( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress2'] ) || trim( $_POST['customer']['mailaddress1'] ) != trim( $_POST['customer']['mailaddress2'] ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['name1'] ) ) {
$mes .= __( 'Name is not correct', 'usces' ) . '
';
}
$zip_check = false;
$addressform = $this->options['system']['addressform'];
$applyform = usces_get_apply_addressform( $addressform );
if ( 'JP' === $applyform ) {
if ( isset( $_POST['customer']['country'] ) ) {
if ( 'JP' === $_POST['customer']['country'] ) {
$zip_check = true;
}
} else {
$base = usces_get_base_country();
if ( 'JP' === $base ) {
$zip_check = true;
}
}
}
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
if ( WCUtils::is_blank( $_POST['customer']['zipcode'] ) ) {
if ( usces_is_required_field( 'zipcode' ) ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
} else {
if ( $zip_check ) {
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['customer']['zipcode'] ) ) {
$_SESSION['usces_entry']['customer']['zipcode'] = usces_convert_zipcode( $_POST['customer']['zipcode'] );
}
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['customer']['zipcode'] ) ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
}
}
if ( ( __( '-- Select --', 'usces' ) == $_POST['customer']['pref'] || '-- Select --' == $_POST['customer']['pref'] ) && usces_is_required_field( 'states' ) ) {
$mes .= __( 'enter the prefecture', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['address1'] ) && usces_is_required_field( 'address1' ) ) {
$mes .= __( 'enter the city name', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['address2'] ) && usces_is_required_field( 'address2' ) ) {
$mes .= __( 'enter house numbers', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['customer']['tel'] ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'enter phone numbers', 'usces' ) . '
';
}
if ( ! WCUtils::is_blank( $_POST['customer']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['customer']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '
';
}
$mes = apply_filters( 'usces_filter_customer_check', $mes );
return $mes;
}
public function admin_new_member_check() {
global $wpdb;
$mes = $this->get_pwd_errors( $_POST['member']['password'] );
if ( ! is_email( trim( $_POST['member']['email'] ) ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
} else {
$member_table = usces_get_tablename( 'usces_member' );
$mem_email = $wpdb->get_var( $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim( $_POST['member_id'] ) ) );
if ( trim( $_POST['member']['email'] ) != $mem_email ) {
$mem_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim( $_POST['member']['email'] ) ) );
if ( ! empty( $mem_ID ) ) {
$mes .= __( 'This e-mail address has been already registered.', 'usces' ) . '
';
}
}
}
if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) {
$mes .= __( 'Name is not correct', 'usces' ) . '
';
}
if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) ) {
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '
';
}
$mes = apply_filters( 'usces_filter_admin_member_check', $mes );
return $mes;
}
public function delivery_check() {
global $usces_settings;
do_action( 'usces_action_before_delivery_check' );
$mes = '';
if ( isset( $_POST['delivery']['delivery_flag'] ) && 1 === (int) $_POST['delivery']['delivery_flag'] ) {
if ( WCUtils::is_blank( $_POST['delivery']['name1'] ) ) {
$mes .= __( 'Name is not correct', 'usces' ) . '
';
}
$zip_check = false;
$addressform = $this->options['system']['addressform'];
$applyform = usces_get_apply_addressform( $addressform );
if ( 'JP' === $applyform ) {
if ( isset( $_POST['delivery']['country'] ) ) {
if ( 'JP' === $_POST['delivery']['country'] ) {
$zip_check = true;
}
} else {
$base = usces_get_base_country();
if ( 'JP' === $base ) {
$zip_check = true;
}
}
}
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
if ( WCUtils::is_blank( $_POST['delivery']['zipcode'] ) ) {
if ( usces_is_required_field( 'zipcode' ) ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
} else {
if ( $zip_check ) {
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['delivery']['zipcode'] ) ) {
$_SESSION['usces_entry']['delivery']['zipcode'] = usces_convert_zipcode( $_POST['delivery']['zipcode'] );
}
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['delivery']['zipcode'] ) ) {
$mes .= __( 'postal code is not correct', 'usces' ) . '
';
}
}
}
if ( ( __( '-- Select --', 'usces' ) == $_POST['delivery']['pref'] || '-- Select --' == $_POST['delivery']['pref'] ) && usces_is_required_field( 'states' ) ) {
$mes .= __( 'enter the prefecture', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['delivery']['address1'] ) && usces_is_required_field( 'address1' ) ) {
$mes .= __( 'enter the city name', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['delivery']['address2'] ) && usces_is_required_field( 'address2' ) ) {
$mes .= __( 'enter house numbers', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $_POST['delivery']['tel'] ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'enter phone numbers', 'usces' ) . '
';
}
if ( ! WCUtils::is_blank( $_POST['delivery']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['delivery']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '
';
}
$post_offer = filter_input( INPUT_POST, 'offer', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
if ( ! empty( $post_offer['delivery_date'] ) && usces_is_date( $post_offer['delivery_date'] ) && isset( $post_offer['delivery_method'] ) ) {
$post_delivery = filter_input( INPUT_POST, 'delivery', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
$deli_method_index = $this->get_delivery_method_index( $post_offer['delivery_method'] );
$delivery_days_id = isset( $this->options['delivery_method'][ $deli_method_index ]['days'] ) ? $this->options['delivery_method'][ $deli_method_index ]['days'] : -1;
if ( 0 <= $delivery_days_id ) {
$delivery_days_list = $this->options['delivery_days'];
$delivery_days = 0;
foreach ( (array) $delivery_days_list as $delivery_days_value ) {
if ( (int) $delivery_days_value['id'] === (int) $delivery_days_id ) {
$delivery_days = (int) $delivery_days_value[ $applyform ][ $post_delivery['pref'] ];
}
}
$sendout = usces_get_send_out_date();
$sendout_date = implode( '-', $sendout['sendout_date'] );
$arrival_date = new DateTime( $sendout_date );
$arrival_date->modify( '+' . $delivery_days . ' days' );
$offer_deli_date = new DateTime( $post_offer['delivery_date'] );
if ( $offer_deli_date < $arrival_date ) {
$mes .= __( 'Please re-specify the desired arrival date.', 'usces' ) . '
';
}
} else {
$mes .= __( 'Please re-specify the desired arrival date.', 'usces' ) . '
';
}
}
}
if ( ! isset( $_POST['offer']['delivery_method'] ) || ( empty( $_POST['offer']['delivery_method'] ) && ! WCUtils::is_zero( $_POST['offer']['delivery_method'] ) ) ) {
$mes .= __( 'chose one from delivery method.', 'usces' ) . '
';
} else {
$d_method_index = $this->get_delivery_method_index( (int) $_POST['offer']['delivery_method'] );
if ( 0 > $d_method_index ) {
$mes .= __( 'chose one from delivery method.', 'usces' ) . '
';
} elseif ( isset( $_SESSION['usces_entry']['delivery']['country'] ) ) {
$country = $_SESSION['usces_entry']['delivery']['country'];
$current_locate = get_locale();
$wplang = get_option( 'WPLANG', $current_locate );
$local_country = $usces_settings['lungage2country'][ $wplang ];
if ( $country == $local_country ) {
if ( 1 == $this->options['delivery_method'][ $d_method_index ]['intl'] ) {
$mes .= __( 'Delivery method is incorrect. Can not specify an international flight.', 'usces' ) . '
';
}
} else {
if ( WCUtils::is_zero( $this->options['delivery_method'][ $d_method_index ]['intl'] ) ) {
$mes .= __( 'Delivery method is incorrect. Specify the international flights.', 'usces' ) . '
';
}
}
}
}
if ( ! isset( $_POST['offer']['payment_name'] ) ) {
$mes .= __( 'chose one from payment options.', 'usces' ) . '
';
} else {
$payments = $this->getPayments( $_POST['offer']['payment_name'] );
if ( 'COD' == $payments['settlement'] ) {
$total_items_price = $this->get_total_price();
$usces_entries = $this->cart->get_entry();
$materials = array(
'total_items_price' => $usces_entries['order']['total_items_price'],
'discount' => ( isset( $usces_entries['order']['discount'] ) ) ? $usces_entries['order']['discount'] : 0,
'shipping_charge' => $usces_entries['order']['shipping_charge'],
'cod_fee' => $usces_entries['order']['cod_fee'],
'use_point' => ( isset( $usces_entries['order']['use_point'] ) ) ? $usces_entries['order']['use_point'] : 0,
);
$tax = $this->getTax( $total_items_price, $materials );
$total_items_price = $total_items_price + $tax;
$cod_limit_amount = ( isset( $this->options['cod_limit_amount'] ) && 0 < (int) $this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
if ( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount ) {
$mes .= sprintf( __( 'A total products amount of money surpasses the upper limit(%s) that I can purchase in C.O.D.', 'usces' ), usces_crform( $this->options['cod_limit_amount'], true, false, 'return' ) ) . '
';
}
}
}
if ( isset( $d_method_index ) && isset( $payments ) ) {
if ( 1 == $this->options['delivery_method'][ $d_method_index ]['nocod'] ) {
if ( 'COD' == $payments['settlement'] ) {
$mes .= __( 'COD is not available.', 'usces' ) . '
';
}
}
}
$mes = apply_filters( 'usces_filter_delivery_check', $mes );
return $mes;
}
public function point_check( $entries ) {
$member = $this->get_member();
$this->set_cart_fees( $member, $entries );
$mes = '';
if ( isset( $_POST['offer']['usedpoint'] ) ) {
if ( WCUtils::is_blank( $_POST['offer']['usedpoint'] ) || ! preg_match( '/^[0-9]+$/', $_POST['offer']['usedpoint'] ) || (int) $_POST['offer']['usedpoint'] < 0 ) {
$mes .= __( 'Invalid value. Please enter in the numbers.', 'usces' ) . '
';
} else {
$payments = $this->getPayments( $entries['order']['payment_name'] );
$usedpoint = (int) trim( $_POST['offer']['usedpoint'] );
if ( $usedpoint > $member['point'] ) {
$mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $member['point'] . ' ' . __( 'points', 'usces' ) . '
';
} elseif ( 'acting_paypal_ec' == $payments['settlement'] ) {
$target_full_price = $entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'] + $entries['order']['tax'];
$target_item_price = $entries['order']['total_items_price'] + $entries['order']['discount'];
if ( 1 == $this->options['point_coverage'] && $usedpoint >= $target_full_price ) {
$target_item_price = $target_full_price;
} elseif ( 'products' == $this->options['tax_target'] ) {
$target_item_price += $entries['order']['tax'];
}
if ( $usedpoint > $target_item_price ) {
$mes .= __( "In the case of settlement method you choose, the upper limit of the point you'll find that will change. If you became a settlement error, please reduce the point that you want to use.", 'usces' ) . '
';
}
} else {
if ( 1 == $this->options['point_coverage'] ) {
$target_full_price = $entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'] + $entries['order']['tax'];
if ( $usedpoint > $target_full_price ) {
$mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $target_full_price . ' ' . __( 'points', 'usces' ) . '
';
}
} else {
$target_item_price = $entries['order']['total_items_price'] + $entries['order']['discount'];
if ( 'products' == $this->options['tax_target'] ) {
$target_item_price += $entries['order']['tax'];
}
if ( $usedpoint > $target_item_price ) {
$mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $target_item_price . ' ' . __( 'points', 'usces' ) . '
';
}
}
}
$mes = apply_filters( 'usces_filter_point_check', $mes );
if ( '' != $mes ) {
$_POST['offer']['usedpoint'] = 0;
$array = array(
'usedpoint' => 0,
);
$this->cart->set_order_entry( $array );
}
}
}
$mes = apply_filters( 'usces_filter_point_check_last', $mes );
return $mes;
}
public function lostpass_mailaddcheck() {
$mes = '';
if ( ! is_email( $_POST['loginmail'] ) || WCUtils::is_blank( $_POST['loginmail'] ) ) {
$mes .= __( 'e-mail address is not correct', 'usces' ) . '
';
}
return $mes;
}
public function changepass_check() {
$mes = $this->get_pwd_errors( $_POST['loginpass1'] );
if ( trim( $_POST['loginpass1'] ) != trim( $_POST['loginpass2'] ) ) {
$mes .= __( 'Password confirm does not match.', 'usces' ) . '
';
}
return $mes;
}
public function get_page() {
return $this->page;
}
public function check_display_mode() {
$options = get_option( 'usces' );
if ( isset( $options['display_mode'] ) && 'Maintenancemode' == $options['display_mode'] ) {
return;
}
$start['hour'] = empty( $options['campaign_schedule']['start']['hour'] ) ? 0 : $options['campaign_schedule']['start']['hour'];
$start['min'] = empty( $options['campaign_schedule']['start']['min'] ) ? 0 : $options['campaign_schedule']['start']['min'];
$start['month'] = empty( $options['campaign_schedule']['start']['month'] ) ? 0 : $options['campaign_schedule']['start']['month'];
$start['day'] = empty( $options['campaign_schedule']['start']['day'] ) ? 0 : $options['campaign_schedule']['start']['day'];
$start['year'] = empty( $options['campaign_schedule']['start']['year'] ) ? 0 : $options['campaign_schedule']['start']['year'];
$end['hour'] = empty( $options['campaign_schedule']['end']['hour'] ) ? 0 : $options['campaign_schedule']['end']['hour'];
$end['min'] = empty( $options['campaign_schedule']['end']['min'] ) ? 0 : $options['campaign_schedule']['end']['min'];
$end['month'] = empty( $options['campaign_schedule']['end']['month'] ) ? 0 : $options['campaign_schedule']['end']['month'];
$end['day'] = empty( $options['campaign_schedule']['end']['day'] ) ? 0 : $options['campaign_schedule']['end']['day'];
$end['year'] = empty( $options['campaign_schedule']['end']['year'] ) ? 0 : $options['campaign_schedule']['end']['year'];
$starttime = mktime( $start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year'] );
$endtime = mktime( $end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year'] );
$current_time = current_time( 'timestamp' );
if ( ( $current_time >= $starttime ) && ( $current_time <= $endtime ) ) {
$options['display_mode'] = 'Promotionsale';
} else {
$options['display_mode'] = 'Usualsale';
}
update_option( 'usces', $options );
}
public function update_business_days() {
$options = get_option( 'usces' );
$datetimestr = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) );
$dhour = (int) substr( $datetimestr, 11, 2 );
$dminute = (int) substr( $datetimestr, 14, 2 );
$dsecond = (int) substr( $datetimestr, 17, 2 );
$dmonth = (int) substr( $datetimestr, 5, 2 );
$dday = (int) substr( $datetimestr, 8, 2 );
$dyear = (int) substr( $datetimestr, 0, 4 );
$dtimestamp = mktime( $dhour, $dminute, $dsecond, $dmonth, $dday, $dyear );
$datenow = getdate( $dtimestamp );
list( $year, $mon, $mday ) = getBeforeMonth( $datenow['year'], $datenow['mon'], 1, 1 );
if ( isset( $options['business_days'][ $year ][ $mon ][1] ) ) {
unset( $options['business_days'][ $year ][ $mon ] );
}
for ( $i = 0; $i < 12; $i++ ) {
list( $year, $mon, $mday ) = getAfterMonth( $datenow['year'], $datenow['mon'], 1, $i );
$last = getLastDay( $year, $mon );
for ( $j = 1; $j <= $last; $j++ ) {
if ( ! isset( $options['business_days'][ $year ][ $mon ][ $j ] ) ) {
$options['business_days'][ $year ][ $mon ][ $j ] = 1;
}
}
}
update_option( 'usces', $options );
$this->options = get_option( 'usces' );
$_SESSION['usces_checked_business_days'] = '';
}
public function display_cart() {
if ( $this->cart->num_row() > 0 ) {
// include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
} else {
echo "
' . __( 'Member Services is not running currently.', 'usces' ) . '
'; } $content = $html; remove_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 ); return $content; } public function filter_memberTitle( $title ) { if ( is_admin() ) { return $title; } if ( 'activate' == $this->options['membersystem_state'] && $this->is_member_page( $_SERVER['REQUEST_URI'] ) ) { switch ( $this->page ) { case 'login': $newtitle = apply_filters( 'usces_filter_title_login', __( 'Log-in for members', 'usces' ) ); break; case 'newmemberform': $newtitle = apply_filters( 'usces_filter_title_newmemberform', __( 'New enrollment form', 'usces' ) ); break; case 'lostmemberpassword': $newtitle = apply_filters( 'usces_filter_title_lostmemberpassword', __( 'The new password acquisition', 'usces' ) ); break; case 'changepassword': $newtitle = apply_filters( 'usces_filter_title_changepassword', __( 'Change password', 'usces' ) ); break; case 'newcompletion': case 'editcompletion': case 'lostcompletion': case 'changepasscompletion': $newtitle = apply_filters( 'usces_filter_title_changepasscompletion', __( 'Completion', 'usces' ) ); break; case 'memberverifying': $newtitle = apply_filters( 'usces_filter_title_memberverifying', __( 'Verifying', 'usces' ) ); break; case 'error': $newtitle = apply_filters( 'usces_filter_title_membererror', __( 'Error', 'usces' ) ); break; default: $newtitle = apply_filters( 'usces_filter_title_member_default', $title ); } } else { $newtitle = $title; } $newtitle = apply_filters( 'usces_filter_memberTitle', $newtitle ); return $newtitle; } public function action_memberFilter() { add_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 ); add_filter( 'the_content', array( $this, 'filter_memberContent' ), 20 ); } public function filter_usces_cart_css() { $path = get_stylesheet_directory_uri() . '/usces_cart.css'; return $path; } public function filter_divide_item() { global $wp_query; if ( ( $this->options['divide_item'] && ! is_category() && ! is_search() && ! is_singular() && ! is_admin() ) ) { $ids = $this->getItemIds( 'front' ); if ( isset( $wp_query->query_vars['post__not_in'] ) ) { $wp_query->query_vars['post__not_in'] = $ids; } } if ( is_admin() ) { $ids = $this->getItemIds( 'back' ); if ( isset( $wp_query->query_vars['post__not_in'] ) ) { $wp_query->query_vars['post__not_in'] = $ids; } } do_action( 'usces_action_divide_item' ); } public function load_upload_template() { $post_id = $_POST['post_id']; $file = 'upload_template01.php'; include get_template_directory() . '/' . $file; exit; } public function filter_itemimg_anchor_rel( $html ) { if ( is_single() ) { $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"'; } else { $str = ''; } return $html . $str; } public function filter_permalink( $link ) { if ( false !== strpos( '?page_id=4', $link ) || false !== strpos( '?page_id=3', $link ) || false !== strpos( 'usces-cart', $link ) || false !== strpos( 'usces-member', $link ) ) { $link = str_replace( 'http://', 'https://', $link ); } return $link; } public function filter_cart_page_header( $html ) { if ( ! empty( $this->options['cart_page_data']['header']['cart'] ) ) { $html = $this->options['cart_page_data']['header']['cart']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_cart_page_footer( $html ) { if ( ! empty( $this->options['cart_page_data']['footer']['cart'] ) ) { $html = $this->options['cart_page_data']['footer']['cart']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_customer_page_header( $html ) { if ( ! empty( $this->options['cart_page_data']['header']['customer'] ) ) { $html = $this->options['cart_page_data']['header']['customer']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_customer_page_footer( $html ) { if ( ! empty( $this->options['cart_page_data']['footer']['customer'] ) ) { $html = $this->options['cart_page_data']['footer']['customer']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_delivery_page_header( $html ) { if ( ! empty( $this->options['cart_page_data']['header']['delivery'] ) ) { $html = $this->options['cart_page_data']['header']['delivery']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_delivery_page_footer( $html ) { if ( ! empty( $this->options['cart_page_data']['footer']['delivery'] ) ) { $html = $this->options['cart_page_data']['footer']['delivery']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_confirm_page_header( $html ) { if ( ! empty( $this->options['cart_page_data']['header']['confirm'] ) ) { $html = $this->options['cart_page_data']['header']['confirm']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_confirm_page_footer( $html ) { if ( ! empty( $this->options['cart_page_data']['footer']['confirm'] ) ) { $html = $this->options['cart_page_data']['footer']['confirm']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_cartcompletion_page_header( $html ) { if ( ! empty( $this->options['cart_page_data']['header']['completion'] ) ) { $html = $this->options['cart_page_data']['header']['completion']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_cartcompletion_page_footer( $html ) { if ( ! empty( $this->options['cart_page_data']['footer']['completion'] ) ) { $html = $this->options['cart_page_data']['footer']['completion']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_login_page_header( $html ) { if ( ! empty( $this->options['member_page_data']['header']['login'] ) ) { $html = $this->options['member_page_data']['header']['login']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_login_page_footer( $html ) { if ( ! empty( $this->options['member_page_data']['footer']['login'] ) ) { $html = $this->options['member_page_data']['footer']['login']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_newmember_page_header( $html ) { if ( ! empty( $this->options['member_page_data']['header']['newmember'] ) ) { $html = $this->options['member_page_data']['header']['newmember']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_newmember_page_footer( $html ) { if ( ! empty( $this->options['member_page_data']['footer']['newmember'] ) ) { $html = $this->options['member_page_data']['footer']['newmember']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_newpass_page_header( $html ) { if ( ! empty( $this->options['member_page_data']['header']['newpass'] ) ) { $html = $this->options['member_page_data']['header']['newpass']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_newpass_page_footer( $html ) { if ( ! empty( $this->options['member_page_data']['footer']['newpass'] ) ) { $html = $this->options['member_page_data']['footer']['newpass']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_changepass_page_header( $html ) { if ( ! empty( $this->options['member_page_data']['header']['changepass'] ) ) { $html = $this->options['member_page_data']['header']['changepass']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_changepass_page_footer( $html ) { if ( ! empty( $this->options['member_page_data']['footer']['changepass'] ) ) { $html = $this->options['member_page_data']['footer']['changepass']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_memberinfo_page_header( $html ) { if ( ! empty( $this->options['member_page_data']['header']['memberinfo'] ) ) { $html = $this->options['member_page_data']['header']['memberinfo']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_memberinfo_page_footer( $html ) { if ( ! empty( $this->options['member_page_data']['footer']['memberinfo'] ) ) { $html = $this->options['member_page_data']['footer']['memberinfo']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_membercompletion_page_header( $html ) { if ( ! empty( $this->options['member_page_data']['header']['completion'] ) ) { $html = $this->options['member_page_data']['header']['completion']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function filter_membercompletion_page_footer( $html ) { if ( ! empty( $this->options['member_page_data']['footer']['completion'] ) ) { $html = $this->options['member_page_data']['footer']['completion']; } return do_shortcode( stripslashes( nl2br( $html ) ) ); } public function action_cart_page_header() { if ( ! empty( $this->options['cart_page_data']['header']['cart'] ) ) { $html = $this->options['cart_page_data']['header']['cart']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_cart_page_footer() { if ( ! empty( $this->options['cart_page_data']['footer']['cart'] ) ) { $html = $this->options['cart_page_data']['footer']['cart']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_customer_page_header() { if ( ! empty( $this->options['cart_page_data']['header']['customer'] ) ) { $html = $this->options['cart_page_data']['header']['customer']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_customer_page_footer() { if ( ! empty( $this->options['cart_page_data']['footer']['customer'] ) ) { $html = $this->options['cart_page_data']['footer']['customer']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_delivery_page_header() { if ( ! empty( $this->options['cart_page_data']['header']['delivery'] ) ) { $html = $this->options['cart_page_data']['header']['delivery']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_delivery_page_footer() { if ( ! empty( $this->options['cart_page_data']['footer']['delivery'] ) ) { $html = $this->options['cart_page_data']['footer']['delivery']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_confirm_page_header() { if ( ! empty( $this->options['cart_page_data']['header']['confirm'] ) ) { $html = $this->options['cart_page_data']['header']['confirm']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_confirm_page_footer() { if ( ! empty( $this->options['cart_page_data']['footer']['confirm'] ) ) { $html = $this->options['cart_page_data']['footer']['confirm']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_cartcompletion_page_header() { if ( ! empty( $this->options['cart_page_data']['header']['completion'] ) ) { $html = $this->options['cart_page_data']['header']['completion']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_cartcompletion_page_footer() { if ( ! empty( $this->options['cart_page_data']['footer']['completion'] ) ) { $html = $this->options['cart_page_data']['footer']['completion']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_login_page_header() { if ( ! empty( $this->options['member_page_data']['header']['login'] ) ) { $html = $this->options['member_page_data']['header']['login']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_login_page_footer() { if ( ! empty( $this->options['member_page_data']['footer']['login'] ) ) { $html = $this->options['member_page_data']['footer']['login']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_newmember_page_header() { if ( ! empty( $this->options['member_page_data']['header']['newmember'] ) ) { $html = $this->options['member_page_data']['header']['newmember']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_newmember_page_footer() { if ( ! empty( $this->options['member_page_data']['footer']['newmember'] ) ) { $html = $this->options['member_page_data']['footer']['newmember']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_newpass_page_header() { if ( ! empty( $this->options['member_page_data']['header']['newpass'] ) ) { $html = $this->options['member_page_data']['header']['newpass']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_newpass_page_footer() { if ( ! empty( $this->options['member_page_data']['footer']['newpass'] ) ) { $html = $this->options['member_page_data']['footer']['newpass']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_changepass_page_header() { if ( ! empty( $this->options['member_page_data']['header']['changepass'] ) ) { $html = $this->options['member_page_data']['header']['changepass']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_changepass_page_footer() { if ( ! empty( $this->options['member_page_data']['footer']['changepass'] ) ) { $html = $this->options['member_page_data']['footer']['changepass']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_memberinfo_page_header() { if ( ! empty( $this->options['member_page_data']['header']['memberinfo'] ) ) { $html = $this->options['member_page_data']['header']['memberinfo']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_memberinfo_page_footer() { if ( ! empty( $this->options['member_page_data']['footer']['memberinfo'] ) ) { $html = $this->options['member_page_data']['footer']['memberinfo']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_membercompletion_page_header() { if ( ! empty( $this->options['member_page_data']['header']['completion'] ) ) { $html = $this->options['member_page_data']['header']['completion']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function action_membercompletion_page_footer() { if ( ! empty( $this->options['member_page_data']['footer']['completion'] ) ) { $html = $this->options['member_page_data']['footer']['completion']; echo do_shortcode( stripslashes( nl2br( $html ) ) ); } } public function filter_confirm_page_notes( $html ) { if ( ! empty( $this->options['cart_page_data']['confirm_notes'] ) ) { $html = '