PluginProbe
Welcart e-Commerce / 1.3.5
Welcart e-Commerce v1.3.5
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.3.5, at classes/usceshop.class.php

7,995 lines 310.5 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
17 function usc_e_shop()
18 {
19 //20110331ysk start
20 //global $post, $usces_settings;
21 global $post, $usces_settings, $usces_states;
22 //20110331ysk end
23 do_action('usces_construct');
24 add_action('after_setup_theme', array(&$this, 'usces_session_start'));
25
26 if ( is_admin() ){
27 clean_term_cache( get_option('usces_item_cat_parent_id'), 'category' );
28 }
29
30 $locales = usces_locales();
31 foreach($locales as $l){
32 $usces_settings['language'][$l] = $l;
33 }
34 $usces_settings['language']['others'] = __('Follow config.php', 'usces');
35
36 $this->options = get_option('usces');
37 if(!isset($this->options['smtp_hostname']) || empty($this->options['smtp_hostname'])){ $this->options['smtp_hostname'] = 'localhost';}
38 if(!isset($this->options['delivery_method']) || !is_array($this->options['delivery_method'])) $this->options['delivery_method'] = array();
39 if(!isset($this->options['shipping_charge']) || !is_array($this->options['shipping_charge'])) $this->options['shipping_charge'] = array();
40 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
41 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = 'activate';
42 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
43 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 0;
44 if(!isset($this->options['use_javascript'])) $this->options['use_javascript'] = 1;
45 if(!isset($this->options['privilege_discount'])) $this->options['privilege_discount'] = '';
46 if(!isset($this->options['privilege_point'])) $this->options['privilege_point'] = '';
47 if(!isset($this->options['campaign_privilege'])) $this->options['campaign_privilege'] = '';
48 if(!isset($this->options['campaign_category'])) $this->options['campaign_category'] = 0;
49 if(!isset($this->options['campaign_schedule']['start'])) $this->options['campaign_schedule']['start'] = array();
50 if(!isset($this->options['campaign_schedule']['end'])) $this->options['campaign_schedule']['end'] = array();
51 if(!isset($this->options['acting_settings']['paypal']['ec_activate'])) $this->options['acting_settings']['paypal']['ec_activate'] = '';
52 if(!isset($this->options['purchase_limit'])) $this->options['purchase_limit'] = '';
53 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
54 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
55 if(!isset($this->options['company_name'])) $this->options['company_name'] = '';
56 if(!isset($this->options['address1'])) $this->options['address1'] = '';
57 if(!isset($this->options['address2'])) $this->options['address2'] = '';
58 if(!isset($this->options['zip_code'])) $this->options['zip_code'] = '';
59 if(!isset($this->options['tel_number'])) $this->options['tel_number'] = '';
60 if(!isset($this->options['fax_number'])) $this->options['fax_number'] = '';
61 if(!isset($this->options['order_mail'])) $this->options['order_mail'] = '';
62 if(!isset($this->options['inquiry_mail'])) $this->options['inquiry_mail'] = '';
63 if(!isset($this->options['sender_mail'])) $this->options['sender_mail'] = '';
64 if(!isset($this->options['error_mail'])) $this->options['error_mail'] = '';
65 if(!isset($this->options['copyright'])) $this->options['copyright'] = '';
66 if(!isset($this->options['postage_privilege'])) $this->options['postage_privilege'] = '';
67 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
68 if(!isset($this->options['tax_rate'])) $this->options['tax_rate'] = '';
69 if(!isset($this->options['tax_method'])) $this->options['tax_method'] = 'cutting';
70 if(!isset($this->options['transferee'])) $this->options['transferee'] = '';
71 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
72 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = '';
73 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
74 if(!isset($this->options['start_point'])) $this->options['start_point'] = '';
75 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 1;
76 if(!isset($this->options['point_assign'])) $this->options['point_assign'] = 1;//20120919ysk 0000573
77 if(!isset($this->options['cod_type'])) $this->options['cod_type'] = 'fix';
78 if(!isset($this->options['newmem_admin_mail'])) $this->options['newmem_admin_mail'] = 0;
79 if(!isset($this->options['delmem_admin_mail'])) $this->options['delmem_admin_mail'] = 1;
80 if(!isset($this->options['delmem_customer_mail'])) $this->options['delmem_customer_mail'] = 1;
81 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'=>'');
82 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'=>'');
83 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'=>'');
84 if(!isset($this->options['cart_page_data']['header'])) $this->options['cart_page_data']['header'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
85 if(!isset($this->options['cart_page_data']['footer'])) $this->options['cart_page_data']['footer'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
86 if(!isset($this->options['member_page_data']['header'])) $this->options['member_page_data']['header'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
87 if(!isset($this->options['member_page_data']['footer'])) $this->options['member_page_data']['footer'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
88
89 if(!isset($this->options['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = '0';
90 if(!isset($this->options['delivery_after_days'])) $this->options['delivery_after_days'] = 15;
91 if(!isset($this->options['delivery_days'])) $this->options['delivery_days'] = array();
92 if(!isset($this->options['delivery_time_limit']['hour'])) $this->options['delivery_time_limit']['hour'] = '00';
93 if(!isset($this->options['delivery_time_limit']['min'])) $this->options['delivery_time_limit']['min'] = '00';
94
95 if(!isset($this->options['divide_item'])) $this->options['divide_item'] = 0;
96 if(!isset($this->options['itemimg_anchor_rel'])) $this->options['itemimg_anchor_rel'] = '';
97 if(!isset($this->options['fukugo_category_orderby'])) $this->options['fukugo_category_orderby'] = 'ID';
98 if(!isset($this->options['fukugo_category_order'])) $this->options['fukugo_category_order'] = 'ASC';
99 if(!isset($this->options['settlement_path'])) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
100 if(!isset($this->options['logs_path'])) $this->options['logs_path'] = '';
101 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
102 if(!isset($this->options['ssl_url'])) $this->options['ssl_url'] = '';
103 if(!isset($this->options['ssl_url_admin'])) $this->options['ssl_url_admin'] = '';
104 if(!isset($this->options['inquiry_id'])) $this->options['inquiry_id'] = '';
105 if(!isset($this->options['system']['orderby_itemsku'])) $this->options['system']['orderby_itemsku'] = 0;
106 if(!isset($this->options['system']['orderby_itemopt'])) $this->options['system']['orderby_itemopt'] = 0;
107 if(!isset($this->options['system']['front_lang'])) $this->options['system']['front_lang'] = usces_get_local_language();
108 if(!isset($this->options['system']['currency'])) $this->options['system']['currency'] = usces_get_base_country();
109 if(!isset($this->options['system']['addressform'])) $this->options['system']['addressform'] = usces_get_local_addressform();
110 if(!isset($this->options['system']['target_market'])) $this->options['system']['target_market'] = usces_get_local_target_market();
111 if(!isset($this->options['system']['no_cart_css'])) $this->options['system']['no_cart_css'] = 0;
112 if(!isset($this->options['system']['dec_orderID_flag'])) $this->options['system']['dec_orderID_flag'] = 0;
113 if(!isset($this->options['system']['dec_orderID_prefix'])) $this->options['system']['dec_orderID_prefix'] = '';
114 if(!isset($this->options['system']['dec_orderID_digit'])) $this->options['system']['dec_orderID_digit'] = 6;
115 if(!isset($this->options['system']['subimage_rule'])) $this->options['system']['subimage_rule'] = 0;
116
117 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'=>'');
118 if(!isset($this->options['acting_settings']['zeus']['connection'])) $this->options['acting_settings']['zeus']['connection'] = '1';
119 if(!isset($this->options['acting_settings']['zeus']['3dsecur'])) $this->options['acting_settings']['zeus']['3dsecur'] = '2';
120 if(!isset($this->options['acting_settings']['zeus']['security'])) $this->options['acting_settings']['zeus']['security'] = '2';
121 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'=>'');
122 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'=>'');
123 if(!isset($this->options['acting_settings']['paypal'])) $this->options['acting_settings']['paypal'] = array('activate'=>'','ec_activate'=>'','sandbox'=>'','user'=>'','pwd'=>'','signature'=>'', 'continuation'=>'');
124
125 //20010420ysk start
126 //if(!isset($this->options['system']['base_country'])) $this->options['system']['base_country'] = usces_get_base_country();
127 $this->options['system']['base_country'] = usces_get_base_country();
128 //20010420ysk end
129 //20110331ysk start
130 if(!isset($this->options['province'])) $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
131 //20110331ysk end
132 if(!isset($this->options['system']['pointreduction'])) $this->options['system']['pointreduction'] = usces_get_pointreduction($this->options['system']['currency']);
133 if(!isset($this->options['indi_item_name'])){
134 $this->options['indi_item_name']['item_name'] = 1;
135 $this->options['indi_item_name']['item_code'] = 1;
136 $this->options['indi_item_name']['sku_name'] = 1;
137 $this->options['indi_item_name']['sku_code'] = 1;
138 $this->options['pos_item_name']['item_name'] = 1;
139 $this->options['pos_item_name']['item_code'] = 2;
140 $this->options['pos_item_name']['sku_name'] = 3;
141 $this->options['pos_item_name']['sku_code'] = 4;
142 }
143 update_option('usces', $this->options);
144
145 $this->check_display_mode();
146 $this->error_message = '';
147 $this->login_mail = '';
148 $this->get_current_member();
149 $this->page = '';
150 $this->payment_results = array();
151 $this->use_js = $this->options['use_javascript'];
152
153 //admin_ssl options
154 // $this->use_ssl = get_option("admin_ssl_use_ssl") === "1" ? true : false;
155 // $use_shared = get_option("admin_ssl_use_shared") === "1" && $this->use_ssl ? true : false;
156 // $shared_url = get_option("admin_ssl_shared_url");
157
158 $this->use_ssl = $this->options['use_ssl'];
159 // if ( $use_shared ) {
160 // $ssl_url = str_replace('/wp-admin/', '', $shared_url);
161 // } else {
162 // $ssl_url = str_replace('http://', 'https://', get_option('home'));
163 // }
164 define('USCES_CART_NUMBER', get_option('usces_cart_number'));
165 define('USCES_MEMBER_NUMBER', get_option('usces_member_number'));
166
167 if ( $this->use_ssl ) {
168 $ssl_url = $this->options['ssl_url'];
169 $ssl_url_admin = $this->options['ssl_url_admin'];
170 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
171 define('USCES_FRONT_PLUGIN_URL', $ssl_url_admin . '/wp-content/plugins/' . USCES_PLUGIN_FOLDER);
172 define('USCES_COOKIEPATH', preg_replace('|https?://[^/]+|i', '', $ssl_url . '/' ) );
173 }else{
174 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
175 define('USCES_COOKIEPATH', COOKIEPATH);
176 }
177 define('USCES_SSL_URL', $ssl_url);
178 define('USCES_SSL_URL_ADMIN', $ssl_url_admin);
179 }else{
180 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
181 define('USCES_SSL_URL', get_option('home'));
182 define('USCES_SSL_URL_ADMIN', get_option('siteurl'));
183 define('USCES_COOKIEPATH', COOKIEPATH);
184 }
185 // if($this->use_ssl) {
186 // define('USCES_CART_URL', $ssl_url . '/?page_id=' . USCES_CART_NUMBER . '&usces=' . $this->get_uscesid());
187 // define('USCES_MEMBER_URL', $ssl_url . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces=' . $this->get_uscesid());
188 // define('USCES_INQUIRY_URL', $ssl_url . '/?page_id=' . $this->options['inquiry_id'] . '&usces=' . $this->get_uscesid());
189 // add_filter('home_url', array($this, 'usces_ssl_page_link'));
190 // add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
191 // add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
192 // add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
193 // add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
194 // add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
195 // } else {
196 // define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
197 // define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
198 // define('USCES_INQUIRY_URL', get_option('home') . '/?page_id=' . $this->options['inquiry_id']);
199 // }
200 define('USCES_ITEM_CAT_PARENT_ID', get_option('usces_item_cat_parent_id'));
201
202 $this->zaiko_status = get_option('usces_zaiko_status');
203 $this->member_status = get_option('usces_customer_status');
204 $this->payment_structure = get_option('usces_payment_structure');
205 $this->display_mode = get_option('usces_display_mode');
206 define('USCES_MYSQL_VERSION', (int)substr(mysql_get_server_info(), 0, 1));
207 define('USCES_JP', ('ja' === get_locale() ? true : false));
208
209 }
210
211 function get_default_post_to_edit30( $post_type = 'post', $create_in_db = false ) {
212 global $wpdb;
213
214 $post_title = '';
215 if ( !empty( $_REQUEST['post_title'] ) )
216 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
217
218 $post_content = '';
219 if ( !empty( $_REQUEST['content'] ) )
220 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
221
222 $post_excerpt = '';
223 if ( !empty( $_REQUEST['excerpt'] ) )
224 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
225
226 if ( $create_in_db ) {
227 // Cleanup old auto-drafts more than 7 days old
228 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
229 foreach ( (array) $old_posts as $delete )
230 wp_delete_post( $delete, true ); // Force delete
231 $post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) );
232 } else {
233 $post->ID = 0;
234 $post->post_author = '';
235 $post->post_date = '';
236 $post->post_date_gmt = '';
237 $post->post_password = '';
238 $post->post_type = $post_type;
239 $post->post_status = 'draft';
240 $post->to_ping = '';
241 $post->pinged = '';
242 $post->comment_status = get_option( 'default_comment_status' );
243 $post->ping_status = get_option( 'default_ping_status' );
244 $post->post_pingback = get_option( 'default_pingback_flag' );
245 $post->post_category = get_option( 'default_category' );
246 $post->page_template = 'default';
247 $post->post_parent = 0;
248 $post->menu_order = 0;
249 }
250
251 $post->post_content = apply_filters( 'default_content', $post_content, $post );
252 $post->post_title = apply_filters( 'default_title', $post_title, $post );
253 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
254 $post->post_name = '';
255
256 return $post;
257 }
258
259 function get_default_post_to_edit() {
260 global $post;
261
262 $post_title = '';
263 if ( !empty( $_REQUEST['post_title'] ) )
264 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
265
266 $post_content = '';
267 if ( !empty( $_REQUEST['content'] ) )
268 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
269
270 $post_excerpt = '';
271 if ( !empty( $_REQUEST['excerpt'] ) )
272 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
273
274 $post->ID = 0;
275 $post->post_name = '';
276 $post->post_author = '';
277 $post->post_date = '';
278 $post->post_date_gmt = '';
279 $post->post_password = '';
280 $post->post_status = 'draft';
281 $post->post_type = 'post';
282 $post->to_ping = '';
283 $post->pinged = '';
284 $post->comment_status = get_option( 'default_comment_status' );
285 $post->ping_status = get_option( 'default_ping_status' );
286 $post->post_pingback = get_option( 'default_pingback_flag' );
287 $post->post_category = get_option( 'default_category' );
288 $post->post_content = apply_filters( 'default_content', $post_content);
289 $post->post_title = apply_filters( 'default_title', $post_title );
290 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
291 $post->page_template = 'default';
292 $post->post_parent = 0;
293 $post->menu_order = 0;
294
295 return $post;
296 }
297 function is_cart_or_member_page($link)
298 {
299 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart', ('page_id='.USCES_MEMBER_NUMBER), '/usces-member');
300 $flag = false;
301 foreach($search as $value){
302 $parts = array();
303 if( false !== strpos($link, $value) ){
304 if( $value == ('page_id='.USCES_CART_NUMBER) || $value == ('page_id='.USCES_MEMBER_NUMBER) ){
305 $parts = parse_url($link);
306 parse_str($parts['query'], $query);
307 if( $query['page_id'] == USCES_CART_NUMBER || $query['page_id'] == USCES_MEMBER_NUMBER ){
308 $flag = true;
309 }
310 }else{
311 $flag = true;
312 }
313 }
314 }
315 return $flag;
316 }
317
318 function is_cart_page($link)
319 {
320 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart' );
321 $flag = false;
322 foreach($search as $value){
323 if( false !== strpos($link, $value) ){
324 if( $value == ('page_id='.USCES_CART_NUMBER) ){
325 $parts = parse_url($link);
326 parse_str($parts['query'], $query);
327 if( $query['page_id'] == USCES_CART_NUMBER ){
328 $flag = true;
329 }
330 }else{
331 $flag = true;
332 }
333 }
334 }
335 return $flag;
336 }
337
338 function is_member_page($link)
339 {
340 $search = array(('page_id='.USCES_MEMBER_NUMBER), '/usces-member' );
341 $flag = false;
342 foreach($search as $value){
343 if( false !== strpos($link, $value) ){
344 if( $value == ('page_id='.USCES_MEMBER_NUMBER) ){
345 $parts = parse_url($link);
346 parse_str($parts['query'], $query);
347 if( $query['page_id'] == USCES_MEMBER_NUMBER ){
348 $flag = true;
349 }
350 }else{
351 $flag = true;
352 }
353 }
354 }
355 return $flag;
356 }
357
358 function is_inquiry_page($link)
359 {
360 if( empty($this->options['inquiry_id']) )
361 return false;
362
363 $search = array(('page_id='.$this->options['inquiry_id']), '/usces-inquiry' );
364 $flag = false;
365 foreach($search as $value){
366 if( false !== strpos($link, $value) ){
367 if( $value == ('page_id='.$this->options['inquiry_id']) ){
368 $parts = parse_url($link);
369 parse_str($parts['query'], $query);
370 if( $query['page_id'] == $this->options['inquiry_id'] ){
371 $flag = true;
372 }
373 }else{
374 $flag = true;
375 }
376 }
377 }
378 return $flag;
379 }
380
381 function usces_ssl_page_link($link)
382 {
383 $parts = parse_url($link);
384
385 if( isset($parts['query']) ){
386 parse_str($parts['query'], $query);
387 }
388
389 if( false !== strpos($link, '/usces-cart') || (isset( $query['page_id']) && $query['page_id'] == USCES_CART_NUMBER) ){
390 $link = USCES_CART_URL;
391
392 }elseif( false !== strpos($link, '/usces-member') || (isset( $query['page_id']) && $query['page_id'] == USCES_MEMBER_NUMBER) ){
393 $link = USCES_MEMBER_URL;
394
395 }elseif( !empty($this->options['inquiry_id']) && (false !== strpos($link, '/usces-inquiry') || (isset( $query['page_id']) && $query['page_id'] == $this->options['inquiry_id'])) ){
396 $link = USCES_INQUIRY_URL;
397
398 }else{
399 $link = str_replace('https://', 'http://', $link);
400 $link = apply_filters('usces_ssl_page_link', $link);
401 }
402
403 return $link;
404 }
405 function usces_ssl_contents_link($link)
406 {
407 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])){
408 $req = explode('/wp-content/',$link);
409 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
410 }else{
411 $link = apply_filters('usces_ssl_contents_link', $link);
412 }
413 return $link;
414 }
415
416 function ssl_admin_ajax_url(){
417 $path = '/wp-admin/admin-ajax.php';
418 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) ){
419 $link = USCES_SSL_URL_ADMIN . '/wp-admin/admin-ajax.php';
420 }else{
421 $link = site_url( $path );
422 }
423 $link = apply_filters('ssl_admin_ajax_url', $link);
424 return $link;
425 }
426
427 function usces_ssl_attachment_link($link)
428 {
429 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
430 $link = str_replace(get_option('siteurl'), USCES_SSL_URL_ADMIN, $link);
431 }else{
432 $link = apply_filters('usces_ssl_attachment_link', $link);
433 }
434 return $link;
435 }
436
437 function usces_ssl_icon_dir_uri($uri)
438 {
439 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
440 $uri = USCES_SSL_URL_ADMIN. '/' . WPINC . '/images/crystal';
441 }else{
442 $link = apply_filters('usces_ssl_icon_dir_uri', $uri);
443 }
444 return $uri;
445 }
446
447 function usces_ssl_script_link($link)
448 {
449 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
450 if(strpos($link, '/wp-content/') !== false){
451 $req = explode('/wp-content/',$link, 2);
452 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
453 }else if(strpos($link, '/wp-includes/') !== false){
454 $req = explode('/wp-includes/',$link, 2);
455 $link = USCES_SSL_URL_ADMIN . '/wp-includes/' . $req[1];
456 }else if(strpos($link, '/wp-admin/') !== false){
457 $req = explode('/wp-admin/',$link, 2);
458 $link = USCES_SSL_URL_ADMIN . '/wp-admin/' . $req[1];
459 }
460 }else{
461 $link = apply_filters('usces_ssl_script_link', $link);
462 }
463 return $link;
464 }
465
466 function set_action_status($status, $message)
467 {
468 $this->action_status = $status;
469 $this->action_message = $message;
470 }
471
472
473 /******************************************************************************/
474 function add_pages() {
475
476
477 add_object_page('Welcart Shop', 'Welcart Shop', 'level_6', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
478 add_submenu_page(USCES_PLUGIN_BASENAME, __('Home','usces'), __('Home','usces'), 'level_6', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
479 add_submenu_page(USCES_PLUGIN_BASENAME, __('Master Items','usces'), __('Master Items','usces'), 'level_6', 'usces_itemedit', array($this, 'item_master_page'));
480 add_submenu_page(USCES_PLUGIN_BASENAME, __('Add New Item','usces'), __('Add New Item','usces'), 'level_6', 'usces_itemnew', array($this, 'item_master_page'));
481 add_submenu_page(USCES_PLUGIN_BASENAME, __('General Setting','usces'), __('General Setting','usces'), 'level_6', 'usces_initial', array($this, 'admin_setup_page'));
482 add_submenu_page(USCES_PLUGIN_BASENAME, __('Business Days Setting','usces'), __('Business Days Setting','usces'), 'level_6', 'usces_schedule', array($this, 'admin_schedule_page'));
483 add_submenu_page(USCES_PLUGIN_BASENAME, __('Shipping Setting','usces'), __('Shipping Setting','usces'), 'level_6', 'usces_delivery', array($this, 'admin_delivery_page'));
484 add_submenu_page(USCES_PLUGIN_BASENAME, __('E-mail Setting','usces'), __('E-mail Setting','usces'), 'level_6', 'usces_mail', array($this, 'admin_mail_page'));
485 add_submenu_page(USCES_PLUGIN_BASENAME, __('Cart Page Setting','usces'), __('Cart Page Setting','usces'), 'level_6', 'usces_cart', array($this, 'admin_cart_page'));
486 add_submenu_page(USCES_PLUGIN_BASENAME, __('Member Page Setting','usces'), __('Member Page Setting','usces'), 'level_6', 'usces_member', array($this, 'admin_member_page'));
487 add_submenu_page(USCES_PLUGIN_BASENAME, __('System Setting','usces'), __('System Setting','usces'), 'administrator', 'usces_system', array($this, 'admin_system_page'));
488 add_submenu_page(USCES_PLUGIN_BASENAME, __('Settlement Setting','usces'), __('Settlement Setting','usces'), 'administrator', 'usces_settlement', array($this, 'admin_settlement_page'));
489 //add_submenu_page(USCES_PLUGIN_BASENAME, __('Backup','usces'), __('Backup','usces'), 'level_6', 'usces_backup', array($this, 'admin_backup_page'));
490 do_action('usces_action_shop_admin_menue');
491
492 add_object_page('Welcart Management', 'Welcart Management', 'level_6', 'usces_orderlist', array($this, 'order_list_page'));
493 add_submenu_page('usces_orderlist', __('Order List','usces'), __('Order List','usces'), 'level_6', 'usces_orderlist', array($this, 'order_list_page'));
494 add_submenu_page('usces_orderlist', __('New Order or Estimate','usces'), __('New Order or Estimate','usces'), 'level_6', 'usces_ordernew', array($this, 'order_list_page'));
495 add_submenu_page('usces_orderlist', __('List of Members','usces'), __('List of Members','usces'), 'level_6', 'usces_memberlist', array($this, 'member_list_page'));
496 //add_submenu_page('usces_orderlist', __('New Member','usces'), __('New Member','usces'), 'level_6', 'usces_membernew', array($this, 'member_list_page'));
497 do_action('usces_action_management_admin_menue');
498 }
499
500
501 /* Item Master Page */
502 function item_master_page() {
503 global $wpdb, $wp_locale;
504 global $wp_query;
505
506 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
507 $this->action_status = 'none';
508 $this->action_message = '';
509 }
510
511 if($_REQUEST['page'] == 'usces_itemnew'){
512 $action = 'new';
513 }else{
514 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
515 }
516 do_action( 'usces_action_item_master_page', $action );
517 switch ( $action ) {
518 case 'dlitemlist':
519 usces_download_item_list();
520 break;
521 case 'upload_register':
522 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_upload_register.php');
523 break;
524 case 'delete':
525 case 'new':
526 case 'editpost':
527 case 'edit':
528 global $current_user;
529 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_edit.php');
530 break;
531 default:
532 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_list.php');
533 break;
534 }
535 }
536
537 /* order list page */
538 function order_list_page() {
539 $order_edit_form = apply_filters( 'usces_admin_order_edit_form', USCES_PLUGIN_DIR . '/includes/order_edit_form.php' );
540 $order_list = apply_filters( 'usces_admin_order_list', USCES_PLUGIN_DIR . '/includes/order_list.php' );
541
542 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
543 $this->action_status = 'none';
544 $this->action_message = '';
545 }
546 if($_REQUEST['page'] == 'usces_ordernew'){
547 $order_action = 'new';
548 }else{
549 $order_action = isset($_REQUEST['order_action']) ? $_REQUEST['order_action'] : '';
550 }
551 do_action('usces_action_order_list_page', $order_action);
552 switch ($order_action) {
553 //20100908ysk start
554 case 'dlproductlist':
555 usces_download_product_list();
556 break;
557 case 'dlorderlist':
558 usces_download_order_list();
559 break;
560 //20100908ysk end
561 // case 'printpdf':
562 // require_once(USCES_PLUGIN_DIR . '/includes/order_print.php');
563 // break;
564 case 'editpost':
565 do_action('usces_pre_update_orderdata', $_REQUEST['order_id']);
566 $res = usces_update_orderdata();
567 if ( 1 === $res ) {
568 $this->set_action_status('success', __('order date is updated','usces').' <a href="'.stripslashes( $_POST['usces_referer'] ).'">'.__('back to the summary','usces').'</a>');
569 } elseif ( 0 === $res ) {
570 $this->set_action_status('none', '');
571 } else {
572 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
573 }
574 do_action('usces_after_update_orderdata', $_REQUEST['order_id'], $res);
575 require_once($order_edit_form);
576 break;
577 case 'newpost':
578 do_action('usces_pre_new_orderdata');
579 $res = usces_new_orderdata();
580 if ( 1 === $res ) {
581 $this->set_action_status('success', __('New date is add','usces'));
582 } elseif ( 0 === $res ) {
583 $this->set_action_status('none', '');
584 } else {
585 $this->set_action_status('error', 'ERROR : '.__('failure in addition','usces'));
586 }
587 do_action('usces_after_new_orderdata', $res);
588 $_REQUEST['order_action'] = 'edit';
589 $order_action = $_REQUEST['order_action'];
590 require_once($order_edit_form);
591 break;
592 case 'new':
593 case 'edit':
594 require_once($order_edit_form);
595 break;
596 case 'delete':
597 do_action('usces_pre_delete_orderdata', $_REQUEST['order_id']);
598 $res = usces_delete_orderdata();
599 if ( 1 === $res ) {
600 $this->set_action_status('success', __('the order date is deleted','usces'));
601 } elseif ( 0 === $res ) {
602 $this->set_action_status('none', '');
603 } else {
604 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
605 }
606 do_action('usces_after_delete_orderdata', $_REQUEST['order_id'], $res);
607 default:
608 require_once($order_list);
609 }
610 }
611
612 /* member list page */
613 function member_list_page() {
614
615 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
616 $this->action_status = 'none';
617 $this->action_message = '';
618 }
619 $member_action = isset($_REQUEST['member_action']) ? $_REQUEST['member_action'] : '';
620 switch ($member_action) {
621 //20100908ysk start
622 case 'dlmemberlist':
623 usces_download_member_list();
624 break;
625 //20100908ysk end
626 case 'editpost':
627 $this->error_message = $this->admin_member_check();
628 if( WCUtils::is_blank($this->error_message) ){
629 $res = usces_update_memberdata();
630 if ( 1 === $res ) {
631 $this->set_action_status('success', __('Membership information is updated','usces'));
632 } elseif ( 0 === $res ) {
633 $this->set_action_status('none', '');
634 } else {
635 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
636 }
637 }
638 require_once(USCES_PLUGIN_DIR . '/includes/member_edit_form.php');
639 break;
640 case 'new':
641 case 'edit':
642 require_once(USCES_PLUGIN_DIR . '/includes/member_edit_form.php');
643 break;
644 case 'delete':
645 $res = usces_delete_memberdata();
646 if ( 1 === $res ) {
647 $this->set_action_status('success', __('The member data is deleted','usces'));
648 } elseif ( 0 === $res ) {
649 $this->set_action_status('none', '');
650 } else {
651 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
652 }
653 default:
654 require_once(USCES_PLUGIN_DIR . '/includes/member_list.php');
655 }
656
657 }
658
659 /* admin backup page */
660 function admin_backup_page() {
661
662 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
663 $this->action_status = 'none';
664 $this->action_message = '';
665 }
666 require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
667
668 }
669
670 /* Shop Top Page */
671 function admin_top_page() {
672
673 require_once(USCES_PLUGIN_DIR . '/includes/admin_top.php');
674
675 }
676
677 /* Shop Setup Page */
678 function admin_setup_page() {
679 $this->options = get_option('usces');
680 //$this->options = array();
681
682
683 if(isset($_POST['usces_option_update'])) {
684
685 $_POST = $this->stripslashes_deep_post($_POST);
686 $this->options['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : '';
687 $this->options['campaign_category'] = empty($_POST['cat']) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat'];
688 $this->options['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : '';
689 $this->options['privilege_point'] = isset($_POST['point_num']) ? (int)$_POST['point_num'] : '';
690 $this->options['privilege_discount'] = isset($_POST['discount_num']) ? (int)$_POST['discount_num'] : '';
691 $this->options['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : '';
692 $this->options['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : '';
693 $this->options['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : '';
694 $this->options['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : '';
695 $this->options['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : '';
696 $this->options['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : '';
697 $this->options['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : '';
698 $this->options['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : '';
699 $this->options['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : '';
700 $this->options['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : '';
701 $this->options['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : '';
702 $this->options['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : '';
703 $this->options['point_rate'] = isset($_POST['point_rate']) ? (int)$_POST['point_rate'] : '';
704 $this->options['start_point'] = isset($_POST['start_point']) ? (int)$_POST['start_point'] : '';
705 $this->options['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : '';
706 $this->options['tax_rate'] = isset($_POST['tax_rate']) ? (int)$_POST['tax_rate'] : '';
707 $this->options['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : '';
708 $this->options['cod_type'] = isset($this->options['cod_type']) ? $this->options['cod_type'] : 'fix';
709 $this->options['transferee'] = isset($_POST['transferee']) ? trim($_POST['transferee']) : '';
710 $this->options['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : '';
711 $this->options['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : '';
712 $this->options['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : '';
713 $this->options['point_coverage'] = isset($_POST['point_coverage']) ? (int)$_POST['point_coverage'] : 0;
714 $this->options['point_assign'] = isset($_POST['point_assign']) ? (int)$_POST['point_assign'] : 1;//20120919ysk 0000573
715
716 $this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options );
717
718 update_option('usces', $this->options);
719
720 $this->action_status = 'success';
721 $this->action_message = __('options are updated','usces');
722
723 } else {
724 $this->action_status = 'none';
725 $this->action_message = '';
726 }
727
728 require_once(USCES_PLUGIN_DIR . '/includes/admin_setup.php');
729
730 }
731
732 /* Shop Schedule Page */
733 function admin_schedule_page() {
734
735 $this->options = get_option('usces');
736
737 if(isset($_POST['usces_option_update'])) {
738 $_POST = $this->stripslashes_deep_post($_POST);
739
740 $this->options['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0';
741 if(isset($_POST['business_days']))
742 $this->options['business_days'] = $_POST['business_days'];
743
744 update_option('usces', $this->options);
745
746 do_action( 'usces_action_admin_schedule_update' );
747
748 $this->action_status = 'success';
749 $this->action_message = __('options are updated','usces');
750 } else {
751 $this->action_status = 'none';
752 $this->action_message = '';
753 }
754
755 require_once(USCES_PLUGIN_DIR . '/includes/admin_schedule.php');
756
757 }
758
759 /* Shop Delivery Page */
760 function admin_delivery_page() {
761
762 $this->options = get_option('usces');
763
764 if(isset($_POST['usces_option_update'])) {
765 $_POST = $this->stripslashes_deep_post($_POST);
766
767 //20101208ysk start
768 if(isset($_POST['delivery_time_limit'])) $this->options['delivery_time_limit'] = $_POST['delivery_time_limit'];
769 if(isset($_POST['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time'];
770 if(isset($_POST['delivery_after_days'])) $this->options['delivery_after_days'] = $_POST['delivery_after_days'];
771 //20101208ysk end
772
773 update_option('usces', $this->options);
774
775 $this->action_status = 'success';
776 $this->action_message = __('options are updated','usces');
777 } else {
778 $this->action_status = 'none';
779 $this->action_message = '';
780 }
781
782 require_once(USCES_PLUGIN_DIR . '/includes/admin_delivery.php');
783
784 }
785
786 /* Shop Mail Page */
787 function admin_mail_page() {
788 global $allowedposttags;
789
790 $this->options = get_option('usces');
791
792 if(isset($_POST['usces_option_update'])) {
793 $_POST = $this->stripslashes_deep_post($_POST);
794
795 $this->options['smtp_hostname'] = trim($_POST['smtp_hostname']);
796 $this->options['newmem_admin_mail'] = (int)$_POST['newmem_admin_mail'];
797 $this->options['delmem_admin_mail'] = (int)$_POST['delmem_admin_mail'];
798 $this->options['delmem_customer_mail'] = (int)$_POST['delmem_customer_mail'];
799
800 foreach ( $_POST['title'] as $key => $value ) {
801 if( WCUtils::is_blank($value) ) {
802 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
803 }else{
804 $this->options['mail_data']['title'][$key] = trim($value);
805 }
806 }
807 foreach ( $_POST['header'] as $key => $value ) {
808 if( WCUtils::is_blank($value) ) {
809 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
810 }else{
811 $this->options['mail_data']['header'][$key] = $value;
812 }
813 }
814 foreach ( $_POST['footer'] as $key => $value ) {
815 if( WCUtils::is_blank($value) ) {
816 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
817 }else{
818 $this->options['mail_data']['footer'][$key] = $value;
819 }
820 }
821
822
823 $this->action_status = 'success';
824 $this->action_message = __('options are updated','usces');
825
826 } else {
827
828 foreach ( (array)$this->options['mail_data']['title'] as $key => $value ) {
829 if( WCUtils::is_blank($value) ) {
830 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
831 }
832 }
833 foreach ( (array)$this->options['mail_data']['header'] as $key => $value ) {
834 if( WCUtils::is_blank($value) ) {
835 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
836 }
837 }
838 foreach ( (array)$this->options['mail_data']['footer'] as $key => $value ) {
839 if( WCUtils::is_blank($value) ) {
840 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
841 }
842 }
843
844 $this->action_status = 'none';
845 $this->action_message = '';
846
847 }
848
849 update_option('usces', $this->options);
850 do_action( 'usces_action_admin_mail_page' );
851
852 require_once(USCES_PLUGIN_DIR . '/includes/admin_mail.php');
853
854 }
855
856 /* Admin Cart Page */
857 function admin_cart_page() {
858 global $allowedposttags;
859 $this->options = get_option('usces');
860
861 if(isset($_POST['usces_option_update'])) {
862 $_POST = $this->stripslashes_deep_post($_POST);
863
864 foreach ( $this->options['indi_item_name'] as $key => $value ) {
865 $this->options['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0;
866 }
867 foreach ( $_POST['position'] as $key => $value ) {
868 $this->options['pos_item_name'][$key] = $value;
869 }
870 foreach ( $_POST['header'] as $key => $value ) {
871 $this->options['cart_page_data']['header'][$key] = addslashes(wp_kses($value, $allowedposttags));
872 }
873 foreach ( $_POST['footer'] as $key => $value ) {
874 $this->options['cart_page_data']['footer'][$key] = addslashes(wp_kses($value, $allowedposttags));
875 }
876
877 update_option('usces', $this->options);
878
879 $this->action_status = 'success';
880 $this->action_message = __('options are updated','usces');
881 } else {
882
883 $this->action_status = 'none';
884 $this->action_message = '';
885 }
886
887
888
889 require_once(USCES_PLUGIN_DIR . '/includes/admin_cart.php');
890
891 }
892
893 /* Admin Member Page */
894 function admin_member_page() {
895
896 $this->options = get_option('usces');
897
898 if(isset($_POST['usces_option_update'])) {
899 $_POST = $this->stripslashes_deep_post($_POST);
900
901 foreach ( $_POST['header'] as $key => $value ) {
902 $this->options['member_page_data']['header'][$key] = $value;
903 }
904 foreach ( $_POST['footer'] as $key => $value ) {
905 $this->options['member_page_data']['footer'][$key] = $value;
906 }
907
908 update_option('usces', $this->options);
909
910 $this->action_status = 'success';
911 $this->action_message = __('options are updated','usces');
912 } else {
913
914 $this->action_status = 'none';
915 $this->action_message = '';
916 }
917
918
919
920 require_once(USCES_PLUGIN_DIR . '/includes/admin_member.php');
921
922 }
923
924
925 /* Admin System Page */
926 function admin_system_page() {
927 //20110331ysk start
928 global $usces_states;
929 //20110331ysk end
930 $action_status = '';//20120511ysk 0000470
931
932 $this->options = get_option('usces');
933
934 if(isset($_POST['usces_option_update'])) {
935 $_POST = $this->stripslashes_deep_post($_POST);
936
937 $this->options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0;
938 $this->options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : '';
939 $this->options['fukugo_category_orderby'] = isset($_POST['fukugo_category_orderby']) ? $_POST['fukugo_category_orderby'] : '';
940 $this->options['fukugo_category_order'] = isset($_POST['fukugo_category_order']) ? $_POST['fukugo_category_order'] : '';
941 $this->options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : '';
942 if( WCUtils::is_blank($this->options['settlement_path']) ) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
943 $sl = substr($this->options['settlement_path'], -1);
944 if($sl != '/' && $sl != '\\') $this->options['settlement_path'] .= '/';
945 $this->options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : '';
946 if( !WCUtils::is_blank($this->options['logs_path']) ){
947 $sl = substr($this->options['logs_path'], -1);
948 if($sl == '/' || $sl == '\\') $this->options['logs_path'] = substr($this->options['logs_path'], 0, -1);
949 }
950 $this->options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0;
951 $this->options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : '';
952 $this->options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : '';
953 if( WCUtils::is_blank($this->options['ssl_url']) || WCUtils::is_blank($this->options['ssl_url_admin']) ) $this->options['use_ssl'] = 0;
954 $this->options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : '';
955 $this->options['use_javascript'] = isset($_POST['use_javascript']) ? (int)$_POST['use_javascript'] : 1;
956 $this->options['system']['front_lang'] = (isset($_POST['front_lang']) && 'others' != $_POST['front_lang']) ? $_POST['front_lang'] : usces_get_local_language();
957 $this->options['system']['currency'] = (isset($_POST['currency']) && 'others' != $_POST['currency']) ? $_POST['currency'] : usces_get_base_country();
958 $this->options['system']['addressform'] = (isset($_POST['addressform']) ) ? $_POST['addressform'] : usces_get_local_addressform();
959 $this->options['system']['target_market'] = (isset($_POST['target_market']) ) ? $_POST['target_market'] : usces_get_local_target_market();
960 $this->options['system']['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0;
961 $this->options['system']['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int)$_POST['dec_orderID_flag'] : 0;
962 $this->options['system']['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : '';
963 if( isset($_POST['dec_orderID_digit']) ){
964 $dec_orderID_digit = (int)rtrim($_POST['dec_orderID_digit']);
965 if( 6 > $dec_orderID_digit ){
966 $this->options['system']['dec_orderID_digit'] = 6;
967 }else{
968 $this->options['system']['dec_orderID_digit'] = $dec_orderID_digit;
969 }
970 }else{
971 $this->options['system']['dec_orderID_digit'] = 6;
972 }
973 $this->options['system']['subimage_rule'] = isset($_POST['subimage_rule']) ? (int)$_POST['subimage_rule'] : 0;
974 //20110331ysk start
975 unset($this->options['province']);
976 //$action_status = '';//20120511ysk 0000470
977 foreach((array)$this->options['system']['target_market'] as $target_market) {
978 $province = array();
979 if(!empty($_POST['province_'.$target_market])) {
980 $temp_pref = explode("\n", $_POST['province_'.$target_market]);
981 //20120123ysk start 0000386
982 //$province[] = __('-- Select --', 'usces');
983 $province[] = '-- Select --';
984 //20120123ysk end
985 //20120725ysk start 0000537
986 //for($i = 0; $i < count($temp_pref); $i++) {
987 //$province[] = trim($temp_pref[$i]);
988 foreach( $temp_pref as $pref ) {
989 if( !WCUtils::is_blank($pref) )
990 $province[] = trim($pref);
991 }
992 if( 1 == count($province) )
993 $action_status = 'error';
994 //20120725ysk end
995 } else {
996 if(isset($usces_states[$target_market]) && is_array($usces_states[$target_market])) {
997 $province = $usces_states[$target_market];
998 } else {
999 $action_status = 'error';
1000 }
1001 }
1002 $this->options['province'][$target_market] = $province;
1003 }
1004
1005 if($action_status != '') {
1006 $this->action_status = 'error';
1007 $this->action_message = __('Data have deficiency.','usces');
1008 } else {
1009 $this->action_status = 'success';
1010 $this->action_message = __('options are updated','usces');
1011 }
1012 //20110331ysk end
1013 } else {
1014
1015 if( !isset($this->options['province']) || empty($this->options['province']) ){
1016 //20110331ysk start
1017 //$this->options['province'] = get_option('usces_pref');
1018 $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
1019 //20110331ysk end
1020 }
1021 $this->action_status = 'none';
1022 $this->action_message = '';
1023 }
1024
1025 if($action_status != 'error') //20120511ysk 0000470
1026 update_option('usces', $this->options);
1027
1028 require_once(USCES_PLUGIN_DIR . '/includes/admin_system.php');
1029
1030 }
1031
1032 /* Settlement Setting Page */
1033 function admin_settlement_page() {
1034
1035 $this->action_status = 'none';
1036 $this->action_message = '';
1037
1038 $options = get_option('usces');
1039
1040
1041 if( isset($_POST['usces_option_update']) ) {
1042 $_POST = $this->stripslashes_deep_post($_POST);
1043 $mes = '';
1044
1045 switch( $_POST['acting'] ){
1046 case 'zeus':
1047 unset( $options['acting_settings']['zeus'] );
1048 $options['acting_settings']['zeus']['card_url'] = isset($_POST['card_url']) ? $_POST['card_url'] : '';
1049 $options['acting_settings']['zeus']['card_secureurl'] = isset($_POST['card_secureurl']) ? $_POST['card_secureurl'] : '';
1050 $options['acting_settings']['zeus']['ipaddrs'] = isset($_POST['ipaddrs']) ? $_POST['ipaddrs'] : '';
1051 $options['acting_settings']['zeus']['pay_cvs'] = isset($_POST['pay_cvs']) ? $_POST['pay_cvs'] : '';
1052 $options['acting_settings']['zeus']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1053 $options['acting_settings']['zeus']['connection'] = isset($_POST['connection']) ? $_POST['connection'] : 1;
1054 $options['acting_settings']['zeus']['3dsecur'] = isset($_POST['3dsecur']) ? $_POST['3dsecur'] : 2;
1055 $options['acting_settings']['zeus']['security'] = isset($_POST['security']) ? $_POST['security'] : 2;
1056 if( isset($_POST['authkey']) ){
1057 $options['acting_settings']['zeus']['authkey'] = $_POST['authkey'];
1058 }
1059 // if( 1 == $options['acting_settings']['zeus']['security'] ){
1060 // $options['acting_settings']['zeus']['quickcharge'] = '2';
1061 // }else{
1062 $options['acting_settings']['zeus']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : '';
1063 // }
1064 $options['acting_settings']['zeus']['batch'] = isset($_POST['batch']) ? $_POST['batch'] : '';
1065 $options['acting_settings']['zeus']['clientip'] = isset($_POST['clientip']) ? trim($_POST['clientip']) : '';
1066 $options['acting_settings']['zeus']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1067 $options['acting_settings']['zeus']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1068 $options['acting_settings']['zeus']['clientip_bank'] = isset($_POST['clientip_bank']) ? trim($_POST['clientip_bank']) : '';
1069 $options['acting_settings']['zeus']['testid_bank'] = isset($_POST['testid_bank']) ? trim($_POST['testid_bank']) : '';
1070 $options['acting_settings']['zeus']['bank_url'] = isset($_POST['bank_url']) ? $_POST['bank_url'] : '';
1071 $options['acting_settings']['zeus']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1072 $options['acting_settings']['zeus']['clientip_conv'] = isset($_POST['clientip_conv']) ? trim($_POST['clientip_conv']) : '';
1073 $options['acting_settings']['zeus']['testid_conv'] = isset($_POST['testid_conv']) ? trim($_POST['testid_conv']) : '';
1074 $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'];
1075 $options['acting_settings']['zeus']['conv_url'] = isset($_POST['conv_url']) ? $_POST['conv_url'] : '';
1076
1077 if( WCUtils::is_blank($_POST['clientip']) && isset($_POST['card_activate']) && 'on' == $_POST['card_activate'])
1078 $mes .= '※カード決済IPコードを�
1079 �力して下さい<br />';
1080 if( isset($_POST['authkey']) && WCUtils::is_blank($_POST['authkey']) && isset($_POST['security']) && 3 == $_POST['security'])
1081 $mes .= '※認証キーを�
1082 �力して下さい<br />';
1083 if( WCUtils::is_blank($_POST['clientip_bank']) && isset($_POST['bank_activate']) && 'on' == $_POST['bank_activate'] )
1084 $mes .= '※�
1085 �金お任せIPコードを�
1086 �力して下さい<br />';
1087 if( WCUtils::is_blank($_POST['clientip_conv']) && isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] )
1088 $mes .= '※コンビニ決済IPコードを�
1089 �力して下さい<br />';
1090 if( isset($_POST['batch']) && 'on' == $_POST['batch'] ) {
1091 if( isset($_POST['quickcharge']) && 'on' == $_POST['quickcharge'] ) {
1092 } else {
1093 $mes .= '※バッチ処理を利用する場合は、クイックチャージを利用するにして下さい<br />';
1094 }
1095 }
1096 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']) )
1097 $mes .= '※設定が不正です!<br />';
1098
1099 if( WCUtils::is_blank($mes) ){
1100 $this->action_status = 'success';
1101 $this->action_message = __('options are updated','usces');
1102 $options['acting_settings']['zeus']['activate'] = 'on';
1103 if( 'on' == $options['acting_settings']['zeus']['card_activate'] ){
1104 $this->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
1105 }else{
1106 unset($this->payment_structure['acting_zeus_card']);
1107 }
1108 if( 'on' == $options['acting_settings']['zeus']['bank_activate'] ){
1109 $this->payment_structure['acting_zeus_bank'] = '�
1110 �金お任せ(ZEUS)';
1111 }else{
1112 unset($this->payment_structure['acting_zeus_bank']);
1113 }
1114 if( 'on' == $options['acting_settings']['zeus']['conv_activate'] ){
1115 $this->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
1116 }else{
1117 unset($this->payment_structure['acting_zeus_conv']);
1118 }
1119 }else{
1120 $this->action_status = 'error';
1121 $this->action_message = __('データに不備が有ります','usces');
1122 $options['acting_settings']['zeus']['activate'] = 'off';
1123 unset($this->payment_structure['acting_zeus_card'], $this->payment_structure['acting_zeus_bank'], $this->payment_structure['acting_zeus_conv']);
1124 }
1125 ksort($this->payment_structure);
1126 update_option('usces_payment_structure',$this->payment_structure);
1127 $options['acting_settings']['zeus']['vercheck'] = '115';
1128 if( update_option('usces', $options) ){
1129 usces_clear_quickcharge();
1130 }
1131 break;
1132
1133 case 'remise':
1134 unset( $options['acting_settings']['remise'] );
1135 $options['acting_settings']['remise']['plan'] = isset($_POST['plan']) ? $_POST['plan'] : '';
1136 $options['acting_settings']['remise']['SHOPCO'] = isset($_POST['SHOPCO']) ? $_POST['SHOPCO'] : '';
1137 $options['acting_settings']['remise']['HOSTID'] = isset($_POST['HOSTID']) ? $_POST['HOSTID'] : '';
1138 $options['acting_settings']['remise']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1139 $options['acting_settings']['remise']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1140 $options['acting_settings']['remise']['card_pc_ope'] = isset($_POST['card_pc_ope']) ? $_POST['card_pc_ope'] : '';
1141 $options['acting_settings']['remise']['payquick'] = isset($_POST['payquick']) ? $_POST['payquick'] : '';
1142 $options['acting_settings']['remise']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1143 $options['acting_settings']['remise']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1144 $options['acting_settings']['remise']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1145 $options['acting_settings']['remise']['conv_pc_ope'] = isset($_POST['conv_pc_ope']) ? $_POST['conv_pc_ope'] : '';
1146 $options['acting_settings']['remise']['S_PAYDATE'] = isset($_POST['S_PAYDATE']) ? $_POST['S_PAYDATE'] : '';
1147 $options['acting_settings']['remise']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1148 $options['acting_settings']['remise']['send_url_pc'] = isset($_POST['send_url_pc']) ? $_POST['send_url_pc'] : '';
1149 $options['acting_settings']['remise']['send_url_cvs_mbl'] = isset($_POST['send_url_cvs_mbl']) ? $_POST['send_url_cvs_mbl'] : '';
1150 $options['acting_settings']['remise']['send_url_cvs_pc'] = isset($_POST['send_url_cvs_pc']) ? $_POST['send_url_cvs_pc'] : '';
1151 $options['acting_settings']['remise']['send_url_mbl_test'] = isset($_POST['send_url_mbl_test']) ? $_POST['send_url_mbl_test'] : '';
1152 $options['acting_settings']['remise']['send_url_pc_test'] = isset($_POST['send_url_pc_test']) ? $_POST['send_url_pc_test'] : '';
1153 $options['acting_settings']['remise']['send_url_cvs_mbl_test'] = isset($_POST['send_url_cvs_mbl_test']) ? $_POST['send_url_cvs_mbl_test'] : '';
1154 $options['acting_settings']['remise']['send_url_cvs_pc_test'] = isset($_POST['send_url_cvs_pc_test']) ? $_POST['send_url_cvs_pc_test'] : '';
1155 $options['acting_settings']['remise']['REMARKS3'] = isset($_POST['REMARKS3']) ? $_POST['REMARKS3'] : '';
1156
1157 if( isset($_POST['plan_remise']) && WCUtils::is_zero($_POST['plan_remise']) )
1158 $mes .= '※サービスプランを選択してください<br />';
1159 if( WCUtils::is_blank($_POST['SHOPCO']) )
1160 $mes .= '※加盟店コードを�
1161 �力して下さい<br />';
1162 if( WCUtils::is_blank($_POST['HOSTID']) )
1163 $mes .= '※ホスト番号を�
1164 �力して下さい<br />';
1165 if( isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] && empty($_POST['S_PAYDATE']) )
1166 $mes .= '※支払期限を�
1167 �力して下さい<br />';
1168 if( isset($_POST['card_pc_ope']) && 'public' == $_POST['card_pc_ope'] && empty($_POST['send_url_pc']) )
1169 $mes .= '※クレジットカード決済の本番URLを�
1170 �力して下さい<br />';
1171 if( isset($_POST['conv_pc_ope']) && 'public' == $_POST['conv_pc_ope'] && empty($_POST['send_url_cvs_pc']) )
1172 $mes .= '※コンビニ・電子マネー決済の本番URLを�
1173 �力して下さい<br />';
1174 if( !isset($_POST['REMARKS3']) || empty($_POST['REMARKS3']) )
1175 $mes .= '※設定が不正です!<br />';
1176
1177 if( WCUtils::is_blank($mes) ){
1178 //$this->zaction_status = 'success';
1179 $this->action_status = 'success';
1180 $this->action_message = __('options are updated','usces');
1181 $options['acting_settings']['remise']['activate'] = 'on';
1182 if( 'on' == $options['acting_settings']['remise']['card_activate'] ){
1183 $this->payment_structure['acting_remise_card'] = 'カード決済(ルミーズ)';
1184 }else{
1185 unset($this->payment_structure['acting_remise_card']);
1186 }
1187 if( 'on' == $options['acting_settings']['remise']['conv_activate'] ){
1188 $this->payment_structure['acting_remise_conv'] = 'コンビニ決済(ルミーズ)';
1189 }else{
1190 unset($this->payment_structure['acting_remise_conv']);
1191 }
1192
1193 }else{
1194 $this->action_status = 'error';
1195 $this->action_message = __('データに不備が有ります','usces');
1196 $options['acting_settings']['remise']['activate'] = 'off';
1197 unset($this->payment_structure['acting_remise_card']);
1198 unset($this->payment_structure['acting_remise_conv']);
1199 }
1200 ksort($this->payment_structure);
1201 update_option('usces_payment_structure',$this->payment_structure);
1202 update_option('usces', $options);
1203 break;
1204 //20101018ysk start
1205 case 'jpayment':
1206 unset( $options['acting_settings']['jpayment'] );
1207 $options['acting_settings']['jpayment']['aid'] = isset($_POST['aid']) ? $_POST['aid'] : '';
1208 $options['acting_settings']['jpayment']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1209 $options['acting_settings']['jpayment']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1210 $options['acting_settings']['jpayment']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1211 //$options['acting_settings']['jpayment']['webm_activate'] = isset($_POST['webm_activate']) ? $_POST['webm_activate'] : '';
1212 //$options['acting_settings']['jpayment']['bitc_activate'] = isset($_POST['bitc_activate']) ? $_POST['bitc_activate'] : '';
1213 //$options['acting_settings']['jpayment']['suica_activate'] = isset($_POST['suica_activate']) ? $_POST['suica_activate'] : '';
1214 $options['acting_settings']['jpayment']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1215 $options['acting_settings']['jpayment']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1216
1217 if( WCUtils::is_blank($_POST['aid']) )
1218 $mes .= '※店舗IDコードを�
1219 �力して下さい<br />';
1220 if( isset($_POST['card_activate']) && 'on' == $_POST['card_activate'] && empty($_POST['card_jb']) )
1221 $mes .= '※ジョブタイプを指定して下さい<br />';
1222
1223 if( WCUtils::is_blank($mes) ){
1224 $this->action_status = 'success';
1225 $this->action_message = __('options are updated','usces');
1226 $options['acting_settings']['jpayment']['activate'] = 'on';
1227 if( 'on' == $options['acting_settings']['jpayment']['card_activate'] ){
1228 $this->payment_structure['acting_jpayment_card'] = 'カード決済(J-Payment)';
1229 }else{
1230 unset($this->payment_structure['acting_jpayment_card']);
1231 }
1232 if( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ){
1233 $this->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(J-Payment)';
1234 }else{
1235 unset($this->payment_structure['acting_jpayment_conv']);
1236 }
1237 //if( 'on' == $options['acting_settings']['jpayment']['webm_activate'] ){
1238 // $this->payment_structure['acting_jpayment_webm'] = 'WebMoney決済(J-Payment)';
1239 //}else{
1240 // unset($this->payment_structure['acting_jpayment_webm']);
1241 //}
1242 //if( 'on' == $options['acting_settings']['jpayment']['bitc_activate'] ){
1243 // $this->payment_structure['acting_jpayment_bitc'] = 'BitCash決済(J-Payment)';
1244 //}else{
1245 // unset($this->payment_structure['acting_jpayment_bitc']);
1246 //}
1247 //if( 'on' == $options['acting_settings']['jpayment']['suica_activate'] ){
1248 // $this->payment_structure['acting_jpayment_suica'] = 'モバイルSuica決済(J-Payment)';
1249 //}else{
1250 // unset($this->payment_structure['acting_jpayment_suica']);
1251 //}
1252 if( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ){
1253 $this->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(J-Payment)';
1254 }else{
1255 unset($this->payment_structure['acting_jpayment_bank']);
1256 }
1257
1258 }else{
1259 $this->action_status = 'error';
1260 $this->action_message = __('データに不備が有ります', 'usces');
1261 $options['acting_settings']['jpayment']['activate'] = 'off';
1262 unset($this->payment_structure['acting_jpayment_card']);
1263 unset($this->payment_structure['acting_jpayment_conv']);
1264 //unset($this->payment_structure['acting_jpayment_webm']);
1265 //unset($this->payment_structure['acting_jpayment_bitc']);
1266 //unset($this->payment_structure['acting_jpayment_suica']);
1267 unset($this->payment_structure['acting_jpayment_bank']);
1268 }
1269 ksort($this->payment_structure);
1270 update_option('usces_payment_structure', $this->payment_structure);
1271 update_option('usces', $options);
1272 break;
1273 //20101018ysk end
1274 //20110208ysk start
1275 case 'paypal':
1276 unset( $options['acting_settings']['paypal'] );
1277 $options['acting_settings']['paypal']['ec_activate'] = isset($_POST['ec_activate']) ? $_POST['ec_activate'] : '';
1278 $options['acting_settings']['paypal']['sandbox'] = isset($_POST['sandbox']) ? $_POST['sandbox'] : '';
1279 $options['acting_settings']['paypal']['user'] = isset($_POST['user']) ? $_POST['user'] : '';
1280 $options['acting_settings']['paypal']['pwd'] = isset($_POST['pwd']) ? $_POST['pwd'] : '';
1281 $options['acting_settings']['paypal']['signature'] = isset($_POST['signature']) ? $_POST['signature'] : '';
1282 //20110412ysk start
1283 $options['acting_settings']['paypal']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1284 //20110412ysk end
1285
1286 if( !isset($_POST['sandbox']) || empty($_POST['sandbox']) )
1287 $mes .= '※PayPalサーバーが不正です<br />';
1288 if( WCUtils::is_blank($_POST['user']) )
1289 $mes .= '※APIユーザー名を�
1290 �力して下さい<br />';
1291 if( WCUtils::is_blank($_POST['pwd']) )
1292 $mes .= '※APIパスワードを�
1293 �力して下さい<br />';
1294 if( WCUtils::is_blank($_POST['signature']) )
1295 $mes .= '※署名を�
1296 �力して下さい<br />';
1297
1298 if( WCUtils::is_blank($mes) ){
1299 $this->action_status = 'success';
1300 $this->action_message = __('options are updated','usces');
1301 if($options['acting_settings']['paypal']['sandbox'] == 1) {
1302 $options['acting_settings']['paypal']['api_host'] = 'api-3t.sandbox.paypal.com';
1303 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.sandbox.paypal.com/nvp';
1304 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
1305 } else {
1306 $options['acting_settings']['paypal']['api_host'] = 'api-3t.paypal.com';
1307 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.paypal.com/nvp';
1308 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.paypal.com/cgi-bin/webscr';
1309 }
1310 $options['acting_settings']['paypal']['activate'] = 'on';
1311 if( 'on' == $options['acting_settings']['paypal']['ec_activate'] ){
1312 $this->payment_structure['acting_paypal_ec'] = 'PayPal決済';
1313 }else{
1314 unset($this->payment_structure['acting_paypal_ec']);
1315 }
1316
1317 }else{
1318 $this->action_status = 'error';
1319 $this->action_message = __('データに不備が有ります', 'usces');
1320 $options['acting_settings']['paypal']['activate'] = 'off';
1321 unset($this->payment_structure['acting_paypal_ec']);
1322 }
1323 ksort($this->payment_structure);
1324 update_option('usces_payment_structure', $this->payment_structure);
1325 update_option('usces', $options);
1326 break;
1327 //20110208ysk end
1328 //20120413ysk start
1329 case 'sbps':
1330 unset( $options['acting_settings']['sbps'] );
1331 $options['acting_settings']['sbps']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : '';
1332 $options['acting_settings']['sbps']['service_id'] = isset($_POST['service_id']) ? $_POST['service_id'] : '';
1333 $options['acting_settings']['sbps']['hash_key'] = isset($_POST['hash_key']) ? $_POST['hash_key'] : '';
1334 $options['acting_settings']['sbps']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1335 $options['acting_settings']['sbps']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1336 $options['acting_settings']['sbps']['send_url_check'] = isset($_POST['send_url_check']) ? $_POST['send_url_check'] : '';
1337 $options['acting_settings']['sbps']['send_url_test'] = isset($_POST['send_url_test']) ? $_POST['send_url_test'] : '';
1338 $options['acting_settings']['sbps']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1339 $options['acting_settings']['sbps']['3d_secure'] = isset($_POST['3d_secure']) ? $_POST['3d_secure'] : '';
1340 $options['acting_settings']['sbps']['cust'] = isset($_POST['cust']) ? $_POST['cust'] : '';
1341 $options['acting_settings']['sbps']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1342 $options['acting_settings']['sbps']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1343 $options['acting_settings']['sbps']['payeasy_activate'] = isset($_POST['payeasy_activate']) ? $_POST['payeasy_activate'] : '';
1344 $options['acting_settings']['sbps']['wallet_yahoowallet'] = isset($_POST['wallet_yahoowallet']) ? $_POST['wallet_yahoowallet'] : '';
1345 $options['acting_settings']['sbps']['wallet_rakuten'] = isset($_POST['wallet_rakuten']) ? $_POST['wallet_rakuten'] : '';
1346 $options['acting_settings']['sbps']['wallet_paypal'] = isset($_POST['wallet_paypal']) ? $_POST['wallet_paypal'] : '';
1347 $options['acting_settings']['sbps']['wallet_netmile'] = isset($_POST['wallet_netmile']) ? $_POST['wallet_netmile'] : '';
1348 $options['acting_settings']['sbps']['wallet_alipay'] = isset($_POST['wallet_alipay']) ? $_POST['wallet_alipay'] : '';
1349 $options['acting_settings']['sbps']['mobile_docomo'] = isset($_POST['mobile_docomo']) ? $_POST['mobile_docomo'] : '';
1350 $options['acting_settings']['sbps']['mobile_softbank'] = isset($_POST['mobile_softbank']) ? $_POST['mobile_softbank'] : '';
1351 $options['acting_settings']['sbps']['mobile_auone'] = isset($_POST['mobile_auone']) ? $_POST['mobile_auone'] : '';
1352 $options['acting_settings']['sbps']['mobile_mysoftbank'] = isset($_POST['mobile_mysoftbank']) ? $_POST['mobile_mysoftbank'] : '';
1353
1354 if( WCUtils::is_blank($_POST['merchant_id']) )
1355 $mes .= '※マーチャントIDを�
1356 �力して下さい<br />';
1357 if( WCUtils::is_blank($_POST['service_id']) )
1358 $mes .= '※サービスIDを�
1359 �力して下さい<br />';
1360 if( WCUtils::is_blank($_POST['hash_key']) )
1361 $mes .= '※Hash KEYを�
1362 �力して下さい<br />';
1363 if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1364 $mes .= '※本番URLを�
1365 �力して下さい<br />';
1366
1367 if( WCUtils::is_blank($mes) ){
1368 $this->action_status = 'success';
1369 $this->action_message = __('options are updated','usces');
1370 $options['acting_settings']['sbps']['activate'] = 'on';
1371 if( 'on' == $options['acting_settings']['sbps']['card_activate'] ){
1372 $this->payment_structure['acting_sbps_card'] = 'カード決済(ソフトバンク・ペイメント)';
1373 }else{
1374 unset($this->payment_structure['acting_sbps_card']);
1375 }
1376 if( 'on' == $options['acting_settings']['sbps']['conv_activate'] ){
1377 $this->payment_structure['acting_sbps_conv'] = 'コンビニ決済(ソフトバンク・ペイメント)';
1378 }else{
1379 unset($this->payment_structure['acting_sbps_conv']);
1380 }
1381 if( 'on' == $options['acting_settings']['sbps']['payeasy_activate'] ){
1382 $this->payment_structure['acting_sbps_payeasy'] = 'ペイジー決済(ソフトバンク・ペイメント)';
1383 }else{
1384 unset($this->payment_structure['acting_sbps_payeasy']);
1385 }
1386 if( ( 'on' == $options['acting_settings']['sbps']['wallet_yahoowallet'] ) ||
1387 ( 'on' == $options['acting_settings']['sbps']['wallet_rakuten'] ) ||
1388 ( 'on' == $options['acting_settings']['sbps']['wallet_paypal'] ) ||
1389 ( 'on' == $options['acting_settings']['sbps']['wallet_netmile'] ) ||
1390 ( 'on' == $options['acting_settings']['sbps']['wallet_alipay'] ) ) {
1391 $options['acting_settings']['sbps']['wallet_activate'] = 'on';
1392 } else {
1393 $options['acting_settings']['sbps']['wallet_activate'] = 'off';
1394 }
1395 if( 'on' == $options['acting_settings']['sbps']['wallet_activate'] ){
1396 $this->payment_structure['acting_sbps_wallet'] = 'ウォレット決済(ソフトバンク・ペイメント)';
1397 }else{
1398 unset($this->payment_structure['acting_sbps_wallet']);
1399 }
1400 if( ( 'on' == $options['acting_settings']['sbps']['mobile_docomo'] ) ||
1401 ( 'on' == $options['acting_settings']['sbps']['mobile_softbank'] ) ||
1402 ( 'on' == $options['acting_settings']['sbps']['mobile_auone'] ) ||
1403 ( 'on' == $options['acting_settings']['sbps']['mobile_mysoftbank'] ) ) {
1404 $options['acting_settings']['sbps']['mobile_activate'] = 'on';
1405 } else {
1406 $options['acting_settings']['sbps']['mobile_activate'] = 'off';
1407 }
1408 if( 'on' == $options['acting_settings']['sbps']['mobile_activate'] ){
1409 $this->payment_structure['acting_sbps_mobile'] = '携帯キャリア決済(ソフトバンク・ペイメント)';
1410 }else{
1411 unset($this->payment_structure['acting_sbps_mobile']);
1412 }
1413
1414 }else{
1415 $this->action_status = 'error';
1416 $this->action_message = __('データに不備が有ります','usces');
1417 $options['acting_settings']['sbps']['activate'] = 'off';
1418 unset($this->payment_structure['acting_sbps_card']);
1419 unset($this->payment_structure['acting_sbps_conv']);
1420 unset($this->payment_structure['acting_sbps_payeasy']);
1421 unset($this->payment_structure['acting_sbps_wallet']);
1422 unset($this->payment_structure['acting_sbps_mobile']);
1423 }
1424 ksort($this->payment_structure);
1425 update_option('usces_payment_structure', $this->payment_structure);
1426 update_option('usces', $options);
1427 break;
1428 //20120413ysk end
1429 //20120618ysk start
1430 case 'telecom':
1431 unset( $options['acting_settings']['telecom'] );
1432 $options['acting_settings']['telecom']['clientip'] = isset($_POST['clientip']) ? $_POST['clientip'] : '';
1433 $options['acting_settings']['telecom']['stype'] = isset($_POST['stype']) ? $_POST['stype'] : '';
1434 $options['acting_settings']['telecom']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1435 $options['acting_settings']['telecom']['edy_activate'] = isset($_POST['edy_activate']) ? $_POST['edy_activate'] : '';
1436
1437 if( WCUtils::is_blank($_POST['clientip']) )
1438 $mes .= '※クライアントIPを�
1439 �力して下さい<br />';
1440 if( WCUtils::is_blank($_POST['stype']) )
1441 $mes .= '※決済タイプを�
1442 �力して下さい<br />';
1443
1444 if( WCUtils::is_blank($mes) ){
1445 $this->action_status = 'success';
1446 $this->action_message = __('options are updated','usces');
1447 $options['acting_settings']['telecom']['activate'] = 'on';
1448 if( 'on' == $options['acting_settings']['telecom']['card_activate'] ){
1449 if( 'E' == $options['acting_settings']['telecom']['stype'][0] ) {
1450 $options['acting_settings']['telecom']['send_url'] = "https://www.credit-cgiserver.com/inetcredit/secure/order.pl";
1451 } else {
1452 $options['acting_settings']['telecom']['send_url'] = "https://secure.telecomcredit.co.jp/inetcredit/secure/order.pl";
1453 }
1454 $this->payment_structure['acting_telecom_card'] = 'カード決済(テレコムクレジット)';
1455 }else{
1456 unset($this->payment_structure['acting_telecom_card']);
1457 }
1458 if( 'on' == $options['acting_settings']['telecom']['edy_activate'] ){
1459 $options['acting_settings']['telecom']['send_url_edy'] = "https://secure.telecomcredit.co.jp/payment/edy/order.pl";
1460 $this->payment_structure['acting_telecom_edy'] = 'Edy決済(テレコムクレジット)';
1461 }else{
1462 unset($this->payment_structure['acting_telecom_edy']);
1463 }
1464 }else{
1465 $this->action_status = 'error';
1466 $this->action_message = __('データに不備が有ります','usces');
1467 $options['acting_settings']['telecom']['activate'] = 'off';
1468 unset($this->payment_structure['acting_telecom_card']);
1469 unset($this->payment_structure['acting_telecom_edy']);
1470 }
1471 ksort($this->payment_structure);
1472 update_option('usces_payment_structure', $this->payment_structure);
1473 update_option('usces', $options);
1474 break;
1475 //20120618ysk end
1476 //20121206ysk start
1477 case 'digitalcheck':
1478 unset( $options['acting_settings']['digitalcheck'] );
1479 $options['acting_settings']['digitalcheck']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1480 $options['acting_settings']['digitalcheck']['card_ip'] = isset($_POST['card_ip']) ? $_POST['card_ip'] : '';
1481 $options['acting_settings']['digitalcheck']['card_pass'] = isset($_POST['card_pass']) ? $_POST['card_pass'] : '';
1482 $options['acting_settings']['digitalcheck']['card_kakutei'] = isset($_POST['card_kakutei']) ? $_POST['card_kakutei'] : '';
1483 $options['acting_settings']['digitalcheck']['card_user_id'] = isset($_POST['card_user_id']) ? $_POST['card_user_id'] : '';
1484 $options['acting_settings']['digitalcheck']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1485 $options['acting_settings']['digitalcheck']['conv_ip'] = isset($_POST['conv_ip']) ? $_POST['conv_ip'] : '';
1486 $options['acting_settings']['digitalcheck']['conv_store'] = isset($_POST['conv_store']) ? $_POST['conv_store'] : array();
1487 $options['acting_settings']['digitalcheck']['conv_kigen'] = isset($_POST['conv_kigen']) ? $_POST['conv_kigen'] : '14';
1488
1489 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) {
1490 if( '' == trim($_POST['card_ip']) )
1491 $mes .= '※加盟店コードを�
1492 �力して下さい<br />';
1493 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1494 if( '' == trim($_POST['card_pass']) )
1495 $mes .= '※加盟店パスワードを�
1496 �力して下さい<br />';
1497 }
1498 }
1499 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
1500 if( '' == trim($_POST['conv_ip']) )
1501 $mes .= '※加盟店コードを�
1502 �力して下さい<br />';
1503 if( empty($_POST['conv_store']) )
1504 $mes .= '※利用コンビニを選択して下さい<br />';
1505 }
1506
1507 if( '' == $mes ){
1508 $this->action_status = 'success';
1509 $this->action_message = __('options are updated','usces');
1510 $options['acting_settings']['digitalcheck']['activate'] = 'on';
1511 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ){
1512 $options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll";
1513 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1514 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.digitalcheck.jp/settle/settlex/credit2.dll";
1515 } else {
1516 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "";
1517 }
1518 $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(デジタルチェック)';
1519 }else{
1520 unset($this->payment_structure['acting_digitalcheck_card']);
1521 }
1522 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ){
1523 //$options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle2/ubp3.dll";
1524 $options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll";
1525 $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(デジタルチェック)';
1526 }else{
1527 unset($this->payment_structure['acting_digitalcheck_conv']);
1528 }
1529 }else{
1530 $this->action_status = 'error';
1531 $this->action_message = __('データに不備が有ります','usces');
1532 $options['acting_settings']['digitalcheck']['activate'] = 'off';
1533 unset($this->payment_structure['acting_digitalcheck_card']);
1534 unset($this->payment_structure['acting_digitalcheck_conv']);
1535 }
1536 ksort($this->payment_structure);
1537 update_option('usces_payment_structure', $this->payment_structure);
1538 update_option('usces', $options);
1539 break;
1540 //20121206ysk end
1541 //20130225ysk start
1542 case 'mizuho':
1543 unset( $options['acting_settings']['mizuho'] );
1544 $options['acting_settings']['mizuho']['shopid'] = isset($_POST['shopid']) ? $_POST['shopid'] : '';
1545 $options['acting_settings']['mizuho']['cshopid'] = isset($_POST['cshopid']) ? $_POST['cshopid'] : '';
1546 $options['acting_settings']['mizuho']['hash_pass'] = isset($_POST['hash_pass']) ? $_POST['hash_pass'] : '';
1547 $options['acting_settings']['mizuho']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1548 $options['acting_settings']['mizuho']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1549 $options['acting_settings']['mizuho']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1550 $options['acting_settings']['mizuho']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1551 $options['acting_settings']['mizuho']['conv1_activate'] = isset($_POST['conv1_activate']) ? $_POST['conv1_activate'] : '';
1552 $options['acting_settings']['mizuho']['conv2_activate'] = isset($_POST['conv2_activate']) ? $_POST['conv2_activate'] : '';
1553
1554 //if( 'on' == $options['acting_settings']['mizuho']['card_activate'] or 'on' == $options['acting_settings']['mizuho']['conv_activate'] ) {
1555 if( '' == trim($_POST['shopid']) )
1556 $mes .= '※加盟店コードを�
1557 �力して下さい<br />';
1558 if( '' == trim($_POST['cshopid']) )
1559 $mes .= '※加盟店サブコードを�
1560 �力して下さい<br />';
1561 if( '' == trim($_POST['hash_pass']) )
1562 $mes .= '※ハッシュ用パスワードを�
1563 �力して下さい<br />';
1564 //}
1565 if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1566 $mes .= '※本番URLを�
1567 �力して下さい<br />';
1568 if( defined('WCEX_MOBILE') and isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url_mbl']) )
1569 $mes .= '※本番URL(携帯)を�
1570 �力して下さい<br />';
1571
1572 if( '' == $mes ) {
1573 $this->action_status = 'success';
1574 $this->action_message = __('options are updated','usces');
1575 $options['acting_settings']['mizuho']['activate'] = 'on';
1576 $options['acting_settings']['mizuho']['send_url_test'] = "https://210.161.141.207/mltbank/MBWebFrontPayment";
1577 if( defined('WCEX_MOBILE') ) $options['acting_settings']['mizuho']['send_url_mbl_test'] = "https://210.161.141.207/mltbank/iMBWebFrontPayment";
1578 if( 'on' == $options['acting_settings']['mizuho']['card_activate'] ) {
1579 $this->payment_structure['acting_mizuho_card'] = 'カード決済(みずほファクター)';
1580 } else {
1581 unset($this->payment_structure['acting_mizuho_card']);
1582 }
1583 if( 'on' == $options['acting_settings']['mizuho']['conv1_activate'] ) {
1584 $this->payment_structure['acting_mizuho_conv1'] = 'コンビニ・ウェルネット決済(みずほファクター)';
1585 } else {
1586 unset($this->payment_structure['acting_mizuho_conv1']);
1587 }
1588 if( 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) {
1589 $this->payment_structure['acting_mizuho_conv2'] = 'コンビニ・セブンイレブン決済(みずほファクター)';
1590 } else {
1591 unset($this->payment_structure['acting_mizuho_conv2']);
1592 }
1593 } else {
1594 $this->action_status = 'error';
1595 $this->action_message = __('データに不備が有ります','usces');
1596 $options['acting_settings']['mizuho']['activate'] = 'off';
1597 unset($this->payment_structure['acting_mizuho_card']);
1598 unset($this->payment_structure['acting_mizuho_conv1']);
1599 unset($this->payment_structure['acting_mizuho_conv2']);
1600 }
1601 ksort($this->payment_structure);
1602 update_option('usces_payment_structure', $this->payment_structure);
1603 update_option('usces', $options);
1604 break;
1605 //20130225ysk end
1606 }
1607
1608
1609 }
1610
1611
1612 $this->options = get_option('usces');
1613
1614 require_once(USCES_PLUGIN_DIR . '/includes/admin_settlement.php');
1615 }
1616
1617 /********************************************************************************/
1618 function selected( $selected, $current) {
1619 if ( $selected == $current)
1620 echo ' selected="selected"';
1621 }
1622 /********************************************************************************/
1623
1624 function usces_session_start() {
1625 $options = get_option('usces');
1626 if( !isset($options['usces_key']) || empty($options['usces_key']) ){
1627 $options['usces_key'] = uniqid('uk');
1628 update_option('usces', $options);
1629 }
1630
1631 if(defined( 'USCES_KEY' )){
1632 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1633 session_name( 'adm'.USCES_KEY );
1634 }else{
1635 session_name( USCES_KEY );
1636 }
1637 }else{
1638 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1639 session_name( 'adm'.$options['usces_key'] );
1640 }else{
1641 session_name( $options['usces_key'] );
1642 }
1643 }
1644 if(isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid'])) {
1645 $sessid = $_GET['uscesid'];
1646 $sessid = $this->uscesdc($sessid);
1647 session_id($sessid);
1648 }
1649
1650 @session_start();
1651
1652 //20111222ysk start 0000367
1653 //if ( !isset($_SESSION['usces_member']) ){
1654 if ( !isset($_SESSION['usces_member']) || $options['membersystem_state'] != 'activate' ){
1655 //20111222ysk end
1656 $_SESSION['usces_member'] = array();
1657 }
1658
1659 if(!isset($_SESSION['usces_checked_business_days']))
1660 $this->update_business_days();
1661 }
1662
1663 function usces_cookie() {
1664 if(is_admin()) return;
1665
1666 $actionflag = false;
1667 $sess = NULL;
1668 $addr = NULL;
1669 $rckid = NULL;
1670 $none = NULL;
1671 $cookie = $this->get_cookie();
1672
1673 if( isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid']) ){
1674 $sessid = base64_decode(urldecode($_GET['uscesid']));
1675 list($sess, $addr, $rckid, $none) = explode('_', $sessid, 4);
1676 }
1677 if('acting' == $addr) return;
1678
1679 if( apply_filters( 'usces_filter_cookie', false) ) return;
1680
1681 //There is a need to consider.
1682 return;
1683
1684 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
1685
1686 $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
1687 $sslid = isset($cookie['sslid']) ? $cookie['sslid'] : NULL;
1688 $option = get_option('usces');
1689 $parsed = parse_url(get_option('home'));
1690 $home = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1691 $parsed = parse_url($option['ssl_url']);
1692 $sslhome = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1693
1694 //usces_log('refer : '.$refer, 'acting_transaction.log');
1695 // usces_log('sslid : '.$sslid, 'acting_transaction.log');
1696 // usces_log('rckid : '.$rckid, 'acting_transaction.log');
1697 // usces_log('usces_cookieid : '.$_SESSION['usces_cookieid'], 'acting_transaction.log');
1698 // usces_log('request : '.print_r($_SERVER['REQUEST_URI'],true), 'acting_transaction.log');
1699
1700 if( empty($refer) || (false === strpos($refer, $home) && false === strpos($refer, $sslhome)) ){
1701 if( !empty($sslid) && !empty($rckid) && $sslid === $rckid ){
1702 $actionflag = true;
1703 }else{
1704 $actionflag = false;
1705 }
1706 }else{
1707 if( !empty($sslid) && $sslid !== $rckid ){
1708 $actionflag = false;
1709 }else{
1710 $actionflag = true;
1711 }
1712 }
1713
1714
1715 if( $actionflag ){
1716 $values = array(
1717 'id' => $rckid,
1718 'sslid' => $rckid,
1719 'name' => '',
1720 'rme' => ''
1721 );
1722 if( 'acting' !== $rckid ){
1723 $this->set_cookie($values);
1724 }
1725 }else{
1726 if( 'acting' !== $rckid ){
1727 unset($_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] );
1728 wp_redirect( 'http://'.$home );
1729 }
1730 }
1731 }else{
1732 if( !isset($cookie['id']) || WCUtils::is_blank($cookie['id']) ) {
1733 $values = array(
1734 'id' => md5(uniqid(rand(), true)),
1735 'name' => '',
1736 'rme' => ''
1737 );
1738 $this->set_cookie($values);
1739 $_SESSION['usces_cookieid'] = $values['id'];
1740 } else {
1741 if( !isset($_SESSION['usces_cookieid']) || $_SESSION['usces_cookieid'] != $cookie['id'])
1742 $_SESSION['usces_cookieid'] = $cookie['id'];
1743 }
1744
1745 $actionflag = true;
1746 }
1747
1748 }
1749
1750 function set_cookie($values){
1751 $value = serialize($values);
1752 $timeout = time()+7*86400;
1753 $domain = $_SERVER['SERVER_NAME'];
1754 $res = setcookie('usces_cookie', $value, $timeout, USCES_COOKIEPATH, $domain);
1755 }
1756
1757 function get_cookie() {
1758 $values = isset($_COOKIE['usces_cookie']) ? unserialize(stripslashes($_COOKIE['usces_cookie'])) : NULL;
1759 return $values;
1760 }
1761
1762 function get_access( $key, $type, $date ) {
1763 global $wpdb;
1764 $table_name = $wpdb->prefix . "usces_access";
1765
1766 $query = $wpdb->prepare("SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date);
1767 $value = $wpdb->get_var( $query );
1768 if( !$value ){
1769 $res = NULL;
1770 }else{
1771 $res = unserialize($value);
1772 }
1773
1774 return $res;
1775 }
1776
1777 function get_access_piriod( $key, $type, $startday, $endday ) {
1778 global $wpdb;
1779 $table_name = $wpdb->prefix . "usces_access";
1780 //$wpdb->show_errors();
1781 $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);
1782 $res = $wpdb->get_results( $query, ARRAY_A );
1783
1784 return $res;
1785 }
1786
1787 function update_access( $array ) {
1788 global $wpdb;
1789 $table_name = $wpdb->prefix . "usces_access";
1790
1791 $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']);
1792 $res = $wpdb->get_var( $query );
1793 //$wpdb->show_errors();
1794 if(empty($res)){
1795 $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']);
1796 $wpdb->query( $query );
1797 }else{
1798 $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']);
1799 $wpdb->query( $query );
1800 }
1801 }
1802
1803 function get_uscesid( $flag = true) {
1804
1805 $sessname = session_name();
1806 $sessid = session_id();
1807 $sessid = $this->uscescv($sessid, $flag);
1808 return $sessid;
1809 }
1810
1811 function shop_head() {
1812 global $post;
1813 $this->item = $post;
1814 $no_cart_css = isset($this->options['system']['no_cart_css']) ? $this->options['system']['no_cart_css'] : 0;
1815
1816 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1817 $css_url = USCES_FRONT_PLUGIN_URL . '/css/usces_cart.css';
1818 }else{
1819 $css_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/css/usces_cart.css';
1820 }
1821 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) ){
1822 echo " <meta name='robots' content='noindex,nofollow' />\n";
1823 wp_print_scripts( array( 'sack' ));
1824 }
1825 if( !$no_cart_css ){
1826 echo '<link href="' . $css_url . '" rel="stylesheet" type="text/css" />';
1827 }
1828 if( file_exists(get_stylesheet_directory() . '/usces_cart.css') ){
1829 echo '<link href="' . get_stylesheet_directory_uri() . '/usces_cart.css" rel="stylesheet" type="text/css" />';
1830 }
1831 }
1832
1833 function shop_foot() {
1834 global $current_user;
1835 $item = $this->item;
1836 if( empty($item) ){
1837 $item->ID = 0;
1838 $item->post_mime_type = '';
1839 }
1840 get_currentuserinfo();
1841 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1842 $javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js';
1843 }else{
1844 $javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js';
1845 }
1846 $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')) : '';
1847 $this->previous_url = isset($_SESSION['usces_previous_url']) ? $_SESSION['usces_previous_url'] : get_home_url();
1848
1849 // usces_log('post_type : '.$item->post_mime_type, 'test.log');
1850 // usces_log('is_single : '.(is_single() ? 'true' : 'false'), 'test.log');
1851
1852 if( $this->use_js && empty($this->item) && !is_admin() ) :
1853 ?>
1854 <script type='text/javascript'>
1855 /* <![CDATA[ */
1856 uscesL10n = {
1857 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
1858 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>"
1859 }
1860 /* ]]> */
1861 </script>
1862 <?php elseif( $this->use_js && !empty($this->item) ) :
1863
1864 $ioptkeys = $this->get_itemOptionKey( $item->ID );
1865 $mes_opts_str = "";
1866 $key_opts_str = "";
1867 $opt_means = "";
1868 $opt_esse = "";
1869 if($ioptkeys){
1870 foreach($ioptkeys as $key => $value){
1871 $optValues = $this->get_itemOptions( $value, $item->ID );
1872 if($optValues['means'] < 2){
1873 $mes_opts_str .= "'" . sprintf(__("Chose the %s", 'usces'), esc_js($value)) . "',";
1874 }else{
1875 $mes_opts_str .= "'" . sprintf(__("Input the %s", 'usces'), esc_js($value)) . "',";
1876 }
1877 $key_opts_str .= "'" . urlencode(esc_js($value)) . "',";
1878 $opt_means .= "'" . esc_js($optValues['means']) . "',";
1879 $opt_esse .= "'" . esc_js($optValues['essential']) . "',";
1880 }
1881 $mes_opts_str = rtrim($mes_opts_str, ',');
1882 $key_opts_str = rtrim($key_opts_str, ',');
1883 $opt_means = rtrim($opt_means, ',');
1884 $opt_esse = rtrim($opt_esse, ',');
1885 }
1886 //$itemRestriction = get_post_custom_values('_itemRestriction', $item->ID);
1887 $itemRestriction = get_post_meta($item->ID, '_itemRestriction', true);
1888
1889 ?>
1890 <script type='text/javascript'>
1891 /* <![CDATA[ */
1892 uscesL10n = {
1893 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
1894 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>",
1895 'post_id': "<?php echo $item->ID; ?>",
1896 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
1897 'is_cart_row': <?php echo ( (0 < $this->cart->num_row()) ? 'true' : 'false'); ?>,
1898 'opt_esse': new Array( <?php echo $opt_esse; ?> ),
1899 'opt_means': new Array( <?php echo $opt_means; ?> ),
1900 'mes_opts': new Array( <?php echo $mes_opts_str; ?> ),
1901 'key_opts': new Array( <?php echo $key_opts_str; ?> ),
1902 'previous_url': "<?php echo $this->previous_url; ?>",
1903 'itemRestriction': "<?php echo $itemRestriction; ?>"
1904 }
1905 /* ]]> */
1906 </script>
1907 <script type='text/javascript' src='<?php echo $javascript_url; ?>'></script>
1908 <?php endif; ?>
1909 <?php //if( !is_home() && !is_front_page() && $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || ('item' == $item->post_mime_type)) ) : ?>
1910 <?php if( $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || (is_singular() && 'item' == $item->post_mime_type)) ) : ?>
1911 <script type='text/javascript'>
1912 (function($) {
1913 uscesCart = {
1914 intoCart : function (post_id, sku) {
1915
1916 var zaikonum = document.getElementById("zaikonum["+post_id+"]["+sku+"]").value;
1917 var zaiko = document.getElementById("zaiko["+post_id+"]["+sku+"]").value;
1918 if( (zaiko != '0' && zaiko != '1') || parseInt(zaikonum) == 0 ){
1919 alert('<?php _e('temporaly out of stock now', 'usces'); ?>');
1920 return false;
1921 }
1922
1923 var mes = '';
1924 if(document.getElementById("quant["+post_id+"]["+sku+"]")){
1925 var quant = document.getElementById("quant["+post_id+"]["+sku+"]").value;
1926 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
1927 mes += "<?php _e('enter the correct amount', 'usces'); ?>\n";
1928 }
1929 var checknum = '';
1930 var checkmode = '';
1931 if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
1932 checknum = uscesL10n.itemRestriction;
1933 checkmode ='rest';
1934 } else if( parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
1935 checknum = zaikonum;
1936 checkmode ='zaiko';
1937 } else if( (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) {
1938 checknum = zaikonum;
1939 checkmode ='zaiko';
1940 } else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum == '' ) {
1941 checknum = uscesL10n.itemRestriction;
1942 checkmode ='rest';
1943 }
1944
1945
1946 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
1947 if(checkmode == 'rest'){
1948 mes += <?php _e("'This article is limited by '+checknum+' at a time.'", 'usces'); ?>+"\n";
1949 }else{
1950 mes += <?php _e("'Stock is remainder '+checknum+'.'", 'usces'); ?>+"\n";
1951 }
1952 }
1953 }
1954 for(i=0; i<uscesL10n.key_opts.length; i++){
1955 var skuob = document.getElementById("itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]");
1956 if( uscesL10n.opt_esse[i] == '1' ){
1957
1958 if( uscesL10n.opt_means[i] < 2 && skuob.value == '#NONE#' ){
1959 mes += uscesL10n.mes_opts[i]+"\n";
1960 }else if( uscesL10n.opt_means[i] >= 2 && skuob.value == '' ){
1961 mes += uscesL10n.mes_opts[i]+"\n";
1962 }
1963 }
1964 }
1965
1966 <?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); //Unavailable ?>
1967 <?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?>
1968
1969 if( mes != '' ){
1970 alert( mes );
1971 return false;
1972 }else{
1973 <?php echo apply_filters('usces_filter_js_intoCart', "return true;\n", $item->ID, NULL); ?>
1974 }
1975 },
1976
1977 upCart : function () {
1978
1979 var zaikoob = $("input[name*='zaikonum']");
1980 var quantob = $("input[name*='quant']");
1981 var postidob = $("input[name*='itempostid']");
1982 var skuob = $("input[name*='itemsku']");
1983
1984 var zaikonum = '';
1985 var zaiko = '';
1986 var quant = '';
1987 var mes = '';
1988 var checknum = '';
1989 var post_id = '';
1990 var sku = '';
1991 var itemRestriction = '';
1992
1993 var ct = zaikoob.length;
1994 for(var i=0; i< ct; i++){
1995 post_id = postidob[i].value;
1996 sku = skuob[i].value;
1997 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
1998 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
1999
2000 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2001 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2002 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2003 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2004 }
2005 var checknum = '';
2006 var checkmode = '';
2007 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2008 checknum = itemRestriction;
2009 checkmode ='rest';
2010 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2011 checknum = zaikonum;
2012 checkmode ='zaiko';
2013 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2014 checknum = zaikonum;
2015 checkmode ='zaiko';
2016 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2017 checknum = itemRestriction;
2018 checkmode ='rest';
2019 }
2020 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2021 if(checkmode == 'rest'){
2022 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2023 }else{
2024 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2025 }
2026 }
2027 }
2028 }
2029
2030 <?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); //Unavailable ?>
2031 <?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?>
2032
2033 if( mes != '' ){
2034 alert( mes );
2035 return false;
2036 }else{
2037 <?php echo apply_filters('usces_filter_js_upCart', "return true;\n", $item->ID, NULL); ?>
2038 }
2039 },
2040
2041 cartNext : function () {
2042
2043 var zaikoob = $("input[name*='zaikonum']");
2044 var quantob = $("input[name*='quant']");
2045 var postidob = $("input[name*='itempostid']");
2046 var skuob = $("input[name*='itemsku']");
2047
2048 var zaikonum = '';
2049 var zaiko = '';
2050 var quant = '';
2051 var mes = '';
2052 var checknum = '';
2053 var post_id = '';
2054 var sku = '';
2055 var itemRestriction = '';
2056
2057 var ct = zaikoob.length;
2058 for(var i=0; i< ct; i++){
2059 post_id = postidob[i].value;
2060 sku = skuob[i].value;
2061 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2062 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2063
2064 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2065 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2066 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2067 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2068 }
2069 var checknum = '';
2070 var checkmode = '';
2071 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2072 checknum = itemRestriction;
2073 checkmode ='rest';
2074 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2075 checknum = zaikonum;
2076 checkmode ='zaiko';
2077 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2078 checknum = zaikonum;
2079 checkmode ='zaiko';
2080 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2081 checknum = itemRestriction;
2082 checkmode ='rest';
2083 }
2084
2085 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2086 if(checkmode == 'rest'){
2087 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2088 }else{
2089 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2090 }
2091 }
2092 }
2093 }
2094 if( mes != '' ){
2095 alert( mes );
2096 return false;
2097 }else{
2098 return true;
2099 }
2100 },
2101
2102 previousCart : function () {
2103 location.href = uscesL10n.previous_url;
2104 },
2105
2106 settings: {
2107 url: uscesL10n.ajaxurl,
2108 type: 'POST',
2109 cache: false,
2110 success: function(data, dataType){
2111 //$("tbody#item-opt-list").html( data );
2112 },
2113 error: function(msg){
2114 //$("#ajax-response").html(msg);
2115 }
2116 },
2117
2118 changeStates : function( country ) {
2119 var s = this.settings;
2120 s.data = "action=change_states_ajax&country=" + country;
2121 s.success = function(data, dataType){
2122 if( 'error' == data ){
2123 alert('error');
2124 }else{
2125 $("select#pref").html( data );
2126 }
2127 };
2128 s.error = function(msg){
2129 alert("error");
2130 };
2131 $.ajax( s );
2132 return false;
2133 },
2134
2135 isNum : function (num) {
2136 if (num.match(/[^0-9]/g)) {
2137 return false;
2138 }
2139 return true;
2140 },
2141 purchase : 0
2142 };
2143 $("#country").change(function () {
2144 var country = $("#country option:selected").val();
2145 $("#newcharging_type option:selected").val()
2146 uscesCart.changeStates( country );
2147 });
2148 $("#purchase_form").submit(function () {
2149 if( 0 == uscesCart.purchase ){
2150 uscesCart.purchase = 1;
2151 return true;
2152 }else{
2153 $("#purchase_button").attr("disabled", "disabled");
2154 $("#back_button").attr("disabled", "disabled");
2155 return false;
2156 }
2157 });
2158
2159 })(jQuery);
2160 </script>
2161 <?php endif; ?>
2162 <?php
2163 usces_states_form_js();
2164 }
2165
2166 function admin_head() {
2167 global $wp_version;
2168 $payments_str = '';
2169 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
2170 foreach ( (array)$payments as $id => $array ) {
2171 $payments_str .= "'" . esc_js($array['name']) . "': '" . esc_js($array['settlement']) . "', ";
2172 }
2173 $payments_str .= "'" . __('Transfer (prepayment)', 'usces') . "': 'transferAdvance', ";
2174 $payments_str .= "'" . __('Transfer (postpay)', 'usces') . "': 'transferDeferred', ";
2175 $payments_str .= "'" . __('COD', 'usces') . "': 'COD', ";
2176 $payments_str = rtrim($payments_str, ', ');
2177 $wcex_str = '';
2178 $wcex = usces_get_wcex();
2179 foreach ( (array)$wcex as $key => $values ) {
2180 $wcex_str .= "'" . esc_js($key) . "-" . esc_js($values['version']) . "', ";
2181 }
2182 $wcex_str = rtrim($wcex_str, ', ');
2183 if ( version_compare($wp_version, '3.4', '>=') ){
2184 $theme_ob = wp_get_theme();
2185 $theme['Name'] = esc_js($theme_ob->get('Name'));
2186 $theme['Version'] = esc_js($theme_ob->get('Version'));
2187 }else{
2188 $theme = get_theme_data( get_stylesheet_directory().'/style.css' );//20120618ysk
2189 }
2190 ?>
2191
2192 <link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" />
2193 <script type='text/javascript'>
2194 /* <![CDATA[ */
2195 uscesL10n = {
2196 'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php",
2197 'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>",
2198 'version': "<?php echo USCES_VERSION; ?>",
2199 'wcid': "<?php echo get_option('usces_wcid'); ?>",
2200 'locale': '<?php echo get_locale(); ?>',
2201 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
2202 'purchase_limit': "<?php echo $this->options['purchase_limit']; ?>",
2203 'point_rate': "<?php echo $this->options['point_rate']; ?>",
2204 'shipping_rule': "<?php echo $this->options['shipping_rule']; ?>",
2205 'theme': "<?php echo $theme['Name'] . '-' . $theme['Version']; ?>",
2206 'wcex': new Array( <?php echo $wcex_str; ?> ),
2207 'now_loading': "<?php _e('now loading', 'usces'); ?>"
2208 };
2209 uscesPayments = {<?php echo $payments_str; ?>};
2210 /* ]]> */
2211 </script>
2212 <script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js'></script>
2213 <?php
2214 if($this->action_status == 'edit' || $this->action_status == 'editpost'){
2215 ?>
2216 <link rel='stylesheet' href='<?php echo get_option('siteurl'); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' />
2217 <?php
2218 }
2219 if( isset($_REQUEST['page']) ){
2220 switch( $_REQUEST['page'] ){
2221 case 'usces_initial':
2222 ?>
2223 <script type='text/javascript'>
2224 /* <![CDATA[ */
2225 usces_ini = {
2226 'cod_type': "<?php if( 'change' == $this->options['cod_type'] ) {echo 'change';}else{echo 'fix';} ?>",
2227 'cod_type_fix': "<?php echo esc_js(__('Fixation C.O.D.', 'usces')); ?>",
2228 'cod_type_change': "<?php echo esc_js(__('Variable C.O.D.', 'usces')); ?>",
2229 'cod_unit': "<?php echo esc_js(__('dollars', 'usces')); ?>",
2230 'cod_failure': "<?php echo esc_js(__('failure in update', 'usces')); ?>",
2231 'cod_updated': "<?php echo esc_js(__('options are updated', 'usces')); ?>",
2232 'cod_limit': "<?php echo esc_js(__('A value of the amount of upper limit is dirty.', 'usces')); ?>"
2233 };
2234 /* ]]> */
2235 </script>
2236 <?php
2237 break;
2238 case 'usces_itemnew':
2239 case 'usces_itemedit':
2240 ?>
2241 <style type="text/css">
2242 <!--
2243 #usces_mess {
2244 color: #FF0000;
2245 font-weight: bold;
2246 }
2247 -->
2248 </style>
2249 <?php
2250 break;
2251 }
2252 }
2253 ?>
2254 <?php
2255 if( is_admin() && ( (isset($_GET['order_action']) && 'newpost' == $_GET['order_action'])
2256 || (isset($_GET['page']) && 'usces_ordernew' == $_GET['page'])
2257 || (isset($_GET['order_action']) && 'edit' == $_GET['order_action'])
2258 || (isset($_GET['order_action']) && 'editpost' == $_GET['order_action'])
2259 || (isset($_GET['member_action']) && 'edit' == $_GET['member_action'])
2260 || (isset($_GET['member_action']) && 'editpost' == $_GET['member_action'])) ) :
2261 switch( $_GET['page'] ){
2262 case 'usces_ordernew':
2263 case 'usces_orderlist':
2264 $admin_page = 'order';
2265 break;
2266 case 'usces_memberlist':
2267 $admin_page = 'member';
2268 break;
2269 }
2270 ?>
2271 <script type='text/javascript'>
2272 jQuery(function($) {
2273 uscesForm = {
2274 settings: {
2275 url: uscesL10n.requestFile,
2276 type: 'POST',
2277 cache: false,
2278 success: function(data, dataType){
2279 //$("tbody#item-opt-list").html( data );
2280 },
2281 error: function(msg){
2282 //$("#ajax-response").html(msg);
2283 }
2284 },
2285
2286 changeStates : function( country, type ) {
2287 var s = this.settings;
2288 s.data = "action=change_states_ajax&country=" + country;
2289 s.success = function(data, dataType){
2290 if( 'error' == data ){
2291 alert('error');
2292 }else{
2293 $("select#" + type + "_pref").html( data );
2294 if( customercountry == country && 'customer' == type ){
2295 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2296 }else if( deliverycountry == country && 'delivery' == type ){
2297 $("#" + type + "_pref").attr({selectedIndex:deliverystate});
2298 }else if( customercountry == country && 'member' == type ){
2299 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2300 }
2301 }
2302 };
2303 s.error = function(msg){
2304 alert("error");
2305 };
2306 $.ajax( s );
2307 return false;
2308 },
2309
2310 isNum : function (num) {
2311 if (num.match(/[^0-9]/g)) {
2312 return false;
2313 }
2314 return true;
2315 }
2316 };
2317 <?php
2318 if( 'order' == $admin_page ){
2319 ?>
2320 if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) {
2321 var customerstate = $("#customer_pref").get(0).selectedIndex;
2322 var customercountry = $("#customer_country").val();
2323 var deliverystate = $("#delivery_pref").get(0).selectedIndex;
2324 var deliverycountry = $("#delivery_country").val();
2325
2326 $("#customer_country").change(function () {
2327 var country = $("#customer_country option:selected").val();
2328 uscesForm.changeStates( country, 'customer' );
2329 });
2330 $("#delivery_country").change(function () {
2331 var country = $("#delivery_country option:selected").val();
2332 uscesForm.changeStates( country, 'delivery' );
2333 });
2334 }
2335 <?php
2336 }else if( 'member' == $admin_page ){
2337 ?>
2338 if( undefined != $("#member_pref").get(0) ) {
2339 var customerstate = $("#member_pref").get(0).selectedIndex;
2340 var customercountry = $("#member_country").val();
2341 var deliverystate = '';
2342 var deliverycountry = '';
2343
2344 $("#member_country").change(function () {
2345 var country = $("#member_country option:selected").val();
2346 uscesForm.changeStates( country, 'member' );
2347 });
2348 }
2349 <?php
2350 }
2351 ?>
2352 });
2353 </script>
2354 <?php
2355 endif;
2356 }
2357
2358 function main() {
2359 global $wpdb, $wp_locale, $wp_version, $post_ID;
2360 global $wp_query, $usces_action, $post, $action, $editing;
2361
2362 update_option('usces_shipping_rule', apply_filters('usces_filter_shipping_rule', get_option('usces_shipping_rule')));
2363 $this->shipping_rule = get_option('usces_shipping_rule');
2364
2365 // $_wp_http_referer = isset($_POST['_wp_http_referer']) ? $_POST['_wp_http_referer'] : 'a';
2366 // if( isset($_POST) && 1 !== preg_match('/(?:plugin|theme)-editor\.php/', $_wp_http_referer) ){
2367 // $_POST = $this->stripslashes_deep_post($_POST);
2368 // }
2369
2370 if( !is_admin() ){
2371 $this->usces_cookie();
2372 }
2373 $this->make_url();
2374
2375 //usces_log('HTTP_REFERER : '.$_SERVER['HTTP_REFERER'], 'acting_transaction.log');
2376 //usces_log('REQUEST_URI : '.$_SERVER['REQUEST_URI'], 'acting_transaction.log');
2377
2378 do_action('usces_main');
2379 $this->update_table();
2380
2381
2382 // if( 'customer' == $this->page ){
2383 // header("Pragma: private");
2384 // header("Cache-Control: private");
2385 // }else{
2386 // header("Pragma: no-cache");
2387 // header("Cache-Control: no-cache");
2388 // }
2389
2390
2391 //var_dump($_REQUEST);
2392 require_once(USCES_PLUGIN_DIR . '/classes/cart.class.php');
2393 $this->cart = new usces_cart();
2394
2395 do_action('usces_after_cart_instant');
2396
2397 if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate' ){
2398 $post_id = (int)$_GET['post'];
2399 $new_id = usces_item_dupricate($post_id);
2400 $ref = isset($_REQUEST['usces_referer']) ? urlencode($_REQUEST['usces_referer']) : '';
2401 $url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref;
2402 wp_redirect($url);
2403 exit;
2404 }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'itemcsv' ){
2405 $filename = usces_item_uploadcsv();
2406 $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&regfile='.$filename;
2407 wp_redirect($url);
2408 exit;
2409 }
2410 //20110208ysk start
2411 if('on' == $this->options['acting_settings']['paypal']['ec_activate']) {
2412 require_once(USCES_PLUGIN_DIR . '/classes/paymentPaypal.class.php');
2413 $this->paypal = new usces_paypal();
2414 }
2415 //20110208ysk end
2416
2417 $this->ad_controller();
2418 //$this->controller();
2419
2420
2421
2422 if( isset($_GET['page']) && $_GET['page'] == 'usces_itemnew'){
2423 $itemnew = 'new';
2424 }else{
2425 $itemnew = '';
2426 }
2427
2428 wp_enqueue_script('jquery');
2429
2430 if( is_admin() && isset($_REQUEST['page']) && ((isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') || $itemnew == 'new' || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'editpost'))) {
2431
2432 if(isset($_REQUEST['action']) && $_REQUEST['action'] != 'editpost' && $itemnew == 'new'){
2433 if ( version_compare($wp_version, '3.0-beta', '>') ){
2434 if ( !isset($_GET['post_type']) )
2435 $post_type = 'post';
2436 elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
2437 $post_type = $_GET['post_type'];
2438 else
2439 wp_die( __('Invalid post type') );
2440 $post_type_object = get_post_type_object($post_type);
2441 $editing = true;
2442 // if ( current_user_can($post_type_object->edit_type_cap) ) {
2443 $post = $this->get_default_post_to_edit30( $post_type, true );
2444 $post_ID = $post->ID;
2445 // }
2446
2447 }else{
2448 $post = $this->get_default_post_to_edit();
2449 }
2450 }else{
2451 if ( version_compare($wp_version, '3.0-beta', '>') ){
2452 if ( isset($_GET['post']) )
2453 $post_id = (int) $_GET['post'];
2454 elseif ( isset($_POST['post_ID']) )
2455 $post_id = (int) $_POST['post_ID'];
2456 else
2457 $post_id = 0;
2458 $post_ID = $post_id;
2459 $post = null;
2460 $post_type_object = null;
2461 $post_type = null;
2462 if ( $post_id ) {
2463 $post = get_post($post_id);
2464 if ( $post ) {
2465 $post_type_object = get_post_type_object($post->post_type);
2466 if ( $post_type_object ) {
2467 $post_type = $post->post_type;
2468 $current_screen->post_type = $post->post_type;
2469 $current_screen->id = $current_screen->post_type;
2470 }
2471 }
2472 } elseif ( isset($_POST['post_type']) ) {
2473 $post_type_object = get_post_type_object($_POST['post_type']);
2474 if ( $post_type_object ) {
2475 $post_type = $post_type_object->name;
2476 $current_screen->post_type = $post_type;
2477 $current_screen->id = $current_screen->post_type;
2478 }
2479 }
2480
2481
2482 // $post = get_post( $post_id, OBJECT, 'edit' );
2483 // if ( $post->post_type == 'page' )
2484 // $post->page_template = get_post_meta( $id, '_wp_page_template', true );
2485
2486 }else{
2487 if(isset($_GET['post'])){
2488 $post_ID = (int) $_GET['post'];
2489 $post = get_post($post_ID);
2490 }else{
2491 $post_ID = isset($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : 0;
2492 if(!empty($post_ID))
2493 $post = get_post($post_ID);
2494 }
2495 }
2496 // global $wp_query, $usces_action, $post;
2497
2498 }
2499 $editing = true;
2500 wp_enqueue_script('autosave');
2501 wp_enqueue_script('post');
2502 //if ( user_can_richedit() )
2503 //wp_enqueue_script('editor');
2504 add_thickbox();
2505 wp_enqueue_script('media-upload');
2506 wp_enqueue_script('word-count');
2507 wp_enqueue_script( 'admin-comments' );
2508
2509 if ( version_compare($wp_version, '3.3', '<') )
2510 add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
2511 wp_enqueue_script('quicktags');
2512
2513 }
2514
2515
2516 if( is_admin() && isset($_REQUEST['page']) ){
2517
2518 wp_enqueue_script('jquery-color');
2519
2520 switch( $_REQUEST['page'] ){
2521
2522 case 'usces_initial':
2523 $js = USCES_FRONT_PLUGIN_URL.'/js/usces_initial.js';
2524 wp_enqueue_script('usces_initial.js', $js, array('jquery-ui-dialog', 'jquery-ui-sortable'));
2525 //wp_enqueue_script('jquery-ui-sortable');
2526 break;
2527
2528 case 'usces_settlement':
2529 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2530 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2531 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0' );
2532 // $item_list_layoutUrl = USCES_FRONT_PLUGIN_URL.'/js/usces_dumy.js';
2533 // wp_enqueue_script('usces_dumy', $item_list_layoutUrl, array('jquery-ui-tabs'), '1.0' );
2534 break;
2535 //20100809ysk start
2536 case 'usces_cart':
2537 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2538 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2539 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2540 break;
2541 //20100809ysk end
2542 //20100818ysk start
2543 case 'usces_member':
2544 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2545 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2546 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2547 break;
2548 //20100818ysk end
2549 //20100908ysk start
2550 case 'usces_orderlist':
2551 case 'usces_ordernew':
2552 wp_enqueue_script('jquery-ui-dialog');
2553 break;
2554 case 'usces_memberlist':
2555 wp_enqueue_script('jquery-ui-dialog');
2556 break;
2557 //20100908ysk end
2558 //20101111ysk start
2559 case 'usces_itemnew':
2560 wp_enqueue_script('jquery-ui-sortable');
2561 break;
2562 case 'usces_itemedit':
2563 if( isset($_REQUEST['action']) && 'upload_register' == $_REQUEST['action'] ){
2564 @ob_end_clean();
2565 ob_start();
2566 }else{
2567 wp_enqueue_script('jquery-ui-sortable');
2568 wp_enqueue_script('jquery-ui-dialog');
2569 }
2570 break;
2571 //20101111ysk end
2572 //20101208ysk start
2573 case 'usces_delivery':
2574 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2575 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2576 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2577 break;
2578 //20101208ysk end
2579 //20110331ysk start
2580 case 'usces_system':
2581 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2582 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2583 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2584 break;
2585 //20110331ysk end
2586 }
2587 }
2588
2589 if( isset($_REQUEST['order_action']) && $_REQUEST['order_action'] == 'pdfout' ){
2590 $this->get_current_member();
2591 $mid = $this->current_member['id'];
2592 $oid = $_GET['order_id'];
2593 if( !is_user_logged_in() && !$this->is_order($mid, $oid) )
2594 die('No permission');
2595 require_once( apply_filters('usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php') );
2596 }
2597
2598 do_action( 'usces_after_main' );
2599 }
2600
2601 function stripslashes_deep_post( $array ){
2602 $res = array();
2603 foreach( $array as $key => $value ){
2604 $key = stripslashes($key);
2605 if( is_array($value) ){
2606 $value = $this->stripslashes_deep_post( $value );
2607 }else{
2608 $value = stripslashes($value);
2609 }
2610 $res[$key] = $value;
2611 }
2612 return $res;
2613 }
2614
2615 function make_url(){
2616
2617 $permalink_structure = get_option('permalink_structure');
2618 //usces_log('use_ssl : '.$this->use_ssl, 'acting_transaction.log');
2619 if($this->use_ssl) {
2620 if( $permalink_structure ){
2621 $this->delim = '&';
2622 $home_perse = parse_url(get_option('home'));
2623 $home_perse_path = isset($home_perse['path']) ? $home_perse['path'] : '';
2624 $home_path = $home_perse['host'].$home_perse_path;
2625 $ssl_perse = parse_url($this->options['ssl_url']);
2626 $ssl_perse_path = isset($ssl_perse['path']) ? $ssl_perse['path'] : '';
2627 $ssl_path = $ssl_perse['host'].$ssl_perse_path;
2628 if( $home_perse_path != $ssl_perse_path ){
2629 if( ! defined('USCES_CUSTOMER_URL') )
2630 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2631 if( ! defined('USCES_CART_URL') )
2632 define('USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2633 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2634 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2635 if( ! defined('USCES_NEWMEMBER_URL') )
2636 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2637 if( ! defined('USCES_LOGIN_URL') )
2638 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2639 if( ! defined('USCES_LOGOUT_URL') )
2640 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2641 if( ! defined('USCES_MEMBER_URL') )
2642 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2643 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2644 if( ! defined('USCES_INQUIRY_URL') )
2645 define('USCES_INQUIRY_URL', $inquiry_url);
2646 if( ! defined('USCES_CART_NONSESSION_URL') )
2647 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER);
2648 //20110208ysk start
2649 //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));
2650 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2651 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2652 //20110208ysk end
2653 }else{
2654 $ssl_plink_cart = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_CART_NUMBER) ));
2655 $ssl_plink_member = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_MEMBER_NUMBER) ));
2656 if( ! defined('USCES_CUSTOMER_URL') )
2657 define('USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1');
2658 if( ! defined('USCES_CART_URL') )
2659 define('USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid());
2660 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2661 define('USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2662 if( ! defined('USCES_NEWMEMBER_URL') )
2663 define('USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid(). '&page=newmember');
2664 if( ! defined('USCES_LOGIN_URL') )
2665 define('USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=login');
2666 if( ! defined('USCES_LOGOUT_URL') )
2667 define('USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=logout');
2668 if( ! defined('USCES_MEMBER_URL') )
2669 define('USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid());
2670 if( !isset($this->options['inquiry_id']) || !( (int)$this->options['inquiry_id'] ) ){
2671 $inquiry_url = get_home_url();
2672 }else{
2673 $ssl_plink_inquiry = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link($this->options['inquiry_id']) ));
2674 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid();
2675 }
2676 if( ! defined('USCES_INQUIRY_URL') )
2677 define('USCES_INQUIRY_URL', $inquiry_url);
2678 if( ! defined('USCES_CART_NONSESSION_URL') )
2679 define('USCES_CART_NONSESSION_URL', $ssl_plink_cart);
2680 //20110208ysk start
2681 //define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2682 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2683 define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2684 //20110208ysk end
2685 }
2686 }else{
2687 $this->delim = '&';
2688 if( ! defined('USCES_CUSTOMER_URL') )
2689 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2690 if( ! defined('USCES_CART_URL') )
2691 define('USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2692 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2693 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2694 if( ! defined('USCES_NEWMEMBER_URL') )
2695 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2696 if( ! defined('USCES_LOGIN_URL') )
2697 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2698 if( ! defined('USCES_LOGOUT_URL') )
2699 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2700 if( ! defined('USCES_MEMBER_URL') )
2701 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2702 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2703 if( ! defined('USCES_INQUIRY_URL') )
2704 define('USCES_INQUIRY_URL', $inquiry_url);
2705 if( ! defined('USCES_CART_NONSESSION_URL') )
2706 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER);
2707 //20110208ysk start
2708 //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2709 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2710 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2711 //20110208ysk end
2712 }
2713 if( !is_admin() ){
2714 add_filter('home_url', array($this, 'usces_ssl_page_link'));
2715 add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
2716 add_filter('icon_dir_uri', array($this, 'usces_ssl_icon_dir_uri'));
2717 add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
2718 add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
2719 add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
2720 add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
2721 }
2722 } else {
2723 if( $permalink_structure ){
2724 $this->delim = '?';
2725 if( ! defined('USCES_CUSTOMER_URL') )
2726 define('USCES_CUSTOMER_URL', get_page_link(USCES_CART_NUMBER) . '?customerinfo=1');
2727 if( ! defined('USCES_CART_URL') )
2728 define('USCES_CART_URL', get_page_link(USCES_CART_NUMBER));
2729 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2730 define('USCES_LOSTMEMBERPASSWORD_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=lostmemberpassword');
2731 if( ! defined('USCES_NEWMEMBER_URL') )
2732 define('USCES_NEWMEMBER_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=newmember');
2733 if( ! defined('USCES_LOGIN_URL') )
2734 define('USCES_LOGIN_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=login');
2735 if( ! defined('USCES_LOGOUT_URL') )
2736 define('USCES_LOGOUT_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=logout');
2737 if( ! defined('USCES_MEMBER_URL') )
2738 define('USCES_MEMBER_URL', get_page_link(USCES_MEMBER_NUMBER));
2739 $inquiry_url = ( !isset( $this->options['inquiry_id'] ) || !( (int)$this->options['inquiry_id'] )) ? get_home_url() : get_page_link($this->options['inquiry_id']);
2740 if( ! defined('USCES_INQUIRY_URL') )
2741 define('USCES_INQUIRY_URL', $inquiry_url);
2742 if( ! defined('USCES_CART_NONSESSION_URL') )
2743 define('USCES_CART_NONSESSION_URL', get_page_link(USCES_CART_NUMBER));
2744 //20110208ysk start
2745 //define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2746 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2747 define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2748 //20110208ysk end
2749 }else{
2750 $this->delim = '&';
2751 if( ! defined('USCES_CUSTOMER_URL') )
2752 define('USCES_CUSTOMER_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1');
2753 if( ! defined('USCES_CART_URL') )
2754 define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2755 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2756 define('USCES_LOSTMEMBERPASSWORD_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=lostmemberpassword');
2757 if( ! defined('USCES_NEWMEMBER_URL') )
2758 define('USCES_NEWMEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=newmember');
2759 if( ! defined('USCES_LOGIN_URL') )
2760 define('USCES_LOGIN_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=login');
2761 if( ! defined('USCES_LOGOUT_URL') )
2762 define('USCES_LOGOUT_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2763 if( ! defined('USCES_CART_NONSESSION_URL') )
2764 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2765 if( ! defined('USCES_MEMBER_URL') )
2766 define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
2767 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option('home') . '/?page_id=' . $this->options['inquiry_id'];
2768 if( ! defined('USCES_INQUIRY_URL') )
2769 define('USCES_INQUIRY_URL', $inquiry_url);
2770 if( ! defined('USCES_CART_NONSESSION_URL') )
2771 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2772 //20110208ysk start
2773 //define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2774 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2775 define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2776 //20110208ysk end
2777 }
2778 }
2779 }
2780
2781 function regist_action(){
2782 usces_register_action('inCart', 'post', 'inCart', NULL, 'inCart');
2783 usces_register_action('upButton', 'post', 'upButton', NULL, 'upButton');
2784 usces_register_action('delButton', 'post', 'delButton', NULL, 'delButton');
2785 usces_register_action('backCart', 'post', 'backCart', NULL, 'backCart');
2786 usces_register_action('customerinfo', 'request', 'customerinfo', NULL, 'customerinfo');
2787 usces_register_action('backCustomer', 'post', 'backCustomer', NULL, 'backCustomer');
2788 usces_register_action('customerlogin', 'post', 'customerlogin', NULL, 'customerlogin');
2789 usces_register_action('reganddeliveryinfo', 'post', 'reganddeliveryinfo', NULL, 'reganddeliveryinfo');
2790 usces_register_action('deliveryinfo', 'post', 'deliveryinfo', NULL, 'deliveryinfo');
2791 usces_register_action('backDelivery', 'post', 'backDelivery', NULL, 'backDelivery');
2792 usces_register_action('confirm', 'request', 'confirm', NULL, 'confirm');
2793 usces_register_action('use_point', 'post', 'use_point', NULL, 'use_point');
2794 usces_register_action('backConfirm', 'post', 'backConfirm', NULL, 'backConfirm');
2795 usces_register_action('purchase', 'request', 'purchase', NULL, 'purchase');
2796 usces_register_action('acting_return', 'request', 'acting_return', NULL, 'acting_return');
2797 usces_register_action('settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon');
2798 usces_register_action('inquiry_button', 'post', 'inquiry_button', NULL, 'inquiry_button');
2799 usces_register_action('member_login', 'request', 'member_login', NULL, 'member_login_page');
2800 usces_register_action('regmember', 'request', 'regmember', NULL, 'regmember');
2801 usces_register_action('editmember', 'request', 'editmember', NULL, 'editmember');
2802 usces_register_action('deletemember', 'request', 'deletemember', NULL, 'deletemember');
2803 usces_register_action('page_login', 'get', 'page', 'login', 'member_login_page');
2804 usces_register_action('page_logout', 'get', 'page', 'logout', 'page_logout');
2805 usces_register_action('page_lostmemberpassword', 'get', 'page', 'lostmemberpassword', 'page_lostmemberpassword');
2806 usces_register_action('lostpassword', 'request', 'lostpassword', NULL, 'lostpassword');
2807 usces_register_action('uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword');
2808 usces_register_action('changepassword', 'request', 'changepassword', NULL, 'changepassword_page');
2809 usces_register_action('page_newmember', 'get', 'page', 'newmember', 'page_newmember');
2810 usces_register_action('usces_export', 'post', 'usces_export', NULL, 'usces_export');
2811 usces_register_action('usces_import', 'post', 'usces_import', NULL, 'usces_import');
2812 usces_register_action('page_search_item', 'get', 'page', 'search_item', 'page_search_item');
2813 usces_register_action('front_ajax', 'post', 'usces_ajax_action', NULL, 'front_ajax');
2814 }
2815
2816 function ad_controller(){
2817 global $usces_action;
2818 ksort($usces_action);
2819 //if($this->is_maintenance()){
2820 if($this->is_maintenance() and !is_user_logged_in()){//0000651
2821 $this->maintenance();
2822 }else{
2823 $action_array = array('inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer',
2824 'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point',
2825 'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login',
2826 'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword',
2827 'uscesmode_changepassword', 'changepassword', 'page_newmember', 'usces_export', 'usces_import',
2828 'page_search_item', 'front_ajax');
2829 $flg = 0;
2830 $res = true;
2831 foreach( $usces_action as $handle => $action ){
2832 extract($action);
2833 switch($type){
2834 case 'post':
2835 if( empty($value) ){
2836 if( isset($_POST[$key]) ){
2837 if(in_array($handle, $action_array)){
2838 $res = call_user_func(array($this, $function));
2839 }else{
2840 $res = call_user_func($function);
2841 }
2842 $flg = 1;
2843 }
2844 }else{
2845 if( isset($_POST[$key]) && $_POST[$key] == $value ){
2846 if(in_array($handle, $action_array)){
2847 $res = call_user_func(array($this, $function));
2848 }else{
2849 $res = call_user_func($function);
2850 }
2851 $flg = 1;
2852 }
2853 }
2854 break;
2855 case 'get':
2856 if( empty($value) ){
2857 if( isset($_GET[$key]) ){
2858 if(in_array($handle, $action_array)){
2859 $res = call_user_func(array($this, $function));
2860 }else{
2861 $res = call_user_func($function);
2862 }
2863 $flg = 1;
2864 }
2865 }else{
2866 if( isset($_GET[$key]) && $_GET[$key] == $value ){
2867 if(in_array($handle, $action_array)){
2868 $res = call_user_func(array($this, $function));
2869 }else{
2870 $res = call_user_func($function);
2871 }
2872 $flg = 1;
2873 }
2874 }
2875 break;
2876 case 'request':
2877 if( empty($value) ){
2878 if( isset($_REQUEST[$key]) ){
2879 if(in_array($handle, $action_array)){
2880 $res = call_user_func(array($this, $function));
2881 }else{
2882 $res = call_user_func($function);
2883 }
2884 $flg = 1;
2885 }
2886 }else{
2887 if( isset($_REQUEST[$key]) && $_REQUEST[$key] == $value ){
2888 if(in_array($handle, $action_array)){
2889 $res = call_user_func(array($this, $function));
2890 }else{
2891 $res = call_user_func($function);
2892 }
2893 $flg = 1;
2894 }
2895 }
2896 break;
2897 }
2898 if( ! $res ) break;
2899 }
2900 if( !$flg ) $this->default_page();
2901 }
2902 }
2903
2904 //action function------------------------------------------------------------
2905 function front_ajax(){
2906 switch ($_POST['usces_ajax_action']){
2907 case 'change_states':
2908 change_states_ajax();
2909 break;
2910 }
2911 do_action('usces_front_ajax');
2912 }
2913
2914 function maintenance(){
2915 $this->page = 'maintenance';
2916 add_action('the_post', array($this, 'action_cartFilter'));
2917 }
2918
2919 function inCart(){
2920 global $wp_query;
2921 $this->page = 'cart';
2922 $this->incart_check();
2923 $this->cart->inCart();
2924 add_action('the_post', array($this, 'action_cartFilter'));
2925 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2926 add_action('template_redirect', array($this, 'template_redirect'));
2927 }
2928
2929 function upButton(){
2930 global $wp_query;
2931 $this->page = 'cart';
2932 $this->cart->upCart();
2933 $this->error_message = $this->zaiko_check();
2934 add_action('the_post', array($this, 'action_cartFilter'));
2935 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2936 add_action('template_redirect', array($this, 'template_redirect'));
2937 }
2938
2939 function delButton(){
2940 global $wp_query;
2941 $this->page = 'cart';
2942 $this->cart->del_row();
2943 add_action('the_post', array($this, 'action_cartFilter'));
2944 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2945 add_action('template_redirect', array($this, 'template_redirect'));
2946 }
2947
2948 function backCart(){
2949 global $wp_query;
2950 $this->page = 'cart';
2951 add_action('the_post', array($this, 'action_cartFilter'));
2952 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2953 add_action('template_redirect', array($this, 'template_redirect'));
2954 }
2955
2956 function customerinfo(){
2957 global $wp_query;
2958 if( false === $this->cart->num_row() ){
2959 header('location: ' . get_option('home'));
2960 exit;
2961 }
2962 $this->cart->entry();
2963 $this->error_message = $this->zaiko_check();
2964 $this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message );
2965 if( WCUtils::is_blank($this->error_message) ){
2966 if($this->is_member_logged_in()){
2967 //20100818ysk start
2968 //$this->page = 'delivery';
2969 $this->error_message = has_custom_customer_field_essential();
2970 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'delivery' : 'customer';
2971 //20100818ysk end
2972 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
2973 }else{
2974 $this->page = 'customer';
2975 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
2976 }
2977 }else{
2978 $this->page = 'cart';
2979 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2980 }
2981 if ( !$this->cart->is_order_condition() ) {
2982 $order_conditions = $this->get_condition();
2983 $this->cart->set_order_condition($order_conditions);
2984 }
2985 add_action('the_post', array($this, 'action_cartFilter'));
2986 add_action('template_redirect', array($this, 'template_redirect'));
2987 }
2988
2989 function backCustomer(){
2990 global $wp_query;
2991 if( false === $this->cart->num_row() ){
2992 header('location: ' . get_option('home'));
2993 exit;
2994 }
2995 $this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' );
2996 add_action('the_post', array($this, 'action_cartFilter'));
2997 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
2998 add_action('template_redirect', array($this, 'template_redirect'));
2999 // $this->cart->entry();
3000 // $this->error_message = $this->delivery_check();
3001 // $this->page = ($this->error_message == '') ? 'customer' : 'delivery';
3002 }
3003
3004 function customerlogin(){
3005 global $wp_query;
3006 if( false === $this->cart->num_row() ){
3007 header('location: ' . get_option('home'));
3008 exit;
3009 }
3010 //20100818ysk start
3011 //$this->cart->entry();
3012 //$this->page = ($this->member_login() == 'member') ? 'delivery' : 'customer';
3013 if($this->member_login() == 'member') {
3014 $this->cart->entry();
3015 $this->error_message = has_custom_customer_field_essential();
3016 if( WCUtils::is_blank($this->error_message) ){
3017 $this->page = 'delivery';
3018 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3019 }else{
3020 $this->page = 'customer';
3021 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3022 }
3023 } else {
3024 $this->cart->entry();
3025 $this->page = 'customer';
3026 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3027 }
3028 //20100818ysk end
3029 add_action('the_post', array($this, 'action_cartFilter'));
3030 add_action('template_redirect', array($this, 'template_redirect'));
3031 }
3032
3033 function reganddeliveryinfo(){
3034 global $wp_query;
3035 if( false === $this->cart->num_row() ){
3036 header('location: ' . get_option('home'));
3037 exit;
3038 }
3039 $this->cart->entry();
3040 //20110715ysk start 0000203
3041 //$_POST['member_regmode'] = 'newmemberfromcart';
3042 if(empty($_POST['member_regmode']) or $_POST['member_regmode'] != 'editmemberfromcart') $_POST['member_regmode'] = 'newmemberfromcart';
3043 //20110715ysk end
3044
3045 if( $this->regist_member() == 'newcompletion' ){
3046 $this->page = 'delivery';
3047 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3048 }else{
3049 $this->page = 'customer';
3050 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3051 }
3052 add_action('the_post', array($this, 'action_cartFilter'));
3053 add_action('template_redirect', array($this, 'template_redirect'));
3054 }
3055
3056 function deliveryinfo(){
3057 global $wp_query;
3058 if( false === $this->cart->num_row() ){
3059 header('location: ' . get_option('home'));
3060 exit;
3061 }
3062 $this->cart->entry();
3063 $this->error_message = $this->customer_check();
3064
3065 if( WCUtils::is_blank($this->error_message) ){
3066 $this->page = 'delivery';
3067 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3068 }else{
3069 $this->page = 'customer';
3070 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3071 }
3072 add_action('the_post', array($this, 'action_cartFilter'));
3073 add_action('template_redirect', array($this, 'template_redirect'));
3074 }
3075
3076 function backDelivery(){
3077 global $wp_query;
3078 if( false === $this->cart->num_row() ){
3079 header('location: ' . get_option('home'));
3080 exit;
3081 }
3082 $this->page = 'delivery';
3083 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3084 add_action('the_post', array($this, 'action_cartFilter'));
3085 add_action('template_redirect', array($this, 'template_redirect'));
3086 }
3087
3088 function confirm(){
3089 global $wpdb, $wp_query;
3090 if( false === $this->cart->num_row() ){
3091 header('location: ' . get_option('home'));
3092 exit;
3093 }
3094
3095 $this->cart->entry();
3096 $this->error_message = $this->zaiko_check();
3097 if( $this->error_message != '' ){
3098 $this->page = 'cart';
3099 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3100 add_action('the_post', array($this, 'action_cartFilter'));
3101 add_action('template_redirect', array($this, 'template_redirect'));
3102 return;
3103 }
3104
3105 $this->set_reserve_pre_order_id();
3106 if(isset($_POST['confirm'])){
3107 $this->error_message = $this->delivery_check();
3108 }
3109 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'confirm' : 'delivery';
3110 if( WCUtils::is_blank($this->error_message) ){
3111 //20120919ysk start 0000573
3112 if( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) {
3113 unset( $_SESSION['usces_entry']['order']['usedpoint'] );//20120914ysk 0000566
3114 $member_table = $wpdb->prefix."usces_member";
3115 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID']);
3116 $mem_point = $wpdb->get_var( $query );
3117 $_SESSION['usces_member']['point'] = $mem_point;
3118 }
3119 //20120919ysk end
3120 $this->page = 'confirm';
3121 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3122 }else{
3123 $this->page = 'delivery';
3124 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3125 }
3126 add_action('the_post', array($this, 'action_cartFilter'));
3127 add_action('template_redirect', array($this, 'template_redirect'));
3128 }
3129
3130 function use_point(){
3131 global $wp_query;
3132 $this->cart->entry();
3133 $this->error_message = $this->point_check( $this->cart->get_entry() );
3134 $this->page = 'confirm';
3135 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3136 add_action('the_post', array($this, 'action_cartFilter'));
3137 add_action('template_redirect', array($this, 'template_redirect'));
3138 }
3139
3140 function backConfirm(){
3141 global $wp_query;
3142 if( false === $this->cart->num_row() ){
3143 header('location: ' . get_option('home'));
3144 exit;
3145 }
3146 $this->page = 'confirm';
3147 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3148 add_action('the_post', array($this, 'action_cartFilter'));
3149 add_action('template_redirect', array($this, 'template_redirect'));
3150 }
3151
3152 function purchase(){
3153 global $wp_query;
3154 if( false === $this->cart->num_row() ){
3155 header('location: ' . get_option('home'));
3156 exit;
3157 }
3158
3159 if( !apply_filters('usces_purchase_check', true) ) return;
3160
3161 do_action('usces_purchase_validate');
3162 $entry = $this->cart->get_entry();
3163 $this->error_message = $this->zaiko_check();
3164 if( WCUtils::is_blank($this->error_message) && 0 < $this->cart->num_row()){
3165 $actinc_status = '';
3166 $payments = $this->getPayments( $entry['order']['payment_name'] );
3167 if( substr($payments['settlement'], 0, 6) == 'acting' && $entry['order']['total_full_price'] > 0 ){
3168 $acting_flg = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3169 $query = '';
3170 foreach($_POST as $key => $value){
3171 if($key != 'purchase')
3172 $query .= '&' . $key . '=' . urlencode(maybe_serialize($value));
3173 }
3174 $actinc_status = $this->acting_processing($acting_flg, $query);
3175 }
3176
3177 if($actinc_status == 'error'){
3178 $this->page = 'error';
3179 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3180 }else{
3181 $res = $this->order_processing();
3182 if( 'ordercompletion' == $res ){
3183 $this->page = 'ordercompletion';
3184 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3185 }else{
3186 $this->page = 'error';
3187 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3188 }
3189 }
3190 }else{
3191 $this->page = 'cart';
3192 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3193 }
3194 add_action('the_post', array($this, 'action_cartFilter'));
3195 add_action('template_redirect', array($this, 'template_redirect'));
3196 }
3197
3198 function acting_return(){
3199 global $wp_query;
3200 $entry = $this->cart->get_entry();
3201
3202 //20110208ysk start
3203 /* if( 'paypal_ipn' == $_REQUEST['acting_return'] ){
3204 usces_log('paypal_ipn in ', 'acting_transaction.log');
3205 require_once($this->options['settlement_path'] . 'paypal.php');
3206 $ipn_res = paypal_ipn_check($usces_paypal_url);
3207 if( $ipn_res[0] === true ){
3208 $res = $this->order_processing( $ipn_res );
3209 if( 'ordercompletion' == $res ){
3210 $this->cart->crear_cart();
3211 }else{
3212 usces_log('paypal_ipn regorder error (acting_return) : '.print_r($entry, true), 'acting_transaction.log');
3213 }
3214 }
3215 exit;
3216 }*/
3217 //20110208ysk end
3218 if( false === $this->cart->num_row() && ('paypal' != $_GET['acting'] && 1 !== (int)$_GET['acting_return']) ){
3219 header('location: ' . get_option('home'));
3220 exit;
3221 }
3222
3223 $this->payment_results = usces_check_acting_return();
3224
3225 if( isset($this->payment_results[0]) && $this->payment_results[0] === 'duplicate' ){
3226
3227 header('location: ' . get_option('home'));
3228 exit;
3229
3230 }else if( isset($this->payment_results[0]) && $this->payment_results[0] ){//result OK
3231
3232 if( ! $this->payment_results['reg_order'] ){//without Registration Order
3233 $this->page = 'ordercompletion';
3234 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3235
3236 }else{
3237 $res = $this->order_processing( $this->payment_results );
3238
3239 if( 'ordercompletion' == $res ){
3240 $this->page = 'ordercompletion';
3241 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3242 }else{
3243 $this->page = 'error';
3244 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3245 }
3246 }
3247
3248 }else{//result NG
3249 $this->page = 'error';
3250 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3251 }
3252
3253 add_action('the_post', array($this, 'action_cartFilter'));
3254 add_action('template_redirect', array($this, 'template_redirect'));
3255 }
3256
3257 function settlement_epsilon(){
3258 global $wp_query;
3259 require_once($this->options['settlement_path'] . 'epsilon.php');
3260 }
3261
3262 function inquiry_button(){
3263 if( 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']) ){
3264 $res = $this->inquiry_processing();
3265 }else{
3266 $res = 'deficiency';
3267 }
3268
3269 $this->page = $res;
3270 }
3271
3272 function member_login_page(){
3273 global $wp_query;
3274 $res = $this->member_login();
3275 if( 'member' == $res ){
3276 $this->page = 'member';
3277 do_action('usces_action_member_logined');
3278 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_member');
3279 }elseif( 'login' == $res ){
3280 $this->page = 'login';
3281 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_login');
3282 }
3283 add_action('the_post', array($this, 'action_memberFilter'));
3284 add_action('template_redirect', array($this, 'template_redirect'));
3285 }
3286
3287 function regmember(){
3288 global $wp_query;
3289 $res = $this->regist_member();
3290 if( 'editmemberform' == $res ){
3291 $this->page = 'editmemberform';
3292 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3293 }elseif( 'newcompletion' == $res ){
3294 $this->page = 'newcompletion';
3295 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3296 }else{
3297 $this->page = $res;
3298 }
3299 add_action('the_post', array($this, 'action_memberFilter'));
3300 add_action('template_redirect', array($this, 'template_redirect'));
3301 }
3302
3303 function editmember(){
3304 global $wp_query;
3305 $res = $this->regist_member();
3306 if( 'editmemberform' == $res ){
3307 $this->page = 'editmemberform';
3308 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3309 }elseif( 'newcompletion' == $res ){
3310 $this->page = 'newcompletion';
3311 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3312 }else{
3313 $this->page = $res;
3314 }
3315 add_action('the_post', array($this, 'action_memberFilter'));
3316 add_action('template_redirect', array($this, 'template_redirect'));
3317 }
3318
3319 function deletemember(){
3320 $res = $this->delete_member();
3321 if( $res ){
3322 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember');
3323 $this->member_logout();
3324 }else{
3325 $this->page = 'editmemberform';
3326 add_action('the_post', array($this, 'action_memberFilter'));
3327 }
3328 add_action('template_redirect', array($this, 'template_redirect'));
3329 }
3330
3331 function page_logout(){
3332 global $wp_query;
3333 $this->member_logout();
3334 add_action('the_post', array($this, 'action_memberFilter'));
3335 add_action('template_redirect', array($this, 'template_redirect'));
3336 }
3337
3338 function page_lostmemberpassword(){
3339 global $wp_query;
3340 $this->page = 'lostmemberpassword';
3341 add_action('the_post', array($this, 'action_memberFilter'));
3342 add_action('template_redirect', array($this, 'template_redirect'));
3343 }
3344
3345 function lostpassword(){
3346 global $wp_query;
3347 $this->error_message = $this->lostpass_mailaddcheck();
3348 if ( $this->error_message != '' ) {
3349 $this->page = 'lostmemberpassword';
3350 } else {
3351 $res = $this->lostmail();
3352 $this->page = $res;//'lostcompletion';
3353 }
3354 add_action('the_post', array($this, 'action_memberFilter'));
3355 add_action('template_redirect', array($this, 'template_redirect'));
3356 }
3357
3358 function uscesmode_changepassword(){
3359 global $wp_query;
3360 $this->page = 'changepassword';
3361 add_action('the_post', array($this, 'action_memberFilter'));
3362 add_action('template_redirect', array($this, 'template_redirect'));
3363 }
3364
3365 function changepassword_page(){
3366 global $wp_query;
3367 $this->error_message = $this->changepass_check();
3368 if ( $this->error_message != '' ) {
3369 $this->page = 'changepassword';
3370 } else {
3371 $res = $this->changepassword();
3372 $this->page = $res;//'changepasscompletion';
3373 }
3374 add_action('the_post', array($this, 'action_memberFilter'));
3375 add_action('template_redirect', array($this, 'template_redirect'));
3376 }
3377
3378 function page_newmember(){
3379
3380 global $wp_query;
3381 $this->page = 'newmemberform';
3382 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform');
3383 add_action('the_post', array($this, 'action_memberFilter'));
3384 add_action('template_redirect', array($this, 'template_redirect'));
3385 }
3386
3387 function usces_export(){
3388 $this->export();
3389 }
3390
3391 function usces_import(){
3392 $this->import();
3393 }
3394
3395 function page_search_item(){
3396 global $wp_query;
3397 $this->page = 'search_item';
3398 //add_action('template_redirect', array($this, 'action_search_item'));
3399 add_action('the_post', array($this, 'action_cartFilter'));
3400 add_action('template_redirect', array($this, 'template_redirect'));
3401 }
3402
3403 function default_page(){
3404 global $wp_query;
3405 add_action('the_post', array($this, 'goDefaultPage'));
3406 add_action('template_redirect', array($this, 'template_redirect'));
3407 }
3408 //--------------------------------------------------------------------------------------
3409
3410
3411 function goDefaultPage(){
3412 global $post;
3413
3414 if( $post->ID == USCES_CART_NUMBER ) {
3415
3416 $this->page = 'cart';
3417 add_filter('the_content', array($this, 'filter_cartContent'),20);
3418
3419 }else if( $post->ID == USCES_MEMBER_NUMBER ) {
3420
3421 $this->page = 'member';
3422 add_filter('the_content', array($this, 'filter_memberContent'),20);
3423
3424 }else if( !is_singular() ) {
3425 $this->page = 'wp_search';
3426 add_filter('the_excerpt', array($this, 'filter_cartContent'),20);
3427 add_filter('the_content', array($this, 'filter_cartContent'),20);
3428
3429 }else{
3430 add_filter('the_content', array(&$this, 'filter_itemPage'));
3431
3432 }
3433 }
3434
3435 function template_redirect () {
3436 global $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode;
3437
3438 if( apply_filters('usces_action_template_redirect', false) ) return;//Deprecated
3439 if( apply_filters('usces_filter_template_redirect', false) ) return;
3440
3441 if( is_single() && 'item' == $post->post_mime_type ) {
3442 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_item_single.php') ){
3443 if( !post_password_required($post) ){
3444 include(get_stylesheet_directory() . '/wc_templates/wc_item_single.php');
3445 exit;
3446 }
3447 }
3448 }elseif( isset($_REQUEST['page']) && ('search_item' == $_REQUEST['page'] || 'usces_search' == $_REQUEST['page']) && $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3449 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_search_page.php') ){
3450 include(get_stylesheet_directory() . '/wc_templates/wc_search_page.php');
3451 exit;
3452 }
3453
3454 }else if( $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3455 switch( $this->page ){
3456 case 'customer':
3457 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php') ){
3458 usces_get_entries();
3459 usces_get_member_regmode();
3460 include(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php');
3461 exit;
3462 }
3463 break;
3464 case 'delivery':
3465 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php') ){
3466 usces_get_entries();
3467 usces_get_carts();
3468 include(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php');
3469 exit;
3470 }
3471 break;
3472 case 'confirm':
3473 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php') ){
3474 usces_get_entries();
3475 usces_get_carts();
3476 usces_get_members();
3477 include(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php');
3478 exit;
3479 }
3480 break;
3481 case 'ordercompletion':
3482 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php') ){
3483 usces_get_entries();
3484 usces_get_carts();
3485 include(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php');
3486 exit;
3487 }
3488 break;
3489 case 'error':
3490 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php') ){
3491 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php');
3492 exit;
3493 }
3494 break;
3495 case 'cart':
3496 default:
3497 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php') ){
3498 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php');
3499 exit;
3500 }
3501
3502 }
3503 }else if($this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
3504
3505 }else if( $this->is_member_page($_SERVER['REQUEST_URI']) ){
3506 if($this->options['membersystem_state'] != 'activate') return;
3507
3508 if( $this->is_member_logged_in() ) {
3509 $member_regmode = 'editmemberform';
3510 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php') ){
3511 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php');
3512 exit;
3513 }
3514
3515 } else {
3516
3517 switch( $this->page ){
3518 case 'login':
3519 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3520 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3521 exit;
3522 }
3523 break;
3524 case 'newmemberform':
3525 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php') ){
3526 $member_regmode = 'newmemberform';
3527 include(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php');
3528 exit;
3529 }
3530 break;
3531 case 'lostmemberpassword':
3532 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php') ){
3533 include(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php');
3534 exit;
3535 }
3536 break;
3537 case 'changepassword':
3538 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php') ){
3539 include(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php');
3540 exit;
3541 }
3542 break;
3543 case 'newcompletion':
3544 case 'editcompletion':
3545 case 'lostcompletion':
3546 case 'changepasscompletion':
3547 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php') ){
3548 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php');
3549 exit;
3550 }
3551 break;
3552 default:
3553 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3554 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3555 exit;
3556 }
3557 }
3558 }
3559
3560 }else{
3561 // remove_action('the_post', array(&$this, 'goDefaultPage'));
3562 }
3563 }
3564
3565 function import() {
3566 $res = usces_import_xml();
3567 if ( $res === false ) :
3568 $this->action_status = 'error';
3569 //$this->action_message = __('Import was not completed.', 'usces');
3570 else :
3571 $this->action_status = 'success';
3572 $this->action_message = __('Import is cmpleted', 'usces');
3573 endif;
3574
3575 // require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
3576 }
3577
3578 function export() {
3579 $filename = 'usces.' . substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10) . '.xml';
3580
3581 header('Content-Description: File Transfer');
3582 header("Content-Disposition: attachment; filename=$filename");
3583 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
3584
3585 usces_export_xml();
3586 die();
3587
3588 }
3589
3590
3591 function changepassword() {
3592 global $wpdb;
3593
3594 if ( !isset($_SESSION['usces_lostmail']) ) :
3595 $this->error_message = __('Failed in update due to time-out', 'usces');
3596 return 'login';
3597 else :
3598
3599 $member_table = $wpdb->prefix . "usces_member";
3600
3601 $query = $wpdb->prepare("UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s",
3602 md5(trim($_POST['loginpass1'])), $_SESSION['usces_lostmail']);
3603 $res = $wpdb->query( $query );
3604 //$res = $wpdb->last_results;
3605
3606 if ( $res === false ) :
3607 $this->error_message = __('Error: failure in updating password', 'usces');
3608 return 'login';
3609 else :
3610 return 'changepasscompletion';
3611 endif;
3612
3613 endif;
3614 }
3615
3616 function lostmail() {
3617 $delim = apply_filters( 'usces_filter_delim', $this->delim );
3618
3619 $_SESSION['usces_lostmail'] = trim($_POST['loginmail']);
3620 $id = session_id();
3621 $uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword';
3622 $res = usces_lostmail($uri);
3623 return $res;
3624
3625 }
3626
3627 function regist_member() {
3628 global $wpdb;
3629 $_POST = $this->stripslashes_deep_post($_POST);
3630
3631 $member = $this->get_member();
3632 $mode = $_POST['member_regmode'];
3633 $member_table = $wpdb->prefix . "usces_member";
3634 $member_meta_table = $wpdb->prefix . "usces_member_meta";
3635
3636 //20110715ysk start 0000203
3637 //$error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3638 $error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' or $_POST['member_regmode'] == 'editmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3639 //20110715ysk end
3640
3641 if ( $error_mes != '' ) {
3642
3643 $this->error_message = $error_mes;
3644 return $mode;
3645
3646 } elseif ( $_POST['member_regmode'] == 'editmemberform' ) {
3647
3648 $this->get_current_member();
3649 $mem_id = $this->current_member['id'];
3650 do_action('usces_action_pre_edit_memberdata', $_POST['member'], $mem_id);
3651
3652 //20130802ysk start 0000741
3653 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3654 $id = $wpdb->get_var( $query );
3655 if ( !empty($id) and $id != $mem_id ) {
3656 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3657 return $mode;
3658 }
3659 //20130802ysk end
3660
3661 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3662 $pass = $wpdb->get_var( $query );
3663
3664 $password = ( !empty($_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? md5(trim($_POST['member']['password1'])) : $pass;
3665 $query = $wpdb->prepare("UPDATE $member_table SET
3666 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3667 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3668 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3669 $password,
3670 trim($_POST['member']['name1']),
3671 trim($_POST['member']['name2']),
3672 trim($_POST['member']['name3']),
3673 trim($_POST['member']['name4']),
3674 trim($_POST['member']['zipcode']),
3675 trim($_POST['member']['pref']),
3676 trim($_POST['member']['address1']),
3677 trim($_POST['member']['address2']),
3678 trim($_POST['member']['address3']),
3679 trim($_POST['member']['tel']),
3680 trim($_POST['member']['fax']),
3681 trim($_POST['member']['mailaddress1']),
3682 $mem_id
3683 );
3684 $res = $wpdb->query( $query );
3685
3686 if( $res !== false ){
3687 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $mem_id);
3688 //20100818ysk start
3689 $res = $this->reg_custom_member($mem_id);
3690 //20100818ysk end
3691 do_action('usces_action_edit_memberdata', $_POST['member'], $mem_id);
3692 $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" );
3693 $query = $wpdb->prepare("DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )",
3694 $mem_id
3695 );
3696 $res = $wpdb->query( $query );
3697
3698 $this->get_current_member();
3699 return 'editmemberform';
3700
3701 } else {
3702 $this->error_message = __('Error:failure in update', 'usces');
3703 return $mode;
3704 }
3705
3706 } elseif ( $_POST['member_regmode'] == 'newmemberform' ) {
3707
3708 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3709 $id = $wpdb->get_var( $query );
3710 if ( !empty($id) ) {
3711 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3712 return $mode;
3713 } else {
3714
3715 $point = $this->options['start_point'];
3716 $pass = md5(trim($_POST['member']['password1']));
3717 $query = $wpdb->prepare("INSERT INTO $member_table
3718 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3719 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3720 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3721 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3722 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3723 trim($_POST['member']['mailaddress1']),
3724 $pass,
3725 0,
3726 "",
3727 $point,
3728 trim($_POST['member']['name1']),
3729 trim($_POST['member']['name2']),
3730 trim($_POST['member']['name3']),
3731 trim($_POST['member']['name4']),
3732 trim($_POST['member']['zipcode']),
3733 trim($_POST['member']['pref']),
3734 trim($_POST['member']['address1']),
3735 trim($_POST['member']['address2']),
3736 trim($_POST['member']['address3']),
3737 trim($_POST['member']['tel']),
3738 trim($_POST['member']['fax']),
3739 '',
3740 '',
3741 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3742 '');
3743 $res = $wpdb->query( $query );
3744
3745 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3746 //$this->get_current_member();
3747 if($res !== false) {
3748 $user = $_POST['member'];
3749 $user['ID'] = $wpdb->insert_id;
3750 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $user['ID']);
3751 //20110714ysk start 0000207
3752 //20100818ysk start
3753 //$res = $this->reg_custom_member($wpdb->insert_id);
3754 $res = $this->reg_custom_member($user['ID']);
3755 //20100818ysk end
3756 //20110714ysk end
3757 $mser = usces_send_regmembermail($user);
3758
3759 do_action('usces_action_member_registered', $_POST['member'], $user['ID']);
3760
3761 return 'newcompletion';
3762
3763 } else {
3764 $this->error_message = __('Error:failure in update', 'usces');
3765 return $mode;
3766 }
3767 }
3768
3769 } elseif ( $_POST['member_regmode'] == 'newmemberfromcart' ) {
3770
3771 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1']));
3772 $id = $wpdb->get_var( $query );
3773 if ( !empty($id) ) {
3774 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3775 return $mode;
3776 } else {
3777
3778 $point = $this->options['start_point'];
3779 $pass = md5(trim($_POST['customer']['password1']));
3780 $query = $wpdb->prepare("INSERT INTO $member_table
3781 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3782 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3783 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3784 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3785 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3786 trim($_POST['customer']['mailaddress1']),
3787 $pass,
3788 0,
3789 "",
3790 $point,
3791 trim($_POST['customer']['name1']),
3792 trim($_POST['customer']['name2']),
3793 trim($_POST['customer']['name3']),
3794 trim($_POST['customer']['name4']),
3795 trim($_POST['customer']['zipcode']),
3796 trim($_POST['customer']['pref']),
3797 trim($_POST['customer']['address1']),
3798 trim($_POST['customer']['address2']),
3799 trim($_POST['customer']['address3']),
3800 trim($_POST['customer']['tel']),
3801 trim($_POST['customer']['fax']),
3802 '',
3803 '',
3804 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3805 '');
3806 $res = $wpdb->query( $query );
3807
3808 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3809 //$this->get_current_member();
3810 if($res !== false) {
3811 //20110714ysk start 0000207
3812 $member_id = $wpdb->insert_id;
3813 //$this->set_member_meta_value('customer_country', $_POST['member']['country'], $wpdb->insert_id);
3814 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $member_id);
3815 //20100818ysk start
3816 //$res = $this->reg_custom_member($wpdb->insert_id);
3817 $res = $this->reg_custom_member($member_id);
3818 //20100818ysk end
3819 //20110714ysk end
3820 //usces_send_regmembermail();
3821 do_action('usces_action_member_registered', $_POST['customer'], $member_id);
3822 $user = $_POST['customer'];
3823 $user['ID'] = $member_id;
3824 $mser = usces_send_regmembermail($user);
3825 $_POST['loginmail'] = trim($_POST['customer']['mailaddress1']);
3826 $_POST['loginpass'] = trim($_POST['customer']['password1']);
3827 if( $this->member_login() == 'member' ){
3828 $_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart';
3829 return 'newcompletion';
3830 }
3831
3832 } else {
3833 $this->error_message = __('Error:failure in update', 'usces');
3834 return $mode;
3835 }
3836 }
3837
3838 //20110715ysk start 0000203
3839 } elseif ( $_POST['member_regmode'] == 'editmemberfromcart' ) {
3840
3841 $this->get_current_member();
3842 $mem_id = $this->current_member['id'];
3843 do_action('usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id);
3844
3845 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3846 $pass = $wpdb->get_var( $query );
3847
3848 $password = ( !empty($_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? md5(trim($_POST['customer']['password1'])) : $pass;
3849 $query = $wpdb->prepare("UPDATE $member_table SET
3850 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3851 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3852 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3853 $password,
3854 trim($_POST['customer']['name1']),
3855 trim($_POST['customer']['name2']),
3856 trim($_POST['customer']['name3']),
3857 trim($_POST['customer']['name4']),
3858 trim($_POST['customer']['zipcode']),
3859 trim($_POST['customer']['pref']),
3860 trim($_POST['customer']['address1']),
3861 trim($_POST['customer']['address2']),
3862 trim($_POST['customer']['address3']),
3863 trim($_POST['customer']['tel']),
3864 trim($_POST['customer']['fax']),
3865 trim($_POST['customer']['mailaddress1']),
3866 $mem_id
3867 );
3868 $res = $wpdb->query( $query );
3869 if( $res !== false ){
3870 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $mem_id);
3871 $res = $this->reg_custom_member($mem_id);
3872 do_action('usces_action_edit_memberdata', $_POST['customer'], $mem_id);
3873 unset($_SESSION['usces_member']);
3874 $this->member_just_login(trim($_POST['customer']['mailaddress1']), trim($_POST['customer']['password1']));
3875 return 'newcompletion';
3876
3877 } else {
3878 $this->error_message = __('Error:failure in update', 'usces');
3879 return $mode;
3880 }
3881 //20110715ysk end
3882 }
3883 }
3884
3885 function delete_member() {
3886 if( ! $this->is_member_logged_in() )
3887 return false;
3888 $mem = $this->get_member();
3889 if( ! $mem['ID'] )
3890 return false;
3891
3892 $res = usces_delete_memberdata( $mem['ID'] );
3893 if( $res ) {
3894 usces_send_delmembermail( $mem );
3895 }
3896
3897 return $res;
3898 }
3899
3900 function is_member_logged_in( $id = false ) {
3901 if( $id === false ){
3902 if( !empty($_SESSION['usces_member']['ID']) )
3903 return true;
3904 else
3905 return false;
3906 }else{
3907 if( !empty($_SESSION['usces_member']['ID']) && $_SESSION['usces_member']['ID'] == $id )
3908 return true;
3909 else
3910 return false;
3911 }
3912 }
3913
3914 function is_member($email) {
3915 global $wpdb;
3916
3917 $member_table = $wpdb->prefix . "usces_member";
3918 $query = $wpdb->prepare("SELECT mem_email FROM $member_table WHERE mem_email = %s", $email);
3919 $member = $wpdb->get_row( $query, ARRAY_A );
3920 if ( empty($member) ) {
3921 return false;
3922 }else{
3923 return true;
3924 }
3925 }
3926
3927 function member_login() {
3928 global $wpdb;
3929 $_POST = $this->stripslashes_deep_post($_POST);
3930
3931 $cookie = $this->get_cookie();
3932
3933
3934 if ( isset($cookie['rme']) && $cookie['rme'] == 'forever' && !isset($_POST['rememberme']) && !isset($_POST['loginmail'])) {
3935 $email = $cookie['name'];
3936 $member_table = $wpdb->prefix . "usces_member";
3937
3938 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
3939 $id = $wpdb->get_var( $query );
3940
3941 if ( !$id ) {
3942 $this->current_member['email'] = htmlspecialchars($email);
3943 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
3944 return 'login';
3945 } else {
3946 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s", $email);
3947 $member = $wpdb->get_row( $query, ARRAY_A );
3948 if ( empty($member) ) {
3949 $this->current_member['email'] = htmlspecialchars($email);
3950 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
3951 return 'login';
3952 } else {
3953 $_SESSION['usces_member']['ID'] = $member['ID'];
3954 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
3955 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
3956 $_SESSION['usces_member']['point'] = $member['mem_point'];
3957 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
3958 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
3959 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
3960 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
3961 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
3962 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
3963 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
3964 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
3965 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
3966 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
3967 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
3968 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
3969 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
3970 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
3971 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
3972 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
3973 $_SESSION['usces_member']['status'] = $member['mem_status'];
3974 //20100818ysk start
3975 $this->set_session_custom_member($member['ID']);
3976 //20100818ysk end
3977 $this->get_current_member();
3978
3979 do_action( 'usces_action_after_login' );
3980 return apply_filters( 'usces_filter_member_login', 'member', $member );
3981 }
3982 }
3983 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginmail']) && isset($_POST['loginpass']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
3984 return 'login';
3985 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
3986 $this->current_member['email'] = trim($_POST['loginmail']);
3987 $this->error_message = __('<b>Error:</b> Enter the password.', 'usces');
3988 return 'login';
3989 } else if ( !isset($_POST['loginmail']) ){
3990 return 'login';
3991 } else {
3992 $email = isset($_POST['loginmail']) ? trim($_POST['loginmail']) : '';
3993 $pass = isset($_POST['loginpass']) ? md5(trim($_POST['loginpass'])) : '';
3994 $member_table = $wpdb->prefix . "usces_member";
3995
3996 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
3997 $id = $wpdb->get_var( $query );
3998
3999 if ( !$id ) {
4000 $this->current_member['email'] = htmlspecialchars($email);
4001 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
4002 return 'login';
4003 } else {
4004 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4005 $member = $wpdb->get_row( $query, ARRAY_A );
4006 if ( empty($member) ) {
4007 $this->current_member['email'] = htmlspecialchars($email);
4008 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4009 return 'login';
4010 } else {
4011 $_SESSION['usces_member']['ID'] = $member['ID'];
4012 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4013 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4014 $_SESSION['usces_member']['point'] = $member['mem_point'];
4015 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4016 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4017 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4018 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4019 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4020 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4021 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4022 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4023 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4024 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4025 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4026 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4027 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4028 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4029 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4030 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4031 $_SESSION['usces_member']['status'] = $member['mem_status'];
4032 //20100818ysk start
4033 $this->set_session_custom_member($member['ID']);
4034 //20100818ysk end
4035 $this->get_current_member();
4036
4037 if( isset($_POST['rememberme']) ){
4038 $cookie['name'] = $email;
4039 $cookie['rme'] = 'forever';
4040 $this->set_cookie($cookie);
4041 }else{
4042 $cookie['name'] = '';
4043 $cookie['rme'] = '';
4044 $this->set_cookie($cookie);
4045 }
4046
4047 do_action( 'usces_action_after_login' );
4048 return apply_filters( 'usces_filter_member_login', 'member', $member );
4049 }
4050 }
4051 }
4052 }
4053
4054 function member_just_login($email, $pass) {
4055 global $wpdb;
4056 $pass = md5($pass);
4057 $member_table = $wpdb->prefix . "usces_member";
4058
4059 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4060 $member = $wpdb->get_row( $query, ARRAY_A );
4061 if ( empty($member) ) {
4062 $this->current_member['email'] = htmlspecialchars($email);
4063 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4064 return 'login';
4065 } else {
4066 $_SESSION['usces_member']['ID'] = $member['ID'];
4067 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4068 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4069 $_SESSION['usces_member']['point'] = $member['mem_point'];
4070 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4071 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4072 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4073 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4074 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4075 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4076 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4077 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4078 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4079 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4080 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4081 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4082 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4083 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4084 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4085 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4086 $_SESSION['usces_member']['status'] = $member['mem_status'];
4087 //20100818ysk start
4088 $this->set_session_custom_member($member['ID']);
4089 //20100818ysk end
4090 $this->get_current_member();
4091
4092 // $cookie = $this->get_cookie();
4093 // if(isset($_POST['rememberme']) && $cookie){
4094 // $cookie['name'] = $email;
4095 // $cookie['pass'] = trim($_POST['loginpass']);
4096 // $this->set_cookie($cookie);
4097 // }else{
4098 // $cookie['name'] = '';
4099 // $cookie['pass'] = '';
4100 // $this->set_cookie($cookie);
4101 // }
4102
4103 do_action( 'usces_action_after_login' );
4104 return apply_filters( 'usces_filter_member_login', 'member', $member );
4105 }
4106 }
4107
4108 function member_logout() {
4109 unset($_SESSION['usces_member'], $_SESSION['usces_entry']);
4110 do_action('usces_action_member_logout');
4111 wp_redirect(get_option('home'));
4112 exit;
4113 }
4114
4115 function get_current_member() {
4116
4117 if ( isset($_SESSION['usces_member']['ID']) ) {
4118 $this->current_member['id'] = $_SESSION['usces_member']['ID'];
4119 $this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return');
4120 } else {
4121 $this->current_member['id'] = 0;
4122 $this->current_member['name'] = __('guest', 'usces');
4123 }
4124 }
4125
4126 function get_member() {
4127 $res = array(
4128 'ID' => '',
4129 'registered' => '',
4130 'mailaddress1' => '',
4131 'mailaddress2' => '',
4132 'password1' => '',
4133 'password2' => '',
4134 'point' => '',
4135 'name1' => '',
4136 'name2' => '',
4137 'name3' => '',
4138 'name4' => '',
4139 'zipcode' => '',
4140 'address1' => '',
4141 'address2' => '',
4142 'address3' => '',
4143 'tel' => '',
4144 'fax' => '',
4145 'country' => '',
4146 'pref' => '',
4147 'status' => ''
4148 );
4149 if(!empty($_SESSION['usces_member'])) {
4150 foreach ( $_SESSION['usces_member'] as $key => $value ) {
4151 //20100818ysk start
4152 if(is_array($_SESSION['usces_member'][$key]))
4153 $res[$key] = stripslashes_deep($value);
4154 else
4155 //20100818ysk end
4156 $res[$key] = stripslashes($value);
4157 }
4158 }
4159 return $res;
4160 }
4161
4162 function get_member_info( $mid ) {
4163 global $wpdb;
4164 $infos = array();
4165
4166 //if( !current_user_can('activate_plugins') ) return array();
4167
4168 $table = $wpdb->prefix . "usces_member";
4169 $query = $wpdb->prepare("SELECT * FROM $table WHERE ID = %d", $mid);
4170 $datas = $wpdb->get_results( $query, ARRAY_A );
4171 if( $datas ) {
4172 $infos = $datas[0];
4173
4174 $table = $wpdb->prefix . "usces_member_meta";
4175 $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid);
4176 $metas = $wpdb->get_results( $query, ARRAY_A );
4177
4178 foreach( $metas as $meta ){
4179 $infos[$meta['meta_key']] = maybe_unserialize($meta['meta_value']);
4180 }
4181 }
4182 return $infos;
4183 }
4184
4185 function set_member_info( $data=array(), $mid ) {
4186 global $wpdb;
4187
4188 $table = $wpdb->prefix . "usces_member";
4189 $res = $wpdb->update( $table, $data, array('ID'=>$mid), NULL, array('%d'));
4190 return $res;
4191 }
4192
4193 function is_order($mid, $oid) {
4194 global $wpdb;
4195
4196 $table = $wpdb->prefix . "usces_order";
4197 $query = $wpdb->prepare("SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid);
4198 $mem_id = $wpdb->get_var( $query );
4199 if ( empty($mem_id) ) {
4200 return false;
4201 }else{
4202 return true;
4203 }
4204 }
4205
4206 function is_purchased_item($mid, $post_id, $sku = NULL) {
4207 global $wpdb;
4208 $res = false;
4209
4210 $history = $this->get_member_history($mid);
4211 foreach ( $history as $umhs ) {
4212 $cart = $umhs['cart'];
4213 $status = $umhs['order_status'];
4214 for($i=0; $i<count($cart); $i++) {
4215 $cart_row = $cart[$i];
4216 $sku_code = urldecode($cart_row['sku']);
4217 if( empty($sku) ){
4218 if( $cart_row['post_id'] == $post_id && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4219 $res = true;
4220 break 2;
4221 }elseif( $cart_row['post_id'] == $post_id && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4222 $res = 'noreceipt';
4223 break 2;
4224 }
4225 }else{
4226 if( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4227 $res = true;
4228 break 2;
4229 }elseif( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4230 $res = 'noreceipt';
4231 break 2;
4232 }
4233 }
4234 }
4235
4236 }
4237 return $res;
4238 }
4239
4240 function get_order_data($order_id, $mode = '' ) {
4241 global $wpdb, $usces;
4242 $order_table = $wpdb->prefix . "usces_order";
4243
4244 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $order_id);
4245
4246 if( 'direct' == $mode ){
4247 $value = $wpdb->get_row( $query, ARRAY_A );
4248 return $value;
4249 }
4250
4251 $value = $wpdb->get_row( $query );
4252
4253 if( $value == NULL ) {
4254 return false;
4255 }else{
4256 $res =array();
4257 }
4258 if(strpos($value->order_status, 'cancel') !== false || strpos($value->order_status, 'estimate') !== false){
4259 return false;
4260 }
4261
4262 $res = array(
4263 'ID' => $value->ID,
4264 'mem_id' => $value->mem_id,
4265 'cart' => unserialize($value->order_cart),
4266 'condition' => unserialize($value->order_condition),
4267 'getpoint' => $value->order_getpoint,
4268 'usedpoint' => $value->order_usedpoint,
4269 'discount' => $value->order_discount,
4270 'payment_name' => $value->order_payment_name,
4271 'shipping_charge' => $value->order_shipping_charge,
4272 'cod_fee' => $value->order_cod_fee,
4273 'tax' => $value->order_tax,
4274 'end_price' => $value->order_item_total_price - ($value->order_getpoint*$usces->options['system']['pointreduction']) + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax,
4275 'status' => $value->order_status,
4276 'date' => mysql2date(__('Y/m/d'), $value->order_date),
4277 'modified' => mysql2date(__('Y/m/d'), $value->order_modified)
4278 );
4279
4280 return $res;
4281 }
4282
4283 function get_orderIDs_by_postID($mem_id, $post_id) {
4284 global $wpdb;
4285 $order_table = $wpdb->prefix . "usces_order";
4286
4287 $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);
4288 $rows = $wpdb->get_query( $query, ARRAY_A );
4289
4290 if( $value == NULL ) {
4291 return false;
4292 }else{
4293 foreach($rows as $row){
4294 if(strpos($row['order_status'], 'cancel') !== false || strpos($row['order_status'], 'estimate') !== false){
4295 continue;
4296 }else{
4297 $carts = unserialize($row['order_cart']);
4298 foreach($carts as $cart){
4299 if( $post_id == $cart['post_id'] ){
4300 $res[] = $row['ID'];
4301 break;
4302 }
4303 }
4304 }
4305 }
4306 }
4307 return $res;
4308 }
4309
4310 function incart_check() {
4311 //$_POST = $this->stripslashes_deep_post($_POST);
4312 $mes = array();
4313
4314 $ids = array_keys($_POST['inCart']);
4315 $post_id = $ids[0];
4316 $skus = array_keys($_POST['inCart'][$post_id]);
4317 $sku = $skus[0];
4318 $quant = isset($_POST['quant'][$post_id][$sku]) ? (int)$_POST['quant'][$post_id][$sku] : 1;
4319 $stock = $this->getItemZaikoNum($post_id, $sku);
4320 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku);
4321 $itemRestriction = get_post_meta($post_id, '_itemRestriction',true );
4322
4323 if( 1 > $quant ){
4324 $mes[$post_id][$sku] = __('enter the correct amount', 'usces') . "<br />";
4325 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4326 $mes[$post_id][$sku] = sprintf(__("This article is limited by %d at a time.", 'usces'), $itemRestriction) . "<br />";
4327 }else if( $quant > (int)$stock && !WCUtils::is_blank($stock) ){
4328 $mes[$post_id][$sku] = __('Sorry, stock is insufficient.', 'usces') . ' ' . __('Current stock', 'usces') . $stock . "<br />";
4329 }else if( 1 < $zaiko_id ){
4330 $mes[$post_id][$sku] = __('Sorry, this item is sold out.', 'usces') . "<br />";
4331 }
4332
4333 $ioptkeys = $this->get_itemOptionKey( $post_id, true );
4334 if($ioptkeys){
4335 foreach($ioptkeys as $key => $value){
4336 $optValues = $this->get_itemOptions( urldecode($value), $post_id );
4337 if( 0 == $optValues['means'] ){ //case of select
4338 if( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][$post_id][$sku][$value] ){
4339 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4340 }
4341 }elseif( 1 == $optValues['means'] ){ //case of multiselect
4342 if( $optValues['essential'] ){
4343 $mselect = 0;
4344 foreach((array)$_POST['itemOption'][$post_id][$sku][$value] as $mvalue){
4345 if(!empty($mvalue) and '#NONE#' != $mvalue) $mselect++;
4346 }
4347 if( $mselect == 0 ){
4348 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4349 }
4350 }
4351 }else{ //case of text
4352 if( $optValues['essential'] && WCUtils::is_blank($_POST['itemOption'][$post_id][$sku][$value]) ){
4353 $mes[$post_id][$sku] .= sprintf(__("Input the %s", 'usces'), urldecode($value)) . "<br />";
4354 }
4355 }
4356 }
4357 }
4358
4359 $mes = apply_filters('usces_filter_incart_check', $mes, $post_id, $sku);
4360
4361 if( isset($mes[$post_id]) && is_array($mes[$post_id]) ){
4362 foreach( $mes[$post_id] as $skukey => $skuvalue ){
4363 $mes[$post_id][$skukey] = rtrim($skuvalue, "<br />");
4364 }
4365 }
4366
4367 if( !empty($mes) ){
4368 $_SESSION['usces_singleitem']['itemOption'] = $_POST['itemOption'];
4369 $_SESSION['usces_singleitem']['quant'] = $_POST['quant'];
4370 $_SESSION['usces_singleitem']['error_message'] = $mes;
4371 if( false === strpos($_POST['usces_referer'], 'http') ){
4372 $parse_url = parse_url(get_home_url());
4373 header('location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $_POST['usces_referer'] . '#cart_button');
4374 }else{
4375 header('location: ' . $_POST['usces_referer'] . '#cart_button');
4376 }
4377 exit;
4378 }
4379
4380 do_action('usces_action_incart_checked', $mes, $post_id, $sku);
4381 }
4382
4383 function zaiko_check() {
4384 $mes = '';
4385 $cart = $this->cart->get_cart();
4386 $stocks = array();
4387
4388 for($i=0; $i<count($cart); $i++) {
4389 $cart_row = $cart[$i];
4390 $post_id = $cart_row['post_id'];
4391 $sku = $cart_row['sku'];
4392 $sku_code = urldecode($cart_row['sku']);
4393
4394 $quant = ( isset($_POST['quant']) ) ? trim($_POST['quant'][$i][$post_id][$sku]) : $cart_row['quantity'];
4395 //$zaiko_status = $this->getItemZaiko($post_id, $sku);
4396 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku_code);
4397 $stock = $this->getItemZaikoNum($post_id, $sku_code);
4398 if( !isset($stocks[$post_id][$sku]) ){
4399 if( !WCUtils::is_blank($stock) ){
4400 $stocks[$post_id][$sku] = $stock;
4401 }else{
4402 $stocks[$post_id][$sku] = NULL;
4403 }
4404 }
4405 $checkstock = $stocks[$post_id][$sku];
4406 $stocks[$post_id][$sku] = $stocks[$post_id][$sku] - $quant;
4407 $itemRestriction = get_post_meta($post_id, '_itemRestriction', true);
4408
4409 //$red = (in_array($zaiko_status, array(__('Sold Out', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'red' : '';
4410
4411 if( 1 > (int)$quant ){
4412 $mes .= sprintf(__("Enter the correct amount for the No.%d item.", 'usces'), ($i+1)) . "<br />";
4413 }else if( 1 < $zaiko_id || WCUtils::is_zero($stock) ){
4414 $mes .= sprintf(__('Sorry, No.%d item is sold out.', 'usces'), ($i+1)) . "<br />";
4415 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4416 $mes .= sprintf(__('This article is limited by %1$d at a time for the No.%2$d item.', 'usces'), $itemRestriction, ($i+1)) . "<br />";
4417 }else if( 0 > $stocks[$post_id][$sku] && !WCUtils::is_blank($stock) ){
4418 $mes .= sprintf(__('Stock of No.%1$d item is remainder %2$d.', 'usces'), ($i+1), $checkstock) . "<br />";
4419 }
4420 }
4421 $mes = apply_filters('usces_filter_zaiko_check', $mes, $cart);
4422 return $mes;
4423 }
4424
4425 function member_check() {
4426 $mes = '';
4427 foreach ( $_POST['member'] as $key => $vlue ) {
4428 $_SESSION['usces_member'][$key] = trim($vlue);
4429 }
4430 if ( $_POST['member_regmode'] == 'editmemberform' ) {
4431 if ( (!WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ) && trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4432 $mes .= __('Password is not correct.', 'usces') . "<br />";
4433 if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) )
4434 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4435
4436 } else {
4437 if ( WCUtils::is_blank($_POST['member']['password1']) || WCUtils::is_blank($_POST['member']['password2']) || trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4438 $mes .= __('Password is not correct.', 'usces') . "<br />";
4439 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']) )
4440 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4441
4442 }
4443 if ( WCUtils::is_blank($_POST["member"]["name1"]) )
4444 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4445 // if ( trim($_POST["member"]["name3"]) == "" && USCES_JP )
4446 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4447 if ( WCUtils::is_blank($_POST["member"]["zipcode"]) )
4448 $mes .= __('postal code is not correct', 'usces') . "<br />";
4449 if ( $_POST["member"]["pref"] == __('-- Select --', 'usces') )
4450 $mes .= __('enter the prefecture', 'usces') . "<br />";
4451 if ( WCUtils::is_blank($_POST["member"]["address1"]) )
4452 $mes .= __('enter the city name', 'usces') . "<br />";
4453 if ( WCUtils::is_blank($_POST["member"]["address2"]) )
4454 $mes .= __('enter house numbers', 'usces') . "<br />";
4455 if ( WCUtils::is_blank($_POST["member"]["tel"]) )
4456 $mes .= __('enter phone numbers', 'usces') . "<br />";
4457 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4458 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4459
4460 $mes = apply_filters('usces_filter_member_check', $mes);
4461
4462 return $mes;
4463 }
4464
4465 function member_check_fromcart() {
4466 $mes = '';
4467 if ( WCUtils::is_blank($_POST['customer']['password1']) || WCUtils::is_blank($_POST['customer']['password2']) || trim($_POST['customer']['password1']) != trim($_POST['customer']['password2']) )
4468 $mes .= __('Password is not correct.', 'usces') . "<br />";
4469 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']) )
4470 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4471 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4472 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4473 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4474 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4475 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4476 $mes .= __('postal code is not correct', 'usces') . "<br />";
4477 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4478 $mes .= __('enter the prefecture', 'usces') . "<br />";
4479 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4480 $mes .= __('enter the city name', 'usces') . "<br />";
4481 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4482 $mes .= __('enter house numbers', 'usces') . "<br />";
4483 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4484 $mes .= __('enter phone numbers', 'usces') . "<br />";
4485 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4486 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4487
4488 $mes = apply_filters('usces_filter_member_check_fromcart', $mes);
4489
4490 return $mes;
4491 }
4492
4493 function admin_member_check() {
4494 global $wpdb;
4495 $mes = '';
4496 if ( !is_email( trim($_POST['member']["email"]) ) ){
4497 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4498 }else{
4499 $member_table = $wpdb->prefix . "usces_member";
4500 $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
4501 if( trim($_POST['member']["email"]) != $mem_email ){
4502 $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
4503 if( !empty($mem_ID) )
4504 $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />";
4505 }
4506 }
4507 if ( WCUtils::is_blank($_POST['member']["name1"]) )
4508 $mes .= __('Name is not correct', 'usces') . "<br />";
4509 // if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
4510 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4511 // if ( trim($_POST['member']["zipcode"]) == "" )
4512 // $mes .= __('postal code is not correct', 'usces') . "<br />";
4513 // if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
4514 // $mes .= __('enter the prefecture', 'usces') . "<br />";
4515 // if ( trim($_POST['member']["address1"]) == "" )
4516 // $mes .= __('enter the city name', 'usces') . "<br />";
4517 // if ( trim($_POST['member']["address2"]) == "" )
4518 // $mes .= __('enter house numbers', 'usces') . "<br />";
4519 // if ( trim($_POST['member']["tel"]) == "" )
4520 // $mes .= __('enter phone numbers', 'usces') . "<br />";
4521 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4522 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4523
4524 $mes = apply_filters('usces_filter_admin_member_check', $mes);
4525
4526 return $mes;
4527 }
4528
4529 function customer_check() {
4530 $mes = '';
4531 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']) )
4532 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4533 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4534 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4535 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4536 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4537 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4538 $mes .= __('postal code is not correct', 'usces') . "<br />";
4539 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4540 $mes .= __('enter the prefecture', 'usces') . "<br />";
4541 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4542 $mes .= __('enter the city name', 'usces') . "<br />";
4543 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4544 $mes .= __('enter house numbers', 'usces') . "<br />";
4545 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4546 $mes .= __('enter phone numbers', 'usces') . "<br />";
4547 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4548 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4549
4550 $mes = apply_filters('usces_filter_customer_check', $mes);
4551
4552 return $mes;
4553 }
4554
4555 function delivery_check() {
4556 $mes = '';
4557 if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
4558 if ( WCUtils::is_blank($_POST["delivery"]["name1"]) )
4559 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4560 // if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP )
4561 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4562 if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) )
4563 $mes .= __('postal code is not correct', 'usces') . "<br />";
4564 if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') )
4565 $mes .= __('enter the prefecture', 'usces') . "<br />";
4566 if ( WCUtils::is_blank($_POST["delivery"]["address1"]) )
4567 $mes .= __('enter the city name', 'usces') . "<br />";
4568 if ( WCUtils::is_blank($_POST["delivery"]["address2"]) )
4569 $mes .= __('enter house numbers', 'usces') . "<br />";
4570 if ( WCUtils::is_blank($_POST["delivery"]["tel"]) )
4571 $mes .= __('enter phone numbers', 'usces') . "<br />";
4572 }
4573 if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) )
4574 $mes .= __('chose one from delivery method.', 'usces') . "<br />";
4575 if ( !isset($_POST['offer']['payment_name']) ){
4576 $mes .= __('chose one from payment options.', 'usces') . "<br />";
4577 }else{
4578 $payments = $this->getPayments($_POST['offer']['payment_name']);
4579 if('COD' == $payments['settlement']){
4580 $total_items_price = $this->get_total_price();
4581 $tax = $this->getTax( $total_items_price );
4582 $total_items_price = $total_items_price + $tax;
4583 $cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
4584 if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount )
4585 $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 />";
4586 }
4587
4588 }
4589 //20101119ysk start
4590 if(isset($_POST['offer']['delivery_method']) and isset($_POST['offer']['payment_name'])) {
4591 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4592 if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) {
4593 $payments = $this->getPayments($_POST['offer']['payment_name']);
4594 if('COD' == $payments['settlement'])
4595 $mes .= __('COD is not available.', 'usces') . "<br />";
4596 }
4597 }
4598 //20101119ysk end
4599 //20110317ysk start
4600 if(isset($_POST['offer']['delivery_method'])) {
4601 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4602 $country = $_SESSION['usces_entry']["delivery"]["country"];
4603 $local_country = usces_get_base_country();
4604 if($country == $local_country) {
4605 if($this->options['delivery_method'][$d_method_index]['intl'] == 1) {
4606 $mes .= __('�
4607 �送方法が誤っています。国際便は指定できません。', 'usces') . "<br />";
4608 }
4609 } else {
4610 if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) {
4611 $mes .= __('�
4612 �送方法が誤っています。国際便を指定してください。', 'usces') . "<br />";
4613 }
4614 }
4615 }
4616 //20110317ysk end
4617
4618 $mes = apply_filters('usces_filter_delivery_check', $mes);
4619
4620 return $mes;
4621 }
4622
4623 function point_check( $entries ) {
4624 $member = $this->get_member();
4625 $this->set_cart_fees( $member, $entries );
4626 $mes = '';
4627 if( isset($_POST['offer']["usedpoint"]) ) {
4628 if ( WCUtils::is_blank($_POST['offer']["usedpoint"]) || !preg_match("/^[0-9]+$/", $_POST['offer']["usedpoint"]) || (int)$_POST['offer']["usedpoint"] < 0 ) {
4629 $mes .= __('Invalid value. Please enter in the numbers.', 'usces') . "<br />";
4630 } else {
4631 /* if ( trim($_POST['offer']["usedpoint"]) > $member['point'] ){
4632 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".$member['point']."pt<br />";
4633 $_POST['offer']["usedpoint"] = 0;
4634 $array = array(
4635 'usedpoint' => 0
4636 );
4637 $this->cart->set_order_entry( $array );
4638 }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'])){
4639 $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 />";
4640 $_POST['offer']["usedpoint"] = 0;
4641 $array = array(
4642 'usedpoint' => 0
4643 );
4644 $this->cart->set_order_entry( $array );
4645 }elseif(!$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'])){
4646 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4647 $_POST['offer']["usedpoint"] = 0;
4648 $array = array(
4649 'usedpoint' => 0
4650 );
4651 $this->cart->set_order_entry( $array );
4652 }
4653 */ if( trim($_POST['offer']["usedpoint"]) > $member['point'] ) {
4654 $mes .= __('You have exceeded the maximum available.', 'usces')."max".$member['point']."pt<br />";
4655 } 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']) ) {
4656 $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 />";
4657 } elseif( !$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount']) ) {
4658 $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4659 }
4660 $mes = apply_filters( 'usces_filter_point_check', $mes );
4661 if( '' != $mes ) {
4662 $_POST['offer']["usedpoint"] = 0;
4663 $array = array(
4664 'usedpoint' => 0
4665 );
4666 $this->cart->set_order_entry( $array );
4667 }
4668 }
4669 }
4670 return $mes;
4671 }
4672
4673 function lostpass_mailaddcheck() {
4674 $mes = '';
4675 if ( !is_email($_POST['loginmail']) || WCUtils::is_blank($_POST['loginmail']) ) {
4676 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4677 }elseif( !$this->is_member($_POST['loginmail']) ){
4678 $mes .= __('It is the e-mail address that there is not.', 'usces') . "<br />";
4679 }
4680
4681 return $mes;
4682 }
4683
4684 function changepass_check() {
4685 $mes = '';
4686 if ( WCUtils::is_blank($_POST['loginpass1']) || WCUtils::is_blank($_POST['loginpass2']) || (trim($_POST['loginpass1']) != trim($_POST['loginpass2'])))
4687 $mes .= __('Password is not correct.', 'usces') . "<br />";
4688
4689 return $mes;
4690 }
4691
4692 function get_page() {
4693 return $this->page;
4694 }
4695
4696 function check_display_mode() {
4697 $options = get_option('usces');
4698 if( isset($options['display_mode']) && $options['display_mode'] == 'Maintenancemode' ) return;
4699
4700 $start['hour'] = empty($options['campaign_schedule']['start']['hour']) ? 0 : $options['campaign_schedule']['start']['hour'];
4701 $start['min'] = empty($options['campaign_schedule']['start']['min']) ? 0 : $options['campaign_schedule']['start']['min'];
4702 $start['month'] = empty($options['campaign_schedule']['start']['month']) ? 0 : $options['campaign_schedule']['start']['month'];
4703 $start['day'] = empty($options['campaign_schedule']['start']['day']) ? 0 : $options['campaign_schedule']['start']['day'];
4704 $start['year'] = empty($options['campaign_schedule']['start']['year']) ? 0 : $options['campaign_schedule']['start']['year'];
4705 $end['hour'] = empty($options['campaign_schedule']['end']['hour']) ? 0 : $options['campaign_schedule']['end']['hour'];
4706 $end['min'] = empty($options['campaign_schedule']['end']['min']) ? 0 : $options['campaign_schedule']['end']['min'];
4707 $end['month'] = empty($options['campaign_schedule']['end']['month']) ? 0 : $options['campaign_schedule']['end']['month'];
4708 $end['day'] = empty($options['campaign_schedule']['end']['day']) ? 0 : $options['campaign_schedule']['end']['day'];
4709 $end['year'] = empty($options['campaign_schedule']['end']['year']) ? 0 : $options['campaign_schedule']['end']['year'];
4710 $starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']);
4711 $endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']);
4712 $current_time = current_time('timestamp');
4713
4714 if( ($current_time >= $starttime) && ($current_time <= $endtime) )
4715 $options['display_mode'] = 'Promotionsale';
4716 else
4717 $options['display_mode'] = 'Usualsale';
4718
4719 update_option('usces', $options);
4720
4721 }
4722
4723 function update_business_days() {
4724 $options = get_option('usces');
4725 $datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
4726 $dhour = (int)substr($datetimestr, 11, 2);
4727 $dminute = (int)substr($datetimestr, 14, 2);
4728 $dsecond = (int)substr($datetimestr, 17, 2);
4729 $dmonth = (int)substr($datetimestr, 5, 2);
4730 $dday = (int)substr($datetimestr, 8, 2);
4731 $dyear = (int)substr($datetimestr, 0, 4);
4732 $dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear);
4733 $datenow = getdate($dtimestamp);
4734 //list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1);
4735 list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], 1, 1);
4736
4737 if(isset($options['business_days'][$year][$mon][1]))
4738 unset($options['business_days'][$year][$mon]);
4739
4740 for($i=0; $i<3; $i++){
4741 //list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i);
4742 list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], 1, $i);
4743 $last = getLastDay($year, $mon);
4744 for($j=1; $j<=$last; $j++){
4745 if(!isset($options['business_days'][$year][$mon][$j]))
4746 $options['business_days'][$year][$mon][$j] = 1;
4747 }
4748 }
4749
4750 update_option('usces', $options);
4751
4752 $_SESSION['usces_checked_business_days'] = '';
4753 }
4754
4755 function display_cart() {
4756 if($this->cart->num_row() > 0) {
4757 include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
4758 } else {
4759 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4760 }
4761 }
4762
4763 function display_cart_confirm() {
4764 if($this->cart->num_row() > 0) {
4765 include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php');
4766 } else {
4767 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4768 }
4769 }
4770
4771 function set_initial() {
4772
4773 usces_log('set_initial : OK', 'database_error.log');
4774 $rets07 = usces_upgrade_07();
4775 $rets11 = usces_upgrade_11();
4776 usces_log('rets11 : ' . print_r($rets11,true), 'database_error.log');
4777 $this->set_default_theme();
4778 $this->set_default_page();
4779 $this->set_default_categories();
4780 $this->create_table();
4781 $this->update_table();
4782 $this->update_options();//20120710ysk 0000472
4783 }
4784
4785 function create_table() {
4786 global $wpdb;
4787
4788 if ( ! empty($wpdb->charset) )
4789 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
4790 if ( ! empty($wpdb->collate) )
4791 $charset_collate .= " COLLATE $wpdb->collate";
4792
4793 $access_table = $wpdb->prefix . "usces_access";
4794 $member_table = $wpdb->prefix . "usces_member";
4795 $member_meta_table = $wpdb->prefix . "usces_member_meta";
4796 $order_table = $wpdb->prefix . "usces_order";
4797 $order_meta_table = $wpdb->prefix . "usces_order_meta";
4798
4799 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4800
4801 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
4802
4803 $sql = "CREATE TABLE " . $access_table . " (
4804 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4805 acc_key VARCHAR( 50 ) NOT NULL ,
4806 acc_type VARCHAR( 50 ) NULL ,
4807 acc_value LONGTEXT NULL ,
4808 acc_date DATE NOT NULL DEFAULT '0000-00-00',
4809 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
4810 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
4811 acc_str1 VARCHAR( 200 ) NULL ,
4812 acc_str2 VARCHAR( 200 ) NULL ,
4813 KEY acc_key ( acc_key ),
4814 KEY acc_type ( acc_type ),
4815 KEY acc_date ( acc_date ),
4816 KEY acc_num1 ( acc_num1 ),
4817 KEY acc_num2 ( acc_num2 )
4818 ) ENGINE = MYISAM AUTO_INCREMENT=0 $charset_collate;";
4819
4820 dbDelta($sql);
4821 add_option("usces_db_access", USCES_DB_ACCESS);
4822 }
4823 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
4824
4825 $sql = "CREATE TABLE " . $member_table . " (
4826 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4827 mem_email VARCHAR( 100 ) NOT NULL ,
4828 mem_pass VARCHAR( 64 ) NOT NULL ,
4829 mem_status INT( 11 ) NOT NULL DEFAULT '0',
4830 mem_cookie VARCHAR( 13 ) NULL ,
4831 mem_point INT( 11 ) NOT NULL DEFAULT '0',
4832 mem_name1 VARCHAR( 100 ) NOT NULL ,
4833 mem_name2 VARCHAR( 100 ) NULL ,
4834 mem_name3 VARCHAR( 100 ) NULL ,
4835 mem_name4 VARCHAR( 100 ) NULL ,
4836 mem_zip VARCHAR( 50 ) NULL ,
4837 mem_pref VARCHAR( 100 ) NOT NULL ,
4838 mem_address1 VARCHAR( 100 ) NOT NULL ,
4839 mem_address2 VARCHAR( 100 ) NULL ,
4840 mem_address3 VARCHAR( 100 ) NULL ,
4841 mem_tel VARCHAR( 100 ) NOT NULL ,
4842 mem_fax VARCHAR( 100 ) NULL ,
4843 mem_delivery_flag TINYINT ( 1 ) NULL ,
4844 mem_delivery LONGTEXT,
4845 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
4846 mem_nicename VARCHAR( 50 ) NULL ,
4847 KEY mem_email ( mem_email ) ,
4848 KEY mem_pass ( mem_pass )
4849 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
4850
4851 dbDelta($sql);
4852 add_option("usces_db_member", USCES_DB_MEMBER);
4853 }
4854 if($wpdb->get_var("show tables like '$member_meta_table'") != $member_meta_table) {
4855
4856 $sql = "CREATE TABLE " . $member_meta_table . " (
4857 mmeta_id bigint(20) NOT NULL auto_increment,
4858 member_id bigint(20) NOT NULL default '0',
4859 meta_key varchar(255) default NULL,
4860 meta_value longtext,
4861 PRIMARY KEY (mmeta_id),
4862 KEY order_id (member_id),
4863 KEY meta_key (meta_key)
4864 ) ENGINE = MYISAM $charset_collate;";
4865
4866 dbDelta($sql);
4867 add_option("usces_db_member_meta", USCES_DB_MEMBER_META);
4868 }
4869 if($wpdb->get_var("show tables like '$order_table'") != $order_table) {
4870
4871 $sql = "CREATE TABLE " . $order_table . " (
4872 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4873 mem_id BIGINT( 20 ) UNSIGNED NULL ,
4874 order_email VARCHAR( 100 ) NOT NULL ,
4875 order_name1 VARCHAR( 100 ) NOT NULL ,
4876 order_name2 VARCHAR( 100 ) NULL ,
4877 order_name3 VARCHAR( 100 ) NULL ,
4878 order_name4 VARCHAR( 100 ) NULL ,
4879 order_zip VARCHAR( 50 ) NULL ,
4880 order_pref VARCHAR( 100 ) NOT NULL ,
4881 order_address1 VARCHAR( 100 ) NOT NULL ,
4882 order_address2 VARCHAR( 100 ) NULL ,
4883 order_address3 VARCHAR( 100 ) NULL ,
4884 order_tel VARCHAR( 100 ) NOT NULL ,
4885 order_fax VARCHAR( 100 ) NULL ,
4886 order_delivery LONGTEXT,
4887 order_cart LONGTEXT,
4888 order_note TEXT,
4889 order_delivery_time VARCHAR( 100 ) NOT NULL ,
4890 order_payment_name VARCHAR( 100 ) NOT NULL ,
4891 order_condition TEXT,
4892 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4893 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
4894 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
4895 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4896 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4897 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4898 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4899 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
4900 order_modified VARCHAR( 20 ) NULL ,
4901 order_status VARCHAR( 255 ) NULL ,
4902 order_check VARCHAR( 255 ) NULL ,
4903 order_delidue_date VARCHAR( 30 ) NULL ,
4904 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
4905 order_delivery_date VARCHAR( 100 ) NULL,
4906 KEY order_email ( order_email ) ,
4907 KEY order_name1 ( order_name1 ) ,
4908 KEY order_name2 ( order_name2 ) ,
4909 KEY order_pref ( order_pref ) ,
4910 KEY order_address1 ( order_address1 ) ,
4911 KEY order_tel ( order_tel ) ,
4912 KEY order_date ( order_date )
4913 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
4914
4915 dbDelta($sql);
4916 add_option("usces_db_order", USCES_DB_ORDER);
4917 }
4918 if($wpdb->get_var("show tables like '$order_meta_table'") != $order_meta_table) {
4919
4920 $sql = "CREATE TABLE " . $order_meta_table . " (
4921 ometa_id bigint(20) NOT NULL auto_increment,
4922 order_id bigint(20) NOT NULL default '0',
4923 meta_key varchar(255) default NULL,
4924 meta_value longtext,
4925 PRIMARY KEY (ometa_id),
4926 KEY order_id (order_id),
4927 KEY meta_key (meta_key)
4928 ) ENGINE = MYISAM $charset_collate;";
4929
4930 dbDelta($sql);
4931 add_option("usces_db_order_meta", USCES_DB_ORDER_META);
4932 }
4933
4934 }
4935
4936 function update_table()
4937 {
4938 global $wpdb;
4939 $access_table = $wpdb->prefix . "usces_access";
4940 $member_table = $wpdb->prefix . "usces_member";
4941 $member_meta_table = $wpdb->prefix . "usces_member_meta";
4942 $order_table = $wpdb->prefix . "usces_order";
4943 $order_meta_table = $wpdb->prefix . "usces_order_meta";
4944
4945 $access_ver = get_option( "usces_db_access" );
4946 $member_ver = get_option( "usces_db_member" );
4947 $member_meta_ver = get_option( "usces_db_member_meta" );
4948 $order_ver = get_option( "usces_db_order" );
4949 $order_meta_ver = get_option( "usces_db_order_meta" );
4950
4951 if( $access_ver != USCES_DB_ACCESS ) {
4952 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4953 $sql = "CREATE TABLE " . $access_table . " (
4954 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4955 acc_key VARCHAR( 50 ) NOT NULL ,
4956 acc_type VARCHAR( 50 ) NULL ,
4957 acc_value LONGTEXT NULL ,
4958 acc_date DATE NOT NULL DEFAULT '0000-00-00',
4959 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
4960 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
4961 acc_str1 VARCHAR( 200 ) NULL ,
4962 acc_str2 VARCHAR( 200 ) NULL ,
4963 KEY acc_key ( acc_key ),
4964 KEY acc_type ( acc_type ),
4965 KEY acc_date ( acc_date ),
4966 KEY acc_num1 ( acc_num1 ),
4967 KEY acc_num2 ( acc_num2 )
4968 ) ENGINE = MYISAM;";
4969
4970 dbDelta($sql);
4971 update_option( "usces_db_access", USCES_DB_ACCESS );
4972 }
4973 if( $member_ver != USCES_DB_MEMBER ) {
4974 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4975 $sql = "CREATE TABLE " . $member_table . " (
4976 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4977 mem_email VARCHAR( 100 ) NOT NULL ,
4978 mem_pass VARCHAR( 64 ) NOT NULL ,
4979 mem_status INT( 11 ) NOT NULL DEFAULT '0',
4980 mem_cookie VARCHAR( 13 ) NULL ,
4981 mem_point INT( 11 ) NOT NULL DEFAULT '0',
4982 mem_name1 VARCHAR( 100 ) NOT NULL ,
4983 mem_name2 VARCHAR( 100 ) NULL ,
4984 mem_name3 VARCHAR( 100 ) NULL ,
4985 mem_name4 VARCHAR( 100 ) NULL ,
4986 mem_zip VARCHAR( 50 ) NULL ,
4987 mem_pref VARCHAR( 100 ) NOT NULL ,
4988 mem_address1 VARCHAR( 100 ) NOT NULL ,
4989 mem_address2 VARCHAR( 100 ) NULL ,
4990 mem_address3 VARCHAR( 100 ) NULL ,
4991 mem_tel VARCHAR( 100 ) NOT NULL ,
4992 mem_fax VARCHAR( 100 ) NULL ,
4993 mem_delivery_flag TINYINT ( 1 ) NULL ,
4994 mem_delivery LONGTEXT,
4995 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
4996 mem_nicename VARCHAR( 50 ) NULL ,
4997 KEY mem_email ( mem_email ) ,
4998 KEY mem_pass ( mem_pass )
4999 ) ENGINE = MYISAM;";
5000
5001 dbDelta($sql);
5002 update_option( "usces_db_member", USCES_DB_MEMBER );
5003 }
5004 if( $member_meta_ver != USCES_DB_MEMBER_META ) {
5005 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5006 $sql = "CREATE TABLE " . $member_meta_table . " (
5007 mmeta_id bigint(20) NOT NULL auto_increment,
5008 member_id bigint(20) NOT NULL default '0',
5009 meta_key varchar(255) default NULL,
5010 meta_value longtext,
5011 PRIMARY KEY (mmeta_id),
5012 KEY order_id (member_id),
5013 KEY meta_key (meta_key)
5014 ) ENGINE = MYISAM;";
5015
5016 dbDelta($sql);
5017 update_option("usces_db_member_meta", USCES_DB_MEMBER_META);
5018 }
5019 if( $order_ver != USCES_DB_ORDER ) {
5020 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5021 $sql = "CREATE TABLE " . $order_table . " (
5022 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5023 mem_id BIGINT( 20 ) UNSIGNED NULL ,
5024 order_email VARCHAR( 100 ) NOT NULL ,
5025 order_name1 VARCHAR( 100 ) NOT NULL ,
5026 order_name2 VARCHAR( 100 ) NULL ,
5027 order_name3 VARCHAR( 100 ) NULL ,
5028 order_name4 VARCHAR( 100 ) NULL ,
5029 order_zip VARCHAR( 50 ) NULL ,
5030 order_pref VARCHAR( 100 ) NOT NULL ,
5031 order_address1 VARCHAR( 100 ) NOT NULL ,
5032 order_address2 VARCHAR( 100 ) NULL ,
5033 order_address3 VARCHAR( 100 ) NULL ,
5034 order_tel VARCHAR( 100 ) NOT NULL ,
5035 order_fax VARCHAR( 100 ) NULL ,
5036 order_delivery LONGTEXT,
5037 order_cart LONGTEXT,
5038 order_note TEXT,
5039 order_delivery_time VARCHAR( 100 ) NOT NULL ,
5040 order_payment_name VARCHAR( 100 ) NOT NULL ,
5041 order_condition TEXT,
5042 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5043 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
5044 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
5045 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5046 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5047 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5048 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5049 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5050 order_modified VARCHAR( 20 ) NULL ,
5051 order_status VARCHAR( 255 ) NULL ,
5052 order_check VARCHAR( 255 ) NULL ,
5053 order_delidue_date VARCHAR( 30 ) NULL ,
5054 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
5055 order_delivery_date VARCHAR( 100 ) NULL,
5056 KEY order_email ( order_email ) ,
5057 KEY order_name1 ( order_name1 ) ,
5058 KEY order_name2 ( order_name2 ) ,
5059 KEY order_pref ( order_pref ) ,
5060 KEY order_address1 ( order_address1 ) ,
5061 KEY order_tel ( order_tel ) ,
5062 KEY order_date ( order_date )
5063 ) ENGINE = MYISAM;";
5064
5065 dbDelta($sql);
5066 update_option("usces_db_order", USCES_DB_ORDER);
5067 }
5068 if( $order_meta_ver != USCES_DB_ORDER_META ) {
5069 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5070 $sql = "CREATE TABLE " . $order_meta_table . " (
5071 ometa_id bigint(20) NOT NULL auto_increment,
5072 order_id bigint(20) NOT NULL default '0',
5073 meta_key varchar(255) default NULL,
5074 meta_value longtext,
5075 PRIMARY KEY (ometa_id),
5076 KEY order_id (order_id),
5077 KEY meta_key (meta_key)
5078 ) ENGINE = MYISAM;";
5079
5080 dbDelta($sql);
5081 update_option("usces_db_order_meta", USCES_DB_ORDER_META);
5082 }
5083 }
5084
5085 function set_default_theme()
5086 {
5087 $themepath = USCES_WP_CONTENT_DIR.'/themes/welcart_default';
5088 $resourcepath = USCES_WP_CONTENT_DIR.'/plugins/usc-e-shop/theme/welcart_default';
5089 if( file_exists($themepath) ) return false;
5090 if(!file_exists($resourcepath) ) return false;
5091
5092 mkdir($themepath, 0775);
5093 $this->dir_copy($resourcepath, $themepath);
5094
5095 }
5096
5097 function dir_copy($source, $dest){
5098 if ($res = opendir($source)) {
5099 while (($file = readdir($res)) !== false) {
5100 $sorce_path = $source . '/' . $file;
5101 $dest_path = $dest . '/' . $file;
5102 $filetype = @filetype($sorce_path);
5103 if( $filetype == 'file' ) {
5104 copy($sorce_path, $dest_path);
5105 }elseif( $filetype == 'dir' && $file != '..' && $file != '.' ){
5106 mkdir($dest_path);
5107 $this->dir_copy($sorce_path, $dest_path);
5108 }
5109 }
5110 closedir($res);
5111 }
5112 }
5113
5114 function set_default_page()
5115 {
5116 global $wpdb;
5117 $datetime = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
5118 $datetime_gmt = gmdate('Y-m-d H:i:s', time());
5119
5120 //cart_page
5121 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER);
5122 $cart_number = $wpdb->get_var( $query );
5123 if( $cart_number === NULL ) {
5124 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5125 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5126 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5127 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5128 VALUES (%d, %s, %s, %s, %s, %s, %s,
5129 %s, %s, %s, %s, %s, %s, %s, %s,
5130 %s, %d, %s, %d, %s, %s, %d)",
5131 1, $datetime, $datetime_gmt, '', __('Cart', 'usces'), '', 'publish',
5132 'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt,
5133 '', 0, '', 0, 'page', '', 0);
5134 $wpdb->query($query);
5135 $cart_number = $wpdb->insert_id;
5136 if( $cart_number !== NULL ) {
5137 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5138 $cart_number, '_wp_page_template', 'uscescart.php');
5139 $wpdb->query($query);
5140 }
5141 }
5142 update_option('usces_cart_number', $cart_number);
5143
5144 //member_page
5145 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER);
5146 $member_number = $wpdb->get_var( $query );
5147 if( $member_number === NULL ) {
5148 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5149 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5150 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5151 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5152 VALUES (%d, %s, %s, %s, %s, %s, %s,
5153 %s, %s, %s, %s, %s, %s, %s, %s,
5154 %s, %d, %s, %d, %s, %s, %d)",
5155 1, $datetime, $datetime_gmt, '', __('Membership', 'usces'), '', 'publish',
5156 'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt,
5157 '', 0, '', 0, 'page', '', 0);
5158 $wpdb->query($query);
5159 $member_number = $wpdb->insert_id;
5160 if( $member_number !== NULL ) {
5161 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5162 $member_number, '_wp_page_template', 'uscesmember.php');
5163 $wpdb->query($query);
5164 }
5165 }
5166 update_option('usces_member_number', $member_number);
5167
5168 }
5169
5170 function set_default_categories()
5171 {
5172 global $wpdb;
5173
5174 $idObj = get_category_by_slug('item');
5175 if( empty($idObj) ) {
5176 $item_cat = array('cat_name' => __('Items', 'usces'), 'category_description' => '', 'category_nicename' => 'item', 'category_parent' => 0);
5177 $item_cat_id = wp_insert_category($item_cat);
5178 update_option('usces_item_cat_parent_id', $item_cat_id);
5179 }
5180
5181 $idObj = get_category_by_slug('itemreco');
5182 if( empty($idObj) && isset($item_cat_id) ) {
5183 $itemreco_cat = array('cat_name' => __('Items recommended', 'usces'), 'category_description' => '', 'category_nicename' => 'itemreco', 'category_parent' => $item_cat_id);
5184 $itemreco_cat_id = wp_insert_category($itemreco_cat);
5185 }
5186
5187 $idObj = get_category_by_slug('itemnew');
5188 if( empty($idObj) && isset($item_cat_id) ) {
5189 $itemnew_cat = array('cat_name' => __('New items', 'usces'), 'category_description' => '', 'category_nicename' => 'itemnew', 'category_parent' => $item_cat_id);
5190 $itemnew_cat_id = wp_insert_category($itemnew_cat);
5191 }
5192
5193 $idObj = get_category_by_slug('itemgenre');
5194 if( empty($idObj) && isset($item_cat_id) ) {
5195 $itemgenre_cat = array('cat_name' => __('Item genre', 'usces'), 'category_description' => '', 'category_nicename' => 'itemgenre', 'category_parent' => $item_cat_id);
5196 $itemgenre_cat_id = wp_insert_category($itemgenre_cat);
5197 }
5198 }
5199 //20120710ysk start 0000472
5200 function update_options() {
5201 $target_market = $this->options['system']['target_market'];
5202
5203 $update_shipping_charge = false;
5204 $shipping_charge = isset($this->options['shipping_charge']) ? $this->options['shipping_charge'] : array();
5205 foreach( (array)$target_market as $tm ) {
5206 for( $i = 0; $i < count($shipping_charge); $i++ ) {
5207 if( isset($shipping_charge[$i]['country']) and $shipping_charge[$i]['country'] == $tm ) {
5208 foreach( $shipping_charge[$i]['value'] as $pref => $value ) {
5209 $shipping_charge[$i][$tm][$pref] = $value;
5210 }
5211 unset($shipping_charge[$i]['country']);
5212 unset($shipping_charge[$i]['value']);
5213 $update_shipping_charge = true;
5214 }
5215 }
5216 }
5217 if( $update_shipping_charge ) $this->options['shipping_charge'] = $shipping_charge;
5218
5219 $update_delivery_days = false;
5220 $delivery_days = isset($this->options['delivery_days']) ? $this->options['delivery_days'] : array();
5221 foreach( (array)$target_market as $tm ) {
5222 for( $i = 0; $i < count($delivery_days); $i++ ) {
5223 if( isset($delivery_days[$i]['country']) and $delivery_days[$i]['country'] == $tm ) {
5224 foreach( $delivery_days[$i]['value'] as $pref => $value ) {
5225 $delivery_days[$i][$tm][$pref] = $value;
5226 }
5227 unset($delivery_days[$i]['country']);
5228 unset($delivery_days[$i]['value']);
5229 $update_delivery_days = true;
5230 }
5231 }
5232 }
5233 if( $update_delivery_days ) $this->options['delivery_days'] = $delivery_days;
5234
5235 if( $update_shipping_charge or $update_delivery_days )
5236 update_option('usces', $this->options);
5237 }
5238 //20120710ysk end
5239 function get_item_cat_ids(){
5240 $args = array('child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0, 'hierarchical' => 0);
5241 $categories = get_categories( $args );
5242 foreach($categories as $category){
5243 $ids[] = $category->term_id;
5244 }
5245 return $ids;
5246 }
5247
5248 function get_item_post_ids(){
5249 global $wpdb;
5250 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5251 $ids = $wpdb->get_col( $query );
5252
5253 return $ids;
5254 }
5255
5256 function get_item_cat_genre_ids( $post_id ){
5257 $ids = array();
5258 $all_ids = array();
5259 $genre = get_category_by_slug( 'itemgenre' );
5260 $genre_id = $genre->term_id;
5261 $args = array('child_of' => $genre_id, 'hide_empty' => 0, 'hierarchical' => 0);
5262 $categories = get_categories( $args );
5263 foreach($categories as $category){
5264 $ids[] = $category->term_id;
5265 }
5266 $allcats = get_the_category( $post_id );
5267 foreach($allcats as $cat){
5268 $all_ids[] = $cat->term_id;
5269 }
5270 //$all_ids =
5271 $results = array_intersect($ids, $all_ids);
5272
5273 return $results;
5274 }
5275
5276 function set_item_mime($post_id, $str)
5277 {
5278 global $wpdb;
5279 if( WCUtils::is_blank($str) ) return;
5280
5281 $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id);
5282 $results = $wpdb->query( $query );
5283 return $results;
5284 }
5285
5286 function isAdnminSSL()
5287 {
5288 $plugins = get_option('active_plugins');
5289 foreach($plugins as $plugin) {
5290 if( false !== strpos($plugin, USCES_ADMIN_SSL_BASE_NAME) )
5291 return true;
5292 }
5293 return false;
5294 }
5295
5296 function getGuidTax() {
5297 $tax_rate = (int)$this->options['tax_rate'];
5298 if ( 0 < $tax_rate )
5299 $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>';
5300 else
5301 $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>';
5302
5303 return apply_filters('usces_filter_tax_guid', $str, $tax_rate);
5304 }
5305
5306 function getItemCode($post_id) {
5307 $str = get_post_meta($post_id, '_itemCode', true);
5308 return $str;
5309 }
5310
5311 function getItemName($post_id) {
5312 $str = get_post_meta($post_id, '_itemName', true);
5313 return $str;
5314 }
5315
5316 function getItemRestriction($post_id) {
5317 $str = get_post_meta($post_id, '_itemRestriction', true);
5318 return $str;
5319 }
5320
5321 function getItemPointrate($post_id) {
5322 $str = get_post_meta($post_id, '_itemPointrate', true);
5323 return $str;
5324 }
5325
5326 function getItemShipping($post_id) {
5327 $str = get_post_meta($post_id, '_itemShipping', true);
5328 return $str;
5329 }
5330
5331 function getItemShippingCharge($post_id) {
5332 $str = get_post_meta($post_id, '_itemShippingCharge', true);
5333 return (float)$str;
5334 }
5335
5336 function getItemDeliveryMethod($post_id) {
5337 $str = get_post_meta($post_id, '_itemDeliveryMethod', true);
5338 if( empty($str) )
5339 return array();
5340 else
5341 return $str;
5342 }
5343
5344 function getItemIndividualSCharge($post_id) {
5345 $str = get_post_meta($post_id, '_itemIndividualSCharge', true);
5346 return $str;
5347 }
5348
5349 function getItemGpNum1($post_id) {
5350 $str = get_post_meta($post_id, '_itemGpNum1', true);
5351 return $str;
5352 }
5353
5354 function getItemGpNum2($post_id) {
5355 $str = get_post_meta($post_id, '_itemGpNum2', true);
5356 return $str;
5357 }
5358
5359 function getItemGpNum3($post_id) {
5360 $str = get_post_meta($post_id, '_itemGpNum3', true);
5361 return $str;
5362 }
5363
5364 function getItemGpDis1($post_id) {
5365 $str = get_post_meta($post_id, '_itemGpDis1', true);
5366 return $str;
5367 }
5368
5369 function getItemGpDis2($post_id) {
5370 $str = get_post_meta($post_id, '_itemGpDis2', true);
5371 return $str;
5372 }
5373
5374 function getItemGpDis3($post_id) {
5375 $str = get_post_meta($post_id, '_itemGpDis3', true);
5376 return $str;
5377 }
5378
5379 function getItemSku($post_id, $index = '') {
5380 $array = array();
5381 $skus = $this->get_skus($post_id, 'sort');
5382 foreach((array)$skus as $sku){
5383 $array[] = $sku['code'];
5384 }
5385 if(!$array) return false;
5386 if($index == ''){
5387 return $array;
5388 }else if(isset($array[$index])){
5389 return $array[$index];
5390 }else{
5391 return false;
5392 }
5393 }
5394
5395 function getItemPrice($post_id, $skukey = '') {
5396 $array = array();
5397 $skus = $this->get_skus($post_id, 'code');
5398 foreach((array)$skus as $key => $sku){
5399 $array[$key] = (float)str_replace('.', '', $sku['price']);
5400 }
5401 if(!$array) return false;
5402 if($skukey == ''){
5403 return $array;
5404 }else if(isset($array[$skukey])){
5405 return $array[$skukey];
5406 }else{
5407 return false;
5408 }
5409 }
5410
5411 function getItemDiscount($post_id, $skukey = '') {
5412 $display_mode = $this->options['display_mode'];
5413 $array = array();
5414 $skus = $this->get_skus($post_id, 'code');
5415 foreach((array)$skus as $key => $sku){
5416 $price = (float)str_replace(',', '', $sku['price']);
5417 if ( $display_mode == 'Promotionsale' ) {
5418 if ( $this->options['campaign_privilege'] == 'discount' ){
5419 if( 0 === (int)$this->options['campaign_category'] || in_category((int)$this->options['campaign_category'], $post_id) ){
5420 $discount = $price * $this->options['privilege_discount'] / 100;
5421 }else{
5422 $discount = 0;
5423 }
5424 }else if ( $this->options['campaign_privilege'] == 'point' ){
5425 $discount = 0;
5426 }
5427 }
5428
5429 $discount = ceil($discount);
5430 $array[$key] = $discount;
5431 }
5432 if(!$array) return false;
5433 if($skukey == ''){
5434 return $array;
5435 }else if(isset($array[$skukey])){
5436 return $array[$skukey];
5437 }else{
5438 return false;
5439 }
5440 }
5441
5442 function getItemZaiko($post_id, $skukey = '') {
5443 $array = array();
5444 $skus = $this->get_skus($post_id, 'code');
5445 foreach((array)$skus as $key => $sku){
5446 $num = $sku['stock'];
5447 $array[$key] = $this->zaiko_status[$num];
5448 }
5449 if(!$array) return false;
5450 if($skukey == ''){
5451 return $array;
5452 }else if(isset($array[$skukey])){
5453 return $array[$skukey];
5454 }else{
5455 return false;
5456 }
5457 }
5458
5459 function getItemZaikoStatusId($post_id, $skukey = '') {
5460 $array = array();
5461 $skus = $this->get_skus($post_id, 'code');
5462 foreach((array)$skus as $key => $sku){
5463 $num = $sku['stock'];
5464 $array[$key] = $num;
5465 }
5466 if(!$array) return false;
5467 if($skukey == ''){
5468 return $array;
5469 }else if(isset($array[$skukey])){
5470 return $array[$skukey];
5471 }else{
5472 return false;
5473 }
5474 }
5475
5476 function updateItemZaiko($post_id, $skucode, $value) {
5477 $res = usces_update_sku( $post_id, $skucode, 'stock', $value );
5478 if( !$res ){
5479 return false;
5480 }else{
5481 return true;
5482 }
5483 }
5484
5485 function getItemZaikoNum($post_id, $skukey = '') {
5486 $array = array();
5487 $skus = $this->get_skus($post_id, 'code');
5488 foreach((array)$skus as $key => $sku){
5489 $array[$key] = $sku['stocknum'];
5490 }
5491 if(!$array) return false;
5492 if($skukey == ''){
5493 return $array;
5494 }else if(isset($array[$skukey])){
5495 return $array[$skukey];
5496 }else{
5497 return false;
5498 }
5499 }
5500
5501 function updateItemZaikoNum($post_id, $skucode, $value) {
5502 $res = usces_update_sku( $post_id, $skucode, 'stocknum', $value );
5503 if( !$res ){
5504 return false;
5505 }else{
5506 return true;
5507 }
5508 }
5509 //20120629ysk start 0000520
5510 function getItemDivision( $post_id ){
5511 if( usces_is_item($post_id) ){
5512 $item_division = get_post_meta($post_id, '_item_division', true);
5513 $division = empty($item_division) ? 'shipped' : $item_division;
5514 }else{
5515 $division = NULL;
5516 }
5517 return $division;
5518 }
5519 //20120629ysk end
5520 function getItemChargingType( $post_id, $cart = array() ){
5521 if( usces_is_item($post_id) ){
5522 $charging = get_post_meta($post_id, '_item_charging_type', true);
5523 //if( !defined('WCEX_DLSELLER') )
5524 if( !defined('WCEX_DLSELLER') and !defined('WCEX_AUTO_DELIVERY') )
5525 $charging = NULL;
5526 }else{
5527 $charging = NULL;
5528 }
5529 switch( $charging ){
5530 case 0:
5531 $type = 'once';
5532 break;
5533 case 1:
5534 $type = 'continue';
5535 break;
5536 case 2:
5537 $type = 'regular';
5538 if( !empty($cart) ) {
5539 if( empty($cart['advance']) ) {
5540 $type = 'once';
5541 } else {
5542 $advance = $this->cart->wc_unserialize( $cart['advance'] );
5543 $sku = urldecode( $cart['sku'] );
5544 $regular = $advance[$post_id][$sku]['regular'];
5545 $unit = isset( $regular['unit'] ) ? $regular['unit'] : '';
5546 $interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0;
5547 if( empty($unit) or 1 > $interval ) //通常課金扱い
5548 $type = 'once';
5549 }
5550 }
5551 break;
5552 default:
5553 $type = NULL;
5554 }
5555 return $type;
5556 }
5557
5558 function getItemFrequency( $post_id ){
5559 $frequency = get_post_meta($post_id, '_item_frequency',true );
5560 return $frequency;
5561 }
5562
5563 function getItemChargingDay( $post_id ){
5564 $array = get_post_meta($post_id, '_item_chargingday',true );
5565 $day = (int)$array;
5566 $chargingday = empty($day) ? 1 : $day;
5567 return $chargingday;
5568 }
5569
5570 function getItemSkuDisp($post_id, $skukey = '') {
5571 $array = array();
5572 $skus = $this->get_skus($post_id, 'code');
5573 foreach((array)$skus as $key => $sku){
5574 $array[$key] = $sku['name'];
5575 }
5576 if(!$array) return false;
5577 if($skukey == ''){
5578 return $array;
5579 }else if(isset($array[$skukey])){
5580 return $array[$skukey];
5581 }else{
5582 return false;
5583 }
5584 }
5585
5586 // function getItemSkuChargingType($post_id, $skukey = '') {
5587 // $fields = get_post_custom($post_id);
5588 // $skus = array();
5589 // foreach((array)$fields as $key => $value){
5590 // if( preg_match('/^_isku_/', $key, $match) ){
5591 // $key = substr($key, 6);
5592 // $values = maybe_unserialize($value[0]);
5593 // if( isset($values['charging_type']) && "undefined" != $values['charging_type'] && !empty($values['charging_type']) ){
5594 // $skus[$key] = $values['charging_type'];
5595 // }else{
5596 // continue;
5597 // }
5598 // }
5599 // }
5600 // if( empty($skus) ) return false;
5601 // if($skukey == ''){
5602 // return $skus;
5603 // }elseif( isset($skus[$skukey]) ){
5604 // return $skus[$skukey];
5605 // }else{
5606 // return false;
5607 // }
5608 // }
5609
5610 function getItemSkuUnit($post_id, $skukey = '') {
5611 $array = array();
5612 $skus = $this->get_skus($post_id, 'code');
5613 foreach((array)$skus as $key => $sku){
5614 $array[$key] = $sku['unit'];
5615 }
5616 if(!$array) return false;
5617 if($skukey == ''){
5618 return $array;
5619 }else if(isset($array[$skukey])){
5620 return $array[$skukey];
5621 }else{
5622 return false;
5623 }
5624 }
5625
5626 function get_item( $post_id ) {
5627 $usces_item['post_id'] = $post_id;
5628 $usces_item['itemCode'] = $this->getItemCode($post_id);
5629 $usces_item['itemName'] = $this->getItemName($post_id);
5630
5631 $skus = $this->get_skus($post_id, 'code');
5632 foreach((array)$skus as $key => $sku){
5633 $usces_item['skuCodes'][] = $key;
5634 $usces_item['skuValues'][] = $sku;
5635 }
5636
5637 $usces_item = apply_filters('usces_filter_get_item', $usces_item, $post_id);
5638
5639 return $usces_item;
5640 }
5641
5642 function get_itemOptionKey( $post_id, $enc = false ) {
5643 $opts = usces_get_opts( $post_id );
5644 if(empty($opts)) return;
5645
5646 $res = array();
5647 foreach ( (array)$opts as $opt ) {
5648 if( $enc )
5649 $res[] = urlencode($opt['name']);
5650 else
5651 $res[] = $opt['name'];
5652 }
5653 return $res;
5654 }
5655
5656 function get_itemOptions( $key, $post_id ) {
5657 $opts = usces_get_opts( $post_id, 'name' );
5658 if(empty($opts[$key]))
5659 return;
5660 else
5661 return $opts[$key];
5662 }
5663
5664 function get_postIDbyCode( $itemcode ) {
5665 global $wpdb;
5666
5667 $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_itemCode', $itemcode);
5668 $res = $wpdb->get_var( $query );
5669 return $res;
5670 }
5671
5672 function get_pictids($item_code) {
5673 global $wpdb, $usces;
5674
5675 if( empty($item_code) )
5676 return false;
5677
5678 if( !$usces->options['system']['subimage_rule'] ){
5679 $codestr = $item_code.'%';
5680 $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);
5681 }else{
5682 $codestr = $item_code.'--%';
5683 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr);
5684 }
5685 $results = $wpdb->get_col( $query );
5686 return $results;
5687 }
5688
5689 function get_mainpictid($item_code) {
5690 global $wpdb;
5691 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $item_code);
5692 $id = $wpdb->get_var( $query );
5693 $id = apply_filters( 'usces_filter_get_mainpictid', $id, $item_code );
5694 return $id;
5695 }
5696
5697 function get_skus( $post_id, $keyflag = 'sort' ) {
5698 if( !$post_id )
5699 return array();
5700
5701 $skus = array();
5702 $metas = usces_get_post_meta($post_id, '_isku_');
5703 if( empty($metas) ) return $skus;
5704
5705 foreach( $metas as $rows ){
5706 $values = unserialize($rows['meta_value']);
5707 $key = isset($values[$keyflag]) ? $values[$keyflag] : $values['sort'];
5708 $skus[$key] = array(
5709 'meta_id' => $rows['meta_id'],
5710 'code' => $values['code'],
5711 'name' => $values['name'],
5712 'cprice' => $values['cprice'],
5713 'price' => $values['price'],
5714 'unit' => $values['unit'],
5715 'stocknum' => $values['stocknum'],
5716 'stock' => $values['stock'],
5717 'gp' => $values['gp'],
5718 'sort' => $values['sort'],
5719 'advance' => isset($values['advance']) ? $values['advance'] : ''
5720 );
5721 }
5722 $skus = apply_filters( 'usces_filter_get_skus', $skus, $post_id, $keyflag );
5723 ksort($skus);
5724
5725 return $skus;
5726 }
5727
5728 function is_item( $post ) {
5729
5730 if( $post->post_mime_type == 'item' )
5731 return true;
5732 else
5733 return false;
5734 }
5735
5736 function getItemIds( $end_type ) {
5737 global $wpdb;
5738 if( 'front' == $end_type )
5739 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item');
5740 if( 'back' == $end_type )
5741 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5742 $ids = $wpdb->get_col( $query );
5743 if( empty($ids) ) $ids = array();
5744 return $ids;
5745 }
5746
5747 function getNotItemIds() {
5748 global $wpdb;
5749 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item');
5750 $ids = $wpdb->get_col( $query );
5751 if( empty($ids) ) $ids = array();
5752 return $ids;
5753 }
5754
5755 function getPaymentMethod( $name ) {
5756 $res = array();
5757 $payments = $this->options['payment_method'];
5758 foreach ( (array)$payments as $payment ) {
5759 if($name = $payment['name']) {
5760 $res = $payment;
5761 break;
5762 }
5763 }
5764 return $res;
5765 }
5766
5767 function order_processing( $results = array() ) {
5768 do_action('usces_pre_reg_orderdata');
5769 //db(function.php)
5770 //20110203ysk start
5771 $res = usces_check_acting_return_duplicate( $results );
5772 if($res != NULL) {
5773 usces_log('order processing duplicate : acting='.$_REQUEST['acting'].', order_id='.$res, 'acting_transaction.log');
5774 return 'ordercompletion';
5775 }
5776 if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) {
5777 usces_log($_REQUEST['acting'].' transaction : '.$_REQUEST['gid'], 'acting_transaction.log');//OK
5778 }
5779 //20110203ysk end
5780 //20110621ysk start 0000184
5781 if(isset($_REQUEST['acting']) && ('paypal_ec' == $_REQUEST['acting'])) {
5782 if( !usces_paypal_doecp( $results ) )
5783 return 'error';
5784 }
5785 //20110621ysk end
5786 $order_id = usces_reg_orderdata( $results );
5787 do_action('usces_post_reg_orderdata', $order_id, $results);
5788
5789 if ( $order_id ) {
5790 //mail(function.php)
5791 $mail_res = usces_send_ordermail( $order_id );
5792 return 'ordercompletion';
5793
5794 } else {
5795 return 'error';
5796 }
5797
5798 }
5799
5800 function acting_processing($acting_flg, $query) {
5801 global $wpdb;
5802 $entry = $this->cart->get_entry();
5803 $delim = apply_filters( 'usces_filter_delim', $this->delim );
5804 $acting_flg = trim($acting_flg);
5805 //$usces_entries = $this->cart->get_entry();
5806
5807 if( empty($acting_flg) ) return 'error';
5808
5809
5810 //include(USCES_PLUGIN_DIR . '/settlement/' . $acting_flg);
5811 if($acting_flg == 'paypal.php'){
5812 // if( !file_exists($this->options['settlement_path'] . $acting_flg) )
5813 // return 'error';
5814 //
5815 // require_once($this->options['settlement_path'] . "paypal.php");
5816 // paypal_submit();
5817
5818 }else if($acting_flg == 'epsilon.php'){
5819 if( !file_exists($this->options['settlement_path'] . $acting_flg) )
5820 return 'error';
5821
5822 if ( $this->use_ssl ) {
5823 $redirect = str_replace('http://', 'https://', USCES_CART_URL);
5824 }else{
5825 $redirect = USCES_CART_URL;
5826 }
5827 usces_log('epsilon card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5828 $query .= '&settlement=epsilon&redirect_url=' . urlencode($redirect);
5829 $query = $delim . ltrim($query, '&');
5830 header("location: " . $redirect . $query);
5831 exit;
5832
5833 }else if($acting_flg == 'acting_zeus_card' && 2 == $this->options['acting_settings']['zeus']['connection'] ){
5834 if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] ){
5835 if( !isset($_REQUEST['PaRes'])){
5836
5837 usces_log('zeus card entry data2 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5838 usces_zeus_3dsecure_enrol();
5839
5840 }else if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] && isset($_REQUEST['PaRes'])){
5841
5842 usces_zeus_3dsecure_auth();
5843 }
5844 }else{
5845 $res = usces_zeus_secure_payreq();
5846 return $res;
5847 }
5848 }else if($acting_flg == 'acting_zeus_card' && 1 == $this->options['acting_settings']['zeus']['connection'] ){
5849
5850 $acting_opts = $this->options['acting_settings']['zeus'];
5851 $interface = parse_url($acting_opts['card_url']);
5852
5853 //usces_log('zeus card ***** : '.print_r($entry, true), 'acting_transaction.log');
5854
5855 $vars = 'send=mall';
5856 $vars .= '&clientip=' . $acting_opts['clientip'];
5857 $vars .= '&cardnumber=' . $_POST['cardnumber'];
5858 if( 1 == $this->options['acting_settings']['zeus']['security'] ){
5859 $vars .= '&seccode=' . $_POST['securecode'];
5860 }
5861 $vars .= '&expyy=' . substr($_POST['expyy'], 2);
5862 $vars .= '&expmm=' . $_POST['expmm'];
5863 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
5864 $vars .= '&email=' . $_POST['email'];
5865 $vars .= '&sendid=' . $_POST['sendid'];
5866 $vars .= '&username=' . $_POST['username'];
5867 $vars .= '&money=' . $_POST['money'];
5868 $vars .= '&sendpoint=' . $_POST['sendpoint'];
5869 $vars .= '&printord=' . $_POST['printord'];
5870 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
5871 $vars .= '&div=' . $_POST['div'];
5872 }
5873
5874 //usces_log('zeus card *****vars : '.print_r($vars, true), 'acting_transaction.log');
5875
5876 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
5877 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
5878 //$header .= "Host: usctest.securesites.com\r\n";
5879 $header .= "User-Agent: PHP Script\r\n";
5880 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
5881 $header .= "Content-Length: " . strlen($vars) . "\r\n";
5882 $header .= "Connection: close\r\n\r\n";
5883 $header .= $vars;
5884 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
5885
5886 if ($fp){
5887 fwrite($fp, $header);
5888 while ( !feof($fp) ) {
5889 $scr = fgets($fp, 1024);
5890 $page .= $scr;
5891 }
5892 fclose($fp);
5893
5894 //usces_log('zeus card *****2 : '.print_r($page, true), 'acting_transaction.log');
5895 if( false !== strpos( $page, 'Success_order') ){
5896 usces_log('zeus card entry data1 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5897 $ordd = usces_get_order_number( $page );
5898 //20120904ysk start 0000541
5899 if ( !isset($_POST['cbrand']) || (isset($_POST['howpay']) && 1 == $_POST['howpay']) ) {
5900 $args = '';
5901 } else {
5902 $div = 'div_'.$_POST['cbrand'];
5903 $args = '&cbrand='.$_POST['cbrand'].'&howpay='.$_POST['howpay'].'&'.$div.'='.$_POST[$div];
5904 }
5905 $args .= '&order_number='.$ordd;
5906 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=1'.$args);
5907 //20120904ysk end
5908 exit;
5909 }else{
5910 usces_log('zeus card : Certification Error', 'acting_transaction.log');
5911 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
5912 exit;
5913 }
5914 }else{
5915 usces_log('zeus card : Socket Error', 'acting_transaction.log');
5916 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
5917 }
5918 exit;
5919
5920 }else if($acting_flg == 'acting_zeus_conv'){
5921
5922 $acting_opts = $this->options['acting_settings']['zeus'];
5923 $interface = parse_url($acting_opts['conv_url']);
5924
5925
5926 $vars .= 'clientip=' . $acting_opts['clientip_conv'];
5927 $vars .= '&act=' . $_POST['act'];
5928 $vars .= '&money=' . $_POST['money'];
5929 $vars .= '&username=' . mb_convert_encoding($_POST['username'], 'SJIS', 'UTF-8');
5930 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
5931 $vars .= '&email=' . $_POST['email'];
5932 $vars .= '&pay_cvs=' . $_POST['pay_cvs'];
5933 $vars .= '&sendid=' . $_POST['sendid'];
5934 $vars .= '&sendpoint=' . $_POST['sendpoint'];
5935 if( !WCUtils::is_blank($acting_opts['testid_conv']) ){
5936 $vars .= '&testid=' . $acting_opts['testid_conv'];
5937 $vars .= '&test_type=' . $acting_opts['test_type_conv'];
5938 }
5939
5940
5941 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
5942 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
5943 $header .= "User-Agent: PHP Script\r\n";
5944 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
5945 $header .= "Content-Length: " . strlen($vars) . "\r\n";
5946 $header .= "Connection: close\r\n\r\n";
5947 $header .= $vars;
5948 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
5949
5950 if ($fp){
5951 fwrite($fp, $header);
5952 while ( !feof($fp) ) {
5953 $scr = fgets($fp, 1024);
5954 $page .= $scr;
5955 if( false !== strpos( $scr, 'order_no') )
5956 $qstr .= trim($scr) . '&';
5957 if( false !== strpos( $scr, 'pay_no1') )
5958 $qstr .= trim($scr) . '&';
5959 if( false !== strpos( $scr, 'pay_no2') )
5960 $qstr .= trim($scr) . '&';
5961 if( false !== strpos( $scr, 'pay_limit') )
5962 $qstr .= trim($scr) . '&';
5963 if( false !== strpos( $scr, 'pay_url') )
5964 $qstr .= trim($scr) . '&';
5965 if( false !== strpos( $scr, 'error_code') )
5966 $qstr .= trim($scr) . '&';
5967 if( false !== strpos( $scr, 'sendpoint') )
5968 $qstr .= trim($scr) . '&';
5969 }
5970 $qstr .= 'pay_cvs=' . $_POST['pay_cvs'];
5971 fclose($fp);
5972 //usces_log('zeus page : '.$page, 'acting_transaction.log');
5973
5974 if( false !== strpos( $page, 'Success_order') ){
5975 usces_log('zeus conv entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5976 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=1&' . $qstr);
5977 exit;
5978 }else{
5979 usces_log('zeus data NG : '.$page, 'acting_transaction.log');
5980 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
5981 exit;
5982 }
5983 }else{
5984 usces_log('zeus : sockopen NG', 'acting_transaction.log');
5985 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
5986 }
5987 exit;
5988
5989 //20110208ysk start
5990 }else if($acting_flg == 'acting_paypal_ec') {
5991 $acting_opts = $this->options['acting_settings']['paypal'];
5992
5993 $nvpstr = $query;
5994 $nvpstr .= '&CURRENCYCODE='.$this->get_currency_code();
5995 //$nvpstr .= '&ADDROVERRIDE=1';
5996 $nvpstr .= '&PAYMENTACTION=' . apply_filters('usces_filter_paypal_ec_paymentaction', 'Sale');
5997
5998 //The returnURL is the location where buyers return to when a payment has been succesfully authorized.
5999 $nvpstr .= '&RETURNURL='.urlencode(USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=1');
6000
6001 //The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow
6002 $nvpstr .= '&CANCELURL='.urlencode(USCES_CART_URL.$delim.'confirm=1');
6003
6004 $nvpstr .= '&NOTIFYURL='.urlencode(USCES_PAYPAL_NOTIFY_URL);
6005
6006 $this->paypal->setMethod('SetExpressCheckout');
6007 $this->paypal->setData($nvpstr);
6008 $res = $this->paypal->doExpressCheckout();
6009 $resArray = $this->paypal->getResponse();
6010 $ack = strtoupper($resArray["ACK"]);
6011 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
6012 $token = urldecode($resArray["TOKEN"]);
6013 $payPalURL = $acting_opts['paypal_url'].'?cmd=_express-checkout&token='.$token.'&useraction=commit';
6014 header("Location: ".$payPalURL);
6015
6016 } else {
6017 //Display a user friendly Error on the page using any of the following error information returned by PayPal
6018 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
6019 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
6020 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
6021 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
6022 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');
6023 header("Location: ".USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=0');
6024 }
6025 exit;
6026 //20110208ysk end
6027 //20121030ysk start
6028 } elseif( $acting_flg == 'acting_telecom_edy' ) {
6029 $table_meta_name = $wpdb->prefix."usces_order_meta";
6030 $value = array();
6031 $value['usces_cart'] = $_SESSION['usces_cart'];
6032 $value['usces_entry'] = $_SESSION['usces_entry'];
6033 $value['usces_member'] = $_SESSION['usces_member'];
6034 $mvalue = serialize( $value );
6035 $mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue );
6036 $res = $wpdb->query( $mquery );
6037
6038 unset( $_SESSION['usces_cart'] );
6039 unset( $_SESSION['usces_entry'] );
6040
6041 $acting_opts = $this->options['acting_settings']['telecom'];
6042 header( "location: ".$acting_opts['send_url_edy'].'?acting=telecom_edy'.$query );
6043 exit;
6044 //20121030ysk end
6045 //20121206ysk start
6046 } else if( $acting_flg == 'acting_digitalcheck_card' ) {
6047 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6048 $interface = parse_url($acting_opts['send_url_user_id']);
6049 $kakutei = ( empty($acting_opts['card_kakutei']) ) ? '0' : $acting_opts['card_kakutei'];
6050
6051 $vars = 'IP='.$acting_opts['card_ip'];
6052 $vars .= '&PASS='.$acting_opts['card_pass'];
6053 $vars .= '&IP_USER_ID='.$_POST['IP_USER_ID'];
6054 $vars .= '&SID='.$_POST['SID'];
6055 $vars .= '&STORE=51';
6056 $vars .= '&N1='.$_POST['N1'];
6057 $vars .= '&K1='.$_POST['K1'];
6058 $vars .= '&KAKUTEI='.$kakutei;
6059 $vars .= '&FUKA='.$acting_flg;
6060
6061 $header = "POST ".$interface['path']." HTTP/1.1\r\n";
6062 $header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
6063 $header .= "User-Agent: PHP Script\r\n";
6064 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6065 $header .= "Content-Length: ".strlen($vars)."\r\n";
6066 $header .= "Connection: close\r\n\r\n";
6067 $header .= $vars;
6068 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6069
6070 if( $fp ) {
6071 fwrite( $fp, $header );
6072 $page = '';
6073 while( !feof($fp) ) {
6074 $line = fgets( $fp, 1024 );
6075 if( strcmp($line, "\r\n") == 0 ) {
6076 $headerdone = true;
6077 } elseif( $headerdone ) {
6078 $page .= $line;
6079 }
6080 }
6081 fclose($fp);
6082 $lines = explode("\n", $page);
6083 if( false !== strpos( $lines[0], 'OK') ) {
6084 usces_log('digitalcheck card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6085 //$args = '&SID='.$lines[1];
6086 $args = '&SID='.$_POST['SID'].'&FUKA='.$acting_flg;
6087 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=1'.$args );
6088 } else {
6089 usces_log('digitalcheck card : Certification Error : '.$page, 'acting_transaction.log');
6090 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6091 }
6092 } else {
6093 usces_log('digitalcheck card : Socket Error', 'acting_transaction.log');
6094 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6095 }
6096 exit;
6097 } else if( $acting_flg == 'acting_digitalcheck_conv' ) {
6098 if( isset($_REQUEST['STORE']) and '99' != $_REQUEST['STORE'] ) {
6099 $res = $this->order_processing();
6100 if( 'ordercompletion' == $res ) {
6101 $table_meta_name = $wpdb->prefix."usces_order_meta";
6102 $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] );
6103 $order_id = $wpdb->get_var($mquery);
6104 if( $order_id ) {
6105 $data = array( "settltment_status" => "未決済", "settltment_errmsg" => "決済が完了していません" );
6106 $this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
6107 }
6108 $this->cart->crear_cart();
6109 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6110 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6111 exit;
6112 } else {
6113 usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
6114 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=0' );
6115 }
6116 } else {
6117 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6118 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6119 exit;
6120 }
6121 //20121206ysk end
6122 }
6123 do_action('usces_action_acting_processing', $acting_flg, $query);
6124 }
6125
6126 function inquiry_processing() {
6127
6128 $mail_res = usces_send_inquirymail();
6129
6130 if ( $mail_res )
6131 return 'inquiry_comp';
6132 else
6133 return 'inquiry_error';
6134 }
6135
6136 function lastprocessing() {
6137
6138 if ( $this->page == 'ordercompletion' )
6139 $this->cart->crear_cart();
6140
6141 unset($_SESSION['usces_singleitem']);
6142
6143 }
6144
6145 function is_item_zaiko( $post_id, $sku ){
6146 $status_num = (int)$this->getItemZaikoStatusId($post_id, $sku);
6147 $zaiko_num = trim($this->getItemZaikoNum($post_id, $sku));
6148
6149 if( false !== $zaiko_num
6150 && ( 0 < (int)$zaiko_num || WCUtils::is_blank($zaiko_num) )
6151 && false !== $status_num
6152 && 2 > $status_num
6153 ){
6154 return true;
6155 }else{
6156 return false;
6157 }
6158 }
6159
6160 // function for the cart ***********************************************************
6161 function get_total_price( $cart = array() ) {
6162 if( empty($cart) )
6163 $cart = $this->cart->get_cart();
6164
6165 $total_price = 0;
6166
6167 if( !empty($cart) ) {
6168 for($i=0; $i<count($cart); $i++) {
6169 $quantity = $cart[$i]['quantity'];
6170 $skuPrice = $cart[$i]['price'];
6171
6172 $total_price += ($skuPrice * $quantity);
6173 }
6174 }
6175 return apply_filters( 'usces_filter_get_total_price', $total_price, $cart);
6176 }
6177
6178 function get_total_quantity( $cart = array() ) {
6179 if( empty($cart) )
6180 $cart = $this->cart->get_cart();
6181
6182 $total_quantity = 0;
6183
6184 if( !empty($cart) ) {
6185 for($i=0; $i<count($cart); $i++) {
6186 $total_quantity += $cart[$i]['quantity'];
6187 }
6188 }
6189 return $total_quantity;
6190 }
6191
6192 function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) {
6193 if( $mem_id == '' || $this->options['membersystem_state'] == 'deactivate' || $this->options['membersystem_point'] == 'deactivate') return 0;
6194
6195 if ( empty($cart) )
6196 $cart = $this->cart->get_cart();
6197
6198 if ( empty($display_mode) )
6199 $display_mode = $this->options['display_mode'];
6200
6201 $point = 0;
6202 $total = $this->get_total_price( $cart );
6203 if ( $display_mode == 'Promotionsale' ) {
6204 if ( $this->options['campaign_privilege'] == 'discount' ) {
6205 foreach ( $cart as $rows ) {
6206 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6207 if ( !in_array($this->options['campaign_category'], $cats) ){
6208 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6209 $price = $rows['price'] * $rows['quantity'];
6210 $point += $price * $rate / 100;
6211 }
6212 }
6213 } elseif ( $this->options['campaign_privilege'] == 'point' ) {
6214 foreach ( $cart as $rows ) {
6215 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6216 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6217 $price = $rows['price'] * $rows['quantity'];
6218 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6219 if ( in_array($this->options['campaign_category'], $cats) )
6220 $point += $price * $rate / 100 * $this->options['privilege_point'];
6221 else
6222 $point += $price * $rate / 100;
6223 }
6224 }
6225 } else {
6226 foreach ( $cart as $rows ) {
6227 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6228 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6229 $price = $rows['price'] * $rows['quantity'];
6230 $point += $price * $rate / 100;
6231 }
6232 }
6233
6234 //20130425ysk start 0000699
6235 if( 0 < $point ) $point = ceil( $point );
6236
6237 $entry = $this->cart->get_entry();
6238 $use_point = isset( $entry['order']['usedpoint'] ) ? (int)$entry['order']['usedpoint'] : 0;
6239 if( 0 < $use_point ) {
6240 $point = ceil( $point - ( $point * $use_point / $total ) );
6241 if( 0 > $point )
6242 $point = 0;
6243 }
6244
6245 return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart );
6246 //20130425ysk end
6247 }
6248
6249 function get_order_discount( $display_mode = '', $cart = array() ) {
6250 if ( empty($cart) )
6251 $cart = $this->cart->get_cart();
6252
6253 if ( empty($display_mode) )
6254 $display_mode = $this->options['display_mode'];
6255
6256 $discount = 0;
6257 $total = $this->get_total_price( $cart );
6258 if ( $display_mode == 'Promotionsale' ) {
6259 if ( $this->options['campaign_privilege'] == 'discount' ){
6260 if( 0 === (int)$this->options['campaign_category'] ){
6261 $discount = $total * $this->options['privilege_discount'] / 100;
6262 }else{
6263 foreach($cart as $cart_row){
6264 if( in_category((int)$this->options['campaign_category'], $cart_row['post_id']) ){
6265 $discount += $cart_row['price'] * $cart_row['quantity'] * $this->options['privilege_discount'] / 100;
6266 }
6267 }
6268 }
6269 }else if ( $this->options['campaign_privilege'] == 'point' ){
6270 $discount = 0;
6271 }
6272 }
6273
6274 $discount = ceil($discount * -1);
6275 $discount = apply_filters('usces_order_discount', $discount, $cart);
6276 return $discount;
6277 }
6278
6279 function getShippingCharge( $pref, $cart = array(), $entry = array() ) {
6280 if( empty($cart) )
6281 $cart = $this->cart->get_cart();
6282 if( empty($entry) )
6283 $entry = $this->cart->get_entry();
6284
6285 //�
6286 �送方法ID
6287 $d_method_id = $entry['order']['delivery_method'];
6288 //�
6289 �送方法index
6290 $d_method_index = $this->get_delivery_method_index($d_method_id);
6291 //送料ID
6292 $fixed_charge_id = ( isset($this->options['delivery_method'][$d_method_index]['charge']) ) ? $this->options['delivery_method'][$d_method_index]['charge'] : -1;
6293 $individual_quant = 0;
6294 $total_quant = 0;
6295 $charges = array();
6296 $individual_charges = array();
6297 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
6298
6299 foreach ( $cart as $rows ) {
6300
6301 if( -1 == $fixed_charge_id ){
6302 //商品送料ID
6303 $s_charge_id = $this->getItemShippingCharge($rows['post_id']);
6304 //商品送料index
6305 $s_charge_index = $this->get_shipping_charge_index($s_charge_id);
6306 //20120710ysk start 0000472
6307 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6308 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6309 //20120710ysk end
6310 }else{
6311
6312 $s_charge_index = $this->get_shipping_charge_index($fixed_charge_id);
6313 //20120710ysk start 0000472
6314 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6315 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6316 //20120710ysk end
6317 }
6318
6319 if($this->getItemIndividualSCharge($rows['post_id'])){
6320 $individual_quant += $rows['quantity'];
6321 $individual_charges[] = $rows['quantity'] * $charge;
6322 }else{
6323 $charges[] = $charge;
6324 }
6325 $total_quant += $rows['quantity'];
6326 }
6327
6328 if( count($charges) > 0 ){
6329 rsort($charges);
6330 $max_charge = $charges[0];
6331 $charge = $max_charge + array_sum($individual_charges);
6332 }else{
6333 $charge = array_sum($individual_charges);
6334 }
6335
6336 $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
6337
6338 return $charge;
6339 }
6340
6341 function getCODFee($payment_name, $amount_by_cod) {
6342 $payments = $this->getPayments($payment_name);
6343 if( 'COD' != $payments['settlement'] ){
6344 $fee = 0;
6345
6346 }else if( 'change' != $this->options['cod_type'] ){
6347 //$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : '';
6348 $fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : 0;
6349
6350 }else{
6351 $price = $amount_by_cod + $this->getTax( $amount_by_cod );
6352 if( $price <= $this->options['cod_first_amount'] ){
6353 $fee = $this->options['cod_first_fee'];
6354
6355 }else if( isset($this->options['cod_amounts']) ){
6356 $last = count( $this->options['cod_amounts'] ) - 1;
6357 if( $price > $this->options['cod_amounts'][$last] ){
6358 $fee = $this->options['cod_end_fee'];
6359
6360 }else{
6361 $fee = 0;
6362 foreach( $this->options['cod_amounts'] as $key => $value ){
6363 if( $price <= $value ){
6364 $fee = $this->options['cod_fees'][$key];
6365 break;
6366 }
6367 }
6368 }
6369 }else{
6370 $fee = $this->options['cod_end_fee'];
6371 }
6372 }
6373 $fee = apply_filters('usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod);
6374 return $fee;
6375 }
6376
6377 function getTax( $total ) {
6378 if( empty($this->options['tax_rate']) )
6379 return 0;
6380
6381 if( $this->options['tax_method'] == 'cutting' )
6382 $tax = floor($total * $this->options['tax_rate'] / 100);
6383 elseif($this->options['tax_method'] == 'bring')
6384 $tax = ceil($total * $this->options['tax_rate'] / 100);
6385 elseif($this->options['tax_method'] == 'rounding')
6386 $tax = round($total * $this->options['tax_rate'] / 100);
6387
6388 return $tax;
6389 }
6390
6391 function set_cart_fees( $member, &$entries ) {
6392 $carts = $this->cart->get_cart();
6393 $total_items_price = $this->get_total_price();
6394 if ( empty($this->options['postage_privilege']) || $total_items_price < $this->options['postage_privilege'] ) {
6395 $shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'] );
6396 } else {
6397 $shipping_charge = 0;
6398 }
6399 $shipping_charge = apply_filters('usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries);
6400 $payments = $this->getPayments( $entries['order']['payment_name'] );
6401 $discount = $this->get_order_discount();
6402 $use_point = $entries['order']['usedpoint'];
6403 $amount_by_cod = $total_items_price - $use_point + $discount + $shipping_charge;
6404 $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);
6405 $cod_fee = $this->getCODFee($entries['order']['payment_name'], $amount_by_cod);
6406 $cod_fee = apply_filters('usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge);
6407 $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
6408 $total_price = apply_filters('usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee);
6409 $tax = $this->getTax( $total_price );
6410 $total_full_price = $total_price + $tax;
6411 $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);
6412 $get_point = $this->get_order_point( $member['ID'] );
6413 //20130425ysk start 0000699
6414 //if(0 < (int)$use_point){
6415 // $get_point = ceil( $get_point - ($get_point * $use_point / $total_items_price) );
6416 // if(0 > $get_point)
6417 // $get_point = 0;
6418 //}
6419 //20130425ysk end
6420
6421 $array = array(
6422 'total_items_price' => $total_items_price,
6423 'total_price' => $total_price,
6424 'total_full_price' => $total_full_price,
6425 'getpoint' => $get_point,
6426 'usedpoint' => $use_point,
6427 'discount' => $discount,
6428 'shipping_charge' => $shipping_charge,
6429 'cod_fee' => $cod_fee,
6430 'tax' => $tax
6431 );
6432 $this->cart->set_order_entry( $array );
6433 //$entries = $this->cart->get_entry();
6434 //var_dump($entries);
6435 }
6436
6437 function getPayments( $payment_name ) {
6438 if( '#none#' == $payment_name )
6439 return NULL;
6440
6441 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
6442 if( isset($payments[$payment_name]) )
6443 return $payments[$payment_name];
6444 return NULL;
6445 }
6446
6447 function is_maintenance() {
6448 if ( $this->options['display_mode'] == 'Maintenancemode' )
6449 return true;
6450 else
6451 return false;
6452 }
6453
6454 // function maintenance_mode() {
6455 // if ( $this->is_maintenance() && !is_user_logged_in() && (!strstr($_SERVER['REQUEST_URI'], 'wp-admin') || !strstr($_SERVER['REQUEST_URI'], 'wp-login') ) ) {
6456 // include ( TEMPLATEPATH . '/maintenance.php ');
6457 // exit;
6458 // } elseif ( isset($_GET['uscesmode']) && $_GET['uscesmode'] == 'lostpassword' ) {
6459 // $error = isset($_GET['error']) ? '?error='.$_GET['error'] : '';
6460 // include ( TEMPLATEPATH . '/member/changepassword.php ');
6461 // exit;
6462 // }
6463 // }
6464
6465 function get_member_history($mem_id) {
6466 global $wpdb;
6467 $order_table = $wpdb->prefix . "usces_order";
6468
6469 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
6470 // $query = $wpdb->prepare("SELECT ID, order_cart, order_condition, order_date, order_usedpoint, order_getpoint,
6471 // order_discount, order_shipping_charge, order_cod_fee, order_tax, order_status
6472 // FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
6473 $results = $wpdb->get_results( $query );
6474
6475 $i=0;
6476 $res = array();
6477 foreach ( $results as $value ) {
6478 if(strpos($value->order_status, 'cancel') === false && strpos($value->order_status, 'estimate') === false){
6479
6480 $res[] = array(
6481 'ID' => $value->ID,
6482 'cart' => unserialize($value->order_cart),
6483 'condition' => unserialize($value->order_condition),
6484 'getpoint' => $value->order_getpoint,
6485 'usedpoint' => $value->order_usedpoint,
6486 'discount' => $value->order_discount,
6487 'shipping_charge' => $value->order_shipping_charge,
6488 'payment_name' => $value->order_payment_name,
6489 'cod_fee' => $value->order_cod_fee,
6490 'tax' => $value->order_tax,
6491 'order_status' => $value->order_status,
6492 'date' => mysql2date(__('Y/m/d'), $value->order_date),
6493 'order_date' => $value->order_date
6494 );
6495 $i++;
6496
6497 }
6498 }
6499
6500 return $res;
6501
6502 }
6503
6504 function get_post_term_ids( $post_id, $taxonomy ){
6505 global $wpdb;
6506 $query = $wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_relationships AS tr
6507 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
6508 WHERE tt.taxonomy = %s AND tr.object_id = %d", $taxonomy, $post_id);
6509 $ids = $wpdb->get_col( $query );
6510
6511 return $ids;
6512
6513 }
6514
6515 function get_tag_names($post_id) {
6516 global $wpdb;
6517 $tag = 'post_tag';
6518 $query = $wpdb->prepare("SELECT t.name FROM $wpdb->term_relationships AS tr
6519 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
6520 INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id
6521 WHERE tt.taxonomy = %s AND tr.object_id = %d", $tag, $post_id);
6522 $names = $wpdb->get_col( $query );
6523
6524 return apply_filters('usces_filter_get_tag_names', $names, $post_id);
6525
6526 }
6527
6528 function get_ID_byItemName($itemname, $status = 'publish') {
6529 global $wpdb;
6530 $meta_key = '_itemCode';
6531 $query = $wpdb->prepare("SELECT p.ID FROM $wpdb->posts AS p
6532 INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id
6533 WHERE p.post_status = %s AND pm.meta_key = %s AND meta_value = %s ", $status, $meta_key, $itemname);
6534 $id = $wpdb->get_var( $query );
6535
6536 // $wpdb->show_errors();
6537 // $wpdb->print_error();
6538
6539 return $id;
6540
6541 }
6542
6543 function uscescv( $sessid, $flag ) {
6544
6545 $chars = '';
6546 $i=0;
6547 $h=0;
6548 $usces_cookie = $this->get_cookie();
6549 if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
6550 $cid = $usces_cookie['id'];
6551 }elseif( isset($_SESSION['usces_cookieid']) && !empty($_SESSION['usces_cookieid']) ){
6552 $cid = $_SESSION['usces_cookieid'];
6553 }else{
6554 $cid = 0;
6555 }
6556 while($h<strlen($sessid)){
6557 if(0 == $i % 3){
6558 $chars .= substr($i, -1);
6559 }else{
6560 $chars .= substr($sessid, $h, 1);
6561 $h++;
6562 }
6563 $i++;
6564 }
6565 if( $flag ){
6566 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
6567 $postfix = apply_filters('usces_sessid_force', $postfix);
6568 $sessid = $chars . '_' . $postfix . '_' . $cid . '_A';
6569 }else{
6570 $sessid = $chars . '_' . apply_filters('usces_sessid_flag', 'acting') . '_' . $cid . '_A';
6571 }
6572 $sessid = urlencode(base64_encode($sessid));
6573 //usces_log('sessid2 : '.$sessid, 'acting_transaction.log');
6574
6575 return $sessid;
6576 }
6577
6578 function uscesdc( $sessid ) {
6579 // $usces_cookie = $this->get_cookie();
6580 // if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
6581 // if( isset($usces_cookie['sslid']) && !empty($usces_cookie['sslid']) ){
6582 // $cid = $usces_cookie['sslid'];
6583 // }else{
6584 // $cid = 0;
6585 // }
6586 // }else{
6587 // if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
6588 // $cid = $usces_cookie['id'];
6589 // }else{
6590 // $cid = 0;
6591 // }
6592 // }
6593 $sessid = base64_decode(urldecode($sessid));
6594 list($sess, $addr, $cookieid, $none) = explode('_', $sessid, 4);
6595 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
6596 $postfix = apply_filters('usces_sessid_force', $postfix);
6597 //usces_log('cid : '.$cid, 'acting_transaction.log');
6598 //usces_log('cookieid : '.$cookieid, 'acting_transaction.log');
6599 //usces_log('postfix : '.$postfix, 'acting_transaction.log');
6600 //usces_log('addr : '.$addr, 'acting_transaction.log');
6601 if( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) {
6602 $sessid = '';
6603 return NULL;
6604 }
6605 $chars = '';
6606 $h=0;
6607 while($h<strlen($sess)){
6608 if(0 != $h % 3){
6609 $chars .= substr($sess, $h, 1);
6610 }
6611 $h++;
6612 }
6613 $sessid = $chars;
6614
6615 return $sessid;
6616
6617 }
6618
6619 function get_visiter( $period ) {
6620 global $wpdb;
6621 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6622 $yearstr = substr($datestr, 0, 4);
6623 $monthstr = substr($datestr, 5, 2);
6624 $daystr = substr($datestr, 8, 2);
6625 if($period == 'today') {
6626 $date = $datestr;
6627 $today = $datestr;
6628 }else if($period == 'thismonth') {
6629 $date = date('Y-m-01');
6630 $today = $datestr;
6631 }else if($period == 'lastyear') {
6632 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6633 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
6634 }
6635 $table_name = $wpdb->prefix . 'usces_access';
6636
6637 $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);
6638 $res = $wpdb->get_row($query, ARRAY_A);
6639
6640 if( $res == NULL )
6641 return 0;
6642 else
6643 return $res['ct1']+$res['ct2'];
6644 }
6645
6646 function get_fvisiter( $period ) {
6647 global $wpdb;
6648 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6649 $yearstr = substr($datestr, 0, 4);
6650 $monthstr = substr($datestr, 5, 2);
6651 $daystr = substr($datestr, 8, 2);
6652 if($period == 'today') {
6653 $date = $datestr;
6654 $today = $datestr;
6655 }else if($period == 'thismonth') {
6656 $date = date('Y-m-01');
6657 $today = $datestr;
6658 }else if($period == 'lastyear') {
6659 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6660 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
6661 }
6662 $table_name = $wpdb->prefix . 'usces_access';
6663
6664 $query = $wpdb->prepare("SELECT SUM(acc_num2) AS ct FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today);
6665 $res = $wpdb->get_var($query);
6666
6667 if( $res == NULL )
6668 return 0;
6669 else
6670 return $res;
6671 }
6672
6673 function get_order_num( $period ) {
6674 global $wpdb;
6675 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6676 $yearstr = substr($datestr, 0, 4);
6677 $monthstr = substr($datestr, 5, 2);
6678 $daystr = substr($datestr, 8, 2);
6679 if($period == 'today') {
6680 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
6681 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6682 }else if($period == 'thismonth') {
6683 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
6684 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6685 }else if($period == 'lastyear') {
6686 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6687 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
6688 }
6689 $table_name = $wpdb->prefix . 'usces_order';
6690
6691 $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');
6692 $res = $wpdb->get_var($query);
6693
6694 if( $res == NULL )
6695 return 0;
6696 else
6697 return $res;
6698 }
6699
6700 function get_order_amount( $period ) {
6701 global $wpdb;
6702 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6703 $yearstr = substr($datestr, 0, 4);
6704 $monthstr = substr($datestr, 5, 2);
6705 $daystr = substr($datestr, 8, 2);
6706 if($period == 'today') {
6707 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
6708 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6709 }else if($period == 'thismonth') {
6710 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
6711 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6712 }else if($period == 'lastyear') {
6713 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6714 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
6715 }
6716 $table_name = $wpdb->prefix . 'usces_order';
6717
6718 $query = $wpdb->prepare("SELECT
6719 SUM(order_item_total_price) AS price,
6720 SUM(order_usedpoint) AS point,
6721 SUM(order_discount) AS discount,
6722 SUM(order_shipping_charge) AS shipping,
6723 SUM(order_cod_fee) AS cod,
6724 SUM(order_tax) AS tax
6725 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');
6726 $res = $wpdb->get_row($query, ARRAY_A);
6727
6728 if( $res == NULL )
6729 return 0;
6730 else
6731 return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax'];
6732 }
6733
6734 function is_status($need, $str){
6735 $array = explode(',', $str);
6736 return in_array($need, $array);
6737 }
6738
6739 function make_status( $taio='', $receipt='', $admin='' ){
6740 $str = '';
6741 if($taio != '' && $taio != '#none#')
6742 $str .= $taio . ',';
6743 if($receipt != '' && $receipt != '#none#')
6744 $str .= $receipt . ',';
6745 if($admin != '' && $admin != '#none#')
6746 $str .= $admin . ',';
6747 return $str;
6748 }
6749
6750 function get_memberid_by_email($email){
6751 global $wpdb;
6752 $table_name = $wpdb->prefix . "usces_member";
6753 $query = $wpdb->prepare("SELECT ID FROM $table_name WHERE mem_email = %s", $email);
6754 $res = $wpdb->get_var($query);
6755 return $res;
6756 }
6757
6758 function get_condition(){
6759 //20120807ysk start 0000544
6760 $order_conditions = array(
6761 'display_mode' => $this->options['display_mode'],
6762 'campaign_privilege' => $this->options['campaign_privilege'],
6763 'campaign_category' => $this->options['campaign_category'],
6764 'privilege_point' => $this->options['privilege_point'],
6765 'privilege_discount' => $this->options['privilege_discount']);
6766 return $order_conditions;
6767 //20120807ysk end
6768 }
6769
6770 function get_bestseller_ids( $days = "" ){
6771 global $wpdb;
6772 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6773 $yearstr = substr($datestr, 0, 4);
6774 $monthstr = substr($datestr, 5, 2);
6775 $daystr = substr($datestr, 8, 2);
6776 $res = array();
6777 $order_table_name = $wpdb->prefix . "usces_order";
6778 $where = "";
6779 if($days != ''){
6780 $order_date = date('Y-m-d H:i:s', mktime(0, 0, 0, (int)$monthstr, ((int)$daystr-$days), (int)$yearstr));
6781 $where = " WHERE order_date >= '{$order_date}'";
6782 }
6783 $query = "SELECT order_cart FROM {$order_table_name}" . $where;
6784 $dbres = $wpdb->get_col($query);
6785 if(!$dbres) return false;
6786
6787 foreach((array)$dbres as $carts){
6788 $rows = unserialize($carts);
6789 foreach((array)$rows as $carts){
6790 if( 'publish' != get_post_status($carts['post_id']) )
6791 continue;
6792
6793 $id = $carts['post_id'];
6794 $qu = $carts['quantity'];
6795 if(array_key_exists($id, $res)){
6796 $res[$id] = $res[$id] + $qu;
6797 }else{
6798 $res[$id] = $qu;
6799 }
6800 }
6801 }
6802 arsort($res);
6803 $results = array_keys($res);
6804 return $results;
6805 }
6806
6807 function get_items_num(){
6808 global $wpdb;
6809 $query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM {$wpdb->posts}
6810 WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
6811 'item', 'post', 'trush');
6812 $res = $wpdb->get_var($query);
6813
6814 return $res;
6815 }
6816
6817 function is_gptekiyo( $post_id, $sku, $quant ) {
6818 $skus = $this->get_skus( $post_id, 'code' );
6819 if( !isset($skus[$sku]['gp']) || !$skus[$sku]['gp'] ) return false;
6820
6821 $GpN1 = $this->getItemGpNum1($post_id);
6822 $GpN2 = $this->getItemGpNum2($post_id);
6823 $GpN3 = $this->getItemGpNum3($post_id);
6824
6825 if( empty($GpN1) ) {
6826
6827 return false;
6828
6829 }else if( !empty($GpN1) && empty($GpN2) ) {
6830
6831 if( $quant >= $GpN1 ) {
6832 return true;
6833 }else{
6834 return false;
6835 }
6836
6837 }else if( !empty($GpN1) && !empty($GpN2) && empty($GpN3) ) {
6838
6839 if( $quant >= $GpN2 ) {
6840 return true;
6841 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
6842 return true;
6843 }else{
6844 return false;
6845 }
6846
6847 }else if( !empty($GpN1) && !empty($GpN2) && !empty($GpN3) ) {
6848
6849 if( $quant >= $GpN3 ) {
6850 return true;
6851 }else if( $quant >= $GpN2 && $quant < $GpN3 ) {
6852 return true;
6853 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
6854 return true;
6855 }else{
6856 return false;
6857 }
6858 }
6859 }
6860
6861 function get_available_delivery_method() {
6862 if($this->cart->num_row() > 0) {
6863 $cart = $this->cart->get_cart();
6864 $before_deli = array();
6865 $intersect = array();
6866 $integration = array();
6867 $temp = array();
6868 $in = 0;
6869 foreach($cart as $key => $row){
6870 $deli = $this->getItemDeliveryMethod($row['post_id']);
6871 //usces_p($deli);
6872 if( empty($deli))
6873 continue;
6874
6875 //usces_log('deli : '.print_r($deli, true), 'acting_transaction.log');
6876 if( 0 === $in ){
6877 $intersect = $deli;
6878 }
6879 $intersect = array_intersect($deli, $intersect);
6880 $before_deli = $deli;
6881 foreach($deli as $value){
6882 $integration[] = $value;
6883 }
6884 $in++;
6885 }
6886 $integration = array_unique($integration);
6887 foreach($integration as $id){
6888 $index = $this->get_delivery_method_index($id);
6889 $temp[$index] = $id;
6890 }
6891 ksort($temp);
6892 //20120820ysk start 0000546
6893 //$force = array($temp[0]);
6894 $force = array(array_shift($temp));
6895 //20120820ysk end
6896
6897 if( empty($intersect) ){
6898 return $force;
6899 }else{
6900 return $intersect;
6901 }
6902 }
6903 return array();
6904 }
6905
6906 function get_delivery_method_index($id) {
6907 $index = false;
6908 for($i=0; $i<count($this->options['delivery_method']); $i++){
6909 if( $this->options['delivery_method'][$i]['id'] === (int)$id ){
6910 $index = $i;
6911 }
6912 }
6913 if($index === false)
6914 return -1;
6915 else
6916 return $index;
6917 }
6918
6919 function get_shipping_charge_index($id) {
6920 $index = false;
6921 for($i=0; $i<count($this->options['shipping_charge']); $i++){
6922 //20120710ysk start 0000472
6923 //if( $this->options['shipping_charge'][$i]['id'] === $id ){
6924 if( (int)$this->options['shipping_charge'][$i]['id'] == (int)$id ){
6925 //20120710ysk end
6926 $index = $i;
6927 }
6928 }
6929 if($index === false)
6930 return -1;
6931 else
6932 return $index;
6933 }
6934
6935 function get_initial_data($xml){
6936 $buf = file_get_contents($xml);
6937 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);
6938 return $match;
6939 }
6940
6941 function getCurrencySymbol(){
6942 global $usces_settings;
6943 $cr = $this->options['system']['currency'];
6944 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
6945 return $symbol;
6946 }
6947
6948 function getCartItemName($post_id, $sku){
6949 $name_arr = array();
6950 $name_str = '';
6951
6952 foreach($this->options['indi_item_name'] as $key => $value){
6953 if($value){
6954 $pos = (int)$this->options['pos_item_name'][$key];
6955 $ind = ($pos === 0) ? 'A' : $pos;
6956 switch($key){
6957 case 'item_name':
6958 $name_arr[$ind][$key] = $this->getItemName($post_id);
6959 break;
6960 case 'item_code':
6961 $name_arr[$ind][$key] = $this->getItemCode($post_id);
6962 break;
6963 case 'sku_name':
6964 $name_arr[$ind][$key] = $this->getItemSkuDisp($post_id, $sku);
6965 break;
6966 case 'sku_code':
6967 $name_arr[$ind][$key] = $sku;
6968 break;
6969 }
6970 }
6971
6972 }
6973 ksort($name_arr);
6974 foreach($name_arr as $vals){
6975 foreach($vals as $key => $value){
6976
6977 $name_str .= $value . ' ';
6978 }
6979 }
6980
6981 $name_str = apply_filters('usces_admin_order_item_name_filter', $name_str);
6982
6983 return trim($name_str);
6984 }
6985
6986 function set_reserve_pre_order_id(){
6987 $entry = $this->cart->get_entry();
6988 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : uniqid('');
6989 $this->cart->set_pre_order_id($id);
6990 }
6991
6992 function get_current_pre_order_id(){
6993 $entry = $this->cart->get_entry();
6994 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : NULL;
6995 return $id;
6996 }
6997
6998 function get_reserve($order_id, $key){
6999 global $wpdb;
7000 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7001 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7002 $order_id, $key);
7003 $res = $wpdb->get_var($query);
7004 return $res;
7005 }
7006
7007 //20100818ysk start
7008 //20100816ysk start
7009 //function get_order_meta($order_id, $key) {
7010 function get_order_meta_value($key, $order_id) {
7011 global $wpdb;
7012 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7013 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7014 $order_id, $key);
7015 $res = $wpdb->get_var($query);
7016 return $res;
7017 }
7018 //20100816ysk end
7019 function set_order_meta_value($key, $meta_value, $order_id) {
7020 global $wpdb;
7021
7022 //if( empty($meta_value) ) return;
7023 if( empty($order_id) ) return;
7024
7025 $table_name = $wpdb->prefix . "usces_order_meta";
7026 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s",
7027 $order_id, $key);
7028 $res = $wpdb->get_var($query);
7029 if(0 < $res) {
7030 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s",
7031 $meta_value,
7032 $order_id,
7033 $key
7034 );
7035 $res2 = $wpdb->query($query);
7036 } else {
7037 $query = $wpdb->prepare("INSERT INTO $table_name (order_id, meta_key, meta_value)
7038 VALUES(%d, %s, %s)",
7039 $order_id,
7040 $key,
7041 $meta_value
7042 );
7043 $res2 = $wpdb->query($query);
7044 }
7045 return $res2;
7046 }
7047 //20130524ysk start
7048 function del_order_meta( $key, $order_id ) {
7049 global $wpdb;
7050 $table_name = $wpdb->prefix."usces_order_meta";
7051 $query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
7052 $res = $wpdb->query( $query );
7053 return $res;
7054 }
7055 //20130524ysk end
7056 function set_session_custom_member($member_id) {
7057 unset($_SESSION['usces_member']['custom_member']);
7058 $meta = usces_has_custom_field_meta('member');
7059 if(is_array($meta)) {
7060 $keys = array_keys($meta);
7061 foreach($keys as $key) {
7062 $csmb_key = 'csmb_'.$key;
7063 $_SESSION['usces_member']['custom_member'][$key] = maybe_unserialize($this->get_member_meta_value($csmb_key, $member_id));
7064 }
7065 }
7066 }
7067
7068 function reg_custom_member($member_id) {
7069 //20130524ysk start 0000712
7070 $csmb_meta = usces_has_custom_field_meta( 'member' );
7071 if( is_array($csmb_meta) ) {
7072 foreach( $csmb_meta as $key => $entry ) {
7073 if( '4' == $entry['means'] ) {
7074 $this->del_member_meta( 'csmb_'.$key, $member_id );
7075 }
7076 }
7077 }
7078 //20130524ysk end
7079 if( !empty($_POST['custom_member']) ) {
7080 foreach( $_POST['custom_member'] as $key => $value ) {
7081 $csmb_key = 'csmb_'.$key;
7082 if( is_array($value) )
7083 $value = serialize($value);
7084 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7085 if(false === $res)
7086 return false;
7087 }
7088 }elseif( isset($_POST['custom_customer']) ){
7089 foreach( $_POST['custom_customer'] as $key => $value ) {
7090 $csmb_key = 'csmb_'.$key;
7091 if( is_array($value) )
7092 $value = serialize($value);
7093 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7094 if(false === $res)
7095 return false;
7096 }
7097 }
7098 }
7099 //20100818ysk end
7100
7101 function save_order_acting_data($rand){
7102 global $wpdb;
7103 $data = serialize(array( 'cart' => $this->cart->get_cart(), 'entry' => $this->cart->get_entry() ));
7104 $table_name = $wpdb->prefix . "usces_access";
7105 $query = $wpdb->prepare("INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value)
7106 VALUES(%s, %s, now(), %s, %s)",
7107 'acting_data',
7108 $this->get_uscesid(false),
7109 $rand,
7110 $data
7111 );
7112 $res = $wpdb->query($query);
7113 return $res;
7114 }
7115
7116 //20100818ysk start
7117 function set_member_meta_value($key, $meta_value, $member_id = ''){
7118 global $wpdb;
7119
7120 //if( empty($meta_value) ) return;
7121 if( WCUtils::is_blank($member_id) ) {
7122 if( !$this->is_member_logged_in() ) return;
7123 $member = $this->get_member();
7124 $member_id = $member['ID'];
7125 }
7126
7127 $table_name = $wpdb->prefix . "usces_member_meta";
7128 //$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7129 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s",
7130 $member_id, $key);
7131 $res = $wpdb->get_var($query);
7132 //if($res != NULL){
7133 if(0 < $res){
7134 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s",
7135 $meta_value,
7136 $member_id,
7137 $key
7138 );
7139 $res2 = $wpdb->query($query);
7140 }else{
7141 $query = $wpdb->prepare("INSERT INTO $table_name (member_id, meta_key, meta_value)
7142 VALUES(%d, %s, %s)",
7143 $member_id,
7144 $key,
7145 $meta_value
7146 );
7147 $res2 = $wpdb->query($query);
7148 }
7149 return $res2;
7150 }
7151 //20100818ysk end
7152
7153 function get_member_meta_value($key, $member_id){
7154 global $wpdb;
7155 $table_name = $wpdb->prefix . "usces_member_meta";
7156 $query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7157 $member_id, $key);
7158 $res = $wpdb->get_var($query);
7159 return $res;
7160 }
7161
7162 function del_member_meta($key, $member_id){
7163 global $wpdb;
7164 $table_name = $wpdb->prefix . "usces_member_meta";
7165 $query = $wpdb->prepare("DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s",
7166 $member_id, $key);
7167 $res = $wpdb->query($query);
7168 return $res;
7169 }
7170
7171 function get_member_meta($member_id){
7172 global $wpdb;
7173 $table_name = $wpdb->prefix . "usces_member_meta";
7174 $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_%');
7175 $res = $wpdb->get_results($query, ARRAY_A);
7176 return $res;
7177 }
7178
7179 function get_settle_info_field( $order_id ){
7180 global $wpdb;
7181 $fields = array();
7182 $table_name = $wpdb->prefix . "usces_order_meta";
7183 $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)",
7184 $order_id, 'acting_%', 'settlement_id', 'order_number', 'res_tracking_id', 'SID');
7185 $res = $wpdb->get_results($query, ARRAY_A);
7186 if( !$res )
7187 return $fields;
7188
7189 foreach( $res as $value ){
7190 if( 'settlement_id' == $value['meta_key'] ){
7191 $meta_values = maybe_unserialize($value['meta_value']);
7192 if( is_array($meta_values) ){
7193 foreach( $meta_values as $key => $meta_value ){
7194 $fields[$key] = $meta_value;
7195 }
7196 }else{
7197 $fields['settlement_id'] = $meta_values;
7198 }
7199 }elseif( 'order_number' == $value['meta_key'] ){
7200 $fields['order_number'] = $value['meta_value'];
7201 }elseif( 'res_tracking_id' == $value['meta_key'] ){
7202 $fields['res_tracking_id'] = $value['meta_value'];
7203 }elseif( 'SID' == $value['meta_key'] ){
7204 $fields['SID'] = $value['meta_value'];
7205 }elseif( 'acting_' == substr($value['meta_key'], 0, 7) ){
7206 $meta_values = unserialize($value['meta_value']);
7207 if(is_array($meta_values)){
7208 foreach( $meta_values as $key => $meta_value ){
7209 $fields[$key] = $meta_value;
7210 }
7211 }
7212 }
7213 }
7214 return $fields;
7215 }
7216
7217 function get_post_custom($post_id, $orderby='meta_id', $order='ASC'){
7218 global $wpdb;
7219 $table = $wpdb->prefix . "postmeta";
7220 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7221 $post_id), ARRAY_A );
7222
7223 if ( !empty($meta_list) ) {
7224 foreach ( $meta_list as $metarow) {
7225 $mkey = $metarow['meta_key'];
7226 $mval = $metarow['meta_value'];
7227 $res[$mkey][] = $mval;
7228 }
7229 }
7230 return $res;
7231 }
7232
7233 function get_post_user_custom($post_id, $orderby='meta_id', $order='ASC'){
7234 global $wpdb;
7235 $res = array();
7236 $table = $wpdb->prefix . "postmeta";
7237 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7238 $post_id), ARRAY_A );
7239
7240 if ( !empty($meta_list) ) {
7241 foreach ( $meta_list as $metarow) {
7242 if( 0 === strpos($metarow['meta_key'], '_') )
7243 continue;
7244
7245 $mkey = $metarow['meta_key'];
7246 $mval = $metarow['meta_value'];
7247 if( array_key_exists($mkey, $res) ){
7248 $cval = $res[$mkey];
7249 $cval = (array)$cval;
7250 $cval[] = $mval;
7251 $res[$mkey] = $cval;
7252 }else{
7253 $res[$mkey] = $mval;
7254 }
7255 }
7256 }
7257 return $res;
7258 }
7259
7260 function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ){
7261 global $usces_settings;
7262 $cr = $this->options['system']['currency'];
7263 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7264 if( !$seperator_flag ){
7265 $seperator = '';
7266 }
7267 $price = number_format((double)$amount, $decimal, $point, $seperator);//0000652
7268
7269 if( $symbol_pre )
7270 $price = ( usces_is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol ) . $price;
7271
7272 if( $symbol_post )
7273 $price = $price . __($code, 'usces');
7274
7275 return $price;
7276 }
7277
7278 function get_currency_code(){
7279 global $usces_settings;
7280 $cr = $this->options['system']['currency'];
7281 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7282 return $code;
7283 }
7284
7285 //shortcode-----------------------------------------------------------------------------
7286 function sc_company_name() {
7287 return htmlspecialchars($this->options['company_name']);
7288 }
7289 function sc_zip_code() {
7290 return htmlspecialchars($this->options['zip_code']);
7291 }
7292 function sc_address1() {
7293 return htmlspecialchars($this->options['address1']);
7294 }
7295 function sc_address2() {
7296 return htmlspecialchars($this->options['address2']);
7297 }
7298 function sc_tel_number() {
7299 return htmlspecialchars($this->options['tel_number']);
7300 }
7301 function sc_fax_number() {
7302 return htmlspecialchars($this->options['fax_number']);
7303 }
7304 function sc_inquiry_mail() {
7305 return htmlspecialchars($this->options['inquiry_mail']);
7306 }
7307 function sc_payment() {
7308 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
7309 $htm = "<ul>\n";
7310 foreach ( (array)$payments as $payment ) {
7311 $htm .= "<li>" . htmlspecialchars($payment['name']) . "<br />\n";
7312 $htm .= nl2br(htmlspecialchars($payment['explanation'])) . "</li>\n";
7313 }
7314 $htm .= "</ul>\n";
7315 return $htm;
7316 }
7317 function sc_payment_title() {
7318 $payments = $this->options['payment_method'];
7319 $htm = "<ul>\n";
7320 foreach ( (array)$payments as $payment ) {
7321 $htm .= "<li>" . esc_html($payment['name']) . "</li>\n";
7322 }
7323 $htm .= "</ul>\n";
7324 return $htm;
7325 }
7326 function sc_cod_fee() {
7327 return number_format($this->options['cod_fee']);
7328 }
7329 function sc_start_point() {
7330 return number_format($this->options['start_point']);
7331 }
7332 function sc_postage_privilege() {
7333 if(empty($this->options['postage_privilege']))
7334 return;
7335 return number_format($this->options['postage_privilege']);
7336 }
7337 function sc_shipping_charge() {
7338 //20120710ysk start 0000472
7339 $entry = $this->cart->get_entry();
7340 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
7341 //20120710ysk end
7342 $arr = array();
7343 foreach ( (array)$this->options['shipping_charge'] as $charges ) {
7344 //20120710ysk start 0000472
7345 //foreach ( (array)$charges['value'] as $value ) {
7346 foreach ( (array)$charges[$country] as $value ) {
7347 //20120710ysk end
7348 $arr[] = $value;
7349 }
7350 }
7351 sort($arr);
7352 $min = $arr[0];
7353 rsort($arr);
7354 $max = $arr[0];
7355 if($min == $max){
7356 $res = number_format($min);
7357 }else{
7358 $res = number_format($min) . __(' - ', 'usces') . number_format($max);
7359 }
7360 return $res;
7361 }
7362 function sc_site_url() {
7363 return get_option('home');
7364 }
7365 function sc_button_to_cart($atts) {
7366 extract(shortcode_atts(array(
7367 'item' => '',
7368 'sku' => '',
7369 'value' => __('to the cart', 'usces'),
7370 'force' => 0,
7371 'quant' => 0,
7372 'opt' => 1,
7373 ), $atts));
7374
7375 $post_id = $this->get_ID_byItemName($item);
7376 $datas = $this->get_skus( $post_id, 'code' );
7377 $zaikonum = $datas[$sku]['stocknum'];
7378 $zaiko = $datas[$sku]['stock'];
7379 $gptekiyo = $datas[$sku]['gp'];
7380 $skuPrice = $datas[$sku]['price'];
7381 $sku_enc = urlencode($sku);
7382 $mats = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc');
7383 if( ! $this->is_item_zaiko( $post_id, $sku ) ){
7384 return '<div class="button_status">' . esc_html($this->zaiko_status[$zaiko]) . '</div>';
7385 }
7386
7387 $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n";
7388 $html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"{$zaikonum}\" />\n";
7389 $html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"{$zaiko}\" />\n";
7390 $html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"{$gptekiyo}\" />\n";
7391 $html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"{$skuPrice}\" />\n";
7392 if( 1 == $opt ){
7393 $html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' );
7394 }elseif( 2 == $opt ){
7395 $html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' );
7396 }
7397 if( $quant ){
7398 $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;}\" />";
7399 $html .= apply_filters('usces_filter_sc_itemQuant', $quant_field, $mats);
7400 }
7401 $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) . " />";
7402 $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
7403 if( $force )
7404 $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
7405 $html = apply_filters('usces_filter_single_item_inform', $html);
7406 $html .= "</form>";
7407 $html .= '<div class="error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";
7408
7409 return $html;
7410 }
7411
7412 function filter_itemPage($content){
7413 global $post;
7414 $html = '';
7415
7416 if( ($post->post_mime_type != 'item' || !is_single()) ) return $content;
7417 if( post_password_required($post) ) return $content;
7418
7419 $temp_path = apply_filters('usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php');
7420 include( $temp_path );
7421
7422 $content = apply_filters('usces_filter_itemPage', $html, $post->ID);
7423
7424 return $content;
7425 }
7426
7427 function filter_cartContent($content) {
7428 global $post;
7429 $html = '';
7430
7431 switch($this->page){
7432 case 'cart':
7433 $temp_path = apply_filters('usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php');
7434 include( $temp_path );
7435 break;
7436 case 'customer':
7437 $temp_path = apply_filters('usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php');
7438 include( $temp_path );
7439 break;
7440 case 'delivery':
7441 $temp_path = apply_filters('usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php');
7442 include( $temp_path );
7443 break;
7444 case 'confirm':
7445 $temp_path = apply_filters('usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php');
7446 include( $temp_path );
7447 break;
7448 case 'ordercompletion':
7449 $temp_path = apply_filters('usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php');
7450 include( $temp_path );
7451 break;
7452 case 'error':
7453 $temp_path = apply_filters('usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php');
7454 include( $temp_path );
7455 break;
7456 case 'maintenance':
7457 $temp_path = apply_filters('usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php');
7458 include( $temp_path );
7459 break;
7460 case 'search_item':
7461 $temp_path = apply_filters('usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php');
7462 include( $temp_path );
7463 break;
7464 case 'wp_search':
7465 if($post->post_mime_type == 'item'){
7466 $temp_path = apply_filters('usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php');
7467 include( $temp_path );
7468 }else{
7469 $html = $content;
7470 }
7471 break;
7472 default:
7473 $html = $content;
7474 }
7475
7476 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) )
7477 $html = str_replace('src="'.get_option('siteurl'), 'src="'.USCES_SSL_URL_ADMIN, $html);
7478
7479 $html = apply_filters('usces_filter_cartContent', $html);
7480
7481 $content = $html;
7482
7483 remove_filter('the_title', array($this, 'filter_cartTitle'));
7484
7485 return $content;
7486 }
7487
7488 function filter_cartTitle($title) {
7489
7490 if( $title == 'Cart' || $title == __('Cart', 'usces') ){
7491 switch($this->page){
7492 case 'cart':
7493 $newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces'));
7494 break;
7495 case 'customer':
7496 $newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces'));
7497 break;
7498 case 'delivery':
7499 $newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces'));
7500 break;
7501 case 'confirm':
7502 $newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces'));
7503 break;
7504 case 'ordercompletion':
7505 $newtitle = apply_filters('usces_filter_title_ordercompletion', __('Completion', 'usces'));
7506 break;
7507 case 'error':
7508 $newtitle = apply_filters('usces_filter_title_carterror', __('Error', 'usces'));
7509 break;
7510 case 'search_item':
7511 $newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces'));
7512 break;
7513 case 'maintenance':
7514 $newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces'));
7515 break;
7516 case 'login':
7517 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
7518 break;
7519 default:
7520 $newtitle = apply_filters('usces_filter_title_cart_default', $title);
7521 }
7522 }else{
7523 $newtitle = $title;
7524 }
7525
7526 $newtitle = apply_filters('usces_filter_cartTitle', $newtitle);
7527 return $newtitle;
7528 }
7529
7530 function action_cartFilter(){
7531 add_filter('the_title', array($this, 'filter_cartTitle'),20);
7532 add_filter('the_content', array($this, 'filter_cartContent'),20);
7533 }
7534
7535 function action_search_item(){
7536 include(TEMPLATEPATH . '/page.php');
7537 exit;
7538 }
7539
7540 function filter_memberContent($content) {
7541 global $post;
7542 $html = '';
7543
7544 if($this->options['membersystem_state'] == 'activate'){
7545
7546 if( $this->is_member_logged_in() ) {
7547
7548 $member_regmode = 'editmemberform';
7549 $temp_path = apply_filters('usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php');
7550 include( $temp_path );
7551
7552 } else {
7553
7554 switch($this->page){
7555 case 'login':
7556 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
7557 include( $temp_path );
7558 break;
7559 case 'lostmemberpassword':
7560 $temp_path = apply_filters('usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php');
7561 include( $temp_path );
7562 break;
7563 case 'changepassword':
7564 $temp_path = apply_filters('usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php');
7565 include( $temp_path );
7566 break;
7567 case 'newcompletion':
7568 case 'editcompletion':
7569 case 'lostcompletion':
7570 case 'changepasscompletion':
7571 $temp_path = apply_filters('usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php');
7572 include( $temp_path );
7573 break;
7574 case 'newmemberform':
7575 $member_form_title = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
7576 $member_regmode = 'newmemberform';
7577 $temp_path = apply_filters('usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php');
7578 include( $temp_path );
7579 break;
7580 default:
7581 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
7582 include( $temp_path );
7583 }
7584
7585 }
7586 }else{
7587 $html .= "<p>只今会員サービスは提供いたしておりません。</p>";
7588 }
7589
7590 $content = $html;
7591
7592 remove_filter('the_title', array($this, 'filter_memberTitle'));
7593
7594 return $content;
7595 }
7596
7597 function filter_memberTitle($title) {
7598
7599 if( $this->options['membersystem_state'] == 'activate' && ($title == 'Member' || $title == __('Membership', 'usces')) ){
7600 switch($this->page){
7601 case 'login':
7602 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
7603 break;
7604 case 'newmemberform':
7605 $newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
7606 break;
7607 case 'lostmemberpassword':
7608 $newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces'));
7609 break;
7610 case 'changepassword':
7611 $newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces'));
7612 break;
7613 case 'newcompletion':
7614 case 'editcompletion':
7615 case 'lostcompletion':
7616 case 'changepasscompletion':
7617 $newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Completion', 'usces'));
7618 break;
7619 case 'error':
7620 $newtitle = apply_filters('usces_filter_title_membererror', __('Error', 'usces'));
7621 break;
7622 default:
7623 $newtitle = apply_filters('usces_filter_title_member_default', $title);
7624 }
7625 }else{
7626 $newtitle = $title;
7627 }
7628
7629 $newtitle = apply_filters('usces_filter_memberTitle', $newtitle);
7630 return $newtitle;
7631 }
7632
7633 function action_memberFilter(){
7634 add_filter('the_title', array($this, 'filter_memberTitle'),20);
7635 add_filter('the_content', array($this, 'filter_memberContent'),20);
7636 }
7637
7638 function filter_usces_cart_css(){
7639 $path = get_stylesheet_directory_uri() . '/usces_cart.css';
7640 return $path;
7641 }
7642
7643 function filter_divide_item(){
7644 global $wp_query;
7645
7646
7647 if( ($this->options['divide_item'] && !is_category() && !is_search() && !is_singular() && !is_admin()) ){
7648 $ids = $this->getItemIds( 'front' );
7649 $wp_query->query_vars['post__not_in'] = $ids;
7650
7651 }
7652 if( is_admin() ){
7653 $ids = $this->getItemIds( 'back' );
7654 //$wp_query->query_vars['category__not_in'] = array(USCES_ITEM_CAT_PARENT_ID);
7655 $wp_query->query_vars['post__not_in'] = $ids;
7656 }
7657 do_action( 'usces_action_divide_item');
7658 }
7659
7660 function load_upload_template(){
7661 $post_id = $_POST['post_id'];
7662 $file = 'upload_template01.php';
7663 include(TEMPLATEPATH . '/' . $file);
7664 exit;
7665 }
7666
7667 function filter_itemimg_anchor_rel($html){
7668
7669 if( is_single() ){
7670 $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"';
7671 }else{
7672 $str = '';
7673 }
7674 return $html . $str;
7675 }
7676
7677 function filter_permalink( $link ) {
7678
7679 if(false !== strpos('?page_id=4', $link) || false !== strpos('?page_id=3', $link) || false !== strpos('usces-cart', $link) || false !== strpos('usces-member', $link) )
7680 $link = str_replace('http://', 'https://', $link);
7681
7682 return $link;
7683 }
7684
7685 function filter_cart_page_header($html){
7686 if( !empty($this->options['cart_page_data']['header']['cart']) ){
7687 $html = $this->options['cart_page_data']['header']['cart'];
7688 }
7689 return do_shortcode( stripslashes(nl2br($html)) );
7690 }
7691
7692 function filter_cart_page_footer($html){
7693 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
7694 $html = $this->options['cart_page_data']['footer']['cart'];
7695 }
7696 return do_shortcode( stripslashes(nl2br($html)) );
7697 }
7698
7699 function filter_customer_page_header($html){
7700 if( !empty($this->options['cart_page_data']['header']['customer']) ){
7701 $html = $this->options['cart_page_data']['header']['customer'];
7702 }
7703 return do_shortcode( stripslashes(nl2br($html)) );
7704 }
7705
7706 function filter_customer_page_footer($html){
7707 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
7708 $html = $this->options['cart_page_data']['footer']['customer'];
7709 }
7710 return do_shortcode( stripslashes(nl2br($html)) );
7711 }
7712
7713 function filter_delivery_page_header($html){
7714 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
7715 $html = $this->options['cart_page_data']['header']['delivery'];
7716 }
7717 return do_shortcode( stripslashes(nl2br($html)) );
7718 }
7719
7720 function filter_delivery_page_footer($html){
7721 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
7722 $html = $this->options['cart_page_data']['footer']['delivery'];
7723 }
7724 return do_shortcode( stripslashes(nl2br($html)) );
7725 }
7726
7727 function filter_confirm_page_header($html){
7728 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
7729 $html = $this->options['cart_page_data']['header']['confirm'];
7730 }
7731 return do_shortcode( stripslashes(nl2br($html)) );
7732 }
7733
7734 function filter_confirm_page_footer($html){
7735 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
7736 $html = $this->options['cart_page_data']['footer']['confirm'];
7737 }
7738 return do_shortcode( stripslashes(nl2br($html)) );
7739 }
7740
7741 function filter_cartcompletion_page_header($html){
7742 if( !empty($this->options['cart_page_data']['header']['completion']) ){
7743 $html = $this->options['cart_page_data']['header']['completion'];
7744 }
7745 return do_shortcode( stripslashes(nl2br($html)) );
7746 }
7747
7748 function filter_cartcompletion_page_footer($html){
7749 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
7750 $html = $this->options['cart_page_data']['footer']['completion'];
7751 }
7752 return do_shortcode( stripslashes(nl2br($html)) );
7753 }
7754
7755 function filter_login_page_header($html){
7756 if( !empty($this->options['member_page_data']['header']['login']) ){
7757 $html = $this->options['member_page_data']['header']['login'];
7758 }
7759 return do_shortcode( stripslashes(nl2br($html)) );
7760 }
7761
7762 function filter_login_page_footer($html){
7763 if( !empty($this->options['member_page_data']['footer']['login']) ){
7764 $html = $this->options['member_page_data']['footer']['login'];
7765 }
7766 return do_shortcode( stripslashes(nl2br($html)) );
7767 }
7768
7769 function filter_newmember_page_header($html){
7770 if( !empty($this->options['member_page_data']['header']['newmember']) ){
7771 $html = $this->options['member_page_data']['header']['newmember'];
7772 }
7773 return do_shortcode( stripslashes(nl2br($html)) );
7774 }
7775
7776 function filter_newmember_page_footer($html){
7777 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
7778 $html = $this->options['member_page_data']['footer']['newmember'];
7779 }
7780 return do_shortcode( stripslashes(nl2br($html)) );
7781 }
7782
7783 function filter_newpass_page_header($html){
7784 if( !empty($this->options['member_page_data']['header']['newpass']) ){
7785 $html = $this->options['member_page_data']['header']['newpass'];
7786 }
7787 return do_shortcode( stripslashes(nl2br($html)) );
7788 }
7789
7790 function filter_newpass_page_footer($html){
7791 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
7792 $html = $this->options['member_page_data']['footer']['newpass'];
7793 }
7794 return do_shortcode( stripslashes(nl2br($html)) );
7795 }
7796
7797 function filter_changepass_page_header($html){
7798 if( !empty($this->options['member_page_data']['header']['changepass']) ){
7799 $html = $this->options['member_page_data']['header']['changepass'];
7800 }
7801 return do_shortcode( stripslashes(nl2br($html)) );
7802 }
7803
7804 function filter_changepass_page_footer($html){
7805 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
7806 $html = $this->options['member_page_data']['footer']['changepass'];
7807 }
7808 return do_shortcode( stripslashes(nl2br($html)) );
7809 }
7810
7811 function filter_memberinfo_page_header($html){
7812 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
7813 $html = $this->options['member_page_data']['header']['memberinfo'];
7814 }
7815 return do_shortcode( stripslashes(nl2br($html)) );
7816 }
7817
7818 function filter_memberinfo_page_footer($html){
7819 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
7820 $html = $this->options['member_page_data']['footer']['memberinfo'];
7821 }
7822 return do_shortcode( stripslashes(nl2br($html)) );
7823 }
7824
7825 function filter_membercompletion_page_header($html){
7826 if( !empty($this->options['member_page_data']['header']['completion']) ){
7827 $html = $this->options['member_page_data']['header']['completion'];
7828 }
7829 return do_shortcode( stripslashes(nl2br($html)) );
7830 }
7831
7832 function filter_membercompletion_page_footer($html){
7833 if( !empty($this->options['member_page_data']['footer']['completion']) ){
7834 $html = $this->options['member_page_data']['footer']['completion'];
7835 }
7836 return do_shortcode( stripslashes(nl2br($html)) );
7837 }
7838
7839 function action_cart_page_header(){
7840 if( !empty($this->options['cart_page_data']['header']['cart']) ){
7841 $html = $this->options['cart_page_data']['header']['cart'];
7842 echo do_shortcode( stripslashes(nl2br($html)) );
7843 }
7844 }
7845
7846 function action_cart_page_footer(){
7847 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
7848 $html = $this->options['cart_page_data']['footer']['cart'];
7849 echo do_shortcode( stripslashes(nl2br($html)) );
7850 }
7851 }
7852
7853 function action_customer_page_header(){
7854 if( !empty($this->options['cart_page_data']['header']['customer']) ){
7855 $html = $this->options['cart_page_data']['header']['customer'];
7856 echo do_shortcode( stripslashes(nl2br($html)) );
7857 }
7858 }
7859
7860 function action_customer_page_footer(){
7861 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
7862 $html = $this->options['cart_page_data']['footer']['customer'];
7863 echo do_shortcode( stripslashes(nl2br($html)) );
7864 }
7865 }
7866
7867 function action_delivery_page_header(){
7868 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
7869 $html = $this->options['cart_page_data']['header']['delivery'];
7870 echo do_shortcode( stripslashes(nl2br($html)) );
7871 }
7872 }
7873
7874 function action_delivery_page_footer(){
7875 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
7876 $html = $this->options['cart_page_data']['footer']['delivery'];
7877 echo do_shortcode( stripslashes(nl2br($html)) );
7878 }
7879 }
7880
7881 function action_confirm_page_header(){
7882 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
7883 $html = $this->options['cart_page_data']['header']['confirm'];
7884 echo do_shortcode( stripslashes(nl2br($html)) );
7885 }
7886 }
7887
7888 function action_confirm_page_footer(){
7889 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
7890 $html = $this->options['cart_page_data']['footer']['confirm'];
7891 echo do_shortcode( stripslashes(nl2br($html)) );
7892 }
7893 }
7894
7895 function action_cartcompletion_page_header(){
7896 if( !empty($this->options['cart_page_data']['header']['completion']) ){
7897 $html = $this->options['cart_page_data']['header']['completion'];
7898 echo do_shortcode( stripslashes(nl2br($html)) );
7899 }
7900 }
7901
7902 function action_cartcompletion_page_footer(){
7903 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
7904 $html = $this->options['cart_page_data']['footer']['completion'];
7905 echo do_shortcode( stripslashes(nl2br($html)) );
7906 }
7907 }
7908
7909 function action_login_page_header(){
7910 if( !empty($this->options['member_page_data']['header']['login']) ){
7911 $html = $this->options['member_page_data']['header']['login'];
7912 echo do_shortcode( stripslashes(nl2br($html)) );
7913 }
7914 }
7915
7916 function action_login_page_footer(){
7917 if( !empty($this->options['member_page_data']['footer']['login']) ){
7918 $html = $this->options['member_page_data']['footer']['login'];
7919 echo do_shortcode( stripslashes(nl2br($html)) );
7920 }
7921 }
7922
7923 function action_newmember_page_header(){
7924 if( !empty($this->options['member_page_data']['header']['newmember']) ){
7925 $html = $this->options['member_page_data']['header']['newmember'];
7926 echo do_shortcode( stripslashes(nl2br($html)) );
7927 }
7928 }
7929
7930 function action_newmember_page_footer(){
7931 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
7932 $html = $this->options['member_page_data']['footer']['newmember'];
7933 echo do_shortcode( stripslashes(nl2br($html)) );
7934 }
7935 }
7936
7937 function action_newpass_page_header(){
7938 if( !empty($this->options['member_page_data']['header']['newpass']) ){
7939 $html = $this->options['member_page_data']['header']['newpass'];
7940 echo do_shortcode( stripslashes(nl2br($html)) );
7941 }
7942 }
7943
7944 function action_newpass_page_footer(){
7945 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
7946 $html = $this->options['member_page_data']['footer']['newpass'];
7947 echo do_shortcode( stripslashes(nl2br($html)) );
7948 }
7949 }
7950
7951 function action_changepass_page_header(){
7952 if( !empty($this->options['member_page_data']['header']['changepass']) ){
7953 $html = $this->options['member_page_data']['header']['changepass'];
7954 echo do_shortcode( stripslashes(nl2br($html)) );
7955 }
7956 }
7957
7958 function action_changepass_page_footer(){
7959 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
7960 $html = $this->options['member_page_data']['footer']['changepass'];
7961 echo do_shortcode( stripslashes(nl2br($html)) );
7962 }
7963 }
7964
7965 function action_memberinfo_page_header(){
7966 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
7967 $html = $this->options['member_page_data']['header']['memberinfo'];
7968 echo do_shortcode( stripslashes(nl2br($html)) );
7969 }
7970 }
7971
7972 function action_memberinfo_page_footer(){
7973 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
7974 $html = $this->options['member_page_data']['footer']['memberinfo'];
7975 echo do_shortcode( stripslashes(nl2br($html)) );
7976 }
7977 }
7978
7979 function action_membercompletion_page_header(){
7980 if( !empty($this->options['member_page_data']['header']['completion']) ){
7981 $html = $this->options['member_page_data']['header']['completion'];
7982 echo do_shortcode( stripslashes(nl2br($html)) );
7983 }
7984 }
7985
7986 function action_membercompletion_page_footer(){
7987 if( !empty($this->options['member_page_data']['footer']['completion']) ){
7988 $html = $this->options['member_page_data']['footer']['completion'];
7989 echo do_shortcode( stripslashes(nl2br($html)) );
7990 }
7991 }
7992
7993 }
7994 ?>
7995