PluginProbe
Welcart e-Commerce / 1.4.1
Welcart e-Commerce v1.4.1
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / classes / usceshop.class.php

usceshop.class.php in Welcart e-Commerce 1.4.1, at classes/usceshop.class.php

8,697 lines 342.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class usc_e_shop
3 {
4
5 var $page; //page action
6 var $cart; //cart object
7 var $use_ssl; //ssl flag
8 var $action, $action_status, $error_status;
9 var $action_message, $error_message;
10 var $itemskus, $itemsku, $itemopts, $itemopt, $item;
11 var $zaiko_status, $payment_structure, $display_mode, $shipping_rule;
12 var $member_status;
13 var $options, $mail_para;
14 var $login_mail, $current_member, $member_form;
15 var $payment_results, $log_flg, $delim, $use_js;
16 var $user_level;
17
18 function usc_e_shop()
19 {
20 global $wpdb, $post, $usces_settings, $usces_states;
21
22 usces_add_role();
23
24 do_action('usces_construct');
25 add_action('after_setup_theme', array(&$this, 'usces_session_start'));
26
27 if ( is_admin() ){
28 clean_term_cache( get_option('usces_item_cat_parent_id'), 'category' );
29 }
30
31 $locales = usces_locales();
32 foreach($locales as $l){
33 $usces_settings['language'][$l] = $l;
34 }
35 $usces_settings['language']['others'] = __('Follow config.php', 'usces');
36
37 $this->options = get_option('usces');
38 if(!isset($this->options['smtp_hostname']) || empty($this->options['smtp_hostname'])){ $this->options['smtp_hostname'] = 'localhost';}
39 if(!isset($this->options['delivery_method']) || !is_array($this->options['delivery_method'])) $this->options['delivery_method'] = array();
40 if(!isset($this->options['shipping_charge']) || !is_array($this->options['shipping_charge'])) $this->options['shipping_charge'] = array();
41 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
42 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = 'activate';
43 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
44 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 0;
45 if(!isset($this->options['use_javascript'])) $this->options['use_javascript'] = 1;
46 if(!isset($this->options['privilege_discount'])) $this->options['privilege_discount'] = '';
47 if(!isset($this->options['privilege_point'])) $this->options['privilege_point'] = '';
48 if(!isset($this->options['campaign_privilege'])) $this->options['campaign_privilege'] = '';
49 if(!isset($this->options['campaign_category'])) $this->options['campaign_category'] = 0;
50 if(!isset($this->options['campaign_schedule']['start'])) $this->options['campaign_schedule']['start'] = array();
51 if(!isset($this->options['campaign_schedule']['end'])) $this->options['campaign_schedule']['end'] = array();
52 if(!isset($this->options['acting_settings']['paypal']['ec_activate'])) $this->options['acting_settings']['paypal']['ec_activate'] = '';
53 if(!isset($this->options['purchase_limit'])) $this->options['purchase_limit'] = '';
54 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
55 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
56 if(!isset($this->options['company_name'])) $this->options['company_name'] = '';
57 if(!isset($this->options['address1'])) $this->options['address1'] = '';
58 if(!isset($this->options['address2'])) $this->options['address2'] = '';
59 if(!isset($this->options['zip_code'])) $this->options['zip_code'] = '';
60 if(!isset($this->options['tel_number'])) $this->options['tel_number'] = '';
61 if(!isset($this->options['fax_number'])) $this->options['fax_number'] = '';
62 if(!isset($this->options['order_mail'])) $this->options['order_mail'] = '';
63 if(!isset($this->options['inquiry_mail'])) $this->options['inquiry_mail'] = '';
64 if(!isset($this->options['sender_mail'])) $this->options['sender_mail'] = '';
65 if(!isset($this->options['error_mail'])) $this->options['error_mail'] = '';
66 if(!isset($this->options['copyright'])) $this->options['copyright'] = '';
67 if(!isset($this->options['postage_privilege'])) $this->options['postage_privilege'] = '';
68 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
69 if(!isset($this->options['tax_rate'])){
70 $this->options['tax_rate'] = '';
71 $this->options['tax_method'] = 'cutting';
72 $this->options['tax_mode'] = 'include';
73 $this->options['tax_target'] = 'products';
74 }
75 if(!isset($this->options['transferee'])) $this->options['transferee'] = '';
76 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
77 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = '';
78 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
79 if(!isset($this->options['start_point'])) $this->options['start_point'] = '';
80 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 1;
81 if(!isset($this->options['point_assign'])) $this->options['point_assign'] = 1;//20120919ysk 0000573
82 if(!isset($this->options['cod_type'])) $this->options['cod_type'] = 'fix';
83 if(!isset($this->options['newmem_admin_mail'])) $this->options['newmem_admin_mail'] = 0;
84 if(!isset($this->options['delmem_admin_mail'])) $this->options['delmem_admin_mail'] = 1;
85 if(!isset($this->options['delmem_customer_mail'])) $this->options['delmem_customer_mail'] = 1;
86 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'=>'');
87 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'=>'');
88 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'=>'');
89 if(!isset($this->options['cart_page_data']['header'])) $this->options['cart_page_data']['header'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
90 if(!isset($this->options['cart_page_data']['footer'])) $this->options['cart_page_data']['footer'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
91 if(!isset($this->options['member_page_data']['header'])) $this->options['member_page_data']['header'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
92 if(!isset($this->options['member_page_data']['footer'])) $this->options['member_page_data']['footer'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
93
94 if(!isset($this->options['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = '0';
95 if(!isset($this->options['delivery_after_days'])) $this->options['delivery_after_days'] = 15;
96 if(!isset($this->options['delivery_days'])) $this->options['delivery_days'] = array();
97 if(!isset($this->options['delivery_time_limit']['hour'])) $this->options['delivery_time_limit']['hour'] = '00';
98 if(!isset($this->options['delivery_time_limit']['min'])) $this->options['delivery_time_limit']['min'] = '00';
99
100 if(!isset($this->options['divide_item'])) $this->options['divide_item'] = 0;
101 if(!isset($this->options['itemimg_anchor_rel'])) $this->options['itemimg_anchor_rel'] = '';
102 if(!isset($this->options['fukugo_category_orderby'])) $this->options['fukugo_category_orderby'] = 'ID';
103 if(!isset($this->options['fukugo_category_order'])) $this->options['fukugo_category_order'] = 'ASC';
104 if(!isset($this->options['settlement_path'])) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
105 if(!isset($this->options['logs_path'])) $this->options['logs_path'] = '';
106 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
107 if(!isset($this->options['ssl_url'])) $this->options['ssl_url'] = '';
108 if(!isset($this->options['ssl_url_admin'])) $this->options['ssl_url_admin'] = '';
109 if(!isset($this->options['inquiry_id'])) $this->options['inquiry_id'] = '';
110 if(!isset($this->options['system']['orderby_itemsku'])) $this->options['system']['orderby_itemsku'] = 0;
111 if(!isset($this->options['system']['orderby_itemopt'])) $this->options['system']['orderby_itemopt'] = 0;
112 if(!isset($this->options['system']['front_lang'])) $this->options['system']['front_lang'] = usces_get_local_language();
113 if(!isset($this->options['system']['currency'])) $this->options['system']['currency'] = usces_get_base_country();
114 if(!isset($this->options['system']['addressform'])) $this->options['system']['addressform'] = usces_get_local_addressform();
115 if(!isset($this->options['system']['target_market'])) $this->options['system']['target_market'] = usces_get_local_target_market();
116 if(!isset($this->options['system']['no_cart_css'])) $this->options['system']['no_cart_css'] = 0;
117 if(!isset($this->options['system']['dec_orderID_flag'])) $this->options['system']['dec_orderID_flag'] = 0;
118 if(!isset($this->options['system']['dec_orderID_prefix'])) $this->options['system']['dec_orderID_prefix'] = '';
119 if(!isset($this->options['system']['dec_orderID_digit'])) $this->options['system']['dec_orderID_digit'] = 8;
120 if(!isset($this->options['system']['subimage_rule'])) $this->options['system']['subimage_rule'] = 1;
121 if(!isset($this->options['system']['pdf_delivery'])) $this->options['system']['pdf_delivery'] = 0;
122 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;
123 if(!isset($this->options['system']['member_pass_rule_max']) || empty($this->options['system']['member_pass_rule_max'])) $this->options['system']['member_pass_rule_max'] = '';
124 if(!isset($this->options['system']['csv_encode_type'])) $this->options['system']['csv_encode_type'] = 0;
125 if(!isset($this->options['acting_settings']['zeus'])) $this->options['acting_settings']['zeus'] = array('activate'=>'','card_activate'=>'','clientip'=>'','authkey'=>'','connection'=>'','3dsecure'=>'','security'=>'','quickcharge'=>'', 'howpay'=>'','bank_activate'=>'','clientip_bank'=>'','testid_bank'=>'','conv_activate'=>'','clientip_conv'=>'','testid_conv'=>'','test_type_conv'=>'');
126 if(!isset($this->options['acting_settings']['zeus']['connection'])) $this->options['acting_settings']['zeus']['connection'] = '1';
127 if(!isset($this->options['acting_settings']['zeus']['3dsecur'])) $this->options['acting_settings']['zeus']['3dsecur'] = '2';
128 if(!isset($this->options['acting_settings']['zeus']['security'])) $this->options['acting_settings']['zeus']['security'] = '2';
129 if(!isset($this->options['acting_settings']['remise'])) $this->options['acting_settings']['remise'] = array('activate'=>'','plan'=>'','SHOPCO'=>'','HOSTID'=>'','card_activate'=>'','card_jb'=>'', 'payquick'=>'','howpay'=>'','continuation'=>'','card_pc_ope'=>'','send_url_pc'=>'','conv_activate'=>'','S_PAYDATE'=>'','conv_pc_ope'=>'','send_url_cvs_pc'=>'');
130 if(!isset($this->options['acting_settings']['jpayment'])) $this->options['acting_settings']['jpayment'] = array('activate'=>'','aid'=>'','card_activate'=>'','card_jb'=>'','conv_activate'=>'','webm_activate'=>'', 'bitc_activate'=>'','suica_activate'=>'','bank_activate'=>'');
131 if(!isset($this->options['acting_settings']['paypal'])) $this->options['acting_settings']['paypal'] = array('activate'=>'','ec_activate'=>'','sandbox'=>'','user'=>'','pwd'=>'','signature'=>'', 'continuation'=>'');
132
133 //20010420ysk start
134 //if(!isset($this->options['system']['base_country'])) $this->options['system']['base_country'] = usces_get_base_country();
135 $this->options['system']['base_country'] = usces_get_base_country();
136 //20010420ysk end
137 //20110331ysk start
138 if(!isset($this->options['province'])) $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
139 //20110331ysk end
140 if(!isset($this->options['system']['pointreduction'])) $this->options['system']['pointreduction'] = usces_get_pointreduction($this->options['system']['currency']);
141 if(!isset($this->options['indi_item_name'])){
142 $this->options['indi_item_name']['item_name'] = 1;
143 $this->options['indi_item_name']['item_code'] = 1;
144 $this->options['indi_item_name']['sku_name'] = 1;
145 $this->options['indi_item_name']['sku_code'] = 1;
146 $this->options['pos_item_name']['item_name'] = 1;
147 $this->options['pos_item_name']['item_code'] = 2;
148 $this->options['pos_item_name']['sku_name'] = 3;
149 $this->options['pos_item_name']['sku_code'] = 4;
150 }
151 update_option('usces', $this->options);
152
153 $this->check_display_mode();
154 $this->error_message = '';
155 $this->login_mail = '';
156 $this->get_current_member();
157 $this->page = '';
158 $this->payment_results = array();
159 $this->use_js = $this->options['use_javascript'];
160
161 //admin_ssl options
162 // $this->use_ssl = get_option("admin_ssl_use_ssl") === "1" ? true : false;
163 // $use_shared = get_option("admin_ssl_use_shared") === "1" && $this->use_ssl ? true : false;
164 // $shared_url = get_option("admin_ssl_shared_url");
165
166 $this->use_ssl = $this->options['use_ssl'];
167 // if ( $use_shared ) {
168 // $ssl_url = str_replace('/wp-admin/', '', $shared_url);
169 // } else {
170 // $ssl_url = str_replace('http://', 'https://', get_option('home'));
171 // }
172 define('USCES_CART_NUMBER', get_option('usces_cart_number'));
173 define('USCES_MEMBER_NUMBER', get_option('usces_member_number'));
174
175 if ( $this->use_ssl ) {
176 $ssl_url = $this->options['ssl_url'];
177 $ssl_url_admin = $this->options['ssl_url_admin'];
178 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
179 define('USCES_FRONT_PLUGIN_URL', $ssl_url_admin . '/wp-content/plugins/' . USCES_PLUGIN_FOLDER);
180 define('USCES_COOKIEPATH', preg_replace('|https?://[^/]+|i', '', $ssl_url . '/' ) );
181 }else{
182 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
183 define('USCES_COOKIEPATH', COOKIEPATH);
184 }
185 define('USCES_SSL_URL', $ssl_url);
186 define('USCES_SSL_URL_ADMIN', $ssl_url_admin);
187 }else{
188 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
189 define('USCES_SSL_URL', get_option('home'));
190 define('USCES_SSL_URL_ADMIN', site_url());
191 define('USCES_COOKIEPATH', COOKIEPATH);
192 }
193 // if($this->use_ssl) {
194 // define('USCES_CART_URL', $ssl_url . '/?page_id=' . USCES_CART_NUMBER . '&usces=' . $this->get_uscesid());
195 // define('USCES_MEMBER_URL', $ssl_url . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces=' . $this->get_uscesid());
196 // define('USCES_INQUIRY_URL', $ssl_url . '/?page_id=' . $this->options['inquiry_id'] . '&usces=' . $this->get_uscesid());
197 // add_filter('home_url', array($this, 'usces_ssl_page_link'));
198 // add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
199 // add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
200 // add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
201 // add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
202 // add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
203 // } else {
204 // define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
205 // define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
206 // define('USCES_INQUIRY_URL', get_option('home') . '/?page_id=' . $this->options['inquiry_id']);
207 // }
208 define('USCES_ITEM_CAT_PARENT_ID', get_option('usces_item_cat_parent_id'));
209
210 $this->zaiko_status = get_option('usces_zaiko_status');
211 $this->member_status = get_option('usces_customer_status');
212 $this->payment_structure = get_option('usces_payment_structure');
213 $this->display_mode = get_option('usces_display_mode');
214 define('USCES_MYSQL_VERSION', $wpdb->db_version());
215 define('USCES_JP', ('ja' === get_locale() ? true : false));
216
217 }
218
219 function get_default_post_to_edit30( $post_type = 'post', $create_in_db = false ) {
220 global $wpdb;
221
222 $post_title = '';
223 if ( !empty( $_REQUEST['post_title'] ) )
224 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
225
226 $post_content = '';
227 if ( !empty( $_REQUEST['content'] ) )
228 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
229
230 $post_excerpt = '';
231 if ( !empty( $_REQUEST['excerpt'] ) )
232 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
233
234 if ( $create_in_db ) {
235 // Cleanup old auto-drafts more than 7 days old
236 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
237 foreach ( (array) $old_posts as $delete )
238 wp_delete_post( $delete, true ); // Force delete
239 $post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) );
240 } else {
241 $post->ID = 0;
242 $post->post_author = '';
243 $post->post_date = '';
244 $post->post_date_gmt = '';
245 $post->post_password = '';
246 $post->post_type = $post_type;
247 $post->post_status = 'draft';
248 $post->to_ping = '';
249 $post->pinged = '';
250 $post->comment_status = get_option( 'default_comment_status' );
251 $post->ping_status = get_option( 'default_ping_status' );
252 $post->post_pingback = get_option( 'default_pingback_flag' );
253 $post->post_category = get_option( 'default_category' );
254 $post->page_template = 'default';
255 $post->post_parent = 0;
256 $post->menu_order = 0;
257 }
258
259 $post->post_content = apply_filters( 'default_content', $post_content, $post );
260 $post->post_title = apply_filters( 'default_title', $post_title, $post );
261 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
262 $post->post_name = '';
263
264 return $post;
265 }
266
267 function get_default_post_to_edit() {
268 global $post;
269
270 $post_title = '';
271 if ( !empty( $_REQUEST['post_title'] ) )
272 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
273
274 $post_content = '';
275 if ( !empty( $_REQUEST['content'] ) )
276 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
277
278 $post_excerpt = '';
279 if ( !empty( $_REQUEST['excerpt'] ) )
280 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
281
282 $post->ID = 0;
283 $post->post_name = '';
284 $post->post_author = '';
285 $post->post_date = '';
286 $post->post_date_gmt = '';
287 $post->post_password = '';
288 $post->post_status = 'draft';
289 $post->post_type = 'post';
290 $post->to_ping = '';
291 $post->pinged = '';
292 $post->comment_status = get_option( 'default_comment_status' );
293 $post->ping_status = get_option( 'default_ping_status' );
294 $post->post_pingback = get_option( 'default_pingback_flag' );
295 $post->post_category = get_option( 'default_category' );
296 $post->post_content = apply_filters( 'default_content', $post_content);
297 $post->post_title = apply_filters( 'default_title', $post_title );
298 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
299 $post->page_template = 'default';
300 $post->post_parent = 0;
301 $post->menu_order = 0;
302
303 return $post;
304 }
305 function is_cart_or_member_page($link)
306 {
307 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart', ('page_id='.USCES_MEMBER_NUMBER), '/usces-member');
308 $flag = false;
309 foreach($search as $value){
310 $parts = array();
311 if( false !== strpos($link, $value) ){
312 if( $value == ('page_id='.USCES_CART_NUMBER) || $value == ('page_id='.USCES_MEMBER_NUMBER) ){
313 $parts = parse_url($link);
314 parse_str($parts['query'], $query);
315 if( $query['page_id'] == USCES_CART_NUMBER || $query['page_id'] == USCES_MEMBER_NUMBER ){
316 $flag = true;
317 }
318 }else{
319 $flag = true;
320 }
321 }
322 }
323 return $flag;
324 }
325
326 function is_cart_page($link)
327 {
328 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart' );
329 $flag = false;
330 foreach($search as $value){
331 if( false !== strpos($link, $value) ){
332 if( $value == ('page_id='.USCES_CART_NUMBER) ){
333 $parts = parse_url($link);
334 parse_str($parts['query'], $query);
335 if( $query['page_id'] == USCES_CART_NUMBER ){
336 $flag = true;
337 }
338 }else{
339 $flag = true;
340 }
341 }
342 }
343 return $flag;
344 }
345
346 function is_member_page($link)
347 {
348 $search = array(('page_id='.USCES_MEMBER_NUMBER), '/usces-member' );
349 $flag = false;
350 foreach($search as $value){
351 if( false !== strpos($link, $value) ){
352 if( $value == ('page_id='.USCES_MEMBER_NUMBER) ){
353 $parts = parse_url($link);
354 parse_str($parts['query'], $query);
355 if( $query['page_id'] == USCES_MEMBER_NUMBER ){
356 $flag = true;
357 }
358 }else{
359 $flag = true;
360 }
361 }
362 }
363 return $flag;
364 }
365
366 function is_inquiry_page($link)
367 {
368 if( empty($this->options['inquiry_id']) )
369 return false;
370
371 $search = array(('page_id='.$this->options['inquiry_id']), '/usces-inquiry' );
372 $flag = false;
373 foreach($search as $value){
374 if( false !== strpos($link, $value) ){
375 if( $value == ('page_id='.$this->options['inquiry_id']) ){
376 $parts = parse_url($link);
377 parse_str($parts['query'], $query);
378 if( $query['page_id'] == $this->options['inquiry_id'] ){
379 $flag = true;
380 }
381 }else{
382 $flag = true;
383 }
384 }
385 }
386 return $flag;
387 }
388
389 function usces_ssl_page_link($link)
390 {
391 $parts = parse_url($link);
392
393 if( isset($parts['query']) ){
394 parse_str($parts['query'], $query);
395 }
396
397 if( false !== strpos($link, '/usces-cart') || (isset( $query['page_id']) && $query['page_id'] == USCES_CART_NUMBER) ){
398 $link = USCES_CART_URL;
399
400 }elseif( false !== strpos($link, '/usces-member') || (isset( $query['page_id']) && $query['page_id'] == USCES_MEMBER_NUMBER) ){
401 $link = USCES_MEMBER_URL;
402
403 }elseif( !empty($this->options['inquiry_id']) && (false !== strpos($link, '/usces-inquiry') || (isset( $query['page_id']) && $query['page_id'] == $this->options['inquiry_id'])) ){
404 $link = USCES_INQUIRY_URL;
405
406 }else{
407 $link = str_replace('https://', 'http://', $link);
408 $link = apply_filters('usces_ssl_page_link', $link);
409 }
410
411 return $link;
412 }
413 function usces_ssl_contents_link($link)
414 {
415 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])){
416 $req = explode('/wp-content/',$link);
417 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
418 }else{
419 $link = apply_filters('usces_ssl_contents_link', $link);
420 }
421 return $link;
422 }
423
424 function ssl_admin_ajax_url(){
425 $path = '/wp-admin/admin-ajax.php';
426 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) ){
427 $link = USCES_SSL_URL_ADMIN . '/wp-admin/admin-ajax.php';
428 }else{
429 $link = site_url( $path );
430 }
431 $link = apply_filters('ssl_admin_ajax_url', $link);
432 return $link;
433 }
434
435 function usces_ssl_attachment_link($link)
436 {
437 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
438 $link = str_replace(site_url(), USCES_SSL_URL_ADMIN, $link);
439 }else{
440 $link = apply_filters('usces_ssl_attachment_link', $link);
441 }
442 return $link;
443 }
444
445 function usces_ssl_icon_dir_uri($uri)
446 {
447 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
448 $uri = USCES_SSL_URL_ADMIN. '/' . WPINC . '/images/crystal';
449 }else{
450 $link = apply_filters('usces_ssl_icon_dir_uri', $uri);
451 }
452 return $uri;
453 }
454
455 function usces_ssl_script_link($link)
456 {
457 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
458 if(strpos($link, '/wp-content/') !== false){
459 $req = explode('/wp-content/',$link, 2);
460 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
461 }else if(strpos($link, '/wp-includes/') !== false){
462 $req = explode('/wp-includes/',$link, 2);
463 $link = USCES_SSL_URL_ADMIN . '/wp-includes/' . $req[1];
464 }else if(strpos($link, '/wp-admin/') !== false){
465 $req = explode('/wp-admin/',$link, 2);
466 $link = USCES_SSL_URL_ADMIN . '/wp-admin/' . $req[1];
467 }
468 }else{
469 $link = apply_filters('usces_ssl_script_link', $link);
470 }
471 return $link;
472 }
473
474 function set_action_status($status, $message)
475 {
476 $this->action_status = $status;
477 $this->action_message = $message;
478 }
479
480 /******************************************************************************/
481 function add_pages() {
482
483 add_object_page('Welcart Shop', 'Welcart Shop', 'level_2', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
484 add_submenu_page(USCES_PLUGIN_BASENAME, __('Home','usces'), __('Home','usces'), 'level_2', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
485 add_submenu_page(USCES_PLUGIN_BASENAME, __('Master Items','usces'), __('Master Items','usces'), 'level_2', 'usces_itemedit', array($this, 'item_master_page'));
486 add_submenu_page(USCES_PLUGIN_BASENAME, __('Add New Item','usces'), __('Add New Item','usces'), 'level_2', 'usces_itemnew', array($this, 'item_master_page'));
487 add_submenu_page(USCES_PLUGIN_BASENAME, __('General Setting','usces'), __('General Setting','usces'), 'level_6', 'usces_initial', array($this, 'admin_setup_page'));
488 add_submenu_page(USCES_PLUGIN_BASENAME, __('Business Days Setting','usces'), __('Business Days Setting','usces'), 'level_6', 'usces_schedule', array($this, 'admin_schedule_page'));
489 add_submenu_page(USCES_PLUGIN_BASENAME, __('Shipping Setting','usces'), __('Shipping Setting','usces'), 'level_6', 'usces_delivery', array($this, 'admin_delivery_page'));
490 add_submenu_page(USCES_PLUGIN_BASENAME, __('E-mail Setting','usces'), __('E-mail Setting','usces'), 'level_6', 'usces_mail', array($this, 'admin_mail_page'));
491 add_submenu_page(USCES_PLUGIN_BASENAME, __('Cart Page Setting','usces'), __('Cart Page Setting','usces'), 'level_6', 'usces_cart', array($this, 'admin_cart_page'));
492 add_submenu_page(USCES_PLUGIN_BASENAME, __('Member Page Setting','usces'), __('Member Page Setting','usces'), 'level_6', 'usces_member', array($this, 'admin_member_page'));
493 add_submenu_page(USCES_PLUGIN_BASENAME, __('System Setting','usces'), __('System Setting','usces'), 'administrator', 'usces_system', array($this, 'admin_system_page'));
494 add_submenu_page(USCES_PLUGIN_BASENAME, __('Settlement Setting','usces'), __('Settlement Setting','usces'), 'administrator', 'usces_settlement', array($this, 'admin_settlement_page'));
495 //add_submenu_page(USCES_PLUGIN_BASENAME, __('Backup','usces'), __('Backup','usces'), 'level_6', 'usces_backup', array($this, 'admin_backup_page'));
496 do_action('usces_action_shop_admin_menue');
497
498 add_object_page('Welcart Management', 'Welcart Management', 'level_5', 'usces_orderlist', array($this, 'order_list_page'));
499 add_submenu_page('usces_orderlist', __('Order List','usces'), __('Order List','usces'), 'level_5', 'usces_orderlist', array($this, 'order_list_page'));
500 add_submenu_page('usces_orderlist', __('New Order or Estimate','usces'), __('New Order or Estimate','usces'), 'level_5', 'usces_ordernew', array($this, 'order_list_page'));
501 add_submenu_page('usces_orderlist', __('List of Members','usces'), __('List of Members','usces'), 'level_5', 'usces_memberlist', array($this, 'member_list_page'));
502 add_submenu_page('usces_orderlist', __('新規会員登録','usces'), __('新規会員登録','usces'), 'level_5', 'usces_membernew', array($this, 'member_list_page'));
503 do_action('usces_action_management_admin_menue');
504 }
505
506
507 /* Item Master Page */
508 function item_master_page() {
509 global $wpdb, $wp_locale;
510 global $wp_query;
511
512 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
513 $this->action_status = 'none';
514 $this->action_message = '';
515 }
516
517 if($_REQUEST['page'] == 'usces_itemnew'){
518 $action = 'new';
519 }else{
520 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
521 }
522 do_action( 'usces_action_item_master_page', $action );
523 switch ( $action ) {
524 case 'dlitemlist':
525 usces_download_item_list();
526 break;
527 case 'upload_register':
528 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_upload_register.php');
529 break;
530 case 'delete':
531 case 'new':
532 case 'editpost':
533 case 'edit':
534 global $current_user;
535 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_edit.php');
536 break;
537 default:
538 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_list.php');
539 break;
540 }
541 }
542
543 /* order list page */
544 function order_list_page() {
545 $order_edit_form = apply_filters( 'usces_admin_order_edit_form', USCES_PLUGIN_DIR . '/includes/order_edit_form.php' );
546 $order_list = apply_filters( 'usces_admin_order_list', USCES_PLUGIN_DIR . '/includes/order_list.php' );
547
548 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
549 $this->action_status = 'none';
550 $this->action_message = '';
551 }
552 if($_REQUEST['page'] == 'usces_ordernew'){
553 $order_action = 'new';
554 }else{
555 $order_action = isset($_REQUEST['order_action']) ? $_REQUEST['order_action'] : '';
556 }
557 do_action('usces_action_order_list_page', $order_action);
558 switch ($order_action) {
559 //20100908ysk start
560 case 'dlproductlist':
561 usces_download_product_list();
562 break;
563 case 'dlorderlist':
564 usces_download_order_list();
565 break;
566 //20100908ysk end
567 // case 'printpdf':
568 // require_once(USCES_PLUGIN_DIR . '/includes/order_print.php');
569 // break;
570 case 'editpost':
571 do_action('usces_pre_update_orderdata', $_REQUEST['order_id']);
572 $res = usces_update_orderdata();
573 if ( 1 === $res ) {
574 $this->set_action_status('success', __('order date is updated','usces').' <a href="'.stripslashes( $_POST['usces_referer'] ).'">'.__('back to the summary','usces').'</a>');
575 } elseif ( 0 === $res ) {
576 $this->set_action_status('none', '');
577 } else {
578 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
579 }
580 do_action('usces_after_update_orderdata', $_REQUEST['order_id'], $res);
581 require_once($order_edit_form);
582 break;
583 case 'newpost':
584 do_action('usces_pre_new_orderdata');
585 $res = usces_new_orderdata();
586 if ( 1 === $res ) {
587 $this->set_action_status('success', __('New date is add','usces'));
588 } elseif ( 0 === $res ) {
589 $this->set_action_status('none', '');
590 } else {
591 $this->set_action_status('error', 'ERROR : '.__('failure in addition','usces'));
592 }
593 do_action('usces_after_new_orderdata', $res);
594 $_REQUEST['order_action'] = 'edit';
595 $order_action = $_REQUEST['order_action'];
596 require_once($order_edit_form);
597 break;
598 case 'new':
599 case 'edit':
600 require_once($order_edit_form);
601 break;
602 case 'delete':
603 do_action('usces_pre_delete_orderdata', $_REQUEST['order_id']);
604 $res = usces_delete_orderdata();
605 if ( 1 === $res ) {
606 $this->set_action_status('success', __('the order date is deleted','usces'));
607 } elseif ( 0 === $res ) {
608 $this->set_action_status('none', '');
609 } else {
610 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
611 }
612 do_action('usces_after_delete_orderdata', $_REQUEST['order_id'], $res);
613 default:
614 require_once($order_list);
615 }
616 }
617
618 /* member list page */
619 function member_list_page() {
620 $member_edit_form = apply_filters( 'usces_admin_member_edit_form', USCES_PLUGIN_DIR . '/includes/member_edit_form.php' );
621 $member_list = apply_filters( 'usces_admin_member_list', USCES_PLUGIN_DIR . '/includes/member_list.php' );
622
623 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
624 $this->action_status = 'none';
625 $this->action_message = '';
626 }
627 if( $_REQUEST['page'] == 'usces_membernew' && !isset($_REQUEST['member_action']) ){
628 $member_action = 'new';
629 }elseif( $_REQUEST['page'] == 'usces_membernew' && isset($_REQUEST['member_action']) ){
630 $member_action = 'newpost';
631 }else{
632 $member_action = isset($_REQUEST['member_action']) ? $_REQUEST['member_action'] : '';
633 }
634 switch ($member_action) {
635 // case 'upmemberlist':
636 // usces_upload_member_list();
637 // break;
638 //20100908ysk start
639 case 'dlmemberlist':
640 usces_download_member_list();
641 break;
642 //20100908ysk end
643 case 'editpost':
644 $this->error_message = $this->admin_member_check();
645 if( WCUtils::is_blank($this->error_message) ){
646 $res = usces_update_memberdata();
647 if ( 1 === $res ) {
648 $this->set_action_status('success', __('Membership information is updated','usces'));
649 } elseif ( 0 === $res ) {
650 $this->set_action_status('none', '');
651 } else {
652 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
653 }
654 }
655 require_once($member_edit_form);
656 break;
657 case 'newpost':
658 $this->error_message = $this->admin_new_member_check();
659 if( WCUtils::is_blank($this->error_message) ){
660 $res = usces_new_memberdata();
661 if ( 1 === $res ) {
662 $this->set_action_status('success', __('新規会員登録が完了しました', 'usces'));
663 $_REQUEST['member_action'] = 'edit';
664 $member_action = $_REQUEST['member_action'];
665 } elseif ( 0 === $res ) {
666 $this->set_action_status('none', '');
667 } else {
668 $this->set_action_status('error', 'ERROR : '.__('登録できませんでした','usces'));
669 }
670 }
671 require_once($member_edit_form);
672 break;
673
674 case 'new':
675 case 'edit':
676 require_once($member_edit_form);
677 break;
678 case 'delete':
679 $res = usces_delete_memberdata();
680 if ( 1 === $res ) {
681 $this->set_action_status('success', __('The member data is deleted','usces'));
682 } elseif ( 0 === $res ) {
683 $this->set_action_status('none', '');
684 } else {
685 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
686 }
687 default:
688 require_once($member_list);
689 }
690
691 }
692
693 /* admin backup page */
694 function admin_backup_page() {
695
696 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
697 $this->action_status = 'none';
698 $this->action_message = '';
699 }
700 require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
701
702 }
703
704 /* Shop Top Page */
705 function admin_top_page() {
706 $path = apply_filters( 'usces_filter_admin_top_page', USCES_PLUGIN_DIR . '/includes/admin_top.php');
707 require_once($path);
708
709 }
710
711 /* Shop Setup Page */
712 function admin_setup_page() {
713 $this->options = get_option('usces');
714 //$this->options = array();
715
716
717 if(isset($_POST['usces_option_update'])) {
718
719 $_POST = $this->stripslashes_deep_post($_POST);
720 $this->options['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : '';
721 $this->options['campaign_category'] = empty($_POST['cat']) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat'];
722 $this->options['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : '';
723 $this->options['privilege_point'] = isset($_POST['point_num']) ? (int)$_POST['point_num'] : '';
724 $this->options['privilege_discount'] = isset($_POST['discount_num']) ? (int)$_POST['discount_num'] : '';
725 $this->options['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : '';
726 $this->options['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : '';
727 $this->options['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : '';
728 $this->options['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : '';
729 $this->options['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : '';
730 $this->options['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : '';
731 $this->options['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : '';
732 $this->options['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : '';
733 $this->options['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : '';
734 $this->options['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : '';
735 $this->options['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : '';
736 $this->options['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : '';
737 $this->options['point_rate'] = isset($_POST['point_rate']) ? (int)$_POST['point_rate'] : 1;
738 $this->options['start_point'] = isset($_POST['start_point']) ? (int)$_POST['start_point'] : '';
739 $this->options['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : '';
740 $this->options['tax_mode'] = isset($_POST['tax_mode']) ? trim($_POST['tax_mode']) : 'include';
741 $this->options['tax_target'] = isset($_POST['tax_target']) ? trim($_POST['tax_target']) : 'products';
742 $this->options['tax_rate'] = isset($_POST['tax_rate']) ? (int)$_POST['tax_rate'] : '';
743 $this->options['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : '';
744 $this->options['cod_type'] = isset($this->options['cod_type']) ? $this->options['cod_type'] : 'fix';
745 $this->options['transferee'] = isset($_POST['transferee']) ? trim($_POST['transferee']) : '';
746 $this->options['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : '';
747 $this->options['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : '';
748 $this->options['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : '';
749 $this->options['point_coverage'] = isset($_POST['point_coverage']) ? (int)$_POST['point_coverage'] : 0;
750 $this->options['point_assign'] = isset($_POST['point_assign']) ? (int)$_POST['point_assign'] : 1;//20120919ysk 0000573
751
752 $this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options );
753
754 update_option('usces', $this->options);
755
756 $this->action_status = 'success';
757 $this->action_message = __('options are updated','usces');
758
759 } else {
760 $this->action_status = 'none';
761 $this->action_message = '';
762 }
763
764 require_once(USCES_PLUGIN_DIR . '/includes/admin_setup.php');
765
766 }
767
768 /* Shop Schedule Page */
769 function admin_schedule_page() {
770
771 $this->options = get_option('usces');
772
773 if(isset($_POST['usces_option_update'])) {
774 $_POST = $this->stripslashes_deep_post($_POST);
775
776 $this->options['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0';
777 if(isset($_POST['business_days']))
778 $this->options['business_days'] = $_POST['business_days'];
779
780 update_option('usces', $this->options);
781
782 do_action( 'usces_action_admin_schedule_update' );
783
784 $this->action_status = 'success';
785 $this->action_message = __('options are updated','usces');
786 } else {
787 $this->action_status = 'none';
788 $this->action_message = '';
789 }
790
791 require_once(USCES_PLUGIN_DIR . '/includes/admin_schedule.php');
792
793 }
794
795 /* Shop Delivery Page */
796 function admin_delivery_page() {
797
798 $this->options = get_option('usces');
799
800 if(isset($_POST['usces_option_update'])) {
801 $_POST = $this->stripslashes_deep_post($_POST);
802
803 //20101208ysk start
804 if(isset($_POST['delivery_time_limit'])) $this->options['delivery_time_limit'] = $_POST['delivery_time_limit'];
805 if(isset($_POST['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time'];
806 if(isset($_POST['delivery_after_days'])) $this->options['delivery_after_days'] = $_POST['delivery_after_days'];
807 //20101208ysk end
808
809 update_option('usces', $this->options);
810
811 $this->action_status = 'success';
812 $this->action_message = __('options are updated','usces');
813 } else {
814 $this->action_status = 'none';
815 $this->action_message = '';
816 }
817
818 require_once(USCES_PLUGIN_DIR . '/includes/admin_delivery.php');
819
820 }
821
822 /* Shop Mail Page */
823 function admin_mail_page() {
824 global $allowedposttags;
825
826 $this->options = get_option('usces');
827
828 if(isset($_POST['usces_option_update'])) {
829 $_POST = $this->stripslashes_deep_post($_POST);
830
831 $this->options['smtp_hostname'] = trim($_POST['smtp_hostname']);
832 $this->options['newmem_admin_mail'] = (int)$_POST['newmem_admin_mail'];
833 $this->options['delmem_admin_mail'] = (int)$_POST['delmem_admin_mail'];
834 $this->options['delmem_customer_mail'] = (int)$_POST['delmem_customer_mail'];
835
836 foreach ( $_POST['title'] as $key => $value ) {
837 if( WCUtils::is_blank($value) ) {
838 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
839 }else{
840 $this->options['mail_data']['title'][$key] = trim($value);
841 }
842 }
843 foreach ( $_POST['header'] as $key => $value ) {
844 if( WCUtils::is_blank($value) ) {
845 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
846 }else{
847 $this->options['mail_data']['header'][$key] = $value;
848 }
849 }
850 foreach ( $_POST['footer'] as $key => $value ) {
851 if( WCUtils::is_blank($value) ) {
852 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
853 }else{
854 $this->options['mail_data']['footer'][$key] = $value;
855 }
856 }
857
858
859 $this->action_status = 'success';
860 $this->action_message = __('options are updated','usces');
861
862 } else {
863
864 foreach ( (array)$this->options['mail_data']['title'] as $key => $value ) {
865 if( WCUtils::is_blank($value) ) {
866 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
867 }
868 }
869 foreach ( (array)$this->options['mail_data']['header'] as $key => $value ) {
870 if( WCUtils::is_blank($value) ) {
871 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
872 }
873 }
874 foreach ( (array)$this->options['mail_data']['footer'] as $key => $value ) {
875 if( WCUtils::is_blank($value) ) {
876 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
877 }
878 }
879
880 $this->action_status = 'none';
881 $this->action_message = '';
882
883 }
884
885 update_option('usces', $this->options);
886 do_action( 'usces_action_admin_mail_page' );
887
888 require_once(USCES_PLUGIN_DIR . '/includes/admin_mail.php');
889
890 }
891
892 /* Admin Cart Page */
893 function admin_cart_page() {
894 global $allowedposttags;
895 $this->options = get_option('usces');
896
897 if(isset($_POST['usces_option_update'])) {
898 $_POST = $this->stripslashes_deep_post($_POST);
899
900 foreach ( $this->options['indi_item_name'] as $key => $value ) {
901 $this->options['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0;
902 }
903 foreach ( $_POST['position'] as $key => $value ) {
904 $this->options['pos_item_name'][$key] = $value;
905 }
906 foreach ( $_POST['header'] as $key => $value ) {
907 $this->options['cart_page_data']['header'][$key] = addslashes(wp_kses($value, $allowedposttags));
908 }
909 foreach ( $_POST['footer'] as $key => $value ) {
910 $this->options['cart_page_data']['footer'][$key] = addslashes(wp_kses($value, $allowedposttags));
911 }
912
913 update_option('usces', $this->options);
914
915 $this->action_status = 'success';
916 $this->action_message = __('options are updated','usces');
917 } else {
918
919 $this->action_status = 'none';
920 $this->action_message = '';
921 }
922
923
924
925 require_once(USCES_PLUGIN_DIR . '/includes/admin_cart.php');
926
927 }
928
929 /* Admin Member Page */
930 function admin_member_page() {
931
932 $this->options = get_option('usces');
933
934 if(isset($_POST['usces_option_update'])) {
935 $_POST = $this->stripslashes_deep_post($_POST);
936
937 foreach ( $_POST['header'] as $key => $value ) {
938 $this->options['member_page_data']['header'][$key] = $value;
939 }
940 foreach ( $_POST['footer'] as $key => $value ) {
941 $this->options['member_page_data']['footer'][$key] = $value;
942 }
943
944 update_option('usces', $this->options);
945
946 $this->action_status = 'success';
947 $this->action_message = __('options are updated','usces');
948 } else {
949
950 $this->action_status = 'none';
951 $this->action_message = '';
952 }
953
954
955
956 require_once(USCES_PLUGIN_DIR . '/includes/admin_member.php');
957
958 }
959
960
961 /* Admin System Page */
962 function admin_system_page() {
963 //20110331ysk start
964 global $usces_states;
965 //20110331ysk end
966 $action_status = '';//20120511ysk 0000470
967
968 $this->options = get_option('usces');
969
970 if(isset($_POST['usces_option_update'])) {
971 $_POST = $this->stripslashes_deep_post($_POST);
972
973 $this->options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0;
974 $this->options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : '';
975 $this->options['fukugo_category_orderby'] = isset($_POST['fukugo_category_orderby']) ? $_POST['fukugo_category_orderby'] : '';
976 $this->options['fukugo_category_order'] = isset($_POST['fukugo_category_order']) ? $_POST['fukugo_category_order'] : '';
977 $this->options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : '';
978 if( WCUtils::is_blank($this->options['settlement_path']) ) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
979 $sl = substr($this->options['settlement_path'], -1);
980 if($sl != '/' && $sl != '\\') $this->options['settlement_path'] .= '/';
981 $this->options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : '';
982 if( !WCUtils::is_blank($this->options['logs_path']) ){
983 $sl = substr($this->options['logs_path'], -1);
984 if($sl == '/' || $sl == '\\') $this->options['logs_path'] = substr($this->options['logs_path'], 0, -1);
985 }
986 $this->options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0;
987 $this->options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : '';
988 $this->options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : '';
989 if( WCUtils::is_blank($this->options['ssl_url']) || WCUtils::is_blank($this->options['ssl_url_admin']) ) $this->options['use_ssl'] = 0;
990 $this->options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : '';
991 $this->options['use_javascript'] = isset($_POST['use_javascript']) ? (int)$_POST['use_javascript'] : 1;
992 $this->options['system']['front_lang'] = (isset($_POST['front_lang']) && 'others' != $_POST['front_lang']) ? $_POST['front_lang'] : usces_get_local_language();
993 $this->options['system']['currency'] = (isset($_POST['currency']) && 'others' != $_POST['currency']) ? $_POST['currency'] : usces_get_base_country();
994 $this->options['system']['addressform'] = (isset($_POST['addressform']) ) ? $_POST['addressform'] : usces_get_local_addressform();
995 $this->options['system']['target_market'] = (isset($_POST['target_market']) ) ? $_POST['target_market'] : usces_get_local_target_market();
996 $this->options['system']['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0;
997 $this->options['system']['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int)$_POST['dec_orderID_flag'] : 0;
998 $this->options['system']['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : '';
999 $this->options['system']['pdf_delivery'] = isset($_POST['pdf_delivery']) ? (int)$_POST['pdf_delivery'] : 0;
1000 $this->options['system']['member_pass_rule_min'] = isset($_POST['member_pass_rule_min']) ? (int)$_POST['member_pass_rule_min'] : 6;
1001 $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'] : '';
1002 $this->options['system']['csv_encode_type'] = isset($_POST['csv_encode_type']) ? (int)$_POST['csv_encode_type'] : 0;
1003
1004 if( isset($_POST['dec_orderID_digit']) ){
1005 $dec_orderID_digit = (int)rtrim($_POST['dec_orderID_digit']);
1006 if( 6 > $dec_orderID_digit ){
1007 $this->options['system']['dec_orderID_digit'] = 6;
1008 }else{
1009 $this->options['system']['dec_orderID_digit'] = $dec_orderID_digit;
1010 }
1011 }else{
1012 $this->options['system']['dec_orderID_digit'] = 6;
1013 }
1014 $this->options['system']['subimage_rule'] = isset($_POST['subimage_rule']) ? (int)$_POST['subimage_rule'] : 0;
1015 //20110331ysk start
1016 unset($this->options['province']);
1017 //$action_status = '';//20120511ysk 0000470
1018 foreach((array)$this->options['system']['target_market'] as $target_market) {
1019 $province = array();
1020 if(!empty($_POST['province_'.$target_market])) {
1021 $temp_pref = explode("\n", $_POST['province_'.$target_market]);
1022 //20120123ysk start 0000386
1023 //$province[] = __('-- Select --', 'usces');
1024 $province[] = '-- Select --';
1025 //20120123ysk end
1026 //20120725ysk start 0000537
1027 //for($i = 0; $i < count($temp_pref); $i++) {
1028 //$province[] = trim($temp_pref[$i]);
1029 foreach( $temp_pref as $pref ) {
1030 if( !WCUtils::is_blank($pref) )
1031 $province[] = trim($pref);
1032 }
1033 if( 1 == count($province) )
1034 $action_status = 'error';
1035 //20120725ysk end
1036 } else {
1037 if(isset($usces_states[$target_market]) && is_array($usces_states[$target_market])) {
1038 $province = $usces_states[$target_market];
1039 } else {
1040 $action_status = 'error';
1041 }
1042 }
1043 $this->options['province'][$target_market] = $province;
1044 }
1045
1046 if($action_status != '') {
1047 $this->action_status = 'error';
1048 $this->action_message = __('Data have deficiency.','usces');
1049 } else {
1050 $this->action_status = 'success';
1051 $this->action_message = __('options are updated','usces');
1052 }
1053 //20110331ysk end
1054 } else {
1055
1056 if( !isset($this->options['province']) || empty($this->options['province']) ){
1057 //20110331ysk start
1058 //$this->options['province'] = get_option('usces_pref');
1059 $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
1060 //20110331ysk end
1061 }
1062 $this->action_status = 'none';
1063 $this->action_message = '';
1064 }
1065
1066 if($action_status != 'error') //20120511ysk 0000470
1067 update_option('usces', $this->options);
1068
1069 require_once(USCES_PLUGIN_DIR . '/includes/admin_system.php');
1070
1071 }
1072
1073 /* Settlement Setting Page */
1074 function admin_settlement_page() {
1075
1076 $this->action_status = 'none';
1077 $this->action_message = '';
1078
1079 $options = get_option('usces');
1080
1081 if( isset($_POST['usces_option_update']) ) {
1082 $_POST = $this->stripslashes_deep_post($_POST);
1083 $mes = '';
1084
1085 switch( $_POST['acting'] ){
1086 case 'zeus':
1087 unset( $options['acting_settings']['zeus'] );
1088 $options['acting_settings']['zeus']['card_url'] = isset($_POST['card_url']) ? $_POST['card_url'] : '';
1089 $options['acting_settings']['zeus']['card_secureurl'] = isset($_POST['card_secureurl']) ? $_POST['card_secureurl'] : '';
1090 $options['acting_settings']['zeus']['ipaddrs'] = isset($_POST['ipaddrs']) ? $_POST['ipaddrs'] : '';
1091 $options['acting_settings']['zeus']['pay_cvs'] = isset($_POST['pay_cvs']) ? $_POST['pay_cvs'] : '';
1092 $options['acting_settings']['zeus']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1093 $options['acting_settings']['zeus']['connection'] = isset($_POST['connection']) ? $_POST['connection'] : 1;
1094 $options['acting_settings']['zeus']['3dsecur'] = isset($_POST['3dsecur']) ? $_POST['3dsecur'] : 2;
1095 $options['acting_settings']['zeus']['security'] = isset($_POST['security']) ? $_POST['security'] : 2;
1096 if( isset($_POST['authkey']) ){
1097 $options['acting_settings']['zeus']['authkey'] = $_POST['authkey'];
1098 }
1099 // if( 1 == $options['acting_settings']['zeus']['security'] ){
1100 // $options['acting_settings']['zeus']['quickcharge'] = '2';
1101 // }else{
1102 $options['acting_settings']['zeus']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : '';
1103 // }
1104 $options['acting_settings']['zeus']['batch'] = isset($_POST['batch']) ? $_POST['batch'] : '';
1105 $options['acting_settings']['zeus']['clientip'] = isset($_POST['clientip']) ? trim($_POST['clientip']) : '';
1106 $options['acting_settings']['zeus']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1107 $options['acting_settings']['zeus']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1108 $options['acting_settings']['zeus']['bank_ope'] = isset($_POST['bank_ope']) ? $_POST['bank_ope'] : '';
1109 $options['acting_settings']['zeus']['clientip_bank'] = isset($_POST['clientip_bank']) ? trim($_POST['clientip_bank']) : '';
1110 $options['acting_settings']['zeus']['testid_bank'] = isset($_POST['testid_bank']) ? trim($_POST['testid_bank']) : '';
1111 $options['acting_settings']['zeus']['bank_url'] = isset($_POST['bank_url']) ? $_POST['bank_url'] : '';
1112 $options['acting_settings']['zeus']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1113 $options['acting_settings']['zeus']['conv_ope'] = isset($_POST['conv_ope']) ? $_POST['conv_ope'] : '';
1114 $options['acting_settings']['zeus']['clientip_conv'] = isset($_POST['clientip_conv']) ? trim($_POST['clientip_conv']) : '';
1115 $options['acting_settings']['zeus']['testid_conv'] = isset($_POST['testid_conv']) ? trim($_POST['testid_conv']) : '';
1116 $options['acting_settings']['zeus']['test_type_conv'] = ( (isset($_POST['testid_conv']) && WCUtils::is_blank($_POST['testid_conv'])) || !isset($_POST['test_type']) ) ? 0 : $_POST['test_type'];
1117 $options['acting_settings']['zeus']['conv_url'] = isset($_POST['conv_url']) ? $_POST['conv_url'] : '';
1118
1119 if( WCUtils::is_blank($_POST['clientip']) && isset($_POST['card_activate']) && 'on' == $_POST['card_activate'])
1120 $mes .= '※カード決済IPコードを�
1121 �力して下さい<br />';
1122 if( isset($_POST['authkey']) && WCUtils::is_blank($_POST['authkey']) && isset($_POST['security']) && 3 == $_POST['security'])
1123 $mes .= '※認証キーを�
1124 �力して下さい<br />';
1125 if( WCUtils::is_blank($_POST['clientip_bank']) && isset($_POST['bank_activate']) && 'on' == $_POST['bank_activate'] )
1126 $mes .= '※�
1127 �金お任せIPコードを�
1128 �力して下さい<br />';
1129 if( WCUtils::is_blank($_POST['testid_bank']) && isset($_POST['bank_ope']) && 'test' == $_POST['bank_ope'] )
1130 $mes .= '※�
1131 �金お任せテストIDを�
1132 �力して下さい<br />';
1133 if( WCUtils::is_blank($_POST['clientip_conv']) && isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] )
1134 $mes .= '※コンビニ決済IPコードを�
1135 �力して下さい<br />';
1136 if( WCUtils::is_blank($_POST['testid_conv']) && isset($_POST['conv_ope']) && 'test' == $_POST['conv_ope'] )
1137 $mes .= '※コンビニ決済テストIDを�
1138 �力して下さい<br />';
1139 if( isset($_POST['batch']) && 'on' == $_POST['batch'] ) {
1140 if( isset($_POST['quickcharge']) && 'on' == $_POST['quickcharge'] ) {
1141 } else {
1142 $mes .= '※バッチ処理を利用する場合は、クイックチャージを利用するにして下さい<br />';
1143 $options['acting_settings']['zeus']['quickcharge'] = 'on';
1144 }
1145 }
1146 if( !isset($_POST['card_url']) || empty($_POST['card_url']) || !isset($_POST['ipaddrs']) || empty($_POST['ipaddrs']) || !isset($_POST['bank_url']) || empty($_POST['bank_url']) || !isset($_POST['conv_url']) || empty($_POST['conv_url']) )
1147 $mes .= '※設定が不正です!<br />';
1148
1149 if( WCUtils::is_blank($mes) ){
1150 $this->action_status = 'success';
1151 $this->action_message = __('options are updated','usces');
1152 $options['acting_settings']['zeus']['activate'] = 'on';
1153 if( 'on' == $options['acting_settings']['zeus']['card_activate'] ){
1154 $this->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
1155 }else{
1156 unset($this->payment_structure['acting_zeus_card']);
1157 }
1158 if( 'on' == $options['acting_settings']['zeus']['bank_activate'] ){
1159 $this->payment_structure['acting_zeus_bank'] = '�
1160 �金お任せ(ZEUS)';
1161 }else{
1162 unset($this->payment_structure['acting_zeus_bank']);
1163 }
1164 if( 'on' == $options['acting_settings']['zeus']['conv_activate'] ){
1165 $this->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
1166 }else{
1167 unset($this->payment_structure['acting_zeus_conv']);
1168 }
1169 $options['acting_settings']['zeus']['vercheck'] = '115';
1170 update_option( 'usces', $options );
1171 if( 'on' != $options['acting_settings']['zeus']['quickcharge'] ) {
1172 usces_clear_quickcharge( 'zeus_pcid' );
1173 }
1174 }else{
1175 $this->action_status = 'error';
1176 $this->action_message = __('Data have deficiency.','usces');
1177 $options['acting_settings']['zeus']['activate'] = 'off';
1178 unset($this->payment_structure['acting_zeus_card'], $this->payment_structure['acting_zeus_bank'], $this->payment_structure['acting_zeus_conv']);
1179 }
1180 ksort($this->payment_structure);
1181 update_option('usces_payment_structure',$this->payment_structure);
1182 break;
1183
1184 case 'remise':
1185 unset( $options['acting_settings']['remise'] );
1186 $options['acting_settings']['remise']['plan'] = isset($_POST['plan']) ? $_POST['plan'] : '';
1187 $options['acting_settings']['remise']['SHOPCO'] = isset($_POST['SHOPCO']) ? $_POST['SHOPCO'] : '';
1188 $options['acting_settings']['remise']['HOSTID'] = isset($_POST['HOSTID']) ? $_POST['HOSTID'] : '';
1189 $options['acting_settings']['remise']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1190 $options['acting_settings']['remise']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1191 $options['acting_settings']['remise']['card_pc_ope'] = isset($_POST['card_pc_ope']) ? $_POST['card_pc_ope'] : '';
1192 $options['acting_settings']['remise']['payquick'] = isset($_POST['payquick']) ? $_POST['payquick'] : '';
1193 $options['acting_settings']['remise']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1194 $options['acting_settings']['remise']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1195 $options['acting_settings']['remise']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1196 $options['acting_settings']['remise']['conv_pc_ope'] = isset($_POST['conv_pc_ope']) ? $_POST['conv_pc_ope'] : '';
1197 $options['acting_settings']['remise']['S_PAYDATE'] = isset($_POST['S_PAYDATE']) ? $_POST['S_PAYDATE'] : '';
1198 $options['acting_settings']['remise']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1199 $options['acting_settings']['remise']['send_url_pc'] = isset($_POST['send_url_pc']) ? $_POST['send_url_pc'] : '';
1200 $options['acting_settings']['remise']['send_url_cvs_mbl'] = isset($_POST['send_url_cvs_mbl']) ? $_POST['send_url_cvs_mbl'] : '';
1201 $options['acting_settings']['remise']['send_url_cvs_pc'] = isset($_POST['send_url_cvs_pc']) ? $_POST['send_url_cvs_pc'] : '';
1202 $options['acting_settings']['remise']['send_url_mbl_test'] = isset($_POST['send_url_mbl_test']) ? $_POST['send_url_mbl_test'] : '';
1203 $options['acting_settings']['remise']['send_url_pc_test'] = isset($_POST['send_url_pc_test']) ? $_POST['send_url_pc_test'] : '';
1204 $options['acting_settings']['remise']['send_url_cvs_mbl_test'] = isset($_POST['send_url_cvs_mbl_test']) ? $_POST['send_url_cvs_mbl_test'] : '';
1205 $options['acting_settings']['remise']['send_url_cvs_pc_test'] = isset($_POST['send_url_cvs_pc_test']) ? $_POST['send_url_cvs_pc_test'] : '';
1206 $options['acting_settings']['remise']['REMARKS3'] = isset($_POST['REMARKS3']) ? $_POST['REMARKS3'] : '';
1207
1208 if( isset($_POST['plan_remise']) && WCUtils::is_zero($_POST['plan_remise']) )
1209 $mes .= '※サービスプランを選択してください<br />';
1210 if( WCUtils::is_blank($_POST['SHOPCO']) )
1211 $mes .= '※加盟店コードを�
1212 �力して下さい<br />';
1213 if( WCUtils::is_blank($_POST['HOSTID']) )
1214 $mes .= '※ホスト番号を�
1215 �力して下さい<br />';
1216 if( isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] && empty($_POST['S_PAYDATE']) )
1217 $mes .= '※支払期限を�
1218 �力して下さい<br />';
1219 if( isset($_POST['card_pc_ope']) && 'public' == $_POST['card_pc_ope'] && empty($_POST['send_url_pc']) )
1220 $mes .= '※クレジットカード決済の本番URLを�
1221 �力して下さい<br />';
1222 if( isset($_POST['conv_pc_ope']) && 'public' == $_POST['conv_pc_ope'] && empty($_POST['send_url_cvs_pc']) )
1223 $mes .= '※コンビニ・電子マネー決済の本番URLを�
1224 �力して下さい<br />';
1225 if( !isset($_POST['REMARKS3']) || empty($_POST['REMARKS3']) )
1226 $mes .= '※設定が不正です!<br />';
1227
1228 if( WCUtils::is_blank($mes) ){
1229 //$this->zaction_status = 'success';
1230 $this->action_status = 'success';
1231 $this->action_message = __('options are updated','usces');
1232 $options['acting_settings']['remise']['activate'] = 'on';
1233 if( 'on' == $options['acting_settings']['remise']['card_activate'] ){
1234 $this->payment_structure['acting_remise_card'] = 'カード決済(ルミーズ)';
1235 }else{
1236 unset($this->payment_structure['acting_remise_card']);
1237 }
1238 if( 'on' == $options['acting_settings']['remise']['conv_activate'] ){
1239 $this->payment_structure['acting_remise_conv'] = 'コンビニ決済(ルミーズ)';
1240 }else{
1241 unset($this->payment_structure['acting_remise_conv']);
1242 }
1243 update_option('usces', $options);
1244 if( 'on' != $options['acting_settings']['remise']['payquick'] ) {
1245 usces_clear_quickcharge( 'remise_pcid' );
1246 }
1247
1248 }else{
1249 $this->action_status = 'error';
1250 $this->action_message = __('Data have deficiency.','usces');
1251 $options['acting_settings']['remise']['activate'] = 'off';
1252 unset($this->payment_structure['acting_remise_card']);
1253 unset($this->payment_structure['acting_remise_conv']);
1254 }
1255 ksort($this->payment_structure);
1256 update_option('usces_payment_structure',$this->payment_structure);
1257 break;
1258 //20101018ysk start
1259 case 'jpayment':
1260 unset( $options['acting_settings']['jpayment'] );
1261 $options['acting_settings']['jpayment']['aid'] = isset($_POST['aid']) ? $_POST['aid'] : '';
1262 $options['acting_settings']['jpayment']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1263 $options['acting_settings']['jpayment']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1264 $options['acting_settings']['jpayment']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1265 //$options['acting_settings']['jpayment']['webm_activate'] = isset($_POST['webm_activate']) ? $_POST['webm_activate'] : '';
1266 //$options['acting_settings']['jpayment']['bitc_activate'] = isset($_POST['bitc_activate']) ? $_POST['bitc_activate'] : '';
1267 //$options['acting_settings']['jpayment']['suica_activate'] = isset($_POST['suica_activate']) ? $_POST['suica_activate'] : '';
1268 $options['acting_settings']['jpayment']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1269 $options['acting_settings']['jpayment']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1270
1271 if( WCUtils::is_blank($_POST['aid']) )
1272 $mes .= '※店舗IDコードを�
1273 �力して下さい<br />';
1274 if( isset($_POST['card_activate']) && 'on' == $_POST['card_activate'] && empty($_POST['card_jb']) )
1275 $mes .= '※ジョブタイプを指定して下さい<br />';
1276
1277 if( WCUtils::is_blank($mes) ){
1278 $this->action_status = 'success';
1279 $this->action_message = __('options are updated','usces');
1280 $options['acting_settings']['jpayment']['activate'] = 'on';
1281 if( 'on' == $options['acting_settings']['jpayment']['card_activate'] ){
1282 $this->payment_structure['acting_jpayment_card'] = 'カード決済(J-Payment)';
1283 }else{
1284 unset($this->payment_structure['acting_jpayment_card']);
1285 }
1286 if( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ){
1287 $this->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(J-Payment)';
1288 }else{
1289 unset($this->payment_structure['acting_jpayment_conv']);
1290 }
1291 //if( 'on' == $options['acting_settings']['jpayment']['webm_activate'] ){
1292 // $this->payment_structure['acting_jpayment_webm'] = 'WebMoney決済(J-Payment)';
1293 //}else{
1294 // unset($this->payment_structure['acting_jpayment_webm']);
1295 //}
1296 //if( 'on' == $options['acting_settings']['jpayment']['bitc_activate'] ){
1297 // $this->payment_structure['acting_jpayment_bitc'] = 'BitCash決済(J-Payment)';
1298 //}else{
1299 // unset($this->payment_structure['acting_jpayment_bitc']);
1300 //}
1301 //if( 'on' == $options['acting_settings']['jpayment']['suica_activate'] ){
1302 // $this->payment_structure['acting_jpayment_suica'] = 'モバイルSuica決済(J-Payment)';
1303 //}else{
1304 // unset($this->payment_structure['acting_jpayment_suica']);
1305 //}
1306 if( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ){
1307 $this->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(J-Payment)';
1308 }else{
1309 unset($this->payment_structure['acting_jpayment_bank']);
1310 }
1311 update_option('usces', $options);
1312 }else{
1313 $this->action_status = 'error';
1314 $this->action_message = __('Data have deficiency.', 'usces');
1315 $options['acting_settings']['jpayment']['activate'] = 'off';
1316 unset($this->payment_structure['acting_jpayment_card']);
1317 unset($this->payment_structure['acting_jpayment_conv']);
1318 //unset($this->payment_structure['acting_jpayment_webm']);
1319 //unset($this->payment_structure['acting_jpayment_bitc']);
1320 //unset($this->payment_structure['acting_jpayment_suica']);
1321 unset($this->payment_structure['acting_jpayment_bank']);
1322 }
1323 ksort($this->payment_structure);
1324 update_option('usces_payment_structure', $this->payment_structure);
1325 break;
1326 //20101018ysk end
1327 //20110208ysk start
1328 case 'paypal':
1329 unset( $options['acting_settings']['paypal'] );
1330 $options['acting_settings']['paypal']['ec_activate'] = isset($_POST['ec_activate']) ? $_POST['ec_activate'] : '';
1331 $options['acting_settings']['paypal']['sandbox'] = isset($_POST['sandbox']) ? $_POST['sandbox'] : '';
1332 $options['acting_settings']['paypal']['user'] = isset($_POST['user']) ? $_POST['user'] : '';
1333 $options['acting_settings']['paypal']['pwd'] = isset($_POST['pwd']) ? $_POST['pwd'] : '';
1334 $options['acting_settings']['paypal']['signature'] = isset($_POST['signature']) ? $_POST['signature'] : '';
1335 //20110412ysk start
1336 $options['acting_settings']['paypal']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1337 //20110412ysk end
1338 $options['acting_settings']['paypal']['logoimg'] = isset($_POST['logoimg']) ? $_POST['logoimg'] : '';
1339 $options['acting_settings']['paypal']['set_cartbordercolor'] = isset($_POST['set_cartbordercolor']) ? $_POST['set_cartbordercolor'] : 'off';
1340 $options['acting_settings']['paypal']['cartbordercolor'] = ( 'on' == $options['acting_settings']['paypal']['set_cartbordercolor'] ) ? $_POST['cartbordercolor'] : '';
1341
1342 if( !isset($_POST['sandbox']) || empty($_POST['sandbox']) )
1343 $mes .= '※動作環境が不正です<br />';
1344 if( WCUtils::is_blank($_POST['user']) )
1345 $mes .= '※APIユーザー名を�
1346 �力して下さい<br />';
1347 if( WCUtils::is_blank($_POST['pwd']) )
1348 $mes .= '※APIパスワードを�
1349 �力して下さい<br />';
1350 if( WCUtils::is_blank($_POST['signature']) )
1351 $mes .= '※署名を�
1352 �力して下さい<br />';
1353
1354 if( WCUtils::is_blank($mes) ){
1355 $this->action_status = 'success';
1356 $this->action_message = __('options are updated','usces');
1357 if($options['acting_settings']['paypal']['sandbox'] == 1) {
1358 $options['acting_settings']['paypal']['api_host'] = 'api-3t.sandbox.paypal.com';
1359 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.sandbox.paypal.com/nvp';
1360 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
1361 } else {
1362 $options['acting_settings']['paypal']['api_host'] = 'api-3t.paypal.com';
1363 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.paypal.com/nvp';
1364 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.paypal.com/cgi-bin/webscr';
1365 }
1366 $options['acting_settings']['paypal']['activate'] = 'on';
1367 if( 'on' == $options['acting_settings']['paypal']['ec_activate'] ){
1368 $this->payment_structure['acting_paypal_ec'] = 'PayPal決済';
1369 }else{
1370 unset($this->payment_structure['acting_paypal_ec']);
1371 }
1372 update_option('usces', $options);
1373 }else{
1374 $this->action_status = 'error';
1375 $this->action_message = __('Data have deficiency.', 'usces');
1376 $options['acting_settings']['paypal']['activate'] = 'off';
1377 unset($this->payment_structure['acting_paypal_ec']);
1378 }
1379 ksort($this->payment_structure);
1380 update_option('usces_payment_structure', $this->payment_structure);
1381 break;
1382 //20110208ysk end
1383 //20120413ysk start
1384 case 'sbps':
1385 unset( $options['acting_settings']['sbps'] );
1386 $options['acting_settings']['sbps']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : '';
1387 $options['acting_settings']['sbps']['service_id'] = isset($_POST['service_id']) ? $_POST['service_id'] : '';
1388 $options['acting_settings']['sbps']['hash_key'] = isset($_POST['hash_key']) ? $_POST['hash_key'] : '';
1389 $options['acting_settings']['sbps']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1390 //$options['acting_settings']['sbps']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1391 $options['acting_settings']['sbps']['send_url_check'] = isset($_POST['send_url_check']) ? $_POST['send_url_check'] : '';
1392 $options['acting_settings']['sbps']['send_url_test'] = isset($_POST['send_url_test']) ? $_POST['send_url_test'] : '';
1393 $options['acting_settings']['sbps']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1394 $options['acting_settings']['sbps']['3d_secure'] = isset($_POST['3d_secure']) ? $_POST['3d_secure'] : '';
1395 $options['acting_settings']['sbps']['cust'] = isset($_POST['cust']) ? $_POST['cust'] : '';
1396 $options['acting_settings']['sbps']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1397 $options['acting_settings']['sbps']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1398 $options['acting_settings']['sbps']['payeasy_activate'] = isset($_POST['payeasy_activate']) ? $_POST['payeasy_activate'] : '';
1399 $options['acting_settings']['sbps']['wallet_yahoowallet'] = isset($_POST['wallet_yahoowallet']) ? $_POST['wallet_yahoowallet'] : '';
1400 $options['acting_settings']['sbps']['wallet_rakuten'] = isset($_POST['wallet_rakuten']) ? $_POST['wallet_rakuten'] : '';
1401 $options['acting_settings']['sbps']['wallet_paypal'] = isset($_POST['wallet_paypal']) ? $_POST['wallet_paypal'] : '';
1402 $options['acting_settings']['sbps']['wallet_netmile'] = isset($_POST['wallet_netmile']) ? $_POST['wallet_netmile'] : '';
1403 $options['acting_settings']['sbps']['wallet_alipay'] = isset($_POST['wallet_alipay']) ? $_POST['wallet_alipay'] : '';
1404 $options['acting_settings']['sbps']['mobile_docomo'] = isset($_POST['mobile_docomo']) ? $_POST['mobile_docomo'] : '';
1405 $options['acting_settings']['sbps']['mobile_softbank'] = isset($_POST['mobile_softbank']) ? $_POST['mobile_softbank'] : '';
1406 $options['acting_settings']['sbps']['mobile_auone'] = isset($_POST['mobile_auone']) ? $_POST['mobile_auone'] : '';
1407 $options['acting_settings']['sbps']['mobile_mysoftbank'] = isset($_POST['mobile_mysoftbank']) ? $_POST['mobile_mysoftbank'] : '';
1408 $options['acting_settings']['sbps']['mobile_softbank2'] = isset($_POST['mobile_softbank2']) ? $_POST['mobile_softbank2'] : '';
1409
1410 if( WCUtils::is_blank($_POST['merchant_id']) )
1411 $mes .= '※マーチャントIDを�
1412 �力して下さい<br />';
1413 if( WCUtils::is_blank($_POST['service_id']) )
1414 $mes .= '※サービスIDを�
1415 �力して下さい<br />';
1416 if( WCUtils::is_blank($_POST['hash_key']) )
1417 $mes .= '※Hash KEYを�
1418 �力して下さい<br />';
1419 //if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1420 // $mes .= '※本番URLを�
1421 �力して下さい<br />';
1422
1423 if( WCUtils::is_blank($mes) ){
1424 $this->action_status = 'success';
1425 $this->action_message = __('options are updated','usces');
1426 $options['acting_settings']['sbps']['activate'] = 'on';
1427 if( isset($_POST['ope']) && 'public' == $_POST['ope'] ) {
1428 $options['acting_settings']['sbps']['send_url'] = 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do';
1429 }
1430 if( 'on' == $options['acting_settings']['sbps']['card_activate'] ){
1431 $this->payment_structure['acting_sbps_card'] = 'カード決済(ソフトバンク・ペイメント)';
1432 }else{
1433 unset($this->payment_structure['acting_sbps_card']);
1434 }
1435 if( 'on' == $options['acting_settings']['sbps']['conv_activate'] ){
1436 $this->payment_structure['acting_sbps_conv'] = 'コンビニ決済(ソフトバンク・ペイメント)';
1437 }else{
1438 unset($this->payment_structure['acting_sbps_conv']);
1439 }
1440 if( 'on' == $options['acting_settings']['sbps']['payeasy_activate'] ){
1441 $this->payment_structure['acting_sbps_payeasy'] = 'ペイジー決済(ソフトバンク・ペイメント)';
1442 }else{
1443 unset($this->payment_structure['acting_sbps_payeasy']);
1444 }
1445 if( ( 'on' == $options['acting_settings']['sbps']['wallet_yahoowallet'] ) ||
1446 ( 'on' == $options['acting_settings']['sbps']['wallet_rakuten'] ) ||
1447 ( 'on' == $options['acting_settings']['sbps']['wallet_paypal'] ) ||
1448 ( 'on' == $options['acting_settings']['sbps']['wallet_netmile'] ) ||
1449 ( 'on' == $options['acting_settings']['sbps']['wallet_alipay'] ) ) {
1450 $options['acting_settings']['sbps']['wallet_activate'] = 'on';
1451 } else {
1452 $options['acting_settings']['sbps']['wallet_activate'] = 'off';
1453 }
1454 if( 'on' == $options['acting_settings']['sbps']['wallet_activate'] ){
1455 $this->payment_structure['acting_sbps_wallet'] = 'ウォレット決済(ソフトバンク・ペイメント)';
1456 }else{
1457 unset($this->payment_structure['acting_sbps_wallet']);
1458 }
1459 if( ( 'on' == $options['acting_settings']['sbps']['mobile_docomo'] ) ||
1460 ( 'on' == $options['acting_settings']['sbps']['mobile_softbank'] ) ||
1461 ( 'on' == $options['acting_settings']['sbps']['mobile_auone'] ) ||
1462 ( 'on' == $options['acting_settings']['sbps']['mobile_mysoftbank'] ) ||
1463 ( 'on' == $options['acting_settings']['sbps']['mobile_softbank2'] ) ) {
1464 $options['acting_settings']['sbps']['mobile_activate'] = 'on';
1465 } else {
1466 $options['acting_settings']['sbps']['mobile_activate'] = 'off';
1467 }
1468 if( 'on' == $options['acting_settings']['sbps']['mobile_activate'] ){
1469 $this->payment_structure['acting_sbps_mobile'] = '携帯キャリア決済(ソフトバンク・ペイメント)';
1470 }else{
1471 unset($this->payment_structure['acting_sbps_mobile']);
1472 }
1473 update_option('usces', $options);
1474 }else{
1475 $this->action_status = 'error';
1476 $this->action_message = __('Data have deficiency.','usces');
1477 $options['acting_settings']['sbps']['activate'] = 'off';
1478 unset($this->payment_structure['acting_sbps_card']);
1479 unset($this->payment_structure['acting_sbps_conv']);
1480 unset($this->payment_structure['acting_sbps_payeasy']);
1481 unset($this->payment_structure['acting_sbps_wallet']);
1482 unset($this->payment_structure['acting_sbps_mobile']);
1483 }
1484 ksort($this->payment_structure);
1485 update_option('usces_payment_structure', $this->payment_structure);
1486 break;
1487 //20120413ysk end
1488 //20120618ysk start
1489 case 'telecom':
1490 unset( $options['acting_settings']['telecom'] );
1491 $options['acting_settings']['telecom']['clientip'] = isset($_POST['clientip']) ? $_POST['clientip'] : '';
1492 $options['acting_settings']['telecom']['stype'] = isset($_POST['stype']) ? $_POST['stype'] : '';
1493 $options['acting_settings']['telecom']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1494 $options['acting_settings']['telecom']['edy_activate'] = isset($_POST['edy_activate']) ? $_POST['edy_activate'] : '';
1495
1496 if( WCUtils::is_blank($_POST['clientip']) )
1497 $mes .= '※クライアントIPを�
1498 �力して下さい<br />';
1499 if( WCUtils::is_blank($_POST['stype']) )
1500 $mes .= '※決済タイプを�
1501 �力して下さい<br />';
1502
1503 if( WCUtils::is_blank($mes) ){
1504 $this->action_status = 'success';
1505 $this->action_message = __('options are updated','usces');
1506 $options['acting_settings']['telecom']['activate'] = 'on';
1507 if( 'on' == $options['acting_settings']['telecom']['card_activate'] ){
1508 if( 'E' == $options['acting_settings']['telecom']['stype'][0] ) {
1509 $options['acting_settings']['telecom']['send_url'] = "https://www.credit-cgiserver.com/inetcredit/secure/order.pl";
1510 } else {
1511 $options['acting_settings']['telecom']['send_url'] = "https://secure.telecomcredit.co.jp/inetcredit/secure/order.pl";
1512 }
1513 $this->payment_structure['acting_telecom_card'] = 'カード決済(テレコムクレジット)';
1514 }else{
1515 unset($this->payment_structure['acting_telecom_card']);
1516 }
1517 if( 'on' == $options['acting_settings']['telecom']['edy_activate'] ){
1518 $options['acting_settings']['telecom']['send_url_edy'] = "https://secure.telecomcredit.co.jp/payment/edy/order.pl";
1519 $this->payment_structure['acting_telecom_edy'] = 'Edy決済(テレコムクレジット)';
1520 }else{
1521 unset($this->payment_structure['acting_telecom_edy']);
1522 }
1523 update_option('usces', $options);
1524 }else{
1525 $this->action_status = 'error';
1526 $this->action_message = __('Data have deficiency.','usces');
1527 $options['acting_settings']['telecom']['activate'] = 'off';
1528 unset($this->payment_structure['acting_telecom_card']);
1529 unset($this->payment_structure['acting_telecom_edy']);
1530 }
1531 ksort($this->payment_structure);
1532 update_option('usces_payment_structure', $this->payment_structure);
1533 break;
1534 //20120618ysk end
1535 //20121206ysk start
1536 case 'digitalcheck':
1537 unset( $options['acting_settings']['digitalcheck'] );
1538 $options['acting_settings']['digitalcheck']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1539 $options['acting_settings']['digitalcheck']['card_ip'] = isset($_POST['card_ip']) ? $_POST['card_ip'] : '';
1540 $options['acting_settings']['digitalcheck']['card_pass'] = isset($_POST['card_pass']) ? $_POST['card_pass'] : '';
1541 $options['acting_settings']['digitalcheck']['card_kakutei'] = isset($_POST['card_kakutei']) ? $_POST['card_kakutei'] : '';
1542 $options['acting_settings']['digitalcheck']['card_user_id'] = isset($_POST['card_user_id']) ? $_POST['card_user_id'] : '';
1543 $options['acting_settings']['digitalcheck']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1544 $options['acting_settings']['digitalcheck']['conv_ip'] = isset($_POST['conv_ip']) ? $_POST['conv_ip'] : '';
1545 $options['acting_settings']['digitalcheck']['conv_store'] = isset($_POST['conv_store']) ? $_POST['conv_store'] : array();
1546 $options['acting_settings']['digitalcheck']['conv_kigen'] = isset($_POST['conv_kigen']) ? $_POST['conv_kigen'] : '14';
1547
1548 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) {
1549 if( '' == trim($_POST['card_ip']) )
1550 $mes .= '※加盟店コードを�
1551 �力して下さい<br />';
1552 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1553 if( '' == trim($_POST['card_pass']) )
1554 $mes .= '※加盟店パスワードを�
1555 �力して下さい<br />';
1556 }
1557 }
1558 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
1559 if( '' == trim($_POST['conv_ip']) )
1560 $mes .= '※加盟店コードを�
1561 �力して下さい<br />';
1562 if( empty($_POST['conv_store']) )
1563 $mes .= '※利用コンビニを選択して下さい<br />';
1564 }
1565
1566 if( '' == $mes ){
1567 $this->action_status = 'success';
1568 $this->action_message = __('options are updated','usces');
1569 $options['acting_settings']['digitalcheck']['activate'] = 'on';
1570 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ){
1571 $options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
1572 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1573 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.paydesign.jp/settle/settlex/credit2.dll";
1574 } else {
1575 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "";
1576 }
1577 $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(ペイデザイン)';
1578 }else{
1579 unset($this->payment_structure['acting_digitalcheck_card']);
1580 }
1581 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ){
1582 $options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
1583 $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(ペイデザイン)';
1584 }else{
1585 unset($this->payment_structure['acting_digitalcheck_conv']);
1586 }
1587 update_option('usces', $options);
1588 if( 'on' != $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1589 usces_clear_quickcharge( 'digitalcheck_ip_user_id' );
1590 }
1591 }else{
1592 $this->action_status = 'error';
1593 $this->action_message = __('Data have deficiency.','usces');
1594 $options['acting_settings']['digitalcheck']['activate'] = 'off';
1595 unset($this->payment_structure['acting_digitalcheck_card']);
1596 unset($this->payment_structure['acting_digitalcheck_conv']);
1597 }
1598 ksort($this->payment_structure);
1599 update_option('usces_payment_structure', $this->payment_structure);
1600 break;
1601 //20121206ysk end
1602 //20130225ysk start
1603 case 'mizuho':
1604 unset( $options['acting_settings']['mizuho'] );
1605 $options['acting_settings']['mizuho']['shopid'] = isset($_POST['shopid']) ? $_POST['shopid'] : '';
1606 $options['acting_settings']['mizuho']['cshopid'] = isset($_POST['cshopid']) ? $_POST['cshopid'] : '';
1607 $options['acting_settings']['mizuho']['hash_pass'] = isset($_POST['hash_pass']) ? $_POST['hash_pass'] : '';
1608 $options['acting_settings']['mizuho']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1609 $options['acting_settings']['mizuho']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1610 $options['acting_settings']['mizuho']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1611 $options['acting_settings']['mizuho']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1612 $options['acting_settings']['mizuho']['conv1_activate'] = isset($_POST['conv1_activate']) ? $_POST['conv1_activate'] : '';
1613 $options['acting_settings']['mizuho']['conv2_activate'] = isset($_POST['conv2_activate']) ? $_POST['conv2_activate'] : '';
1614
1615 //if( 'on' == $options['acting_settings']['mizuho']['card_activate'] or 'on' == $options['acting_settings']['mizuho']['conv_activate'] ) {
1616 if( '' == trim($_POST['shopid']) )
1617 $mes .= '※加盟店コードを�
1618 �力して下さい<br />';
1619 if( '' == trim($_POST['cshopid']) )
1620 $mes .= '※加盟店サブコードを�
1621 �力して下さい<br />';
1622 if( '' == trim($_POST['hash_pass']) )
1623 $mes .= '※ハッシュ用パスワードを�
1624 �力して下さい<br />';
1625 //}
1626 if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1627 $mes .= '※本番URLを�
1628 �力して下さい<br />';
1629 if( defined('WCEX_MOBILE') and isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url_mbl']) )
1630 $mes .= '※本番URL(携帯)を�
1631 �力して下さい<br />';
1632
1633 if( '' == $mes ) {
1634 $this->action_status = 'success';
1635 $this->action_message = __('options are updated','usces');
1636 $options['acting_settings']['mizuho']['activate'] = 'on';
1637 $options['acting_settings']['mizuho']['send_url_test'] = "https://210.161.141.207/mltbank/MBWebFrontPayment";
1638 if( defined('WCEX_MOBILE') ) $options['acting_settings']['mizuho']['send_url_mbl_test'] = "https://210.161.141.207/mltbank/iMBWebFrontPayment";
1639 if( 'on' == $options['acting_settings']['mizuho']['card_activate'] ) {
1640 $this->payment_structure['acting_mizuho_card'] = 'カード決済(みずほファクター)';
1641 } else {
1642 unset($this->payment_structure['acting_mizuho_card']);
1643 }
1644 if( 'on' == $options['acting_settings']['mizuho']['conv1_activate'] ) {
1645 $this->payment_structure['acting_mizuho_conv1'] = 'コンビニ・ウェルネット決済(みずほファクター)';
1646 } else {
1647 unset($this->payment_structure['acting_mizuho_conv1']);
1648 }
1649 if( 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) {
1650 $this->payment_structure['acting_mizuho_conv2'] = 'コンビニ・セブンイレブン決済(みずほファクター)';
1651 } else {
1652 unset($this->payment_structure['acting_mizuho_conv2']);
1653 }
1654 update_option('usces', $options);
1655 } else {
1656 $this->action_status = 'error';
1657 $this->action_message = __('Data have deficiency.','usces');
1658 $options['acting_settings']['mizuho']['activate'] = 'off';
1659 unset($this->payment_structure['acting_mizuho_card']);
1660 unset($this->payment_structure['acting_mizuho_conv1']);
1661 unset($this->payment_structure['acting_mizuho_conv2']);
1662 }
1663 ksort($this->payment_structure);
1664 update_option('usces_payment_structure', $this->payment_structure);
1665 break;
1666 //20130225ysk end
1667 //20131220ysk start
1668 case 'anotherlane':
1669 unset( $options['acting_settings']['anotherlane'] );
1670 $options['acting_settings']['anotherlane']['siteid'] = isset($_POST['siteid']) ? $_POST['siteid'] : '';
1671 $options['acting_settings']['anotherlane']['sitepass'] = isset($_POST['sitepass']) ? $_POST['sitepass'] : '';
1672 $options['acting_settings']['anotherlane']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : '';
1673 $options['acting_settings']['anotherlane']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1674
1675 if( WCUtils::is_blank($_POST['siteid']) )
1676 $mes .= '※サイトIDを�
1677 �力して下さい<br />';
1678 if( WCUtils::is_blank($_POST['sitepass']) )
1679 $mes .= '※サイトパスワードを�
1680 �力して下さい<br />';
1681
1682 if( WCUtils::is_blank($mes) ) {
1683 $this->action_status = 'success';
1684 $this->action_message = __('options are updated','usces');
1685 $options['acting_settings']['anotherlane']['activate'] = 'on';
1686 if( 'on' == $options['acting_settings']['anotherlane']['card_activate'] ) {
1687 $options['acting_settings']['anotherlane']['send_url'] = "https://credit.alij.ne.jp/service/credit/input.html";
1688 $this->payment_structure['acting_anotherlane_card'] = 'カード決済(アナザーレーン)';
1689 } else {
1690 unset( $this->payment_structure['acting_anotherlane_card'] );
1691 }
1692 update_option( 'usces', $options );
1693 } else {
1694 $this->action_status = 'error';
1695 $this->action_message = __('Data have deficiency.','usces');
1696 $options['acting_settings']['anotherlane']['activate'] = 'off';
1697 unset( $this->payment_structure['acting_anotherlane_card'] );
1698 }
1699 ksort( $this->payment_structure );
1700 update_option( 'usces_payment_structure', $this->payment_structure );
1701 break;
1702 //20131220ysk end
1703 //20140206ysk start
1704 case 'veritrans':
1705 unset( $options['acting_settings']['veritrans'] );
1706 $options['acting_settings']['veritrans']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : '';
1707 $options['acting_settings']['veritrans']['merchanthash'] = isset($_POST['merchanthash']) ? $_POST['merchanthash'] : '';
1708 $options['acting_settings']['veritrans']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1709 $options['acting_settings']['veritrans']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1710 $options['acting_settings']['veritrans']['card_capture_flag'] = isset($_POST['card_capture_flag']) ? $_POST['card_capture_flag'] : '';
1711 $options['acting_settings']['veritrans']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1712
1713 if( WCUtils::is_blank($options['acting_settings']['veritrans']['merchant_id']) )
1714 $mes .= '※マーチャントIDを�
1715 �力して下さい<br />';
1716 if( WCUtils::is_blank($options['acting_settings']['veritrans']['merchanthash']) )
1717 $mes .= '※マーチャントハッシュキーを�
1718 �力して下さい<br />';
1719 if( WCUtils::is_blank($options['acting_settings']['veritrans']['ope']) )
1720 $mes .= '※稼働環境を選択して下さい<br />';
1721 if( 'on' == $options['acting_settings']['veritrans']['card_activate'] ) {
1722 if( WCUtils::is_blank($options['acting_settings']['veritrans']['card_capture_flag']) )
1723 $mes .= '※カード売上フラグを選択して下さい<br />';
1724 }
1725
1726 if( WCUtils::is_blank($mes) ) {
1727 $this->action_status = 'success';
1728 $this->action_message = __('options are updated','usces');
1729 $options['acting_settings']['veritrans']['activate'] = 'on';
1730 $options['acting_settings']['veritrans']['regist_url'] = "https://air.veritrans.co.jp/web/commodityRegist.action";
1731 $options['acting_settings']['veritrans']['payment_url'] = "https://air.veritrans.co.jp/web/paymentStart.action";
1732 if( 'on' == $options['acting_settings']['veritrans']['card_activate'] ) {
1733 $this->payment_structure['acting_veritrans_card'] = 'カード決済(ベリトランス)';
1734 } else {
1735 unset($this->payment_structure['acting_veritrans_card']);
1736 }
1737 if( 'on' == $options['acting_settings']['veritrans']['conv_activate'] ) {
1738 $this->payment_structure['acting_veritrans_conv'] = 'コンビニ決済(ベリトランス)';
1739 } else {
1740 unset($this->payment_structure['acting_veritrans_conv']);
1741 }
1742 update_option('usces', $options);
1743 } else {
1744 $this->action_status = 'error';
1745 $this->action_message = __('Data have deficiency.','usces');
1746 $options['acting_settings']['veritrans']['activate'] = 'off';
1747 unset($this->payment_structure['acting_veritrans_card']);
1748 unset($this->payment_structure['acting_veritrans_conv']);
1749 }
1750 ksort($this->payment_structure);
1751 update_option('usces_payment_structure', $this->payment_structure);
1752 break;
1753 //20140206ysk end
1754 }
1755
1756 }
1757
1758 $this->options = get_option('usces');
1759
1760 require_once(USCES_PLUGIN_DIR . '/includes/admin_settlement.php');
1761 }
1762
1763 /********************************************************************************/
1764 function selected( $selected, $current) {
1765 if ( $selected == $current)
1766 echo ' selected="selected"';
1767 }
1768 /********************************************************************************/
1769
1770 function usces_session_start() {
1771 $options = get_option('usces');
1772 if( !isset($options['usces_key']) || empty($options['usces_key']) ){
1773 $options['usces_key'] = uniqid('uk');
1774 update_option('usces', $options);
1775 }
1776
1777 if(defined( 'USCES_KEY' )){
1778 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1779 session_name( 'adm'.USCES_KEY );
1780 }else{
1781 session_name( USCES_KEY );
1782 }
1783 }else{
1784 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1785 session_name( 'adm'.$options['usces_key'] );
1786 }else{
1787 session_name( $options['usces_key'] );
1788 }
1789 }
1790 if(isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid'])) {
1791 $sessid = $_GET['uscesid'];
1792 $sessid = $this->uscesdc($sessid);
1793 session_id($sessid);
1794 }
1795
1796 @session_start();
1797
1798 //20111222ysk start 0000367
1799 //if ( !isset($_SESSION['usces_member']) ){
1800 if ( !isset($_SESSION['usces_member']) || $options['membersystem_state'] != 'activate' ){
1801 //20111222ysk end
1802 $_SESSION['usces_member'] = array();
1803 }
1804
1805 if(!isset($_SESSION['usces_checked_business_days']))
1806 $this->update_business_days();
1807 }
1808
1809 function usces_cookie() {
1810 if(is_admin()) return;
1811
1812 $actionflag = false;
1813 $sess = NULL;
1814 $addr = NULL;
1815 $rckid = NULL;
1816 $none = NULL;
1817 $cookie = $this->get_cookie();
1818
1819 if( isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid']) ){
1820 $sessid = base64_decode(urldecode($_GET['uscesid']));
1821 list($sess, $addr, $rckid, $none) = explode('_', $sessid, 4);
1822 }
1823 if('acting' == $addr) return;
1824
1825 if( apply_filters( 'usces_filter_cookie', false) ) return;
1826
1827 //There is a need to consider.
1828 return;
1829
1830 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
1831
1832 $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
1833 $sslid = isset($cookie['sslid']) ? $cookie['sslid'] : NULL;
1834 $option = get_option('usces');
1835 $parsed = parse_url(get_option('home'));
1836 $home = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1837 $parsed = parse_url($option['ssl_url']);
1838 $sslhome = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1839
1840 //usces_log('refer : '.$refer, 'acting_transaction.log');
1841 // usces_log('sslid : '.$sslid, 'acting_transaction.log');
1842 // usces_log('rckid : '.$rckid, 'acting_transaction.log');
1843 // usces_log('usces_cookieid : '.$_SESSION['usces_cookieid'], 'acting_transaction.log');
1844 // usces_log('request : '.print_r($_SERVER['REQUEST_URI'],true), 'acting_transaction.log');
1845
1846 if( empty($refer) || (false === strpos($refer, $home) && false === strpos($refer, $sslhome)) ){
1847 if( !empty($sslid) && !empty($rckid) && $sslid === $rckid ){
1848 $actionflag = true;
1849 }else{
1850 $actionflag = false;
1851 }
1852 }else{
1853 if( !empty($sslid) && $sslid !== $rckid ){
1854 $actionflag = false;
1855 }else{
1856 $actionflag = true;
1857 }
1858 }
1859
1860
1861 if( $actionflag ){
1862 $values = array(
1863 'id' => $rckid,
1864 'sslid' => $rckid,
1865 'name' => '',
1866 'rme' => ''
1867 );
1868 if( 'acting' !== $rckid ){
1869 $this->set_cookie($values);
1870 }
1871 }else{
1872 if( 'acting' !== $rckid ){
1873 unset($_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] );
1874 wp_redirect( 'http://'.$home );
1875 }
1876 }
1877 }else{
1878 if( !isset($cookie['id']) || WCUtils::is_blank($cookie['id']) ) {
1879 $values = array(
1880 'id' => md5(uniqid(rand(), true)),
1881 'name' => '',
1882 'rme' => ''
1883 );
1884 $this->set_cookie($values);
1885 $_SESSION['usces_cookieid'] = $values['id'];
1886 } else {
1887 if( !isset($_SESSION['usces_cookieid']) || $_SESSION['usces_cookieid'] != $cookie['id'])
1888 $_SESSION['usces_cookieid'] = $cookie['id'];
1889 }
1890
1891 $actionflag = true;
1892 }
1893
1894 }
1895
1896 function set_cookie($values){
1897 $value = serialize($values);
1898 $timeout = time()+7*86400;
1899 $domain = $_SERVER['SERVER_NAME'];
1900 $res = setcookie('usces_cookie', $value, $timeout, USCES_COOKIEPATH, $domain);
1901 }
1902
1903 function get_cookie() {
1904 $values = isset($_COOKIE['usces_cookie']) ? unserialize(stripslashes($_COOKIE['usces_cookie'])) : NULL;
1905 return $values;
1906 }
1907
1908 function get_access( $key, $type, $date ) {
1909 global $wpdb;
1910 $table_name = $wpdb->prefix . "usces_access";
1911
1912 $query = $wpdb->prepare("SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date);
1913 $value = $wpdb->get_var( $query );
1914 if( !$value ){
1915 $res = NULL;
1916 }else{
1917 $res = unserialize($value);
1918 }
1919
1920 return $res;
1921 }
1922
1923 function get_access_piriod( $key, $type, $startday, $endday ) {
1924 global $wpdb;
1925 $table_name = $wpdb->prefix . "usces_access";
1926 //$wpdb->show_errors();
1927 $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);
1928 $res = $wpdb->get_results( $query, ARRAY_A );
1929
1930 return $res;
1931 }
1932
1933 function update_access( $array ) {
1934 global $wpdb;
1935 $table_name = $wpdb->prefix . "usces_access";
1936
1937 $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']);
1938 $res = $wpdb->get_var( $query );
1939 //$wpdb->show_errors();
1940 if(empty($res)){
1941 $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']);
1942 $wpdb->query( $query );
1943 }else{
1944 $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']);
1945 $wpdb->query( $query );
1946 }
1947 }
1948
1949 function get_uscesid( $flag = true) {
1950
1951 $sessname = session_name();
1952 $sessid = session_id();
1953 $sessid = $this->uscescv($sessid, $flag);
1954 return $sessid;
1955 }
1956
1957 function shop_head() {
1958 global $post;
1959 $this->item = $post;
1960 $no_cart_css = isset($this->options['system']['no_cart_css']) ? $this->options['system']['no_cart_css'] : 0;
1961
1962 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1963 $css_url = USCES_FRONT_PLUGIN_URL . '/css/usces_cart.css';
1964 }else{
1965 $css_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/css/usces_cart.css';
1966 }
1967 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) ){
1968 echo " <meta name='robots' content='noindex,nofollow' />\n";
1969 wp_print_scripts( array( 'sack' ));
1970 }
1971 if( !$no_cart_css ){
1972 echo '<link href="' . $css_url . '" rel="stylesheet" type="text/css" />';
1973 }
1974 if( file_exists(get_stylesheet_directory() . '/usces_cart.css') ){
1975 echo '<link href="' . get_stylesheet_directory_uri() . '/usces_cart.css" rel="stylesheet" type="text/css" />';
1976 }
1977 }
1978
1979 function shop_foot() {
1980 global $current_user;
1981 $item = $this->item;
1982 if( empty($item) ){
1983 $item->ID = 0;
1984 $item->post_mime_type = '';
1985 }
1986 get_currentuserinfo();
1987 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1988 $javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js';
1989 }else{
1990 $javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js';
1991 }
1992 // $this->member_name = ( is_user_logged_in() ) ? esc_js(get_user_meta($current_user->ID,'first_name').get_user_meta($current_user->ID,'last_name')) : '';
1993 $this->previous_url = isset($_SESSION['usces_previous_url']) ? $_SESSION['usces_previous_url'] : get_home_url();
1994
1995 // usces_log('post_type : '.$item->post_mime_type, 'test.log');
1996 // usces_log('is_single : '.(is_single() ? 'true' : 'false'), 'test.log');
1997
1998 if( $this->use_js && empty($this->item) && !is_admin() ) :
1999 ?>
2000 <script type='text/javascript'>
2001 /* <![CDATA[ */
2002 uscesL10n = {
2003 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
2004 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>"
2005 }
2006 /* ]]> */
2007 </script>
2008 <?php elseif( $this->use_js && !empty($this->item) ) :
2009
2010 $ioptkeys = $this->get_itemOptionKey( $item->ID );
2011 $mes_opts_str = "";
2012 $key_opts_str = "";
2013 $opt_means = "";
2014 $opt_esse = "";
2015 if($ioptkeys){
2016 foreach($ioptkeys as $key => $value){
2017 $optValues = $this->get_itemOptions( $value, $item->ID );
2018 if($optValues['means'] < 2){
2019 $mes_opts_str .= "'" . sprintf(__("Chose the %s", 'usces'), esc_js($value)) . "',";
2020 }else{
2021 $mes_opts_str .= "'" . sprintf(__("Input the %s", 'usces'), esc_js($value)) . "',";
2022 }
2023 $key_opts_str .= "'" . urlencode(esc_js($value)) . "',";
2024 $opt_means .= "'" . esc_js($optValues['means']) . "',";
2025 $opt_esse .= "'" . esc_js($optValues['essential']) . "',";
2026 }
2027 $mes_opts_str = rtrim($mes_opts_str, ',');
2028 $key_opts_str = rtrim($key_opts_str, ',');
2029 $opt_means = rtrim($opt_means, ',');
2030 $opt_esse = rtrim($opt_esse, ',');
2031 }
2032 //$itemRestriction = get_post_custom_values('_itemRestriction', $item->ID);
2033 $itemRestriction = get_post_meta($item->ID, '_itemRestriction', true);
2034
2035 ?>
2036 <script type='text/javascript'>
2037 /* <![CDATA[ */
2038 uscesL10n = {
2039 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
2040 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>",
2041 'post_id': "<?php echo $item->ID; ?>",
2042 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
2043 'is_cart_row': <?php echo ( (0 < $this->cart->num_row()) ? 'true' : 'false'); ?>,
2044 'opt_esse': new Array( <?php echo $opt_esse; ?> ),
2045 'opt_means': new Array( <?php echo $opt_means; ?> ),
2046 'mes_opts': new Array( <?php echo $mes_opts_str; ?> ),
2047 'key_opts': new Array( <?php echo $key_opts_str; ?> ),
2048 'previous_url': "<?php echo $this->previous_url; ?>",
2049 'itemRestriction': "<?php echo $itemRestriction; ?>"
2050 }
2051 /* ]]> */
2052 </script>
2053 <script type='text/javascript' src='<?php echo $javascript_url; ?>'></script>
2054 <?php endif; ?>
2055 <?php ob_start(); ?>
2056 <?php if( $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || (is_singular() && 'item' == $item->post_mime_type)) ) : ?>
2057 <script type='text/javascript'>
2058 (function($) {
2059 uscesCart = {
2060 intoCart : function (post_id, sku) {
2061
2062 var zaikonum = document.getElementById("zaikonum["+post_id+"]["+sku+"]").value;
2063 var zaiko = document.getElementById("zaiko["+post_id+"]["+sku+"]").value;
2064 if( (zaiko != '0' && zaiko != '1') || parseInt(zaikonum) == 0 ){
2065 alert('<?php _e('temporaly out of stock now', 'usces'); ?>');
2066 return false;
2067 }
2068
2069 var mes = '';
2070 if(document.getElementById("quant["+post_id+"]["+sku+"]")){
2071 var quant = document.getElementById("quant["+post_id+"]["+sku+"]").value;
2072 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2073 mes += "<?php _e('enter the correct amount', 'usces'); ?>\n";
2074 }
2075 var checknum = '';
2076 var checkmode = '';
2077 if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
2078 checknum = uscesL10n.itemRestriction;
2079 checkmode ='rest';
2080 } else if( parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
2081 checknum = zaikonum;
2082 checkmode ='zaiko';
2083 } else if( (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) {
2084 checknum = zaikonum;
2085 checkmode ='zaiko';
2086 } else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum == '' ) {
2087 checknum = uscesL10n.itemRestriction;
2088 checkmode ='rest';
2089 }
2090
2091
2092 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2093 if(checkmode == 'rest'){
2094 mes += <?php _e("'This article is limited by '+checknum+' at a time.'", 'usces'); ?>+"\n";
2095 }else{
2096 mes += <?php _e("'Stock is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2097 }
2098 }
2099 }
2100 for(i=0; i<uscesL10n.key_opts.length; i++){
2101 var skuob = document.getElementById("itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]");
2102 if( uscesL10n.opt_esse[i] == '1' && null != skuob ){
2103
2104 if( uscesL10n.opt_means[i] < 2 && skuob.value == '#NONE#' ){
2105 mes += uscesL10n.mes_opts[i]+"\n";
2106 }else if( uscesL10n.opt_means[i] >= 2 && skuob.value == '' ){
2107 mes += uscesL10n.mes_opts[i]+"\n";
2108 }
2109 }
2110 }
2111
2112 <?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); //Unavailable ?>
2113 <?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?>
2114
2115 if( mes != '' ){
2116 alert( mes );
2117 return false;
2118 }else{
2119 <?php echo apply_filters('usces_filter_js_intoCart', "return true;\n", $item->ID, NULL); ?>
2120 }
2121 },
2122
2123 upCart : function () {
2124
2125 var zaikoob = $("input[name*='zaikonum']");
2126 var quantob = $("input[name*='quant']");
2127 var postidob = $("input[name*='itempostid']");
2128 var skuob = $("input[name*='itemsku']");
2129
2130 var zaikonum = '';
2131 var zaiko = '';
2132 var quant = '';
2133 var mes = '';
2134 var checknum = '';
2135 var post_id = '';
2136 var sku = '';
2137 var itemRestriction = '';
2138
2139 var ct = zaikoob.length;
2140 for(var i=0; i< ct; i++){
2141 post_id = postidob[i].value;
2142 sku = skuob[i].value;
2143 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2144 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2145
2146 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2147 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2148 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2149 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2150 }
2151 var checknum = '';
2152 var checkmode = '';
2153 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2154 checknum = itemRestriction;
2155 checkmode ='rest';
2156 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2157 checknum = zaikonum;
2158 checkmode ='zaiko';
2159 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2160 checknum = zaikonum;
2161 checkmode ='zaiko';
2162 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2163 checknum = itemRestriction;
2164 checkmode ='rest';
2165 }
2166 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2167 if(checkmode == 'rest'){
2168 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2169 }else{
2170 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2171 }
2172 }
2173 }
2174 }
2175
2176 <?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); //Unavailable ?>
2177 <?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?>
2178
2179 if( mes != '' ){
2180 alert( mes );
2181 return false;
2182 }else{
2183 <?php echo apply_filters('usces_filter_js_upCart', "return true;\n", $item->ID, NULL); ?>
2184 }
2185 },
2186
2187 cartNext : function () {
2188
2189 var zaikoob = $("input[name*='zaikonum']");
2190 var quantob = $("input[name*='quant']");
2191 var postidob = $("input[name*='itempostid']");
2192 var skuob = $("input[name*='itemsku']");
2193
2194 var zaikonum = '';
2195 var zaiko = '';
2196 var quant = '';
2197 var mes = '';
2198 var checknum = '';
2199 var post_id = '';
2200 var sku = '';
2201 var itemRestriction = '';
2202
2203 var ct = zaikoob.length;
2204 for(var i=0; i< ct; i++){
2205 post_id = postidob[i].value;
2206 sku = skuob[i].value;
2207 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2208 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2209
2210 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2211 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2212 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2213 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2214 }
2215 var checknum = '';
2216 var checkmode = '';
2217 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2218 checknum = itemRestriction;
2219 checkmode ='rest';
2220 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2221 checknum = zaikonum;
2222 checkmode ='zaiko';
2223 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2224 checknum = zaikonum;
2225 checkmode ='zaiko';
2226 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2227 checknum = itemRestriction;
2228 checkmode ='rest';
2229 }
2230
2231 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2232 if(checkmode == 'rest'){
2233 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2234 }else{
2235 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2236 }
2237 }
2238 }
2239 }
2240 if( mes != '' ){
2241 alert( mes );
2242 return false;
2243 }else{
2244 return true;
2245 }
2246 },
2247
2248 previousCart : function () {
2249 location.href = uscesL10n.previous_url;
2250 },
2251
2252 settings: {
2253 url: uscesL10n.ajaxurl,
2254 type: 'POST',
2255 cache: false,
2256 success: function(data, dataType){
2257 //$("tbody#item-opt-list").html( data );
2258 },
2259 error: function(msg){
2260 //$("#ajax-response").html(msg);
2261 }
2262 },
2263
2264 changeStates : function( country ) {
2265 var s = this.settings;
2266 s.data = "action=change_states_ajax&country=" + country;
2267 s.success = function(data, dataType){
2268 if( 'error' == data ){
2269 alert('error');
2270 }else{
2271 $("select#pref").html( data );
2272 }
2273 };
2274 s.error = function(msg){
2275 alert("error");
2276 };
2277 $.ajax( s );
2278 return false;
2279 },
2280
2281 isNum : function (num) {
2282 if (num.match(/[^0-9]/g)) {
2283 return false;
2284 }
2285 return true;
2286 },
2287 purchase : 0
2288 };
2289 $("#country").change(function () {
2290 var country = $("#country option:selected").val();
2291 $("#newcharging_type option:selected").val()
2292 uscesCart.changeStates( country );
2293 });
2294 $("#purchase_form").submit(function () {
2295 if( 0 == uscesCart.purchase ){
2296 uscesCart.purchase = 1;
2297 return true;
2298 }else{
2299 $("#purchase_button").attr("disabled", "disabled");
2300 $("#back_button").attr("disabled", "disabled");
2301 return false;
2302 }
2303 });
2304
2305 })(jQuery);
2306 </script>
2307 <?php endif; ?>
2308 <?php
2309 usces_states_form_js();
2310 $js = apply_filters( 'usces_filter_shop_foot_js', ob_get_contents() );
2311 ob_end_clean();
2312 echo $js;
2313
2314 }
2315
2316 function admin_head() {
2317 global $wp_version;
2318 $payments_str = '';
2319 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
2320 foreach ( (array)$payments as $id => $array ) {
2321 $payments_str .= "'" . esc_js($array['name']) . "': '" . esc_js($array['settlement']) . "', ";
2322 }
2323 $payments_str .= "'" . __('Transfer (prepayment)', 'usces') . "': 'transferAdvance', ";
2324 $payments_str .= "'" . __('Transfer (postpay)', 'usces') . "': 'transferDeferred', ";
2325 $payments_str .= "'" . __('COD', 'usces') . "': 'COD', ";
2326 $payments_str = rtrim($payments_str, ', ');
2327 $wcex_str = '';
2328 $wcex = usces_get_wcex();
2329 foreach ( (array)$wcex as $key => $values ) {
2330 $wcex_str .= "'" . esc_js($key) . "-" . esc_js($values['version']) . "', ";
2331 }
2332 $wcex_str = rtrim($wcex_str, ', ');
2333 if ( version_compare($wp_version, '3.4', '>=') ){
2334 $theme_ob = wp_get_theme();
2335 $theme['Name'] = esc_js($theme_ob->get('Name'));
2336 $theme['Version'] = esc_js($theme_ob->get('Version'));
2337 }else{
2338 $theme = get_theme_data( get_stylesheet_directory().'/style.css' );//20120618ysk
2339 }
2340 ?>
2341
2342 <link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" />
2343 <script type='text/javascript'>
2344 /* <![CDATA[ */
2345 uscesL10n = {
2346 <?php echo apply_filters('usces_filter_admin_uscesL10n', NULL ); ?>
2347 'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php",
2348 'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>",
2349 'version': "<?php echo USCES_VERSION; ?>",
2350 'wcid': "<?php echo get_option('usces_wcid'); ?>",
2351 'locale': '<?php echo get_locale(); ?>',
2352 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
2353 'purchase_limit': "<?php echo $this->options['purchase_limit']; ?>",
2354 'point_rate': "<?php echo $this->options['point_rate']; ?>",
2355 'shipping_rule': "<?php echo $this->options['shipping_rule']; ?>",
2356 'theme': "<?php echo $theme['Name'] . '-' . $theme['Version']; ?>",
2357 'wcex': new Array( <?php echo $wcex_str; ?> ),
2358 'now_loading': "<?php _e('now loading', 'usces'); ?>"
2359 };
2360 uscesPayments = {<?php echo $payments_str; ?>};
2361 /* ]]> */
2362 </script>
2363 <script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js'></script>
2364 <?php
2365 if($this->action_status == 'edit' || $this->action_status == 'editpost'){
2366 ?>
2367 <link rel='stylesheet' href='<?php echo site_url(); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' />
2368 <?php
2369 }
2370 if( isset($_REQUEST['page']) ){
2371 switch( $_REQUEST['page'] ){
2372 case 'usces_initial':
2373 ?>
2374 <script type='text/javascript'>
2375 /* <![CDATA[ */
2376 usces_ini = {
2377 'cod_type': "<?php if( 'change' == $this->options['cod_type'] ) {echo 'change';}else{echo 'fix';} ?>",
2378 'cod_type_fix': "<?php echo esc_js(__('Fixation C.O.D.', 'usces')); ?>",
2379 'cod_type_change': "<?php echo esc_js(__('Variable C.O.D.', 'usces')); ?>",
2380 'cod_unit': "<?php echo esc_js(__('dollars', 'usces')); ?>",
2381 'cod_failure': "<?php echo esc_js(__('failure in update', 'usces')); ?>",
2382 'cod_updated': "<?php echo esc_js(__('options are updated', 'usces')); ?>",
2383 'cod_limit': "<?php echo esc_js(__('A value of the amount of upper limit is dirty.', 'usces')); ?>"
2384 };
2385 /* ]]> */
2386 </script>
2387 <?php
2388 break;
2389 case 'usces_itemnew':
2390 case 'usces_itemedit':
2391 ?>
2392 <style type="text/css">
2393 <!--
2394 #usces_mess {
2395 color: #FF0000;
2396 font-weight: bold;
2397 }
2398 -->
2399 </style>
2400 <?php
2401 break;
2402 }
2403 }
2404 ?>
2405 <?php
2406 if( is_admin() && ( (isset($_GET['order_action']) && 'newpost' == $_GET['order_action'])
2407 || (isset($_GET['page']) && 'usces_ordernew' == $_GET['page'])
2408 || (isset($_GET['order_action']) && 'edit' == $_GET['order_action'])
2409 || (isset($_GET['order_action']) && 'editpost' == $_GET['order_action'])
2410 || (isset($_GET['member_action']) && 'edit' == $_GET['member_action'])
2411 || (isset($_GET['member_action']) && 'editpost' == $_GET['member_action'])) ) :
2412 switch( $_GET['page'] ){
2413 case 'usces_ordernew':
2414 case 'usces_orderlist':
2415 $admin_page = 'order';
2416 break;
2417 case 'usces_memberlist':
2418 $admin_page = 'member';
2419 break;
2420 }
2421 ?>
2422 <script type='text/javascript'>
2423 jQuery(function($) {
2424 uscesForm = {
2425 settings: {
2426 url: uscesL10n.requestFile,
2427 type: 'POST',
2428 cache: false,
2429 success: function(data, dataType){
2430 //$("tbody#item-opt-list").html( data );
2431 },
2432 error: function(msg){
2433 //$("#ajax-response").html(msg);
2434 }
2435 },
2436
2437 changeStates : function( country, type ) {
2438 var s = this.settings;
2439 s.data = "action=change_states_ajax&country=" + country;
2440 s.success = function(data, dataType){
2441 if( 'error' == data ){
2442 alert('error');
2443 }else{
2444 $("select#" + type + "_pref").html( data );
2445 if( customercountry == country && 'customer' == type ){
2446 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2447 }else if( deliverycountry == country && 'delivery' == type ){
2448 $("#" + type + "_pref").attr({selectedIndex:deliverystate});
2449 }else if( customercountry == country && 'member' == type ){
2450 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2451 }
2452 }
2453 };
2454 s.error = function(msg){
2455 alert("error");
2456 };
2457 $.ajax( s );
2458 return false;
2459 },
2460
2461 isNum : function (num) {
2462 if (num.match(/[^0-9]/g)) {
2463 return false;
2464 }
2465 return true;
2466 }
2467 };
2468 <?php
2469 if( 'order' == $admin_page ){
2470 ?>
2471 if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) {
2472 var customerstate = $("#customer_pref").get(0).selectedIndex;
2473 var customercountry = $("#customer_country").val();
2474 var deliverystate = $("#delivery_pref").get(0).selectedIndex;
2475 var deliverycountry = $("#delivery_country").val();
2476
2477 $("#customer_country").change(function () {
2478 var country = $("#customer_country option:selected").val();
2479 uscesForm.changeStates( country, 'customer' );
2480 });
2481 $("#delivery_country").change(function () {
2482 var country = $("#delivery_country option:selected").val();
2483 uscesForm.changeStates( country, 'delivery' );
2484 });
2485 }
2486 <?php
2487 }else if( 'member' == $admin_page ){
2488 ?>
2489 if( undefined != $("#member_pref").get(0) ) {
2490 var customerstate = $("#member_pref").get(0).selectedIndex;
2491 var customercountry = $("#member_country").val();
2492 var deliverystate = '';
2493 var deliverycountry = '';
2494
2495 $("#member_country").change(function () {
2496 var country = $("#member_country option:selected").val();
2497 uscesForm.changeStates( country, 'member' );
2498 });
2499 }
2500 <?php
2501 }
2502 ?>
2503 });
2504 </script>
2505 <?php
2506 endif;
2507 }
2508
2509 function main() {
2510 global $wpdb, $wp_locale, $wp_version, $post_ID;
2511 global $wp_query, $usces_action, $post, $action, $editing;
2512
2513 update_option('usces_shipping_rule', apply_filters('usces_filter_shipping_rule', get_option('usces_shipping_rule')));
2514 $this->shipping_rule = get_option('usces_shipping_rule');
2515
2516 if( !is_admin() ){
2517 $this->usces_cookie();
2518 }else{
2519 $this->user_level = usces_get_admin_user_level();
2520 }
2521 $this->make_url();
2522
2523
2524 do_action('usces_main');
2525 $this->update_table();
2526
2527
2528 require_once(USCES_PLUGIN_DIR . '/classes/cart.class.php');
2529 $this->cart = new usces_cart();
2530
2531 do_action('usces_after_cart_instant');
2532
2533 if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate' ){
2534 $post_id = (int)$_GET['post'];
2535 $new_id = usces_item_dupricate($post_id);
2536 $ref = isset($_REQUEST['usces_referer']) ? urlencode($_REQUEST['usces_referer']) : '';
2537 $url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref;
2538 wp_redirect($url);
2539 exit;
2540 }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'itemcsv' ){
2541 $filename = usces_item_uploadcsv();
2542 $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&regfile='.$filename;
2543 wp_redirect($url);
2544 exit;
2545 //member_up
2546 // }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_memberlist' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'membercsv'){
2547 // $filename = usces_upload_member_list();
2548 // $url = USCES_ADMIN_URL . '?page=usces_memberlist&usces_status=none&usces_message=&member_action=upload_register&regfile='.$filename;
2549 // wp_redirect($url);
2550 // exit;
2551 }
2552 //20110208ysk start
2553 if( isset($this->options['acting_settings']['paypal']) and 'on' == $this->options['acting_settings']['paypal']['ec_activate'] ) {
2554 require_once( USCES_PLUGIN_DIR.'/classes/paymentPaypal.class.php' );
2555 $this->paypal = new usces_paypal();
2556 }
2557 //20110208ysk end
2558
2559 $this->ad_controller();
2560 //$this->controller();
2561
2562
2563
2564 if( isset($_GET['page']) && $_GET['page'] == 'usces_itemnew'){
2565 $itemnew = 'new';
2566 }else{
2567 $itemnew = '';
2568 }
2569
2570 wp_enqueue_script('jquery');
2571
2572 if( is_admin() && isset($_REQUEST['page']) && ((isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') || $itemnew == 'new' || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'editpost'))) {
2573
2574 if(isset($_REQUEST['action']) && $_REQUEST['action'] != 'editpost' && $itemnew == 'new'){
2575 if ( version_compare($wp_version, '3.0-beta', '>') ){
2576 if ( !isset($_GET['post_type']) )
2577 $post_type = 'post';
2578 elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
2579 $post_type = $_GET['post_type'];
2580 else
2581 wp_die( __('Invalid post type') );
2582 $post_type_object = get_post_type_object($post_type);
2583 $editing = true;
2584 // if ( current_user_can($post_type_object->edit_type_cap) ) {
2585 $post = $this->get_default_post_to_edit30( $post_type, true );
2586 $post_ID = $post->ID;
2587 // }
2588
2589 }else{
2590 $post = $this->get_default_post_to_edit();
2591 }
2592 }else{
2593 if ( version_compare($wp_version, '3.0-beta', '>') ){
2594 if ( isset($_GET['post']) )
2595 $post_id = (int) $_GET['post'];
2596 elseif ( isset($_POST['post_ID']) )
2597 $post_id = (int) $_POST['post_ID'];
2598 else
2599 $post_id = 0;
2600 $post_ID = $post_id;
2601 $post = null;
2602 $post_type_object = null;
2603 $post_type = null;
2604 if ( $post_id ) {
2605 $post = get_post($post_id);
2606 if ( $post ) {
2607 $post_type_object = get_post_type_object($post->post_type);
2608 if ( $post_type_object ) {
2609 $post_type = $post->post_type;
2610 if( !isset($current_screen) ){
2611 $current_screen = new stdClass();
2612 }
2613 $current_screen->post_type = $post->post_type;
2614 $current_screen->id = $current_screen->post_type;
2615 }
2616 }
2617 } elseif ( isset($_POST['post_type']) ) {
2618 $post_type_object = get_post_type_object($_POST['post_type']);
2619 if ( $post_type_object ) {
2620 $post_type = $post_type_object->name;
2621 $current_screen->post_type = $post_type;
2622 $current_screen->id = $current_screen->post_type;
2623 }
2624 }
2625
2626
2627 // $post = get_post( $post_id, OBJECT, 'edit' );
2628 // if ( $post->post_type == 'page' )
2629 // $post->page_template = get_post_meta( $id, '_wp_page_template', true );
2630
2631 }else{
2632 if(isset($_GET['post'])){
2633 $post_ID = (int) $_GET['post'];
2634 $post = get_post($post_ID);
2635 }else{
2636 $post_ID = isset($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : 0;
2637 if(!empty($post_ID))
2638 $post = get_post($post_ID);
2639 }
2640 }
2641 // global $wp_query, $usces_action, $post;
2642
2643 }
2644 $editing = true;
2645 wp_enqueue_script('autosave');
2646 wp_enqueue_script('post');
2647 //if ( user_can_richedit() )
2648 //wp_enqueue_script('editor');
2649 add_thickbox();
2650 wp_enqueue_script('media-upload');
2651 wp_enqueue_script('word-count');
2652 wp_enqueue_script( 'admin-comments' );
2653
2654 if ( version_compare($wp_version, '3.3', '<') )
2655 add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
2656 wp_enqueue_script('quicktags');
2657
2658 }
2659
2660
2661 if( is_admin() && isset($_REQUEST['page']) ){
2662
2663 wp_enqueue_script('jquery-color');
2664
2665 switch( $_REQUEST['page'] ){
2666
2667 case 'usces_initial':
2668 $js = USCES_FRONT_PLUGIN_URL.'/js/usces_initial.js';
2669 wp_enqueue_script('usces_initial.js', $js, array('jquery-ui-dialog', 'jquery-ui-sortable'));
2670 //wp_enqueue_script('jquery-ui-sortable');
2671 break;
2672 case 'usces_settlement':
2673 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2674 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2675 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2676 $jquery_colorUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/color/jscolor.js';
2677 wp_enqueue_script( 'jquery-jscolor', $jquery_colorUrl, array('jquery-color') );
2678 break;
2679 case 'usces_cart':
2680 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2681 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2682 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2683 break;
2684 case 'usces_member':
2685 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2686 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2687 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2688 break;
2689 case 'usces_orderlist':
2690 case 'usces_ordernew':
2691 wp_enqueue_script('jquery-ui-dialog');
2692 break;
2693 case 'usces_memberlist':
2694 wp_enqueue_script('jquery-ui-dialog');
2695 break;
2696 case 'usces_itemnew':
2697 wp_enqueue_script('jquery-ui-sortable');
2698 break;
2699 case 'usces_itemedit':
2700 if( isset($_REQUEST['action']) && 'upload_register' == $_REQUEST['action'] ){
2701 @ob_end_clean();
2702 ob_start();
2703 }else{
2704 wp_enqueue_script('jquery-ui-sortable');
2705 wp_enqueue_script('jquery-ui-dialog');
2706 }
2707 break;
2708 case 'usces_delivery':
2709 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2710 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2711 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2712 break;
2713 case 'usces_system':
2714 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2715 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2716 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2717 break;
2718 }
2719 }
2720
2721 if( isset($_REQUEST['order_action']) && $_REQUEST['order_action'] == 'pdfout' ){
2722 $this->get_current_member();
2723 $mid = $this->current_member['id'];
2724 $oid = $_GET['order_id'];
2725 if( !is_user_logged_in() && !$this->is_order($mid, $oid) )
2726 die('No permission');
2727 require_once( apply_filters('usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php') );
2728 }
2729
2730 do_action( 'usces_after_main' );
2731 }
2732
2733 function stripslashes_deep_post( $array ){
2734 $res = array();
2735 foreach( $array as $key => $value ){
2736 $key = stripslashes($key);
2737 if( is_array($value) ){
2738 $value = $this->stripslashes_deep_post( $value );
2739 }else{
2740 $value = stripslashes($value);
2741 }
2742 $res[$key] = $value;
2743 }
2744 return $res;
2745 }
2746
2747 function make_url(){
2748
2749 $permalink_structure = get_option('permalink_structure');
2750 //usces_log('use_ssl : '.$this->use_ssl, 'acting_transaction.log');
2751 if($this->use_ssl) {
2752 if( $permalink_structure ){
2753 $this->delim = '&';
2754 $home_perse = parse_url(get_option('home'));
2755 $home_perse_path = isset($home_perse['path']) ? $home_perse['path'] : '';
2756 $home_path = $home_perse['host'].$home_perse_path;
2757 $ssl_perse = parse_url($this->options['ssl_url']);
2758 $ssl_perse_path = isset($ssl_perse['path']) ? $ssl_perse['path'] : '';
2759 $ssl_path = $ssl_perse['host'].$ssl_perse_path;
2760 if( $home_perse_path != $ssl_perse_path ){
2761 if( ! defined('USCES_CUSTOMER_URL') )
2762 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2763 if( ! defined('USCES_CART_URL') )
2764 define('USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2765 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2766 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2767 if( ! defined('USCES_NEWMEMBER_URL') )
2768 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2769 if( ! defined('USCES_LOGIN_URL') )
2770 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2771 if( ! defined('USCES_LOGOUT_URL') )
2772 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2773 if( ! defined('USCES_MEMBER_URL') )
2774 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2775 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2776 if( ! defined('USCES_INQUIRY_URL') )
2777 define('USCES_INQUIRY_URL', $inquiry_url);
2778 if( ! defined('USCES_CART_NONSESSION_URL') )
2779 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER);
2780 //20110208ysk start
2781 //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2782 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2783 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2784 //20110208ysk end
2785 }else{
2786 $ssl_plink_cart = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_CART_NUMBER) ));
2787 $ssl_plink_member = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_MEMBER_NUMBER) ));
2788 if( ! defined('USCES_CUSTOMER_URL') )
2789 define('USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1');
2790 if( ! defined('USCES_CART_URL') )
2791 define('USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid());
2792 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2793 define('USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2794 if( ! defined('USCES_NEWMEMBER_URL') )
2795 define('USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid(). '&page=newmember');
2796 if( ! defined('USCES_LOGIN_URL') )
2797 define('USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=login');
2798 if( ! defined('USCES_LOGOUT_URL') )
2799 define('USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=logout');
2800 if( ! defined('USCES_MEMBER_URL') )
2801 define('USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid());
2802 if( !isset($this->options['inquiry_id']) || !( (int)$this->options['inquiry_id'] ) ){
2803 $inquiry_url = get_home_url();
2804 }else{
2805 $ssl_plink_inquiry = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link($this->options['inquiry_id']) ));
2806 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid();
2807 }
2808 if( ! defined('USCES_INQUIRY_URL') )
2809 define('USCES_INQUIRY_URL', $inquiry_url);
2810 if( ! defined('USCES_CART_NONSESSION_URL') )
2811 define('USCES_CART_NONSESSION_URL', $ssl_plink_cart);
2812 //20110208ysk start
2813 //define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2814 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2815 define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2816 //20110208ysk end
2817 }
2818 }else{
2819 $this->delim = '&';
2820 if( ! defined('USCES_CUSTOMER_URL') )
2821 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2822 if( ! defined('USCES_CART_URL') )
2823 define('USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2824 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2825 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2826 if( ! defined('USCES_NEWMEMBER_URL') )
2827 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2828 if( ! defined('USCES_LOGIN_URL') )
2829 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2830 if( ! defined('USCES_LOGOUT_URL') )
2831 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2832 if( ! defined('USCES_MEMBER_URL') )
2833 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2834 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2835 if( ! defined('USCES_INQUIRY_URL') )
2836 define('USCES_INQUIRY_URL', $inquiry_url);
2837 if( ! defined('USCES_CART_NONSESSION_URL') )
2838 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER);
2839 //20110208ysk start
2840 //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2841 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2842 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2843 //20110208ysk end
2844 }
2845 if( !is_admin() ){
2846 add_filter('home_url', array($this, 'usces_ssl_page_link'));
2847 add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
2848 add_filter('icon_dir_uri', array($this, 'usces_ssl_icon_dir_uri'));
2849 add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
2850 add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
2851 add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
2852 add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
2853 }
2854 } else {
2855 if( $permalink_structure ){
2856 $this->delim = '?';
2857 if( ! defined('USCES_CUSTOMER_URL') )
2858 define('USCES_CUSTOMER_URL', get_page_link(USCES_CART_NUMBER) . '?customerinfo=1');
2859 if( ! defined('USCES_CART_URL') )
2860 define('USCES_CART_URL', get_page_link(USCES_CART_NUMBER));
2861 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2862 define('USCES_LOSTMEMBERPASSWORD_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=lostmemberpassword');
2863 if( ! defined('USCES_NEWMEMBER_URL') )
2864 define('USCES_NEWMEMBER_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=newmember');
2865 if( ! defined('USCES_LOGIN_URL') )
2866 define('USCES_LOGIN_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=login');
2867 if( ! defined('USCES_LOGOUT_URL') )
2868 define('USCES_LOGOUT_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=logout');
2869 if( ! defined('USCES_MEMBER_URL') )
2870 define('USCES_MEMBER_URL', get_page_link(USCES_MEMBER_NUMBER));
2871 $inquiry_url = ( !isset( $this->options['inquiry_id'] ) || !( (int)$this->options['inquiry_id'] )) ? get_home_url() : get_page_link($this->options['inquiry_id']);
2872 if( ! defined('USCES_INQUIRY_URL') )
2873 define('USCES_INQUIRY_URL', $inquiry_url);
2874 if( ! defined('USCES_CART_NONSESSION_URL') )
2875 define('USCES_CART_NONSESSION_URL', get_page_link(USCES_CART_NUMBER));
2876 //20110208ysk start
2877 //define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2878 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2879 define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2880 //20110208ysk end
2881 }else{
2882 $this->delim = '&';
2883 if( ! defined('USCES_CUSTOMER_URL') )
2884 define('USCES_CUSTOMER_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1');
2885 if( ! defined('USCES_CART_URL') )
2886 define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2887 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2888 define('USCES_LOSTMEMBERPASSWORD_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=lostmemberpassword');
2889 if( ! defined('USCES_NEWMEMBER_URL') )
2890 define('USCES_NEWMEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=newmember');
2891 if( ! defined('USCES_LOGIN_URL') )
2892 define('USCES_LOGIN_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=login');
2893 if( ! defined('USCES_LOGOUT_URL') )
2894 define('USCES_LOGOUT_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2895 if( ! defined('USCES_CART_NONSESSION_URL') )
2896 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2897 if( ! defined('USCES_MEMBER_URL') )
2898 define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
2899 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option('home') . '/?page_id=' . $this->options['inquiry_id'];
2900 if( ! defined('USCES_INQUIRY_URL') )
2901 define('USCES_INQUIRY_URL', $inquiry_url);
2902 if( ! defined('USCES_CART_NONSESSION_URL') )
2903 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2904 //20110208ysk start
2905 //define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2906 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2907 define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2908 //20110208ysk end
2909 }
2910 }
2911 }
2912
2913 function regist_action(){
2914 usces_register_action('inCart', 'post', 'inCart', NULL, 'inCart');
2915 usces_register_action('upButton', 'post', 'upButton', NULL, 'upButton');
2916 usces_register_action('delButton', 'post', 'delButton', NULL, 'delButton');
2917 usces_register_action('backCart', 'post', 'backCart', NULL, 'backCart');
2918 usces_register_action('customerinfo', 'request', 'customerinfo', NULL, 'customerinfo');
2919 usces_register_action('backCustomer', 'post', 'backCustomer', NULL, 'backCustomer');
2920 usces_register_action('customerlogin', 'post', 'customerlogin', NULL, 'customerlogin');
2921 usces_register_action('reganddeliveryinfo', 'post', 'reganddeliveryinfo', NULL, 'reganddeliveryinfo');
2922 usces_register_action('deliveryinfo', 'post', 'deliveryinfo', NULL, 'deliveryinfo');
2923 usces_register_action('backDelivery', 'post', 'backDelivery', NULL, 'backDelivery');
2924 usces_register_action('confirm', 'request', 'confirm', NULL, 'confirm');
2925 usces_register_action('use_point', 'post', 'use_point', NULL, 'use_point');
2926 usces_register_action('backConfirm', 'post', 'backConfirm', NULL, 'backConfirm');
2927 usces_register_action('purchase', 'request', 'purchase', NULL, 'purchase');
2928 usces_register_action('acting_return', 'request', 'acting_return', NULL, 'acting_return');
2929 usces_register_action('settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon');
2930 usces_register_action('inquiry_button', 'post', 'inquiry_button', NULL, 'inquiry_button');
2931 usces_register_action('member_login', 'request', 'member_login', NULL, 'member_login_page');
2932 usces_register_action('regmember', 'request', 'regmember', NULL, 'regmember');
2933 usces_register_action('editmember', 'request', 'editmember', NULL, 'editmember');
2934 usces_register_action('deletemember', 'request', 'deletemember', NULL, 'deletemember');
2935 usces_register_action('page_login', 'get', 'page', 'login', 'member_login_page');
2936 usces_register_action('page_logout', 'get', 'page', 'logout', 'page_logout');
2937 usces_register_action('page_lostmemberpassword', 'get', 'page', 'lostmemberpassword', 'page_lostmemberpassword');
2938 usces_register_action('lostpassword', 'request', 'lostpassword', NULL, 'lostpassword');
2939 usces_register_action('uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword');
2940 usces_register_action('changepassword', 'request', 'changepassword', NULL, 'changepassword_page');
2941 usces_register_action('page_newmember', 'get', 'page', 'newmember', 'page_newmember');
2942 usces_register_action('usces_export', 'post', 'usces_export', NULL, 'usces_export');
2943 usces_register_action('usces_import', 'post', 'usces_import', NULL, 'usces_import');
2944 usces_register_action('page_search_item', 'get', 'page', 'search_item', 'page_search_item');
2945 usces_register_action('front_ajax', 'post', 'usces_ajax_action', NULL, 'front_ajax');
2946 }
2947
2948 function ad_controller(){
2949 global $usces_action;
2950 ksort($usces_action);
2951 //if($this->is_maintenance()){
2952 if($this->is_maintenance() and !is_user_logged_in()){//0000651
2953 $this->maintenance();
2954 }else{
2955 $action_array = array('inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer',
2956 'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point',
2957 'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login',
2958 'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword',
2959 'uscesmode_changepassword', 'changepassword', 'page_newmember', 'usces_export', 'usces_import',
2960 'page_search_item', 'front_ajax');
2961 $flg = 0;
2962 $res = true;
2963 foreach( $usces_action as $handle => $action ){
2964 extract($action);
2965 switch($type){
2966 case 'post':
2967 if( empty($value) ){
2968 if( isset($_POST[$key]) ){
2969 if(in_array($handle, $action_array)){
2970 $res = call_user_func(array($this, $function));
2971 }else{
2972 $res = call_user_func($function);
2973 }
2974 $flg = 1;
2975 }
2976 }else{
2977 if( isset($_POST[$key]) && $_POST[$key] == $value ){
2978 if(in_array($handle, $action_array)){
2979 $res = call_user_func(array($this, $function));
2980 }else{
2981 $res = call_user_func($function);
2982 }
2983 $flg = 1;
2984 }
2985 }
2986 break;
2987 case 'get':
2988 if( empty($value) ){
2989 if( isset($_GET[$key]) ){
2990 if(in_array($handle, $action_array)){
2991 $res = call_user_func(array($this, $function));
2992 }else{
2993 $res = call_user_func($function);
2994 }
2995 $flg = 1;
2996 }
2997 }else{
2998 if( isset($_GET[$key]) && $_GET[$key] == $value ){
2999 if(in_array($handle, $action_array)){
3000 $res = call_user_func(array($this, $function));
3001 }else{
3002 $res = call_user_func($function);
3003 }
3004 $flg = 1;
3005 }
3006 }
3007 break;
3008 case 'request':
3009 if( empty($value) ){
3010 if( isset($_REQUEST[$key]) ){
3011 if(in_array($handle, $action_array)){
3012 $res = call_user_func(array($this, $function));
3013 }else{
3014 $res = call_user_func($function);
3015 }
3016 $flg = 1;
3017 }
3018 }else{
3019 if( isset($_REQUEST[$key]) && $_REQUEST[$key] == $value ){
3020 if(in_array($handle, $action_array)){
3021 $res = call_user_func(array($this, $function));
3022 }else{
3023 $res = call_user_func($function);
3024 }
3025 $flg = 1;
3026 }
3027 }
3028 break;
3029 }
3030 if( ! $res ) break;
3031 }
3032 if( !$flg ) $this->default_page();
3033 }
3034 }
3035
3036 //action function------------------------------------------------------------
3037 function front_ajax(){
3038 switch ($_POST['usces_ajax_action']){
3039 case 'change_states':
3040 change_states_ajax();
3041 break;
3042 }
3043 do_action('usces_front_ajax');
3044 }
3045
3046 function maintenance(){
3047 $this->page = 'maintenance';
3048 add_action('the_post', array($this, 'action_cartFilter'));
3049 }
3050
3051 function inCart(){
3052 global $wp_query;
3053 $this->page = 'cart';
3054 $this->incart_check();
3055 $this->cart->inCart();
3056 add_action('the_post', array($this, 'action_cartFilter'));
3057 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3058 add_action('template_redirect', array($this, 'template_redirect'));
3059 }
3060
3061 function upButton(){
3062 global $wp_query;
3063 $this->page = 'cart';
3064 $this->cart->upCart();
3065 $this->error_message = $this->zaiko_check();
3066 add_action('the_post', array($this, 'action_cartFilter'));
3067 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3068 add_action('template_redirect', array($this, 'template_redirect'));
3069 }
3070
3071 function delButton(){
3072 global $wp_query;
3073 $this->page = 'cart';
3074 $this->cart->del_row();
3075 add_action('the_post', array($this, 'action_cartFilter'));
3076 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3077 add_action('template_redirect', array($this, 'template_redirect'));
3078 }
3079
3080 function backCart(){
3081 global $wp_query;
3082 $this->page = 'cart';
3083 add_action('the_post', array($this, 'action_cartFilter'));
3084 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3085 add_action('template_redirect', array($this, 'template_redirect'));
3086 }
3087
3088 function customerinfo(){
3089 global $wp_query;
3090 if( false === $this->cart->num_row() ){
3091 header('location: ' . get_option('home'));
3092 exit;
3093 }
3094 do_action( 'usces_action_customerinfo' );
3095 $this->cart->entry();
3096 $this->error_message = $this->zaiko_check();
3097 $this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message );
3098 if( WCUtils::is_blank($this->error_message) ){
3099 if($this->is_member_logged_in()){
3100 //20100818ysk start
3101 //$this->page = 'delivery';
3102 $this->error_message = has_custom_customer_field_essential();
3103 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'delivery' : 'customer';
3104 //20100818ysk end
3105 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3106 }else{
3107 $this->page = 'customer';
3108 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3109 }
3110 }else{
3111 $this->page = 'cart';
3112 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3113 }
3114 if ( !$this->cart->is_order_condition() ) {
3115 $order_conditions = $this->get_condition();
3116 $this->cart->set_order_condition($order_conditions);
3117 }
3118 add_action('the_post', array($this, 'action_cartFilter'));
3119 add_action('template_redirect', array($this, 'template_redirect'));
3120 }
3121
3122 function backCustomer(){
3123 global $wp_query;
3124 if( false === $this->cart->num_row() ){
3125 header('location: ' . get_option('home'));
3126 exit;
3127 }
3128 $this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' );
3129 add_action('the_post', array($this, 'action_cartFilter'));
3130 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3131 add_action('template_redirect', array($this, 'template_redirect'));
3132 // $this->cart->entry();
3133 // $this->error_message = $this->delivery_check();
3134 // $this->page = ($this->error_message == '') ? 'customer' : 'delivery';
3135 }
3136
3137 function customerlogin(){
3138 global $wp_query;
3139 if( false === $this->cart->num_row() ){
3140 header('location: ' . get_option('home'));
3141 exit;
3142 }
3143 //20100818ysk start
3144 //$this->cart->entry();
3145 //$this->page = ($this->member_login() == 'member') ? 'delivery' : 'customer';
3146 if($this->member_login() == 'member') {
3147 $this->cart->entry();
3148 $this->error_message = has_custom_customer_field_essential();
3149 if( WCUtils::is_blank($this->error_message) ){
3150 $this->page = 'delivery';
3151 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3152 }else{
3153 $this->page = 'customer';
3154 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3155 }
3156 } else {
3157 $this->cart->entry();
3158 $this->page = 'customer';
3159 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3160 }
3161 //20100818ysk end
3162 add_action('the_post', array($this, 'action_cartFilter'));
3163 add_action('template_redirect', array($this, 'template_redirect'));
3164 }
3165
3166 function reganddeliveryinfo(){
3167 global $wp_query;
3168 if( false === $this->cart->num_row() ){
3169 header('location: ' . get_option('home'));
3170 exit;
3171 }
3172 $this->cart->entry();
3173 //20110715ysk start 0000203
3174 //$_POST['member_regmode'] = 'newmemberfromcart';
3175 if(empty($_POST['member_regmode']) or $_POST['member_regmode'] != 'editmemberfromcart') $_POST['member_regmode'] = 'newmemberfromcart';
3176 //20110715ysk end
3177
3178 if( $this->regist_member() == 'newcompletion' ){
3179 $this->page = 'delivery';
3180 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3181 }else{
3182 $this->page = 'customer';
3183 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3184 }
3185 add_action('the_post', array($this, 'action_cartFilter'));
3186 add_action('template_redirect', array($this, 'template_redirect'));
3187 }
3188
3189 function deliveryinfo(){
3190 global $wp_query;
3191 if( false === $this->cart->num_row() ){
3192 header('location: ' . get_option('home'));
3193 exit;
3194 }
3195 $this->cart->entry();
3196 $this->error_message = $this->customer_check();
3197
3198 if( WCUtils::is_blank($this->error_message) ){
3199 $this->page = 'delivery';
3200 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3201 }else{
3202 $this->page = 'customer';
3203 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3204 }
3205 add_action('the_post', array($this, 'action_cartFilter'));
3206 add_action('template_redirect', array($this, 'template_redirect'));
3207 }
3208
3209 function backDelivery(){
3210 global $wp_query;
3211 if( false === $this->cart->num_row() ){
3212 header('location: ' . get_option('home'));
3213 exit;
3214 }
3215 $this->page = 'delivery';
3216 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3217 add_action('the_post', array($this, 'action_cartFilter'));
3218 add_action('template_redirect', array($this, 'template_redirect'));
3219 }
3220
3221 function confirm(){
3222 global $wpdb, $wp_query;
3223 if( false === $this->cart->num_row() ){
3224 header('location: ' . get_option('home'));
3225 exit;
3226 }
3227
3228 $this->cart->entry();
3229 $this->error_message = $this->zaiko_check();
3230 if( $this->error_message != '' ){
3231 $this->page = 'cart';
3232 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3233 add_action('the_post', array($this, 'action_cartFilter'));
3234 add_action('template_redirect', array($this, 'template_redirect'));
3235 return;
3236 }
3237
3238 $this->set_reserve_pre_order_id();
3239 if(isset($_POST['confirm'])){
3240 $this->error_message = $this->delivery_check();
3241 }
3242 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'confirm' : 'delivery';
3243 if( WCUtils::is_blank($this->error_message) ){
3244 //20120919ysk start 0000573
3245 if( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) {
3246 $member_table = $wpdb->prefix."usces_member";
3247 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID']);
3248 $mem_point = $wpdb->get_var( $query );
3249 $_SESSION['usces_member']['point'] = $mem_point;
3250 }
3251 //20120919ysk end
3252 $this->page = 'confirm';
3253 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3254 }else{
3255 $this->page = 'delivery';
3256 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3257 }
3258 add_action('the_post', array($this, 'action_cartFilter'));
3259 add_action('template_redirect', array($this, 'template_redirect'));
3260 }
3261
3262 function use_point(){
3263 global $wp_query;
3264 $this->error_message = $this->point_check( $this->cart->get_entry() );
3265 if( empty($this->error_message) )
3266 $this->cart->entry();
3267 $this->page = 'confirm';
3268 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3269 add_action('the_post', array($this, 'action_cartFilter'));
3270 add_action('template_redirect', array($this, 'template_redirect'));
3271 }
3272
3273 function backConfirm(){
3274 global $wp_query;
3275 if( false === $this->cart->num_row() ){
3276 header('location: ' . get_option('home'));
3277 exit;
3278 }
3279 $this->page = 'confirm';
3280 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3281 add_action('the_post', array($this, 'action_cartFilter'));
3282 add_action('template_redirect', array($this, 'template_redirect'));
3283 }
3284
3285 function purchase(){
3286 global $wp_query;
3287 if( false === $this->cart->num_row() ){
3288 header('location: ' . get_option('home'));
3289 exit;
3290 }
3291
3292 if( !apply_filters('usces_purchase_check', true) ) return;
3293
3294 do_action('usces_purchase_validate');
3295 $entry = $this->cart->get_entry();
3296 $this->error_message = $this->zaiko_check();
3297 if( WCUtils::is_blank($this->error_message) && 0 < $this->cart->num_row()){
3298 $acting_status = '';
3299 $payments = $this->getPayments( $entry['order']['payment_name'] );
3300 if( substr($payments['settlement'], 0, 6) == 'acting' && $entry['order']['total_full_price'] > 0 ){
3301 $acting_flg = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3302 //$query = '';
3303 //foreach($_POST as $key => $value){
3304 // if($key != 'purchase')
3305 // $query .= '&' . $key . '=' . urlencode(maybe_serialize($value));
3306 //}
3307 unset( $_POST['purchase'] );
3308 $query = '&'.http_build_query( $_POST );
3309 $acting_status = $this->acting_processing($acting_flg, $query);
3310 }
3311
3312 if($acting_status == 'error'){
3313 $this->page = 'error';
3314 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3315 }else{
3316 $res = $this->order_processing();
3317 if( 'ordercompletion' == $res ){
3318 $this->page = 'ordercompletion';
3319 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3320 }else{
3321 $this->page = 'error';
3322 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3323 }
3324 }
3325 }else{
3326 $this->page = 'cart';
3327 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3328 }
3329 add_action('the_post', array($this, 'action_cartFilter'));
3330 add_action('template_redirect', array($this, 'template_redirect'));
3331 }
3332
3333 function acting_return(){
3334 global $wp_query;
3335 $entry = $this->cart->get_entry();
3336
3337 //20110208ysk start
3338 /* if( 'paypal_ipn' == $_REQUEST['acting_return'] ){
3339 usces_log('paypal_ipn in ', 'acting_transaction.log');
3340 require_once($this->options['settlement_path'] . 'paypal.php');
3341 $ipn_res = paypal_ipn_check($usces_paypal_url);
3342 if( $ipn_res[0] === true ){
3343 $res = $this->order_processing( $ipn_res );
3344 if( 'ordercompletion' == $res ){
3345 $this->cart->crear_cart();
3346 }else{
3347 usces_log('paypal_ipn regorder error (acting_return) : '.print_r($entry, true), 'acting_transaction.log');
3348 }
3349 }
3350 exit;
3351 }*/
3352 //20110208ysk end
3353 if( isset($_GET['acting']) and 'anotherlane_card' != $_GET['acting'] ) {//20131220ysk
3354 if( false === $this->cart->num_row() && ('paypal' != $_GET['acting'] && 1 !== (int)$_GET['acting_return']) ){
3355 header('location: ' . get_option('home'));
3356 exit;
3357 }
3358 }//20131220ysk
3359
3360 $this->payment_results = usces_check_acting_return();
3361
3362 if( isset($this->payment_results[0]) && $this->payment_results[0] === 'duplicate' ){
3363
3364 header('location: ' . get_option('home'));
3365 exit;
3366
3367 }else if( isset($this->payment_results[0]) && $this->payment_results[0] ){//result OK
3368
3369 if( ! $this->payment_results['reg_order'] ){//without Registration Order
3370 $this->page = 'ordercompletion';
3371 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3372
3373 }else{
3374 $res = $this->order_processing( $this->payment_results );
3375
3376 if( 'ordercompletion' == $res ){
3377 if( isset($_REQUEST['wctid']) ){
3378 usces_ordered_acting_data($_REQUEST['wctid']);
3379 }
3380 $this->page = 'ordercompletion';
3381 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3382 }else{
3383 $this->page = 'error';
3384 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3385 }
3386 }
3387
3388 }else{//result NG
3389 $this->page = 'error';
3390 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3391 }
3392
3393 add_action('the_post', array($this, 'action_cartFilter'));
3394 add_action('template_redirect', array($this, 'template_redirect'));
3395 }
3396
3397 function settlement_epsilon(){
3398 global $wp_query;
3399 require_once($this->options['settlement_path'] . 'epsilon.php');
3400 }
3401
3402 function inquiry_button(){
3403 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']) ){
3404 $res = $this->inquiry_processing();
3405 }else{
3406 $res = 'deficiency';
3407 }
3408
3409 $this->page = $res;
3410 }
3411
3412 function member_login_page(){
3413 global $wp_query;
3414 $res = $this->member_login();
3415 if( 'member' == $res ){
3416 $this->page = 'member';
3417 do_action('usces_action_member_logined');
3418 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_member');
3419 }elseif( 'login' == $res ){
3420 $this->page = 'login';
3421 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_login');
3422 }
3423 add_action('the_post', array($this, 'action_memberFilter'));
3424 add_action('template_redirect', array($this, 'template_redirect'));
3425 }
3426
3427 function regmember(){
3428 global $wp_query;
3429 $res = $this->regist_member();
3430 if( 'editmemberform' == $res ){
3431 $this->page = 'editmemberform';
3432 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3433 }elseif( 'newcompletion' == $res ){
3434 $this->page = 'newcompletion';
3435 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3436 }else{
3437 $this->page = $res;
3438 }
3439 add_action('the_post', array($this, 'action_memberFilter'));
3440 add_action('template_redirect', array($this, 'template_redirect'));
3441 }
3442
3443 function editmember(){
3444 global $wp_query;
3445 $res = $this->regist_member();
3446 if( 'editmemberform' == $res ){
3447 $this->page = 'editmemberform';
3448 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3449 }elseif( 'newcompletion' == $res ){
3450 $this->page = 'newcompletion';
3451 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3452 }else{
3453 $this->page = $res;
3454 }
3455 add_action('the_post', array($this, 'action_memberFilter'));
3456 add_action('template_redirect', array($this, 'template_redirect'));
3457 }
3458
3459 function deletemember(){
3460 $res = $this->delete_member();
3461 if( $res ){
3462 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember');
3463 $this->member_logout();
3464 }else{
3465 $this->page = 'editmemberform';
3466 add_action('the_post', array($this, 'action_memberFilter'));
3467 }
3468 add_action('template_redirect', array($this, 'template_redirect'));
3469 }
3470
3471 function page_logout(){
3472 global $wp_query;
3473 $this->member_logout();
3474 add_action('the_post', array($this, 'action_memberFilter'));
3475 add_action('template_redirect', array($this, 'template_redirect'));
3476 }
3477
3478 function page_lostmemberpassword(){
3479 global $wp_query;
3480 $this->page = 'lostmemberpassword';
3481 add_action('the_post', array($this, 'action_memberFilter'));
3482 add_action('template_redirect', array($this, 'template_redirect'));
3483 }
3484
3485 function lostpassword(){
3486 global $wp_query;
3487 $this->error_message = $this->lostpass_mailaddcheck();
3488 if ( $this->error_message != '' ) {
3489 $this->page = 'lostmemberpassword';
3490 } else {
3491 $res = $this->lostmail();
3492 $this->page = $res;//'lostcompletion';
3493 }
3494 add_action('the_post', array($this, 'action_memberFilter'));
3495 add_action('template_redirect', array($this, 'template_redirect'));
3496 }
3497
3498 function uscesmode_changepassword(){
3499 global $wp_query;
3500 $this->page = 'changepassword';
3501 add_action('the_post', array($this, 'action_memberFilter'));
3502 add_action('template_redirect', array($this, 'template_redirect'));
3503 }
3504
3505 function changepassword_page(){
3506 global $wp_query;
3507 $this->error_message = $this->changepass_check();
3508 if ( $this->error_message != '' ) {
3509 $this->page = 'changepassword';
3510 } else {
3511 $res = $this->changepassword();
3512 $this->page = $res;//'changepasscompletion';
3513 }
3514 add_action('the_post', array($this, 'action_memberFilter'));
3515 add_action('template_redirect', array($this, 'template_redirect'));
3516 }
3517
3518 function page_newmember(){
3519
3520 global $wp_query;
3521 $this->page = 'newmemberform';
3522 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform');
3523 add_action('the_post', array($this, 'action_memberFilter'));
3524 add_action('template_redirect', array($this, 'template_redirect'));
3525 }
3526
3527 function usces_export(){
3528 $this->export();
3529 }
3530
3531 function usces_import(){
3532 $this->import();
3533 }
3534
3535 function page_search_item(){
3536 global $wp_query;
3537 $this->page = 'search_item';
3538 //add_action('template_redirect', array($this, 'action_search_item'));
3539 add_action('the_post', array($this, 'action_cartFilter'));
3540 add_action('template_redirect', array($this, 'template_redirect'));
3541 }
3542
3543 function default_page(){
3544 global $wp_query;
3545 add_action('the_post', array($this, 'goDefaultPage'));
3546 add_action('template_redirect', array($this, 'template_redirect'));
3547 }
3548 //--------------------------------------------------------------------------------------
3549
3550
3551 function goDefaultPage(){
3552 global $post;
3553
3554 if( $post->ID == USCES_CART_NUMBER ) {
3555
3556 $this->page = 'cart';
3557 add_filter('the_content', array($this, 'filter_cartContent'),20);
3558
3559 }else if( $post->ID == USCES_MEMBER_NUMBER ) {
3560
3561 $this->page = 'member';
3562 add_filter('the_content', array($this, 'filter_memberContent'),20);
3563
3564 }else if( !is_singular() ) {
3565 $this->page = 'wp_search';
3566 add_filter('the_excerpt', array($this, 'filter_cartContent'),20);
3567 add_filter('the_content', array($this, 'filter_cartContent'),20);
3568
3569 }else{
3570 add_filter('the_content', array(&$this, 'filter_itemPage'));
3571
3572 }
3573 }
3574
3575 function template_redirect () {
3576 global $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode;
3577
3578 if( apply_filters('usces_action_template_redirect', false) ) return;//Deprecated
3579 if( apply_filters('usces_filter_template_redirect', false) ) return;
3580
3581 if( is_single() && 'item' == $post->post_mime_type ) {
3582 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_item_single.php') ){
3583 if( !post_password_required($post) ){
3584 include(get_stylesheet_directory() . '/wc_templates/wc_item_single.php');
3585 exit;
3586 }
3587 }
3588 }elseif( isset($_REQUEST['page']) && ('search_item' == $_REQUEST['page'] || 'usces_search' == $_REQUEST['page']) && $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3589 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_search_page.php') ){
3590 include(get_stylesheet_directory() . '/wc_templates/wc_search_page.php');
3591 exit;
3592 }
3593
3594 }else if( $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3595 switch( $this->page ){
3596 case 'customer':
3597 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php') ){
3598 usces_get_entries();
3599 usces_get_member_regmode();
3600 include(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php');
3601 exit;
3602 }
3603 break;
3604 case 'delivery':
3605 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php') ){
3606 usces_get_entries();
3607 usces_get_carts();
3608 include(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php');
3609 exit;
3610 }
3611 break;
3612 case 'confirm':
3613 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php') ){
3614 usces_get_entries();
3615 usces_get_carts();
3616 usces_get_members();
3617 include(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php');
3618 exit;
3619 }
3620 break;
3621 case 'ordercompletion':
3622 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php') ){
3623 usces_get_entries();
3624 usces_get_carts();
3625 include(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php');
3626 exit;
3627 }
3628 break;
3629 case 'error':
3630 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php') ){
3631 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php');
3632 exit;
3633 }
3634 break;
3635 case 'cart':
3636 default:
3637 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php') ){
3638 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php');
3639 exit;
3640 }
3641
3642 }
3643 }else if($this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
3644
3645 }else if( $this->is_member_page($_SERVER['REQUEST_URI']) ){
3646 if($this->options['membersystem_state'] != 'activate') return;
3647
3648 if( $this->is_member_logged_in() ) {
3649 $member_regmode = 'editmemberform';
3650 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php') ){
3651 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php');
3652 exit;
3653 }
3654
3655 } else {
3656
3657 switch( $this->page ){
3658 case 'login':
3659 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3660 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3661 exit;
3662 }
3663 break;
3664 case 'newmemberform':
3665 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php') ){
3666 $member_regmode = 'newmemberform';
3667 include(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php');
3668 exit;
3669 }
3670 break;
3671 case 'lostmemberpassword':
3672 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php') ){
3673 include(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php');
3674 exit;
3675 }
3676 break;
3677 case 'changepassword':
3678 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php') ){
3679 include(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php');
3680 exit;
3681 }
3682 break;
3683 case 'newcompletion':
3684 case 'editcompletion':
3685 case 'lostcompletion':
3686 case 'changepasscompletion':
3687 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php') ){
3688 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php');
3689 exit;
3690 }
3691 break;
3692 default:
3693 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3694 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3695 exit;
3696 }
3697 }
3698 }
3699
3700 }else{
3701 // remove_action('the_post', array(&$this, 'goDefaultPage'));
3702 }
3703 }
3704
3705 function import() {
3706 $res = usces_import_xml();
3707 if ( $res === false ) :
3708 $this->action_status = 'error';
3709 //$this->action_message = __('Import was not completed.', 'usces');
3710 else :
3711 $this->action_status = 'success';
3712 $this->action_message = __('Import is cmpleted', 'usces');
3713 endif;
3714
3715 // require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
3716 }
3717
3718 function export() {
3719 $filename = 'usces.' . substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10) . '.xml';
3720
3721 header('Content-Description: File Transfer');
3722 header("Content-Disposition: attachment; filename=$filename");
3723 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
3724
3725 usces_export_xml();
3726 die();
3727
3728 }
3729
3730
3731 function changepassword() {
3732 global $wpdb;
3733
3734 if ( !isset($_SESSION['usces_lostmail']) ) :
3735 $this->error_message = __('Failed in update due to time-out', 'usces');
3736 return 'login';
3737 else :
3738
3739 $member_table = $wpdb->prefix . "usces_member";
3740
3741 $query = $wpdb->prepare("UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s",
3742 md5(trim($_POST['loginpass1'])), $_SESSION['usces_lostmail']);
3743 $res = $wpdb->query( $query );
3744 //$res = $wpdb->last_results;
3745
3746 if ( $res === false ) :
3747 $this->error_message = __('Error: failure in updating password', 'usces');
3748 return 'login';
3749 else :
3750 return 'changepasscompletion';
3751 endif;
3752
3753 endif;
3754 }
3755
3756 function lostmail() {
3757 $delim = apply_filters( 'usces_filter_delim', $this->delim );
3758
3759 $_SESSION['usces_lostmail'] = trim($_POST['loginmail']);
3760 $id = session_id();
3761 $uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword';
3762 $res = usces_lostmail($uri);
3763 return $res;
3764
3765 }
3766
3767 function regist_member() {
3768 global $wpdb;
3769 $_POST = $this->stripslashes_deep_post($_POST);
3770
3771 $member = $this->get_member();
3772 $mode = $_POST['member_regmode'];
3773 $member_table = $wpdb->prefix . "usces_member";
3774 $member_meta_table = $wpdb->prefix . "usces_member_meta";
3775
3776 //20110715ysk start 0000203
3777 //$error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3778 $error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' or $_POST['member_regmode'] == 'editmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3779 //20110715ysk end
3780
3781 if ( $error_mes != '' ) {
3782
3783 $this->error_message = $error_mes;
3784 return $mode;
3785
3786 } elseif ( $_POST['member_regmode'] == 'editmemberform' ) {
3787
3788 $this->get_current_member();
3789 $mem_id = $this->current_member['id'];
3790 do_action('usces_action_pre_edit_memberdata', $_POST['member'], $mem_id);
3791
3792 //20130802ysk start 0000741
3793 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3794 $id = $wpdb->get_var( $query );
3795 if ( !empty($id) and $id != $mem_id ) {
3796 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3797 return $mode;
3798 }
3799 //20130802ysk end
3800
3801 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3802 $pass = $wpdb->get_var( $query );
3803
3804 $password = ( !empty($_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? md5(trim($_POST['member']['password1'])) : $pass;
3805 $query = $wpdb->prepare("UPDATE $member_table SET
3806 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3807 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3808 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3809 $password,
3810 trim($_POST['member']['name1']),
3811 trim($_POST['member']['name2']),
3812 trim($_POST['member']['name3']),
3813 trim($_POST['member']['name4']),
3814 trim($_POST['member']['zipcode']),
3815 trim($_POST['member']['pref']),
3816 trim($_POST['member']['address1']),
3817 trim($_POST['member']['address2']),
3818 trim($_POST['member']['address3']),
3819 trim($_POST['member']['tel']),
3820 trim($_POST['member']['fax']),
3821 trim($_POST['member']['mailaddress1']),
3822 $mem_id
3823 );
3824 $res = $wpdb->query( $query );
3825
3826 if( $res !== false ){
3827 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $mem_id);
3828 //20100818ysk start
3829 $res = $this->reg_custom_member($mem_id);
3830 //20100818ysk end
3831 do_action('usces_action_edit_memberdata', $_POST['member'], $mem_id);
3832 //$meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" );
3833 $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'remise_pcid', 'digitalcheck_ip_user_id'" );
3834 $query = $wpdb->prepare("DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )",
3835 $mem_id
3836 );
3837 $res = $wpdb->query( $query );
3838
3839 $this->get_current_member();
3840 return 'editmemberform';
3841
3842 } else {
3843 $this->error_message = __('Error:failure in update', 'usces');
3844 return $mode;
3845 }
3846
3847 } elseif ( $_POST['member_regmode'] == 'newmemberform' ) {
3848
3849 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3850 $id = $wpdb->get_var( $query );
3851 if ( !empty($id) ) {
3852 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3853 return $mode;
3854 } else {
3855
3856 $point = $this->options['start_point'];
3857 $pass = md5(trim($_POST['member']['password1']));
3858 $query = $wpdb->prepare("INSERT INTO $member_table
3859 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3860 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3861 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3862 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3863 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3864 trim($_POST['member']['mailaddress1']),
3865 $pass,
3866 0,
3867 "",
3868 $point,
3869 trim($_POST['member']['name1']),
3870 trim($_POST['member']['name2']),
3871 trim($_POST['member']['name3']),
3872 trim($_POST['member']['name4']),
3873 trim($_POST['member']['zipcode']),
3874 trim($_POST['member']['pref']),
3875 trim($_POST['member']['address1']),
3876 trim($_POST['member']['address2']),
3877 trim($_POST['member']['address3']),
3878 trim($_POST['member']['tel']),
3879 trim($_POST['member']['fax']),
3880 '',
3881 '',
3882 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3883 '');
3884 $res = $wpdb->query( $query );
3885
3886 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3887 //$this->get_current_member();
3888 if($res !== false) {
3889 $user = $_POST['member'];
3890 $user['ID'] = $wpdb->insert_id;
3891 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $user['ID']);
3892 //20110714ysk start 0000207
3893 //20100818ysk start
3894 //$res = $this->reg_custom_member($wpdb->insert_id);
3895 $res = $this->reg_custom_member($user['ID']);
3896 //20100818ysk end
3897 //20110714ysk end
3898 $mser = usces_send_regmembermail($user);
3899
3900 do_action('usces_action_member_registered', $_POST['member'], $user['ID']);
3901
3902 return 'newcompletion';
3903
3904 } else {
3905 $this->error_message = __('Error:failure in update', 'usces');
3906 return $mode;
3907 }
3908 }
3909
3910 } elseif ( $_POST['member_regmode'] == 'newmemberfromcart' ) {
3911
3912 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1']));
3913 $id = $wpdb->get_var( $query );
3914 if ( !empty($id) ) {
3915 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3916 return $mode;
3917 } else {
3918
3919 $point = $this->options['start_point'];
3920 $pass = md5(trim($_POST['customer']['password1']));
3921 $query = $wpdb->prepare("INSERT INTO $member_table
3922 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3923 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3924 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3925 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3926 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3927 trim($_POST['customer']['mailaddress1']),
3928 $pass,
3929 0,
3930 "",
3931 $point,
3932 trim($_POST['customer']['name1']),
3933 trim($_POST['customer']['name2']),
3934 trim($_POST['customer']['name3']),
3935 trim($_POST['customer']['name4']),
3936 trim($_POST['customer']['zipcode']),
3937 trim($_POST['customer']['pref']),
3938 trim($_POST['customer']['address1']),
3939 trim($_POST['customer']['address2']),
3940 trim($_POST['customer']['address3']),
3941 trim($_POST['customer']['tel']),
3942 trim($_POST['customer']['fax']),
3943 '',
3944 '',
3945 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3946 '');
3947 $res = $wpdb->query( $query );
3948
3949 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3950 //$this->get_current_member();
3951 if($res !== false) {
3952 //20110714ysk start 0000207
3953 $member_id = $wpdb->insert_id;
3954 //$this->set_member_meta_value('customer_country', $_POST['member']['country'], $wpdb->insert_id);
3955 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $member_id);
3956 //20100818ysk start
3957 //$res = $this->reg_custom_member($wpdb->insert_id);
3958 $res = $this->reg_custom_member($member_id);
3959 //20100818ysk end
3960 //20110714ysk end
3961 //usces_send_regmembermail();
3962 do_action('usces_action_member_registered', $_POST['customer'], $member_id);
3963 $user = $_POST['customer'];
3964 $user['ID'] = $member_id;
3965 $mser = usces_send_regmembermail($user);
3966 $_POST['loginmail'] = trim($_POST['customer']['mailaddress1']);
3967 $_POST['loginpass'] = trim($_POST['customer']['password1']);
3968 if( $this->member_login() == 'member' ){
3969 $_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart';
3970 return 'newcompletion';
3971 }
3972
3973 } else {
3974 $this->error_message = __('Error:failure in update', 'usces');
3975 return $mode;
3976 }
3977 }
3978
3979 //20110715ysk start 0000203
3980 } elseif ( $_POST['member_regmode'] == 'editmemberfromcart' ) {
3981
3982 $this->get_current_member();
3983 $mem_id = $this->current_member['id'];
3984 do_action('usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id);
3985
3986 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3987 $pass = $wpdb->get_var( $query );
3988
3989 $password = ( !empty($_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? md5(trim($_POST['customer']['password1'])) : $pass;
3990 $query = $wpdb->prepare("UPDATE $member_table SET
3991 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3992 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3993 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3994 $password,
3995 trim($_POST['customer']['name1']),
3996 trim($_POST['customer']['name2']),
3997 trim($_POST['customer']['name3']),
3998 trim($_POST['customer']['name4']),
3999 trim($_POST['customer']['zipcode']),
4000 trim($_POST['customer']['pref']),
4001 trim($_POST['customer']['address1']),
4002 trim($_POST['customer']['address2']),
4003 trim($_POST['customer']['address3']),
4004 trim($_POST['customer']['tel']),
4005 trim($_POST['customer']['fax']),
4006 trim($_POST['customer']['mailaddress1']),
4007 $mem_id
4008 );
4009 $res = $wpdb->query( $query );
4010 if( $res !== false ){
4011 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $mem_id);
4012 $res = $this->reg_custom_member($mem_id);
4013 do_action('usces_action_edit_memberdata', $_POST['customer'], $mem_id);
4014 unset($_SESSION['usces_member']);
4015 $this->member_just_login(trim($_POST['customer']['mailaddress1']), trim($_POST['customer']['password1']));
4016 return 'newcompletion';
4017
4018 } else {
4019 $this->error_message = __('Error:failure in update', 'usces');
4020 return $mode;
4021 }
4022 //20110715ysk end
4023 }
4024 }
4025
4026 function delete_member() {
4027 if( ! $this->is_member_logged_in() )
4028 return false;
4029 $mem = $this->get_member();
4030 if( ! $mem['ID'] )
4031 return false;
4032
4033 $res = usces_delete_memberdata( $mem['ID'] );
4034 if( $res ) {
4035 usces_send_delmembermail( $mem );
4036 }
4037
4038 return $res;
4039 }
4040
4041 function is_member_logged_in( $id = false ) {
4042 if( $id === false ){
4043 if( !empty($_SESSION['usces_member']['ID']) )
4044 return true;
4045 else
4046 return false;
4047 }else{
4048 if( !empty($_SESSION['usces_member']['ID']) && $_SESSION['usces_member']['ID'] == $id )
4049 return true;
4050 else
4051 return false;
4052 }
4053 }
4054
4055 function is_member($email) {
4056 global $wpdb;
4057
4058 $member_table = $wpdb->prefix . "usces_member";
4059 $query = $wpdb->prepare("SELECT mem_email FROM $member_table WHERE mem_email = %s", $email);
4060 $member = $wpdb->get_row( $query, ARRAY_A );
4061 if ( empty($member) ) {
4062 return false;
4063 }else{
4064 return true;
4065 }
4066 }
4067
4068 function member_login() {
4069 global $wpdb;
4070 $_POST = $this->stripslashes_deep_post($_POST);
4071
4072 $cookie = $this->get_cookie();
4073
4074
4075 if ( isset($cookie['rme']) && $cookie['rme'] == 'forever' && !isset($_POST['rememberme']) && !isset($_POST['loginmail'])) {
4076 $email = $cookie['name'];
4077 $member_table = $wpdb->prefix . "usces_member";
4078
4079 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
4080 $id = $wpdb->get_var( $query );
4081
4082 if ( !$id ) {
4083 $this->current_member['email'] = htmlspecialchars($email);
4084 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
4085 return 'login';
4086 } else {
4087 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s", $email);
4088 $member = $wpdb->get_row( $query, ARRAY_A );
4089 if ( empty($member) ) {
4090 $this->current_member['email'] = htmlspecialchars($email);
4091 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4092 return 'login';
4093 } else {
4094 $_SESSION['usces_member']['ID'] = $member['ID'];
4095 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4096 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4097 $_SESSION['usces_member']['point'] = $member['mem_point'];
4098 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4099 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4100 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4101 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4102 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4103 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4104 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4105 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4106 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4107 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4108 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4109 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4110 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4111 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4112 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4113 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4114 $_SESSION['usces_member']['status'] = $member['mem_status'];
4115 //20100818ysk start
4116 $this->set_session_custom_member($member['ID']);
4117 //20100818ysk end
4118 $this->get_current_member();
4119
4120 do_action( 'usces_action_after_login' );
4121 return apply_filters( 'usces_filter_member_login', 'member', $member );
4122 }
4123 }
4124 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginmail']) && isset($_POST['loginpass']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
4125 return 'login';
4126 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
4127 $this->current_member['email'] = trim($_POST['loginmail']);
4128 $this->error_message = __('<b>Error:</b> Enter the password.', 'usces');
4129 return 'login';
4130 } else if ( !isset($_POST['loginmail']) ){
4131 return 'login';
4132 } else {
4133 $email = isset($_POST['loginmail']) ? trim($_POST['loginmail']) : '';
4134 $pass = isset($_POST['loginpass']) ? md5(trim($_POST['loginpass'])) : '';
4135 $member_table = $wpdb->prefix . "usces_member";
4136
4137 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
4138 $id = $wpdb->get_var( $query );
4139
4140 if ( !$id ) {
4141 $this->current_member['email'] = htmlspecialchars($email);
4142 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
4143 return 'login';
4144 } else {
4145 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4146 $member = $wpdb->get_row( $query, ARRAY_A );
4147 if ( empty($member) ) {
4148 $this->current_member['email'] = htmlspecialchars($email);
4149 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4150 return 'login';
4151 } else {
4152 $_SESSION['usces_member']['ID'] = $member['ID'];
4153 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4154 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4155 $_SESSION['usces_member']['point'] = $member['mem_point'];
4156 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4157 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4158 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4159 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4160 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4161 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4162 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4163 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4164 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4165 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4166 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4167 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4168 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4169 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4170 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4171 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4172 $_SESSION['usces_member']['status'] = $member['mem_status'];
4173 //20100818ysk start
4174 $this->set_session_custom_member($member['ID']);
4175 //20100818ysk end
4176 $this->get_current_member();
4177
4178 if( isset($_POST['rememberme']) ){
4179 $cookie['name'] = $email;
4180 $cookie['rme'] = 'forever';
4181 $this->set_cookie($cookie);
4182 }else{
4183 $cookie['name'] = '';
4184 $cookie['rme'] = '';
4185 $this->set_cookie($cookie);
4186 }
4187
4188 do_action( 'usces_action_after_login' );
4189 return apply_filters( 'usces_filter_member_login', 'member', $member );
4190 }
4191 }
4192 }
4193 }
4194
4195 function member_just_login($email, $pass) {
4196 global $wpdb;
4197 $pass = md5($pass);
4198 $member_table = $wpdb->prefix . "usces_member";
4199
4200 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4201 $member = $wpdb->get_row( $query, ARRAY_A );
4202 if ( empty($member) ) {
4203 $this->current_member['email'] = htmlspecialchars($email);
4204 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4205 return 'login';
4206 } else {
4207 $_SESSION['usces_member']['ID'] = $member['ID'];
4208 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4209 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4210 $_SESSION['usces_member']['point'] = $member['mem_point'];
4211 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4212 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4213 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4214 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4215 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4216 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4217 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4218 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4219 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4220 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4221 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4222 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4223 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4224 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4225 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4226 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4227 $_SESSION['usces_member']['status'] = $member['mem_status'];
4228 //20100818ysk start
4229 $this->set_session_custom_member($member['ID']);
4230 //20100818ysk end
4231 $this->get_current_member();
4232
4233 // $cookie = $this->get_cookie();
4234 // if(isset($_POST['rememberme']) && $cookie){
4235 // $cookie['name'] = $email;
4236 // $cookie['pass'] = trim($_POST['loginpass']);
4237 // $this->set_cookie($cookie);
4238 // }else{
4239 // $cookie['name'] = '';
4240 // $cookie['pass'] = '';
4241 // $this->set_cookie($cookie);
4242 // }
4243
4244 do_action( 'usces_action_after_login' );
4245 return apply_filters( 'usces_filter_member_login', 'member', $member );
4246 }
4247 }
4248
4249 function member_logout() {
4250 unset($_SESSION['usces_member'], $_SESSION['usces_entry']);
4251 do_action('usces_action_member_logout');
4252 wp_redirect(get_option('home'));
4253 exit;
4254 }
4255
4256 function get_current_member() {
4257
4258 if ( isset($_SESSION['usces_member']['ID']) ) {
4259 $this->current_member['id'] = $_SESSION['usces_member']['ID'];
4260 $this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return');
4261 } else {
4262 $this->current_member['id'] = 0;
4263 $this->current_member['name'] = __('guest', 'usces');
4264 }
4265 }
4266
4267 function get_member() {
4268 $res = array(
4269 'ID' => '',
4270 'registered' => '',
4271 'mailaddress1' => '',
4272 'mailaddress2' => '',
4273 'password1' => '',
4274 'password2' => '',
4275 'point' => '',
4276 'name1' => '',
4277 'name2' => '',
4278 'name3' => '',
4279 'name4' => '',
4280 'zipcode' => '',
4281 'address1' => '',
4282 'address2' => '',
4283 'address3' => '',
4284 'tel' => '',
4285 'fax' => '',
4286 'country' => '',
4287 'pref' => '',
4288 'status' => ''
4289 );
4290 if(!empty($_SESSION['usces_member'])) {
4291 foreach ( $_SESSION['usces_member'] as $key => $value ) {
4292 //20100818ysk start
4293 if(is_array($_SESSION['usces_member'][$key]))
4294 $res[$key] = stripslashes_deep($value);
4295 else
4296 //20100818ysk end
4297 $res[$key] = stripslashes($value);
4298 }
4299 }
4300 return $res;
4301 }
4302
4303 function get_member_info( $mid ) {
4304 global $wpdb;
4305 $infos = array();
4306
4307 //if( !current_user_can('activate_plugins') ) return array();
4308
4309 $table = $wpdb->prefix . "usces_member";
4310 $query = $wpdb->prepare("SELECT * FROM $table WHERE ID = %d", $mid);
4311 $datas = $wpdb->get_results( $query, ARRAY_A );
4312 if( $datas ) {
4313 $infos = $datas[0];
4314
4315 $table = $wpdb->prefix . "usces_member_meta";
4316 $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid);
4317 $metas = $wpdb->get_results( $query, ARRAY_A );
4318
4319 foreach( $metas as $meta ){
4320 $infos[$meta['meta_key']] = maybe_unserialize($meta['meta_value']);
4321 }
4322 }
4323 return $infos;
4324 }
4325
4326 function set_member_info( $data=array(), $mid ) {
4327 global $wpdb;
4328
4329 $table = $wpdb->prefix . "usces_member";
4330 $res = $wpdb->update( $table, $data, array('ID'=>$mid), NULL, array('%d'));
4331 return $res;
4332 }
4333
4334 function is_order($mid, $oid) {
4335 global $wpdb;
4336
4337 $table = $wpdb->prefix . "usces_order";
4338 $query = $wpdb->prepare("SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid);
4339 $mem_id = $wpdb->get_var( $query );
4340 if ( empty($mem_id) ) {
4341 return false;
4342 }else{
4343 return true;
4344 }
4345 }
4346
4347 function is_purchased_item($mid, $post_id, $sku = NULL) {
4348 global $wpdb;
4349 $res = false;
4350
4351 $history = $this->get_member_history($mid);
4352 foreach ( $history as $umhs ) {
4353 $cart = $umhs['cart'];
4354 $status = $umhs['order_status'];
4355 for($i=0; $i<count($cart); $i++) {
4356 $cart_row = $cart[$i];
4357 $sku_code = urldecode($cart_row['sku']);
4358 if( empty($sku) ){
4359 if( $cart_row['post_id'] == $post_id && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4360 $res = true;
4361 break 2;
4362 }elseif( $cart_row['post_id'] == $post_id && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4363 $res = 'noreceipt';
4364 break 2;
4365 }
4366 }else{
4367 if( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4368 $res = true;
4369 break 2;
4370 }elseif( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4371 $res = 'noreceipt';
4372 break 2;
4373 }
4374 }
4375 }
4376
4377 }
4378 return $res;
4379 }
4380
4381 function get_order_data($order_id, $mode = '' ) {
4382 global $wpdb, $usces;
4383 $order_table = $wpdb->prefix . "usces_order";
4384
4385 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $order_id);
4386
4387 if( 'direct' == $mode ){
4388 $value = $wpdb->get_row( $query, ARRAY_A );
4389 return $value;
4390 }
4391
4392 $value = $wpdb->get_row( $query );
4393
4394 if( $value == NULL ) {
4395 return false;
4396 }else{
4397 $res =array();
4398 }
4399 if(strpos($value->order_status, 'cancel') !== false || strpos($value->order_status, 'estimate') !== false){
4400 return false;
4401 }
4402
4403 $res = array(
4404 'ID' => $value->ID,
4405 'mem_id' => $value->mem_id,
4406 'cart' => unserialize($value->order_cart),
4407 'condition' => unserialize($value->order_condition),
4408 'getpoint' => $value->order_getpoint,
4409 'usedpoint' => $value->order_usedpoint,
4410 'discount' => $value->order_discount,
4411 'payment_name' => $value->order_payment_name,
4412 'shipping_charge' => $value->order_shipping_charge,
4413 'cod_fee' => $value->order_cod_fee,
4414 'tax' => $value->order_tax,
4415 'end_price' => $value->order_item_total_price - $value->order_usedpoint + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax,
4416 'status' => $value->order_status,
4417 'date' => mysql2date(__('Y/m/d'), $value->order_date),
4418 'modified' => mysql2date(__('Y/m/d'), $value->order_modified)
4419 );
4420
4421 return $res;
4422 }
4423
4424 function get_orderIDs_by_postID($mem_id, $post_id) {
4425 global $wpdb;
4426 $order_table = $wpdb->prefix . "usces_order";
4427
4428 $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);
4429 $rows = $wpdb->get_query( $query, ARRAY_A );
4430
4431 if( $value == NULL ) {
4432 return false;
4433 }else{
4434 foreach($rows as $row){
4435 if(strpos($row['order_status'], 'cancel') !== false || strpos($row['order_status'], 'estimate') !== false){
4436 continue;
4437 }else{
4438 $carts = unserialize($row['order_cart']);
4439 foreach($carts as $cart){
4440 if( $post_id == $cart['post_id'] ){
4441 $res[] = $row['ID'];
4442 break;
4443 }
4444 }
4445 }
4446 }
4447 }
4448 return $res;
4449 }
4450
4451 function incart_check() {
4452 //$_POST = $this->stripslashes_deep_post($_POST);
4453 $mes = array();
4454
4455 $ids = array_keys($_POST['inCart']);
4456 $post_id = $ids[0];
4457 $skus = array_keys($_POST['inCart'][$post_id]);
4458 $sku = $skus[0];
4459 $quant = isset($_POST['quant'][$post_id][$sku]) ? (int)$_POST['quant'][$post_id][$sku] : 1;
4460 $stock = $this->getItemZaikoNum($post_id, $sku);
4461 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku);
4462 $itemRestriction = get_post_meta($post_id, '_itemRestriction',true );
4463
4464 if( 1 > $quant ){
4465 $mes[$post_id][$sku] = __('enter the correct amount', 'usces') . "<br />";
4466 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4467 $mes[$post_id][$sku] = sprintf(__("This article is limited by %d at a time.", 'usces'), $itemRestriction) . "<br />";
4468 }else if( $quant > (int)$stock && !WCUtils::is_blank($stock) ){
4469 $mes[$post_id][$sku] = __('Sorry, stock is insufficient.', 'usces') . ' ' . __('Current stock', 'usces') . $stock . "<br />";
4470 }else if( 1 < $zaiko_id ){
4471 $mes[$post_id][$sku] = __('Sorry, this item is sold out.', 'usces') . "<br />";
4472 }
4473
4474 $ioptkeys = $this->get_itemOptionKey( $post_id, true );
4475 if($ioptkeys){
4476 foreach($ioptkeys as $key => $value){
4477 $optValues = $this->get_itemOptions( urldecode($value), $post_id );
4478 if( 0 == $optValues['means'] ){ //case of select
4479 if( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][$post_id][$sku][$value] ){
4480 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4481 }
4482 }elseif( 1 == $optValues['means'] ){ //case of multiselect
4483 if( $optValues['essential'] ){
4484 $mselect = 0;
4485 foreach((array)$_POST['itemOption'][$post_id][$sku][$value] as $mvalue){
4486 if(!empty($mvalue) and '#NONE#' != $mvalue) $mselect++;
4487 }
4488 if( $mselect == 0 ){
4489 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4490 }
4491 }
4492 }else{ //case of text
4493 if( $optValues['essential'] && WCUtils::is_blank($_POST['itemOption'][$post_id][$sku][$value]) ){
4494 $mes[$post_id][$sku] .= sprintf(__("Input the %s", 'usces'), urldecode($value)) . "<br />";
4495 }
4496 }
4497 }
4498 }
4499
4500 $mes = apply_filters('usces_filter_incart_check', $mes, $post_id, $sku);
4501
4502 if( isset($mes[$post_id]) && is_array($mes[$post_id]) ){
4503 foreach( $mes[$post_id] as $skukey => $skuvalue ){
4504 $mes[$post_id][$skukey] = rtrim($skuvalue, "<br />");
4505 }
4506 }
4507
4508 if( !empty($mes) ){
4509 $_SESSION['usces_singleitem']['itemOption'] = $_POST['itemOption'];
4510 $_SESSION['usces_singleitem']['quant'] = $_POST['quant'];
4511 $_SESSION['usces_singleitem']['error_message'] = $mes;
4512 if( false === strpos($_POST['usces_referer'], 'http') ){
4513 $parse_url = parse_url(get_home_url());
4514 header('location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $_POST['usces_referer'] . '#cart_button');
4515 }else{
4516 header('location: ' . $_POST['usces_referer'] . '#cart_button');
4517 }
4518 exit;
4519 }
4520
4521 do_action('usces_action_incart_checked', $mes, $post_id, $sku);
4522 }
4523
4524 function zaiko_check() {
4525 $mes = '';
4526 $cart = $this->cart->get_cart();
4527 $stocks = array();
4528
4529 for($i=0; $i<count($cart); $i++) {
4530 $cart_row = $cart[$i];
4531 $post_id = $cart_row['post_id'];
4532 $sku = $cart_row['sku'];
4533 $sku_code = urldecode($cart_row['sku']);
4534
4535 $quant = ( isset($_POST['quant']) ) ? trim($_POST['quant'][$i][$post_id][$sku]) : $cart_row['quantity'];
4536 //$zaiko_status = $this->getItemZaiko($post_id, $sku);
4537 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku_code);
4538 $stock = $this->getItemZaikoNum($post_id, $sku_code);
4539 if( !isset($stocks[$post_id][$sku]) ){
4540 if( !WCUtils::is_blank($stock) ){
4541 $stocks[$post_id][$sku] = $stock;
4542 }else{
4543 $stocks[$post_id][$sku] = NULL;
4544 }
4545 }
4546 $checkstock = $stocks[$post_id][$sku];
4547 $stocks[$post_id][$sku] = $stocks[$post_id][$sku] - $quant;
4548 $itemRestriction = get_post_meta($post_id, '_itemRestriction', true);
4549
4550 //$red = (in_array($zaiko_status, array(__('Sold Out', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'red' : '';
4551
4552 if( 1 > (int)$quant ){
4553 $mes .= sprintf(__("Enter the correct amount for the No.%d item.", 'usces'), ($i+1)) . "<br />";
4554 }else if( 1 < $zaiko_id || WCUtils::is_zero($stock) ){
4555 $mes .= sprintf(__('Sorry, No.%d item is sold out.', 'usces'), ($i+1)) . "<br />";
4556 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4557 $mes .= sprintf(__('This article is limited by %1$d at a time for the No.%2$d item.', 'usces'), $itemRestriction, ($i+1)) . "<br />";
4558 }else if( 0 > $stocks[$post_id][$sku] && !WCUtils::is_blank($stock) ){
4559 $mes .= sprintf(__('Stock of No.%1$d item is remainder %2$d.', 'usces'), ($i+1), $checkstock) . "<br />";
4560 }
4561 }
4562 $mes = apply_filters('usces_filter_zaiko_check', $mes, $cart);
4563 return $mes;
4564 }
4565
4566 function member_check() {
4567 $mes = '';
4568 foreach ( $_POST['member'] as $key => $vlue ) {
4569 $_SESSION['usces_member'][$key] = trim($vlue);
4570 }
4571 //0000526
4572 $member_pass_rule_min = $this->options['system']['member_pass_rule_min'];
4573 $member_pass_rule_max = $this->options['system']['member_pass_rule_max'];
4574
4575 if ( !WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ){
4576 if( !empty( $member_pass_rule_max ) ){
4577 if( $member_pass_rule_min > strlen( trim($_POST['member']['password1']) ) || strlen( trim($_POST['member']['password1']) ) > $member_pass_rule_max ){
4578 $mes .= sprintf(__('Please enter %2$s characters a minimum of %1$s characters and a maximum password.', 'usces'), $member_pass_rule_min, $member_pass_rule_max ) . "<br />";
4579 }
4580 }else{
4581 if( $member_pass_rule_min > strlen( trim($_POST['member']['password1']) ) ){
4582 $mes .= sprintf(__('Please enter at least %s characters password.', 'usces'), $member_pass_rule_min) . "<br />";
4583 }
4584 }
4585 }
4586 if ( $_POST['member_regmode'] == 'editmemberform' ) {
4587 if ( (!WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ) && trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4588 $mes .= __('Password is not correct.', 'usces') . "<br />";
4589
4590 if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) )
4591 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4592
4593 } else {
4594 if ( WCUtils::is_blank($_POST['member']['password1']) || WCUtils::is_blank($_POST['member']['password2']) || trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4595 $mes .= __('Password is not correct.', 'usces') . "<br />";
4596 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']) )
4597 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4598
4599 }
4600 if ( WCUtils::is_blank($_POST["member"]["name1"]) )
4601 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4602 // if ( trim($_POST["member"]["name3"]) == "" && USCES_JP )
4603 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4604 if ( WCUtils::is_blank($_POST["member"]["zipcode"]) )
4605 $mes .= __('postal code is not correct', 'usces') . "<br />";
4606 if ( $_POST["member"]["pref"] == __('-- Select --', 'usces') )
4607 $mes .= __('enter the prefecture', 'usces') . "<br />";
4608 if ( WCUtils::is_blank($_POST["member"]["address1"]) )
4609 $mes .= __('enter the city name', 'usces') . "<br />";
4610 if ( WCUtils::is_blank($_POST["member"]["address2"]) )
4611 $mes .= __('enter house numbers', 'usces') . "<br />";
4612 if ( WCUtils::is_blank($_POST["member"]["tel"]) )
4613 $mes .= __('enter phone numbers', 'usces') . "<br />";
4614 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4615 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4616
4617 $mes = apply_filters('usces_filter_member_check', $mes);
4618
4619 return $mes;
4620 }
4621
4622 function member_check_fromcart() {
4623 $mes = '';
4624 //0000526
4625 $member_pass_rule_min = $this->options['system']['member_pass_rule_min'];
4626 $member_pass_rule_max = $this->options['system']['member_pass_rule_max'];
4627
4628 if ( !WCUtils::is_blank($_POST['customer']['password1']) || !WCUtils::is_blank($_POST['customer']['password2']) ){
4629 if( !empty( $member_pass_rule_max ) ){
4630 if( $member_pass_rule_min > strlen( trim($_POST['customer']['password1']) ) || strlen( trim($_POST['customer']['password1']) ) > $member_pass_rule_max )
4631 $mes .= sprintf(__('Please enter %2$s characters a minimum of %1$s characters and a maximum password.', 'usces'), $member_pass_rule_min, $member_pass_rule_max ) . "<br />";
4632 }else{
4633 if( $member_pass_rule_min > strlen( trim($_POST['customer']['password1']) ) )
4634 $mes .= sprintf(__('Please enter at least %s characters password.', 'usces'), $member_pass_rule_min) . "<br />";
4635 }
4636 }
4637 if ( WCUtils::is_blank($_POST['customer']['password1']) || WCUtils::is_blank($_POST['customer']['password2']) || trim($_POST['customer']['password1']) != trim($_POST['customer']['password2']) )
4638 $mes .= __('Password is not correct.', 'usces') . "<br />";
4639 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']) )
4640 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4641 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4642 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4643 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4644 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4645 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4646 $mes .= __('postal code is not correct', 'usces') . "<br />";
4647 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4648 $mes .= __('enter the prefecture', 'usces') . "<br />";
4649 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4650 $mes .= __('enter the city name', 'usces') . "<br />";
4651 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4652 $mes .= __('enter house numbers', 'usces') . "<br />";
4653 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4654 $mes .= __('enter phone numbers', 'usces') . "<br />";
4655 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4656 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4657
4658 $mes = apply_filters('usces_filter_member_check_fromcart', $mes);
4659
4660 return $mes;
4661 }
4662
4663 function admin_member_check() {
4664 global $wpdb;
4665 $mes = '';
4666 if ( !is_email( trim($_POST['member']["email"]) ) ){
4667 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4668 }else{
4669 $member_table = $wpdb->prefix . "usces_member";
4670 $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
4671 if( trim($_POST['member']["email"]) != $mem_email ){
4672 $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
4673 if( !empty($mem_ID) )
4674 $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />";
4675 }
4676 }
4677 if ( WCUtils::is_blank($_POST['member']["name1"]) )
4678 $mes .= __('Name is not correct', 'usces') . "<br />";
4679 // if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
4680 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4681 // if ( trim($_POST['member']["zipcode"]) == "" )
4682 // $mes .= __('postal code is not correct', 'usces') . "<br />";
4683 // if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
4684 // $mes .= __('enter the prefecture', 'usces') . "<br />";
4685 // if ( trim($_POST['member']["address1"]) == "" )
4686 // $mes .= __('enter the city name', 'usces') . "<br />";
4687 // if ( trim($_POST['member']["address2"]) == "" )
4688 // $mes .= __('enter house numbers', 'usces') . "<br />";
4689 // if ( trim($_POST['member']["tel"]) == "" )
4690 // $mes .= __('enter phone numbers', 'usces') . "<br />";
4691 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4692 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4693
4694 $mes = apply_filters('usces_filter_admin_member_check', $mes);
4695
4696 return $mes;
4697 }
4698
4699 function customer_check() {
4700 $mes = '';
4701 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']) )
4702 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4703 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4704 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4705 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4706 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4707 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4708 $mes .= __('postal code is not correct', 'usces') . "<br />";
4709 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4710 $mes .= __('enter the prefecture', 'usces') . "<br />";
4711 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4712 $mes .= __('enter the city name', 'usces') . "<br />";
4713 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4714 $mes .= __('enter house numbers', 'usces') . "<br />";
4715 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4716 $mes .= __('enter phone numbers', 'usces') . "<br />";
4717 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4718 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4719
4720 $mes = apply_filters('usces_filter_customer_check', $mes);
4721
4722 return $mes;
4723 }
4724
4725 function admin_new_member_check() {
4726 global $wpdb;
4727
4728 $member_pass_rule_min = $this->options['system']['member_pass_rule_min'];
4729 $member_pass_rule_max = $this->options['system']['member_pass_rule_max'];
4730 $mes = '';
4731
4732 if ( !WCUtils::is_blank( $_POST['member']['password'] ) ){
4733 if( !empty( $member_pass_rule_max ) ){
4734 if( $member_pass_rule_min > strlen( trim($_POST['member']['password']) ) || strlen( trim($_POST['member']['password']) ) > $member_pass_rule_max ){
4735 $mes .= sprintf(__('Please enter %2$s characters a minimum of %1$s characters and a maximum password.', 'usces'), $member_pass_rule_min, $member_pass_rule_max ) . "<br />";
4736 }
4737 }else{
4738 if( $member_pass_rule_min > strlen( trim($_POST['member']['password']) ) ){
4739 $mes .= sprintf(__('Please enter at least %s characters password.', 'usces'), $member_pass_rule_min) . "<br />";
4740 }
4741 }
4742 }
4743 if ( !is_email( trim($_POST['member']["email"]) ) ){
4744 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4745 }else{
4746 $member_table = $wpdb->prefix . "usces_member";
4747 $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
4748 if( trim($_POST['member']["email"]) != $mem_email ){
4749 $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
4750 if( !empty($mem_ID) )
4751 $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />";
4752 }
4753 }
4754 if ( WCUtils::is_blank($_POST['member']["name1"]) )
4755 $mes .= __('Name is not correct', 'usces') . "<br />";
4756 // if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
4757 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4758 // if ( trim($_POST['member']["zipcode"]) == "" )
4759 // $mes .= __('postal code is not correct', 'usces') . "<br />";
4760 // if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
4761 // $mes .= __('enter the prefecture', 'usces') . "<br />";
4762 // if ( trim($_POST['member']["address1"]) == "" )
4763 // $mes .= __('enter the city name', 'usces') . "<br />";
4764 // if ( trim($_POST['member']["address2"]) == "" )
4765 // $mes .= __('enter house numbers', 'usces') . "<br />";
4766 // if ( trim($_POST['member']["tel"]) == "" )
4767 // $mes .= __('enter phone numbers', 'usces') . "<br />";
4768 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4769 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4770
4771 $mes = apply_filters('usces_filter_admin_member_check', $mes);
4772
4773 return $mes;
4774 }
4775
4776 function delivery_check() {
4777 $mes = '';
4778 if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
4779 if ( WCUtils::is_blank($_POST["delivery"]["name1"]) )
4780 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4781 // if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP )
4782 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4783 if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) )
4784 $mes .= __('postal code is not correct', 'usces') . "<br />";
4785 if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') )
4786 $mes .= __('enter the prefecture', 'usces') . "<br />";
4787 if ( WCUtils::is_blank($_POST["delivery"]["address1"]) )
4788 $mes .= __('enter the city name', 'usces') . "<br />";
4789 if ( WCUtils::is_blank($_POST["delivery"]["address2"]) )
4790 $mes .= __('enter house numbers', 'usces') . "<br />";
4791 if ( WCUtils::is_blank($_POST["delivery"]["tel"]) )
4792 $mes .= __('enter phone numbers', 'usces') . "<br />";
4793 }
4794 if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) )
4795 $mes .= __('chose one from delivery method.', 'usces') . "<br />";
4796 if ( !isset($_POST['offer']['payment_name']) ){
4797 $mes .= __('chose one from payment options.', 'usces') . "<br />";
4798 }else{
4799 $payments = $this->getPayments($_POST['offer']['payment_name']);
4800 if('COD' == $payments['settlement']){
4801 $total_items_price = $this->get_total_price();
4802 $usces_entries = $this->cart->get_entry();
4803 $materials = array(
4804 'total_items_price' => $usces_entries['order']['total_items_price'],
4805 'discount' => $usces_entries['order']['discount'],
4806 'shipping_charge' => $usces_entries['order']['shipping_charge'],
4807 'cod_fee' => $usces_entries['order']['cod_fee'],
4808 );
4809 $tax = $this->getTax( $total_items_price, $materials );
4810 $total_items_price = $total_items_price + $tax;
4811 $cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
4812 if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount )
4813 $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')) . "<br />";
4814 }
4815 }
4816 //20101119ysk start
4817 if(isset($_POST['offer']['delivery_method']) and isset($_POST['offer']['payment_name'])) {
4818 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4819 if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) {
4820 $payments = $this->getPayments($_POST['offer']['payment_name']);
4821 if('COD' == $payments['settlement'])
4822 $mes .= __('COD is not available.', 'usces') . "<br />";
4823 }
4824 }
4825 //20101119ysk end
4826 //20110317ysk start
4827 if(isset($_POST['offer']['delivery_method'])) {
4828 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4829 $country = $_SESSION['usces_entry']["delivery"]["country"];
4830 $local_country = usces_get_base_country();
4831 if($country == $local_country) {
4832 if($this->options['delivery_method'][$d_method_index]['intl'] == 1) {
4833 $mes .= __('Delivery method is incorrect. Can not specify an international flight.', 'usces') . "<br />";
4834 }
4835 } else {
4836 if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) {
4837 $mes .= __('Delivery method is incorrect. Specify the international flights.', 'usces') . "<br />";
4838 }
4839 }
4840 }
4841 //20110317ysk end
4842
4843 $mes = apply_filters('usces_filter_delivery_check', $mes);
4844
4845 return $mes;
4846 }
4847
4848 function point_check( $entries ) {
4849 $member = $this->get_member();
4850 $this->set_cart_fees( $member, $entries );
4851 $mes = '';
4852 if( isset($_POST['offer']["usedpoint"]) ) {
4853 if ( WCUtils::is_blank($_POST['offer']["usedpoint"]) || !preg_match("/^[0-9]+$/", $_POST['offer']["usedpoint"]) || (int)$_POST['offer']["usedpoint"] < 0 ) {
4854 $mes .= __('Invalid value. Please enter in the numbers.', 'usces') . "<br />";
4855 } else {
4856 /* if ( trim($_POST['offer']["usedpoint"]) > $member['point'] ){
4857 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".$member['point']."pt<br />";
4858 $_POST['offer']["usedpoint"] = 0;
4859 $array = array(
4860 'usedpoint' => 0
4861 );
4862 $this->cart->set_order_entry( $array );
4863 }elseif($this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'])){
4864 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'])."pt<br />";
4865 $_POST['offer']["usedpoint"] = 0;
4866 $array = array(
4867 'usedpoint' => 0
4868 );
4869 $this->cart->set_order_entry( $array );
4870 }elseif(!$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'])){
4871 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4872 $_POST['offer']["usedpoint"] = 0;
4873 $array = array(
4874 'usedpoint' => 0
4875 );
4876 $this->cart->set_order_entry( $array );
4877 }
4878 */ if( trim($_POST['offer']["usedpoint"]) > $member['point'] ) {
4879 $mes .= __('You have exceeded the maximum available.', 'usces')."max".$member['point']."pt<br />";
4880 } elseif( $this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee']) ) {
4881 $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'])."pt<br />";
4882 } elseif( !$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount']) ) {
4883 $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4884 }
4885 $mes = apply_filters( 'usces_filter_point_check', $mes );
4886 if( '' != $mes ) {
4887 $_POST['offer']["usedpoint"] = 0;
4888 $array = array(
4889 'usedpoint' => 0
4890 );
4891 $this->cart->set_order_entry( $array );
4892 }
4893 }
4894 }
4895 $mes = apply_filters('usces_filter_point_check_last', $mes);
4896 return $mes;
4897 }
4898
4899 function lostpass_mailaddcheck() {
4900 $mes = '';
4901 if ( !is_email($_POST['loginmail']) || WCUtils::is_blank($_POST['loginmail']) ) {
4902 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4903 }elseif( !$this->is_member($_POST['loginmail']) ){
4904 $mes .= __('It is the e-mail address that there is not.', 'usces') . "<br />";
4905 }
4906
4907 return $mes;
4908 }
4909
4910 function changepass_check() {
4911 $mes = '';
4912 if ( WCUtils::is_blank($_POST['loginpass1']) || WCUtils::is_blank($_POST['loginpass2']) || (trim($_POST['loginpass1']) != trim($_POST['loginpass2'])))
4913 $mes .= __('Password is not correct.', 'usces') . "<br />";
4914
4915 return $mes;
4916 }
4917
4918 function get_page() {
4919 return $this->page;
4920 }
4921
4922 function check_display_mode() {
4923 $options = get_option('usces');
4924 if( isset($options['display_mode']) && $options['display_mode'] == 'Maintenancemode' ) return;
4925
4926 $start['hour'] = empty($options['campaign_schedule']['start']['hour']) ? 0 : $options['campaign_schedule']['start']['hour'];
4927 $start['min'] = empty($options['campaign_schedule']['start']['min']) ? 0 : $options['campaign_schedule']['start']['min'];
4928 $start['month'] = empty($options['campaign_schedule']['start']['month']) ? 0 : $options['campaign_schedule']['start']['month'];
4929 $start['day'] = empty($options['campaign_schedule']['start']['day']) ? 0 : $options['campaign_schedule']['start']['day'];
4930 $start['year'] = empty($options['campaign_schedule']['start']['year']) ? 0 : $options['campaign_schedule']['start']['year'];
4931 $end['hour'] = empty($options['campaign_schedule']['end']['hour']) ? 0 : $options['campaign_schedule']['end']['hour'];
4932 $end['min'] = empty($options['campaign_schedule']['end']['min']) ? 0 : $options['campaign_schedule']['end']['min'];
4933 $end['month'] = empty($options['campaign_schedule']['end']['month']) ? 0 : $options['campaign_schedule']['end']['month'];
4934 $end['day'] = empty($options['campaign_schedule']['end']['day']) ? 0 : $options['campaign_schedule']['end']['day'];
4935 $end['year'] = empty($options['campaign_schedule']['end']['year']) ? 0 : $options['campaign_schedule']['end']['year'];
4936 $starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']);
4937 $endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']);
4938 $current_time = current_time('timestamp');
4939
4940 if( ($current_time >= $starttime) && ($current_time <= $endtime) )
4941 $options['display_mode'] = 'Promotionsale';
4942 else
4943 $options['display_mode'] = 'Usualsale';
4944
4945 update_option('usces', $options);
4946
4947 }
4948
4949 function update_business_days() {
4950 $options = get_option('usces');
4951 $datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
4952 $dhour = (int)substr($datetimestr, 11, 2);
4953 $dminute = (int)substr($datetimestr, 14, 2);
4954 $dsecond = (int)substr($datetimestr, 17, 2);
4955 $dmonth = (int)substr($datetimestr, 5, 2);
4956 $dday = (int)substr($datetimestr, 8, 2);
4957 $dyear = (int)substr($datetimestr, 0, 4);
4958 $dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear);
4959 $datenow = getdate($dtimestamp);
4960 //list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1);
4961 list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], 1, 1);
4962
4963 if(isset($options['business_days'][$year][$mon][1]))
4964 unset($options['business_days'][$year][$mon]);
4965
4966 for($i=0; $i<12; $i++){
4967 //list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i);
4968 list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], 1, $i);
4969 $last = getLastDay($year, $mon);
4970 for($j=1; $j<=$last; $j++){
4971 if(!isset($options['business_days'][$year][$mon][$j]))
4972 $options['business_days'][$year][$mon][$j] = 1;
4973 }
4974 }
4975 update_option('usces', $options);
4976 $this->options = get_option('usces');
4977 $_SESSION['usces_checked_business_days'] = '';
4978 }
4979
4980 function display_cart() {
4981 if($this->cart->num_row() > 0) {
4982 include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
4983 } else {
4984 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4985 }
4986 }
4987
4988 function display_cart_confirm() {
4989 if($this->cart->num_row() > 0) {
4990 include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php');
4991 } else {
4992 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4993 }
4994 }
4995
4996 function set_initial() {
4997
4998 $rets07 = usces_upgrade_07();
4999 $rets11 = usces_upgrade_11();
5000 $this->set_default_theme();
5001 $this->set_default_page();
5002 $this->set_default_categories();
5003 $this->create_table();
5004 $this->update_table();
5005 $rets14 = usces_upgrade_14();
5006 $rets141 = usces_upgrade_141();
5007 $this->update_options();//20120710ysk 0000472
5008 }
5009
5010 function create_table() {
5011 global $wpdb;
5012
5013 if ( ! empty($wpdb->charset) )
5014 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
5015 if ( ! empty($wpdb->collate) )
5016 $charset_collate .= " COLLATE $wpdb->collate";
5017
5018 $access_table = $wpdb->prefix . "usces_access";
5019 $member_table = $wpdb->prefix . "usces_member";
5020 $member_meta_table = $wpdb->prefix . "usces_member_meta";
5021 $order_table = $wpdb->prefix . "usces_order";
5022 $order_meta_table = $wpdb->prefix . "usces_order_meta";
5023 $ordercart_table = $wpdb->prefix . "usces_ordercart";
5024 $ordercart_meta_table = $wpdb->prefix . "usces_ordercart_meta";
5025 $log_table = $wpdb->prefix . "usces_log";
5026
5027 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5028
5029 if($wpdb->get_var("show tables like '$access_table'") != $access_table) {
5030
5031 $sql = "CREATE TABLE " . $access_table . " (
5032 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5033 acc_key VARCHAR( 50 ) NOT NULL ,
5034 acc_type VARCHAR( 50 ) NULL ,
5035 acc_value LONGTEXT NULL ,
5036 acc_date DATE NOT NULL DEFAULT '0000-00-00',
5037 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
5038 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
5039 acc_str1 VARCHAR( 200 ) NULL ,
5040 acc_str2 VARCHAR( 200 ) NULL ,
5041 KEY acc_key ( acc_key ),
5042 KEY acc_type ( acc_type ),
5043 KEY acc_date ( acc_date ),
5044 KEY acc_num1 ( acc_num1 ),
5045 KEY acc_num2 ( acc_num2 )
5046 ) ENGINE = MYISAM AUTO_INCREMENT=0 $charset_collate;";
5047
5048 dbDelta($sql);
5049 add_option("usces_db_access", USCES_DB_ACCESS);
5050 }
5051 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
5052
5053 $sql = "CREATE TABLE " . $member_table . " (
5054 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5055 mem_email VARCHAR( 100 ) NOT NULL ,
5056 mem_pass VARCHAR( 64 ) NOT NULL ,
5057 mem_status INT( 11 ) NOT NULL DEFAULT '0',
5058 mem_cookie VARCHAR( 13 ) NULL ,
5059 mem_point INT( 11 ) NOT NULL DEFAULT '0',
5060 mem_name1 VARCHAR( 100 ) NOT NULL ,
5061 mem_name2 VARCHAR( 100 ) NULL ,
5062 mem_name3 VARCHAR( 100 ) NULL ,
5063 mem_name4 VARCHAR( 100 ) NULL ,
5064 mem_zip VARCHAR( 50 ) NULL ,
5065 mem_pref VARCHAR( 100 ) NOT NULL ,
5066 mem_address1 VARCHAR( 100 ) NOT NULL ,
5067 mem_address2 VARCHAR( 100 ) NULL ,
5068 mem_address3 VARCHAR( 100 ) NULL ,
5069 mem_tel VARCHAR( 100 ) NOT NULL ,
5070 mem_fax VARCHAR( 100 ) NULL ,
5071 mem_delivery_flag TINYINT ( 1 ) NULL ,
5072 mem_delivery LONGTEXT,
5073 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5074 mem_nicename VARCHAR( 50 ) NULL ,
5075 KEY mem_email ( mem_email ) ,
5076 KEY mem_pass ( mem_pass )
5077 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
5078
5079 dbDelta($sql);
5080 add_option("usces_db_member", USCES_DB_MEMBER);
5081 }
5082 if($wpdb->get_var("show tables like '$member_meta_table'") != $member_meta_table) {
5083
5084 $sql = "CREATE TABLE " . $member_meta_table . " (
5085 mmeta_id bigint(20) NOT NULL auto_increment,
5086 member_id bigint(20) NOT NULL default '0',
5087 meta_key varchar(255) default NULL,
5088 meta_value longtext,
5089 PRIMARY KEY (mmeta_id),
5090 KEY order_id (member_id),
5091 KEY meta_key (meta_key)
5092 ) ENGINE = MYISAM $charset_collate;";
5093
5094 dbDelta($sql);
5095 add_option("usces_db_member_meta", USCES_DB_MEMBER_META);
5096 }
5097 if($wpdb->get_var("show tables like '$order_table'") != $order_table) {
5098
5099 $sql = "CREATE TABLE " . $order_table . " (
5100 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5101 mem_id BIGINT( 20 ) UNSIGNED NULL ,
5102 order_email VARCHAR( 100 ) NOT NULL ,
5103 order_name1 VARCHAR( 100 ) NOT NULL ,
5104 order_name2 VARCHAR( 100 ) NULL ,
5105 order_name3 VARCHAR( 100 ) NULL ,
5106 order_name4 VARCHAR( 100 ) NULL ,
5107 order_zip VARCHAR( 50 ) NULL ,
5108 order_pref VARCHAR( 100 ) NOT NULL ,
5109 order_address1 VARCHAR( 100 ) NOT NULL ,
5110 order_address2 VARCHAR( 100 ) NULL ,
5111 order_address3 VARCHAR( 100 ) NULL ,
5112 order_tel VARCHAR( 100 ) NOT NULL ,
5113 order_fax VARCHAR( 100 ) NULL ,
5114 order_delivery LONGTEXT,
5115 order_cart LONGTEXT,
5116 order_note TEXT,
5117 order_delivery_time VARCHAR( 100 ) NOT NULL ,
5118 order_payment_name VARCHAR( 100 ) NOT NULL ,
5119 order_condition TEXT,
5120 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5121 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
5122 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
5123 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5124 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5125 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5126 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5127 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5128 order_modified VARCHAR( 20 ) NULL ,
5129 order_status VARCHAR( 255 ) NULL ,
5130 order_check TEXT NULL ,
5131 order_delidue_date VARCHAR( 30 ) NULL ,
5132 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
5133 order_delivery_date VARCHAR( 100 ) NULL,
5134 KEY order_email ( order_email ) ,
5135 KEY order_name1 ( order_name1 ) ,
5136 KEY order_name2 ( order_name2 ) ,
5137 KEY order_pref ( order_pref ) ,
5138 KEY order_address1 ( order_address1 ) ,
5139 KEY order_tel ( order_tel ) ,
5140 KEY order_date ( order_date )
5141 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
5142
5143 dbDelta($sql);
5144 add_option("usces_db_order", USCES_DB_ORDER);
5145 }
5146 if($wpdb->get_var("show tables like '$order_meta_table'") != $order_meta_table) {
5147
5148 $sql = "CREATE TABLE " . $order_meta_table . " (
5149 ometa_id bigint(20) NOT NULL auto_increment,
5150 order_id bigint(20) NOT NULL default '0',
5151 meta_key varchar(255) default NULL,
5152 meta_value longtext,
5153 PRIMARY KEY (ometa_id),
5154 KEY order_id (order_id),
5155 KEY meta_key (meta_key)
5156 ) ENGINE = MYISAM $charset_collate;";
5157
5158 dbDelta($sql);
5159 add_option("usces_db_order_meta", USCES_DB_ORDER_META);
5160 }
5161
5162 if($wpdb->get_var("show tables like '$ordercart_table'") != $ordercart_table) {
5163
5164 $sql = "CREATE TABLE " . $ordercart_table . " (
5165 `cart_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
5166 `order_id` bigint( 20 ) NOT NULL ,
5167 `group_id` int( 3 ) NOT NULL DEFAULT '0',
5168 `row_index` int( 3 ) NOT NULL ,
5169 `post_id` bigint( 20 ) NOT NULL ,
5170 `item_code` varchar( 100 ) NOT NULL ,
5171 `item_name` varchar( 250 ) NOT NULL ,
5172 `cprice` decimal( 12, 0 ) DEFAULT NULL ,
5173 `sku_code` varchar( 100 ) NOT NULL ,
5174 `sku_name` varchar( 250 ) DEFAULT NULL ,
5175 `price` decimal( 12, 0 ) NOT NULL ,
5176 `quantity` float NOT NULL ,
5177 `unit` varchar( 50 ) DEFAULT NULL ,
5178 `tax` decimal( 10, 0 ) DEFAULT NULL ,
5179 `destination_id` int( 10 ) DEFAULT NULL ,
5180 `cart_serial` text,
5181 PRIMARY KEY ( `cart_id` ) ,
5182 UNIQUE KEY `row` ( `row_index` , `destination_id` , `order_id` ) ,
5183 KEY `order_id` ( `order_id` ) ,
5184 KEY `post_id` ( `post_id` ) ,
5185 KEY `item_code` ( `item_code` ) ,
5186 KEY `item_name` ( `item_name` ) ,
5187 KEY `sku_code` ( `sku_code` ) ,
5188 KEY `sku_name` ( `sku_name` )
5189 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
5190
5191 dbDelta($sql);
5192 add_option("usces_db_ordercart", USCES_DB_ORDERCART);
5193 }
5194 if($wpdb->get_var("show tables like '$ordercart_meta_table'") != $ordercart_meta_table) {
5195
5196 $sql = "CREATE TABLE " . $ordercart_meta_table . " (
5197 `cartmeta_id` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5198 `cart_id` bigint( 20 ) NOT NULL DEFAULT '0',
5199 `meta_type` varchar( 100 ) NOT NULL ,
5200 `meta_key` varchar( 255 ) DEFAULT NULL ,
5201 `meta_value` longtext,
5202 PRIMARY KEY ( `cartmeta_id` ) ,
5203 KEY `cart_id` ( `cart_id` ) ,
5204 KEY `meta_key` ( `meta_key` )
5205 ) ENGINE = MYISAM $charset_collate;";
5206
5207 dbDelta($sql);
5208 add_option("usces_db_ordercart_meta", USCES_DB_ORDERCART_META);
5209 }
5210 if($wpdb->get_var("show tables like '$log_table'") != $log_table) {
5211
5212 $sql = "CREATE TABLE " . $log_table . " (
5213 `ID` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5214 `datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5215 `log` LONGTEXT NULL ,
5216 PRIMARY KEY ( `ID` ) ,
5217 KEY `datetime` ( `datetime` )
5218 ) ENGINE = MYISAM $charset_collate;";
5219
5220 dbDelta($sql);
5221 add_option("usces_db_log", USCES_DB_LOG);
5222 }
5223
5224 }
5225
5226 function update_table()
5227 {
5228 global $wpdb;
5229 $access_table = $wpdb->prefix . "usces_access";
5230 $member_table = $wpdb->prefix . "usces_member";
5231 $member_meta_table = $wpdb->prefix . "usces_member_meta";
5232 $order_table = $wpdb->prefix . "usces_order";
5233 $order_meta_table = $wpdb->prefix . "usces_order_meta";
5234 $ordercart_table = $wpdb->prefix . "usces_ordercart";
5235 $ordercart_meta_table = $wpdb->prefix . "usces_ordercart_meta";
5236 $log_table = $wpdb->prefix . "usces_log";
5237
5238 $access_ver = get_option( "usces_db_access" );
5239 $member_ver = get_option( "usces_db_member" );
5240 $member_meta_ver = get_option( "usces_db_member_meta" );
5241 $order_ver = get_option( "usces_db_order" );
5242 $order_meta_ver = get_option( "usces_db_order_meta" );
5243 $ordercart_ver = get_option( "usces_db_ordercart" );
5244 $ordercart_meta_ver = get_option( "usces_db_ordercart_meta" );
5245 $log_ver = get_option( "usces_db_log" );
5246
5247 if( $access_ver != USCES_DB_ACCESS ) {
5248 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5249 $sql = "CREATE TABLE " . $access_table . " (
5250 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5251 acc_key VARCHAR( 50 ) NOT NULL ,
5252 acc_type VARCHAR( 50 ) NULL ,
5253 acc_value LONGTEXT NULL ,
5254 acc_date DATE NOT NULL DEFAULT '0000-00-00',
5255 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
5256 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
5257 acc_str1 VARCHAR( 200 ) NULL ,
5258 acc_str2 VARCHAR( 200 ) NULL ,
5259 KEY acc_key ( acc_key ),
5260 KEY acc_type ( acc_type ),
5261 KEY acc_date ( acc_date ),
5262 KEY acc_num1 ( acc_num1 ),
5263 KEY acc_num2 ( acc_num2 )
5264 ) ENGINE = MYISAM;";
5265
5266 dbDelta($sql);
5267 update_option( "usces_db_access", USCES_DB_ACCESS );
5268 }
5269 if( $member_ver != USCES_DB_MEMBER ) {
5270 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5271 $sql = "CREATE TABLE " . $member_table . " (
5272 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5273 mem_email VARCHAR( 100 ) NOT NULL ,
5274 mem_pass VARCHAR( 64 ) NOT NULL ,
5275 mem_status INT( 11 ) NOT NULL DEFAULT '0',
5276 mem_cookie VARCHAR( 13 ) NULL ,
5277 mem_point INT( 11 ) NOT NULL DEFAULT '0',
5278 mem_name1 VARCHAR( 100 ) NOT NULL ,
5279 mem_name2 VARCHAR( 100 ) NULL ,
5280 mem_name3 VARCHAR( 100 ) NULL ,
5281 mem_name4 VARCHAR( 100 ) NULL ,
5282 mem_zip VARCHAR( 50 ) NULL ,
5283 mem_pref VARCHAR( 100 ) NOT NULL ,
5284 mem_address1 VARCHAR( 100 ) NOT NULL ,
5285 mem_address2 VARCHAR( 100 ) NULL ,
5286 mem_address3 VARCHAR( 100 ) NULL ,
5287 mem_tel VARCHAR( 100 ) NOT NULL ,
5288 mem_fax VARCHAR( 100 ) NULL ,
5289 mem_delivery_flag TINYINT ( 1 ) NULL ,
5290 mem_delivery LONGTEXT,
5291 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5292 mem_nicename VARCHAR( 50 ) NULL ,
5293 KEY mem_email ( mem_email ) ,
5294 KEY mem_pass ( mem_pass )
5295 ) ENGINE = MYISAM;";
5296
5297 dbDelta($sql);
5298 update_option( "usces_db_member", USCES_DB_MEMBER );
5299 }
5300 if( $member_meta_ver != USCES_DB_MEMBER_META ) {
5301 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5302 $sql = "CREATE TABLE " . $member_meta_table . " (
5303 mmeta_id bigint(20) NOT NULL auto_increment,
5304 member_id bigint(20) NOT NULL default '0',
5305 meta_key varchar(255) default NULL,
5306 meta_value longtext,
5307 PRIMARY KEY (mmeta_id),
5308 KEY order_id (member_id),
5309 KEY meta_key (meta_key)
5310 ) ENGINE = MYISAM;";
5311
5312 dbDelta($sql);
5313 update_option("usces_db_member_meta", USCES_DB_MEMBER_META);
5314 }
5315 if( $order_ver != USCES_DB_ORDER ) {
5316 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5317 $sql = "CREATE TABLE " . $order_table . " (
5318 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5319 mem_id BIGINT( 20 ) UNSIGNED NULL ,
5320 order_email VARCHAR( 100 ) NOT NULL ,
5321 order_name1 VARCHAR( 100 ) NOT NULL ,
5322 order_name2 VARCHAR( 100 ) NULL ,
5323 order_name3 VARCHAR( 100 ) NULL ,
5324 order_name4 VARCHAR( 100 ) NULL ,
5325 order_zip VARCHAR( 50 ) NULL ,
5326 order_pref VARCHAR( 100 ) NOT NULL ,
5327 order_address1 VARCHAR( 100 ) NOT NULL ,
5328 order_address2 VARCHAR( 100 ) NULL ,
5329 order_address3 VARCHAR( 100 ) NULL ,
5330 order_tel VARCHAR( 100 ) NOT NULL ,
5331 order_fax VARCHAR( 100 ) NULL ,
5332 order_delivery LONGTEXT,
5333 order_cart LONGTEXT,
5334 order_note TEXT,
5335 order_delivery_time VARCHAR( 100 ) NOT NULL ,
5336 order_payment_name VARCHAR( 100 ) NOT NULL ,
5337 order_condition TEXT,
5338 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5339 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
5340 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
5341 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5342 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5343 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5344 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5345 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5346 order_modified VARCHAR( 20 ) NULL ,
5347 order_status VARCHAR( 255 ) NULL ,
5348 order_check TEXT NULL ,
5349 order_delidue_date VARCHAR( 30 ) NULL ,
5350 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
5351 order_delivery_date VARCHAR( 100 ) NULL,
5352 KEY order_email ( order_email ) ,
5353 KEY order_name1 ( order_name1 ) ,
5354 KEY order_name2 ( order_name2 ) ,
5355 KEY order_pref ( order_pref ) ,
5356 KEY order_address1 ( order_address1 ) ,
5357 KEY order_tel ( order_tel ) ,
5358 KEY order_date ( order_date )
5359 ) ENGINE = MYISAM;";
5360
5361 dbDelta($sql);
5362 update_option("usces_db_order", USCES_DB_ORDER);
5363 }
5364 if( $order_meta_ver != USCES_DB_ORDER_META ) {
5365 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5366 $sql = "CREATE TABLE " . $order_meta_table . " (
5367 ometa_id bigint(20) NOT NULL auto_increment,
5368 order_id bigint(20) NOT NULL default '0',
5369 meta_key varchar(255) default NULL,
5370 meta_value longtext,
5371 PRIMARY KEY (ometa_id),
5372 KEY order_id (order_id),
5373 KEY meta_key (meta_key)
5374 ) ENGINE = MYISAM;";
5375
5376 dbDelta($sql);
5377 update_option("usces_db_order_meta", USCES_DB_ORDER_META);
5378 }
5379 if( $ordercart_ver != USCES_DB_ORDERCART ) {
5380 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5381 $sql = "CREATE TABLE " . $ordercart_table . " (
5382 `cart_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
5383 `order_id` bigint( 20 ) NOT NULL ,
5384 `group_id` int( 3 ) NOT NULL DEFAULT '0',
5385 `row_index` int( 3 ) NOT NULL ,
5386 `post_id` bigint( 20 ) NOT NULL ,
5387 `item_code` varchar( 100 ) NOT NULL ,
5388 `item_name` varchar( 250 ) NOT NULL ,
5389 `cprice` decimal( 12, 0 ) DEFAULT NULL ,
5390 `sku_code` varchar( 100 ) NOT NULL ,
5391 `sku_name` varchar( 250 ) DEFAULT NULL ,
5392 `price` decimal( 12, 0 ) NOT NULL ,
5393 `quantity` float NOT NULL ,
5394 `unit` varchar( 50 ) DEFAULT NULL ,
5395 `tax` decimal( 10, 0 ) DEFAULT NULL ,
5396 `destination_id` int( 10 ) DEFAULT NULL ,
5397 `cart_serial` text,
5398 PRIMARY KEY ( `cart_id` ) ,
5399 UNIQUE KEY `row` ( `row_index` , `destination_id` , `order_id` ) ,
5400 KEY `order_id` ( `order_id` ) ,
5401 KEY `post_id` ( `post_id` ) ,
5402 KEY `item_code` ( `item_code` ) ,
5403 KEY `item_name` ( `item_name` ) ,
5404 KEY `sku_code` ( `sku_code` ) ,
5405 KEY `sku_name` ( `sku_name` )
5406 ) ENGINE = MYISAM;";
5407
5408 dbDelta($sql);
5409 update_option("usces_db_ordercart", USCES_DB_ORDERCART);
5410 }
5411 if( $ordercart_meta_ver != USCES_DB_ORDERCART_META ) {
5412 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5413 $sql = "CREATE TABLE " . $ordercart_meta_table . " (
5414 `cartmeta_id` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5415 `cart_id` bigint( 20 ) NOT NULL DEFAULT '0',
5416 `meta_type` varchar( 100 ) NOT NULL ,
5417 `meta_key` varchar( 255 ) DEFAULT NULL ,
5418 `meta_value` longtext,
5419 PRIMARY KEY ( `cartmeta_id` ) ,
5420 KEY `cart_id` ( `cart_id` ) ,
5421 KEY `meta_key` ( `meta_key` )
5422 ) ENGINE = MYISAM;";
5423
5424 dbDelta($sql);
5425 update_option("usces_db_ordercart_meta", USCES_DB_ORDERCART_META);
5426 }
5427 if( $log_ver != USCES_DB_LOG ) {
5428 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5429 $sql = "CREATE TABLE " . $log_table . " (
5430 `ID` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5431 `datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5432 `log` LONGTEXT NULL ,
5433 PRIMARY KEY ( `ID` ) ,
5434 KEY `datetime` ( `datetime` )
5435 ) ENGINE = MYISAM;";
5436
5437 dbDelta($sql);
5438 update_option("usces_db_log", USCES_DB_LOG);
5439 }
5440 }
5441
5442 function set_default_theme()
5443 {
5444 $themepath = USCES_WP_CONTENT_DIR.'/themes/welcart_default';
5445 $resourcepath = USCES_WP_CONTENT_DIR.'/plugins/usc-e-shop/theme/welcart_default';
5446 if( file_exists($themepath) ) return false;
5447 if(!file_exists($resourcepath) ) return false;
5448
5449 mkdir($themepath, 0775);
5450 $this->dir_copy($resourcepath, $themepath);
5451
5452 }
5453
5454 function dir_copy($source, $dest){
5455 if ($res = opendir($source)) {
5456 while (($file = readdir($res)) !== false) {
5457 $sorce_path = $source . '/' . $file;
5458 $dest_path = $dest . '/' . $file;
5459 $filetype = @filetype($sorce_path);
5460 if( $filetype == 'file' ) {
5461 copy($sorce_path, $dest_path);
5462 }elseif( $filetype == 'dir' && $file != '..' && $file != '.' ){
5463 mkdir($dest_path);
5464 $this->dir_copy($sorce_path, $dest_path);
5465 }
5466 }
5467 closedir($res);
5468 }
5469 }
5470
5471 function set_default_page()
5472 {
5473 global $wpdb;
5474 $datetime = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
5475 $datetime_gmt = gmdate('Y-m-d H:i:s', time());
5476
5477 //cart_page
5478 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER);
5479 $cart_number = $wpdb->get_var( $query );
5480 if( $cart_number === NULL ) {
5481 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5482 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5483 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5484 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5485 VALUES (%d, %s, %s, %s, %s, %s, %s,
5486 %s, %s, %s, %s, %s, %s, %s, %s,
5487 %s, %d, %s, %d, %s, %s, %d)",
5488 1, $datetime, $datetime_gmt, '', __('Cart', 'usces'), '', 'publish',
5489 'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt,
5490 '', 0, '', 0, 'page', '', 0);
5491 $wpdb->query($query);
5492 $cart_number = $wpdb->insert_id;
5493 if( $cart_number !== NULL ) {
5494 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5495 $cart_number, '_wp_page_template', 'uscescart.php');
5496 $wpdb->query($query);
5497 }
5498 }
5499 update_option('usces_cart_number', $cart_number);
5500
5501 //member_page
5502 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER);
5503 $member_number = $wpdb->get_var( $query );
5504 if( $member_number === NULL ) {
5505 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5506 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5507 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5508 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5509 VALUES (%d, %s, %s, %s, %s, %s, %s,
5510 %s, %s, %s, %s, %s, %s, %s, %s,
5511 %s, %d, %s, %d, %s, %s, %d)",
5512 1, $datetime, $datetime_gmt, '', __('Membership', 'usces'), '', 'publish',
5513 'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt,
5514 '', 0, '', 0, 'page', '', 0);
5515 $wpdb->query($query);
5516 $member_number = $wpdb->insert_id;
5517 if( $member_number !== NULL ) {
5518 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5519 $member_number, '_wp_page_template', 'uscesmember.php');
5520 $wpdb->query($query);
5521 }
5522 }
5523 update_option('usces_member_number', $member_number);
5524
5525 }
5526
5527 function set_default_categories()
5528 {
5529 global $wpdb;
5530
5531 $idObj = get_category_by_slug('item');
5532 if( empty($idObj) ) {
5533 $item_cat = array('cat_name' => __('Items', 'usces'), 'category_description' => '', 'category_nicename' => 'item', 'category_parent' => 0);
5534 $item_cat_id = wp_insert_category($item_cat);
5535 update_option('usces_item_cat_parent_id', $item_cat_id);
5536 }
5537
5538 $idObj = get_category_by_slug('itemreco');
5539 if( empty($idObj) && isset($item_cat_id) ) {
5540 $itemreco_cat = array('cat_name' => __('Items recommended', 'usces'), 'category_description' => '', 'category_nicename' => 'itemreco', 'category_parent' => $item_cat_id);
5541 $itemreco_cat_id = wp_insert_category($itemreco_cat);
5542 }
5543
5544 $idObj = get_category_by_slug('itemnew');
5545 if( empty($idObj) && isset($item_cat_id) ) {
5546 $itemnew_cat = array('cat_name' => __('New items', 'usces'), 'category_description' => '', 'category_nicename' => 'itemnew', 'category_parent' => $item_cat_id);
5547 $itemnew_cat_id = wp_insert_category($itemnew_cat);
5548 }
5549
5550 $idObj = get_category_by_slug('itemgenre');
5551 if( empty($idObj) && isset($item_cat_id) ) {
5552 $itemgenre_cat = array('cat_name' => __('Item genre', 'usces'), 'category_description' => '', 'category_nicename' => 'itemgenre', 'category_parent' => $item_cat_id);
5553 $itemgenre_cat_id = wp_insert_category($itemgenre_cat);
5554 }
5555 }
5556 //20120710ysk start 0000472
5557 function update_options() {
5558 $target_market = $this->options['system']['target_market'];
5559
5560 $update_shipping_charge = false;
5561 $shipping_charge = isset($this->options['shipping_charge']) ? $this->options['shipping_charge'] : array();
5562 foreach( (array)$target_market as $tm ) {
5563 for( $i = 0; $i < count($shipping_charge); $i++ ) {
5564 if( isset($shipping_charge[$i]['country']) and $shipping_charge[$i]['country'] == $tm ) {
5565 foreach( $shipping_charge[$i]['value'] as $pref => $value ) {
5566 $shipping_charge[$i][$tm][$pref] = $value;
5567 }
5568 unset($shipping_charge[$i]['country']);
5569 unset($shipping_charge[$i]['value']);
5570 $update_shipping_charge = true;
5571 }
5572 }
5573 }
5574 if( $update_shipping_charge ) $this->options['shipping_charge'] = $shipping_charge;
5575
5576 $update_delivery_days = false;
5577 $delivery_days = isset($this->options['delivery_days']) ? $this->options['delivery_days'] : array();
5578 foreach( (array)$target_market as $tm ) {
5579 for( $i = 0; $i < count($delivery_days); $i++ ) {
5580 if( isset($delivery_days[$i]['country']) and $delivery_days[$i]['country'] == $tm ) {
5581 foreach( $delivery_days[$i]['value'] as $pref => $value ) {
5582 $delivery_days[$i][$tm][$pref] = $value;
5583 }
5584 unset($delivery_days[$i]['country']);
5585 unset($delivery_days[$i]['value']);
5586 $update_delivery_days = true;
5587 }
5588 }
5589 }
5590 if( $update_delivery_days ) $this->options['delivery_days'] = $delivery_days;
5591
5592 //20140131ysk start
5593 $update_acting_settings_sbps = false;
5594 if( isset($this->options['acting_settings']['sbps']['card_activate']) and 'on' == $this->options['acting_settings']['sbps']['card_activate'] ) {
5595 if( empty($this->options['acting_settings']['sbps']['send_url']) or 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do' != $this->options['acting_settings']['sbps']['send_url'] ) {
5596 $this->options['acting_settings']['sbps']['send_url'] = 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do';
5597 $update_acting_settings_sbps = true;
5598 }
5599 }
5600
5601 $update_acting_settings_paydesign = false;
5602 if( isset($this->options['acting_settings']['digitalcheck']['card_activate']) and 'on' == $this->options['acting_settings']['digitalcheck']['card_activate'] ) {
5603 $pos = strpos( $this->options['acting_settings']['digitalcheck']['send_url_card'], 'paydesign' );
5604 if( $pos === false ) {
5605 $this->options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
5606 $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(ペイデザイン)';
5607 $update_acting_settings_paydesign = true;
5608 }
5609 if( isset($this->options['acting_settings']['digitalcheck']['card_user_id']) and 'on' == $this->options['acting_settings']['digitalcheck']['card_user_id'] ) {
5610 $pos = strpos( $this->options['acting_settings']['digitalcheck']['send_url_user_id'], 'paydesign' );
5611 if( $pos === false ) {
5612 $this->options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.paydesign.jp/settle/settlex/credit2.dll";
5613 $update_acting_settings_paydesign = true;
5614 }
5615 }
5616 }
5617 if( isset($this->options['acting_settings']['digitalcheck']['conv_activate']) and 'on' == $this->options['acting_settings']['digitalcheck']['conv_activate'] ) {
5618 $pos = strpos( $this->options['acting_settings']['digitalcheck']['send_url_conv'], 'paydesign' );
5619 if( $pos === false ) {
5620 $this->options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
5621 $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(ペイデザイン)';
5622 $update_acting_settings_paydesign = true;
5623 }
5624 }
5625
5626 if( $update_shipping_charge or $update_delivery_days or $update_acting_settings_sbps or $update_acting_settings_paydesign )
5627 update_option( 'usces', $this->options );
5628
5629 if( $update_acting_settings_paydesign )
5630 update_option( 'usces_payment_structure', $this->payment_structure );
5631 //20140131ysk end
5632 }
5633 //20120710ysk end
5634 function get_item_cat_ids(){
5635 $args = array('child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0, 'hierarchical' => 0);
5636 $categories = get_categories( $args );
5637 foreach($categories as $category){
5638 $ids[] = $category->term_id;
5639 }
5640 return $ids;
5641 }
5642
5643 function get_item_post_ids(){
5644 global $wpdb;
5645 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5646 $ids = $wpdb->get_col( $query );
5647
5648 return $ids;
5649 }
5650
5651 function get_item_cat_genre_ids( $post_id ){
5652 $ids = array();
5653 $all_ids = array();
5654 $genre = get_category_by_slug( 'itemgenre' );
5655 $genre_id = $genre->term_id;
5656 $args = array('child_of' => $genre_id, 'hide_empty' => 0, 'hierarchical' => 0);
5657 $categories = get_categories( $args );
5658 foreach($categories as $category){
5659 $ids[] = $category->term_id;
5660 }
5661 $allcats = get_the_category( $post_id );
5662 foreach($allcats as $cat){
5663 $all_ids[] = $cat->term_id;
5664 }
5665 //$all_ids =
5666 $results = array_intersect($ids, $all_ids);
5667
5668 return $results;
5669 }
5670
5671 function set_item_mime($post_id, $str)
5672 {
5673 global $wpdb;
5674 if( WCUtils::is_blank($str) ) return;
5675
5676 $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id);
5677 $results = $wpdb->query( $query );
5678 return $results;
5679 }
5680
5681 function isAdnminSSL()
5682 {
5683 $plugins = get_option('active_plugins');
5684 foreach($plugins as $plugin) {
5685 if( false !== strpos($plugin, USCES_ADMIN_SSL_BASE_NAME) )
5686 return true;
5687 }
5688 return false;
5689 }
5690
5691 function getGuidTax() {
5692 $tax_rate = (int)$this->options['tax_rate'];
5693
5694 if( isset($this->options['tax_mode']) ){
5695 if ( 'exclude' == $this->options['tax_mode'] )
5696 $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>';
5697 else
5698 $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>';
5699 }else{
5700 if ( 0 < $tax_rate )
5701 $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>';
5702 else
5703 $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>';
5704 }
5705
5706 return apply_filters('usces_filter_tax_guid', $str, $tax_rate);
5707 }
5708
5709 function getItemCode($post_id) {
5710 $str = get_post_meta($post_id, '_itemCode', true);
5711 return $str;
5712 }
5713
5714 function getItemName($post_id) {
5715 $str = get_post_meta($post_id, '_itemName', true);
5716 return $str;
5717 }
5718
5719 function getItemRestriction($post_id) {
5720 $str = get_post_meta($post_id, '_itemRestriction', true);
5721 return $str;
5722 }
5723
5724 function getItemPointrate($post_id) {
5725 $str = get_post_meta($post_id, '_itemPointrate', true);
5726 return $str;
5727 }
5728
5729 function getItemShipping($post_id) {
5730 $str = get_post_meta($post_id, '_itemShipping', true);
5731 return $str;
5732 }
5733
5734 function getItemShippingCharge($post_id) {
5735 $str = get_post_meta($post_id, '_itemShippingCharge', true);
5736 return (float)$str;
5737 }
5738
5739 function getItemDeliveryMethod($post_id) {
5740 $str = get_post_meta($post_id, '_itemDeliveryMethod', true);
5741 if( empty($str) )
5742 return array();
5743 else
5744 return $str;
5745 }
5746
5747 function getItemIndividualSCharge($post_id) {
5748 $str = get_post_meta($post_id, '_itemIndividualSCharge', true);
5749 return $str;
5750 }
5751
5752 function getItemGpNum1($post_id) {
5753 $str = get_post_meta($post_id, '_itemGpNum1', true);
5754 return $str;
5755 }
5756
5757 function getItemGpNum2($post_id) {
5758 $str = get_post_meta($post_id, '_itemGpNum2', true);
5759 return $str;
5760 }
5761
5762 function getItemGpNum3($post_id) {
5763 $str = get_post_meta($post_id, '_itemGpNum3', true);
5764 return $str;
5765 }
5766
5767 function getItemGpDis1($post_id) {
5768 $str = get_post_meta($post_id, '_itemGpDis1', true);
5769 return $str;
5770 }
5771
5772 function getItemGpDis2($post_id) {
5773 $str = get_post_meta($post_id, '_itemGpDis2', true);
5774 return $str;
5775 }
5776
5777 function getItemGpDis3($post_id) {
5778 $str = get_post_meta($post_id, '_itemGpDis3', true);
5779 return $str;
5780 }
5781
5782 function getItemSku($post_id, $index = '') {
5783 $array = array();
5784 $skus = $this->get_skus($post_id, 'sort');
5785 foreach((array)$skus as $sku){
5786 $array[] = $sku['code'];
5787 }
5788 if(!$array) return false;
5789 if($index == ''){
5790 return $array;
5791 }else if(isset($array[$index])){
5792 return $array[$index];
5793 }else{
5794 return false;
5795 }
5796 }
5797
5798 function getItemPrice($post_id, $skukey = '') {
5799 $array = array();
5800 $skus = $this->get_skus($post_id, 'code');
5801 foreach((array)$skus as $key => $sku){
5802 $array[$key] = (float)str_replace('.', '', $sku['price']);
5803 }
5804 if(!$array) return false;
5805 if($skukey == ''){
5806 return $array;
5807 }else if(isset($array[$skukey])){
5808 return $array[$skukey];
5809 }else{
5810 return false;
5811 }
5812 }
5813
5814 function getItemDiscount($post_id, $skukey = '') {
5815 $display_mode = $this->options['display_mode'];
5816 $array = array();
5817 $skus = $this->get_skus($post_id, 'code');
5818 foreach((array)$skus as $key => $sku){
5819 $price = (float)str_replace(',', '', $sku['price']);
5820 if ( $display_mode == 'Promotionsale' ) {
5821 if ( $this->options['campaign_privilege'] == 'discount' ){
5822 if( 0 === (int)$this->options['campaign_category'] || in_category((int)$this->options['campaign_category'], $post_id) ){
5823 $discount = $price * $this->options['privilege_discount'] / 100;
5824 }else{
5825 $discount = 0;
5826 }
5827 }else if ( $this->options['campaign_privilege'] == 'point' ){
5828 $discount = 0;
5829 }
5830 }
5831
5832 $discount = ceil($discount);
5833 $array[$key] = $discount;
5834 }
5835 if(!$array) return false;
5836 if($skukey == ''){
5837 return $array;
5838 }else if(isset($array[$skukey])){
5839 return $array[$skukey];
5840 }else{
5841 return false;
5842 }
5843 }
5844
5845 function getItemZaiko($post_id, $skukey = '') {
5846 $array = array();
5847 $skus = $this->get_skus($post_id, 'code');
5848 foreach((array)$skus as $key => $sku){
5849 $num = $sku['stock'];
5850 $array[$key] = $this->zaiko_status[$num];
5851 }
5852 if(!$array) return false;
5853 if($skukey == ''){
5854 return $array;
5855 }else if(isset($array[$skukey])){
5856 return $array[$skukey];
5857 }else{
5858 return false;
5859 }
5860 }
5861
5862 function getItemZaikoStatusId($post_id, $skukey = '') {
5863 $array = array();
5864 $skus = $this->get_skus($post_id, 'code');
5865 foreach((array)$skus as $key => $sku){
5866 $num = $sku['stock'];
5867 $array[$key] = $num;
5868 }
5869 if(!$array) return false;
5870 if($skukey == ''){
5871 return $array;
5872 }else if(isset($array[$skukey])){
5873 return $array[$skukey];
5874 }else{
5875 return false;
5876 }
5877 }
5878
5879 function updateItemZaiko($post_id, $skucode, $value) {
5880 $res = usces_update_sku( $post_id, $skucode, 'stock', $value );
5881 if( !$res ){
5882 return false;
5883 }else{
5884 return true;
5885 }
5886 }
5887
5888 function getItemZaikoNum($post_id, $skukey = '') {
5889 $array = array();
5890 $skus = $this->get_skus($post_id, 'code');
5891 foreach((array)$skus as $key => $sku){
5892 $array[$key] = $sku['stocknum'];
5893 }
5894 if(!$array) return false;
5895 if($skukey == ''){
5896 return $array;
5897 }else if(isset($array[$skukey])){
5898 return $array[$skukey];
5899 }else{
5900 return false;
5901 }
5902 }
5903
5904 function updateItemZaikoNum($post_id, $skucode, $value) {
5905 $res = usces_update_sku( $post_id, $skucode, 'stocknum', $value );
5906 if( !$res ){
5907 return false;
5908 }else{
5909 return true;
5910 }
5911 }
5912 //20120629ysk start 0000520
5913 function getItemDivision( $post_id ){
5914 if( usces_is_item($post_id) ){
5915 $item_division = get_post_meta($post_id, '_item_division', true);
5916 $division = empty($item_division) ? 'shipped' : $item_division;
5917 }else{
5918 $division = NULL;
5919 }
5920 return $division;
5921 }
5922 //20120629ysk end
5923 function getItemChargingType( $post_id, $cart = array() ){
5924 if( usces_is_item($post_id) ){
5925 $charging = get_post_meta($post_id, '_item_charging_type', true);
5926 //if( !defined('WCEX_DLSELLER') )
5927 if( !defined('WCEX_DLSELLER') and !defined('WCEX_AUTO_DELIVERY') )
5928 $charging = NULL;
5929 }else{
5930 $charging = NULL;
5931 }
5932 switch( $charging ){
5933 case 0:
5934 $type = 'once';
5935 break;
5936 case 1:
5937 $type = 'continue';
5938 break;
5939 case 2:
5940 $type = 'regular';
5941 if( !empty($cart) ) {
5942 if( empty($cart['advance']) ) {
5943 $type = 'once';
5944 } else {
5945 if( is_array($cart['advance']) and array_key_exists( 'regular', $cart['advance'] ) ) {
5946 $regular = maybe_unserialize( $cart['advance']['regular'] );
5947 } else {
5948 $advance = $this->cart->wc_unserialize( $cart['advance'] );
5949 $sku = urldecode( $cart['sku'] );
5950 $sku_encoded = $cart['sku'];
5951 $regular = $advance[$post_id][$sku_encoded]['regular'];
5952 }
5953 $unit = isset( $regular['unit'] ) ? $regular['unit'] : '';
5954 $interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0;
5955 if( empty($unit) or 1 > $interval ) //通常課金扱い
5956 $type = 'once';
5957 }
5958 }
5959 break;
5960 default:
5961 $type = NULL;
5962 }
5963 return $type;
5964 }
5965
5966 function getItemFrequency( $post_id ){
5967 $frequency = get_post_meta($post_id, '_item_frequency',true );
5968 return $frequency;
5969 }
5970
5971 function getItemChargingDay( $post_id ){
5972 $array = get_post_meta($post_id, '_item_chargingday',true );
5973 $day = (int)$array;
5974 $chargingday = empty($day) ? 1 : $day;
5975 return $chargingday;
5976 }
5977
5978 function getItemSkuDisp($post_id, $skukey = '') {
5979 $array = array();
5980 $skus = $this->get_skus($post_id, 'code');
5981 foreach((array)$skus as $key => $sku){
5982 $array[$key] = $sku['name'];
5983 }
5984 if(!$array) return false;
5985 if($skukey == ''){
5986 return $array;
5987 }else if(isset($array[$skukey])){
5988 return $array[$skukey];
5989 }else{
5990 return false;
5991 }
5992 }
5993
5994 // function getItemSkuChargingType($post_id, $skukey = '') {
5995 // $fields = get_post_custom($post_id);
5996 // $skus = array();
5997 // foreach((array)$fields as $key => $value){
5998 // if( preg_match('/^_isku_/', $key, $match) ){
5999 // $key = substr($key, 6);
6000 // $values = maybe_unserialize($value[0]);
6001 // if( isset($values['charging_type']) && "undefined" != $values['charging_type'] && !empty($values['charging_type']) ){
6002 // $skus[$key] = $values['charging_type'];
6003 // }else{
6004 // continue;
6005 // }
6006 // }
6007 // }
6008 // if( empty($skus) ) return false;
6009 // if($skukey == ''){
6010 // return $skus;
6011 // }elseif( isset($skus[$skukey]) ){
6012 // return $skus[$skukey];
6013 // }else{
6014 // return false;
6015 // }
6016 // }
6017
6018 function getItemSkuUnit($post_id, $skukey = '') {
6019 $array = array();
6020 $skus = $this->get_skus($post_id, 'code');
6021 foreach((array)$skus as $key => $sku){
6022 $array[$key] = $sku['unit'];
6023 }
6024 if(!$array) return false;
6025 if($skukey == ''){
6026 return $array;
6027 }else if(isset($array[$skukey])){
6028 return $array[$skukey];
6029 }else{
6030 return false;
6031 }
6032 }
6033
6034 function get_item( $post_id ) {
6035 $usces_item['post_id'] = $post_id;
6036 $usces_item['itemCode'] = $this->getItemCode($post_id);
6037 $usces_item['itemName'] = $this->getItemName($post_id);
6038
6039 $skus = $this->get_skus($post_id, 'code');
6040 foreach((array)$skus as $key => $sku){
6041 $usces_item['skuCodes'][] = $key;
6042 $usces_item['skuValues'][] = $sku;
6043 }
6044
6045 $usces_item = apply_filters('usces_filter_get_item', $usces_item, $post_id);
6046
6047 return $usces_item;
6048 }
6049
6050 function get_itemOptionKey( $post_id, $enc = false ) {
6051 $opts = usces_get_opts( $post_id );
6052 if(empty($opts)) return;
6053
6054 $res = array();
6055 foreach ( (array)$opts as $opt ) {
6056 if( $enc )
6057 $res[] = urlencode($opt['name']);
6058 else
6059 $res[] = $opt['name'];
6060 }
6061 return $res;
6062 }
6063
6064 function get_itemOptions( $key, $post_id ) {
6065 $opts = usces_get_opts( $post_id, 'name' );
6066 if(empty($opts[$key]))
6067 return;
6068 else
6069 return $opts[$key];
6070 }
6071
6072 function get_postIDbyCode( $itemcode ) {
6073 global $wpdb;
6074
6075 $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_itemCode', $itemcode);
6076 $res = $wpdb->get_var( $query );
6077 return $res;
6078 }
6079
6080 function get_pictids($item_code) {
6081 global $wpdb, $usces;
6082
6083 if( empty($item_code) )
6084 return false;
6085
6086 if( !$usces->options['system']['subimage_rule'] ){
6087 $codestr = $item_code.'%';
6088 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_title <> %s AND post_type = 'attachment' ORDER BY post_title", $codestr, $item_code);
6089 }else{
6090 $codestr = $item_code.'--%';
6091 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr);
6092 }
6093 $results = $wpdb->get_col( $query );
6094 return $results;
6095 }
6096
6097 function get_mainpictid($item_code) {
6098 global $wpdb;
6099 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $item_code);
6100 $id = $wpdb->get_var( $query );
6101 $id = apply_filters( 'usces_filter_get_mainpictid', $id, $item_code );
6102 return $id;
6103 }
6104
6105 function get_skus( $post_id, $keyflag = 'sort' ) {
6106 if( !$post_id )
6107 return array();
6108
6109 $skus = array();
6110 $metas = usces_get_post_meta($post_id, '_isku_');
6111 if( empty($metas) ) return $skus;
6112
6113 foreach( $metas as $rows ){
6114 $values = unserialize($rows['meta_value']);
6115 $key = isset($values[$keyflag]) ? $values[$keyflag] : $values['sort'];
6116 $skus[$key] = array(
6117 'meta_id' => $rows['meta_id'],
6118 'code' => $values['code'],
6119 'name' => $values['name'],
6120 'cprice' => $values['cprice'],
6121 'price' => $values['price'],
6122 'unit' => $values['unit'],
6123 'stocknum' => $values['stocknum'],
6124 'stock' => $values['stock'],
6125 'gp' => $values['gp'],
6126 'sort' => $values['sort'],
6127 'advance' => isset($values['advance']) ? $values['advance'] : ''
6128 );
6129 }
6130 $skus = apply_filters( 'usces_filter_get_skus', $skus, $post_id, $keyflag );
6131 ksort($skus);
6132
6133 return $skus;
6134 }
6135
6136 function is_item( $post ) {
6137
6138 if( $post->post_mime_type == 'item' )
6139 return true;
6140 else
6141 return false;
6142 }
6143
6144 function getItemIds( $end_type ) {
6145 global $wpdb;
6146 if( 'front' == $end_type )
6147 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item');
6148 if( 'back' == $end_type )
6149 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
6150 $ids = $wpdb->get_col( $query );
6151 if( empty($ids) ) $ids = array();
6152 return $ids;
6153 }
6154
6155 function getNotItemIds() {
6156 global $wpdb;
6157 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item');
6158 $ids = $wpdb->get_col( $query );
6159 if( empty($ids) ) $ids = array();
6160 return $ids;
6161 }
6162
6163 function getPaymentMethod( $name ) {
6164 $res = array();
6165 $payments = $this->options['payment_method'];
6166 foreach ( (array)$payments as $payment ) {
6167 if($name = $payment['name']) {
6168 $res = $payment;
6169 break;
6170 }
6171 }
6172 return $res;
6173 }
6174
6175 function order_processing( $results = array() ) {
6176 do_action('usces_pre_reg_orderdata');
6177 //db(function.php)
6178 //20110203ysk start
6179 $res = usces_check_acting_return_duplicate( $results );
6180 if($res != NULL) {
6181 usces_log('order processing duplicate : acting='.$_REQUEST['acting'].', order_id='.$res, 'acting_transaction.log');
6182 return 'ordercompletion';
6183 }
6184 if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) {
6185 usces_log($_REQUEST['acting'].' transaction : '.$_REQUEST['gid'], 'acting_transaction.log');//OK
6186 }
6187 //20110203ysk end
6188 //20110621ysk start 0000184
6189 if(isset($_REQUEST['acting']) && ('paypal_ec' == $_REQUEST['acting'])) {
6190 if( !usces_paypal_doecp( $results ) )
6191 return 'error';
6192 }
6193 //20110621ysk end
6194 $order_id = usces_reg_orderdata( $results );
6195 do_action('usces_post_reg_orderdata', $order_id, $results);
6196
6197 if ( $order_id ) {
6198 //mail(function.php)
6199 $mail_res = usces_send_ordermail( $order_id );
6200 return 'ordercompletion';
6201
6202 } else {
6203 return 'error';
6204 }
6205
6206 }
6207
6208 function acting_processing($acting_flg, $query) {
6209 global $wpdb;
6210 $entry = $this->cart->get_entry();
6211 $delim = apply_filters( 'usces_filter_delim', $this->delim );
6212 $acting_flg = trim($acting_flg);
6213 //$usces_entries = $this->cart->get_entry();
6214
6215 if( empty($acting_flg) ) return 'error';
6216
6217
6218 //include(USCES_PLUGIN_DIR . '/settlement/' . $acting_flg);
6219 if($acting_flg == 'paypal.php'){
6220 // if( !file_exists($this->options['settlement_path'] . $acting_flg) )
6221 // return 'error';
6222 //
6223 // require_once($this->options['settlement_path'] . "paypal.php");
6224 // paypal_submit();
6225
6226 }else if($acting_flg == 'epsilon.php'){
6227 if( !file_exists($this->options['settlement_path'] . $acting_flg) )
6228 return 'error';
6229
6230 if ( $this->use_ssl ) {
6231 $redirect = str_replace('http://', 'https://', USCES_CART_URL);
6232 }else{
6233 $redirect = USCES_CART_URL;
6234 }
6235 usces_log('epsilon card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6236 $query .= '&settlement=epsilon&redirect_url=' . urlencode($redirect);
6237 $query = $delim . ltrim($query, '&');
6238 header("location: " . $redirect . $query);
6239 exit;
6240
6241 }else if($acting_flg == 'acting_zeus_card' && 2 == $this->options['acting_settings']['zeus']['connection'] ){
6242 if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] ){
6243 if( !isset($_REQUEST['PaRes'])){
6244
6245 usces_log('zeus card 3dsecure entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6246 usces_zeus_3dsecure_enrol();
6247
6248 }else{
6249
6250 usces_log('zeus card 3dsecure : auth', 'acting_transaction.log');
6251 usces_zeus_3dsecure_auth();
6252 }
6253 }else{
6254 usces_log('zeus card no3d entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6255 $res = usces_zeus_secure_payreq();
6256 return $res;
6257 }
6258 }else if($acting_flg == 'acting_zeus_card' && 1 == $this->options['acting_settings']['zeus']['connection'] ){
6259
6260 $acting_opts = $this->options['acting_settings']['zeus'];
6261 $interface = parse_url($acting_opts['card_url']);
6262
6263 usces_log('zeus card securelink entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6264
6265 $vars = 'send=mall';
6266 $vars .= '&clientip=' . $acting_opts['clientip'];
6267 $vars .= '&cardnumber=' . $_POST['cardnumber'];
6268 if( 1 == $this->options['acting_settings']['zeus']['security'] ){
6269 $vars .= '&seccode=' . $_POST['securecode'];
6270 }
6271 $vars .= '&expyy=' . substr($_POST['expyy'], 2);
6272 $vars .= '&expmm=' . $_POST['expmm'];
6273 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
6274 $vars .= '&email=' . $_POST['email'];
6275 $vars .= '&sendid=' . $_POST['sendid'];
6276 $vars .= '&username=' . $_POST['username'];
6277 $vars .= '&money=' . $_POST['money'];
6278 $vars .= '&sendpoint=' . $_POST['sendpoint'];
6279 $vars .= '&printord=' . $_POST['printord'];
6280 $vars .= '&return_value=yes';
6281 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
6282 $vars .= '&div=' . $_POST['div'];
6283 }
6284
6285 //usces_log('zeus card *****vars : '.print_r($vars, true), 'acting_transaction.log');
6286
6287 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
6288 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
6289 //$header .= "Host: usctest.securesites.com\r\n";
6290 $header .= "User-Agent: PHP Script\r\n";
6291 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6292 $header .= "Content-Length: " . strlen($vars) . "\r\n";
6293 $header .= "Connection: close\r\n\r\n";
6294 $header .= $vars;
6295 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6296
6297 if ($fp){
6298 fwrite($fp, $header);
6299 while ( !feof($fp) ) {
6300 $scr = fgets($fp, 1024);
6301 $page .= $scr;
6302 }
6303 fclose($fp);
6304
6305 //usces_log('zeus card *****2 : '.print_r($page, true), 'acting_transaction.log');
6306 if( false !== strpos( $page, 'Success_order') ){
6307 usces_auth_order_acting_data($_POST['sendpoint']);
6308 usces_log('zeus card : Success_order ', 'acting_transaction.log');
6309 $ordd = usces_get_order_number( $page );
6310 //20120904ysk start 0000541
6311 if ( !isset($_POST['cbrand']) || (isset($_POST['howpay']) && 1 == $_POST['howpay']) ) {
6312 $args = '';
6313 } else {
6314 $div = 'div_'.$_POST['cbrand'];
6315 $args = '&cbrand='.$_POST['cbrand'].'&howpay='.$_POST['howpay'].'&'.$div.'='.$_POST[$div];
6316 }
6317 $args .= '&order_number='.$ordd.'&wctid='.$_POST['sendpoint'];
6318 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=1'.$args);
6319 //20120904ysk end
6320 exit;
6321 }else{
6322 $err_code = usces_get_err_code( $page );
6323 usces_log('zeus card : Certification Error : '.$err_code, 'acting_transaction.log');
6324 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0&err_code='.substr( $err_code, -3 ) );
6325 exit;
6326 }
6327 }else{
6328 usces_log('zeus card : Socket Error', 'acting_transaction.log');
6329 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
6330 }
6331 exit;
6332
6333 }else if($acting_flg == 'acting_zeus_conv'){
6334
6335 $acting_opts = $this->options['acting_settings']['zeus'];
6336 $interface = parse_url($acting_opts['conv_url']);
6337
6338 $vars .= 'clientip=' . $acting_opts['clientip_conv'];
6339 $vars .= '&act=' . $_POST['act'];
6340 $vars .= '&money=' . $_POST['money'];
6341 $vars .= '&username=' . mb_convert_encoding($_POST['username'], 'SJIS', 'UTF-8');
6342 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
6343 $vars .= '&email=' . $_POST['email'];
6344 $vars .= '&pay_cvs=' . $_POST['pay_cvs'];
6345 $vars .= '&sendid=' . $_POST['sendid'];
6346 $vars .= '&sendpoint=' . $_POST['sendpoint'];
6347 if( isset($acting_opts['conv_ope']) && 'test' == $acting_opts['conv_ope'] ) {
6348 $vars .= '&testid=' . $acting_opts['testid_conv'];
6349 $vars .= '&test_type=' . $acting_opts['test_type_conv'];
6350 }
6351
6352 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
6353 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
6354 $header .= "User-Agent: PHP Script\r\n";
6355 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6356 $header .= "Content-Length: " . strlen($vars) . "\r\n";
6357 $header .= "Connection: close\r\n\r\n";
6358 $header .= $vars;
6359 //usces_log('zeus conv header : '.print_r($header, true), 'acting_transaction.log');
6360 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6361
6362 if ($fp){
6363 fwrite($fp, $header);
6364 while ( !feof($fp) ) {
6365 $scr = fgets($fp, 1024);
6366 $page .= $scr;
6367 if( false !== strpos( $scr, 'order_no') )
6368 $qstr .= trim($scr) . '&';
6369 if( false !== strpos( $scr, 'pay_no1') )
6370 $qstr .= trim($scr) . '&';
6371 if( false !== strpos( $scr, 'pay_no2') )
6372 $qstr .= trim($scr) . '&';
6373 if( false !== strpos( $scr, 'pay_limit') )
6374 $qstr .= trim($scr) . '&';
6375 if( false !== strpos( $scr, 'pay_url') )
6376 $qstr .= trim($scr) . '&';
6377 if( false !== strpos( $scr, 'error_code') )
6378 $qstr .= trim($scr) . '&';
6379 if( false !== strpos( $scr, 'sendpoint') )
6380 $qstr .= trim($scr) . '&';
6381 }
6382 $qstr .= 'pay_cvs=' . $_POST['pay_cvs'].'&wctid='.$_POST['sendpoint'];
6383 fclose($fp);
6384 //usces_log('zeus page : '.$page, 'acting_transaction.log');
6385
6386 if( false !== strpos( $page, 'Success_order') ){
6387 usces_log('zeus conv entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6388 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=1&' . $qstr);
6389 exit;
6390 }else{
6391 usces_log('zeus data NG : '.$page, 'acting_transaction.log');
6392 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
6393 exit;
6394 }
6395 }else{
6396 usces_log('zeus : sockopen NG', 'acting_transaction.log');
6397 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
6398 }
6399 exit;
6400
6401 //20110208ysk start
6402 }else if($acting_flg == 'acting_paypal_ec') {
6403 $acting_opts = $this->options['acting_settings']['paypal'];
6404 $currency_code = $this->get_currency_code();
6405 $addroverride = '1';
6406 if( isset( $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) ) {
6407 if( 'US' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] or 'CA' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) $addroverride = '0';
6408 } else {
6409 $addroverride = '0';
6410 }
6411
6412 $nvpstr = $query;
6413 $nvpstr .= '&SESSION_ID='.$currency_code;
6414 $nvpstr .= '&CURRENCYCODE='.$currency_code;
6415 $nvpstr .= '&ADDROVERRIDE='.$addroverride;
6416 $nvpstr .= '&PAYMENTACTION=' . apply_filters('usces_filter_paypal_ec_paymentaction', 'Sale');
6417
6418 //The returnURL is the location where buyers return to when a payment has been succesfully authorized.
6419 $nvpstr .= '&RETURNURL='.urlencode(USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=1');
6420
6421 //The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow
6422 $nvpstr .= '&CANCELURL='.apply_filters( 'usces_filter_paypal_ec_cancelurl', urlencode(USCES_CART_URL.$delim.'confirm=1'), $query );
6423
6424 $nvpstr .= '&NOTIFYURL='.urlencode(USCES_PAYPAL_NOTIFY_URL);
6425
6426 $this->paypal->setMethod('SetExpressCheckout');
6427 $this->paypal->setData($nvpstr);
6428 $res = $this->paypal->doExpressCheckout();
6429 $resArray = $this->paypal->getResponse();
6430 $ack = strtoupper($resArray["ACK"]);
6431 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
6432 $token = urldecode($resArray["TOKEN"]);
6433 $payPalURL = $acting_opts['paypal_url'].'?cmd=_express-checkout&token='.$token.'&useraction=commit';
6434 header("Location: ".$payPalURL);
6435
6436 } else {
6437 //Display a user friendly Error on the page using any of the following error information returned by PayPal
6438 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
6439 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
6440 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
6441 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
6442 usces_log('PayPal : SetExpressCheckout API call failed. Error Code:['.$ErrorCode.'] Error Severity Code:['.$ErrorSeverityCode.'] Short Error Message:'.$ErrorShortMsg.' Detailed Error Message:'.$ErrorLongMsg, 'acting_transaction.log');
6443 header("Location: ".USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=0');
6444 }
6445 exit;
6446 //20110208ysk end
6447 //20121030ysk start
6448 } elseif( $acting_flg == 'acting_telecom_edy' ) {
6449 $table_meta_name = $wpdb->prefix."usces_order_meta";
6450 $value = array();
6451 $value['usces_cart'] = $_SESSION['usces_cart'];
6452 $value['usces_entry'] = $_SESSION['usces_entry'];
6453 $value['usces_member'] = $_SESSION['usces_member'];
6454 $mvalue = serialize( $value );
6455 $mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue );
6456 $res = $wpdb->query( $mquery );
6457
6458 unset( $_SESSION['usces_cart'] );
6459 unset( $_SESSION['usces_entry'] );
6460
6461 $acting_opts = $this->options['acting_settings']['telecom'];
6462 header( "location: ".$acting_opts['send_url_edy'].'?acting=telecom_edy'.$query );
6463 exit;
6464 //20121030ysk end
6465 //20121206ysk start
6466 } else if( $acting_flg == 'acting_digitalcheck_card' ) {
6467 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6468 $interface = parse_url($acting_opts['send_url_user_id']);
6469 $kakutei = ( empty($acting_opts['card_kakutei']) ) ? '0' : $acting_opts['card_kakutei'];
6470
6471 $vars = 'IP='.$acting_opts['card_ip'];
6472 $vars .= '&PASS='.$acting_opts['card_pass'];
6473 $vars .= '&IP_USER_ID='.$_POST['IP_USER_ID'];
6474 $vars .= '&SID='.$_POST['SID'];
6475 $vars .= '&STORE=51';
6476 $vars .= '&N1='.$_POST['N1'];
6477 $vars .= '&K1='.$_POST['K1'];
6478 $vars .= '&KAKUTEI='.$kakutei;
6479 $vars .= '&FUKA='.$acting_flg;
6480
6481 $header = "POST ".$interface['path']." HTTP/1.1\r\n";
6482 $header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
6483 $header .= "User-Agent: PHP Script\r\n";
6484 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6485 $header .= "Content-Length: ".strlen($vars)."\r\n";
6486 $header .= "Connection: close\r\n\r\n";
6487 $header .= $vars;
6488 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6489
6490 if( $fp ) {
6491 fwrite( $fp, $header );
6492 $page = '';
6493 while( !feof($fp) ) {
6494 $line = fgets( $fp, 1024 );
6495 if( strcmp($line, "\r\n") == 0 ) {
6496 $headerdone = true;
6497 } elseif( $headerdone ) {
6498 $page .= $line;
6499 }
6500 }
6501 fclose($fp);
6502 $lines = explode("\n", $page);
6503 if( false !== strpos( $lines[0], 'OK') ) {
6504 usces_log('digitalcheck card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6505 //$args = '&SID='.$lines[1];
6506 $args = '&SID='.$_POST['SID'].'&FUKA='.$acting_flg;
6507 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=1'.$args );
6508 } else {
6509 usces_log('digitalcheck card : Certification Error : '.$page, 'acting_transaction.log');
6510 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6511 }
6512 } else {
6513 usces_log('digitalcheck card : Socket Error', 'acting_transaction.log');
6514 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6515 }
6516 exit;
6517 } else if( $acting_flg == 'acting_digitalcheck_conv' ) {
6518 if( isset($_REQUEST['STORE']) and '99' != $_REQUEST['STORE'] ) {
6519 $res = $this->order_processing();
6520 if( 'ordercompletion' == $res ) {
6521 $table_meta_name = $wpdb->prefix."usces_order_meta";
6522 $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] );
6523 $order_id = $wpdb->get_var($mquery);
6524 if( $order_id ) {
6525 $data = array( "settltment_status" => __("Failure",'usces'), "settltment_errmsg" => __("Settlement was not completed.",'usces') );
6526 $this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
6527 }
6528 $this->cart->crear_cart();
6529 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6530 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6531 exit;
6532 } else {
6533 usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
6534 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=0' );
6535 }
6536 } else {
6537 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6538 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6539 exit;
6540 }
6541 //20121206ysk end
6542 //20140206ysk start
6543 } else if( $acting_flg == 'acting_veritrans_card' or $acting_flg == 'acting_veritrans_conv' ) {
6544 $acting_opts = $this->options['acting_settings']['veritrans'];
6545 $acting = substr( $acting_flg, 7 );
6546 $dummy_payment_flag = ( 'public' == $acting_opts['ope'] ) ? '0' : '1';
6547 $order_id = isset( $_POST['ORDER_ID'] ) ? $_POST['ORDER_ID'] : '';
6548 $url = parse_url( $acting_opts['regist_url'] );
6549 $path = empty($url['path']) ? '/' : $url['path'];
6550
6551 $postdata = $query;
6552 if( 'acting_veritrans_card' == $acting_flg ) {
6553 $card_capture_flag = ( 'capture' == $acting_opts['card_capture_flag'] ) ? '1' : '0';
6554 $postdata .= '&CARD_CAPTURE_FLAG='.$card_capture_flag;
6555 }
6556 if( 'acting_veritrans_conv' == $acting_flg ) {
6557 $postdata .= '&NAME1='.urlencode( mb_substr( mb_convert_kana( $entry['customer']['name1'], 'ASKV', 'UTF-8' ), 0, 10 ) );
6558 $postdata .= '&NAME2='.urlencode( mb_substr( mb_convert_kana( $entry['customer']['name2'], 'ASKV', 'UTF-8' ), 0, 10 ) );
6559 if( !empty($entry['customer']['name3']) ) {
6560 $kana1 = mb_substr( mb_convert_kana( $entry['customer']['name3'], 'ASKV', 'UTF-8' ), 0, 10 );
6561 mb_regex_encoding( 'UTF-8' );
6562 if( mb_ereg("^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana1) )
6563 $postdata .= '&KANA1='.urlencode( $kana1 );
6564 }
6565 if( !empty($entry['customer']['name4']) ) {
6566 $kana2 = mb_substr( mb_convert_kana( $entry['customer']['name4'], 'ASKV', 'UTF-8' ), 0, 10 );
6567 mb_regex_encoding( 'UTF-8' );
6568 if( mb_ereg("^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana2) )
6569 $postdata .= '&KANA2='.urlencode( $kana2 );
6570 }
6571 $postdata .= '&TELEPHONE_NO='.str_replace( '-', '', $entry['customer']['tel'] );
6572 }
6573 $postdata .= '&MERCHANT_ID='.$acting_opts['merchant_id'];
6574 $postdata .= '&SESSION_ID='.session_id();
6575 $postdata .= '&FINISH_PAYMENT_RETURN_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting.'&acting_return=1&result=1' );
6576 $postdata .= '&UNFINISH_PAYMENT_RETURN_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting.'&confirm=1' );
6577 $postdata .= '&ERROR_PAYMENT_RETURN_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting.'&acting_return=0' );
6578 $postdata .= '&FINISH_PAYMENT_ACCESS_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting );
6579 $postdata .= '&DUMMY_PAYMENT_FLAG='.$dummy_payment_flag;
6580
6581 $postlength = strlen( $postdata );
6582
6583 $request = "POST ".$path." HTTP/1.1"."\r\n";
6584 $request .= "Host: ".$url['host']."\r\n";
6585 $request .= "User-Agent: HttpRequest Powered by ".phpversion()."\r\n";
6586 $request .= "Connection: close"."\r\n";
6587 $request .= "Accept-Language: ja"."\r\n";
6588 $request .= "Content-Type: application/x-www-form-urlencoded"."\r\n";
6589 $request .= "Content-Length: ".$postlength."\r\n\r\n";
6590 $request .= $postdata;
6591
6592 $code = 0;
6593 $resBody = "";
6594 $con = @fsockopen( 'ssl://'.$url['host'], 443 );
6595
6596 if( $con ) {
6597 $ret = fwrite( $con, $request );
6598 if( $ret == strlen($request) ) {
6599 $res = $this->readResponse( $con );
6600 //usces_log( print_r($res,true), "veritrans.log" );
6601 $code = $res['Code'];
6602 $resBody = $res['Body'];
6603
6604 } else {
6605 usces_log( 'Veritrans Write NG: Sent:'.strlen($request).' Send:'.$ret, "acting_transaction.log" );
6606 }
6607 fclose( $con );
6608
6609 } else {
6610 usces_log( "Veritrans Connect NG: ".$url['host'], "acting_transaction.log" );
6611 header( "location: ".USCES_CART_URL.$delim.'acting='.$acting_flg.'&acting_return=0' );
6612 exit;
6613 }
6614
6615 // 正常終了(200 OK)が返ったか
6616 if( intval($code) == 200 ) {
6617 $merchantKey = null;
6618 $browserKey = null;
6619 $scd = null;
6620 $error_message = null;
6621
6622 // レスポンスデータからマーチャントキー、ブラウザキーを取得
6623 $bodyLine = explode( "\n", $resBody );
6624 foreach( $bodyLine as $line ) {
6625 if( preg_match( '/^MERCHANT_ENCRYPTION_KEY=(.+)/', $line, $match ) ) {
6626 $merchantKey = $match[1];
6627 } elseif( preg_match( '/^BROWSER_ENCRYPTION_KEY=(.+)/', $line, $match ) ) {
6628 $browserKey = $match[1];
6629 } elseif( preg_match('/^SCD=(.+)/', $line, $match ) ) {
6630 $scd = $match[1];
6631 } elseif( preg_match( '/^ERROR_MESSAGE=(.+)/', $line, $match ) ) {
6632 $error_message = $match[1];
6633 }
6634 }
6635
6636 // 両方取れたらOK。SCDはカードでセキュリティコードが�
6637 �力された場合のみ
6638 if( !is_null($merchantKey) && !is_null($browserKey) ) {
6639 $getdata = '?MERCHANT_ID='.$acting_opts['merchant_id'];
6640 $getdata .= '&ORDER_ID='.$order_id;
6641 $getdata .= '&BROWSER_ENCRYPTION_KEY='.urlencode($browserKey);
6642 header( "location: ".$acting_opts['payment_url'].$getdata );
6643
6644 } else {
6645 if( !is_null($error_message) )
6646 usces_log( "Veritrans AWeb:".$error_message, "acting_transaction.log" );
6647 header( "location: ".USCES_CART_URL.$delim.'acting='.$acting_flg.'&acting_return=0' );
6648 }
6649
6650 } else {
6651 usces_log( "Veritrans Response NG: ".$resBody, "acting_transaction.log" );
6652 header( "location: ".USCES_CART_URL.$delim.'acting='.$acting_flg.'&acting_return=0' );
6653 }
6654 exit;
6655 //20140206ysk end
6656 }
6657 do_action('usces_action_acting_processing', $acting_flg, $query);
6658 }
6659
6660 private function readResponse( $fp ) {
6661 $res = array( 'Status'=>'', 'Version'=>'', 'Code'=>0, 'Message'=>'', 'Headers'=>array(), 'Body'=>'' );
6662
6663 // HTTPステータスの読み込み
6664 $line = $this->readLine( $fp );
6665 if( preg_match( '/^(HTTP\/1\.[0-9x]+)\s+([0-9]+)\s+(.+)/i', $line, $match ) == 0 ) {
6666 return $res;
6667 }
6668 $res['Status'] = $line;
6669 $res['Version'] = $match[1];
6670 $res['Code'] = $match[2];
6671 $res['Message'] = $match[3];
6672
6673 // レスポンスヘッダの読み込み
6674 while( !feof($fp) ) {
6675 $line = $this->readLine( $fp );
6676 if( $line != '' ) {
6677 list( $hname, $hvalue ) = explode( ':', $line, 2 );
6678 $res['Headers'][strtolower($hname)] = ltrim($hvalue);
6679 } else {
6680 break;
6681 }
6682 }
6683 // レスポンスデータの読み込み
6684 while( !feof($fp) ) {
6685 $data = $this->readLine( $fp )."\n";
6686 if( '' == $data ) {
6687 break;
6688 }
6689 $res['Body'] .= $data;
6690 }
6691 return $res;
6692 }
6693
6694 private function readLine( $fp ) {
6695 if( !$fp ) {
6696 return '';
6697 }
6698 // レスポンスデータを受信
6699 $line = null;
6700 while( !feof($fp) ) {
6701 $line .= @fgets( $fp, 4096 );
6702 if( substr($line, -1) == "\n" ) {
6703 return rtrim( $line, "\r\n" );
6704 }
6705 }
6706 return $line;
6707 }
6708
6709 function inquiry_processing() {
6710
6711 $mail_res = usces_send_inquirymail();
6712
6713 if ( $mail_res )
6714 return 'inquiry_comp';
6715 else
6716 return 'inquiry_error';
6717 }
6718
6719 function lastprocessing() {
6720
6721 if ( $this->page == 'ordercompletion' )
6722 $this->cart->crear_cart();
6723
6724 do_action( 'usces_action_lastprocessing' );
6725
6726 unset($_SESSION['usces_singleitem']);
6727
6728 }
6729
6730 function is_item_zaiko( $post_id, $sku ){
6731 $status_num = (int)$this->getItemZaikoStatusId($post_id, $sku);
6732 $zaiko_num = $this->getItemZaikoNum($post_id, $sku);
6733
6734 if( false !== $zaiko_num
6735 && ( 0 < (int)$zaiko_num || WCUtils::is_blank($zaiko_num) )
6736 && false !== $status_num
6737 && 2 > $status_num
6738 ){
6739 return true;
6740 }else{
6741 return false;
6742 }
6743 }
6744
6745 // function for the cart ***********************************************************
6746 function get_total_price( $cart = array() ) {
6747 if( empty($cart) )
6748 $cart = $this->cart->get_cart();
6749
6750 $total_price = 0;
6751
6752 if( !empty($cart) ) {
6753 for($i=0; $i<count($cart); $i++) {
6754 $quantity = $cart[$i]['quantity'];
6755 $skuPrice = $cart[$i]['price'];
6756
6757 $total_price += ($skuPrice * $quantity);
6758 }
6759 }
6760 return apply_filters( 'usces_filter_get_total_price', $total_price, $cart);
6761 }
6762
6763 function get_total_quantity( $cart = array() ) {
6764 if( empty($cart) )
6765 $cart = $this->cart->get_cart();
6766
6767 $total_quantity = 0;
6768
6769 if( !empty($cart) ) {
6770 for($i=0; $i<count($cart); $i++) {
6771 $total_quantity += $cart[$i]['quantity'];
6772 }
6773 }
6774 return $total_quantity;
6775 }
6776
6777 function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) {
6778 if( $mem_id == '' || $this->options['membersystem_state'] == 'deactivate' || $this->options['membersystem_point'] == 'deactivate') return 0;
6779
6780 if ( empty($cart) )
6781 $cart = $this->cart->get_cart();
6782
6783 if ( empty($display_mode) )
6784 $display_mode = $this->options['display_mode'];
6785
6786 $point = 0;
6787 $total = $this->get_total_price( $cart );
6788 if ( $display_mode == 'Promotionsale' ) {
6789 if ( $this->options['campaign_privilege'] == 'discount' ) {
6790 foreach ( $cart as $rows ) {
6791 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6792 if ( !in_array($this->options['campaign_category'], $cats) ){
6793 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6794 $price = $rows['price'] * $rows['quantity'];
6795 $point += $price * $rate / 100;
6796 }
6797 }
6798 } elseif ( $this->options['campaign_privilege'] == 'point' ) {
6799 foreach ( $cart as $rows ) {
6800 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6801 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6802 $price = $rows['price'] * $rows['quantity'];
6803 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6804 if ( in_array($this->options['campaign_category'], $cats) )
6805 $point += $price * $rate / 100 * $this->options['privilege_point'];
6806 else
6807 $point += $price * $rate / 100;
6808 }
6809 }
6810 } else {
6811 foreach ( $cart as $rows ) {
6812 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6813 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6814 $price = $rows['price'] * $rows['quantity'];
6815 $point += $price * $rate / 100;
6816 }
6817 }
6818
6819 //20130425ysk start 0000699
6820 if( 0 < $point ) $point = ceil( $point );
6821
6822 $entry = $this->cart->get_entry();
6823 $use_point = isset( $entry['order']['usedpoint'] ) ? (int)$entry['order']['usedpoint'] : 0;
6824 if( 0 < $use_point ) {
6825 $point = ceil( $point - ( $point * $use_point / $total ) );
6826 if( 0 > $point )
6827 $point = 0;
6828 }
6829
6830 return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart );
6831 //20130425ysk end
6832 }
6833
6834 function get_order_discount( $display_mode = '', $cart = array() ) {
6835 if ( empty($cart) )
6836 $cart = $this->cart->get_cart();
6837
6838 if ( empty($display_mode) )
6839 $display_mode = $this->options['display_mode'];
6840
6841 $discount = 0;
6842 $total = $this->get_total_price( $cart );
6843 if ( $display_mode == 'Promotionsale' ) {
6844 if ( $this->options['campaign_privilege'] == 'discount' ){
6845 if( 0 === (int)$this->options['campaign_category'] ){
6846 $discount = $total * $this->options['privilege_discount'] / 100;
6847 }else{
6848 foreach($cart as $cart_row){
6849 if( in_category((int)$this->options['campaign_category'], $cart_row['post_id']) ){
6850 $discount += $cart_row['price'] * $cart_row['quantity'] * $this->options['privilege_discount'] / 100;
6851 }
6852 }
6853 }
6854 }else if ( $this->options['campaign_privilege'] == 'point' ){
6855 $discount = 0;
6856 }
6857 }
6858
6859 $discount = ceil($discount * -1);
6860 $discount = apply_filters('usces_order_discount', $discount, $cart);
6861 return $discount;
6862 }
6863
6864 function getShippingCharge( $pref, $cart = array(), $entry = array() ) {
6865 if( empty($cart) )
6866 $cart = $this->cart->get_cart();
6867 if( empty($entry) )
6868 $entry = $this->cart->get_entry();
6869 if( function_exists('dlseller_have_shipped') && !dlseller_have_shipped() ){
6870 $charge = 0;
6871 $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
6872 return $charge;
6873 }
6874
6875 //�
6876 �送方法ID
6877 $d_method_id = $entry['order']['delivery_method'];
6878 //�
6879 �送方法index
6880 $d_method_index = $this->get_delivery_method_index($d_method_id);
6881 //送料ID
6882 $fixed_charge_id = ( isset($this->options['delivery_method'][$d_method_index]['charge']) ) ? $this->options['delivery_method'][$d_method_index]['charge'] : -1;
6883 $individual_quant = 0;
6884 $total_quant = 0;
6885 $charges = array();
6886 $individual_charges = array();
6887 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
6888
6889 foreach ( $cart as $rows ) {
6890
6891 if( -1 == $fixed_charge_id ){
6892 //商品送料ID
6893 $s_charge_id = $this->getItemShippingCharge($rows['post_id']);
6894 //商品送料index
6895 $s_charge_index = $this->get_shipping_charge_index($s_charge_id);
6896 //20120710ysk start 0000472
6897 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6898 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6899 //20120710ysk end
6900 }else{
6901
6902 $s_charge_index = $this->get_shipping_charge_index($fixed_charge_id);
6903 //20120710ysk start 0000472
6904 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6905 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6906 //20120710ysk end
6907 }
6908
6909 if($this->getItemIndividualSCharge($rows['post_id'])){
6910 $individual_quant += $rows['quantity'];
6911 $individual_charges[] = $rows['quantity'] * $charge;
6912 }else{
6913 $charges[] = $charge;
6914 }
6915 $total_quant += $rows['quantity'];
6916 }
6917
6918 if( count($charges) > 0 ){
6919 rsort($charges);
6920 $max_charge = $charges[0];
6921 $charge = $max_charge + array_sum($individual_charges);
6922 }else{
6923 $charge = array_sum($individual_charges);
6924 }
6925
6926 $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
6927
6928 return $charge;
6929 }
6930
6931 function getCODFee($payment_name, $amount_by_cod) {
6932 global $usces_entries;
6933
6934 $payments = $this->getPayments($payment_name);
6935 if( 'COD' != $payments['settlement'] ){
6936 $fee = 0;
6937
6938 }else if( 'change' != $this->options['cod_type'] ){
6939 //$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : '';
6940 $fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : 0;
6941
6942 }else{
6943 $materials = array(
6944 'total_items_price' => $usces_entries['order']['total_items_price'],
6945 'discount' => $usces_entries['order']['discount'],
6946 'shipping_charge' => $usces_entries['order']['shipping_charge'],
6947 'cod_fee' => $usces_entries['order']['cod_fee'],
6948 );
6949 $price = $amount_by_cod + $this->getTax( $amount_by_cod, $materials );
6950 if( $price <= $this->options['cod_first_amount'] ){
6951 $fee = $this->options['cod_first_fee'];
6952
6953 }else if( isset($this->options['cod_amounts']) ){
6954 $last = count( $this->options['cod_amounts'] ) - 1;
6955 if( $price > $this->options['cod_amounts'][$last] ){
6956 $fee = $this->options['cod_end_fee'];
6957
6958 }else{
6959 $fee = 0;
6960 foreach( $this->options['cod_amounts'] as $key => $value ){
6961 if( $price <= $value ){
6962 $fee = $this->options['cod_fees'][$key];
6963 break;
6964 }
6965 }
6966 }
6967 }else{
6968 $fee = $this->options['cod_end_fee'];
6969 }
6970 }
6971 $fee = apply_filters('usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod);
6972 return $fee;
6973 }
6974
6975 function getTax( $total, $materials ) {
6976 global $usces_settings;
6977
6978 if( 'include' == $this->options['tax_mode'] )
6979 return 0;
6980
6981 if( empty($this->options['tax_rate']) )
6982 return 0;
6983
6984 extract($materials);//need( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point' )
6985
6986 if( 'products' == $this->options['tax_target'] ){
6987 $total = $total_items_price + $discount;
6988 }else{
6989 $total = $total_items_price + $discount + $shipping_charge + $cod_fee;
6990 }
6991 $total = apply_filters( 'usces_filter_getTax_total', $total, $materials);
6992
6993 $tax = $total * $this->options['tax_rate'] / 100;
6994 $cr = $this->options['system']['currency'];
6995 $decimal = $usces_settings['currency'][$cr][1];
6996 $decipad = (int)str_pad( '1', $decimal+1, '0', STR_PAD_RIGHT );
6997 switch( $this->options['tax_method'] ){
6998 case 'cutting':
6999 $tax = floor($tax*$decipad)/$decipad;
7000 break;
7001 case 'bring':
7002 $tax = ceil($tax*$decipad)/$decipad;
7003 break;
7004 case 'rounding':
7005 if( 0 < $decimal ){
7006 $tax = round($tax, (int)$decimal);
7007 }else{
7008 $tax = round($tax);
7009 }
7010 break;
7011 }
7012 return $tax;
7013 }
7014
7015 function set_cart_fees( $member, $entries ) {
7016 $carts = $this->cart->get_cart();
7017 $total_items_price = $this->get_total_price();
7018 if ( empty($this->options['postage_privilege']) || $total_items_price < $this->options['postage_privilege'] ) {
7019 $shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'] );
7020 } else {
7021 $shipping_charge = 0;
7022 }
7023 $shipping_charge = apply_filters('usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries);
7024 $payments = $this->getPayments( $entries['order']['payment_name'] );
7025 $discount = $this->get_order_discount();
7026 $use_point = $entries['order']['usedpoint'];
7027 $amount_by_cod = $total_items_price - $use_point + $discount + $shipping_charge;
7028 $amount_by_cod = apply_filters('usces_filter_set_cart_fees_amount_by_cod', $amount_by_cod, $entries, $total_items_price, $use_point, $discount, $shipping_charge);
7029 $cod_fee = $this->getCODFee($entries['order']['payment_name'], $amount_by_cod);
7030 $cod_fee = apply_filters('usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge);
7031 $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
7032 $total_price = apply_filters('usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee);
7033 $materials = compact( 'member', 'entries', 'carts', 'total_items_price', 'shipping_charge', 'payments', 'discount', 'cod_fee', 'use_point', 'discount' );
7034 $tax = $this->getTax( $total_price, $materials );
7035 $total_full_price = $total_price + ( 'exclude' == $this->options['tax_mode'] ? $tax : 0 );
7036 $total_full_price = apply_filters('usces_filter_set_cart_fees_total_full_price', $total_full_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee);
7037 $get_point = $this->get_order_point( $member['ID'] );
7038 //20130425ysk start 0000699
7039 //if(0 < (int)$use_point){
7040 // $get_point = ceil( $get_point - ($get_point * $use_point / $total_items_price) );
7041 // if(0 > $get_point)
7042 // $get_point = 0;
7043 //}
7044 //20130425ysk end
7045
7046 $array = array(
7047 'total_items_price' => $total_items_price,
7048 'total_price' => $total_price,
7049 'total_full_price' => $total_full_price,
7050 'getpoint' => $get_point,
7051 'usedpoint' => $use_point,
7052 'discount' => $discount,
7053 'shipping_charge' => $shipping_charge,
7054 'cod_fee' => $cod_fee,
7055 'tax' => $tax
7056 );
7057 $this->cart->set_order_entry( $array );
7058 //$entries = $this->cart->get_entry();
7059 //var_dump($entries);
7060 }
7061
7062 function getPayments( $payment_name ) {
7063 if( '#none#' == $payment_name )
7064 return NULL;
7065
7066 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
7067 if( isset($payments[$payment_name]) )
7068 return $payments[$payment_name];
7069 return NULL;
7070 }
7071
7072 function is_maintenance() {
7073 if ( $this->options['display_mode'] == 'Maintenancemode' )
7074 return true;
7075 else
7076 return false;
7077 }
7078
7079 // function maintenance_mode() {
7080 // if ( $this->is_maintenance() && !is_user_logged_in() && (!strstr($_SERVER['REQUEST_URI'], 'wp-admin') || !strstr($_SERVER['REQUEST_URI'], 'wp-login') ) ) {
7081 // include ( TEMPLATEPATH . '/maintenance.php ');
7082 // exit;
7083 // } elseif ( isset($_GET['uscesmode']) && $_GET['uscesmode'] == 'lostpassword' ) {
7084 // $error = isset($_GET['error']) ? '?error='.$_GET['error'] : '';
7085 // include ( TEMPLATEPATH . '/member/changepassword.php ');
7086 // exit;
7087 // }
7088 // }
7089
7090 function get_member_history($mem_id) {
7091 global $wpdb;
7092 $order_table = $wpdb->prefix . "usces_order";
7093
7094 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
7095 $query = apply_filters( 'usces_filter_member_history_query', $query, $mem_id );
7096 // $query = $wpdb->prepare("SELECT ID, order_cart, order_condition, order_date, order_usedpoint, order_getpoint,
7097 // order_discount, order_shipping_charge, order_cod_fee, order_tax, order_status
7098 // FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
7099 $results = $wpdb->get_results( $query );
7100
7101 $i=0;
7102 $res = array();
7103
7104 if( is_user_logged_in() && is_admin() ){
7105
7106 foreach ( $results as $value ) {
7107
7108 $res[] = array(
7109 'ID' => $value->ID,
7110 // 'cart' => unserialize($value->order_cart),
7111 'cart' => usces_get_ordercartdata( $value->ID ),
7112 'condition' => unserialize($value->order_condition),
7113 'getpoint' => $value->order_getpoint,
7114 'usedpoint' => $value->order_usedpoint,
7115 'discount' => $value->order_discount,
7116 'shipping_charge' => $value->order_shipping_charge,
7117 'payment_name' => $value->order_payment_name,
7118 'cod_fee' => $value->order_cod_fee,
7119 'tax' => $value->order_tax,
7120 'order_status' => $value->order_status,
7121 'date' => mysql2date(__('Y/m/d'), $value->order_date),
7122 'order_date' => $value->order_date
7123 );
7124 $i++;
7125 }
7126
7127 }elseif( !is_admin() ){
7128
7129 foreach ( $results as $value ) {
7130
7131 if( strpos($value->order_status, 'cancel') === false && strpos($value->order_status, 'estimate') === false ){
7132 $res[] = array(
7133 'ID' => $value->ID,
7134 // 'cart' => unserialize($value->order_cart),
7135 'cart' => usces_get_ordercartdata( $value->ID ),
7136 'condition' => unserialize($value->order_condition),
7137 'getpoint' => $value->order_getpoint,
7138 'usedpoint' => $value->order_usedpoint,
7139 'discount' => $value->order_discount,
7140 'shipping_charge' => $value->order_shipping_charge,
7141 'payment_name' => $value->order_payment_name,
7142 'cod_fee' => $value->order_cod_fee,
7143 'tax' => $value->order_tax,
7144 'order_status' => $value->order_status,
7145 'date' => mysql2date(__('Y/m/d'), $value->order_date),
7146 'order_date' => $value->order_date
7147 );
7148 $i++;
7149 }
7150
7151 }
7152 }
7153
7154 return $res;
7155
7156 }
7157
7158 function get_post_term_ids( $post_id, $taxonomy ){
7159 global $wpdb;
7160 $query = $wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_relationships AS tr
7161 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
7162 WHERE tt.taxonomy = %s AND tr.object_id = %d", $taxonomy, $post_id);
7163 $ids = $wpdb->get_col( $query );
7164
7165 return $ids;
7166
7167 }
7168
7169 function get_tag_names($post_id) {
7170 global $wpdb;
7171 $tag = 'post_tag';
7172 $query = $wpdb->prepare("SELECT t.name FROM $wpdb->term_relationships AS tr
7173 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
7174 INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id
7175 WHERE tt.taxonomy = %s AND tr.object_id = %d", $tag, $post_id);
7176 $names = $wpdb->get_col( $query );
7177
7178 return apply_filters('usces_filter_get_tag_names', $names, $post_id);
7179
7180 }
7181
7182 function get_ID_byItemName($itemname, $status = 'publish') {
7183 global $wpdb;
7184 $meta_key = '_itemCode';
7185 $query = $wpdb->prepare("SELECT p.ID FROM $wpdb->posts AS p
7186 INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id
7187 WHERE p.post_status = %s AND pm.meta_key = %s AND meta_value = %s ", $status, $meta_key, $itemname);
7188 $id = $wpdb->get_var( $query );
7189
7190 // $wpdb->show_errors();
7191 // $wpdb->print_error();
7192
7193 return $id;
7194
7195 }
7196
7197 function uscescv( $sessid, $flag ) {
7198
7199 $chars = '';
7200 $i=0;
7201 $h=0;
7202 $usces_cookie = $this->get_cookie();
7203 if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
7204 $cid = $usces_cookie['id'];
7205 }elseif( isset($_SESSION['usces_cookieid']) && !empty($_SESSION['usces_cookieid']) ){
7206 $cid = $_SESSION['usces_cookieid'];
7207 }else{
7208 $cid = 0;
7209 }
7210 while($h<strlen($sessid)){
7211 if(0 == $i % 3){
7212 $chars .= substr($i, -1);
7213 }else{
7214 $chars .= substr($sessid, $h, 1);
7215 $h++;
7216 }
7217 $i++;
7218 }
7219 if( $flag ){
7220 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
7221 $postfix = apply_filters('usces_sessid_force', $postfix);
7222 $sessid = $chars . '_' . $postfix . '_' . $cid . '_A';
7223 }else{
7224 $sessid = $chars . '_' . apply_filters('usces_sessid_flag', 'acting') . '_' . $cid . '_A';
7225 }
7226 $sessid = urlencode(base64_encode($sessid));
7227 //usces_log('sessid2 : '.$sessid, 'acting_transaction.log');
7228
7229 return $sessid;
7230 }
7231
7232 function uscesdc( $sessid ) {
7233 // $usces_cookie = $this->get_cookie();
7234 // if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
7235 // if( isset($usces_cookie['sslid']) && !empty($usces_cookie['sslid']) ){
7236 // $cid = $usces_cookie['sslid'];
7237 // }else{
7238 // $cid = 0;
7239 // }
7240 // }else{
7241 // if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
7242 // $cid = $usces_cookie['id'];
7243 // }else{
7244 // $cid = 0;
7245 // }
7246 // }
7247 $sessid = base64_decode(urldecode($sessid));
7248 list($sess, $addr, $cookieid, $none) = explode('_', $sessid, 4);
7249 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
7250 $postfix = apply_filters('usces_sessid_force', $postfix);
7251 //usces_log('cid : '.$cid, 'acting_transaction.log');
7252 //usces_log('cookieid : '.$cookieid, 'acting_transaction.log');
7253 //usces_log('postfix : '.$postfix, 'acting_transaction.log');
7254 //usces_log('addr : '.$addr, 'acting_transaction.log');
7255 if( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) {
7256 $sessid = '';
7257 return NULL;
7258 }
7259 $chars = '';
7260 $h=0;
7261 while($h<strlen($sess)){
7262 if(0 != $h % 3){
7263 $chars .= substr($sess, $h, 1);
7264 }
7265 $h++;
7266 }
7267 $sessid = $chars;
7268
7269 return $sessid;
7270
7271 }
7272
7273 function get_visiter( $period ) {
7274 global $wpdb;
7275 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7276 $yearstr = substr($datestr, 0, 4);
7277 $monthstr = substr($datestr, 5, 2);
7278 $daystr = substr($datestr, 8, 2);
7279 if($period == 'today') {
7280 $date = $datestr;
7281 $today = $datestr;
7282 }else if($period == 'thismonth') {
7283 $date = date('Y-m-01');
7284 $today = $datestr;
7285 }else if($period == 'lastyear') {
7286 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7287 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
7288 }
7289 $table_name = $wpdb->prefix . 'usces_access';
7290
7291 $query = $wpdb->prepare("SELECT SUM(acc_num1) AS ct1, SUM(acc_num2) AS ct2 FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today);
7292 $res = $wpdb->get_row($query, ARRAY_A);
7293
7294 if( $res == NULL )
7295 return 0;
7296 else
7297 return $res['ct1']+$res['ct2'];
7298 }
7299
7300 function get_fvisiter( $period ) {
7301 global $wpdb;
7302 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7303 $yearstr = substr($datestr, 0, 4);
7304 $monthstr = substr($datestr, 5, 2);
7305 $daystr = substr($datestr, 8, 2);
7306 if($period == 'today') {
7307 $date = $datestr;
7308 $today = $datestr;
7309 }else if($period == 'thismonth') {
7310 $date = date('Y-m-01');
7311 $today = $datestr;
7312 }else if($period == 'lastyear') {
7313 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7314 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
7315 }
7316 $table_name = $wpdb->prefix . 'usces_access';
7317
7318 $query = $wpdb->prepare("SELECT SUM(acc_num2) AS ct FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today);
7319 $res = $wpdb->get_var($query);
7320
7321 if( $res == NULL )
7322 return 0;
7323 else
7324 return $res;
7325 }
7326
7327 function get_order_num( $period ) {
7328 global $wpdb;
7329 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7330 $yearstr = substr($datestr, 0, 4);
7331 $monthstr = substr($datestr, 5, 2);
7332 $daystr = substr($datestr, 8, 2);
7333 if($period == 'today') {
7334 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
7335 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7336 }else if($period == 'thismonth') {
7337 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
7338 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7339 }else if($period == 'lastyear') {
7340 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7341 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
7342 }
7343 $table_name = $wpdb->prefix . 'usces_order';
7344
7345 $query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM $table_name WHERE order_date >= %s AND order_date <= %s AND 0 = LOCATE(%s, order_status) AND 0 = LOCATE(%s, order_status)", $date, $today, 'cancel', 'estimate');
7346 $res = $wpdb->get_var($query);
7347
7348 if( $res == NULL )
7349 return 0;
7350 else
7351 return $res;
7352 }
7353
7354 function get_order_amount( $period ) {
7355 global $wpdb;
7356 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7357 $yearstr = substr($datestr, 0, 4);
7358 $monthstr = substr($datestr, 5, 2);
7359 $daystr = substr($datestr, 8, 2);
7360 if($period == 'today') {
7361 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
7362 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7363 }else if($period == 'thismonth') {
7364 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
7365 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7366 }else if($period == 'lastyear') {
7367 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7368 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
7369 }
7370 $table_name = $wpdb->prefix . 'usces_order';
7371
7372 $query = $wpdb->prepare("SELECT
7373 SUM(order_item_total_price) AS price,
7374 SUM(order_usedpoint) AS point,
7375 SUM(order_discount) AS discount,
7376 SUM(order_shipping_charge) AS shipping,
7377 SUM(order_cod_fee) AS cod,
7378 SUM(order_tax) AS tax
7379 FROM $table_name WHERE order_date >= %s AND order_date <= %s AND 0 = LOCATE(%s, order_status) AND 0 = LOCATE(%s, order_status)", $date, $today, 'cancel', 'estimate');
7380 $res = $wpdb->get_row($query, ARRAY_A);
7381
7382 if( $res == NULL )
7383 return 0;
7384 else
7385 return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax'];
7386 }
7387
7388 function is_status($need, $str){
7389 $array = explode(',', $str);
7390 return in_array($need, $array);
7391 }
7392
7393 function make_status( $taio='', $receipt='', $admin='' ){
7394 $str = '';
7395 if($taio != '' && $taio != '#none#')
7396 $str .= $taio . ',';
7397 if($receipt != '' && $receipt != '#none#')
7398 $str .= $receipt . ',';
7399 if($admin != '' && $admin != '#none#')
7400 $str .= $admin . ',';
7401 return $str;
7402 }
7403
7404 function get_memberid_by_email($email){
7405 global $wpdb;
7406 $table_name = $wpdb->prefix . "usces_member";
7407 $query = $wpdb->prepare("SELECT ID FROM $table_name WHERE mem_email = %s", $email);
7408 $res = $wpdb->get_var($query);
7409 return $res;
7410 }
7411
7412 function get_condition(){
7413 //20120807ysk start 0000544
7414 $order_conditions = array(
7415 'display_mode' => $this->options['display_mode'],
7416 'campaign_privilege' => $this->options['campaign_privilege'],
7417 'campaign_category' => $this->options['campaign_category'],
7418 'privilege_point' => $this->options['privilege_point'],
7419 'privilege_discount' => $this->options['privilege_discount'],
7420 'tax_mode' => $this->options['tax_mode'],
7421 'tax_target' => $this->options['tax_target'],
7422 'tax_rate' => $this->options['tax_rate'],
7423 'tax_method' => $this->options['tax_method'],
7424 'membersystem_state' => $this->options['membersystem_state'],
7425 'membersystem_point' => $this->options['membersystem_point'],
7426 );
7427 return $order_conditions;
7428 //20120807ysk end
7429 }
7430
7431 function get_bestseller_ids( $days = "" ){
7432 global $wpdb;
7433 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7434 $yearstr = substr($datestr, 0, 4);
7435 $monthstr = substr($datestr, 5, 2);
7436 $daystr = substr($datestr, 8, 2);
7437 $res = array();
7438 $order_table_name = $wpdb->prefix . "usces_order";
7439 $where = "";
7440 if( empty($days) ){
7441 $days = 30;
7442 }
7443 $order_date = date('Y-m-d H:i:s', mktime(0, 0, 0, (int)$monthstr, ((int)$daystr-$days), (int)$yearstr));
7444 $where = " WHERE order_date >= '{$order_date}'";
7445 $query = "SELECT order_cart FROM {$order_table_name}" . $where;
7446 $dbres = $wpdb->get_col($query);
7447 if(!$dbres) return false;
7448
7449 foreach((array)$dbres as $carts){
7450 $rows = unserialize($carts);
7451 foreach((array)$rows as $carts){
7452 if( 'publish' != get_post_status($carts['post_id']) )
7453 continue;
7454
7455 $id = $carts['post_id'];
7456 $qu = $carts['quantity'];
7457 if(array_key_exists($id, $res)){
7458 $res[$id] = $res[$id] + $qu;
7459 }else{
7460 $res[$id] = $qu;
7461 }
7462 }
7463 }
7464 arsort($res);
7465 $results = array_keys($res);
7466 return $results;
7467 }
7468
7469 function get_items_num(){
7470 global $wpdb;
7471 $query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM {$wpdb->posts}
7472 WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
7473 'item', 'post', 'trush');
7474 $res = $wpdb->get_var($query);
7475
7476 return $res;
7477 }
7478
7479 function is_gptekiyo( $post_id, $sku, $quant ) {
7480 $skus = $this->get_skus( $post_id, 'code' );
7481 if( !isset($skus[$sku]['gp']) || !$skus[$sku]['gp'] ) return false;
7482
7483 $GpN1 = $this->getItemGpNum1($post_id);
7484 $GpN2 = $this->getItemGpNum2($post_id);
7485 $GpN3 = $this->getItemGpNum3($post_id);
7486
7487 if( empty($GpN1) ) {
7488
7489 return false;
7490
7491 }else if( !empty($GpN1) && empty($GpN2) ) {
7492
7493 if( $quant >= $GpN1 ) {
7494 return true;
7495 }else{
7496 return false;
7497 }
7498
7499 }else if( !empty($GpN1) && !empty($GpN2) && empty($GpN3) ) {
7500
7501 if( $quant >= $GpN2 ) {
7502 return true;
7503 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
7504 return true;
7505 }else{
7506 return false;
7507 }
7508
7509 }else if( !empty($GpN1) && !empty($GpN2) && !empty($GpN3) ) {
7510
7511 if( $quant >= $GpN3 ) {
7512 return true;
7513 }else if( $quant >= $GpN2 && $quant < $GpN3 ) {
7514 return true;
7515 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
7516 return true;
7517 }else{
7518 return false;
7519 }
7520 }
7521 }
7522
7523 function get_available_delivery_method() {
7524 if($this->cart->num_row() > 0) {
7525 $cart = $this->cart->get_cart();
7526 $before_deli = array();
7527 $intersect = array();
7528 $integration = array();
7529 $temp = array();
7530 $in = 0;
7531 foreach($cart as $key => $row){
7532 $deli = $this->getItemDeliveryMethod($row['post_id']);
7533 //usces_p($deli);
7534 if( empty($deli))
7535 continue;
7536
7537 //usces_log('deli : '.print_r($deli, true), 'acting_transaction.log');
7538 if( 0 === $in ){
7539 $intersect = $deli;
7540 }
7541 $intersect = array_intersect($deli, $intersect);
7542 $before_deli = $deli;
7543 foreach($deli as $value){
7544 $integration[] = $value;
7545 }
7546 $in++;
7547 }
7548 $integration = array_unique($integration);
7549 foreach($integration as $id){
7550 $index = $this->get_delivery_method_index($id);
7551 $temp[$index] = $id;
7552 }
7553 ksort($temp);
7554 //20120820ysk start 0000546
7555 //$force = array($temp[0]);
7556 $force = array(array_shift($temp));
7557 //20120820ysk end
7558
7559 if( empty($intersect) ){
7560 return $force;
7561 }else{
7562 return $intersect;
7563 }
7564 }
7565 return array();
7566 }
7567
7568 function get_delivery_method_index($id) {
7569 $index = false;
7570 for($i=0; $i<count($this->options['delivery_method']); $i++){
7571 if( $this->options['delivery_method'][$i]['id'] === (int)$id ){
7572 $index = $i;
7573 }
7574 }
7575 if($index === false)
7576 return -1;
7577 else
7578 return $index;
7579 }
7580
7581 function get_shipping_charge_index($id) {
7582 $index = false;
7583 for($i=0; $i<count($this->options['shipping_charge']); $i++){
7584 //20120710ysk start 0000472
7585 //if( $this->options['shipping_charge'][$i]['id'] === $id ){
7586 if( (int)$this->options['shipping_charge'][$i]['id'] == (int)$id ){
7587 //20120710ysk end
7588 $index = $i;
7589 }
7590 }
7591 if($index === false)
7592 return -1;
7593 else
7594 return $index;
7595 }
7596
7597 function get_initial_data($xml){
7598 $buf = file_get_contents($xml);
7599 preg_match_all('@<page>.*?<post_title>(.*?)</post_title>.*?<post_status>(.*?)</post_status>.*?<post_name>(.*?)</post_name>.*?<post_content>(.*?)</post_content>.*?</page>@s', $buf, $match, PREG_SET_ORDER);
7600 return $match;
7601 }
7602
7603 function getCurrencySymbol(){
7604 global $usces_settings;
7605 $cr = $this->options['system']['currency'];
7606 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7607 return $symbol;
7608 }
7609
7610 function getCartItemName($post_id, $sku){
7611 $name_arr = array();
7612 $name_str = '';
7613
7614 foreach($this->options['indi_item_name'] as $key => $value){
7615 if($value){
7616 $pos = (int)$this->options['pos_item_name'][$key];
7617 $ind = ($pos === 0) ? 'A' : $pos;
7618 switch($key){
7619 case 'item_name':
7620 $name_arr[$ind][$key] = $this->getItemName($post_id);
7621 break;
7622 case 'item_code':
7623 $name_arr[$ind][$key] = $this->getItemCode($post_id);
7624 break;
7625 case 'sku_name':
7626 $name_arr[$ind][$key] = $this->getItemSkuDisp($post_id, $sku);
7627 break;
7628 case 'sku_code':
7629 $name_arr[$ind][$key] = $sku;
7630 break;
7631 }
7632 }
7633
7634 }
7635 ksort($name_arr);
7636 foreach($name_arr as $vals){
7637 foreach($vals as $key => $value){
7638
7639 $name_str .= $value . ' ';
7640 }
7641 }
7642
7643 $name_str = apply_filters('usces_admin_order_item_name_filter', $name_str, $post_id, $sku);
7644
7645 return trim($name_str);
7646 }
7647
7648 function getCartItemName_byOrder($cart_row){
7649 $name_arr = array();
7650 $name_str = '';
7651
7652 foreach($this->options['indi_item_name'] as $key => $value){
7653 if($value){
7654 $pos = (int)$this->options['pos_item_name'][$key];
7655 $ind = ($pos === 0) ? 'A' : $pos;
7656 switch($key){
7657 case 'item_name':
7658 $name_arr[$ind][$key] = $cart_row['item_name'];
7659 break;
7660 case 'item_code':
7661 $name_arr[$ind][$key] = $cart_row['item_code'];
7662 break;
7663 case 'sku_name':
7664 $name_arr[$ind][$key] = $cart_row['sku_name'];
7665 break;
7666 case 'sku_code':
7667 $name_arr[$ind][$key] = $cart_row['sku_code'];
7668 break;
7669 }
7670 }
7671
7672 }
7673 ksort($name_arr);
7674 foreach($name_arr as $vals){
7675 foreach($vals as $key => $value){
7676
7677 $name_str .= $value . ' ';
7678 }
7679 }
7680
7681 $name_str = apply_filters('usces_filter_item_mame_by_order', $name_str, $cart_row);
7682
7683 return trim($name_str);
7684 }
7685
7686 function set_reserve_pre_order_id(){
7687 $entry = $this->cart->get_entry();
7688 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : uniqid('');
7689 $this->cart->set_pre_order_id($id);
7690 }
7691
7692 function get_current_pre_order_id(){
7693 $entry = $this->cart->get_entry();
7694 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : NULL;
7695 return $id;
7696 }
7697
7698 function get_reserve($order_id, $key){
7699 global $wpdb;
7700 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7701 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7702 $order_id, $key);
7703 $res = $wpdb->get_var($query);
7704 return $res;
7705 }
7706
7707 //20100818ysk start
7708 //20100816ysk start
7709 //function get_order_meta($order_id, $key) {
7710 function get_order_meta_value($key, $order_id) {
7711 global $wpdb;
7712 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7713 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7714 $order_id, $key);
7715 $res = $wpdb->get_var($query);
7716 return $res;
7717 }
7718 //20100816ysk end
7719 function set_order_meta_value($key, $meta_value, $order_id) {
7720 global $wpdb;
7721
7722 //if( empty($meta_value) ) return;
7723 if( empty($order_id) ) return;
7724
7725 $table_name = $wpdb->prefix . "usces_order_meta";
7726 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s",
7727 $order_id, $key);
7728 $res = $wpdb->get_var($query);
7729 if(0 < $res) {
7730 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s",
7731 $meta_value,
7732 $order_id,
7733 $key
7734 );
7735 $res2 = $wpdb->query($query);
7736 } else {
7737 $query = $wpdb->prepare("INSERT INTO $table_name (order_id, meta_key, meta_value)
7738 VALUES(%d, %s, %s)",
7739 $order_id,
7740 $key,
7741 $meta_value
7742 );
7743 $res2 = $wpdb->query($query);
7744 }
7745 return $res2;
7746 }
7747 //20130524ysk start
7748 function del_order_meta( $key, $order_id ) {
7749 global $wpdb;
7750 $table_name = $wpdb->prefix."usces_order_meta";
7751 $query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
7752 $res = $wpdb->query( $query );
7753 return $res;
7754 }
7755 //20130524ysk end
7756 function set_session_custom_member($member_id) {
7757 unset($_SESSION['usces_member']['custom_member']);
7758 $meta = usces_has_custom_field_meta('member');
7759 if(is_array($meta)) {
7760 $keys = array_keys($meta);
7761 foreach($keys as $key) {
7762 $csmb_key = 'csmb_'.$key;
7763 $_SESSION['usces_member']['custom_member'][$key] = maybe_unserialize($this->get_member_meta_value($csmb_key, $member_id));
7764 }
7765 }
7766 }
7767
7768 function reg_custom_member($member_id) {
7769 //20130524ysk start 0000712
7770 $csmb_meta = usces_has_custom_field_meta( 'member' );
7771 if( is_array($csmb_meta) ) {
7772 foreach( $csmb_meta as $key => $entry ) {
7773 if( '4' == $entry['means'] ) {
7774 $this->del_member_meta( 'csmb_'.$key, $member_id );
7775 }
7776 }
7777 }
7778 //20130524ysk end
7779 if( !empty($_POST['custom_member']) ) {
7780 foreach( $_POST['custom_member'] as $key => $value ) {
7781 $csmb_key = 'csmb_'.$key;
7782 if( is_array($value) )
7783 $value = serialize($value);
7784 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7785 if(false === $res)
7786 return false;
7787 }
7788 }elseif( isset($_POST['custom_customer']) ){
7789 foreach( $_POST['custom_customer'] as $key => $value ) {
7790 $csmb_key = 'csmb_'.$key;
7791 if( is_array($value) )
7792 $value = serialize($value);
7793 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7794 if(false === $res)
7795 return false;
7796 }
7797 }
7798 }
7799 //20100818ysk end
7800
7801 function save_order_acting_data($rand){
7802 global $wpdb;
7803 $data = serialize(array( 'cart' => $this->cart->get_cart(), 'entry' => $this->cart->get_entry() ));
7804 $table_name = $wpdb->prefix . "usces_access";
7805 $query = $wpdb->prepare("INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value)
7806 VALUES(%s, %s, now(), %s, %s)",
7807 'acting_data',
7808 $this->get_uscesid(false),
7809 $rand,
7810 $data
7811 );
7812 $res = $wpdb->query($query);
7813 return $res;
7814 }
7815
7816 //20100818ysk start
7817 function set_member_meta_value($key, $meta_value, $member_id = ''){
7818 global $wpdb;
7819
7820 //if( empty($meta_value) ) return;
7821 if( WCUtils::is_blank($member_id) ) {
7822 if( !$this->is_member_logged_in() ) return;
7823 $member = $this->get_member();
7824 $member_id = $member['ID'];
7825 }
7826
7827 $table_name = $wpdb->prefix . "usces_member_meta";
7828 //$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7829 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s",
7830 $member_id, $key);
7831 $res = $wpdb->get_var($query);
7832 //if($res != NULL){
7833 if(0 < $res){
7834 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s",
7835 $meta_value,
7836 $member_id,
7837 $key
7838 );
7839 $res2 = $wpdb->query($query);
7840 }else{
7841 $query = $wpdb->prepare("INSERT INTO $table_name (member_id, meta_key, meta_value)
7842 VALUES(%d, %s, %s)",
7843 $member_id,
7844 $key,
7845 $meta_value
7846 );
7847 $res2 = $wpdb->query($query);
7848 }
7849 return $res2;
7850 }
7851 //20100818ysk end
7852
7853 function get_member_meta_value($key, $member_id){
7854 global $wpdb;
7855 $table_name = $wpdb->prefix . "usces_member_meta";
7856 $query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7857 $member_id, $key);
7858 $res = $wpdb->get_var($query);
7859 return $res;
7860 }
7861
7862 function del_member_meta($key, $member_id){
7863 global $wpdb;
7864 $table_name = $wpdb->prefix . "usces_member_meta";
7865 $query = $wpdb->prepare("DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s",
7866 $member_id, $key);
7867 $res = $wpdb->query($query);
7868 return $res;
7869 }
7870
7871 function get_member_meta($member_id){
7872 global $wpdb;
7873 $table_name = $wpdb->prefix . "usces_member_meta";
7874 $query = $wpdb->prepare("SELECT * FROM $table_name WHERE member_id = %d AND meta_key <> 'customer_country' AND meta_key NOT LIKE %s", $member_id, 'csmb_%');
7875 $res = $wpdb->get_results($query, ARRAY_A);
7876 return $res;
7877 }
7878
7879 function get_settle_info_field( $order_id ){
7880 global $wpdb;
7881 $fields = array();
7882 $table_name = $wpdb->prefix . "usces_order_meta";
7883 $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table_name WHERE order_id = %d AND (meta_key LIKE %s OR meta_key = %s OR meta_key = %s OR meta_key = %s OR meta_key = %s OR meta_key = %s)",
7884 $order_id, 'acting_%', 'settlement_id', 'order_number', 'res_tracking_id', 'SID', 'TransactionId');
7885 $res = $wpdb->get_results($query, ARRAY_A);
7886 if( !$res )
7887 return $fields;
7888
7889 foreach( $res as $value ){
7890 if( 'settlement_id' == $value['meta_key'] ){
7891 $meta_values = maybe_unserialize($value['meta_value']);
7892 if( is_array($meta_values) ){
7893 foreach( $meta_values as $key => $meta_value ){
7894 $fields[$key] = $meta_value;
7895 }
7896 }else{
7897 $fields['settlement_id'] = $meta_values;
7898 }
7899 }elseif( 'order_number' == $value['meta_key'] ){
7900 $fields['order_number'] = $value['meta_value'];
7901 }elseif( 'res_tracking_id' == $value['meta_key'] ){
7902 $fields['res_tracking_id'] = $value['meta_value'];
7903 }elseif( 'SID' == $value['meta_key'] ){
7904 $fields['SID'] = $value['meta_value'];
7905 }elseif( 'TransactionId' == $value['meta_key'] ){
7906 $fields['TransactionId'] = $value['meta_value'];
7907 }elseif( 'acting_' == substr($value['meta_key'], 0, 7) ){
7908 $meta_values = maybe_unserialize($value['meta_value']);
7909 if(is_array($meta_values)){
7910 foreach( $meta_values as $key => $meta_value ){
7911 $fields[$key] = $meta_value;
7912 }
7913 }
7914 }
7915 }
7916 return $fields;
7917 }
7918
7919 function get_post_custom($post_id, $orderby='meta_id', $order='ASC'){
7920 global $wpdb;
7921 $table = $wpdb->prefix . "postmeta";
7922 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7923 $post_id), ARRAY_A );
7924
7925 if ( !empty($meta_list) ) {
7926 foreach ( $meta_list as $metarow) {
7927 $mkey = $metarow['meta_key'];
7928 $mval = $metarow['meta_value'];
7929 $res[$mkey][] = $mval;
7930 }
7931 }
7932 return $res;
7933 }
7934
7935 function get_post_user_custom($post_id, $orderby='meta_id', $order='ASC'){
7936 global $wpdb;
7937 $res = array();
7938 $table = $wpdb->prefix . "postmeta";
7939 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7940 $post_id), ARRAY_A );
7941
7942 if ( !empty($meta_list) ) {
7943 foreach ( $meta_list as $metarow) {
7944 if( 0 === strpos($metarow['meta_key'], '_') )
7945 continue;
7946
7947 $mkey = $metarow['meta_key'];
7948 $mval = $metarow['meta_value'];
7949 if( array_key_exists($mkey, $res) ){
7950 $cval = $res[$mkey];
7951 $cval = (array)$cval;
7952 $cval[] = $mval;
7953 $res[$mkey] = $cval;
7954 }else{
7955 $res[$mkey] = $mval;
7956 }
7957 }
7958 }
7959 return $res;
7960 }
7961
7962 function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ){
7963 global $usces_settings;
7964 $cr = $this->options['system']['currency'];
7965 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7966 if( !$seperator_flag ){
7967 $seperator = '';
7968 }
7969 $price = number_format((double)$amount, $decimal, $point, $seperator);//0000652
7970
7971 if( $symbol_pre )
7972 $price = ( usces_is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol ) . $price;
7973
7974 if( $symbol_post )
7975 $price = $price . __($code, 'usces');
7976
7977 return $price;
7978 }
7979
7980 function get_currency_code(){
7981 global $usces_settings;
7982 $cr = $this->options['system']['currency'];
7983 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7984 return $code;
7985 }
7986
7987 //shortcode-----------------------------------------------------------------------------
7988 function sc_company_name() {
7989 return htmlspecialchars($this->options['company_name']);
7990 }
7991 function sc_zip_code() {
7992 return htmlspecialchars($this->options['zip_code']);
7993 }
7994 function sc_address1() {
7995 return htmlspecialchars($this->options['address1']);
7996 }
7997 function sc_address2() {
7998 return htmlspecialchars($this->options['address2']);
7999 }
8000 function sc_tel_number() {
8001 return htmlspecialchars($this->options['tel_number']);
8002 }
8003 function sc_fax_number() {
8004 return htmlspecialchars($this->options['fax_number']);
8005 }
8006 function sc_inquiry_mail() {
8007 return htmlspecialchars($this->options['inquiry_mail']);
8008 }
8009 function sc_payment() {
8010 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
8011 $htm = "<ul>\n";
8012 foreach ( (array)$payments as $payment ) {
8013 $htm .= "<li>" . htmlspecialchars($payment['name']) . "<br />\n";
8014 $htm .= nl2br(htmlspecialchars($payment['explanation'])) . "</li>\n";
8015 }
8016 $htm .= "</ul>\n";
8017 return $htm;
8018 }
8019 function sc_payment_title() {
8020 $payments = $this->options['payment_method'];
8021 $htm = "<ul>\n";
8022 foreach ( (array)$payments as $payment ) {
8023 $htm .= "<li>" . esc_html($payment['name']) . "</li>\n";
8024 }
8025 $htm .= "</ul>\n";
8026 return $htm;
8027 }
8028 function sc_cod_fee() {
8029 return number_format($this->options['cod_fee']);
8030 }
8031 function sc_start_point() {
8032 return number_format($this->options['start_point']);
8033 }
8034 function sc_postage_privilege() {
8035 if(empty($this->options['postage_privilege']))
8036 return;
8037 return number_format($this->options['postage_privilege']);
8038 }
8039 function sc_shipping_charge() {
8040 //20120710ysk start 0000472
8041 $entry = $this->cart->get_entry();
8042 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
8043 //20120710ysk end
8044 $arr = array();
8045 foreach ( (array)$this->options['shipping_charge'] as $charges ) {
8046 //20120710ysk start 0000472
8047 //foreach ( (array)$charges['value'] as $value ) {
8048 foreach ( (array)$charges[$country] as $value ) {
8049 //20120710ysk end
8050 $arr[] = $value;
8051 }
8052 }
8053 sort($arr);
8054 $min = $arr[0];
8055 rsort($arr);
8056 $max = $arr[0];
8057 if($min == $max){
8058 $res = number_format($min);
8059 }else{
8060 $res = number_format($min) . __(' - ', 'usces') . number_format($max);
8061 }
8062 return $res;
8063 }
8064 function sc_site_url() {
8065 return get_option('home');
8066 }
8067 function sc_button_to_cart($atts) {
8068 extract(shortcode_atts(array(
8069 'item' => '',
8070 'sku' => '',
8071 'value' => __('to the cart', 'usces'),
8072 'force' => 0,
8073 'quant' => 0,
8074 'opt' => 1,
8075 ), $atts));
8076
8077 $post_id = $this->get_ID_byItemName($item);
8078 $datas = $this->get_skus( $post_id, 'code' );
8079 $zaikonum = $datas[$sku]['stocknum'];
8080 $zaiko = $datas[$sku]['stock'];
8081 $gptekiyo = $datas[$sku]['gp'];
8082 $skuPrice = $datas[$sku]['price'];
8083 $sku_enc = urlencode($sku);
8084 $mats = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc');
8085 if( ! $this->is_item_zaiko( $post_id, $sku ) ){
8086 return '<div class="button_status">' . esc_html($this->zaiko_status[$zaiko]) . '</div>';
8087 }
8088
8089 $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n";
8090 $html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"{$zaikonum}\" />\n";
8091 $html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"{$zaiko}\" />\n";
8092 $html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"{$gptekiyo}\" />\n";
8093 $html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"{$skuPrice}\" />\n";
8094 if( 1 == $opt ){
8095 $html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' );
8096 }elseif( 2 == $opt ){
8097 $html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' );
8098 }
8099 if( $quant ){
8100 $quant_field = "<input name=\"quant[{$post_id}][" . $sku_enc . "]\" type=\"text\" id=\"quant[{$post_id}][" . $sku_enc . "]\" class=\"skuquantity\" value=\"\" onKeyDown=\"if (event.keyCode == 13) {return false;}\" />";
8101 $html .= apply_filters('usces_filter_sc_itemQuant', $quant_field, $mats);
8102 }
8103 $html .= "<input name=\"inCart[{$post_id}][{$sku_enc}]\" type=\"submit\" id=\"inCart[{$post_id}][{$sku_enc}]\" class=\"skubutton\" value=\"{$value}\" " . apply_filters('usces_filter_direct_intocart_button', NULL, $post_id, $sku, $force, $options) . " />";
8104 $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
8105 if( $force )
8106 $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
8107 $html = apply_filters('usces_filter_single_item_inform', $html);
8108 $html .= "</form>";
8109 $html .= '<div class="error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";
8110
8111 return $html;
8112 }
8113
8114 function filter_itemPage($content){
8115 global $post;
8116 $html = '';
8117
8118 if( ($post->post_mime_type != 'item' || !is_single()) ) return $content;
8119 if( post_password_required($post) ) return $content;
8120
8121 $temp_path = apply_filters('usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php');
8122 include( $temp_path );
8123
8124 $content = apply_filters('usces_filter_itemPage', $html, $post->ID);
8125
8126 return $content;
8127 }
8128
8129 function filter_cartContent($content) {
8130 global $post;
8131 $html = '';
8132
8133 switch($this->page){
8134 case 'cart':
8135 $temp_path = apply_filters('usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php');
8136 include( $temp_path );
8137 break;
8138 case 'customer':
8139 $temp_path = apply_filters('usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php');
8140 include( $temp_path );
8141 break;
8142 case 'delivery':
8143 $temp_path = apply_filters('usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php');
8144 include( $temp_path );
8145 break;
8146 case 'confirm':
8147 $temp_path = apply_filters('usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php');
8148 include( $temp_path );
8149 break;
8150 case 'ordercompletion':
8151 $temp_path = apply_filters('usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php');
8152 include( $temp_path );
8153 break;
8154 case 'error':
8155 $temp_path = apply_filters('usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php');
8156 include( $temp_path );
8157 break;
8158 case 'maintenance':
8159 $temp_path = apply_filters('usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php');
8160 include( $temp_path );
8161 break;
8162 case 'search_item':
8163 $temp_path = apply_filters('usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php');
8164 include( $temp_path );
8165 break;
8166 case 'wp_search':
8167 if($post->post_mime_type == 'item'){
8168 $temp_path = apply_filters('usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php');
8169 include( $temp_path );
8170 }else{
8171 $html = $content;
8172 }
8173 break;
8174 default:
8175 $html = $content;
8176 }
8177
8178 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) )
8179 $html = str_replace('src="'.site_url(), 'src="'.USCES_SSL_URL_ADMIN, $html);
8180
8181 $html = apply_filters('usces_filter_cartContent', $html);
8182
8183 $content = $html;
8184
8185 remove_filter('the_title', array($this, 'filter_cartTitle'));
8186
8187 return $content;
8188 }
8189
8190 function filter_cartTitle($title) {
8191
8192 if( $title == 'Cart' || $title == __('Cart', 'usces') ){
8193 switch($this->page){
8194 case 'cart':
8195 $newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces'));
8196 break;
8197 case 'customer':
8198 $newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces'));
8199 break;
8200 case 'delivery':
8201 $newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces'));
8202 break;
8203 case 'confirm':
8204 $newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces'));
8205 break;
8206 case 'ordercompletion':
8207 $newtitle = apply_filters('usces_filter_title_ordercompletion', __('Completion', 'usces'));
8208 break;
8209 case 'error':
8210 $newtitle = apply_filters('usces_filter_title_carterror', __('Error', 'usces'));
8211 break;
8212 case 'search_item':
8213 $newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces'));
8214 break;
8215 case 'maintenance':
8216 $newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces'));
8217 break;
8218 case 'login':
8219 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
8220 break;
8221 default:
8222 $newtitle = apply_filters('usces_filter_title_cart_default', $title);
8223 }
8224 }else{
8225 $newtitle = $title;
8226 }
8227
8228 $newtitle = apply_filters('usces_filter_cartTitle', $newtitle);
8229 return $newtitle;
8230 }
8231
8232 function action_cartFilter(){
8233 add_filter('the_title', array($this, 'filter_cartTitle'),20);
8234 add_filter('the_content', array($this, 'filter_cartContent'),20);
8235 }
8236
8237 function action_search_item(){
8238 include(TEMPLATEPATH . '/page.php');
8239 exit;
8240 }
8241
8242 function filter_memberContent($content) {
8243 global $post;
8244 $html = '';
8245
8246 if($this->options['membersystem_state'] == 'activate'){
8247
8248 if( $this->is_member_logged_in() ) {
8249
8250 $member_regmode = 'editmemberform';
8251 $temp_path = apply_filters('usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php');
8252 include( $temp_path );
8253
8254 } else {
8255
8256 switch($this->page){
8257 case 'login':
8258 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
8259 include( $temp_path );
8260 break;
8261 case 'lostmemberpassword':
8262 $temp_path = apply_filters('usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php');
8263 include( $temp_path );
8264 break;
8265 case 'changepassword':
8266 $temp_path = apply_filters('usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php');
8267 include( $temp_path );
8268 break;
8269 case 'newcompletion':
8270 case 'editcompletion':
8271 case 'lostcompletion':
8272 case 'changepasscompletion':
8273 $temp_path = apply_filters('usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php');
8274 include( $temp_path );
8275 break;
8276 case 'newmemberform':
8277 $member_form_title = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
8278 $member_regmode = 'newmemberform';
8279 $temp_path = apply_filters('usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php');
8280 include( $temp_path );
8281 break;
8282 default:
8283 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
8284 include( $temp_path );
8285 }
8286
8287 }
8288 }else{
8289 $html .= "<p>".__('Member Services is not running currently.','usces')."</p>";
8290 }
8291
8292 $content = $html;
8293
8294 remove_filter('the_title', array($this, 'filter_memberTitle'));
8295
8296 return $content;
8297 }
8298
8299 function filter_memberTitle($title) {
8300
8301 if( $this->options['membersystem_state'] == 'activate' && ($title == 'Member' || $title == __('Membership', 'usces')) ){
8302 switch($this->page){
8303 case 'login':
8304 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
8305 break;
8306 case 'newmemberform':
8307 $newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
8308 break;
8309 case 'lostmemberpassword':
8310 $newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces'));
8311 break;
8312 case 'changepassword':
8313 $newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces'));
8314 break;
8315 case 'newcompletion':
8316 case 'editcompletion':
8317 case 'lostcompletion':
8318 case 'changepasscompletion':
8319 $newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Completion', 'usces'));
8320 break;
8321 case 'error':
8322 $newtitle = apply_filters('usces_filter_title_membererror', __('Error', 'usces'));
8323 break;
8324 default:
8325 $newtitle = apply_filters('usces_filter_title_member_default', $title);
8326 }
8327 }else{
8328 $newtitle = $title;
8329 }
8330
8331 $newtitle = apply_filters('usces_filter_memberTitle', $newtitle);
8332 return $newtitle;
8333 }
8334
8335 function action_memberFilter(){
8336 add_filter('the_title', array($this, 'filter_memberTitle'),20);
8337 add_filter('the_content', array($this, 'filter_memberContent'),20);
8338 }
8339
8340 function filter_usces_cart_css(){
8341 $path = get_stylesheet_directory_uri() . '/usces_cart.css';
8342 return $path;
8343 }
8344
8345 function filter_divide_item(){
8346 global $wp_query;
8347
8348
8349 if( ($this->options['divide_item'] && !is_category() && !is_search() && !is_singular() && !is_admin()) ){
8350 $ids = $this->getItemIds( 'front' );
8351 $wp_query->query_vars['post__not_in'] = $ids;
8352
8353 }
8354 if( is_admin() ){
8355 $ids = $this->getItemIds( 'back' );
8356 //$wp_query->query_vars['category__not_in'] = array(USCES_ITEM_CAT_PARENT_ID);
8357 $wp_query->query_vars['post__not_in'] = $ids;
8358 }
8359 do_action( 'usces_action_divide_item');
8360 }
8361
8362 function load_upload_template(){
8363 $post_id = $_POST['post_id'];
8364 $file = 'upload_template01.php';
8365 include(TEMPLATEPATH . '/' . $file);
8366 exit;
8367 }
8368
8369 function filter_itemimg_anchor_rel($html){
8370
8371 if( is_single() ){
8372 $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"';
8373 }else{
8374 $str = '';
8375 }
8376 return $html . $str;
8377 }
8378
8379 function filter_permalink( $link ) {
8380
8381 if(false !== strpos('?page_id=4', $link) || false !== strpos('?page_id=3', $link) || false !== strpos('usces-cart', $link) || false !== strpos('usces-member', $link) )
8382 $link = str_replace('http://', 'https://', $link);
8383
8384 return $link;
8385 }
8386
8387 function filter_cart_page_header($html){
8388 if( !empty($this->options['cart_page_data']['header']['cart']) ){
8389 $html = $this->options['cart_page_data']['header']['cart'];
8390 }
8391 return do_shortcode( stripslashes(nl2br($html)) );
8392 }
8393
8394 function filter_cart_page_footer($html){
8395 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
8396 $html = $this->options['cart_page_data']['footer']['cart'];
8397 }
8398 return do_shortcode( stripslashes(nl2br($html)) );
8399 }
8400
8401 function filter_customer_page_header($html){
8402 if( !empty($this->options['cart_page_data']['header']['customer']) ){
8403 $html = $this->options['cart_page_data']['header']['customer'];
8404 }
8405 return do_shortcode( stripslashes(nl2br($html)) );
8406 }
8407
8408 function filter_customer_page_footer($html){
8409 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
8410 $html = $this->options['cart_page_data']['footer']['customer'];
8411 }
8412 return do_shortcode( stripslashes(nl2br($html)) );
8413 }
8414
8415 function filter_delivery_page_header($html){
8416 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
8417 $html = $this->options['cart_page_data']['header']['delivery'];
8418 }
8419 return do_shortcode( stripslashes(nl2br($html)) );
8420 }
8421
8422 function filter_delivery_page_footer($html){
8423 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
8424 $html = $this->options['cart_page_data']['footer']['delivery'];
8425 }
8426 return do_shortcode( stripslashes(nl2br($html)) );
8427 }
8428
8429 function filter_confirm_page_header($html){
8430 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
8431 $html = $this->options['cart_page_data']['header']['confirm'];
8432 }
8433 return do_shortcode( stripslashes(nl2br($html)) );
8434 }
8435
8436 function filter_confirm_page_footer($html){
8437 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
8438 $html = $this->options['cart_page_data']['footer']['confirm'];
8439 }
8440 return do_shortcode( stripslashes(nl2br($html)) );
8441 }
8442
8443 function filter_cartcompletion_page_header($html){
8444 if( !empty($this->options['cart_page_data']['header']['completion']) ){
8445 $html = $this->options['cart_page_data']['header']['completion'];
8446 }
8447 return do_shortcode( stripslashes(nl2br($html)) );
8448 }
8449
8450 function filter_cartcompletion_page_footer($html){
8451 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
8452 $html = $this->options['cart_page_data']['footer']['completion'];
8453 }
8454 return do_shortcode( stripslashes(nl2br($html)) );
8455 }
8456
8457 function filter_login_page_header($html){
8458 if( !empty($this->options['member_page_data']['header']['login']) ){
8459 $html = $this->options['member_page_data']['header']['login'];
8460 }
8461 return do_shortcode( stripslashes(nl2br($html)) );
8462 }
8463
8464 function filter_login_page_footer($html){
8465 if( !empty($this->options['member_page_data']['footer']['login']) ){
8466 $html = $this->options['member_page_data']['footer']['login'];
8467 }
8468 return do_shortcode( stripslashes(nl2br($html)) );
8469 }
8470
8471 function filter_newmember_page_header($html){
8472 if( !empty($this->options['member_page_data']['header']['newmember']) ){
8473 $html = $this->options['member_page_data']['header']['newmember'];
8474 }
8475 return do_shortcode( stripslashes(nl2br($html)) );
8476 }
8477
8478 function filter_newmember_page_footer($html){
8479 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
8480 $html = $this->options['member_page_data']['footer']['newmember'];
8481 }
8482 return do_shortcode( stripslashes(nl2br($html)) );
8483 }
8484
8485 function filter_newpass_page_header($html){
8486 if( !empty($this->options['member_page_data']['header']['newpass']) ){
8487 $html = $this->options['member_page_data']['header']['newpass'];
8488 }
8489 return do_shortcode( stripslashes(nl2br($html)) );
8490 }
8491
8492 function filter_newpass_page_footer($html){
8493 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
8494 $html = $this->options['member_page_data']['footer']['newpass'];
8495 }
8496 return do_shortcode( stripslashes(nl2br($html)) );
8497 }
8498
8499 function filter_changepass_page_header($html){
8500 if( !empty($this->options['member_page_data']['header']['changepass']) ){
8501 $html = $this->options['member_page_data']['header']['changepass'];
8502 }
8503 return do_shortcode( stripslashes(nl2br($html)) );
8504 }
8505
8506 function filter_changepass_page_footer($html){
8507 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
8508 $html = $this->options['member_page_data']['footer']['changepass'];
8509 }
8510 return do_shortcode( stripslashes(nl2br($html)) );
8511 }
8512
8513 function filter_memberinfo_page_header($html){
8514 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
8515 $html = $this->options['member_page_data']['header']['memberinfo'];
8516 }
8517 return do_shortcode( stripslashes(nl2br($html)) );
8518 }
8519
8520 function filter_memberinfo_page_footer($html){
8521 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
8522 $html = $this->options['member_page_data']['footer']['memberinfo'];
8523 }
8524 return do_shortcode( stripslashes(nl2br($html)) );
8525 }
8526
8527 function filter_membercompletion_page_header($html){
8528 if( !empty($this->options['member_page_data']['header']['completion']) ){
8529 $html = $this->options['member_page_data']['header']['completion'];
8530 }
8531 return do_shortcode( stripslashes(nl2br($html)) );
8532 }
8533
8534 function filter_membercompletion_page_footer($html){
8535 if( !empty($this->options['member_page_data']['footer']['completion']) ){
8536 $html = $this->options['member_page_data']['footer']['completion'];
8537 }
8538 return do_shortcode( stripslashes(nl2br($html)) );
8539 }
8540
8541 function action_cart_page_header(){
8542 if( !empty($this->options['cart_page_data']['header']['cart']) ){
8543 $html = $this->options['cart_page_data']['header']['cart'];
8544 echo do_shortcode( stripslashes(nl2br($html)) );
8545 }
8546 }
8547
8548 function action_cart_page_footer(){
8549 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
8550 $html = $this->options['cart_page_data']['footer']['cart'];
8551 echo do_shortcode( stripslashes(nl2br($html)) );
8552 }
8553 }
8554
8555 function action_customer_page_header(){
8556 if( !empty($this->options['cart_page_data']['header']['customer']) ){
8557 $html = $this->options['cart_page_data']['header']['customer'];
8558 echo do_shortcode( stripslashes(nl2br($html)) );
8559 }
8560 }
8561
8562 function action_customer_page_footer(){
8563 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
8564 $html = $this->options['cart_page_data']['footer']['customer'];
8565 echo do_shortcode( stripslashes(nl2br($html)) );
8566 }
8567 }
8568
8569 function action_delivery_page_header(){
8570 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
8571 $html = $this->options['cart_page_data']['header']['delivery'];
8572 echo do_shortcode( stripslashes(nl2br($html)) );
8573 }
8574 }
8575
8576 function action_delivery_page_footer(){
8577 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
8578 $html = $this->options['cart_page_data']['footer']['delivery'];
8579 echo do_shortcode( stripslashes(nl2br($html)) );
8580 }
8581 }
8582
8583 function action_confirm_page_header(){
8584 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
8585 $html = $this->options['cart_page_data']['header']['confirm'];
8586 echo do_shortcode( stripslashes(nl2br($html)) );
8587 }
8588 }
8589
8590 function action_confirm_page_footer(){
8591 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
8592 $html = $this->options['cart_page_data']['footer']['confirm'];
8593 echo do_shortcode( stripslashes(nl2br($html)) );
8594 }
8595 }
8596
8597 function action_cartcompletion_page_header(){
8598 if( !empty($this->options['cart_page_data']['header']['completion']) ){
8599 $html = $this->options['cart_page_data']['header']['completion'];
8600 echo do_shortcode( stripslashes(nl2br($html)) );
8601 }
8602 }
8603
8604 function action_cartcompletion_page_footer(){
8605 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
8606 $html = $this->options['cart_page_data']['footer']['completion'];
8607 echo do_shortcode( stripslashes(nl2br($html)) );
8608 }
8609 }
8610
8611 function action_login_page_header(){
8612 if( !empty($this->options['member_page_data']['header']['login']) ){
8613 $html = $this->options['member_page_data']['header']['login'];
8614 echo do_shortcode( stripslashes(nl2br($html)) );
8615 }
8616 }
8617
8618 function action_login_page_footer(){
8619 if( !empty($this->options['member_page_data']['footer']['login']) ){
8620 $html = $this->options['member_page_data']['footer']['login'];
8621 echo do_shortcode( stripslashes(nl2br($html)) );
8622 }
8623 }
8624
8625 function action_newmember_page_header(){
8626 if( !empty($this->options['member_page_data']['header']['newmember']) ){
8627 $html = $this->options['member_page_data']['header']['newmember'];
8628 echo do_shortcode( stripslashes(nl2br($html)) );
8629 }
8630 }
8631
8632 function action_newmember_page_footer(){
8633 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
8634 $html = $this->options['member_page_data']['footer']['newmember'];
8635 echo do_shortcode( stripslashes(nl2br($html)) );
8636 }
8637 }
8638
8639 function action_newpass_page_header(){
8640 if( !empty($this->options['member_page_data']['header']['newpass']) ){
8641 $html = $this->options['member_page_data']['header']['newpass'];
8642 echo do_shortcode( stripslashes(nl2br($html)) );
8643 }
8644 }
8645
8646 function action_newpass_page_footer(){
8647 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
8648 $html = $this->options['member_page_data']['footer']['newpass'];
8649 echo do_shortcode( stripslashes(nl2br($html)) );
8650 }
8651 }
8652
8653 function action_changepass_page_header(){
8654 if( !empty($this->options['member_page_data']['header']['changepass']) ){
8655 $html = $this->options['member_page_data']['header']['changepass'];
8656 echo do_shortcode( stripslashes(nl2br($html)) );
8657 }
8658 }
8659
8660 function action_changepass_page_footer(){
8661 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
8662 $html = $this->options['member_page_data']['footer']['changepass'];
8663 echo do_shortcode( stripslashes(nl2br($html)) );
8664 }
8665 }
8666
8667 function action_memberinfo_page_header(){
8668 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
8669 $html = $this->options['member_page_data']['header']['memberinfo'];
8670 echo do_shortcode( stripslashes(nl2br($html)) );
8671 }
8672 }
8673
8674 function action_memberinfo_page_footer(){
8675 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
8676 $html = $this->options['member_page_data']['footer']['memberinfo'];
8677 echo do_shortcode( stripslashes(nl2br($html)) );
8678 }
8679 }
8680
8681 function action_membercompletion_page_header(){
8682 if( !empty($this->options['member_page_data']['header']['completion']) ){
8683 $html = $this->options['member_page_data']['header']['completion'];
8684 echo do_shortcode( stripslashes(nl2br($html)) );
8685 }
8686 }
8687
8688 function action_membercompletion_page_footer(){
8689 if( !empty($this->options['member_page_data']['footer']['completion']) ){
8690 $html = $this->options['member_page_data']['footer']['completion'];
8691 echo do_shortcode( stripslashes(nl2br($html)) );
8692 }
8693 }
8694 }
8695
8696
8697