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

8,007 lines 311.1 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 $member_edit_form = apply_filters( 'usces_admin_member_edit_form', USCES_PLUGIN_DIR . '/includes/member_edit_form.php' );
615 $member_list = apply_filters( 'usces_admin_member_list', USCES_PLUGIN_DIR . '/includes/member_list.php' );
616
617 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
618 $this->action_status = 'none';
619 $this->action_message = '';
620 }
621 $member_action = isset($_REQUEST['member_action']) ? $_REQUEST['member_action'] : '';
622 switch ($member_action) {
623 //20100908ysk start
624 case 'dlmemberlist':
625 usces_download_member_list();
626 break;
627 //20100908ysk end
628 case 'editpost':
629 $this->error_message = $this->admin_member_check();
630 if( WCUtils::is_blank($this->error_message) ){
631 $res = usces_update_memberdata();
632 if ( 1 === $res ) {
633 $this->set_action_status('success', __('Membership information is updated','usces'));
634 } elseif ( 0 === $res ) {
635 $this->set_action_status('none', '');
636 } else {
637 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
638 }
639 }
640 require_once($member_edit_form);
641 break;
642 case 'new':
643 case 'edit':
644 require_once($member_edit_form);
645 break;
646 case 'delete':
647 $res = usces_delete_memberdata();
648 if ( 1 === $res ) {
649 $this->set_action_status('success', __('The member data is deleted','usces'));
650 } elseif ( 0 === $res ) {
651 $this->set_action_status('none', '');
652 } else {
653 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
654 }
655 default:
656 require_once($member_list);
657 }
658
659 }
660
661 /* admin backup page */
662 function admin_backup_page() {
663
664 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
665 $this->action_status = 'none';
666 $this->action_message = '';
667 }
668 require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
669
670 }
671
672 /* Shop Top Page */
673 function admin_top_page() {
674
675 require_once(USCES_PLUGIN_DIR . '/includes/admin_top.php');
676
677 }
678
679 /* Shop Setup Page */
680 function admin_setup_page() {
681 $this->options = get_option('usces');
682 //$this->options = array();
683
684
685 if(isset($_POST['usces_option_update'])) {
686
687 $_POST = $this->stripslashes_deep_post($_POST);
688 $this->options['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : '';
689 $this->options['campaign_category'] = empty($_POST['cat']) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat'];
690 $this->options['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : '';
691 $this->options['privilege_point'] = isset($_POST['point_num']) ? (int)$_POST['point_num'] : '';
692 $this->options['privilege_discount'] = isset($_POST['discount_num']) ? (int)$_POST['discount_num'] : '';
693 $this->options['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : '';
694 $this->options['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : '';
695 $this->options['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : '';
696 $this->options['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : '';
697 $this->options['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : '';
698 $this->options['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : '';
699 $this->options['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : '';
700 $this->options['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : '';
701 $this->options['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : '';
702 $this->options['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : '';
703 $this->options['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : '';
704 $this->options['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : '';
705 $this->options['point_rate'] = isset($_POST['point_rate']) ? (int)$_POST['point_rate'] : '';
706 $this->options['start_point'] = isset($_POST['start_point']) ? (int)$_POST['start_point'] : '';
707 $this->options['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : '';
708 $this->options['tax_rate'] = isset($_POST['tax_rate']) ? (int)$_POST['tax_rate'] : '';
709 $this->options['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : '';
710 $this->options['cod_type'] = isset($this->options['cod_type']) ? $this->options['cod_type'] : 'fix';
711 $this->options['transferee'] = isset($_POST['transferee']) ? trim($_POST['transferee']) : '';
712 $this->options['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : '';
713 $this->options['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : '';
714 $this->options['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : '';
715 $this->options['point_coverage'] = isset($_POST['point_coverage']) ? (int)$_POST['point_coverage'] : 0;
716 $this->options['point_assign'] = isset($_POST['point_assign']) ? (int)$_POST['point_assign'] : 1;//20120919ysk 0000573
717
718 $this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options );
719
720 update_option('usces', $this->options);
721
722 $this->action_status = 'success';
723 $this->action_message = __('options are updated','usces');
724
725 } else {
726 $this->action_status = 'none';
727 $this->action_message = '';
728 }
729
730 require_once(USCES_PLUGIN_DIR . '/includes/admin_setup.php');
731
732 }
733
734 /* Shop Schedule Page */
735 function admin_schedule_page() {
736
737 $this->options = get_option('usces');
738
739 if(isset($_POST['usces_option_update'])) {
740 $_POST = $this->stripslashes_deep_post($_POST);
741
742 $this->options['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0';
743 if(isset($_POST['business_days']))
744 $this->options['business_days'] = $_POST['business_days'];
745
746 update_option('usces', $this->options);
747
748 do_action( 'usces_action_admin_schedule_update' );
749
750 $this->action_status = 'success';
751 $this->action_message = __('options are updated','usces');
752 } else {
753 $this->action_status = 'none';
754 $this->action_message = '';
755 }
756
757 require_once(USCES_PLUGIN_DIR . '/includes/admin_schedule.php');
758
759 }
760
761 /* Shop Delivery Page */
762 function admin_delivery_page() {
763
764 $this->options = get_option('usces');
765
766 if(isset($_POST['usces_option_update'])) {
767 $_POST = $this->stripslashes_deep_post($_POST);
768
769 //20101208ysk start
770 if(isset($_POST['delivery_time_limit'])) $this->options['delivery_time_limit'] = $_POST['delivery_time_limit'];
771 if(isset($_POST['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time'];
772 if(isset($_POST['delivery_after_days'])) $this->options['delivery_after_days'] = $_POST['delivery_after_days'];
773 //20101208ysk end
774
775 update_option('usces', $this->options);
776
777 $this->action_status = 'success';
778 $this->action_message = __('options are updated','usces');
779 } else {
780 $this->action_status = 'none';
781 $this->action_message = '';
782 }
783
784 require_once(USCES_PLUGIN_DIR . '/includes/admin_delivery.php');
785
786 }
787
788 /* Shop Mail Page */
789 function admin_mail_page() {
790 global $allowedposttags;
791
792 $this->options = get_option('usces');
793
794 if(isset($_POST['usces_option_update'])) {
795 $_POST = $this->stripslashes_deep_post($_POST);
796
797 $this->options['smtp_hostname'] = trim($_POST['smtp_hostname']);
798 $this->options['newmem_admin_mail'] = (int)$_POST['newmem_admin_mail'];
799 $this->options['delmem_admin_mail'] = (int)$_POST['delmem_admin_mail'];
800 $this->options['delmem_customer_mail'] = (int)$_POST['delmem_customer_mail'];
801
802 foreach ( $_POST['title'] as $key => $value ) {
803 if( WCUtils::is_blank($value) ) {
804 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
805 }else{
806 $this->options['mail_data']['title'][$key] = trim($value);
807 }
808 }
809 foreach ( $_POST['header'] as $key => $value ) {
810 if( WCUtils::is_blank($value) ) {
811 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
812 }else{
813 $this->options['mail_data']['header'][$key] = $value;
814 }
815 }
816 foreach ( $_POST['footer'] as $key => $value ) {
817 if( WCUtils::is_blank($value) ) {
818 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
819 }else{
820 $this->options['mail_data']['footer'][$key] = $value;
821 }
822 }
823
824
825 $this->action_status = 'success';
826 $this->action_message = __('options are updated','usces');
827
828 } else {
829
830 foreach ( (array)$this->options['mail_data']['title'] as $key => $value ) {
831 if( WCUtils::is_blank($value) ) {
832 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
833 }
834 }
835 foreach ( (array)$this->options['mail_data']['header'] as $key => $value ) {
836 if( WCUtils::is_blank($value) ) {
837 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
838 }
839 }
840 foreach ( (array)$this->options['mail_data']['footer'] as $key => $value ) {
841 if( WCUtils::is_blank($value) ) {
842 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
843 }
844 }
845
846 $this->action_status = 'none';
847 $this->action_message = '';
848
849 }
850
851 update_option('usces', $this->options);
852 do_action( 'usces_action_admin_mail_page' );
853
854 require_once(USCES_PLUGIN_DIR . '/includes/admin_mail.php');
855
856 }
857
858 /* Admin Cart Page */
859 function admin_cart_page() {
860 global $allowedposttags;
861 $this->options = get_option('usces');
862
863 if(isset($_POST['usces_option_update'])) {
864 $_POST = $this->stripslashes_deep_post($_POST);
865
866 foreach ( $this->options['indi_item_name'] as $key => $value ) {
867 $this->options['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0;
868 }
869 foreach ( $_POST['position'] as $key => $value ) {
870 $this->options['pos_item_name'][$key] = $value;
871 }
872 foreach ( $_POST['header'] as $key => $value ) {
873 $this->options['cart_page_data']['header'][$key] = addslashes(wp_kses($value, $allowedposttags));
874 }
875 foreach ( $_POST['footer'] as $key => $value ) {
876 $this->options['cart_page_data']['footer'][$key] = addslashes(wp_kses($value, $allowedposttags));
877 }
878
879 update_option('usces', $this->options);
880
881 $this->action_status = 'success';
882 $this->action_message = __('options are updated','usces');
883 } else {
884
885 $this->action_status = 'none';
886 $this->action_message = '';
887 }
888
889
890
891 require_once(USCES_PLUGIN_DIR . '/includes/admin_cart.php');
892
893 }
894
895 /* Admin Member Page */
896 function admin_member_page() {
897
898 $this->options = get_option('usces');
899
900 if(isset($_POST['usces_option_update'])) {
901 $_POST = $this->stripslashes_deep_post($_POST);
902
903 foreach ( $_POST['header'] as $key => $value ) {
904 $this->options['member_page_data']['header'][$key] = $value;
905 }
906 foreach ( $_POST['footer'] as $key => $value ) {
907 $this->options['member_page_data']['footer'][$key] = $value;
908 }
909
910 update_option('usces', $this->options);
911
912 $this->action_status = 'success';
913 $this->action_message = __('options are updated','usces');
914 } else {
915
916 $this->action_status = 'none';
917 $this->action_message = '';
918 }
919
920
921
922 require_once(USCES_PLUGIN_DIR . '/includes/admin_member.php');
923
924 }
925
926
927 /* Admin System Page */
928 function admin_system_page() {
929 //20110331ysk start
930 global $usces_states;
931 //20110331ysk end
932 $action_status = '';//20120511ysk 0000470
933
934 $this->options = get_option('usces');
935
936 if(isset($_POST['usces_option_update'])) {
937 $_POST = $this->stripslashes_deep_post($_POST);
938
939 $this->options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0;
940 $this->options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : '';
941 $this->options['fukugo_category_orderby'] = isset($_POST['fukugo_category_orderby']) ? $_POST['fukugo_category_orderby'] : '';
942 $this->options['fukugo_category_order'] = isset($_POST['fukugo_category_order']) ? $_POST['fukugo_category_order'] : '';
943 $this->options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : '';
944 if( WCUtils::is_blank($this->options['settlement_path']) ) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
945 $sl = substr($this->options['settlement_path'], -1);
946 if($sl != '/' && $sl != '\\') $this->options['settlement_path'] .= '/';
947 $this->options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : '';
948 if( !WCUtils::is_blank($this->options['logs_path']) ){
949 $sl = substr($this->options['logs_path'], -1);
950 if($sl == '/' || $sl == '\\') $this->options['logs_path'] = substr($this->options['logs_path'], 0, -1);
951 }
952 $this->options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0;
953 $this->options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : '';
954 $this->options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : '';
955 if( WCUtils::is_blank($this->options['ssl_url']) || WCUtils::is_blank($this->options['ssl_url_admin']) ) $this->options['use_ssl'] = 0;
956 $this->options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : '';
957 $this->options['use_javascript'] = isset($_POST['use_javascript']) ? (int)$_POST['use_javascript'] : 1;
958 $this->options['system']['front_lang'] = (isset($_POST['front_lang']) && 'others' != $_POST['front_lang']) ? $_POST['front_lang'] : usces_get_local_language();
959 $this->options['system']['currency'] = (isset($_POST['currency']) && 'others' != $_POST['currency']) ? $_POST['currency'] : usces_get_base_country();
960 $this->options['system']['addressform'] = (isset($_POST['addressform']) ) ? $_POST['addressform'] : usces_get_local_addressform();
961 $this->options['system']['target_market'] = (isset($_POST['target_market']) ) ? $_POST['target_market'] : usces_get_local_target_market();
962 $this->options['system']['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0;
963 $this->options['system']['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int)$_POST['dec_orderID_flag'] : 0;
964 $this->options['system']['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : '';
965 if( isset($_POST['dec_orderID_digit']) ){
966 $dec_orderID_digit = (int)rtrim($_POST['dec_orderID_digit']);
967 if( 6 > $dec_orderID_digit ){
968 $this->options['system']['dec_orderID_digit'] = 6;
969 }else{
970 $this->options['system']['dec_orderID_digit'] = $dec_orderID_digit;
971 }
972 }else{
973 $this->options['system']['dec_orderID_digit'] = 6;
974 }
975 $this->options['system']['subimage_rule'] = isset($_POST['subimage_rule']) ? (int)$_POST['subimage_rule'] : 0;
976 //20110331ysk start
977 unset($this->options['province']);
978 //$action_status = '';//20120511ysk 0000470
979 foreach((array)$this->options['system']['target_market'] as $target_market) {
980 $province = array();
981 if(!empty($_POST['province_'.$target_market])) {
982 $temp_pref = explode("\n", $_POST['province_'.$target_market]);
983 //20120123ysk start 0000386
984 //$province[] = __('-- Select --', 'usces');
985 $province[] = '-- Select --';
986 //20120123ysk end
987 //20120725ysk start 0000537
988 //for($i = 0; $i < count($temp_pref); $i++) {
989 //$province[] = trim($temp_pref[$i]);
990 foreach( $temp_pref as $pref ) {
991 if( !WCUtils::is_blank($pref) )
992 $province[] = trim($pref);
993 }
994 if( 1 == count($province) )
995 $action_status = 'error';
996 //20120725ysk end
997 } else {
998 if(isset($usces_states[$target_market]) && is_array($usces_states[$target_market])) {
999 $province = $usces_states[$target_market];
1000 } else {
1001 $action_status = 'error';
1002 }
1003 }
1004 $this->options['province'][$target_market] = $province;
1005 }
1006
1007 if($action_status != '') {
1008 $this->action_status = 'error';
1009 $this->action_message = __('Data have deficiency.','usces');
1010 } else {
1011 $this->action_status = 'success';
1012 $this->action_message = __('options are updated','usces');
1013 }
1014 //20110331ysk end
1015 } else {
1016
1017 if( !isset($this->options['province']) || empty($this->options['province']) ){
1018 //20110331ysk start
1019 //$this->options['province'] = get_option('usces_pref');
1020 $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
1021 //20110331ysk end
1022 }
1023 $this->action_status = 'none';
1024 $this->action_message = '';
1025 }
1026
1027 if($action_status != 'error') //20120511ysk 0000470
1028 update_option('usces', $this->options);
1029
1030 require_once(USCES_PLUGIN_DIR . '/includes/admin_system.php');
1031
1032 }
1033
1034 /* Settlement Setting Page */
1035 function admin_settlement_page() {
1036
1037 $this->action_status = 'none';
1038 $this->action_message = '';
1039
1040 $options = get_option('usces');
1041
1042
1043 if( isset($_POST['usces_option_update']) ) {
1044 $_POST = $this->stripslashes_deep_post($_POST);
1045 $mes = '';
1046
1047 switch( $_POST['acting'] ){
1048 case 'zeus':
1049 unset( $options['acting_settings']['zeus'] );
1050 $options['acting_settings']['zeus']['card_url'] = isset($_POST['card_url']) ? $_POST['card_url'] : '';
1051 $options['acting_settings']['zeus']['card_secureurl'] = isset($_POST['card_secureurl']) ? $_POST['card_secureurl'] : '';
1052 $options['acting_settings']['zeus']['ipaddrs'] = isset($_POST['ipaddrs']) ? $_POST['ipaddrs'] : '';
1053 $options['acting_settings']['zeus']['pay_cvs'] = isset($_POST['pay_cvs']) ? $_POST['pay_cvs'] : '';
1054 $options['acting_settings']['zeus']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1055 $options['acting_settings']['zeus']['connection'] = isset($_POST['connection']) ? $_POST['connection'] : 1;
1056 $options['acting_settings']['zeus']['3dsecur'] = isset($_POST['3dsecur']) ? $_POST['3dsecur'] : 2;
1057 $options['acting_settings']['zeus']['security'] = isset($_POST['security']) ? $_POST['security'] : 2;
1058 if( isset($_POST['authkey']) ){
1059 $options['acting_settings']['zeus']['authkey'] = $_POST['authkey'];
1060 }
1061 // if( 1 == $options['acting_settings']['zeus']['security'] ){
1062 // $options['acting_settings']['zeus']['quickcharge'] = '2';
1063 // }else{
1064 $options['acting_settings']['zeus']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : '';
1065 // }
1066 $options['acting_settings']['zeus']['batch'] = isset($_POST['batch']) ? $_POST['batch'] : '';
1067 $options['acting_settings']['zeus']['clientip'] = isset($_POST['clientip']) ? trim($_POST['clientip']) : '';
1068 $options['acting_settings']['zeus']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1069 $options['acting_settings']['zeus']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1070 $options['acting_settings']['zeus']['clientip_bank'] = isset($_POST['clientip_bank']) ? trim($_POST['clientip_bank']) : '';
1071 $options['acting_settings']['zeus']['testid_bank'] = isset($_POST['testid_bank']) ? trim($_POST['testid_bank']) : '';
1072 $options['acting_settings']['zeus']['bank_url'] = isset($_POST['bank_url']) ? $_POST['bank_url'] : '';
1073 $options['acting_settings']['zeus']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1074 $options['acting_settings']['zeus']['clientip_conv'] = isset($_POST['clientip_conv']) ? trim($_POST['clientip_conv']) : '';
1075 $options['acting_settings']['zeus']['testid_conv'] = isset($_POST['testid_conv']) ? trim($_POST['testid_conv']) : '';
1076 $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'];
1077 $options['acting_settings']['zeus']['conv_url'] = isset($_POST['conv_url']) ? $_POST['conv_url'] : '';
1078
1079 if( WCUtils::is_blank($_POST['clientip']) && isset($_POST['card_activate']) && 'on' == $_POST['card_activate'])
1080 $mes .= '※カード決済IPコードを�
1081 �力して下さい<br />';
1082 if( isset($_POST['authkey']) && WCUtils::is_blank($_POST['authkey']) && isset($_POST['security']) && 3 == $_POST['security'])
1083 $mes .= '※認証キーを�
1084 �力して下さい<br />';
1085 if( WCUtils::is_blank($_POST['clientip_bank']) && isset($_POST['bank_activate']) && 'on' == $_POST['bank_activate'] )
1086 $mes .= '※�
1087 �金お任せIPコードを�
1088 �力して下さい<br />';
1089 if( WCUtils::is_blank($_POST['clientip_conv']) && isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] )
1090 $mes .= '※コンビニ決済IPコードを�
1091 �力して下さい<br />';
1092 if( isset($_POST['batch']) && 'on' == $_POST['batch'] ) {
1093 if( isset($_POST['quickcharge']) && 'on' == $_POST['quickcharge'] ) {
1094 } else {
1095 $mes .= '※バッチ処理を利用する場合は、クイックチャージを利用するにして下さい<br />';
1096 }
1097 }
1098 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']) )
1099 $mes .= '※設定が不正です!<br />';
1100
1101 if( WCUtils::is_blank($mes) ){
1102 $this->action_status = 'success';
1103 $this->action_message = __('options are updated','usces');
1104 $options['acting_settings']['zeus']['activate'] = 'on';
1105 if( 'on' == $options['acting_settings']['zeus']['card_activate'] ){
1106 $this->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
1107 }else{
1108 unset($this->payment_structure['acting_zeus_card']);
1109 }
1110 if( 'on' == $options['acting_settings']['zeus']['bank_activate'] ){
1111 $this->payment_structure['acting_zeus_bank'] = '�
1112 �金お任せ(ZEUS)';
1113 }else{
1114 unset($this->payment_structure['acting_zeus_bank']);
1115 }
1116 if( 'on' == $options['acting_settings']['zeus']['conv_activate'] ){
1117 $this->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
1118 }else{
1119 unset($this->payment_structure['acting_zeus_conv']);
1120 }
1121 }else{
1122 $this->action_status = 'error';
1123 $this->action_message = __('データに不備が有ります','usces');
1124 $options['acting_settings']['zeus']['activate'] = 'off';
1125 unset($this->payment_structure['acting_zeus_card'], $this->payment_structure['acting_zeus_bank'], $this->payment_structure['acting_zeus_conv']);
1126 }
1127 ksort($this->payment_structure);
1128 update_option('usces_payment_structure',$this->payment_structure);
1129 $options['acting_settings']['zeus']['vercheck'] = '115';
1130 if( update_option('usces', $options) ){
1131 usces_clear_quickcharge();
1132 }
1133 break;
1134
1135 case 'remise':
1136 unset( $options['acting_settings']['remise'] );
1137 $options['acting_settings']['remise']['plan'] = isset($_POST['plan']) ? $_POST['plan'] : '';
1138 $options['acting_settings']['remise']['SHOPCO'] = isset($_POST['SHOPCO']) ? $_POST['SHOPCO'] : '';
1139 $options['acting_settings']['remise']['HOSTID'] = isset($_POST['HOSTID']) ? $_POST['HOSTID'] : '';
1140 $options['acting_settings']['remise']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1141 $options['acting_settings']['remise']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1142 $options['acting_settings']['remise']['card_pc_ope'] = isset($_POST['card_pc_ope']) ? $_POST['card_pc_ope'] : '';
1143 $options['acting_settings']['remise']['payquick'] = isset($_POST['payquick']) ? $_POST['payquick'] : '';
1144 $options['acting_settings']['remise']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1145 $options['acting_settings']['remise']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1146 $options['acting_settings']['remise']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1147 $options['acting_settings']['remise']['conv_pc_ope'] = isset($_POST['conv_pc_ope']) ? $_POST['conv_pc_ope'] : '';
1148 $options['acting_settings']['remise']['S_PAYDATE'] = isset($_POST['S_PAYDATE']) ? $_POST['S_PAYDATE'] : '';
1149 $options['acting_settings']['remise']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1150 $options['acting_settings']['remise']['send_url_pc'] = isset($_POST['send_url_pc']) ? $_POST['send_url_pc'] : '';
1151 $options['acting_settings']['remise']['send_url_cvs_mbl'] = isset($_POST['send_url_cvs_mbl']) ? $_POST['send_url_cvs_mbl'] : '';
1152 $options['acting_settings']['remise']['send_url_cvs_pc'] = isset($_POST['send_url_cvs_pc']) ? $_POST['send_url_cvs_pc'] : '';
1153 $options['acting_settings']['remise']['send_url_mbl_test'] = isset($_POST['send_url_mbl_test']) ? $_POST['send_url_mbl_test'] : '';
1154 $options['acting_settings']['remise']['send_url_pc_test'] = isset($_POST['send_url_pc_test']) ? $_POST['send_url_pc_test'] : '';
1155 $options['acting_settings']['remise']['send_url_cvs_mbl_test'] = isset($_POST['send_url_cvs_mbl_test']) ? $_POST['send_url_cvs_mbl_test'] : '';
1156 $options['acting_settings']['remise']['send_url_cvs_pc_test'] = isset($_POST['send_url_cvs_pc_test']) ? $_POST['send_url_cvs_pc_test'] : '';
1157 $options['acting_settings']['remise']['REMARKS3'] = isset($_POST['REMARKS3']) ? $_POST['REMARKS3'] : '';
1158
1159 if( isset($_POST['plan_remise']) && WCUtils::is_zero($_POST['plan_remise']) )
1160 $mes .= '※サービスプランを選択してください<br />';
1161 if( WCUtils::is_blank($_POST['SHOPCO']) )
1162 $mes .= '※加盟店コードを�
1163 �力して下さい<br />';
1164 if( WCUtils::is_blank($_POST['HOSTID']) )
1165 $mes .= '※ホスト番号を�
1166 �力して下さい<br />';
1167 if( isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] && empty($_POST['S_PAYDATE']) )
1168 $mes .= '※支払期限を�
1169 �力して下さい<br />';
1170 if( isset($_POST['card_pc_ope']) && 'public' == $_POST['card_pc_ope'] && empty($_POST['send_url_pc']) )
1171 $mes .= '※クレジットカード決済の本番URLを�
1172 �力して下さい<br />';
1173 if( isset($_POST['conv_pc_ope']) && 'public' == $_POST['conv_pc_ope'] && empty($_POST['send_url_cvs_pc']) )
1174 $mes .= '※コンビニ・電子マネー決済の本番URLを�
1175 �力して下さい<br />';
1176 if( !isset($_POST['REMARKS3']) || empty($_POST['REMARKS3']) )
1177 $mes .= '※設定が不正です!<br />';
1178
1179 if( WCUtils::is_blank($mes) ){
1180 //$this->zaction_status = 'success';
1181 $this->action_status = 'success';
1182 $this->action_message = __('options are updated','usces');
1183 $options['acting_settings']['remise']['activate'] = 'on';
1184 if( 'on' == $options['acting_settings']['remise']['card_activate'] ){
1185 $this->payment_structure['acting_remise_card'] = 'カード決済(ルミーズ)';
1186 }else{
1187 unset($this->payment_structure['acting_remise_card']);
1188 }
1189 if( 'on' == $options['acting_settings']['remise']['conv_activate'] ){
1190 $this->payment_structure['acting_remise_conv'] = 'コンビニ決済(ルミーズ)';
1191 }else{
1192 unset($this->payment_structure['acting_remise_conv']);
1193 }
1194
1195 }else{
1196 $this->action_status = 'error';
1197 $this->action_message = __('データに不備が有ります','usces');
1198 $options['acting_settings']['remise']['activate'] = 'off';
1199 unset($this->payment_structure['acting_remise_card']);
1200 unset($this->payment_structure['acting_remise_conv']);
1201 }
1202 ksort($this->payment_structure);
1203 update_option('usces_payment_structure',$this->payment_structure);
1204 update_option('usces', $options);
1205 break;
1206 //20101018ysk start
1207 case 'jpayment':
1208 unset( $options['acting_settings']['jpayment'] );
1209 $options['acting_settings']['jpayment']['aid'] = isset($_POST['aid']) ? $_POST['aid'] : '';
1210 $options['acting_settings']['jpayment']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1211 $options['acting_settings']['jpayment']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1212 $options['acting_settings']['jpayment']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1213 //$options['acting_settings']['jpayment']['webm_activate'] = isset($_POST['webm_activate']) ? $_POST['webm_activate'] : '';
1214 //$options['acting_settings']['jpayment']['bitc_activate'] = isset($_POST['bitc_activate']) ? $_POST['bitc_activate'] : '';
1215 //$options['acting_settings']['jpayment']['suica_activate'] = isset($_POST['suica_activate']) ? $_POST['suica_activate'] : '';
1216 $options['acting_settings']['jpayment']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1217 $options['acting_settings']['jpayment']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1218
1219 if( WCUtils::is_blank($_POST['aid']) )
1220 $mes .= '※店舗IDコードを�
1221 �力して下さい<br />';
1222 if( isset($_POST['card_activate']) && 'on' == $_POST['card_activate'] && empty($_POST['card_jb']) )
1223 $mes .= '※ジョブタイプを指定して下さい<br />';
1224
1225 if( WCUtils::is_blank($mes) ){
1226 $this->action_status = 'success';
1227 $this->action_message = __('options are updated','usces');
1228 $options['acting_settings']['jpayment']['activate'] = 'on';
1229 if( 'on' == $options['acting_settings']['jpayment']['card_activate'] ){
1230 $this->payment_structure['acting_jpayment_card'] = 'カード決済(J-Payment)';
1231 }else{
1232 unset($this->payment_structure['acting_jpayment_card']);
1233 }
1234 if( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ){
1235 $this->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(J-Payment)';
1236 }else{
1237 unset($this->payment_structure['acting_jpayment_conv']);
1238 }
1239 //if( 'on' == $options['acting_settings']['jpayment']['webm_activate'] ){
1240 // $this->payment_structure['acting_jpayment_webm'] = 'WebMoney決済(J-Payment)';
1241 //}else{
1242 // unset($this->payment_structure['acting_jpayment_webm']);
1243 //}
1244 //if( 'on' == $options['acting_settings']['jpayment']['bitc_activate'] ){
1245 // $this->payment_structure['acting_jpayment_bitc'] = 'BitCash決済(J-Payment)';
1246 //}else{
1247 // unset($this->payment_structure['acting_jpayment_bitc']);
1248 //}
1249 //if( 'on' == $options['acting_settings']['jpayment']['suica_activate'] ){
1250 // $this->payment_structure['acting_jpayment_suica'] = 'モバイルSuica決済(J-Payment)';
1251 //}else{
1252 // unset($this->payment_structure['acting_jpayment_suica']);
1253 //}
1254 if( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ){
1255 $this->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(J-Payment)';
1256 }else{
1257 unset($this->payment_structure['acting_jpayment_bank']);
1258 }
1259
1260 }else{
1261 $this->action_status = 'error';
1262 $this->action_message = __('データに不備が有ります', 'usces');
1263 $options['acting_settings']['jpayment']['activate'] = 'off';
1264 unset($this->payment_structure['acting_jpayment_card']);
1265 unset($this->payment_structure['acting_jpayment_conv']);
1266 //unset($this->payment_structure['acting_jpayment_webm']);
1267 //unset($this->payment_structure['acting_jpayment_bitc']);
1268 //unset($this->payment_structure['acting_jpayment_suica']);
1269 unset($this->payment_structure['acting_jpayment_bank']);
1270 }
1271 ksort($this->payment_structure);
1272 update_option('usces_payment_structure', $this->payment_structure);
1273 update_option('usces', $options);
1274 break;
1275 //20101018ysk end
1276 //20110208ysk start
1277 case 'paypal':
1278 unset( $options['acting_settings']['paypal'] );
1279 $options['acting_settings']['paypal']['ec_activate'] = isset($_POST['ec_activate']) ? $_POST['ec_activate'] : '';
1280 $options['acting_settings']['paypal']['sandbox'] = isset($_POST['sandbox']) ? $_POST['sandbox'] : '';
1281 $options['acting_settings']['paypal']['user'] = isset($_POST['user']) ? $_POST['user'] : '';
1282 $options['acting_settings']['paypal']['pwd'] = isset($_POST['pwd']) ? $_POST['pwd'] : '';
1283 $options['acting_settings']['paypal']['signature'] = isset($_POST['signature']) ? $_POST['signature'] : '';
1284 //20110412ysk start
1285 $options['acting_settings']['paypal']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1286 //20110412ysk end
1287
1288 if( !isset($_POST['sandbox']) || empty($_POST['sandbox']) )
1289 $mes .= '※PayPalサーバーが不正です<br />';
1290 if( WCUtils::is_blank($_POST['user']) )
1291 $mes .= '※APIユーザー名を�
1292 �力して下さい<br />';
1293 if( WCUtils::is_blank($_POST['pwd']) )
1294 $mes .= '※APIパスワードを�
1295 �力して下さい<br />';
1296 if( WCUtils::is_blank($_POST['signature']) )
1297 $mes .= '※署名を�
1298 �力して下さい<br />';
1299
1300 if( WCUtils::is_blank($mes) ){
1301 $this->action_status = 'success';
1302 $this->action_message = __('options are updated','usces');
1303 if($options['acting_settings']['paypal']['sandbox'] == 1) {
1304 $options['acting_settings']['paypal']['api_host'] = 'api-3t.sandbox.paypal.com';
1305 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.sandbox.paypal.com/nvp';
1306 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
1307 } else {
1308 $options['acting_settings']['paypal']['api_host'] = 'api-3t.paypal.com';
1309 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.paypal.com/nvp';
1310 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.paypal.com/cgi-bin/webscr';
1311 }
1312 $options['acting_settings']['paypal']['activate'] = 'on';
1313 if( 'on' == $options['acting_settings']['paypal']['ec_activate'] ){
1314 $this->payment_structure['acting_paypal_ec'] = 'PayPal決済';
1315 }else{
1316 unset($this->payment_structure['acting_paypal_ec']);
1317 }
1318
1319 }else{
1320 $this->action_status = 'error';
1321 $this->action_message = __('データに不備が有ります', 'usces');
1322 $options['acting_settings']['paypal']['activate'] = 'off';
1323 unset($this->payment_structure['acting_paypal_ec']);
1324 }
1325 ksort($this->payment_structure);
1326 update_option('usces_payment_structure', $this->payment_structure);
1327 update_option('usces', $options);
1328 break;
1329 //20110208ysk end
1330 //20120413ysk start
1331 case 'sbps':
1332 unset( $options['acting_settings']['sbps'] );
1333 $options['acting_settings']['sbps']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : '';
1334 $options['acting_settings']['sbps']['service_id'] = isset($_POST['service_id']) ? $_POST['service_id'] : '';
1335 $options['acting_settings']['sbps']['hash_key'] = isset($_POST['hash_key']) ? $_POST['hash_key'] : '';
1336 $options['acting_settings']['sbps']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1337 $options['acting_settings']['sbps']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1338 $options['acting_settings']['sbps']['send_url_check'] = isset($_POST['send_url_check']) ? $_POST['send_url_check'] : '';
1339 $options['acting_settings']['sbps']['send_url_test'] = isset($_POST['send_url_test']) ? $_POST['send_url_test'] : '';
1340 $options['acting_settings']['sbps']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1341 $options['acting_settings']['sbps']['3d_secure'] = isset($_POST['3d_secure']) ? $_POST['3d_secure'] : '';
1342 $options['acting_settings']['sbps']['cust'] = isset($_POST['cust']) ? $_POST['cust'] : '';
1343 $options['acting_settings']['sbps']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1344 $options['acting_settings']['sbps']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1345 $options['acting_settings']['sbps']['payeasy_activate'] = isset($_POST['payeasy_activate']) ? $_POST['payeasy_activate'] : '';
1346 $options['acting_settings']['sbps']['wallet_yahoowallet'] = isset($_POST['wallet_yahoowallet']) ? $_POST['wallet_yahoowallet'] : '';
1347 $options['acting_settings']['sbps']['wallet_rakuten'] = isset($_POST['wallet_rakuten']) ? $_POST['wallet_rakuten'] : '';
1348 $options['acting_settings']['sbps']['wallet_paypal'] = isset($_POST['wallet_paypal']) ? $_POST['wallet_paypal'] : '';
1349 $options['acting_settings']['sbps']['wallet_netmile'] = isset($_POST['wallet_netmile']) ? $_POST['wallet_netmile'] : '';
1350 $options['acting_settings']['sbps']['wallet_alipay'] = isset($_POST['wallet_alipay']) ? $_POST['wallet_alipay'] : '';
1351 $options['acting_settings']['sbps']['mobile_docomo'] = isset($_POST['mobile_docomo']) ? $_POST['mobile_docomo'] : '';
1352 $options['acting_settings']['sbps']['mobile_softbank'] = isset($_POST['mobile_softbank']) ? $_POST['mobile_softbank'] : '';
1353 $options['acting_settings']['sbps']['mobile_auone'] = isset($_POST['mobile_auone']) ? $_POST['mobile_auone'] : '';
1354 $options['acting_settings']['sbps']['mobile_mysoftbank'] = isset($_POST['mobile_mysoftbank']) ? $_POST['mobile_mysoftbank'] : '';
1355
1356 if( WCUtils::is_blank($_POST['merchant_id']) )
1357 $mes .= '※マーチャントIDを�
1358 �力して下さい<br />';
1359 if( WCUtils::is_blank($_POST['service_id']) )
1360 $mes .= '※サービスIDを�
1361 �力して下さい<br />';
1362 if( WCUtils::is_blank($_POST['hash_key']) )
1363 $mes .= '※Hash KEYを�
1364 �力して下さい<br />';
1365 if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1366 $mes .= '※本番URLを�
1367 �力して下さい<br />';
1368
1369 if( WCUtils::is_blank($mes) ){
1370 $this->action_status = 'success';
1371 $this->action_message = __('options are updated','usces');
1372 $options['acting_settings']['sbps']['activate'] = 'on';
1373 if( 'on' == $options['acting_settings']['sbps']['card_activate'] ){
1374 $this->payment_structure['acting_sbps_card'] = 'カード決済(ソフトバンク・ペイメント)';
1375 }else{
1376 unset($this->payment_structure['acting_sbps_card']);
1377 }
1378 if( 'on' == $options['acting_settings']['sbps']['conv_activate'] ){
1379 $this->payment_structure['acting_sbps_conv'] = 'コンビニ決済(ソフトバンク・ペイメント)';
1380 }else{
1381 unset($this->payment_structure['acting_sbps_conv']);
1382 }
1383 if( 'on' == $options['acting_settings']['sbps']['payeasy_activate'] ){
1384 $this->payment_structure['acting_sbps_payeasy'] = 'ペイジー決済(ソフトバンク・ペイメント)';
1385 }else{
1386 unset($this->payment_structure['acting_sbps_payeasy']);
1387 }
1388 if( ( 'on' == $options['acting_settings']['sbps']['wallet_yahoowallet'] ) ||
1389 ( 'on' == $options['acting_settings']['sbps']['wallet_rakuten'] ) ||
1390 ( 'on' == $options['acting_settings']['sbps']['wallet_paypal'] ) ||
1391 ( 'on' == $options['acting_settings']['sbps']['wallet_netmile'] ) ||
1392 ( 'on' == $options['acting_settings']['sbps']['wallet_alipay'] ) ) {
1393 $options['acting_settings']['sbps']['wallet_activate'] = 'on';
1394 } else {
1395 $options['acting_settings']['sbps']['wallet_activate'] = 'off';
1396 }
1397 if( 'on' == $options['acting_settings']['sbps']['wallet_activate'] ){
1398 $this->payment_structure['acting_sbps_wallet'] = 'ウォレット決済(ソフトバンク・ペイメント)';
1399 }else{
1400 unset($this->payment_structure['acting_sbps_wallet']);
1401 }
1402 if( ( 'on' == $options['acting_settings']['sbps']['mobile_docomo'] ) ||
1403 ( 'on' == $options['acting_settings']['sbps']['mobile_softbank'] ) ||
1404 ( 'on' == $options['acting_settings']['sbps']['mobile_auone'] ) ||
1405 ( 'on' == $options['acting_settings']['sbps']['mobile_mysoftbank'] ) ) {
1406 $options['acting_settings']['sbps']['mobile_activate'] = 'on';
1407 } else {
1408 $options['acting_settings']['sbps']['mobile_activate'] = 'off';
1409 }
1410 if( 'on' == $options['acting_settings']['sbps']['mobile_activate'] ){
1411 $this->payment_structure['acting_sbps_mobile'] = '携帯キャリア決済(ソフトバンク・ペイメント)';
1412 }else{
1413 unset($this->payment_structure['acting_sbps_mobile']);
1414 }
1415
1416 }else{
1417 $this->action_status = 'error';
1418 $this->action_message = __('データに不備が有ります','usces');
1419 $options['acting_settings']['sbps']['activate'] = 'off';
1420 unset($this->payment_structure['acting_sbps_card']);
1421 unset($this->payment_structure['acting_sbps_conv']);
1422 unset($this->payment_structure['acting_sbps_payeasy']);
1423 unset($this->payment_structure['acting_sbps_wallet']);
1424 unset($this->payment_structure['acting_sbps_mobile']);
1425 }
1426 ksort($this->payment_structure);
1427 update_option('usces_payment_structure', $this->payment_structure);
1428 update_option('usces', $options);
1429 break;
1430 //20120413ysk end
1431 //20120618ysk start
1432 case 'telecom':
1433 unset( $options['acting_settings']['telecom'] );
1434 $options['acting_settings']['telecom']['clientip'] = isset($_POST['clientip']) ? $_POST['clientip'] : '';
1435 $options['acting_settings']['telecom']['stype'] = isset($_POST['stype']) ? $_POST['stype'] : '';
1436 $options['acting_settings']['telecom']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1437 $options['acting_settings']['telecom']['edy_activate'] = isset($_POST['edy_activate']) ? $_POST['edy_activate'] : '';
1438
1439 if( WCUtils::is_blank($_POST['clientip']) )
1440 $mes .= '※クライアントIPを�
1441 �力して下さい<br />';
1442 if( WCUtils::is_blank($_POST['stype']) )
1443 $mes .= '※決済タイプを�
1444 �力して下さい<br />';
1445
1446 if( WCUtils::is_blank($mes) ){
1447 $this->action_status = 'success';
1448 $this->action_message = __('options are updated','usces');
1449 $options['acting_settings']['telecom']['activate'] = 'on';
1450 if( 'on' == $options['acting_settings']['telecom']['card_activate'] ){
1451 if( 'E' == $options['acting_settings']['telecom']['stype'][0] ) {
1452 $options['acting_settings']['telecom']['send_url'] = "https://www.credit-cgiserver.com/inetcredit/secure/order.pl";
1453 } else {
1454 $options['acting_settings']['telecom']['send_url'] = "https://secure.telecomcredit.co.jp/inetcredit/secure/order.pl";
1455 }
1456 $this->payment_structure['acting_telecom_card'] = 'カード決済(テレコムクレジット)';
1457 }else{
1458 unset($this->payment_structure['acting_telecom_card']);
1459 }
1460 if( 'on' == $options['acting_settings']['telecom']['edy_activate'] ){
1461 $options['acting_settings']['telecom']['send_url_edy'] = "https://secure.telecomcredit.co.jp/payment/edy/order.pl";
1462 $this->payment_structure['acting_telecom_edy'] = 'Edy決済(テレコムクレジット)';
1463 }else{
1464 unset($this->payment_structure['acting_telecom_edy']);
1465 }
1466 }else{
1467 $this->action_status = 'error';
1468 $this->action_message = __('データに不備が有ります','usces');
1469 $options['acting_settings']['telecom']['activate'] = 'off';
1470 unset($this->payment_structure['acting_telecom_card']);
1471 unset($this->payment_structure['acting_telecom_edy']);
1472 }
1473 ksort($this->payment_structure);
1474 update_option('usces_payment_structure', $this->payment_structure);
1475 update_option('usces', $options);
1476 break;
1477 //20120618ysk end
1478 //20121206ysk start
1479 case 'digitalcheck':
1480 unset( $options['acting_settings']['digitalcheck'] );
1481 $options['acting_settings']['digitalcheck']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1482 $options['acting_settings']['digitalcheck']['card_ip'] = isset($_POST['card_ip']) ? $_POST['card_ip'] : '';
1483 $options['acting_settings']['digitalcheck']['card_pass'] = isset($_POST['card_pass']) ? $_POST['card_pass'] : '';
1484 $options['acting_settings']['digitalcheck']['card_kakutei'] = isset($_POST['card_kakutei']) ? $_POST['card_kakutei'] : '';
1485 $options['acting_settings']['digitalcheck']['card_user_id'] = isset($_POST['card_user_id']) ? $_POST['card_user_id'] : '';
1486 $options['acting_settings']['digitalcheck']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1487 $options['acting_settings']['digitalcheck']['conv_ip'] = isset($_POST['conv_ip']) ? $_POST['conv_ip'] : '';
1488 $options['acting_settings']['digitalcheck']['conv_store'] = isset($_POST['conv_store']) ? $_POST['conv_store'] : array();
1489 $options['acting_settings']['digitalcheck']['conv_kigen'] = isset($_POST['conv_kigen']) ? $_POST['conv_kigen'] : '14';
1490
1491 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) {
1492 if( '' == trim($_POST['card_ip']) )
1493 $mes .= '※加盟店コードを�
1494 �力して下さい<br />';
1495 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1496 if( '' == trim($_POST['card_pass']) )
1497 $mes .= '※加盟店パスワードを�
1498 �力して下さい<br />';
1499 }
1500 }
1501 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
1502 if( '' == trim($_POST['conv_ip']) )
1503 $mes .= '※加盟店コードを�
1504 �力して下さい<br />';
1505 if( empty($_POST['conv_store']) )
1506 $mes .= '※利用コンビニを選択して下さい<br />';
1507 }
1508
1509 if( '' == $mes ){
1510 $this->action_status = 'success';
1511 $this->action_message = __('options are updated','usces');
1512 $options['acting_settings']['digitalcheck']['activate'] = 'on';
1513 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ){
1514 $options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll";
1515 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1516 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.digitalcheck.jp/settle/settlex/credit2.dll";
1517 } else {
1518 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "";
1519 }
1520 $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(デジタルチェック)';
1521 }else{
1522 unset($this->payment_structure['acting_digitalcheck_card']);
1523 }
1524 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ){
1525 //$options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle2/ubp3.dll";
1526 $options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll";
1527 $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(デジタルチェック)';
1528 }else{
1529 unset($this->payment_structure['acting_digitalcheck_conv']);
1530 }
1531 }else{
1532 $this->action_status = 'error';
1533 $this->action_message = __('データに不備が有ります','usces');
1534 $options['acting_settings']['digitalcheck']['activate'] = 'off';
1535 unset($this->payment_structure['acting_digitalcheck_card']);
1536 unset($this->payment_structure['acting_digitalcheck_conv']);
1537 }
1538 ksort($this->payment_structure);
1539 update_option('usces_payment_structure', $this->payment_structure);
1540 update_option('usces', $options);
1541 break;
1542 //20121206ysk end
1543 //20130225ysk start
1544 case 'mizuho':
1545 unset( $options['acting_settings']['mizuho'] );
1546 $options['acting_settings']['mizuho']['shopid'] = isset($_POST['shopid']) ? $_POST['shopid'] : '';
1547 $options['acting_settings']['mizuho']['cshopid'] = isset($_POST['cshopid']) ? $_POST['cshopid'] : '';
1548 $options['acting_settings']['mizuho']['hash_pass'] = isset($_POST['hash_pass']) ? $_POST['hash_pass'] : '';
1549 $options['acting_settings']['mizuho']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1550 $options['acting_settings']['mizuho']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1551 $options['acting_settings']['mizuho']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1552 $options['acting_settings']['mizuho']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1553 $options['acting_settings']['mizuho']['conv1_activate'] = isset($_POST['conv1_activate']) ? $_POST['conv1_activate'] : '';
1554 $options['acting_settings']['mizuho']['conv2_activate'] = isset($_POST['conv2_activate']) ? $_POST['conv2_activate'] : '';
1555
1556 //if( 'on' == $options['acting_settings']['mizuho']['card_activate'] or 'on' == $options['acting_settings']['mizuho']['conv_activate'] ) {
1557 if( '' == trim($_POST['shopid']) )
1558 $mes .= '※加盟店コードを�
1559 �力して下さい<br />';
1560 if( '' == trim($_POST['cshopid']) )
1561 $mes .= '※加盟店サブコードを�
1562 �力して下さい<br />';
1563 if( '' == trim($_POST['hash_pass']) )
1564 $mes .= '※ハッシュ用パスワードを�
1565 �力して下さい<br />';
1566 //}
1567 if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1568 $mes .= '※本番URLを�
1569 �力して下さい<br />';
1570 if( defined('WCEX_MOBILE') and isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url_mbl']) )
1571 $mes .= '※本番URL(携帯)を�
1572 �力して下さい<br />';
1573
1574 if( '' == $mes ) {
1575 $this->action_status = 'success';
1576 $this->action_message = __('options are updated','usces');
1577 $options['acting_settings']['mizuho']['activate'] = 'on';
1578 $options['acting_settings']['mizuho']['send_url_test'] = "https://210.161.141.207/mltbank/MBWebFrontPayment";
1579 if( defined('WCEX_MOBILE') ) $options['acting_settings']['mizuho']['send_url_mbl_test'] = "https://210.161.141.207/mltbank/iMBWebFrontPayment";
1580 if( 'on' == $options['acting_settings']['mizuho']['card_activate'] ) {
1581 $this->payment_structure['acting_mizuho_card'] = 'カード決済(みずほファクター)';
1582 } else {
1583 unset($this->payment_structure['acting_mizuho_card']);
1584 }
1585 if( 'on' == $options['acting_settings']['mizuho']['conv1_activate'] ) {
1586 $this->payment_structure['acting_mizuho_conv1'] = 'コンビニ・ウェルネット決済(みずほファクター)';
1587 } else {
1588 unset($this->payment_structure['acting_mizuho_conv1']);
1589 }
1590 if( 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) {
1591 $this->payment_structure['acting_mizuho_conv2'] = 'コンビニ・セブンイレブン決済(みずほファクター)';
1592 } else {
1593 unset($this->payment_structure['acting_mizuho_conv2']);
1594 }
1595 } else {
1596 $this->action_status = 'error';
1597 $this->action_message = __('データに不備が有ります','usces');
1598 $options['acting_settings']['mizuho']['activate'] = 'off';
1599 unset($this->payment_structure['acting_mizuho_card']);
1600 unset($this->payment_structure['acting_mizuho_conv1']);
1601 unset($this->payment_structure['acting_mizuho_conv2']);
1602 }
1603 ksort($this->payment_structure);
1604 update_option('usces_payment_structure', $this->payment_structure);
1605 update_option('usces', $options);
1606 break;
1607 //20130225ysk end
1608 }
1609
1610
1611 }
1612
1613
1614 $this->options = get_option('usces');
1615
1616 require_once(USCES_PLUGIN_DIR . '/includes/admin_settlement.php');
1617 }
1618
1619 /********************************************************************************/
1620 function selected( $selected, $current) {
1621 if ( $selected == $current)
1622 echo ' selected="selected"';
1623 }
1624 /********************************************************************************/
1625
1626 function usces_session_start() {
1627 $options = get_option('usces');
1628 if( !isset($options['usces_key']) || empty($options['usces_key']) ){
1629 $options['usces_key'] = uniqid('uk');
1630 update_option('usces', $options);
1631 }
1632
1633 if(defined( 'USCES_KEY' )){
1634 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1635 session_name( 'adm'.USCES_KEY );
1636 }else{
1637 session_name( USCES_KEY );
1638 }
1639 }else{
1640 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1641 session_name( 'adm'.$options['usces_key'] );
1642 }else{
1643 session_name( $options['usces_key'] );
1644 }
1645 }
1646 if(isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid'])) {
1647 $sessid = $_GET['uscesid'];
1648 $sessid = $this->uscesdc($sessid);
1649 session_id($sessid);
1650 }
1651
1652 @session_start();
1653
1654 //20111222ysk start 0000367
1655 //if ( !isset($_SESSION['usces_member']) ){
1656 if ( !isset($_SESSION['usces_member']) || $options['membersystem_state'] != 'activate' ){
1657 //20111222ysk end
1658 $_SESSION['usces_member'] = array();
1659 }
1660
1661 if(!isset($_SESSION['usces_checked_business_days']))
1662 $this->update_business_days();
1663 }
1664
1665 function usces_cookie() {
1666 if(is_admin()) return;
1667
1668 $actionflag = false;
1669 $sess = NULL;
1670 $addr = NULL;
1671 $rckid = NULL;
1672 $none = NULL;
1673 $cookie = $this->get_cookie();
1674
1675 if( isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid']) ){
1676 $sessid = base64_decode(urldecode($_GET['uscesid']));
1677 list($sess, $addr, $rckid, $none) = explode('_', $sessid, 4);
1678 }
1679 if('acting' == $addr) return;
1680
1681 if( apply_filters( 'usces_filter_cookie', false) ) return;
1682
1683 //There is a need to consider.
1684 return;
1685
1686 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
1687
1688 $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
1689 $sslid = isset($cookie['sslid']) ? $cookie['sslid'] : NULL;
1690 $option = get_option('usces');
1691 $parsed = parse_url(get_option('home'));
1692 $home = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1693 $parsed = parse_url($option['ssl_url']);
1694 $sslhome = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1695
1696 //usces_log('refer : '.$refer, 'acting_transaction.log');
1697 // usces_log('sslid : '.$sslid, 'acting_transaction.log');
1698 // usces_log('rckid : '.$rckid, 'acting_transaction.log');
1699 // usces_log('usces_cookieid : '.$_SESSION['usces_cookieid'], 'acting_transaction.log');
1700 // usces_log('request : '.print_r($_SERVER['REQUEST_URI'],true), 'acting_transaction.log');
1701
1702 if( empty($refer) || (false === strpos($refer, $home) && false === strpos($refer, $sslhome)) ){
1703 if( !empty($sslid) && !empty($rckid) && $sslid === $rckid ){
1704 $actionflag = true;
1705 }else{
1706 $actionflag = false;
1707 }
1708 }else{
1709 if( !empty($sslid) && $sslid !== $rckid ){
1710 $actionflag = false;
1711 }else{
1712 $actionflag = true;
1713 }
1714 }
1715
1716
1717 if( $actionflag ){
1718 $values = array(
1719 'id' => $rckid,
1720 'sslid' => $rckid,
1721 'name' => '',
1722 'rme' => ''
1723 );
1724 if( 'acting' !== $rckid ){
1725 $this->set_cookie($values);
1726 }
1727 }else{
1728 if( 'acting' !== $rckid ){
1729 unset($_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] );
1730 wp_redirect( 'http://'.$home );
1731 }
1732 }
1733 }else{
1734 if( !isset($cookie['id']) || WCUtils::is_blank($cookie['id']) ) {
1735 $values = array(
1736 'id' => md5(uniqid(rand(), true)),
1737 'name' => '',
1738 'rme' => ''
1739 );
1740 $this->set_cookie($values);
1741 $_SESSION['usces_cookieid'] = $values['id'];
1742 } else {
1743 if( !isset($_SESSION['usces_cookieid']) || $_SESSION['usces_cookieid'] != $cookie['id'])
1744 $_SESSION['usces_cookieid'] = $cookie['id'];
1745 }
1746
1747 $actionflag = true;
1748 }
1749
1750 }
1751
1752 function set_cookie($values){
1753 $value = serialize($values);
1754 $timeout = time()+7*86400;
1755 $domain = $_SERVER['SERVER_NAME'];
1756 $res = setcookie('usces_cookie', $value, $timeout, USCES_COOKIEPATH, $domain);
1757 }
1758
1759 function get_cookie() {
1760 $values = isset($_COOKIE['usces_cookie']) ? unserialize(stripslashes($_COOKIE['usces_cookie'])) : NULL;
1761 return $values;
1762 }
1763
1764 function get_access( $key, $type, $date ) {
1765 global $wpdb;
1766 $table_name = $wpdb->prefix . "usces_access";
1767
1768 $query = $wpdb->prepare("SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date);
1769 $value = $wpdb->get_var( $query );
1770 if( !$value ){
1771 $res = NULL;
1772 }else{
1773 $res = unserialize($value);
1774 }
1775
1776 return $res;
1777 }
1778
1779 function get_access_piriod( $key, $type, $startday, $endday ) {
1780 global $wpdb;
1781 $table_name = $wpdb->prefix . "usces_access";
1782 //$wpdb->show_errors();
1783 $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);
1784 $res = $wpdb->get_results( $query, ARRAY_A );
1785
1786 return $res;
1787 }
1788
1789 function update_access( $array ) {
1790 global $wpdb;
1791 $table_name = $wpdb->prefix . "usces_access";
1792
1793 $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']);
1794 $res = $wpdb->get_var( $query );
1795 //$wpdb->show_errors();
1796 if(empty($res)){
1797 $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']);
1798 $wpdb->query( $query );
1799 }else{
1800 $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']);
1801 $wpdb->query( $query );
1802 }
1803 }
1804
1805 function get_uscesid( $flag = true) {
1806
1807 $sessname = session_name();
1808 $sessid = session_id();
1809 $sessid = $this->uscescv($sessid, $flag);
1810 return $sessid;
1811 }
1812
1813 function shop_head() {
1814 global $post;
1815 $this->item = $post;
1816 $no_cart_css = isset($this->options['system']['no_cart_css']) ? $this->options['system']['no_cart_css'] : 0;
1817
1818 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1819 $css_url = USCES_FRONT_PLUGIN_URL . '/css/usces_cart.css';
1820 }else{
1821 $css_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/css/usces_cart.css';
1822 }
1823 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) ){
1824 echo " <meta name='robots' content='noindex,nofollow' />\n";
1825 wp_print_scripts( array( 'sack' ));
1826 }
1827 if( !$no_cart_css ){
1828 echo '<link href="' . $css_url . '" rel="stylesheet" type="text/css" />';
1829 }
1830 if( file_exists(get_stylesheet_directory() . '/usces_cart.css') ){
1831 echo '<link href="' . get_stylesheet_directory_uri() . '/usces_cart.css" rel="stylesheet" type="text/css" />';
1832 }
1833 }
1834
1835 function shop_foot() {
1836 global $current_user;
1837 $item = $this->item;
1838 if( empty($item) ){
1839 $item->ID = 0;
1840 $item->post_mime_type = '';
1841 }
1842 get_currentuserinfo();
1843 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1844 $javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js';
1845 }else{
1846 $javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js';
1847 }
1848 $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')) : '';
1849 $this->previous_url = isset($_SESSION['usces_previous_url']) ? $_SESSION['usces_previous_url'] : get_home_url();
1850
1851 // usces_log('post_type : '.$item->post_mime_type, 'test.log');
1852 // usces_log('is_single : '.(is_single() ? 'true' : 'false'), 'test.log');
1853
1854 if( $this->use_js && empty($this->item) && !is_admin() ) :
1855 ?>
1856 <script type='text/javascript'>
1857 /* <![CDATA[ */
1858 uscesL10n = {
1859 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
1860 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>"
1861 }
1862 /* ]]> */
1863 </script>
1864 <?php elseif( $this->use_js && !empty($this->item) ) :
1865
1866 $ioptkeys = $this->get_itemOptionKey( $item->ID );
1867 $mes_opts_str = "";
1868 $key_opts_str = "";
1869 $opt_means = "";
1870 $opt_esse = "";
1871 if($ioptkeys){
1872 foreach($ioptkeys as $key => $value){
1873 $optValues = $this->get_itemOptions( $value, $item->ID );
1874 if($optValues['means'] < 2){
1875 $mes_opts_str .= "'" . sprintf(__("Chose the %s", 'usces'), esc_js($value)) . "',";
1876 }else{
1877 $mes_opts_str .= "'" . sprintf(__("Input the %s", 'usces'), esc_js($value)) . "',";
1878 }
1879 $key_opts_str .= "'" . urlencode(esc_js($value)) . "',";
1880 $opt_means .= "'" . esc_js($optValues['means']) . "',";
1881 $opt_esse .= "'" . esc_js($optValues['essential']) . "',";
1882 }
1883 $mes_opts_str = rtrim($mes_opts_str, ',');
1884 $key_opts_str = rtrim($key_opts_str, ',');
1885 $opt_means = rtrim($opt_means, ',');
1886 $opt_esse = rtrim($opt_esse, ',');
1887 }
1888 //$itemRestriction = get_post_custom_values('_itemRestriction', $item->ID);
1889 $itemRestriction = get_post_meta($item->ID, '_itemRestriction', true);
1890
1891 ?>
1892 <script type='text/javascript'>
1893 /* <![CDATA[ */
1894 uscesL10n = {
1895 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
1896 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>",
1897 'post_id': "<?php echo $item->ID; ?>",
1898 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
1899 'is_cart_row': <?php echo ( (0 < $this->cart->num_row()) ? 'true' : 'false'); ?>,
1900 'opt_esse': new Array( <?php echo $opt_esse; ?> ),
1901 'opt_means': new Array( <?php echo $opt_means; ?> ),
1902 'mes_opts': new Array( <?php echo $mes_opts_str; ?> ),
1903 'key_opts': new Array( <?php echo $key_opts_str; ?> ),
1904 'previous_url': "<?php echo $this->previous_url; ?>",
1905 'itemRestriction': "<?php echo $itemRestriction; ?>"
1906 }
1907 /* ]]> */
1908 </script>
1909 <script type='text/javascript' src='<?php echo $javascript_url; ?>'></script>
1910 <?php endif; ?>
1911 <?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)) ) : ?>
1912 <?php if( $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || (is_singular() && 'item' == $item->post_mime_type)) ) : ?>
1913 <script type='text/javascript'>
1914 (function($) {
1915 uscesCart = {
1916 intoCart : function (post_id, sku) {
1917
1918 var zaikonum = document.getElementById("zaikonum["+post_id+"]["+sku+"]").value;
1919 var zaiko = document.getElementById("zaiko["+post_id+"]["+sku+"]").value;
1920 if( (zaiko != '0' && zaiko != '1') || parseInt(zaikonum) == 0 ){
1921 alert('<?php _e('temporaly out of stock now', 'usces'); ?>');
1922 return false;
1923 }
1924
1925 var mes = '';
1926 if(document.getElementById("quant["+post_id+"]["+sku+"]")){
1927 var quant = document.getElementById("quant["+post_id+"]["+sku+"]").value;
1928 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
1929 mes += "<?php _e('enter the correct amount', 'usces'); ?>\n";
1930 }
1931 var checknum = '';
1932 var checkmode = '';
1933 if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
1934 checknum = uscesL10n.itemRestriction;
1935 checkmode ='rest';
1936 } else if( parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
1937 checknum = zaikonum;
1938 checkmode ='zaiko';
1939 } else if( (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) {
1940 checknum = zaikonum;
1941 checkmode ='zaiko';
1942 } else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum == '' ) {
1943 checknum = uscesL10n.itemRestriction;
1944 checkmode ='rest';
1945 }
1946
1947
1948 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
1949 if(checkmode == 'rest'){
1950 mes += <?php _e("'This article is limited by '+checknum+' at a time.'", 'usces'); ?>+"\n";
1951 }else{
1952 mes += <?php _e("'Stock is remainder '+checknum+'.'", 'usces'); ?>+"\n";
1953 }
1954 }
1955 }
1956 for(i=0; i<uscesL10n.key_opts.length; i++){
1957 var skuob = document.getElementById("itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]");
1958 if( uscesL10n.opt_esse[i] == '1' ){
1959
1960 if( uscesL10n.opt_means[i] < 2 && skuob.value == '#NONE#' ){
1961 mes += uscesL10n.mes_opts[i]+"\n";
1962 }else if( uscesL10n.opt_means[i] >= 2 && skuob.value == '' ){
1963 mes += uscesL10n.mes_opts[i]+"\n";
1964 }
1965 }
1966 }
1967
1968 <?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); //Unavailable ?>
1969 <?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?>
1970
1971 if( mes != '' ){
1972 alert( mes );
1973 return false;
1974 }else{
1975 <?php echo apply_filters('usces_filter_js_intoCart', "return true;\n", $item->ID, NULL); ?>
1976 }
1977 },
1978
1979 upCart : function () {
1980
1981 var zaikoob = $("input[name*='zaikonum']");
1982 var quantob = $("input[name*='quant']");
1983 var postidob = $("input[name*='itempostid']");
1984 var skuob = $("input[name*='itemsku']");
1985
1986 var zaikonum = '';
1987 var zaiko = '';
1988 var quant = '';
1989 var mes = '';
1990 var checknum = '';
1991 var post_id = '';
1992 var sku = '';
1993 var itemRestriction = '';
1994
1995 var ct = zaikoob.length;
1996 for(var i=0; i< ct; i++){
1997 post_id = postidob[i].value;
1998 sku = skuob[i].value;
1999 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2000 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2001
2002 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2003 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2004 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2005 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2006 }
2007 var checknum = '';
2008 var checkmode = '';
2009 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2010 checknum = itemRestriction;
2011 checkmode ='rest';
2012 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2013 checknum = zaikonum;
2014 checkmode ='zaiko';
2015 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2016 checknum = zaikonum;
2017 checkmode ='zaiko';
2018 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2019 checknum = itemRestriction;
2020 checkmode ='rest';
2021 }
2022 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2023 if(checkmode == 'rest'){
2024 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2025 }else{
2026 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2027 }
2028 }
2029 }
2030 }
2031
2032 <?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); //Unavailable ?>
2033 <?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?>
2034
2035 if( mes != '' ){
2036 alert( mes );
2037 return false;
2038 }else{
2039 <?php echo apply_filters('usces_filter_js_upCart', "return true;\n", $item->ID, NULL); ?>
2040 }
2041 },
2042
2043 cartNext : function () {
2044
2045 var zaikoob = $("input[name*='zaikonum']");
2046 var quantob = $("input[name*='quant']");
2047 var postidob = $("input[name*='itempostid']");
2048 var skuob = $("input[name*='itemsku']");
2049
2050 var zaikonum = '';
2051 var zaiko = '';
2052 var quant = '';
2053 var mes = '';
2054 var checknum = '';
2055 var post_id = '';
2056 var sku = '';
2057 var itemRestriction = '';
2058
2059 var ct = zaikoob.length;
2060 for(var i=0; i< ct; i++){
2061 post_id = postidob[i].value;
2062 sku = skuob[i].value;
2063 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2064 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2065
2066 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2067 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2068 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2069 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2070 }
2071 var checknum = '';
2072 var checkmode = '';
2073 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2074 checknum = itemRestriction;
2075 checkmode ='rest';
2076 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2077 checknum = zaikonum;
2078 checkmode ='zaiko';
2079 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2080 checknum = zaikonum;
2081 checkmode ='zaiko';
2082 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2083 checknum = itemRestriction;
2084 checkmode ='rest';
2085 }
2086
2087 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2088 if(checkmode == 'rest'){
2089 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2090 }else{
2091 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2092 }
2093 }
2094 }
2095 }
2096 if( mes != '' ){
2097 alert( mes );
2098 return false;
2099 }else{
2100 return true;
2101 }
2102 },
2103
2104 previousCart : function () {
2105 location.href = uscesL10n.previous_url;
2106 },
2107
2108 settings: {
2109 url: uscesL10n.ajaxurl,
2110 type: 'POST',
2111 cache: false,
2112 success: function(data, dataType){
2113 //$("tbody#item-opt-list").html( data );
2114 },
2115 error: function(msg){
2116 //$("#ajax-response").html(msg);
2117 }
2118 },
2119
2120 changeStates : function( country ) {
2121 var s = this.settings;
2122 s.data = "action=change_states_ajax&country=" + country;
2123 s.success = function(data, dataType){
2124 if( 'error' == data ){
2125 alert('error');
2126 }else{
2127 $("select#pref").html( data );
2128 }
2129 };
2130 s.error = function(msg){
2131 alert("error");
2132 };
2133 $.ajax( s );
2134 return false;
2135 },
2136
2137 isNum : function (num) {
2138 if (num.match(/[^0-9]/g)) {
2139 return false;
2140 }
2141 return true;
2142 },
2143 purchase : 0
2144 };
2145 $("#country").change(function () {
2146 var country = $("#country option:selected").val();
2147 $("#newcharging_type option:selected").val()
2148 uscesCart.changeStates( country );
2149 });
2150 $("#purchase_form").submit(function () {
2151 if( 0 == uscesCart.purchase ){
2152 uscesCart.purchase = 1;
2153 return true;
2154 }else{
2155 $("#purchase_button").attr("disabled", "disabled");
2156 $("#back_button").attr("disabled", "disabled");
2157 return false;
2158 }
2159 });
2160
2161 })(jQuery);
2162 </script>
2163 <?php endif; ?>
2164 <?php
2165 usces_states_form_js();
2166 }
2167
2168 function admin_head() {
2169 global $wp_version;
2170 $payments_str = '';
2171 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
2172 foreach ( (array)$payments as $id => $array ) {
2173 $payments_str .= "'" . esc_js($array['name']) . "': '" . esc_js($array['settlement']) . "', ";
2174 }
2175 $payments_str .= "'" . __('Transfer (prepayment)', 'usces') . "': 'transferAdvance', ";
2176 $payments_str .= "'" . __('Transfer (postpay)', 'usces') . "': 'transferDeferred', ";
2177 $payments_str .= "'" . __('COD', 'usces') . "': 'COD', ";
2178 $payments_str = rtrim($payments_str, ', ');
2179 $wcex_str = '';
2180 $wcex = usces_get_wcex();
2181 foreach ( (array)$wcex as $key => $values ) {
2182 $wcex_str .= "'" . esc_js($key) . "-" . esc_js($values['version']) . "', ";
2183 }
2184 $wcex_str = rtrim($wcex_str, ', ');
2185 if ( version_compare($wp_version, '3.4', '>=') ){
2186 $theme_ob = wp_get_theme();
2187 $theme['Name'] = esc_js($theme_ob->get('Name'));
2188 $theme['Version'] = esc_js($theme_ob->get('Version'));
2189 }else{
2190 $theme = get_theme_data( get_stylesheet_directory().'/style.css' );//20120618ysk
2191 }
2192 ?>
2193
2194 <link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" />
2195 <script type='text/javascript'>
2196 /* <![CDATA[ */
2197 uscesL10n = {
2198 'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php",
2199 'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>",
2200 'version': "<?php echo USCES_VERSION; ?>",
2201 'wcid': "<?php echo get_option('usces_wcid'); ?>",
2202 'locale': '<?php echo get_locale(); ?>',
2203 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
2204 'purchase_limit': "<?php echo $this->options['purchase_limit']; ?>",
2205 'point_rate': "<?php echo $this->options['point_rate']; ?>",
2206 'shipping_rule': "<?php echo $this->options['shipping_rule']; ?>",
2207 'theme': "<?php echo $theme['Name'] . '-' . $theme['Version']; ?>",
2208 'wcex': new Array( <?php echo $wcex_str; ?> ),
2209 'now_loading': "<?php _e('now loading', 'usces'); ?>"
2210 };
2211 uscesPayments = {<?php echo $payments_str; ?>};
2212 /* ]]> */
2213 </script>
2214 <script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js'></script>
2215 <?php
2216 if($this->action_status == 'edit' || $this->action_status == 'editpost'){
2217 ?>
2218 <link rel='stylesheet' href='<?php echo get_option('siteurl'); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' />
2219 <?php
2220 }
2221 if( isset($_REQUEST['page']) ){
2222 switch( $_REQUEST['page'] ){
2223 case 'usces_initial':
2224 ?>
2225 <script type='text/javascript'>
2226 /* <![CDATA[ */
2227 usces_ini = {
2228 'cod_type': "<?php if( 'change' == $this->options['cod_type'] ) {echo 'change';}else{echo 'fix';} ?>",
2229 'cod_type_fix': "<?php echo esc_js(__('Fixation C.O.D.', 'usces')); ?>",
2230 'cod_type_change': "<?php echo esc_js(__('Variable C.O.D.', 'usces')); ?>",
2231 'cod_unit': "<?php echo esc_js(__('dollars', 'usces')); ?>",
2232 'cod_failure': "<?php echo esc_js(__('failure in update', 'usces')); ?>",
2233 'cod_updated': "<?php echo esc_js(__('options are updated', 'usces')); ?>",
2234 'cod_limit': "<?php echo esc_js(__('A value of the amount of upper limit is dirty.', 'usces')); ?>"
2235 };
2236 /* ]]> */
2237 </script>
2238 <?php
2239 break;
2240 case 'usces_itemnew':
2241 case 'usces_itemedit':
2242 ?>
2243 <style type="text/css">
2244 <!--
2245 #usces_mess {
2246 color: #FF0000;
2247 font-weight: bold;
2248 }
2249 -->
2250 </style>
2251 <?php
2252 break;
2253 }
2254 }
2255 ?>
2256 <?php
2257 if( is_admin() && ( (isset($_GET['order_action']) && 'newpost' == $_GET['order_action'])
2258 || (isset($_GET['page']) && 'usces_ordernew' == $_GET['page'])
2259 || (isset($_GET['order_action']) && 'edit' == $_GET['order_action'])
2260 || (isset($_GET['order_action']) && 'editpost' == $_GET['order_action'])
2261 || (isset($_GET['member_action']) && 'edit' == $_GET['member_action'])
2262 || (isset($_GET['member_action']) && 'editpost' == $_GET['member_action'])) ) :
2263 switch( $_GET['page'] ){
2264 case 'usces_ordernew':
2265 case 'usces_orderlist':
2266 $admin_page = 'order';
2267 break;
2268 case 'usces_memberlist':
2269 $admin_page = 'member';
2270 break;
2271 }
2272 ?>
2273 <script type='text/javascript'>
2274 jQuery(function($) {
2275 uscesForm = {
2276 settings: {
2277 url: uscesL10n.requestFile,
2278 type: 'POST',
2279 cache: false,
2280 success: function(data, dataType){
2281 //$("tbody#item-opt-list").html( data );
2282 },
2283 error: function(msg){
2284 //$("#ajax-response").html(msg);
2285 }
2286 },
2287
2288 changeStates : function( country, type ) {
2289 var s = this.settings;
2290 s.data = "action=change_states_ajax&country=" + country;
2291 s.success = function(data, dataType){
2292 if( 'error' == data ){
2293 alert('error');
2294 }else{
2295 $("select#" + type + "_pref").html( data );
2296 if( customercountry == country && 'customer' == type ){
2297 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2298 }else if( deliverycountry == country && 'delivery' == type ){
2299 $("#" + type + "_pref").attr({selectedIndex:deliverystate});
2300 }else if( customercountry == country && 'member' == type ){
2301 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2302 }
2303 }
2304 };
2305 s.error = function(msg){
2306 alert("error");
2307 };
2308 $.ajax( s );
2309 return false;
2310 },
2311
2312 isNum : function (num) {
2313 if (num.match(/[^0-9]/g)) {
2314 return false;
2315 }
2316 return true;
2317 }
2318 };
2319 <?php
2320 if( 'order' == $admin_page ){
2321 ?>
2322 if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) {
2323 var customerstate = $("#customer_pref").get(0).selectedIndex;
2324 var customercountry = $("#customer_country").val();
2325 var deliverystate = $("#delivery_pref").get(0).selectedIndex;
2326 var deliverycountry = $("#delivery_country").val();
2327
2328 $("#customer_country").change(function () {
2329 var country = $("#customer_country option:selected").val();
2330 uscesForm.changeStates( country, 'customer' );
2331 });
2332 $("#delivery_country").change(function () {
2333 var country = $("#delivery_country option:selected").val();
2334 uscesForm.changeStates( country, 'delivery' );
2335 });
2336 }
2337 <?php
2338 }else if( 'member' == $admin_page ){
2339 ?>
2340 if( undefined != $("#member_pref").get(0) ) {
2341 var customerstate = $("#member_pref").get(0).selectedIndex;
2342 var customercountry = $("#member_country").val();
2343 var deliverystate = '';
2344 var deliverycountry = '';
2345
2346 $("#member_country").change(function () {
2347 var country = $("#member_country option:selected").val();
2348 uscesForm.changeStates( country, 'member' );
2349 });
2350 }
2351 <?php
2352 }
2353 ?>
2354 });
2355 </script>
2356 <?php
2357 endif;
2358 }
2359
2360 function main() {
2361 global $wpdb, $wp_locale, $wp_version, $post_ID;
2362 global $wp_query, $usces_action, $post, $action, $editing;
2363
2364 update_option('usces_shipping_rule', apply_filters('usces_filter_shipping_rule', get_option('usces_shipping_rule')));
2365 $this->shipping_rule = get_option('usces_shipping_rule');
2366
2367 // $_wp_http_referer = isset($_POST['_wp_http_referer']) ? $_POST['_wp_http_referer'] : 'a';
2368 // if( isset($_POST) && 1 !== preg_match('/(?:plugin|theme)-editor\.php/', $_wp_http_referer) ){
2369 // $_POST = $this->stripslashes_deep_post($_POST);
2370 // }
2371
2372 if( !is_admin() ){
2373 $this->usces_cookie();
2374 }
2375 $this->make_url();
2376
2377 //usces_log('HTTP_REFERER : '.$_SERVER['HTTP_REFERER'], 'acting_transaction.log');
2378 //usces_log('REQUEST_URI : '.$_SERVER['REQUEST_URI'], 'acting_transaction.log');
2379
2380 do_action('usces_main');
2381 $this->update_table();
2382
2383
2384 // if( 'customer' == $this->page ){
2385 // header("Pragma: private");
2386 // header("Cache-Control: private");
2387 // }else{
2388 // header("Pragma: no-cache");
2389 // header("Cache-Control: no-cache");
2390 // }
2391
2392
2393 //var_dump($_REQUEST);
2394 require_once(USCES_PLUGIN_DIR . '/classes/cart.class.php');
2395 $this->cart = new usces_cart();
2396
2397 do_action('usces_after_cart_instant');
2398
2399 if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate' ){
2400 $post_id = (int)$_GET['post'];
2401 $new_id = usces_item_dupricate($post_id);
2402 $ref = isset($_REQUEST['usces_referer']) ? urlencode($_REQUEST['usces_referer']) : '';
2403 $url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref;
2404 wp_redirect($url);
2405 exit;
2406 }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'itemcsv' ){
2407 $filename = usces_item_uploadcsv();
2408 $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&regfile='.$filename;
2409 wp_redirect($url);
2410 exit;
2411 }
2412 //20110208ysk start
2413 if('on' == $this->options['acting_settings']['paypal']['ec_activate']) {
2414 require_once(USCES_PLUGIN_DIR . '/classes/paymentPaypal.class.php');
2415 $this->paypal = new usces_paypal();
2416 }
2417 //20110208ysk end
2418
2419 $this->ad_controller();
2420 //$this->controller();
2421
2422
2423
2424 if( isset($_GET['page']) && $_GET['page'] == 'usces_itemnew'){
2425 $itemnew = 'new';
2426 }else{
2427 $itemnew = '';
2428 }
2429
2430 wp_enqueue_script('jquery');
2431
2432 if( is_admin() && isset($_REQUEST['page']) && ((isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') || $itemnew == 'new' || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'editpost'))) {
2433
2434 if(isset($_REQUEST['action']) && $_REQUEST['action'] != 'editpost' && $itemnew == 'new'){
2435 if ( version_compare($wp_version, '3.0-beta', '>') ){
2436 if ( !isset($_GET['post_type']) )
2437 $post_type = 'post';
2438 elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
2439 $post_type = $_GET['post_type'];
2440 else
2441 wp_die( __('Invalid post type') );
2442 $post_type_object = get_post_type_object($post_type);
2443 $editing = true;
2444 // if ( current_user_can($post_type_object->edit_type_cap) ) {
2445 $post = $this->get_default_post_to_edit30( $post_type, true );
2446 $post_ID = $post->ID;
2447 // }
2448
2449 }else{
2450 $post = $this->get_default_post_to_edit();
2451 }
2452 }else{
2453 if ( version_compare($wp_version, '3.0-beta', '>') ){
2454 if ( isset($_GET['post']) )
2455 $post_id = (int) $_GET['post'];
2456 elseif ( isset($_POST['post_ID']) )
2457 $post_id = (int) $_POST['post_ID'];
2458 else
2459 $post_id = 0;
2460 $post_ID = $post_id;
2461 $post = null;
2462 $post_type_object = null;
2463 $post_type = null;
2464 if ( $post_id ) {
2465 $post = get_post($post_id);
2466 if ( $post ) {
2467 $post_type_object = get_post_type_object($post->post_type);
2468 if ( $post_type_object ) {
2469 $post_type = $post->post_type;
2470 $current_screen->post_type = $post->post_type;
2471 $current_screen->id = $current_screen->post_type;
2472 }
2473 }
2474 } elseif ( isset($_POST['post_type']) ) {
2475 $post_type_object = get_post_type_object($_POST['post_type']);
2476 if ( $post_type_object ) {
2477 $post_type = $post_type_object->name;
2478 $current_screen->post_type = $post_type;
2479 $current_screen->id = $current_screen->post_type;
2480 }
2481 }
2482
2483
2484 // $post = get_post( $post_id, OBJECT, 'edit' );
2485 // if ( $post->post_type == 'page' )
2486 // $post->page_template = get_post_meta( $id, '_wp_page_template', true );
2487
2488 }else{
2489 if(isset($_GET['post'])){
2490 $post_ID = (int) $_GET['post'];
2491 $post = get_post($post_ID);
2492 }else{
2493 $post_ID = isset($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : 0;
2494 if(!empty($post_ID))
2495 $post = get_post($post_ID);
2496 }
2497 }
2498 // global $wp_query, $usces_action, $post;
2499
2500 }
2501 $editing = true;
2502 wp_enqueue_script('autosave');
2503 wp_enqueue_script('post');
2504 //if ( user_can_richedit() )
2505 //wp_enqueue_script('editor');
2506 add_thickbox();
2507 wp_enqueue_script('media-upload');
2508 wp_enqueue_script('word-count');
2509 wp_enqueue_script( 'admin-comments' );
2510
2511 if ( version_compare($wp_version, '3.3', '<') )
2512 add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
2513 wp_enqueue_script('quicktags');
2514
2515 }
2516
2517
2518 if( is_admin() && isset($_REQUEST['page']) ){
2519
2520 wp_enqueue_script('jquery-color');
2521
2522 switch( $_REQUEST['page'] ){
2523
2524 case 'usces_initial':
2525 $js = USCES_FRONT_PLUGIN_URL.'/js/usces_initial.js';
2526 wp_enqueue_script('usces_initial.js', $js, array('jquery-ui-dialog', 'jquery-ui-sortable'));
2527 //wp_enqueue_script('jquery-ui-sortable');
2528 break;
2529
2530 case 'usces_settlement':
2531 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2532 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2533 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0' );
2534 // $item_list_layoutUrl = USCES_FRONT_PLUGIN_URL.'/js/usces_dumy.js';
2535 // wp_enqueue_script('usces_dumy', $item_list_layoutUrl, array('jquery-ui-tabs'), '1.0' );
2536 break;
2537 //20100809ysk start
2538 case 'usces_cart':
2539 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2540 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2541 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2542 break;
2543 //20100809ysk end
2544 //20100818ysk start
2545 case 'usces_member':
2546 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2547 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2548 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2549 break;
2550 //20100818ysk end
2551 //20100908ysk start
2552 case 'usces_orderlist':
2553 case 'usces_ordernew':
2554 wp_enqueue_script('jquery-ui-dialog');
2555 break;
2556 case 'usces_memberlist':
2557 wp_enqueue_script('jquery-ui-dialog');
2558 break;
2559 //20100908ysk end
2560 //20101111ysk start
2561 case 'usces_itemnew':
2562 wp_enqueue_script('jquery-ui-sortable');
2563 break;
2564 case 'usces_itemedit':
2565 if( isset($_REQUEST['action']) && 'upload_register' == $_REQUEST['action'] ){
2566 @ob_end_clean();
2567 ob_start();
2568 }else{
2569 wp_enqueue_script('jquery-ui-sortable');
2570 wp_enqueue_script('jquery-ui-dialog');
2571 }
2572 break;
2573 //20101111ysk end
2574 //20101208ysk start
2575 case 'usces_delivery':
2576 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2577 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2578 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2579 break;
2580 //20101208ysk end
2581 //20110331ysk start
2582 case 'usces_system':
2583 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2584 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2585 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2586 break;
2587 //20110331ysk end
2588 }
2589 }
2590
2591 if( isset($_REQUEST['order_action']) && $_REQUEST['order_action'] == 'pdfout' ){
2592 $this->get_current_member();
2593 $mid = $this->current_member['id'];
2594 $oid = $_GET['order_id'];
2595 if( !is_user_logged_in() && !$this->is_order($mid, $oid) )
2596 die('No permission');
2597 require_once( apply_filters('usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php') );
2598 }
2599
2600 do_action( 'usces_after_main' );
2601 }
2602
2603 function stripslashes_deep_post( $array ){
2604 $res = array();
2605 foreach( $array as $key => $value ){
2606 $key = stripslashes($key);
2607 if( is_array($value) ){
2608 $value = $this->stripslashes_deep_post( $value );
2609 }else{
2610 $value = stripslashes($value);
2611 }
2612 $res[$key] = $value;
2613 }
2614 return $res;
2615 }
2616
2617 function make_url(){
2618
2619 $permalink_structure = get_option('permalink_structure');
2620 //usces_log('use_ssl : '.$this->use_ssl, 'acting_transaction.log');
2621 if($this->use_ssl) {
2622 if( $permalink_structure ){
2623 $this->delim = '&';
2624 $home_perse = parse_url(get_option('home'));
2625 $home_perse_path = isset($home_perse['path']) ? $home_perse['path'] : '';
2626 $home_path = $home_perse['host'].$home_perse_path;
2627 $ssl_perse = parse_url($this->options['ssl_url']);
2628 $ssl_perse_path = isset($ssl_perse['path']) ? $ssl_perse['path'] : '';
2629 $ssl_path = $ssl_perse['host'].$ssl_perse_path;
2630 if( $home_perse_path != $ssl_perse_path ){
2631 if( ! defined('USCES_CUSTOMER_URL') )
2632 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2633 if( ! defined('USCES_CART_URL') )
2634 define('USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2635 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2636 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2637 if( ! defined('USCES_NEWMEMBER_URL') )
2638 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2639 if( ! defined('USCES_LOGIN_URL') )
2640 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2641 if( ! defined('USCES_LOGOUT_URL') )
2642 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2643 if( ! defined('USCES_MEMBER_URL') )
2644 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2645 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2646 if( ! defined('USCES_INQUIRY_URL') )
2647 define('USCES_INQUIRY_URL', $inquiry_url);
2648 if( ! defined('USCES_CART_NONSESSION_URL') )
2649 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER);
2650 //20110208ysk start
2651 //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));
2652 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2653 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2654 //20110208ysk end
2655 }else{
2656 $ssl_plink_cart = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_CART_NUMBER) ));
2657 $ssl_plink_member = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_MEMBER_NUMBER) ));
2658 if( ! defined('USCES_CUSTOMER_URL') )
2659 define('USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1');
2660 if( ! defined('USCES_CART_URL') )
2661 define('USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid());
2662 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2663 define('USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2664 if( ! defined('USCES_NEWMEMBER_URL') )
2665 define('USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid(). '&page=newmember');
2666 if( ! defined('USCES_LOGIN_URL') )
2667 define('USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=login');
2668 if( ! defined('USCES_LOGOUT_URL') )
2669 define('USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=logout');
2670 if( ! defined('USCES_MEMBER_URL') )
2671 define('USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid());
2672 if( !isset($this->options['inquiry_id']) || !( (int)$this->options['inquiry_id'] ) ){
2673 $inquiry_url = get_home_url();
2674 }else{
2675 $ssl_plink_inquiry = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link($this->options['inquiry_id']) ));
2676 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid();
2677 }
2678 if( ! defined('USCES_INQUIRY_URL') )
2679 define('USCES_INQUIRY_URL', $inquiry_url);
2680 if( ! defined('USCES_CART_NONSESSION_URL') )
2681 define('USCES_CART_NONSESSION_URL', $ssl_plink_cart);
2682 //20110208ysk start
2683 //define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2684 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2685 define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2686 //20110208ysk end
2687 }
2688 }else{
2689 $this->delim = '&';
2690 if( ! defined('USCES_CUSTOMER_URL') )
2691 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2692 if( ! defined('USCES_CART_URL') )
2693 define('USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2694 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2695 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2696 if( ! defined('USCES_NEWMEMBER_URL') )
2697 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2698 if( ! defined('USCES_LOGIN_URL') )
2699 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2700 if( ! defined('USCES_LOGOUT_URL') )
2701 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2702 if( ! defined('USCES_MEMBER_URL') )
2703 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2704 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2705 if( ! defined('USCES_INQUIRY_URL') )
2706 define('USCES_INQUIRY_URL', $inquiry_url);
2707 if( ! defined('USCES_CART_NONSESSION_URL') )
2708 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER);
2709 //20110208ysk start
2710 //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2711 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2712 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2713 //20110208ysk end
2714 }
2715 if( !is_admin() ){
2716 add_filter('home_url', array($this, 'usces_ssl_page_link'));
2717 add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
2718 add_filter('icon_dir_uri', array($this, 'usces_ssl_icon_dir_uri'));
2719 add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
2720 add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
2721 add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
2722 add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
2723 }
2724 } else {
2725 if( $permalink_structure ){
2726 $this->delim = '?';
2727 if( ! defined('USCES_CUSTOMER_URL') )
2728 define('USCES_CUSTOMER_URL', get_page_link(USCES_CART_NUMBER) . '?customerinfo=1');
2729 if( ! defined('USCES_CART_URL') )
2730 define('USCES_CART_URL', get_page_link(USCES_CART_NUMBER));
2731 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2732 define('USCES_LOSTMEMBERPASSWORD_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=lostmemberpassword');
2733 if( ! defined('USCES_NEWMEMBER_URL') )
2734 define('USCES_NEWMEMBER_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=newmember');
2735 if( ! defined('USCES_LOGIN_URL') )
2736 define('USCES_LOGIN_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=login');
2737 if( ! defined('USCES_LOGOUT_URL') )
2738 define('USCES_LOGOUT_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=logout');
2739 if( ! defined('USCES_MEMBER_URL') )
2740 define('USCES_MEMBER_URL', get_page_link(USCES_MEMBER_NUMBER));
2741 $inquiry_url = ( !isset( $this->options['inquiry_id'] ) || !( (int)$this->options['inquiry_id'] )) ? get_home_url() : get_page_link($this->options['inquiry_id']);
2742 if( ! defined('USCES_INQUIRY_URL') )
2743 define('USCES_INQUIRY_URL', $inquiry_url);
2744 if( ! defined('USCES_CART_NONSESSION_URL') )
2745 define('USCES_CART_NONSESSION_URL', get_page_link(USCES_CART_NUMBER));
2746 //20110208ysk start
2747 //define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2748 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2749 define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2750 //20110208ysk end
2751 }else{
2752 $this->delim = '&';
2753 if( ! defined('USCES_CUSTOMER_URL') )
2754 define('USCES_CUSTOMER_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1');
2755 if( ! defined('USCES_CART_URL') )
2756 define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2757 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2758 define('USCES_LOSTMEMBERPASSWORD_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=lostmemberpassword');
2759 if( ! defined('USCES_NEWMEMBER_URL') )
2760 define('USCES_NEWMEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=newmember');
2761 if( ! defined('USCES_LOGIN_URL') )
2762 define('USCES_LOGIN_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=login');
2763 if( ! defined('USCES_LOGOUT_URL') )
2764 define('USCES_LOGOUT_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2765 if( ! defined('USCES_CART_NONSESSION_URL') )
2766 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2767 if( ! defined('USCES_MEMBER_URL') )
2768 define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
2769 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option('home') . '/?page_id=' . $this->options['inquiry_id'];
2770 if( ! defined('USCES_INQUIRY_URL') )
2771 define('USCES_INQUIRY_URL', $inquiry_url);
2772 if( ! defined('USCES_CART_NONSESSION_URL') )
2773 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2774 //20110208ysk start
2775 //define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2776 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2777 define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2778 //20110208ysk end
2779 }
2780 }
2781 }
2782
2783 function regist_action(){
2784 usces_register_action('inCart', 'post', 'inCart', NULL, 'inCart');
2785 usces_register_action('upButton', 'post', 'upButton', NULL, 'upButton');
2786 usces_register_action('delButton', 'post', 'delButton', NULL, 'delButton');
2787 usces_register_action('backCart', 'post', 'backCart', NULL, 'backCart');
2788 usces_register_action('customerinfo', 'request', 'customerinfo', NULL, 'customerinfo');
2789 usces_register_action('backCustomer', 'post', 'backCustomer', NULL, 'backCustomer');
2790 usces_register_action('customerlogin', 'post', 'customerlogin', NULL, 'customerlogin');
2791 usces_register_action('reganddeliveryinfo', 'post', 'reganddeliveryinfo', NULL, 'reganddeliveryinfo');
2792 usces_register_action('deliveryinfo', 'post', 'deliveryinfo', NULL, 'deliveryinfo');
2793 usces_register_action('backDelivery', 'post', 'backDelivery', NULL, 'backDelivery');
2794 usces_register_action('confirm', 'request', 'confirm', NULL, 'confirm');
2795 usces_register_action('use_point', 'post', 'use_point', NULL, 'use_point');
2796 usces_register_action('backConfirm', 'post', 'backConfirm', NULL, 'backConfirm');
2797 usces_register_action('purchase', 'request', 'purchase', NULL, 'purchase');
2798 usces_register_action('acting_return', 'request', 'acting_return', NULL, 'acting_return');
2799 usces_register_action('settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon');
2800 usces_register_action('inquiry_button', 'post', 'inquiry_button', NULL, 'inquiry_button');
2801 usces_register_action('member_login', 'request', 'member_login', NULL, 'member_login_page');
2802 usces_register_action('regmember', 'request', 'regmember', NULL, 'regmember');
2803 usces_register_action('editmember', 'request', 'editmember', NULL, 'editmember');
2804 usces_register_action('deletemember', 'request', 'deletemember', NULL, 'deletemember');
2805 usces_register_action('page_login', 'get', 'page', 'login', 'member_login_page');
2806 usces_register_action('page_logout', 'get', 'page', 'logout', 'page_logout');
2807 usces_register_action('page_lostmemberpassword', 'get', 'page', 'lostmemberpassword', 'page_lostmemberpassword');
2808 usces_register_action('lostpassword', 'request', 'lostpassword', NULL, 'lostpassword');
2809 usces_register_action('uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword');
2810 usces_register_action('changepassword', 'request', 'changepassword', NULL, 'changepassword_page');
2811 usces_register_action('page_newmember', 'get', 'page', 'newmember', 'page_newmember');
2812 usces_register_action('usces_export', 'post', 'usces_export', NULL, 'usces_export');
2813 usces_register_action('usces_import', 'post', 'usces_import', NULL, 'usces_import');
2814 usces_register_action('page_search_item', 'get', 'page', 'search_item', 'page_search_item');
2815 usces_register_action('front_ajax', 'post', 'usces_ajax_action', NULL, 'front_ajax');
2816 }
2817
2818 function ad_controller(){
2819 global $usces_action;
2820 ksort($usces_action);
2821 //if($this->is_maintenance()){
2822 if($this->is_maintenance() and !is_user_logged_in()){//0000651
2823 $this->maintenance();
2824 }else{
2825 $action_array = array('inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer',
2826 'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point',
2827 'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login',
2828 'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword',
2829 'uscesmode_changepassword', 'changepassword', 'page_newmember', 'usces_export', 'usces_import',
2830 'page_search_item', 'front_ajax');
2831 $flg = 0;
2832 $res = true;
2833 foreach( $usces_action as $handle => $action ){
2834 extract($action);
2835 switch($type){
2836 case 'post':
2837 if( empty($value) ){
2838 if( isset($_POST[$key]) ){
2839 if(in_array($handle, $action_array)){
2840 $res = call_user_func(array($this, $function));
2841 }else{
2842 $res = call_user_func($function);
2843 }
2844 $flg = 1;
2845 }
2846 }else{
2847 if( isset($_POST[$key]) && $_POST[$key] == $value ){
2848 if(in_array($handle, $action_array)){
2849 $res = call_user_func(array($this, $function));
2850 }else{
2851 $res = call_user_func($function);
2852 }
2853 $flg = 1;
2854 }
2855 }
2856 break;
2857 case 'get':
2858 if( empty($value) ){
2859 if( isset($_GET[$key]) ){
2860 if(in_array($handle, $action_array)){
2861 $res = call_user_func(array($this, $function));
2862 }else{
2863 $res = call_user_func($function);
2864 }
2865 $flg = 1;
2866 }
2867 }else{
2868 if( isset($_GET[$key]) && $_GET[$key] == $value ){
2869 if(in_array($handle, $action_array)){
2870 $res = call_user_func(array($this, $function));
2871 }else{
2872 $res = call_user_func($function);
2873 }
2874 $flg = 1;
2875 }
2876 }
2877 break;
2878 case 'request':
2879 if( empty($value) ){
2880 if( isset($_REQUEST[$key]) ){
2881 if(in_array($handle, $action_array)){
2882 $res = call_user_func(array($this, $function));
2883 }else{
2884 $res = call_user_func($function);
2885 }
2886 $flg = 1;
2887 }
2888 }else{
2889 if( isset($_REQUEST[$key]) && $_REQUEST[$key] == $value ){
2890 if(in_array($handle, $action_array)){
2891 $res = call_user_func(array($this, $function));
2892 }else{
2893 $res = call_user_func($function);
2894 }
2895 $flg = 1;
2896 }
2897 }
2898 break;
2899 }
2900 if( ! $res ) break;
2901 }
2902 if( !$flg ) $this->default_page();
2903 }
2904 }
2905
2906 //action function------------------------------------------------------------
2907 function front_ajax(){
2908 switch ($_POST['usces_ajax_action']){
2909 case 'change_states':
2910 change_states_ajax();
2911 break;
2912 }
2913 do_action('usces_front_ajax');
2914 }
2915
2916 function maintenance(){
2917 $this->page = 'maintenance';
2918 add_action('the_post', array($this, 'action_cartFilter'));
2919 }
2920
2921 function inCart(){
2922 global $wp_query;
2923 $this->page = 'cart';
2924 $this->incart_check();
2925 $this->cart->inCart();
2926 add_action('the_post', array($this, 'action_cartFilter'));
2927 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2928 add_action('template_redirect', array($this, 'template_redirect'));
2929 }
2930
2931 function upButton(){
2932 global $wp_query;
2933 $this->page = 'cart';
2934 $this->cart->upCart();
2935 $this->error_message = $this->zaiko_check();
2936 add_action('the_post', array($this, 'action_cartFilter'));
2937 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2938 add_action('template_redirect', array($this, 'template_redirect'));
2939 }
2940
2941 function delButton(){
2942 global $wp_query;
2943 $this->page = 'cart';
2944 $this->cart->del_row();
2945 add_action('the_post', array($this, 'action_cartFilter'));
2946 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2947 add_action('template_redirect', array($this, 'template_redirect'));
2948 }
2949
2950 function backCart(){
2951 global $wp_query;
2952 $this->page = 'cart';
2953 add_action('the_post', array($this, 'action_cartFilter'));
2954 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2955 add_action('template_redirect', array($this, 'template_redirect'));
2956 }
2957
2958 function customerinfo(){
2959 global $wp_query;
2960 if( false === $this->cart->num_row() ){
2961 header('location: ' . get_option('home'));
2962 exit;
2963 }
2964 do_action( 'usces_action_customerinfo' );
2965 $this->cart->entry();
2966 $this->error_message = $this->zaiko_check();
2967 $this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message );
2968 if( WCUtils::is_blank($this->error_message) ){
2969 if($this->is_member_logged_in()){
2970 //20100818ysk start
2971 //$this->page = 'delivery';
2972 $this->error_message = has_custom_customer_field_essential();
2973 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'delivery' : 'customer';
2974 //20100818ysk end
2975 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
2976 }else{
2977 $this->page = 'customer';
2978 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
2979 }
2980 }else{
2981 $this->page = 'cart';
2982 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2983 }
2984 if ( !$this->cart->is_order_condition() ) {
2985 $order_conditions = $this->get_condition();
2986 $this->cart->set_order_condition($order_conditions);
2987 }
2988 add_action('the_post', array($this, 'action_cartFilter'));
2989 add_action('template_redirect', array($this, 'template_redirect'));
2990 }
2991
2992 function backCustomer(){
2993 global $wp_query;
2994 if( false === $this->cart->num_row() ){
2995 header('location: ' . get_option('home'));
2996 exit;
2997 }
2998 $this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' );
2999 add_action('the_post', array($this, 'action_cartFilter'));
3000 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3001 add_action('template_redirect', array($this, 'template_redirect'));
3002 // $this->cart->entry();
3003 // $this->error_message = $this->delivery_check();
3004 // $this->page = ($this->error_message == '') ? 'customer' : 'delivery';
3005 }
3006
3007 function customerlogin(){
3008 global $wp_query;
3009 if( false === $this->cart->num_row() ){
3010 header('location: ' . get_option('home'));
3011 exit;
3012 }
3013 //20100818ysk start
3014 //$this->cart->entry();
3015 //$this->page = ($this->member_login() == 'member') ? 'delivery' : 'customer';
3016 if($this->member_login() == 'member') {
3017 $this->cart->entry();
3018 $this->error_message = has_custom_customer_field_essential();
3019 if( WCUtils::is_blank($this->error_message) ){
3020 $this->page = 'delivery';
3021 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3022 }else{
3023 $this->page = 'customer';
3024 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3025 }
3026 } else {
3027 $this->cart->entry();
3028 $this->page = 'customer';
3029 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3030 }
3031 //20100818ysk end
3032 add_action('the_post', array($this, 'action_cartFilter'));
3033 add_action('template_redirect', array($this, 'template_redirect'));
3034 }
3035
3036 function reganddeliveryinfo(){
3037 global $wp_query;
3038 if( false === $this->cart->num_row() ){
3039 header('location: ' . get_option('home'));
3040 exit;
3041 }
3042 $this->cart->entry();
3043 //20110715ysk start 0000203
3044 //$_POST['member_regmode'] = 'newmemberfromcart';
3045 if(empty($_POST['member_regmode']) or $_POST['member_regmode'] != 'editmemberfromcart') $_POST['member_regmode'] = 'newmemberfromcart';
3046 //20110715ysk end
3047
3048 if( $this->regist_member() == 'newcompletion' ){
3049 $this->page = 'delivery';
3050 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3051 }else{
3052 $this->page = 'customer';
3053 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3054 }
3055 add_action('the_post', array($this, 'action_cartFilter'));
3056 add_action('template_redirect', array($this, 'template_redirect'));
3057 }
3058
3059 function deliveryinfo(){
3060 global $wp_query;
3061 if( false === $this->cart->num_row() ){
3062 header('location: ' . get_option('home'));
3063 exit;
3064 }
3065 $this->cart->entry();
3066 $this->error_message = $this->customer_check();
3067
3068 if( WCUtils::is_blank($this->error_message) ){
3069 $this->page = 'delivery';
3070 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3071 }else{
3072 $this->page = 'customer';
3073 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3074 }
3075 add_action('the_post', array($this, 'action_cartFilter'));
3076 add_action('template_redirect', array($this, 'template_redirect'));
3077 }
3078
3079 function backDelivery(){
3080 global $wp_query;
3081 if( false === $this->cart->num_row() ){
3082 header('location: ' . get_option('home'));
3083 exit;
3084 }
3085 $this->page = 'delivery';
3086 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3087 add_action('the_post', array($this, 'action_cartFilter'));
3088 add_action('template_redirect', array($this, 'template_redirect'));
3089 }
3090
3091 function confirm(){
3092 global $wpdb, $wp_query;
3093 if( false === $this->cart->num_row() ){
3094 header('location: ' . get_option('home'));
3095 exit;
3096 }
3097
3098 $this->cart->entry();
3099 $this->error_message = $this->zaiko_check();
3100 if( $this->error_message != '' ){
3101 $this->page = 'cart';
3102 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3103 add_action('the_post', array($this, 'action_cartFilter'));
3104 add_action('template_redirect', array($this, 'template_redirect'));
3105 return;
3106 }
3107
3108 $this->set_reserve_pre_order_id();
3109 if(isset($_POST['confirm'])){
3110 $this->error_message = $this->delivery_check();
3111 }
3112 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'confirm' : 'delivery';
3113 if( WCUtils::is_blank($this->error_message) ){
3114 //20120919ysk start 0000573
3115 if( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) {
3116 unset( $_SESSION['usces_entry']['order']['usedpoint'] );//20120914ysk 0000566
3117 $member_table = $wpdb->prefix."usces_member";
3118 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID']);
3119 $mem_point = $wpdb->get_var( $query );
3120 $_SESSION['usces_member']['point'] = $mem_point;
3121 }
3122 //20120919ysk end
3123 $this->page = 'confirm';
3124 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3125 }else{
3126 $this->page = 'delivery';
3127 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3128 }
3129 add_action('the_post', array($this, 'action_cartFilter'));
3130 add_action('template_redirect', array($this, 'template_redirect'));
3131 }
3132
3133 function use_point(){
3134 global $wp_query;
3135 $this->cart->entry();
3136 $this->error_message = $this->point_check( $this->cart->get_entry() );
3137 $this->page = 'confirm';
3138 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3139 add_action('the_post', array($this, 'action_cartFilter'));
3140 add_action('template_redirect', array($this, 'template_redirect'));
3141 }
3142
3143 function backConfirm(){
3144 global $wp_query;
3145 if( false === $this->cart->num_row() ){
3146 header('location: ' . get_option('home'));
3147 exit;
3148 }
3149 $this->page = 'confirm';
3150 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3151 add_action('the_post', array($this, 'action_cartFilter'));
3152 add_action('template_redirect', array($this, 'template_redirect'));
3153 }
3154
3155 function purchase(){
3156 global $wp_query;
3157 if( false === $this->cart->num_row() ){
3158 header('location: ' . get_option('home'));
3159 exit;
3160 }
3161
3162 if( !apply_filters('usces_purchase_check', true) ) return;
3163
3164 do_action('usces_purchase_validate');
3165 $entry = $this->cart->get_entry();
3166 $this->error_message = $this->zaiko_check();
3167 if( WCUtils::is_blank($this->error_message) && 0 < $this->cart->num_row()){
3168 $actinc_status = '';
3169 $payments = $this->getPayments( $entry['order']['payment_name'] );
3170 if( substr($payments['settlement'], 0, 6) == 'acting' && $entry['order']['total_full_price'] > 0 ){
3171 $acting_flg = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3172 $query = '';
3173 foreach($_POST as $key => $value){
3174 if($key != 'purchase')
3175 $query .= '&' . $key . '=' . urlencode(maybe_serialize($value));
3176 }
3177 $actinc_status = $this->acting_processing($acting_flg, $query);
3178 }
3179
3180 if($actinc_status == 'error'){
3181 $this->page = 'error';
3182 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3183 }else{
3184 $res = $this->order_processing();
3185 if( 'ordercompletion' == $res ){
3186 $this->page = 'ordercompletion';
3187 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3188 }else{
3189 $this->page = 'error';
3190 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3191 }
3192 }
3193 }else{
3194 $this->page = 'cart';
3195 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3196 }
3197 add_action('the_post', array($this, 'action_cartFilter'));
3198 add_action('template_redirect', array($this, 'template_redirect'));
3199 }
3200
3201 function acting_return(){
3202 global $wp_query;
3203 $entry = $this->cart->get_entry();
3204
3205 //20110208ysk start
3206 /* if( 'paypal_ipn' == $_REQUEST['acting_return'] ){
3207 usces_log('paypal_ipn in ', 'acting_transaction.log');
3208 require_once($this->options['settlement_path'] . 'paypal.php');
3209 $ipn_res = paypal_ipn_check($usces_paypal_url);
3210 if( $ipn_res[0] === true ){
3211 $res = $this->order_processing( $ipn_res );
3212 if( 'ordercompletion' == $res ){
3213 $this->cart->crear_cart();
3214 }else{
3215 usces_log('paypal_ipn regorder error (acting_return) : '.print_r($entry, true), 'acting_transaction.log');
3216 }
3217 }
3218 exit;
3219 }*/
3220 //20110208ysk end
3221 if( false === $this->cart->num_row() && ('paypal' != $_GET['acting'] && 1 !== (int)$_GET['acting_return']) ){
3222 header('location: ' . get_option('home'));
3223 exit;
3224 }
3225
3226 $this->payment_results = usces_check_acting_return();
3227
3228 if( isset($this->payment_results[0]) && $this->payment_results[0] === 'duplicate' ){
3229
3230 header('location: ' . get_option('home'));
3231 exit;
3232
3233 }else if( isset($this->payment_results[0]) && $this->payment_results[0] ){//result OK
3234
3235 if( ! $this->payment_results['reg_order'] ){//without Registration Order
3236 $this->page = 'ordercompletion';
3237 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3238
3239 }else{
3240 $res = $this->order_processing( $this->payment_results );
3241
3242 if( 'ordercompletion' == $res ){
3243 if( isset($_REQUEST['wctid']) ){
3244 usces_ordered_acting_data($_REQUEST['wctid']);
3245 }
3246 $this->page = 'ordercompletion';
3247 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3248 }else{
3249 $this->page = 'error';
3250 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3251 }
3252 }
3253
3254 }else{//result NG
3255 $this->page = 'error';
3256 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3257 }
3258
3259 add_action('the_post', array($this, 'action_cartFilter'));
3260 add_action('template_redirect', array($this, 'template_redirect'));
3261 }
3262
3263 function settlement_epsilon(){
3264 global $wp_query;
3265 require_once($this->options['settlement_path'] . 'epsilon.php');
3266 }
3267
3268 function inquiry_button(){
3269 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']) ){
3270 $res = $this->inquiry_processing();
3271 }else{
3272 $res = 'deficiency';
3273 }
3274
3275 $this->page = $res;
3276 }
3277
3278 function member_login_page(){
3279 global $wp_query;
3280 $res = $this->member_login();
3281 if( 'member' == $res ){
3282 $this->page = 'member';
3283 do_action('usces_action_member_logined');
3284 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_member');
3285 }elseif( 'login' == $res ){
3286 $this->page = 'login';
3287 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_login');
3288 }
3289 add_action('the_post', array($this, 'action_memberFilter'));
3290 add_action('template_redirect', array($this, 'template_redirect'));
3291 }
3292
3293 function regmember(){
3294 global $wp_query;
3295 $res = $this->regist_member();
3296 if( 'editmemberform' == $res ){
3297 $this->page = 'editmemberform';
3298 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3299 }elseif( 'newcompletion' == $res ){
3300 $this->page = 'newcompletion';
3301 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3302 }else{
3303 $this->page = $res;
3304 }
3305 add_action('the_post', array($this, 'action_memberFilter'));
3306 add_action('template_redirect', array($this, 'template_redirect'));
3307 }
3308
3309 function editmember(){
3310 global $wp_query;
3311 $res = $this->regist_member();
3312 if( 'editmemberform' == $res ){
3313 $this->page = 'editmemberform';
3314 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3315 }elseif( 'newcompletion' == $res ){
3316 $this->page = 'newcompletion';
3317 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3318 }else{
3319 $this->page = $res;
3320 }
3321 add_action('the_post', array($this, 'action_memberFilter'));
3322 add_action('template_redirect', array($this, 'template_redirect'));
3323 }
3324
3325 function deletemember(){
3326 $res = $this->delete_member();
3327 if( $res ){
3328 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember');
3329 $this->member_logout();
3330 }else{
3331 $this->page = 'editmemberform';
3332 add_action('the_post', array($this, 'action_memberFilter'));
3333 }
3334 add_action('template_redirect', array($this, 'template_redirect'));
3335 }
3336
3337 function page_logout(){
3338 global $wp_query;
3339 $this->member_logout();
3340 add_action('the_post', array($this, 'action_memberFilter'));
3341 add_action('template_redirect', array($this, 'template_redirect'));
3342 }
3343
3344 function page_lostmemberpassword(){
3345 global $wp_query;
3346 $this->page = 'lostmemberpassword';
3347 add_action('the_post', array($this, 'action_memberFilter'));
3348 add_action('template_redirect', array($this, 'template_redirect'));
3349 }
3350
3351 function lostpassword(){
3352 global $wp_query;
3353 $this->error_message = $this->lostpass_mailaddcheck();
3354 if ( $this->error_message != '' ) {
3355 $this->page = 'lostmemberpassword';
3356 } else {
3357 $res = $this->lostmail();
3358 $this->page = $res;//'lostcompletion';
3359 }
3360 add_action('the_post', array($this, 'action_memberFilter'));
3361 add_action('template_redirect', array($this, 'template_redirect'));
3362 }
3363
3364 function uscesmode_changepassword(){
3365 global $wp_query;
3366 $this->page = 'changepassword';
3367 add_action('the_post', array($this, 'action_memberFilter'));
3368 add_action('template_redirect', array($this, 'template_redirect'));
3369 }
3370
3371 function changepassword_page(){
3372 global $wp_query;
3373 $this->error_message = $this->changepass_check();
3374 if ( $this->error_message != '' ) {
3375 $this->page = 'changepassword';
3376 } else {
3377 $res = $this->changepassword();
3378 $this->page = $res;//'changepasscompletion';
3379 }
3380 add_action('the_post', array($this, 'action_memberFilter'));
3381 add_action('template_redirect', array($this, 'template_redirect'));
3382 }
3383
3384 function page_newmember(){
3385
3386 global $wp_query;
3387 $this->page = 'newmemberform';
3388 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform');
3389 add_action('the_post', array($this, 'action_memberFilter'));
3390 add_action('template_redirect', array($this, 'template_redirect'));
3391 }
3392
3393 function usces_export(){
3394 $this->export();
3395 }
3396
3397 function usces_import(){
3398 $this->import();
3399 }
3400
3401 function page_search_item(){
3402 global $wp_query;
3403 $this->page = 'search_item';
3404 //add_action('template_redirect', array($this, 'action_search_item'));
3405 add_action('the_post', array($this, 'action_cartFilter'));
3406 add_action('template_redirect', array($this, 'template_redirect'));
3407 }
3408
3409 function default_page(){
3410 global $wp_query;
3411 add_action('the_post', array($this, 'goDefaultPage'));
3412 add_action('template_redirect', array($this, 'template_redirect'));
3413 }
3414 //--------------------------------------------------------------------------------------
3415
3416
3417 function goDefaultPage(){
3418 global $post;
3419
3420 if( $post->ID == USCES_CART_NUMBER ) {
3421
3422 $this->page = 'cart';
3423 add_filter('the_content', array($this, 'filter_cartContent'),20);
3424
3425 }else if( $post->ID == USCES_MEMBER_NUMBER ) {
3426
3427 $this->page = 'member';
3428 add_filter('the_content', array($this, 'filter_memberContent'),20);
3429
3430 }else if( !is_singular() ) {
3431 $this->page = 'wp_search';
3432 add_filter('the_excerpt', array($this, 'filter_cartContent'),20);
3433 add_filter('the_content', array($this, 'filter_cartContent'),20);
3434
3435 }else{
3436 add_filter('the_content', array(&$this, 'filter_itemPage'));
3437
3438 }
3439 }
3440
3441 function template_redirect () {
3442 global $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode;
3443
3444 if( apply_filters('usces_action_template_redirect', false) ) return;//Deprecated
3445 if( apply_filters('usces_filter_template_redirect', false) ) return;
3446
3447 if( is_single() && 'item' == $post->post_mime_type ) {
3448 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_item_single.php') ){
3449 if( !post_password_required($post) ){
3450 include(get_stylesheet_directory() . '/wc_templates/wc_item_single.php');
3451 exit;
3452 }
3453 }
3454 }elseif( isset($_REQUEST['page']) && ('search_item' == $_REQUEST['page'] || 'usces_search' == $_REQUEST['page']) && $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3455 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_search_page.php') ){
3456 include(get_stylesheet_directory() . '/wc_templates/wc_search_page.php');
3457 exit;
3458 }
3459
3460 }else if( $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3461 switch( $this->page ){
3462 case 'customer':
3463 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php') ){
3464 usces_get_entries();
3465 usces_get_member_regmode();
3466 include(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php');
3467 exit;
3468 }
3469 break;
3470 case 'delivery':
3471 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php') ){
3472 usces_get_entries();
3473 usces_get_carts();
3474 include(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php');
3475 exit;
3476 }
3477 break;
3478 case 'confirm':
3479 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php') ){
3480 usces_get_entries();
3481 usces_get_carts();
3482 usces_get_members();
3483 include(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php');
3484 exit;
3485 }
3486 break;
3487 case 'ordercompletion':
3488 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php') ){
3489 usces_get_entries();
3490 usces_get_carts();
3491 include(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php');
3492 exit;
3493 }
3494 break;
3495 case 'error':
3496 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php') ){
3497 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php');
3498 exit;
3499 }
3500 break;
3501 case 'cart':
3502 default:
3503 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php') ){
3504 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php');
3505 exit;
3506 }
3507
3508 }
3509 }else if($this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
3510
3511 }else if( $this->is_member_page($_SERVER['REQUEST_URI']) ){
3512 if($this->options['membersystem_state'] != 'activate') return;
3513
3514 if( $this->is_member_logged_in() ) {
3515 $member_regmode = 'editmemberform';
3516 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php') ){
3517 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php');
3518 exit;
3519 }
3520
3521 } else {
3522
3523 switch( $this->page ){
3524 case 'login':
3525 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3526 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3527 exit;
3528 }
3529 break;
3530 case 'newmemberform':
3531 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php') ){
3532 $member_regmode = 'newmemberform';
3533 include(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php');
3534 exit;
3535 }
3536 break;
3537 case 'lostmemberpassword':
3538 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php') ){
3539 include(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php');
3540 exit;
3541 }
3542 break;
3543 case 'changepassword':
3544 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php') ){
3545 include(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php');
3546 exit;
3547 }
3548 break;
3549 case 'newcompletion':
3550 case 'editcompletion':
3551 case 'lostcompletion':
3552 case 'changepasscompletion':
3553 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php') ){
3554 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php');
3555 exit;
3556 }
3557 break;
3558 default:
3559 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3560 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3561 exit;
3562 }
3563 }
3564 }
3565
3566 }else{
3567 // remove_action('the_post', array(&$this, 'goDefaultPage'));
3568 }
3569 }
3570
3571 function import() {
3572 $res = usces_import_xml();
3573 if ( $res === false ) :
3574 $this->action_status = 'error';
3575 //$this->action_message = __('Import was not completed.', 'usces');
3576 else :
3577 $this->action_status = 'success';
3578 $this->action_message = __('Import is cmpleted', 'usces');
3579 endif;
3580
3581 // require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
3582 }
3583
3584 function export() {
3585 $filename = 'usces.' . substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10) . '.xml';
3586
3587 header('Content-Description: File Transfer');
3588 header("Content-Disposition: attachment; filename=$filename");
3589 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
3590
3591 usces_export_xml();
3592 die();
3593
3594 }
3595
3596
3597 function changepassword() {
3598 global $wpdb;
3599
3600 if ( !isset($_SESSION['usces_lostmail']) ) :
3601 $this->error_message = __('Failed in update due to time-out', 'usces');
3602 return 'login';
3603 else :
3604
3605 $member_table = $wpdb->prefix . "usces_member";
3606
3607 $query = $wpdb->prepare("UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s",
3608 md5(trim($_POST['loginpass1'])), $_SESSION['usces_lostmail']);
3609 $res = $wpdb->query( $query );
3610 //$res = $wpdb->last_results;
3611
3612 if ( $res === false ) :
3613 $this->error_message = __('Error: failure in updating password', 'usces');
3614 return 'login';
3615 else :
3616 return 'changepasscompletion';
3617 endif;
3618
3619 endif;
3620 }
3621
3622 function lostmail() {
3623 $delim = apply_filters( 'usces_filter_delim', $this->delim );
3624
3625 $_SESSION['usces_lostmail'] = trim($_POST['loginmail']);
3626 $id = session_id();
3627 $uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword';
3628 $res = usces_lostmail($uri);
3629 return $res;
3630
3631 }
3632
3633 function regist_member() {
3634 global $wpdb;
3635 $_POST = $this->stripslashes_deep_post($_POST);
3636
3637 $member = $this->get_member();
3638 $mode = $_POST['member_regmode'];
3639 $member_table = $wpdb->prefix . "usces_member";
3640 $member_meta_table = $wpdb->prefix . "usces_member_meta";
3641
3642 //20110715ysk start 0000203
3643 //$error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3644 $error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' or $_POST['member_regmode'] == 'editmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3645 //20110715ysk end
3646
3647 if ( $error_mes != '' ) {
3648
3649 $this->error_message = $error_mes;
3650 return $mode;
3651
3652 } elseif ( $_POST['member_regmode'] == 'editmemberform' ) {
3653
3654 $this->get_current_member();
3655 $mem_id = $this->current_member['id'];
3656 do_action('usces_action_pre_edit_memberdata', $_POST['member'], $mem_id);
3657
3658 //20130802ysk start 0000741
3659 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3660 $id = $wpdb->get_var( $query );
3661 if ( !empty($id) and $id != $mem_id ) {
3662 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3663 return $mode;
3664 }
3665 //20130802ysk end
3666
3667 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3668 $pass = $wpdb->get_var( $query );
3669
3670 $password = ( !empty($_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? md5(trim($_POST['member']['password1'])) : $pass;
3671 $query = $wpdb->prepare("UPDATE $member_table SET
3672 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3673 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3674 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3675 $password,
3676 trim($_POST['member']['name1']),
3677 trim($_POST['member']['name2']),
3678 trim($_POST['member']['name3']),
3679 trim($_POST['member']['name4']),
3680 trim($_POST['member']['zipcode']),
3681 trim($_POST['member']['pref']),
3682 trim($_POST['member']['address1']),
3683 trim($_POST['member']['address2']),
3684 trim($_POST['member']['address3']),
3685 trim($_POST['member']['tel']),
3686 trim($_POST['member']['fax']),
3687 trim($_POST['member']['mailaddress1']),
3688 $mem_id
3689 );
3690 $res = $wpdb->query( $query );
3691
3692 if( $res !== false ){
3693 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $mem_id);
3694 //20100818ysk start
3695 $res = $this->reg_custom_member($mem_id);
3696 //20100818ysk end
3697 do_action('usces_action_edit_memberdata', $_POST['member'], $mem_id);
3698 $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" );
3699 $query = $wpdb->prepare("DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )",
3700 $mem_id
3701 );
3702 $res = $wpdb->query( $query );
3703
3704 $this->get_current_member();
3705 return 'editmemberform';
3706
3707 } else {
3708 $this->error_message = __('Error:failure in update', 'usces');
3709 return $mode;
3710 }
3711
3712 } elseif ( $_POST['member_regmode'] == 'newmemberform' ) {
3713
3714 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3715 $id = $wpdb->get_var( $query );
3716 if ( !empty($id) ) {
3717 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3718 return $mode;
3719 } else {
3720
3721 $point = $this->options['start_point'];
3722 $pass = md5(trim($_POST['member']['password1']));
3723 $query = $wpdb->prepare("INSERT INTO $member_table
3724 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3725 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3726 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3727 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3728 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3729 trim($_POST['member']['mailaddress1']),
3730 $pass,
3731 0,
3732 "",
3733 $point,
3734 trim($_POST['member']['name1']),
3735 trim($_POST['member']['name2']),
3736 trim($_POST['member']['name3']),
3737 trim($_POST['member']['name4']),
3738 trim($_POST['member']['zipcode']),
3739 trim($_POST['member']['pref']),
3740 trim($_POST['member']['address1']),
3741 trim($_POST['member']['address2']),
3742 trim($_POST['member']['address3']),
3743 trim($_POST['member']['tel']),
3744 trim($_POST['member']['fax']),
3745 '',
3746 '',
3747 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3748 '');
3749 $res = $wpdb->query( $query );
3750
3751 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3752 //$this->get_current_member();
3753 if($res !== false) {
3754 $user = $_POST['member'];
3755 $user['ID'] = $wpdb->insert_id;
3756 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $user['ID']);
3757 //20110714ysk start 0000207
3758 //20100818ysk start
3759 //$res = $this->reg_custom_member($wpdb->insert_id);
3760 $res = $this->reg_custom_member($user['ID']);
3761 //20100818ysk end
3762 //20110714ysk end
3763 $mser = usces_send_regmembermail($user);
3764
3765 do_action('usces_action_member_registered', $_POST['member'], $user['ID']);
3766
3767 return 'newcompletion';
3768
3769 } else {
3770 $this->error_message = __('Error:failure in update', 'usces');
3771 return $mode;
3772 }
3773 }
3774
3775 } elseif ( $_POST['member_regmode'] == 'newmemberfromcart' ) {
3776
3777 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1']));
3778 $id = $wpdb->get_var( $query );
3779 if ( !empty($id) ) {
3780 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3781 return $mode;
3782 } else {
3783
3784 $point = $this->options['start_point'];
3785 $pass = md5(trim($_POST['customer']['password1']));
3786 $query = $wpdb->prepare("INSERT INTO $member_table
3787 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3788 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3789 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3790 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3791 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3792 trim($_POST['customer']['mailaddress1']),
3793 $pass,
3794 0,
3795 "",
3796 $point,
3797 trim($_POST['customer']['name1']),
3798 trim($_POST['customer']['name2']),
3799 trim($_POST['customer']['name3']),
3800 trim($_POST['customer']['name4']),
3801 trim($_POST['customer']['zipcode']),
3802 trim($_POST['customer']['pref']),
3803 trim($_POST['customer']['address1']),
3804 trim($_POST['customer']['address2']),
3805 trim($_POST['customer']['address3']),
3806 trim($_POST['customer']['tel']),
3807 trim($_POST['customer']['fax']),
3808 '',
3809 '',
3810 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3811 '');
3812 $res = $wpdb->query( $query );
3813
3814 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3815 //$this->get_current_member();
3816 if($res !== false) {
3817 //20110714ysk start 0000207
3818 $member_id = $wpdb->insert_id;
3819 //$this->set_member_meta_value('customer_country', $_POST['member']['country'], $wpdb->insert_id);
3820 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $member_id);
3821 //20100818ysk start
3822 //$res = $this->reg_custom_member($wpdb->insert_id);
3823 $res = $this->reg_custom_member($member_id);
3824 //20100818ysk end
3825 //20110714ysk end
3826 //usces_send_regmembermail();
3827 do_action('usces_action_member_registered', $_POST['customer'], $member_id);
3828 $user = $_POST['customer'];
3829 $user['ID'] = $member_id;
3830 $mser = usces_send_regmembermail($user);
3831 $_POST['loginmail'] = trim($_POST['customer']['mailaddress1']);
3832 $_POST['loginpass'] = trim($_POST['customer']['password1']);
3833 if( $this->member_login() == 'member' ){
3834 $_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart';
3835 return 'newcompletion';
3836 }
3837
3838 } else {
3839 $this->error_message = __('Error:failure in update', 'usces');
3840 return $mode;
3841 }
3842 }
3843
3844 //20110715ysk start 0000203
3845 } elseif ( $_POST['member_regmode'] == 'editmemberfromcart' ) {
3846
3847 $this->get_current_member();
3848 $mem_id = $this->current_member['id'];
3849 do_action('usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id);
3850
3851 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3852 $pass = $wpdb->get_var( $query );
3853
3854 $password = ( !empty($_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? md5(trim($_POST['customer']['password1'])) : $pass;
3855 $query = $wpdb->prepare("UPDATE $member_table SET
3856 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3857 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3858 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3859 $password,
3860 trim($_POST['customer']['name1']),
3861 trim($_POST['customer']['name2']),
3862 trim($_POST['customer']['name3']),
3863 trim($_POST['customer']['name4']),
3864 trim($_POST['customer']['zipcode']),
3865 trim($_POST['customer']['pref']),
3866 trim($_POST['customer']['address1']),
3867 trim($_POST['customer']['address2']),
3868 trim($_POST['customer']['address3']),
3869 trim($_POST['customer']['tel']),
3870 trim($_POST['customer']['fax']),
3871 trim($_POST['customer']['mailaddress1']),
3872 $mem_id
3873 );
3874 $res = $wpdb->query( $query );
3875 if( $res !== false ){
3876 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $mem_id);
3877 $res = $this->reg_custom_member($mem_id);
3878 do_action('usces_action_edit_memberdata', $_POST['customer'], $mem_id);
3879 unset($_SESSION['usces_member']);
3880 $this->member_just_login(trim($_POST['customer']['mailaddress1']), trim($_POST['customer']['password1']));
3881 return 'newcompletion';
3882
3883 } else {
3884 $this->error_message = __('Error:failure in update', 'usces');
3885 return $mode;
3886 }
3887 //20110715ysk end
3888 }
3889 }
3890
3891 function delete_member() {
3892 if( ! $this->is_member_logged_in() )
3893 return false;
3894 $mem = $this->get_member();
3895 if( ! $mem['ID'] )
3896 return false;
3897
3898 $res = usces_delete_memberdata( $mem['ID'] );
3899 if( $res ) {
3900 usces_send_delmembermail( $mem );
3901 }
3902
3903 return $res;
3904 }
3905
3906 function is_member_logged_in( $id = false ) {
3907 if( $id === false ){
3908 if( !empty($_SESSION['usces_member']['ID']) )
3909 return true;
3910 else
3911 return false;
3912 }else{
3913 if( !empty($_SESSION['usces_member']['ID']) && $_SESSION['usces_member']['ID'] == $id )
3914 return true;
3915 else
3916 return false;
3917 }
3918 }
3919
3920 function is_member($email) {
3921 global $wpdb;
3922
3923 $member_table = $wpdb->prefix . "usces_member";
3924 $query = $wpdb->prepare("SELECT mem_email FROM $member_table WHERE mem_email = %s", $email);
3925 $member = $wpdb->get_row( $query, ARRAY_A );
3926 if ( empty($member) ) {
3927 return false;
3928 }else{
3929 return true;
3930 }
3931 }
3932
3933 function member_login() {
3934 global $wpdb;
3935 $_POST = $this->stripslashes_deep_post($_POST);
3936
3937 $cookie = $this->get_cookie();
3938
3939
3940 if ( isset($cookie['rme']) && $cookie['rme'] == 'forever' && !isset($_POST['rememberme']) && !isset($_POST['loginmail'])) {
3941 $email = $cookie['name'];
3942 $member_table = $wpdb->prefix . "usces_member";
3943
3944 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
3945 $id = $wpdb->get_var( $query );
3946
3947 if ( !$id ) {
3948 $this->current_member['email'] = htmlspecialchars($email);
3949 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
3950 return 'login';
3951 } else {
3952 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s", $email);
3953 $member = $wpdb->get_row( $query, ARRAY_A );
3954 if ( empty($member) ) {
3955 $this->current_member['email'] = htmlspecialchars($email);
3956 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
3957 return 'login';
3958 } else {
3959 $_SESSION['usces_member']['ID'] = $member['ID'];
3960 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
3961 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
3962 $_SESSION['usces_member']['point'] = $member['mem_point'];
3963 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
3964 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
3965 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
3966 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
3967 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
3968 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
3969 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
3970 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
3971 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
3972 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
3973 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
3974 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
3975 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
3976 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
3977 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
3978 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
3979 $_SESSION['usces_member']['status'] = $member['mem_status'];
3980 //20100818ysk start
3981 $this->set_session_custom_member($member['ID']);
3982 //20100818ysk end
3983 $this->get_current_member();
3984
3985 do_action( 'usces_action_after_login' );
3986 return apply_filters( 'usces_filter_member_login', 'member', $member );
3987 }
3988 }
3989 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginmail']) && isset($_POST['loginpass']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
3990 return 'login';
3991 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
3992 $this->current_member['email'] = trim($_POST['loginmail']);
3993 $this->error_message = __('<b>Error:</b> Enter the password.', 'usces');
3994 return 'login';
3995 } else if ( !isset($_POST['loginmail']) ){
3996 return 'login';
3997 } else {
3998 $email = isset($_POST['loginmail']) ? trim($_POST['loginmail']) : '';
3999 $pass = isset($_POST['loginpass']) ? md5(trim($_POST['loginpass'])) : '';
4000 $member_table = $wpdb->prefix . "usces_member";
4001
4002 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
4003 $id = $wpdb->get_var( $query );
4004
4005 if ( !$id ) {
4006 $this->current_member['email'] = htmlspecialchars($email);
4007 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
4008 return 'login';
4009 } else {
4010 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4011 $member = $wpdb->get_row( $query, ARRAY_A );
4012 if ( empty($member) ) {
4013 $this->current_member['email'] = htmlspecialchars($email);
4014 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4015 return 'login';
4016 } else {
4017 $_SESSION['usces_member']['ID'] = $member['ID'];
4018 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4019 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4020 $_SESSION['usces_member']['point'] = $member['mem_point'];
4021 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4022 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4023 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4024 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4025 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4026 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4027 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4028 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4029 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4030 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4031 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4032 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4033 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4034 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4035 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4036 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4037 $_SESSION['usces_member']['status'] = $member['mem_status'];
4038 //20100818ysk start
4039 $this->set_session_custom_member($member['ID']);
4040 //20100818ysk end
4041 $this->get_current_member();
4042
4043 if( isset($_POST['rememberme']) ){
4044 $cookie['name'] = $email;
4045 $cookie['rme'] = 'forever';
4046 $this->set_cookie($cookie);
4047 }else{
4048 $cookie['name'] = '';
4049 $cookie['rme'] = '';
4050 $this->set_cookie($cookie);
4051 }
4052
4053 do_action( 'usces_action_after_login' );
4054 return apply_filters( 'usces_filter_member_login', 'member', $member );
4055 }
4056 }
4057 }
4058 }
4059
4060 function member_just_login($email, $pass) {
4061 global $wpdb;
4062 $pass = md5($pass);
4063 $member_table = $wpdb->prefix . "usces_member";
4064
4065 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4066 $member = $wpdb->get_row( $query, ARRAY_A );
4067 if ( empty($member) ) {
4068 $this->current_member['email'] = htmlspecialchars($email);
4069 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4070 return 'login';
4071 } else {
4072 $_SESSION['usces_member']['ID'] = $member['ID'];
4073 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4074 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4075 $_SESSION['usces_member']['point'] = $member['mem_point'];
4076 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4077 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4078 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4079 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4080 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4081 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4082 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4083 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4084 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4085 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4086 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4087 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4088 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4089 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4090 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4091 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4092 $_SESSION['usces_member']['status'] = $member['mem_status'];
4093 //20100818ysk start
4094 $this->set_session_custom_member($member['ID']);
4095 //20100818ysk end
4096 $this->get_current_member();
4097
4098 // $cookie = $this->get_cookie();
4099 // if(isset($_POST['rememberme']) && $cookie){
4100 // $cookie['name'] = $email;
4101 // $cookie['pass'] = trim($_POST['loginpass']);
4102 // $this->set_cookie($cookie);
4103 // }else{
4104 // $cookie['name'] = '';
4105 // $cookie['pass'] = '';
4106 // $this->set_cookie($cookie);
4107 // }
4108
4109 do_action( 'usces_action_after_login' );
4110 return apply_filters( 'usces_filter_member_login', 'member', $member );
4111 }
4112 }
4113
4114 function member_logout() {
4115 unset($_SESSION['usces_member'], $_SESSION['usces_entry']);
4116 do_action('usces_action_member_logout');
4117 wp_redirect(get_option('home'));
4118 exit;
4119 }
4120
4121 function get_current_member() {
4122
4123 if ( isset($_SESSION['usces_member']['ID']) ) {
4124 $this->current_member['id'] = $_SESSION['usces_member']['ID'];
4125 $this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return');
4126 } else {
4127 $this->current_member['id'] = 0;
4128 $this->current_member['name'] = __('guest', 'usces');
4129 }
4130 }
4131
4132 function get_member() {
4133 $res = array(
4134 'ID' => '',
4135 'registered' => '',
4136 'mailaddress1' => '',
4137 'mailaddress2' => '',
4138 'password1' => '',
4139 'password2' => '',
4140 'point' => '',
4141 'name1' => '',
4142 'name2' => '',
4143 'name3' => '',
4144 'name4' => '',
4145 'zipcode' => '',
4146 'address1' => '',
4147 'address2' => '',
4148 'address3' => '',
4149 'tel' => '',
4150 'fax' => '',
4151 'country' => '',
4152 'pref' => '',
4153 'status' => ''
4154 );
4155 if(!empty($_SESSION['usces_member'])) {
4156 foreach ( $_SESSION['usces_member'] as $key => $value ) {
4157 //20100818ysk start
4158 if(is_array($_SESSION['usces_member'][$key]))
4159 $res[$key] = stripslashes_deep($value);
4160 else
4161 //20100818ysk end
4162 $res[$key] = stripslashes($value);
4163 }
4164 }
4165 return $res;
4166 }
4167
4168 function get_member_info( $mid ) {
4169 global $wpdb;
4170 $infos = array();
4171
4172 //if( !current_user_can('activate_plugins') ) return array();
4173
4174 $table = $wpdb->prefix . "usces_member";
4175 $query = $wpdb->prepare("SELECT * FROM $table WHERE ID = %d", $mid);
4176 $datas = $wpdb->get_results( $query, ARRAY_A );
4177 if( $datas ) {
4178 $infos = $datas[0];
4179
4180 $table = $wpdb->prefix . "usces_member_meta";
4181 $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid);
4182 $metas = $wpdb->get_results( $query, ARRAY_A );
4183
4184 foreach( $metas as $meta ){
4185 $infos[$meta['meta_key']] = maybe_unserialize($meta['meta_value']);
4186 }
4187 }
4188 return $infos;
4189 }
4190
4191 function set_member_info( $data=array(), $mid ) {
4192 global $wpdb;
4193
4194 $table = $wpdb->prefix . "usces_member";
4195 $res = $wpdb->update( $table, $data, array('ID'=>$mid), NULL, array('%d'));
4196 return $res;
4197 }
4198
4199 function is_order($mid, $oid) {
4200 global $wpdb;
4201
4202 $table = $wpdb->prefix . "usces_order";
4203 $query = $wpdb->prepare("SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid);
4204 $mem_id = $wpdb->get_var( $query );
4205 if ( empty($mem_id) ) {
4206 return false;
4207 }else{
4208 return true;
4209 }
4210 }
4211
4212 function is_purchased_item($mid, $post_id, $sku = NULL) {
4213 global $wpdb;
4214 $res = false;
4215
4216 $history = $this->get_member_history($mid);
4217 foreach ( $history as $umhs ) {
4218 $cart = $umhs['cart'];
4219 $status = $umhs['order_status'];
4220 for($i=0; $i<count($cart); $i++) {
4221 $cart_row = $cart[$i];
4222 $sku_code = urldecode($cart_row['sku']);
4223 if( empty($sku) ){
4224 if( $cart_row['post_id'] == $post_id && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4225 $res = true;
4226 break 2;
4227 }elseif( $cart_row['post_id'] == $post_id && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4228 $res = 'noreceipt';
4229 break 2;
4230 }
4231 }else{
4232 if( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4233 $res = true;
4234 break 2;
4235 }elseif( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4236 $res = 'noreceipt';
4237 break 2;
4238 }
4239 }
4240 }
4241
4242 }
4243 return $res;
4244 }
4245
4246 function get_order_data($order_id, $mode = '' ) {
4247 global $wpdb, $usces;
4248 $order_table = $wpdb->prefix . "usces_order";
4249
4250 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $order_id);
4251
4252 if( 'direct' == $mode ){
4253 $value = $wpdb->get_row( $query, ARRAY_A );
4254 return $value;
4255 }
4256
4257 $value = $wpdb->get_row( $query );
4258
4259 if( $value == NULL ) {
4260 return false;
4261 }else{
4262 $res =array();
4263 }
4264 if(strpos($value->order_status, 'cancel') !== false || strpos($value->order_status, 'estimate') !== false){
4265 return false;
4266 }
4267
4268 $res = array(
4269 'ID' => $value->ID,
4270 'mem_id' => $value->mem_id,
4271 'cart' => unserialize($value->order_cart),
4272 'condition' => unserialize($value->order_condition),
4273 'getpoint' => $value->order_getpoint,
4274 'usedpoint' => $value->order_usedpoint,
4275 'discount' => $value->order_discount,
4276 'payment_name' => $value->order_payment_name,
4277 'shipping_charge' => $value->order_shipping_charge,
4278 'cod_fee' => $value->order_cod_fee,
4279 'tax' => $value->order_tax,
4280 '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,
4281 'status' => $value->order_status,
4282 'date' => mysql2date(__('Y/m/d'), $value->order_date),
4283 'modified' => mysql2date(__('Y/m/d'), $value->order_modified)
4284 );
4285
4286 return $res;
4287 }
4288
4289 function get_orderIDs_by_postID($mem_id, $post_id) {
4290 global $wpdb;
4291 $order_table = $wpdb->prefix . "usces_order";
4292
4293 $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);
4294 $rows = $wpdb->get_query( $query, ARRAY_A );
4295
4296 if( $value == NULL ) {
4297 return false;
4298 }else{
4299 foreach($rows as $row){
4300 if(strpos($row['order_status'], 'cancel') !== false || strpos($row['order_status'], 'estimate') !== false){
4301 continue;
4302 }else{
4303 $carts = unserialize($row['order_cart']);
4304 foreach($carts as $cart){
4305 if( $post_id == $cart['post_id'] ){
4306 $res[] = $row['ID'];
4307 break;
4308 }
4309 }
4310 }
4311 }
4312 }
4313 return $res;
4314 }
4315
4316 function incart_check() {
4317 //$_POST = $this->stripslashes_deep_post($_POST);
4318 $mes = array();
4319
4320 $ids = array_keys($_POST['inCart']);
4321 $post_id = $ids[0];
4322 $skus = array_keys($_POST['inCart'][$post_id]);
4323 $sku = $skus[0];
4324 $quant = isset($_POST['quant'][$post_id][$sku]) ? (int)$_POST['quant'][$post_id][$sku] : 1;
4325 $stock = $this->getItemZaikoNum($post_id, $sku);
4326 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku);
4327 $itemRestriction = get_post_meta($post_id, '_itemRestriction',true );
4328
4329 if( 1 > $quant ){
4330 $mes[$post_id][$sku] = __('enter the correct amount', 'usces') . "<br />";
4331 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4332 $mes[$post_id][$sku] = sprintf(__("This article is limited by %d at a time.", 'usces'), $itemRestriction) . "<br />";
4333 }else if( $quant > (int)$stock && !WCUtils::is_blank($stock) ){
4334 $mes[$post_id][$sku] = __('Sorry, stock is insufficient.', 'usces') . ' ' . __('Current stock', 'usces') . $stock . "<br />";
4335 }else if( 1 < $zaiko_id ){
4336 $mes[$post_id][$sku] = __('Sorry, this item is sold out.', 'usces') . "<br />";
4337 }
4338
4339 $ioptkeys = $this->get_itemOptionKey( $post_id, true );
4340 if($ioptkeys){
4341 foreach($ioptkeys as $key => $value){
4342 $optValues = $this->get_itemOptions( urldecode($value), $post_id );
4343 if( 0 == $optValues['means'] ){ //case of select
4344 if( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][$post_id][$sku][$value] ){
4345 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4346 }
4347 }elseif( 1 == $optValues['means'] ){ //case of multiselect
4348 if( $optValues['essential'] ){
4349 $mselect = 0;
4350 foreach((array)$_POST['itemOption'][$post_id][$sku][$value] as $mvalue){
4351 if(!empty($mvalue) and '#NONE#' != $mvalue) $mselect++;
4352 }
4353 if( $mselect == 0 ){
4354 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4355 }
4356 }
4357 }else{ //case of text
4358 if( $optValues['essential'] && WCUtils::is_blank($_POST['itemOption'][$post_id][$sku][$value]) ){
4359 $mes[$post_id][$sku] .= sprintf(__("Input the %s", 'usces'), urldecode($value)) . "<br />";
4360 }
4361 }
4362 }
4363 }
4364
4365 $mes = apply_filters('usces_filter_incart_check', $mes, $post_id, $sku);
4366
4367 if( isset($mes[$post_id]) && is_array($mes[$post_id]) ){
4368 foreach( $mes[$post_id] as $skukey => $skuvalue ){
4369 $mes[$post_id][$skukey] = rtrim($skuvalue, "<br />");
4370 }
4371 }
4372
4373 if( !empty($mes) ){
4374 $_SESSION['usces_singleitem']['itemOption'] = $_POST['itemOption'];
4375 $_SESSION['usces_singleitem']['quant'] = $_POST['quant'];
4376 $_SESSION['usces_singleitem']['error_message'] = $mes;
4377 if( false === strpos($_POST['usces_referer'], 'http') ){
4378 $parse_url = parse_url(get_home_url());
4379 header('location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $_POST['usces_referer'] . '#cart_button');
4380 }else{
4381 header('location: ' . $_POST['usces_referer'] . '#cart_button');
4382 }
4383 exit;
4384 }
4385
4386 do_action('usces_action_incart_checked', $mes, $post_id, $sku);
4387 }
4388
4389 function zaiko_check() {
4390 $mes = '';
4391 $cart = $this->cart->get_cart();
4392 $stocks = array();
4393
4394 for($i=0; $i<count($cart); $i++) {
4395 $cart_row = $cart[$i];
4396 $post_id = $cart_row['post_id'];
4397 $sku = $cart_row['sku'];
4398 $sku_code = urldecode($cart_row['sku']);
4399
4400 $quant = ( isset($_POST['quant']) ) ? trim($_POST['quant'][$i][$post_id][$sku]) : $cart_row['quantity'];
4401 //$zaiko_status = $this->getItemZaiko($post_id, $sku);
4402 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku_code);
4403 $stock = $this->getItemZaikoNum($post_id, $sku_code);
4404 if( !isset($stocks[$post_id][$sku]) ){
4405 if( !WCUtils::is_blank($stock) ){
4406 $stocks[$post_id][$sku] = $stock;
4407 }else{
4408 $stocks[$post_id][$sku] = NULL;
4409 }
4410 }
4411 $checkstock = $stocks[$post_id][$sku];
4412 $stocks[$post_id][$sku] = $stocks[$post_id][$sku] - $quant;
4413 $itemRestriction = get_post_meta($post_id, '_itemRestriction', true);
4414
4415 //$red = (in_array($zaiko_status, array(__('Sold Out', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'red' : '';
4416
4417 if( 1 > (int)$quant ){
4418 $mes .= sprintf(__("Enter the correct amount for the No.%d item.", 'usces'), ($i+1)) . "<br />";
4419 }else if( 1 < $zaiko_id || WCUtils::is_zero($stock) ){
4420 $mes .= sprintf(__('Sorry, No.%d item is sold out.', 'usces'), ($i+1)) . "<br />";
4421 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4422 $mes .= sprintf(__('This article is limited by %1$d at a time for the No.%2$d item.', 'usces'), $itemRestriction, ($i+1)) . "<br />";
4423 }else if( 0 > $stocks[$post_id][$sku] && !WCUtils::is_blank($stock) ){
4424 $mes .= sprintf(__('Stock of No.%1$d item is remainder %2$d.', 'usces'), ($i+1), $checkstock) . "<br />";
4425 }
4426 }
4427 $mes = apply_filters('usces_filter_zaiko_check', $mes, $cart);
4428 return $mes;
4429 }
4430
4431 function member_check() {
4432 $mes = '';
4433 foreach ( $_POST['member'] as $key => $vlue ) {
4434 $_SESSION['usces_member'][$key] = trim($vlue);
4435 }
4436 if ( $_POST['member_regmode'] == 'editmemberform' ) {
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']) )
4440 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4441
4442 } else {
4443 if ( WCUtils::is_blank($_POST['member']['password1']) || WCUtils::is_blank($_POST['member']['password2']) || trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4444 $mes .= __('Password is not correct.', 'usces') . "<br />";
4445 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']) )
4446 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4447
4448 }
4449 if ( WCUtils::is_blank($_POST["member"]["name1"]) )
4450 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4451 // if ( trim($_POST["member"]["name3"]) == "" && USCES_JP )
4452 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4453 if ( WCUtils::is_blank($_POST["member"]["zipcode"]) )
4454 $mes .= __('postal code is not correct', 'usces') . "<br />";
4455 if ( $_POST["member"]["pref"] == __('-- Select --', 'usces') )
4456 $mes .= __('enter the prefecture', 'usces') . "<br />";
4457 if ( WCUtils::is_blank($_POST["member"]["address1"]) )
4458 $mes .= __('enter the city name', 'usces') . "<br />";
4459 if ( WCUtils::is_blank($_POST["member"]["address2"]) )
4460 $mes .= __('enter house numbers', 'usces') . "<br />";
4461 if ( WCUtils::is_blank($_POST["member"]["tel"]) )
4462 $mes .= __('enter phone numbers', 'usces') . "<br />";
4463 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4464 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4465
4466 $mes = apply_filters('usces_filter_member_check', $mes);
4467
4468 return $mes;
4469 }
4470
4471 function member_check_fromcart() {
4472 $mes = '';
4473 if ( WCUtils::is_blank($_POST['customer']['password1']) || WCUtils::is_blank($_POST['customer']['password2']) || trim($_POST['customer']['password1']) != trim($_POST['customer']['password2']) )
4474 $mes .= __('Password is not correct.', 'usces') . "<br />";
4475 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']) )
4476 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4477 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4478 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4479 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4480 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4481 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4482 $mes .= __('postal code is not correct', 'usces') . "<br />";
4483 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4484 $mes .= __('enter the prefecture', 'usces') . "<br />";
4485 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4486 $mes .= __('enter the city name', 'usces') . "<br />";
4487 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4488 $mes .= __('enter house numbers', 'usces') . "<br />";
4489 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4490 $mes .= __('enter phone numbers', 'usces') . "<br />";
4491 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4492 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4493
4494 $mes = apply_filters('usces_filter_member_check_fromcart', $mes);
4495
4496 return $mes;
4497 }
4498
4499 function admin_member_check() {
4500 global $wpdb;
4501 $mes = '';
4502 if ( !is_email( trim($_POST['member']["email"]) ) ){
4503 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4504 }else{
4505 $member_table = $wpdb->prefix . "usces_member";
4506 $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
4507 if( trim($_POST['member']["email"]) != $mem_email ){
4508 $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
4509 if( !empty($mem_ID) )
4510 $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />";
4511 }
4512 }
4513 if ( WCUtils::is_blank($_POST['member']["name1"]) )
4514 $mes .= __('Name is not correct', 'usces') . "<br />";
4515 // if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
4516 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4517 // if ( trim($_POST['member']["zipcode"]) == "" )
4518 // $mes .= __('postal code is not correct', 'usces') . "<br />";
4519 // if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
4520 // $mes .= __('enter the prefecture', 'usces') . "<br />";
4521 // if ( trim($_POST['member']["address1"]) == "" )
4522 // $mes .= __('enter the city name', 'usces') . "<br />";
4523 // if ( trim($_POST['member']["address2"]) == "" )
4524 // $mes .= __('enter house numbers', 'usces') . "<br />";
4525 // if ( trim($_POST['member']["tel"]) == "" )
4526 // $mes .= __('enter phone numbers', 'usces') . "<br />";
4527 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4528 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4529
4530 $mes = apply_filters('usces_filter_admin_member_check', $mes);
4531
4532 return $mes;
4533 }
4534
4535 function customer_check() {
4536 $mes = '';
4537 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']) )
4538 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4539 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4540 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4541 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4542 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4543 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4544 $mes .= __('postal code is not correct', 'usces') . "<br />";
4545 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4546 $mes .= __('enter the prefecture', 'usces') . "<br />";
4547 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4548 $mes .= __('enter the city name', 'usces') . "<br />";
4549 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4550 $mes .= __('enter house numbers', 'usces') . "<br />";
4551 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4552 $mes .= __('enter phone numbers', 'usces') . "<br />";
4553 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4554 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4555
4556 $mes = apply_filters('usces_filter_customer_check', $mes);
4557
4558 return $mes;
4559 }
4560
4561 function delivery_check() {
4562 $mes = '';
4563 if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
4564 if ( WCUtils::is_blank($_POST["delivery"]["name1"]) )
4565 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4566 // if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP )
4567 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4568 if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) )
4569 $mes .= __('postal code is not correct', 'usces') . "<br />";
4570 if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') )
4571 $mes .= __('enter the prefecture', 'usces') . "<br />";
4572 if ( WCUtils::is_blank($_POST["delivery"]["address1"]) )
4573 $mes .= __('enter the city name', 'usces') . "<br />";
4574 if ( WCUtils::is_blank($_POST["delivery"]["address2"]) )
4575 $mes .= __('enter house numbers', 'usces') . "<br />";
4576 if ( WCUtils::is_blank($_POST["delivery"]["tel"]) )
4577 $mes .= __('enter phone numbers', 'usces') . "<br />";
4578 }
4579 if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) )
4580 $mes .= __('chose one from delivery method.', 'usces') . "<br />";
4581 if ( !isset($_POST['offer']['payment_name']) ){
4582 $mes .= __('chose one from payment options.', 'usces') . "<br />";
4583 }else{
4584 $payments = $this->getPayments($_POST['offer']['payment_name']);
4585 if('COD' == $payments['settlement']){
4586 $total_items_price = $this->get_total_price();
4587 $tax = $this->getTax( $total_items_price );
4588 $total_items_price = $total_items_price + $tax;
4589 $cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
4590 if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount )
4591 $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 />";
4592 }
4593
4594 }
4595 //20101119ysk start
4596 if(isset($_POST['offer']['delivery_method']) and isset($_POST['offer']['payment_name'])) {
4597 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4598 if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) {
4599 $payments = $this->getPayments($_POST['offer']['payment_name']);
4600 if('COD' == $payments['settlement'])
4601 $mes .= __('COD is not available.', 'usces') . "<br />";
4602 }
4603 }
4604 //20101119ysk end
4605 //20110317ysk start
4606 if(isset($_POST['offer']['delivery_method'])) {
4607 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4608 $country = $_SESSION['usces_entry']["delivery"]["country"];
4609 $local_country = usces_get_base_country();
4610 if($country == $local_country) {
4611 if($this->options['delivery_method'][$d_method_index]['intl'] == 1) {
4612 $mes .= __('�
4613 �送方法が誤っています。国際便は指定できません。', 'usces') . "<br />";
4614 }
4615 } else {
4616 if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) {
4617 $mes .= __('�
4618 �送方法が誤っています。国際便を指定してください。', 'usces') . "<br />";
4619 }
4620 }
4621 }
4622 //20110317ysk end
4623
4624 $mes = apply_filters('usces_filter_delivery_check', $mes);
4625
4626 return $mes;
4627 }
4628
4629 function point_check( $entries ) {
4630 $member = $this->get_member();
4631 $this->set_cart_fees( $member, $entries );
4632 $mes = '';
4633 if( isset($_POST['offer']["usedpoint"]) ) {
4634 if ( WCUtils::is_blank($_POST['offer']["usedpoint"]) || !preg_match("/^[0-9]+$/", $_POST['offer']["usedpoint"]) || (int)$_POST['offer']["usedpoint"] < 0 ) {
4635 $mes .= __('Invalid value. Please enter in the numbers.', 'usces') . "<br />";
4636 } else {
4637 /* if ( trim($_POST['offer']["usedpoint"]) > $member['point'] ){
4638 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".$member['point']."pt<br />";
4639 $_POST['offer']["usedpoint"] = 0;
4640 $array = array(
4641 'usedpoint' => 0
4642 );
4643 $this->cart->set_order_entry( $array );
4644 }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'])){
4645 $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 />";
4646 $_POST['offer']["usedpoint"] = 0;
4647 $array = array(
4648 'usedpoint' => 0
4649 );
4650 $this->cart->set_order_entry( $array );
4651 }elseif(!$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'])){
4652 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4653 $_POST['offer']["usedpoint"] = 0;
4654 $array = array(
4655 'usedpoint' => 0
4656 );
4657 $this->cart->set_order_entry( $array );
4658 }
4659 */ if( trim($_POST['offer']["usedpoint"]) > $member['point'] ) {
4660 $mes .= __('You have exceeded the maximum available.', 'usces')."max".$member['point']."pt<br />";
4661 } 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']) ) {
4662 $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 />";
4663 } elseif( !$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount']) ) {
4664 $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4665 }
4666 $mes = apply_filters( 'usces_filter_point_check', $mes );
4667 if( '' != $mes ) {
4668 $_POST['offer']["usedpoint"] = 0;
4669 $array = array(
4670 'usedpoint' => 0
4671 );
4672 $this->cart->set_order_entry( $array );
4673 }
4674 }
4675 }
4676 $mes = apply_filters('usces_filter_point_check', $mes);
4677 return $mes;
4678 }
4679
4680 function lostpass_mailaddcheck() {
4681 $mes = '';
4682 if ( !is_email($_POST['loginmail']) || WCUtils::is_blank($_POST['loginmail']) ) {
4683 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4684 }elseif( !$this->is_member($_POST['loginmail']) ){
4685 $mes .= __('It is the e-mail address that there is not.', 'usces') . "<br />";
4686 }
4687
4688 return $mes;
4689 }
4690
4691 function changepass_check() {
4692 $mes = '';
4693 if ( WCUtils::is_blank($_POST['loginpass1']) || WCUtils::is_blank($_POST['loginpass2']) || (trim($_POST['loginpass1']) != trim($_POST['loginpass2'])))
4694 $mes .= __('Password is not correct.', 'usces') . "<br />";
4695
4696 return $mes;
4697 }
4698
4699 function get_page() {
4700 return $this->page;
4701 }
4702
4703 function check_display_mode() {
4704 $options = get_option('usces');
4705 if( isset($options['display_mode']) && $options['display_mode'] == 'Maintenancemode' ) return;
4706
4707 $start['hour'] = empty($options['campaign_schedule']['start']['hour']) ? 0 : $options['campaign_schedule']['start']['hour'];
4708 $start['min'] = empty($options['campaign_schedule']['start']['min']) ? 0 : $options['campaign_schedule']['start']['min'];
4709 $start['month'] = empty($options['campaign_schedule']['start']['month']) ? 0 : $options['campaign_schedule']['start']['month'];
4710 $start['day'] = empty($options['campaign_schedule']['start']['day']) ? 0 : $options['campaign_schedule']['start']['day'];
4711 $start['year'] = empty($options['campaign_schedule']['start']['year']) ? 0 : $options['campaign_schedule']['start']['year'];
4712 $end['hour'] = empty($options['campaign_schedule']['end']['hour']) ? 0 : $options['campaign_schedule']['end']['hour'];
4713 $end['min'] = empty($options['campaign_schedule']['end']['min']) ? 0 : $options['campaign_schedule']['end']['min'];
4714 $end['month'] = empty($options['campaign_schedule']['end']['month']) ? 0 : $options['campaign_schedule']['end']['month'];
4715 $end['day'] = empty($options['campaign_schedule']['end']['day']) ? 0 : $options['campaign_schedule']['end']['day'];
4716 $end['year'] = empty($options['campaign_schedule']['end']['year']) ? 0 : $options['campaign_schedule']['end']['year'];
4717 $starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']);
4718 $endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']);
4719 $current_time = current_time('timestamp');
4720
4721 if( ($current_time >= $starttime) && ($current_time <= $endtime) )
4722 $options['display_mode'] = 'Promotionsale';
4723 else
4724 $options['display_mode'] = 'Usualsale';
4725
4726 update_option('usces', $options);
4727
4728 }
4729
4730 function update_business_days() {
4731 $options = get_option('usces');
4732 $datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
4733 $dhour = (int)substr($datetimestr, 11, 2);
4734 $dminute = (int)substr($datetimestr, 14, 2);
4735 $dsecond = (int)substr($datetimestr, 17, 2);
4736 $dmonth = (int)substr($datetimestr, 5, 2);
4737 $dday = (int)substr($datetimestr, 8, 2);
4738 $dyear = (int)substr($datetimestr, 0, 4);
4739 $dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear);
4740 $datenow = getdate($dtimestamp);
4741 //list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1);
4742 list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], 1, 1);
4743
4744 if(isset($options['business_days'][$year][$mon][1]))
4745 unset($options['business_days'][$year][$mon]);
4746
4747 for($i=0; $i<3; $i++){
4748 //list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i);
4749 list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], 1, $i);
4750 $last = getLastDay($year, $mon);
4751 for($j=1; $j<=$last; $j++){
4752 if(!isset($options['business_days'][$year][$mon][$j]))
4753 $options['business_days'][$year][$mon][$j] = 1;
4754 }
4755 }
4756
4757 update_option('usces', $options);
4758
4759 $_SESSION['usces_checked_business_days'] = '';
4760 }
4761
4762 function display_cart() {
4763 if($this->cart->num_row() > 0) {
4764 include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
4765 } else {
4766 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4767 }
4768 }
4769
4770 function display_cart_confirm() {
4771 if($this->cart->num_row() > 0) {
4772 include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php');
4773 } else {
4774 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4775 }
4776 }
4777
4778 function set_initial() {
4779
4780 usces_log('set_initial : OK', 'database_error.log');
4781 $rets07 = usces_upgrade_07();
4782 $rets11 = usces_upgrade_11();
4783 usces_log('rets11 : ' . print_r($rets11,true), 'database_error.log');
4784 $this->set_default_theme();
4785 $this->set_default_page();
4786 $this->set_default_categories();
4787 $this->create_table();
4788 $this->update_table();
4789 $this->update_options();//20120710ysk 0000472
4790 }
4791
4792 function create_table() {
4793 global $wpdb;
4794
4795 if ( ! empty($wpdb->charset) )
4796 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
4797 if ( ! empty($wpdb->collate) )
4798 $charset_collate .= " COLLATE $wpdb->collate";
4799
4800 $access_table = $wpdb->prefix . "usces_access";
4801 $member_table = $wpdb->prefix . "usces_member";
4802 $member_meta_table = $wpdb->prefix . "usces_member_meta";
4803 $order_table = $wpdb->prefix . "usces_order";
4804 $order_meta_table = $wpdb->prefix . "usces_order_meta";
4805
4806 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4807
4808 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
4809
4810 $sql = "CREATE TABLE " . $access_table . " (
4811 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4812 acc_key VARCHAR( 50 ) NOT NULL ,
4813 acc_type VARCHAR( 50 ) NULL ,
4814 acc_value LONGTEXT NULL ,
4815 acc_date DATE NOT NULL DEFAULT '0000-00-00',
4816 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
4817 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
4818 acc_str1 VARCHAR( 200 ) NULL ,
4819 acc_str2 VARCHAR( 200 ) NULL ,
4820 KEY acc_key ( acc_key ),
4821 KEY acc_type ( acc_type ),
4822 KEY acc_date ( acc_date ),
4823 KEY acc_num1 ( acc_num1 ),
4824 KEY acc_num2 ( acc_num2 )
4825 ) ENGINE = MYISAM AUTO_INCREMENT=0 $charset_collate;";
4826
4827 dbDelta($sql);
4828 add_option("usces_db_access", USCES_DB_ACCESS);
4829 }
4830 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
4831
4832 $sql = "CREATE TABLE " . $member_table . " (
4833 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4834 mem_email VARCHAR( 100 ) NOT NULL ,
4835 mem_pass VARCHAR( 64 ) NOT NULL ,
4836 mem_status INT( 11 ) NOT NULL DEFAULT '0',
4837 mem_cookie VARCHAR( 13 ) NULL ,
4838 mem_point INT( 11 ) NOT NULL DEFAULT '0',
4839 mem_name1 VARCHAR( 100 ) NOT NULL ,
4840 mem_name2 VARCHAR( 100 ) NULL ,
4841 mem_name3 VARCHAR( 100 ) NULL ,
4842 mem_name4 VARCHAR( 100 ) NULL ,
4843 mem_zip VARCHAR( 50 ) NULL ,
4844 mem_pref VARCHAR( 100 ) NOT NULL ,
4845 mem_address1 VARCHAR( 100 ) NOT NULL ,
4846 mem_address2 VARCHAR( 100 ) NULL ,
4847 mem_address3 VARCHAR( 100 ) NULL ,
4848 mem_tel VARCHAR( 100 ) NOT NULL ,
4849 mem_fax VARCHAR( 100 ) NULL ,
4850 mem_delivery_flag TINYINT ( 1 ) NULL ,
4851 mem_delivery LONGTEXT,
4852 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
4853 mem_nicename VARCHAR( 50 ) NULL ,
4854 KEY mem_email ( mem_email ) ,
4855 KEY mem_pass ( mem_pass )
4856 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
4857
4858 dbDelta($sql);
4859 add_option("usces_db_member", USCES_DB_MEMBER);
4860 }
4861 if($wpdb->get_var("show tables like '$member_meta_table'") != $member_meta_table) {
4862
4863 $sql = "CREATE TABLE " . $member_meta_table . " (
4864 mmeta_id bigint(20) NOT NULL auto_increment,
4865 member_id bigint(20) NOT NULL default '0',
4866 meta_key varchar(255) default NULL,
4867 meta_value longtext,
4868 PRIMARY KEY (mmeta_id),
4869 KEY order_id (member_id),
4870 KEY meta_key (meta_key)
4871 ) ENGINE = MYISAM $charset_collate;";
4872
4873 dbDelta($sql);
4874 add_option("usces_db_member_meta", USCES_DB_MEMBER_META);
4875 }
4876 if($wpdb->get_var("show tables like '$order_table'") != $order_table) {
4877
4878 $sql = "CREATE TABLE " . $order_table . " (
4879 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4880 mem_id BIGINT( 20 ) UNSIGNED NULL ,
4881 order_email VARCHAR( 100 ) NOT NULL ,
4882 order_name1 VARCHAR( 100 ) NOT NULL ,
4883 order_name2 VARCHAR( 100 ) NULL ,
4884 order_name3 VARCHAR( 100 ) NULL ,
4885 order_name4 VARCHAR( 100 ) NULL ,
4886 order_zip VARCHAR( 50 ) NULL ,
4887 order_pref VARCHAR( 100 ) NOT NULL ,
4888 order_address1 VARCHAR( 100 ) NOT NULL ,
4889 order_address2 VARCHAR( 100 ) NULL ,
4890 order_address3 VARCHAR( 100 ) NULL ,
4891 order_tel VARCHAR( 100 ) NOT NULL ,
4892 order_fax VARCHAR( 100 ) NULL ,
4893 order_delivery LONGTEXT,
4894 order_cart LONGTEXT,
4895 order_note TEXT,
4896 order_delivery_time VARCHAR( 100 ) NOT NULL ,
4897 order_payment_name VARCHAR( 100 ) NOT NULL ,
4898 order_condition TEXT,
4899 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4900 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
4901 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
4902 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4903 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4904 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4905 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4906 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
4907 order_modified VARCHAR( 20 ) NULL ,
4908 order_status VARCHAR( 255 ) NULL ,
4909 order_check VARCHAR( 255 ) NULL ,
4910 order_delidue_date VARCHAR( 30 ) NULL ,
4911 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
4912 order_delivery_date VARCHAR( 100 ) NULL,
4913 KEY order_email ( order_email ) ,
4914 KEY order_name1 ( order_name1 ) ,
4915 KEY order_name2 ( order_name2 ) ,
4916 KEY order_pref ( order_pref ) ,
4917 KEY order_address1 ( order_address1 ) ,
4918 KEY order_tel ( order_tel ) ,
4919 KEY order_date ( order_date )
4920 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
4921
4922 dbDelta($sql);
4923 add_option("usces_db_order", USCES_DB_ORDER);
4924 }
4925 if($wpdb->get_var("show tables like '$order_meta_table'") != $order_meta_table) {
4926
4927 $sql = "CREATE TABLE " . $order_meta_table . " (
4928 ometa_id bigint(20) NOT NULL auto_increment,
4929 order_id bigint(20) NOT NULL default '0',
4930 meta_key varchar(255) default NULL,
4931 meta_value longtext,
4932 PRIMARY KEY (ometa_id),
4933 KEY order_id (order_id),
4934 KEY meta_key (meta_key)
4935 ) ENGINE = MYISAM $charset_collate;";
4936
4937 dbDelta($sql);
4938 add_option("usces_db_order_meta", USCES_DB_ORDER_META);
4939 }
4940
4941 }
4942
4943 function update_table()
4944 {
4945 global $wpdb;
4946 $access_table = $wpdb->prefix . "usces_access";
4947 $member_table = $wpdb->prefix . "usces_member";
4948 $member_meta_table = $wpdb->prefix . "usces_member_meta";
4949 $order_table = $wpdb->prefix . "usces_order";
4950 $order_meta_table = $wpdb->prefix . "usces_order_meta";
4951
4952 $access_ver = get_option( "usces_db_access" );
4953 $member_ver = get_option( "usces_db_member" );
4954 $member_meta_ver = get_option( "usces_db_member_meta" );
4955 $order_ver = get_option( "usces_db_order" );
4956 $order_meta_ver = get_option( "usces_db_order_meta" );
4957
4958 if( $access_ver != USCES_DB_ACCESS ) {
4959 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4960 $sql = "CREATE TABLE " . $access_table . " (
4961 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4962 acc_key VARCHAR( 50 ) NOT NULL ,
4963 acc_type VARCHAR( 50 ) NULL ,
4964 acc_value LONGTEXT NULL ,
4965 acc_date DATE NOT NULL DEFAULT '0000-00-00',
4966 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
4967 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
4968 acc_str1 VARCHAR( 200 ) NULL ,
4969 acc_str2 VARCHAR( 200 ) NULL ,
4970 KEY acc_key ( acc_key ),
4971 KEY acc_type ( acc_type ),
4972 KEY acc_date ( acc_date ),
4973 KEY acc_num1 ( acc_num1 ),
4974 KEY acc_num2 ( acc_num2 )
4975 ) ENGINE = MYISAM;";
4976
4977 dbDelta($sql);
4978 update_option( "usces_db_access", USCES_DB_ACCESS );
4979 }
4980 if( $member_ver != USCES_DB_MEMBER ) {
4981 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4982 $sql = "CREATE TABLE " . $member_table . " (
4983 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4984 mem_email VARCHAR( 100 ) NOT NULL ,
4985 mem_pass VARCHAR( 64 ) NOT NULL ,
4986 mem_status INT( 11 ) NOT NULL DEFAULT '0',
4987 mem_cookie VARCHAR( 13 ) NULL ,
4988 mem_point INT( 11 ) NOT NULL DEFAULT '0',
4989 mem_name1 VARCHAR( 100 ) NOT NULL ,
4990 mem_name2 VARCHAR( 100 ) NULL ,
4991 mem_name3 VARCHAR( 100 ) NULL ,
4992 mem_name4 VARCHAR( 100 ) NULL ,
4993 mem_zip VARCHAR( 50 ) NULL ,
4994 mem_pref VARCHAR( 100 ) NOT NULL ,
4995 mem_address1 VARCHAR( 100 ) NOT NULL ,
4996 mem_address2 VARCHAR( 100 ) NULL ,
4997 mem_address3 VARCHAR( 100 ) NULL ,
4998 mem_tel VARCHAR( 100 ) NOT NULL ,
4999 mem_fax VARCHAR( 100 ) NULL ,
5000 mem_delivery_flag TINYINT ( 1 ) NULL ,
5001 mem_delivery LONGTEXT,
5002 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5003 mem_nicename VARCHAR( 50 ) NULL ,
5004 KEY mem_email ( mem_email ) ,
5005 KEY mem_pass ( mem_pass )
5006 ) ENGINE = MYISAM;";
5007
5008 dbDelta($sql);
5009 update_option( "usces_db_member", USCES_DB_MEMBER );
5010 }
5011 if( $member_meta_ver != USCES_DB_MEMBER_META ) {
5012 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5013 $sql = "CREATE TABLE " . $member_meta_table . " (
5014 mmeta_id bigint(20) NOT NULL auto_increment,
5015 member_id bigint(20) NOT NULL default '0',
5016 meta_key varchar(255) default NULL,
5017 meta_value longtext,
5018 PRIMARY KEY (mmeta_id),
5019 KEY order_id (member_id),
5020 KEY meta_key (meta_key)
5021 ) ENGINE = MYISAM;";
5022
5023 dbDelta($sql);
5024 update_option("usces_db_member_meta", USCES_DB_MEMBER_META);
5025 }
5026 if( $order_ver != USCES_DB_ORDER ) {
5027 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5028 $sql = "CREATE TABLE " . $order_table . " (
5029 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5030 mem_id BIGINT( 20 ) UNSIGNED NULL ,
5031 order_email VARCHAR( 100 ) NOT NULL ,
5032 order_name1 VARCHAR( 100 ) NOT NULL ,
5033 order_name2 VARCHAR( 100 ) NULL ,
5034 order_name3 VARCHAR( 100 ) NULL ,
5035 order_name4 VARCHAR( 100 ) NULL ,
5036 order_zip VARCHAR( 50 ) NULL ,
5037 order_pref VARCHAR( 100 ) NOT NULL ,
5038 order_address1 VARCHAR( 100 ) NOT NULL ,
5039 order_address2 VARCHAR( 100 ) NULL ,
5040 order_address3 VARCHAR( 100 ) NULL ,
5041 order_tel VARCHAR( 100 ) NOT NULL ,
5042 order_fax VARCHAR( 100 ) NULL ,
5043 order_delivery LONGTEXT,
5044 order_cart LONGTEXT,
5045 order_note TEXT,
5046 order_delivery_time VARCHAR( 100 ) NOT NULL ,
5047 order_payment_name VARCHAR( 100 ) NOT NULL ,
5048 order_condition TEXT,
5049 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5050 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
5051 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
5052 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5053 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5054 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5055 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5056 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5057 order_modified VARCHAR( 20 ) NULL ,
5058 order_status VARCHAR( 255 ) NULL ,
5059 order_check VARCHAR( 255 ) NULL ,
5060 order_delidue_date VARCHAR( 30 ) NULL ,
5061 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
5062 order_delivery_date VARCHAR( 100 ) NULL,
5063 KEY order_email ( order_email ) ,
5064 KEY order_name1 ( order_name1 ) ,
5065 KEY order_name2 ( order_name2 ) ,
5066 KEY order_pref ( order_pref ) ,
5067 KEY order_address1 ( order_address1 ) ,
5068 KEY order_tel ( order_tel ) ,
5069 KEY order_date ( order_date )
5070 ) ENGINE = MYISAM;";
5071
5072 dbDelta($sql);
5073 update_option("usces_db_order", USCES_DB_ORDER);
5074 }
5075 if( $order_meta_ver != USCES_DB_ORDER_META ) {
5076 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5077 $sql = "CREATE TABLE " . $order_meta_table . " (
5078 ometa_id bigint(20) NOT NULL auto_increment,
5079 order_id bigint(20) NOT NULL default '0',
5080 meta_key varchar(255) default NULL,
5081 meta_value longtext,
5082 PRIMARY KEY (ometa_id),
5083 KEY order_id (order_id),
5084 KEY meta_key (meta_key)
5085 ) ENGINE = MYISAM;";
5086
5087 dbDelta($sql);
5088 update_option("usces_db_order_meta", USCES_DB_ORDER_META);
5089 }
5090 }
5091
5092 function set_default_theme()
5093 {
5094 $themepath = USCES_WP_CONTENT_DIR.'/themes/welcart_default';
5095 $resourcepath = USCES_WP_CONTENT_DIR.'/plugins/usc-e-shop/theme/welcart_default';
5096 if( file_exists($themepath) ) return false;
5097 if(!file_exists($resourcepath) ) return false;
5098
5099 mkdir($themepath, 0775);
5100 $this->dir_copy($resourcepath, $themepath);
5101
5102 }
5103
5104 function dir_copy($source, $dest){
5105 if ($res = opendir($source)) {
5106 while (($file = readdir($res)) !== false) {
5107 $sorce_path = $source . '/' . $file;
5108 $dest_path = $dest . '/' . $file;
5109 $filetype = @filetype($sorce_path);
5110 if( $filetype == 'file' ) {
5111 copy($sorce_path, $dest_path);
5112 }elseif( $filetype == 'dir' && $file != '..' && $file != '.' ){
5113 mkdir($dest_path);
5114 $this->dir_copy($sorce_path, $dest_path);
5115 }
5116 }
5117 closedir($res);
5118 }
5119 }
5120
5121 function set_default_page()
5122 {
5123 global $wpdb;
5124 $datetime = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
5125 $datetime_gmt = gmdate('Y-m-d H:i:s', time());
5126
5127 //cart_page
5128 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER);
5129 $cart_number = $wpdb->get_var( $query );
5130 if( $cart_number === NULL ) {
5131 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5132 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5133 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5134 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5135 VALUES (%d, %s, %s, %s, %s, %s, %s,
5136 %s, %s, %s, %s, %s, %s, %s, %s,
5137 %s, %d, %s, %d, %s, %s, %d)",
5138 1, $datetime, $datetime_gmt, '', __('Cart', 'usces'), '', 'publish',
5139 'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt,
5140 '', 0, '', 0, 'page', '', 0);
5141 $wpdb->query($query);
5142 $cart_number = $wpdb->insert_id;
5143 if( $cart_number !== NULL ) {
5144 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5145 $cart_number, '_wp_page_template', 'uscescart.php');
5146 $wpdb->query($query);
5147 }
5148 }
5149 update_option('usces_cart_number', $cart_number);
5150
5151 //member_page
5152 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER);
5153 $member_number = $wpdb->get_var( $query );
5154 if( $member_number === NULL ) {
5155 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5156 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5157 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5158 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5159 VALUES (%d, %s, %s, %s, %s, %s, %s,
5160 %s, %s, %s, %s, %s, %s, %s, %s,
5161 %s, %d, %s, %d, %s, %s, %d)",
5162 1, $datetime, $datetime_gmt, '', __('Membership', 'usces'), '', 'publish',
5163 'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt,
5164 '', 0, '', 0, 'page', '', 0);
5165 $wpdb->query($query);
5166 $member_number = $wpdb->insert_id;
5167 if( $member_number !== NULL ) {
5168 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5169 $member_number, '_wp_page_template', 'uscesmember.php');
5170 $wpdb->query($query);
5171 }
5172 }
5173 update_option('usces_member_number', $member_number);
5174
5175 }
5176
5177 function set_default_categories()
5178 {
5179 global $wpdb;
5180
5181 $idObj = get_category_by_slug('item');
5182 if( empty($idObj) ) {
5183 $item_cat = array('cat_name' => __('Items', 'usces'), 'category_description' => '', 'category_nicename' => 'item', 'category_parent' => 0);
5184 $item_cat_id = wp_insert_category($item_cat);
5185 update_option('usces_item_cat_parent_id', $item_cat_id);
5186 }
5187
5188 $idObj = get_category_by_slug('itemreco');
5189 if( empty($idObj) && isset($item_cat_id) ) {
5190 $itemreco_cat = array('cat_name' => __('Items recommended', 'usces'), 'category_description' => '', 'category_nicename' => 'itemreco', 'category_parent' => $item_cat_id);
5191 $itemreco_cat_id = wp_insert_category($itemreco_cat);
5192 }
5193
5194 $idObj = get_category_by_slug('itemnew');
5195 if( empty($idObj) && isset($item_cat_id) ) {
5196 $itemnew_cat = array('cat_name' => __('New items', 'usces'), 'category_description' => '', 'category_nicename' => 'itemnew', 'category_parent' => $item_cat_id);
5197 $itemnew_cat_id = wp_insert_category($itemnew_cat);
5198 }
5199
5200 $idObj = get_category_by_slug('itemgenre');
5201 if( empty($idObj) && isset($item_cat_id) ) {
5202 $itemgenre_cat = array('cat_name' => __('Item genre', 'usces'), 'category_description' => '', 'category_nicename' => 'itemgenre', 'category_parent' => $item_cat_id);
5203 $itemgenre_cat_id = wp_insert_category($itemgenre_cat);
5204 }
5205 }
5206 //20120710ysk start 0000472
5207 function update_options() {
5208 $target_market = $this->options['system']['target_market'];
5209
5210 $update_shipping_charge = false;
5211 $shipping_charge = isset($this->options['shipping_charge']) ? $this->options['shipping_charge'] : array();
5212 foreach( (array)$target_market as $tm ) {
5213 for( $i = 0; $i < count($shipping_charge); $i++ ) {
5214 if( isset($shipping_charge[$i]['country']) and $shipping_charge[$i]['country'] == $tm ) {
5215 foreach( $shipping_charge[$i]['value'] as $pref => $value ) {
5216 $shipping_charge[$i][$tm][$pref] = $value;
5217 }
5218 unset($shipping_charge[$i]['country']);
5219 unset($shipping_charge[$i]['value']);
5220 $update_shipping_charge = true;
5221 }
5222 }
5223 }
5224 if( $update_shipping_charge ) $this->options['shipping_charge'] = $shipping_charge;
5225
5226 $update_delivery_days = false;
5227 $delivery_days = isset($this->options['delivery_days']) ? $this->options['delivery_days'] : array();
5228 foreach( (array)$target_market as $tm ) {
5229 for( $i = 0; $i < count($delivery_days); $i++ ) {
5230 if( isset($delivery_days[$i]['country']) and $delivery_days[$i]['country'] == $tm ) {
5231 foreach( $delivery_days[$i]['value'] as $pref => $value ) {
5232 $delivery_days[$i][$tm][$pref] = $value;
5233 }
5234 unset($delivery_days[$i]['country']);
5235 unset($delivery_days[$i]['value']);
5236 $update_delivery_days = true;
5237 }
5238 }
5239 }
5240 if( $update_delivery_days ) $this->options['delivery_days'] = $delivery_days;
5241
5242 if( $update_shipping_charge or $update_delivery_days )
5243 update_option('usces', $this->options);
5244 }
5245 //20120710ysk end
5246 function get_item_cat_ids(){
5247 $args = array('child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0, 'hierarchical' => 0);
5248 $categories = get_categories( $args );
5249 foreach($categories as $category){
5250 $ids[] = $category->term_id;
5251 }
5252 return $ids;
5253 }
5254
5255 function get_item_post_ids(){
5256 global $wpdb;
5257 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5258 $ids = $wpdb->get_col( $query );
5259
5260 return $ids;
5261 }
5262
5263 function get_item_cat_genre_ids( $post_id ){
5264 $ids = array();
5265 $all_ids = array();
5266 $genre = get_category_by_slug( 'itemgenre' );
5267 $genre_id = $genre->term_id;
5268 $args = array('child_of' => $genre_id, 'hide_empty' => 0, 'hierarchical' => 0);
5269 $categories = get_categories( $args );
5270 foreach($categories as $category){
5271 $ids[] = $category->term_id;
5272 }
5273 $allcats = get_the_category( $post_id );
5274 foreach($allcats as $cat){
5275 $all_ids[] = $cat->term_id;
5276 }
5277 //$all_ids =
5278 $results = array_intersect($ids, $all_ids);
5279
5280 return $results;
5281 }
5282
5283 function set_item_mime($post_id, $str)
5284 {
5285 global $wpdb;
5286 if( WCUtils::is_blank($str) ) return;
5287
5288 $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id);
5289 $results = $wpdb->query( $query );
5290 return $results;
5291 }
5292
5293 function isAdnminSSL()
5294 {
5295 $plugins = get_option('active_plugins');
5296 foreach($plugins as $plugin) {
5297 if( false !== strpos($plugin, USCES_ADMIN_SSL_BASE_NAME) )
5298 return true;
5299 }
5300 return false;
5301 }
5302
5303 function getGuidTax() {
5304 $tax_rate = (int)$this->options['tax_rate'];
5305 if ( 0 < $tax_rate )
5306 $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>';
5307 else
5308 $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>';
5309
5310 return apply_filters('usces_filter_tax_guid', $str, $tax_rate);
5311 }
5312
5313 function getItemCode($post_id) {
5314 $str = get_post_meta($post_id, '_itemCode', true);
5315 return $str;
5316 }
5317
5318 function getItemName($post_id) {
5319 $str = get_post_meta($post_id, '_itemName', true);
5320 return $str;
5321 }
5322
5323 function getItemRestriction($post_id) {
5324 $str = get_post_meta($post_id, '_itemRestriction', true);
5325 return $str;
5326 }
5327
5328 function getItemPointrate($post_id) {
5329 $str = get_post_meta($post_id, '_itemPointrate', true);
5330 return $str;
5331 }
5332
5333 function getItemShipping($post_id) {
5334 $str = get_post_meta($post_id, '_itemShipping', true);
5335 return $str;
5336 }
5337
5338 function getItemShippingCharge($post_id) {
5339 $str = get_post_meta($post_id, '_itemShippingCharge', true);
5340 return (float)$str;
5341 }
5342
5343 function getItemDeliveryMethod($post_id) {
5344 $str = get_post_meta($post_id, '_itemDeliveryMethod', true);
5345 if( empty($str) )
5346 return array();
5347 else
5348 return $str;
5349 }
5350
5351 function getItemIndividualSCharge($post_id) {
5352 $str = get_post_meta($post_id, '_itemIndividualSCharge', true);
5353 return $str;
5354 }
5355
5356 function getItemGpNum1($post_id) {
5357 $str = get_post_meta($post_id, '_itemGpNum1', true);
5358 return $str;
5359 }
5360
5361 function getItemGpNum2($post_id) {
5362 $str = get_post_meta($post_id, '_itemGpNum2', true);
5363 return $str;
5364 }
5365
5366 function getItemGpNum3($post_id) {
5367 $str = get_post_meta($post_id, '_itemGpNum3', true);
5368 return $str;
5369 }
5370
5371 function getItemGpDis1($post_id) {
5372 $str = get_post_meta($post_id, '_itemGpDis1', true);
5373 return $str;
5374 }
5375
5376 function getItemGpDis2($post_id) {
5377 $str = get_post_meta($post_id, '_itemGpDis2', true);
5378 return $str;
5379 }
5380
5381 function getItemGpDis3($post_id) {
5382 $str = get_post_meta($post_id, '_itemGpDis3', true);
5383 return $str;
5384 }
5385
5386 function getItemSku($post_id, $index = '') {
5387 $array = array();
5388 $skus = $this->get_skus($post_id, 'sort');
5389 foreach((array)$skus as $sku){
5390 $array[] = $sku['code'];
5391 }
5392 if(!$array) return false;
5393 if($index == ''){
5394 return $array;
5395 }else if(isset($array[$index])){
5396 return $array[$index];
5397 }else{
5398 return false;
5399 }
5400 }
5401
5402 function getItemPrice($post_id, $skukey = '') {
5403 $array = array();
5404 $skus = $this->get_skus($post_id, 'code');
5405 foreach((array)$skus as $key => $sku){
5406 $array[$key] = (float)str_replace('.', '', $sku['price']);
5407 }
5408 if(!$array) return false;
5409 if($skukey == ''){
5410 return $array;
5411 }else if(isset($array[$skukey])){
5412 return $array[$skukey];
5413 }else{
5414 return false;
5415 }
5416 }
5417
5418 function getItemDiscount($post_id, $skukey = '') {
5419 $display_mode = $this->options['display_mode'];
5420 $array = array();
5421 $skus = $this->get_skus($post_id, 'code');
5422 foreach((array)$skus as $key => $sku){
5423 $price = (float)str_replace(',', '', $sku['price']);
5424 if ( $display_mode == 'Promotionsale' ) {
5425 if ( $this->options['campaign_privilege'] == 'discount' ){
5426 if( 0 === (int)$this->options['campaign_category'] || in_category((int)$this->options['campaign_category'], $post_id) ){
5427 $discount = $price * $this->options['privilege_discount'] / 100;
5428 }else{
5429 $discount = 0;
5430 }
5431 }else if ( $this->options['campaign_privilege'] == 'point' ){
5432 $discount = 0;
5433 }
5434 }
5435
5436 $discount = ceil($discount);
5437 $array[$key] = $discount;
5438 }
5439 if(!$array) return false;
5440 if($skukey == ''){
5441 return $array;
5442 }else if(isset($array[$skukey])){
5443 return $array[$skukey];
5444 }else{
5445 return false;
5446 }
5447 }
5448
5449 function getItemZaiko($post_id, $skukey = '') {
5450 $array = array();
5451 $skus = $this->get_skus($post_id, 'code');
5452 foreach((array)$skus as $key => $sku){
5453 $num = $sku['stock'];
5454 $array[$key] = $this->zaiko_status[$num];
5455 }
5456 if(!$array) return false;
5457 if($skukey == ''){
5458 return $array;
5459 }else if(isset($array[$skukey])){
5460 return $array[$skukey];
5461 }else{
5462 return false;
5463 }
5464 }
5465
5466 function getItemZaikoStatusId($post_id, $skukey = '') {
5467 $array = array();
5468 $skus = $this->get_skus($post_id, 'code');
5469 foreach((array)$skus as $key => $sku){
5470 $num = $sku['stock'];
5471 $array[$key] = $num;
5472 }
5473 if(!$array) return false;
5474 if($skukey == ''){
5475 return $array;
5476 }else if(isset($array[$skukey])){
5477 return $array[$skukey];
5478 }else{
5479 return false;
5480 }
5481 }
5482
5483 function updateItemZaiko($post_id, $skucode, $value) {
5484 $res = usces_update_sku( $post_id, $skucode, 'stock', $value );
5485 if( !$res ){
5486 return false;
5487 }else{
5488 return true;
5489 }
5490 }
5491
5492 function getItemZaikoNum($post_id, $skukey = '') {
5493 $array = array();
5494 $skus = $this->get_skus($post_id, 'code');
5495 foreach((array)$skus as $key => $sku){
5496 $array[$key] = $sku['stocknum'];
5497 }
5498 if(!$array) return false;
5499 if($skukey == ''){
5500 return $array;
5501 }else if(isset($array[$skukey])){
5502 return $array[$skukey];
5503 }else{
5504 return false;
5505 }
5506 }
5507
5508 function updateItemZaikoNum($post_id, $skucode, $value) {
5509 $res = usces_update_sku( $post_id, $skucode, 'stocknum', $value );
5510 if( !$res ){
5511 return false;
5512 }else{
5513 return true;
5514 }
5515 }
5516 //20120629ysk start 0000520
5517 function getItemDivision( $post_id ){
5518 if( usces_is_item($post_id) ){
5519 $item_division = get_post_meta($post_id, '_item_division', true);
5520 $division = empty($item_division) ? 'shipped' : $item_division;
5521 }else{
5522 $division = NULL;
5523 }
5524 return $division;
5525 }
5526 //20120629ysk end
5527 function getItemChargingType( $post_id, $cart = array() ){
5528 if( usces_is_item($post_id) ){
5529 $charging = get_post_meta($post_id, '_item_charging_type', true);
5530 //if( !defined('WCEX_DLSELLER') )
5531 if( !defined('WCEX_DLSELLER') and !defined('WCEX_AUTO_DELIVERY') )
5532 $charging = NULL;
5533 }else{
5534 $charging = NULL;
5535 }
5536 switch( $charging ){
5537 case 0:
5538 $type = 'once';
5539 break;
5540 case 1:
5541 $type = 'continue';
5542 break;
5543 case 2:
5544 $type = 'regular';
5545 if( !empty($cart) ) {
5546 if( empty($cart['advance']) ) {
5547 $type = 'once';
5548 } else {
5549 $advance = $this->cart->wc_unserialize( $cart['advance'] );
5550 $sku = urldecode( $cart['sku'] );
5551 $regular = $advance[$post_id][$sku]['regular'];
5552 $unit = isset( $regular['unit'] ) ? $regular['unit'] : '';
5553 $interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0;
5554 if( empty($unit) or 1 > $interval ) //通常課金扱い
5555 $type = 'once';
5556 }
5557 }
5558 break;
5559 default:
5560 $type = NULL;
5561 }
5562 return $type;
5563 }
5564
5565 function getItemFrequency( $post_id ){
5566 $frequency = get_post_meta($post_id, '_item_frequency',true );
5567 return $frequency;
5568 }
5569
5570 function getItemChargingDay( $post_id ){
5571 $array = get_post_meta($post_id, '_item_chargingday',true );
5572 $day = (int)$array;
5573 $chargingday = empty($day) ? 1 : $day;
5574 return $chargingday;
5575 }
5576
5577 function getItemSkuDisp($post_id, $skukey = '') {
5578 $array = array();
5579 $skus = $this->get_skus($post_id, 'code');
5580 foreach((array)$skus as $key => $sku){
5581 $array[$key] = $sku['name'];
5582 }
5583 if(!$array) return false;
5584 if($skukey == ''){
5585 return $array;
5586 }else if(isset($array[$skukey])){
5587 return $array[$skukey];
5588 }else{
5589 return false;
5590 }
5591 }
5592
5593 // function getItemSkuChargingType($post_id, $skukey = '') {
5594 // $fields = get_post_custom($post_id);
5595 // $skus = array();
5596 // foreach((array)$fields as $key => $value){
5597 // if( preg_match('/^_isku_/', $key, $match) ){
5598 // $key = substr($key, 6);
5599 // $values = maybe_unserialize($value[0]);
5600 // if( isset($values['charging_type']) && "undefined" != $values['charging_type'] && !empty($values['charging_type']) ){
5601 // $skus[$key] = $values['charging_type'];
5602 // }else{
5603 // continue;
5604 // }
5605 // }
5606 // }
5607 // if( empty($skus) ) return false;
5608 // if($skukey == ''){
5609 // return $skus;
5610 // }elseif( isset($skus[$skukey]) ){
5611 // return $skus[$skukey];
5612 // }else{
5613 // return false;
5614 // }
5615 // }
5616
5617 function getItemSkuUnit($post_id, $skukey = '') {
5618 $array = array();
5619 $skus = $this->get_skus($post_id, 'code');
5620 foreach((array)$skus as $key => $sku){
5621 $array[$key] = $sku['unit'];
5622 }
5623 if(!$array) return false;
5624 if($skukey == ''){
5625 return $array;
5626 }else if(isset($array[$skukey])){
5627 return $array[$skukey];
5628 }else{
5629 return false;
5630 }
5631 }
5632
5633 function get_item( $post_id ) {
5634 $usces_item['post_id'] = $post_id;
5635 $usces_item['itemCode'] = $this->getItemCode($post_id);
5636 $usces_item['itemName'] = $this->getItemName($post_id);
5637
5638 $skus = $this->get_skus($post_id, 'code');
5639 foreach((array)$skus as $key => $sku){
5640 $usces_item['skuCodes'][] = $key;
5641 $usces_item['skuValues'][] = $sku;
5642 }
5643
5644 $usces_item = apply_filters('usces_filter_get_item', $usces_item, $post_id);
5645
5646 return $usces_item;
5647 }
5648
5649 function get_itemOptionKey( $post_id, $enc = false ) {
5650 $opts = usces_get_opts( $post_id );
5651 if(empty($opts)) return;
5652
5653 $res = array();
5654 foreach ( (array)$opts as $opt ) {
5655 if( $enc )
5656 $res[] = urlencode($opt['name']);
5657 else
5658 $res[] = $opt['name'];
5659 }
5660 return $res;
5661 }
5662
5663 function get_itemOptions( $key, $post_id ) {
5664 $opts = usces_get_opts( $post_id, 'name' );
5665 if(empty($opts[$key]))
5666 return;
5667 else
5668 return $opts[$key];
5669 }
5670
5671 function get_postIDbyCode( $itemcode ) {
5672 global $wpdb;
5673
5674 $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_itemCode', $itemcode);
5675 $res = $wpdb->get_var( $query );
5676 return $res;
5677 }
5678
5679 function get_pictids($item_code) {
5680 global $wpdb, $usces;
5681
5682 if( empty($item_code) )
5683 return false;
5684
5685 if( !$usces->options['system']['subimage_rule'] ){
5686 $codestr = $item_code.'%';
5687 $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);
5688 }else{
5689 $codestr = $item_code.'--%';
5690 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr);
5691 }
5692 $results = $wpdb->get_col( $query );
5693 return $results;
5694 }
5695
5696 function get_mainpictid($item_code) {
5697 global $wpdb;
5698 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $item_code);
5699 $id = $wpdb->get_var( $query );
5700 $id = apply_filters( 'usces_filter_get_mainpictid', $id, $item_code );
5701 return $id;
5702 }
5703
5704 function get_skus( $post_id, $keyflag = 'sort' ) {
5705 if( !$post_id )
5706 return array();
5707
5708 $skus = array();
5709 $metas = usces_get_post_meta($post_id, '_isku_');
5710 if( empty($metas) ) return $skus;
5711
5712 foreach( $metas as $rows ){
5713 $values = unserialize($rows['meta_value']);
5714 $key = isset($values[$keyflag]) ? $values[$keyflag] : $values['sort'];
5715 $skus[$key] = array(
5716 'meta_id' => $rows['meta_id'],
5717 'code' => $values['code'],
5718 'name' => $values['name'],
5719 'cprice' => $values['cprice'],
5720 'price' => $values['price'],
5721 'unit' => $values['unit'],
5722 'stocknum' => $values['stocknum'],
5723 'stock' => $values['stock'],
5724 'gp' => $values['gp'],
5725 'sort' => $values['sort'],
5726 'advance' => isset($values['advance']) ? $values['advance'] : ''
5727 );
5728 }
5729 $skus = apply_filters( 'usces_filter_get_skus', $skus, $post_id, $keyflag );
5730 ksort($skus);
5731
5732 return $skus;
5733 }
5734
5735 function is_item( $post ) {
5736
5737 if( $post->post_mime_type == 'item' )
5738 return true;
5739 else
5740 return false;
5741 }
5742
5743 function getItemIds( $end_type ) {
5744 global $wpdb;
5745 if( 'front' == $end_type )
5746 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item');
5747 if( 'back' == $end_type )
5748 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5749 $ids = $wpdb->get_col( $query );
5750 if( empty($ids) ) $ids = array();
5751 return $ids;
5752 }
5753
5754 function getNotItemIds() {
5755 global $wpdb;
5756 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item');
5757 $ids = $wpdb->get_col( $query );
5758 if( empty($ids) ) $ids = array();
5759 return $ids;
5760 }
5761
5762 function getPaymentMethod( $name ) {
5763 $res = array();
5764 $payments = $this->options['payment_method'];
5765 foreach ( (array)$payments as $payment ) {
5766 if($name = $payment['name']) {
5767 $res = $payment;
5768 break;
5769 }
5770 }
5771 return $res;
5772 }
5773
5774 function order_processing( $results = array() ) {
5775 do_action('usces_pre_reg_orderdata');
5776 //db(function.php)
5777 //20110203ysk start
5778 $res = usces_check_acting_return_duplicate( $results );
5779 if($res != NULL) {
5780 usces_log('order processing duplicate : acting='.$_REQUEST['acting'].', order_id='.$res, 'acting_transaction.log');
5781 return 'ordercompletion';
5782 }
5783 if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) {
5784 usces_log($_REQUEST['acting'].' transaction : '.$_REQUEST['gid'], 'acting_transaction.log');//OK
5785 }
5786 //20110203ysk end
5787 //20110621ysk start 0000184
5788 if(isset($_REQUEST['acting']) && ('paypal_ec' == $_REQUEST['acting'])) {
5789 if( !usces_paypal_doecp( $results ) )
5790 return 'error';
5791 }
5792 //20110621ysk end
5793 $order_id = usces_reg_orderdata( $results );
5794 do_action('usces_post_reg_orderdata', $order_id, $results);
5795
5796 if ( $order_id ) {
5797 //mail(function.php)
5798 $mail_res = usces_send_ordermail( $order_id );
5799 return 'ordercompletion';
5800
5801 } else {
5802 return 'error';
5803 }
5804
5805 }
5806
5807 function acting_processing($acting_flg, $query) {
5808 global $wpdb;
5809 $entry = $this->cart->get_entry();
5810 $delim = apply_filters( 'usces_filter_delim', $this->delim );
5811 $acting_flg = trim($acting_flg);
5812 //$usces_entries = $this->cart->get_entry();
5813
5814 if( empty($acting_flg) ) return 'error';
5815
5816
5817 //include(USCES_PLUGIN_DIR . '/settlement/' . $acting_flg);
5818 if($acting_flg == 'paypal.php'){
5819 // if( !file_exists($this->options['settlement_path'] . $acting_flg) )
5820 // return 'error';
5821 //
5822 // require_once($this->options['settlement_path'] . "paypal.php");
5823 // paypal_submit();
5824
5825 }else if($acting_flg == 'epsilon.php'){
5826 if( !file_exists($this->options['settlement_path'] . $acting_flg) )
5827 return 'error';
5828
5829 if ( $this->use_ssl ) {
5830 $redirect = str_replace('http://', 'https://', USCES_CART_URL);
5831 }else{
5832 $redirect = USCES_CART_URL;
5833 }
5834 usces_log('epsilon card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5835 $query .= '&settlement=epsilon&redirect_url=' . urlencode($redirect);
5836 $query = $delim . ltrim($query, '&');
5837 header("location: " . $redirect . $query);
5838 exit;
5839
5840 }else if($acting_flg == 'acting_zeus_card' && 2 == $this->options['acting_settings']['zeus']['connection'] ){
5841 if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] ){
5842 if( !isset($_REQUEST['PaRes'])){
5843
5844 usces_log('zeus card entry data2 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5845 usces_zeus_3dsecure_enrol();
5846
5847 }else{
5848
5849 usces_log('zeus card : auth', 'acting_transaction.log');
5850 usces_zeus_3dsecure_auth();
5851 }
5852 }else{
5853 usces_log('zeus card no3d : payreq', 'acting_transaction.log');
5854 $res = usces_zeus_secure_payreq();
5855 return $res;
5856 }
5857 }else if($acting_flg == 'acting_zeus_card' && 1 == $this->options['acting_settings']['zeus']['connection'] ){
5858
5859 $acting_opts = $this->options['acting_settings']['zeus'];
5860 $interface = parse_url($acting_opts['card_url']);
5861
5862 //usces_log('zeus card ***** : '.print_r($entry, true), 'acting_transaction.log');
5863
5864 $vars = 'send=mall';
5865 $vars .= '&clientip=' . $acting_opts['clientip'];
5866 $vars .= '&cardnumber=' . $_POST['cardnumber'];
5867 if( 1 == $this->options['acting_settings']['zeus']['security'] ){
5868 $vars .= '&seccode=' . $_POST['securecode'];
5869 }
5870 $vars .= '&expyy=' . substr($_POST['expyy'], 2);
5871 $vars .= '&expmm=' . $_POST['expmm'];
5872 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
5873 $vars .= '&email=' . $_POST['email'];
5874 $vars .= '&sendid=' . $_POST['sendid'];
5875 $vars .= '&username=' . $_POST['username'];
5876 $vars .= '&money=' . $_POST['money'];
5877 $vars .= '&sendpoint=' . $_POST['sendpoint'];
5878 $vars .= '&printord=' . $_POST['printord'];
5879 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
5880 $vars .= '&div=' . $_POST['div'];
5881 }
5882
5883 //usces_log('zeus card *****vars : '.print_r($vars, true), 'acting_transaction.log');
5884
5885 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
5886 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
5887 //$header .= "Host: usctest.securesites.com\r\n";
5888 $header .= "User-Agent: PHP Script\r\n";
5889 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
5890 $header .= "Content-Length: " . strlen($vars) . "\r\n";
5891 $header .= "Connection: close\r\n\r\n";
5892 $header .= $vars;
5893 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
5894
5895 if ($fp){
5896 fwrite($fp, $header);
5897 while ( !feof($fp) ) {
5898 $scr = fgets($fp, 1024);
5899 $page .= $scr;
5900 }
5901 fclose($fp);
5902
5903 //usces_log('zeus card *****2 : '.print_r($page, true), 'acting_transaction.log');
5904 if( false !== strpos( $page, 'Success_order') ){
5905 usces_log('zeus card entry data1 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5906 $ordd = usces_get_order_number( $page );
5907 //20120904ysk start 0000541
5908 if ( !isset($_POST['cbrand']) || (isset($_POST['howpay']) && 1 == $_POST['howpay']) ) {
5909 $args = '';
5910 } else {
5911 $div = 'div_'.$_POST['cbrand'];
5912 $args = '&cbrand='.$_POST['cbrand'].'&howpay='.$_POST['howpay'].'&'.$div.'='.$_POST[$div];
5913 }
5914 $args .= '&order_number=' . $ordd . '&wctid='.$_POST['sendpoint'];
5915 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=1'.$args);
5916 //20120904ysk end
5917 exit;
5918 }else{
5919 usces_log('zeus card : Certification Error', 'acting_transaction.log');
5920 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
5921 exit;
5922 }
5923 }else{
5924 usces_log('zeus card : Socket Error', 'acting_transaction.log');
5925 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
5926 }
5927 exit;
5928
5929 }else if($acting_flg == 'acting_zeus_conv'){
5930
5931 $acting_opts = $this->options['acting_settings']['zeus'];
5932 $interface = parse_url($acting_opts['conv_url']);
5933
5934
5935 $vars .= 'clientip=' . $acting_opts['clientip_conv'];
5936 $vars .= '&act=' . $_POST['act'];
5937 $vars .= '&money=' . $_POST['money'];
5938 $vars .= '&username=' . mb_convert_encoding($_POST['username'], 'SJIS', 'UTF-8');
5939 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
5940 $vars .= '&email=' . $_POST['email'];
5941 $vars .= '&pay_cvs=' . $_POST['pay_cvs'];
5942 $vars .= '&sendid=' . $_POST['sendid'];
5943 $vars .= '&sendpoint=' . $_POST['sendpoint'];
5944 if( !WCUtils::is_blank($acting_opts['testid_conv']) ){
5945 $vars .= '&testid=' . $acting_opts['testid_conv'];
5946 $vars .= '&test_type=' . $acting_opts['test_type_conv'];
5947 }
5948
5949
5950 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
5951 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
5952 $header .= "User-Agent: PHP Script\r\n";
5953 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
5954 $header .= "Content-Length: " . strlen($vars) . "\r\n";
5955 $header .= "Connection: close\r\n\r\n";
5956 $header .= $vars;
5957 //usces_log('zeus conv header : '.print_r($header, true), 'acting_transaction.log');
5958 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
5959
5960 if ($fp){
5961 fwrite($fp, $header);
5962 while ( !feof($fp) ) {
5963 $scr = fgets($fp, 1024);
5964 $page .= $scr;
5965 if( false !== strpos( $scr, 'order_no') )
5966 $qstr .= trim($scr) . '&';
5967 if( false !== strpos( $scr, 'pay_no1') )
5968 $qstr .= trim($scr) . '&';
5969 if( false !== strpos( $scr, 'pay_no2') )
5970 $qstr .= trim($scr) . '&';
5971 if( false !== strpos( $scr, 'pay_limit') )
5972 $qstr .= trim($scr) . '&';
5973 if( false !== strpos( $scr, 'pay_url') )
5974 $qstr .= trim($scr) . '&';
5975 if( false !== strpos( $scr, 'error_code') )
5976 $qstr .= trim($scr) . '&';
5977 if( false !== strpos( $scr, 'sendpoint') )
5978 $qstr .= trim($scr) . '&';
5979 }
5980 $qstr .= 'pay_cvs=' . $_POST['pay_cvs'].'&wctid='.$_POST['sendpoint'];
5981 fclose($fp);
5982 //usces_log('zeus page : '.$page, 'acting_transaction.log');
5983
5984 if( false !== strpos( $page, 'Success_order') ){
5985 usces_log('zeus conv entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5986 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=1&' . $qstr);
5987 exit;
5988 }else{
5989 usces_log('zeus data NG : '.$page, 'acting_transaction.log');
5990 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
5991 exit;
5992 }
5993 }else{
5994 usces_log('zeus : sockopen NG', 'acting_transaction.log');
5995 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
5996 }
5997 exit;
5998
5999 //20110208ysk start
6000 }else if($acting_flg == 'acting_paypal_ec') {
6001 $acting_opts = $this->options['acting_settings']['paypal'];
6002
6003 $nvpstr = $query;
6004 $nvpstr .= '&CURRENCYCODE='.$this->get_currency_code();
6005 //$nvpstr .= '&ADDROVERRIDE=1';
6006 $nvpstr .= '&PAYMENTACTION=' . apply_filters('usces_filter_paypal_ec_paymentaction', 'Sale');
6007
6008 //The returnURL is the location where buyers return to when a payment has been succesfully authorized.
6009 $nvpstr .= '&RETURNURL='.urlencode(USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=1');
6010
6011 //The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow
6012 $nvpstr .= '&CANCELURL='.urlencode(USCES_CART_URL.$delim.'confirm=1');
6013
6014 $nvpstr .= '&NOTIFYURL='.urlencode(USCES_PAYPAL_NOTIFY_URL);
6015
6016 $this->paypal->setMethod('SetExpressCheckout');
6017 $this->paypal->setData($nvpstr);
6018 $res = $this->paypal->doExpressCheckout();
6019 $resArray = $this->paypal->getResponse();
6020 $ack = strtoupper($resArray["ACK"]);
6021 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
6022 $token = urldecode($resArray["TOKEN"]);
6023 $payPalURL = $acting_opts['paypal_url'].'?cmd=_express-checkout&token='.$token.'&useraction=commit';
6024 header("Location: ".$payPalURL);
6025
6026 } else {
6027 //Display a user friendly Error on the page using any of the following error information returned by PayPal
6028 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
6029 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
6030 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
6031 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
6032 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');
6033 header("Location: ".USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=0');
6034 }
6035 exit;
6036 //20110208ysk end
6037 //20121030ysk start
6038 } elseif( $acting_flg == 'acting_telecom_edy' ) {
6039 $table_meta_name = $wpdb->prefix."usces_order_meta";
6040 $value = array();
6041 $value['usces_cart'] = $_SESSION['usces_cart'];
6042 $value['usces_entry'] = $_SESSION['usces_entry'];
6043 $value['usces_member'] = $_SESSION['usces_member'];
6044 $mvalue = serialize( $value );
6045 $mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue );
6046 $res = $wpdb->query( $mquery );
6047
6048 unset( $_SESSION['usces_cart'] );
6049 unset( $_SESSION['usces_entry'] );
6050
6051 $acting_opts = $this->options['acting_settings']['telecom'];
6052 header( "location: ".$acting_opts['send_url_edy'].'?acting=telecom_edy'.$query );
6053 exit;
6054 //20121030ysk end
6055 //20121206ysk start
6056 } else if( $acting_flg == 'acting_digitalcheck_card' ) {
6057 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6058 $interface = parse_url($acting_opts['send_url_user_id']);
6059 $kakutei = ( empty($acting_opts['card_kakutei']) ) ? '0' : $acting_opts['card_kakutei'];
6060
6061 $vars = 'IP='.$acting_opts['card_ip'];
6062 $vars .= '&PASS='.$acting_opts['card_pass'];
6063 $vars .= '&IP_USER_ID='.$_POST['IP_USER_ID'];
6064 $vars .= '&SID='.$_POST['SID'];
6065 $vars .= '&STORE=51';
6066 $vars .= '&N1='.$_POST['N1'];
6067 $vars .= '&K1='.$_POST['K1'];
6068 $vars .= '&KAKUTEI='.$kakutei;
6069 $vars .= '&FUKA='.$acting_flg;
6070
6071 $header = "POST ".$interface['path']." HTTP/1.1\r\n";
6072 $header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
6073 $header .= "User-Agent: PHP Script\r\n";
6074 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6075 $header .= "Content-Length: ".strlen($vars)."\r\n";
6076 $header .= "Connection: close\r\n\r\n";
6077 $header .= $vars;
6078 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6079
6080 if( $fp ) {
6081 fwrite( $fp, $header );
6082 $page = '';
6083 while( !feof($fp) ) {
6084 $line = fgets( $fp, 1024 );
6085 if( strcmp($line, "\r\n") == 0 ) {
6086 $headerdone = true;
6087 } elseif( $headerdone ) {
6088 $page .= $line;
6089 }
6090 }
6091 fclose($fp);
6092 $lines = explode("\n", $page);
6093 if( false !== strpos( $lines[0], 'OK') ) {
6094 usces_log('digitalcheck card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6095 //$args = '&SID='.$lines[1];
6096 $args = '&SID='.$_POST['SID'].'&FUKA='.$acting_flg;
6097 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=1'.$args );
6098 } else {
6099 usces_log('digitalcheck card : Certification Error : '.$page, 'acting_transaction.log');
6100 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6101 }
6102 } else {
6103 usces_log('digitalcheck card : Socket Error', 'acting_transaction.log');
6104 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6105 }
6106 exit;
6107 } else if( $acting_flg == 'acting_digitalcheck_conv' ) {
6108 if( isset($_REQUEST['STORE']) and '99' != $_REQUEST['STORE'] ) {
6109 $res = $this->order_processing();
6110 if( 'ordercompletion' == $res ) {
6111 $table_meta_name = $wpdb->prefix."usces_order_meta";
6112 $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] );
6113 $order_id = $wpdb->get_var($mquery);
6114 if( $order_id ) {
6115 $data = array( "settltment_status" => "未決済", "settltment_errmsg" => "決済が完了していません" );
6116 $this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
6117 }
6118 $this->cart->crear_cart();
6119 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6120 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6121 exit;
6122 } else {
6123 usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
6124 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=0' );
6125 }
6126 } else {
6127 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6128 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6129 exit;
6130 }
6131 //20121206ysk end
6132 }
6133 do_action('usces_action_acting_processing', $acting_flg, $query);
6134 }
6135
6136 function inquiry_processing() {
6137
6138 $mail_res = usces_send_inquirymail();
6139
6140 if ( $mail_res )
6141 return 'inquiry_comp';
6142 else
6143 return 'inquiry_error';
6144 }
6145
6146 function lastprocessing() {
6147
6148 if ( $this->page == 'ordercompletion' )
6149 $this->cart->crear_cart();
6150
6151 unset($_SESSION['usces_singleitem']);
6152
6153 }
6154
6155 function is_item_zaiko( $post_id, $sku ){
6156 $status_num = (int)$this->getItemZaikoStatusId($post_id, $sku);
6157 $zaiko_num = $this->getItemZaikoNum($post_id, $sku);
6158
6159 if( false !== $zaiko_num
6160 && ( 0 < (int)$zaiko_num || WCUtils::is_blank($zaiko_num) )
6161 && false !== $status_num
6162 && 2 > $status_num
6163 ){
6164 return true;
6165 }else{
6166 return false;
6167 }
6168 }
6169
6170 // function for the cart ***********************************************************
6171 function get_total_price( $cart = array() ) {
6172 if( empty($cart) )
6173 $cart = $this->cart->get_cart();
6174
6175 $total_price = 0;
6176
6177 if( !empty($cart) ) {
6178 for($i=0; $i<count($cart); $i++) {
6179 $quantity = $cart[$i]['quantity'];
6180 $skuPrice = $cart[$i]['price'];
6181
6182 $total_price += ($skuPrice * $quantity);
6183 }
6184 }
6185 return apply_filters( 'usces_filter_get_total_price', $total_price, $cart);
6186 }
6187
6188 function get_total_quantity( $cart = array() ) {
6189 if( empty($cart) )
6190 $cart = $this->cart->get_cart();
6191
6192 $total_quantity = 0;
6193
6194 if( !empty($cart) ) {
6195 for($i=0; $i<count($cart); $i++) {
6196 $total_quantity += $cart[$i]['quantity'];
6197 }
6198 }
6199 return $total_quantity;
6200 }
6201
6202 function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) {
6203 if( $mem_id == '' || $this->options['membersystem_state'] == 'deactivate' || $this->options['membersystem_point'] == 'deactivate') return 0;
6204
6205 if ( empty($cart) )
6206 $cart = $this->cart->get_cart();
6207
6208 if ( empty($display_mode) )
6209 $display_mode = $this->options['display_mode'];
6210
6211 $point = 0;
6212 $total = $this->get_total_price( $cart );
6213 if ( $display_mode == 'Promotionsale' ) {
6214 if ( $this->options['campaign_privilege'] == 'discount' ) {
6215 foreach ( $cart as $rows ) {
6216 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6217 if ( !in_array($this->options['campaign_category'], $cats) ){
6218 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6219 $price = $rows['price'] * $rows['quantity'];
6220 $point += $price * $rate / 100;
6221 }
6222 }
6223 } elseif ( $this->options['campaign_privilege'] == 'point' ) {
6224 foreach ( $cart as $rows ) {
6225 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6226 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6227 $price = $rows['price'] * $rows['quantity'];
6228 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6229 if ( in_array($this->options['campaign_category'], $cats) )
6230 $point += $price * $rate / 100 * $this->options['privilege_point'];
6231 else
6232 $point += $price * $rate / 100;
6233 }
6234 }
6235 } else {
6236 foreach ( $cart as $rows ) {
6237 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6238 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6239 $price = $rows['price'] * $rows['quantity'];
6240 $point += $price * $rate / 100;
6241 }
6242 }
6243
6244 //20130425ysk start 0000699
6245 if( 0 < $point ) $point = ceil( $point );
6246
6247 $entry = $this->cart->get_entry();
6248 $use_point = isset( $entry['order']['usedpoint'] ) ? (int)$entry['order']['usedpoint'] : 0;
6249 if( 0 < $use_point ) {
6250 $point = ceil( $point - ( $point * $use_point / $total ) );
6251 if( 0 > $point )
6252 $point = 0;
6253 }
6254
6255 return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart );
6256 //20130425ysk end
6257 }
6258
6259 function get_order_discount( $display_mode = '', $cart = array() ) {
6260 if ( empty($cart) )
6261 $cart = $this->cart->get_cart();
6262
6263 if ( empty($display_mode) )
6264 $display_mode = $this->options['display_mode'];
6265
6266 $discount = 0;
6267 $total = $this->get_total_price( $cart );
6268 if ( $display_mode == 'Promotionsale' ) {
6269 if ( $this->options['campaign_privilege'] == 'discount' ){
6270 if( 0 === (int)$this->options['campaign_category'] ){
6271 $discount = $total * $this->options['privilege_discount'] / 100;
6272 }else{
6273 foreach($cart as $cart_row){
6274 if( in_category((int)$this->options['campaign_category'], $cart_row['post_id']) ){
6275 $discount += $cart_row['price'] * $cart_row['quantity'] * $this->options['privilege_discount'] / 100;
6276 }
6277 }
6278 }
6279 }else if ( $this->options['campaign_privilege'] == 'point' ){
6280 $discount = 0;
6281 }
6282 }
6283
6284 $discount = ceil($discount * -1);
6285 $discount = apply_filters('usces_order_discount', $discount, $cart);
6286 return $discount;
6287 }
6288
6289 function getShippingCharge( $pref, $cart = array(), $entry = array() ) {
6290 if( empty($cart) )
6291 $cart = $this->cart->get_cart();
6292 if( empty($entry) )
6293 $entry = $this->cart->get_entry();
6294
6295 //�
6296 �送方法ID
6297 $d_method_id = $entry['order']['delivery_method'];
6298 //�
6299 �送方法index
6300 $d_method_index = $this->get_delivery_method_index($d_method_id);
6301 //送料ID
6302 $fixed_charge_id = ( isset($this->options['delivery_method'][$d_method_index]['charge']) ) ? $this->options['delivery_method'][$d_method_index]['charge'] : -1;
6303 $individual_quant = 0;
6304 $total_quant = 0;
6305 $charges = array();
6306 $individual_charges = array();
6307 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
6308
6309 foreach ( $cart as $rows ) {
6310
6311 if( -1 == $fixed_charge_id ){
6312 //商品送料ID
6313 $s_charge_id = $this->getItemShippingCharge($rows['post_id']);
6314 //商品送料index
6315 $s_charge_index = $this->get_shipping_charge_index($s_charge_id);
6316 //20120710ysk start 0000472
6317 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6318 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6319 //20120710ysk end
6320 }else{
6321
6322 $s_charge_index = $this->get_shipping_charge_index($fixed_charge_id);
6323 //20120710ysk start 0000472
6324 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6325 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6326 //20120710ysk end
6327 }
6328
6329 if($this->getItemIndividualSCharge($rows['post_id'])){
6330 $individual_quant += $rows['quantity'];
6331 $individual_charges[] = $rows['quantity'] * $charge;
6332 }else{
6333 $charges[] = $charge;
6334 }
6335 $total_quant += $rows['quantity'];
6336 }
6337
6338 if( count($charges) > 0 ){
6339 rsort($charges);
6340 $max_charge = $charges[0];
6341 $charge = $max_charge + array_sum($individual_charges);
6342 }else{
6343 $charge = array_sum($individual_charges);
6344 }
6345
6346 $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
6347
6348 return $charge;
6349 }
6350
6351 function getCODFee($payment_name, $amount_by_cod) {
6352 $payments = $this->getPayments($payment_name);
6353 if( 'COD' != $payments['settlement'] ){
6354 $fee = 0;
6355
6356 }else if( 'change' != $this->options['cod_type'] ){
6357 //$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : '';
6358 $fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : 0;
6359
6360 }else{
6361 $price = $amount_by_cod + $this->getTax( $amount_by_cod );
6362 if( $price <= $this->options['cod_first_amount'] ){
6363 $fee = $this->options['cod_first_fee'];
6364
6365 }else if( isset($this->options['cod_amounts']) ){
6366 $last = count( $this->options['cod_amounts'] ) - 1;
6367 if( $price > $this->options['cod_amounts'][$last] ){
6368 $fee = $this->options['cod_end_fee'];
6369
6370 }else{
6371 $fee = 0;
6372 foreach( $this->options['cod_amounts'] as $key => $value ){
6373 if( $price <= $value ){
6374 $fee = $this->options['cod_fees'][$key];
6375 break;
6376 }
6377 }
6378 }
6379 }else{
6380 $fee = $this->options['cod_end_fee'];
6381 }
6382 }
6383 $fee = apply_filters('usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod);
6384 return $fee;
6385 }
6386
6387 function getTax( $total ) {
6388 if( empty($this->options['tax_rate']) )
6389 return 0;
6390
6391 if( $this->options['tax_method'] == 'cutting' )
6392 $tax = floor($total * $this->options['tax_rate'] / 100);
6393 elseif($this->options['tax_method'] == 'bring')
6394 $tax = ceil($total * $this->options['tax_rate'] / 100);
6395 elseif($this->options['tax_method'] == 'rounding')
6396 $tax = round($total * $this->options['tax_rate'] / 100);
6397
6398 return $tax;
6399 }
6400
6401 function set_cart_fees( $member, &$entries ) {
6402 $carts = $this->cart->get_cart();
6403 $total_items_price = $this->get_total_price();
6404 if ( empty($this->options['postage_privilege']) || $total_items_price < $this->options['postage_privilege'] ) {
6405 $shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'] );
6406 } else {
6407 $shipping_charge = 0;
6408 }
6409 $shipping_charge = apply_filters('usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries);
6410 $payments = $this->getPayments( $entries['order']['payment_name'] );
6411 $discount = $this->get_order_discount();
6412 $use_point = $entries['order']['usedpoint'];
6413 $amount_by_cod = $total_items_price - $use_point + $discount + $shipping_charge;
6414 $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);
6415 $cod_fee = $this->getCODFee($entries['order']['payment_name'], $amount_by_cod);
6416 $cod_fee = apply_filters('usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge);
6417 $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
6418 $total_price = apply_filters('usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee);
6419 $tax = $this->getTax( $total_price );
6420 $total_full_price = $total_price + $tax;
6421 $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);
6422 $get_point = $this->get_order_point( $member['ID'] );
6423 //20130425ysk start 0000699
6424 //if(0 < (int)$use_point){
6425 // $get_point = ceil( $get_point - ($get_point * $use_point / $total_items_price) );
6426 // if(0 > $get_point)
6427 // $get_point = 0;
6428 //}
6429 //20130425ysk end
6430
6431 $array = array(
6432 'total_items_price' => $total_items_price,
6433 'total_price' => $total_price,
6434 'total_full_price' => $total_full_price,
6435 'getpoint' => $get_point,
6436 'usedpoint' => $use_point,
6437 'discount' => $discount,
6438 'shipping_charge' => $shipping_charge,
6439 'cod_fee' => $cod_fee,
6440 'tax' => $tax
6441 );
6442 $this->cart->set_order_entry( $array );
6443 //$entries = $this->cart->get_entry();
6444 //var_dump($entries);
6445 }
6446
6447 function getPayments( $payment_name ) {
6448 if( '#none#' == $payment_name )
6449 return NULL;
6450
6451 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
6452 if( isset($payments[$payment_name]) )
6453 return $payments[$payment_name];
6454 return NULL;
6455 }
6456
6457 function is_maintenance() {
6458 if ( $this->options['display_mode'] == 'Maintenancemode' )
6459 return true;
6460 else
6461 return false;
6462 }
6463
6464 // function maintenance_mode() {
6465 // if ( $this->is_maintenance() && !is_user_logged_in() && (!strstr($_SERVER['REQUEST_URI'], 'wp-admin') || !strstr($_SERVER['REQUEST_URI'], 'wp-login') ) ) {
6466 // include ( TEMPLATEPATH . '/maintenance.php ');
6467 // exit;
6468 // } elseif ( isset($_GET['uscesmode']) && $_GET['uscesmode'] == 'lostpassword' ) {
6469 // $error = isset($_GET['error']) ? '?error='.$_GET['error'] : '';
6470 // include ( TEMPLATEPATH . '/member/changepassword.php ');
6471 // exit;
6472 // }
6473 // }
6474
6475 function get_member_history($mem_id) {
6476 global $wpdb;
6477 $order_table = $wpdb->prefix . "usces_order";
6478
6479 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
6480 $query = apply_filters( 'usces_filter_member_history_query', $query, $mem_id );
6481 // $query = $wpdb->prepare("SELECT ID, order_cart, order_condition, order_date, order_usedpoint, order_getpoint,
6482 // order_discount, order_shipping_charge, order_cod_fee, order_tax, order_status
6483 // FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
6484 $results = $wpdb->get_results( $query );
6485
6486 $i=0;
6487 $res = array();
6488 foreach ( $results as $value ) {
6489 if(strpos($value->order_status, 'cancel') === false && strpos($value->order_status, 'estimate') === false){
6490
6491 $res[] = array(
6492 'ID' => $value->ID,
6493 'cart' => unserialize($value->order_cart),
6494 'condition' => unserialize($value->order_condition),
6495 'getpoint' => $value->order_getpoint,
6496 'usedpoint' => $value->order_usedpoint,
6497 'discount' => $value->order_discount,
6498 'shipping_charge' => $value->order_shipping_charge,
6499 'payment_name' => $value->order_payment_name,
6500 'cod_fee' => $value->order_cod_fee,
6501 'tax' => $value->order_tax,
6502 'order_status' => $value->order_status,
6503 'date' => mysql2date(__('Y/m/d'), $value->order_date),
6504 'order_date' => $value->order_date
6505 );
6506 $i++;
6507
6508 }
6509 }
6510
6511 return $res;
6512
6513 }
6514
6515 function get_post_term_ids( $post_id, $taxonomy ){
6516 global $wpdb;
6517 $query = $wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_relationships AS tr
6518 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
6519 WHERE tt.taxonomy = %s AND tr.object_id = %d", $taxonomy, $post_id);
6520 $ids = $wpdb->get_col( $query );
6521
6522 return $ids;
6523
6524 }
6525
6526 function get_tag_names($post_id) {
6527 global $wpdb;
6528 $tag = 'post_tag';
6529 $query = $wpdb->prepare("SELECT t.name FROM $wpdb->term_relationships AS tr
6530 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
6531 INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id
6532 WHERE tt.taxonomy = %s AND tr.object_id = %d", $tag, $post_id);
6533 $names = $wpdb->get_col( $query );
6534
6535 return apply_filters('usces_filter_get_tag_names', $names, $post_id);
6536
6537 }
6538
6539 function get_ID_byItemName($itemname, $status = 'publish') {
6540 global $wpdb;
6541 $meta_key = '_itemCode';
6542 $query = $wpdb->prepare("SELECT p.ID FROM $wpdb->posts AS p
6543 INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id
6544 WHERE p.post_status = %s AND pm.meta_key = %s AND meta_value = %s ", $status, $meta_key, $itemname);
6545 $id = $wpdb->get_var( $query );
6546
6547 // $wpdb->show_errors();
6548 // $wpdb->print_error();
6549
6550 return $id;
6551
6552 }
6553
6554 function uscescv( $sessid, $flag ) {
6555
6556 $chars = '';
6557 $i=0;
6558 $h=0;
6559 $usces_cookie = $this->get_cookie();
6560 if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
6561 $cid = $usces_cookie['id'];
6562 }elseif( isset($_SESSION['usces_cookieid']) && !empty($_SESSION['usces_cookieid']) ){
6563 $cid = $_SESSION['usces_cookieid'];
6564 }else{
6565 $cid = 0;
6566 }
6567 while($h<strlen($sessid)){
6568 if(0 == $i % 3){
6569 $chars .= substr($i, -1);
6570 }else{
6571 $chars .= substr($sessid, $h, 1);
6572 $h++;
6573 }
6574 $i++;
6575 }
6576 if( $flag ){
6577 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
6578 $postfix = apply_filters('usces_sessid_force', $postfix);
6579 $sessid = $chars . '_' . $postfix . '_' . $cid . '_A';
6580 }else{
6581 $sessid = $chars . '_' . apply_filters('usces_sessid_flag', 'acting') . '_' . $cid . '_A';
6582 }
6583 $sessid = urlencode(base64_encode($sessid));
6584 //usces_log('sessid2 : '.$sessid, 'acting_transaction.log');
6585
6586 return $sessid;
6587 }
6588
6589 function uscesdc( $sessid ) {
6590 // $usces_cookie = $this->get_cookie();
6591 // if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
6592 // if( isset($usces_cookie['sslid']) && !empty($usces_cookie['sslid']) ){
6593 // $cid = $usces_cookie['sslid'];
6594 // }else{
6595 // $cid = 0;
6596 // }
6597 // }else{
6598 // if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
6599 // $cid = $usces_cookie['id'];
6600 // }else{
6601 // $cid = 0;
6602 // }
6603 // }
6604 $sessid = base64_decode(urldecode($sessid));
6605 list($sess, $addr, $cookieid, $none) = explode('_', $sessid, 4);
6606 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
6607 $postfix = apply_filters('usces_sessid_force', $postfix);
6608 //usces_log('cid : '.$cid, 'acting_transaction.log');
6609 //usces_log('cookieid : '.$cookieid, 'acting_transaction.log');
6610 //usces_log('postfix : '.$postfix, 'acting_transaction.log');
6611 //usces_log('addr : '.$addr, 'acting_transaction.log');
6612 if( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) {
6613 $sessid = '';
6614 return NULL;
6615 }
6616 $chars = '';
6617 $h=0;
6618 while($h<strlen($sess)){
6619 if(0 != $h % 3){
6620 $chars .= substr($sess, $h, 1);
6621 }
6622 $h++;
6623 }
6624 $sessid = $chars;
6625
6626 return $sessid;
6627
6628 }
6629
6630 function get_visiter( $period ) {
6631 global $wpdb;
6632 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6633 $yearstr = substr($datestr, 0, 4);
6634 $monthstr = substr($datestr, 5, 2);
6635 $daystr = substr($datestr, 8, 2);
6636 if($period == 'today') {
6637 $date = $datestr;
6638 $today = $datestr;
6639 }else if($period == 'thismonth') {
6640 $date = date('Y-m-01');
6641 $today = $datestr;
6642 }else if($period == 'lastyear') {
6643 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6644 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
6645 }
6646 $table_name = $wpdb->prefix . 'usces_access';
6647
6648 $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);
6649 $res = $wpdb->get_row($query, ARRAY_A);
6650
6651 if( $res == NULL )
6652 return 0;
6653 else
6654 return $res['ct1']+$res['ct2'];
6655 }
6656
6657 function get_fvisiter( $period ) {
6658 global $wpdb;
6659 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6660 $yearstr = substr($datestr, 0, 4);
6661 $monthstr = substr($datestr, 5, 2);
6662 $daystr = substr($datestr, 8, 2);
6663 if($period == 'today') {
6664 $date = $datestr;
6665 $today = $datestr;
6666 }else if($period == 'thismonth') {
6667 $date = date('Y-m-01');
6668 $today = $datestr;
6669 }else if($period == 'lastyear') {
6670 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6671 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
6672 }
6673 $table_name = $wpdb->prefix . 'usces_access';
6674
6675 $query = $wpdb->prepare("SELECT SUM(acc_num2) AS ct FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today);
6676 $res = $wpdb->get_var($query);
6677
6678 if( $res == NULL )
6679 return 0;
6680 else
6681 return $res;
6682 }
6683
6684 function get_order_num( $period ) {
6685 global $wpdb;
6686 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6687 $yearstr = substr($datestr, 0, 4);
6688 $monthstr = substr($datestr, 5, 2);
6689 $daystr = substr($datestr, 8, 2);
6690 if($period == 'today') {
6691 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
6692 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6693 }else if($period == 'thismonth') {
6694 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
6695 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6696 }else if($period == 'lastyear') {
6697 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6698 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
6699 }
6700 $table_name = $wpdb->prefix . 'usces_order';
6701
6702 $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');
6703 $res = $wpdb->get_var($query);
6704
6705 if( $res == NULL )
6706 return 0;
6707 else
6708 return $res;
6709 }
6710
6711 function get_order_amount( $period ) {
6712 global $wpdb;
6713 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6714 $yearstr = substr($datestr, 0, 4);
6715 $monthstr = substr($datestr, 5, 2);
6716 $daystr = substr($datestr, 8, 2);
6717 if($period == 'today') {
6718 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
6719 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6720 }else if($period == 'thismonth') {
6721 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
6722 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6723 }else if($period == 'lastyear') {
6724 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6725 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
6726 }
6727 $table_name = $wpdb->prefix . 'usces_order';
6728
6729 $query = $wpdb->prepare("SELECT
6730 SUM(order_item_total_price) AS price,
6731 SUM(order_usedpoint) AS point,
6732 SUM(order_discount) AS discount,
6733 SUM(order_shipping_charge) AS shipping,
6734 SUM(order_cod_fee) AS cod,
6735 SUM(order_tax) AS tax
6736 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');
6737 $res = $wpdb->get_row($query, ARRAY_A);
6738
6739 if( $res == NULL )
6740 return 0;
6741 else
6742 return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax'];
6743 }
6744
6745 function is_status($need, $str){
6746 $array = explode(',', $str);
6747 return in_array($need, $array);
6748 }
6749
6750 function make_status( $taio='', $receipt='', $admin='' ){
6751 $str = '';
6752 if($taio != '' && $taio != '#none#')
6753 $str .= $taio . ',';
6754 if($receipt != '' && $receipt != '#none#')
6755 $str .= $receipt . ',';
6756 if($admin != '' && $admin != '#none#')
6757 $str .= $admin . ',';
6758 return $str;
6759 }
6760
6761 function get_memberid_by_email($email){
6762 global $wpdb;
6763 $table_name = $wpdb->prefix . "usces_member";
6764 $query = $wpdb->prepare("SELECT ID FROM $table_name WHERE mem_email = %s", $email);
6765 $res = $wpdb->get_var($query);
6766 return $res;
6767 }
6768
6769 function get_condition(){
6770 //20120807ysk start 0000544
6771 $order_conditions = array(
6772 'display_mode' => $this->options['display_mode'],
6773 'campaign_privilege' => $this->options['campaign_privilege'],
6774 'campaign_category' => $this->options['campaign_category'],
6775 'privilege_point' => $this->options['privilege_point'],
6776 'privilege_discount' => $this->options['privilege_discount']);
6777 return $order_conditions;
6778 //20120807ysk end
6779 }
6780
6781 function get_bestseller_ids( $days = "" ){
6782 global $wpdb;
6783 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6784 $yearstr = substr($datestr, 0, 4);
6785 $monthstr = substr($datestr, 5, 2);
6786 $daystr = substr($datestr, 8, 2);
6787 $res = array();
6788 $order_table_name = $wpdb->prefix . "usces_order";
6789 $where = "";
6790 if( empty($days) ){
6791 $days = 30;
6792 }
6793 $order_date = date('Y-m-d H:i:s', mktime(0, 0, 0, (int)$monthstr, ((int)$daystr-$days), (int)$yearstr));
6794 $where = " WHERE order_date >= '{$order_date}'";
6795 $query = "SELECT order_cart FROM {$order_table_name}" . $where;
6796 $dbres = $wpdb->get_col($query);
6797 if(!$dbres) return false;
6798
6799 foreach((array)$dbres as $carts){
6800 $rows = unserialize($carts);
6801 foreach((array)$rows as $carts){
6802 if( 'publish' != get_post_status($carts['post_id']) )
6803 continue;
6804
6805 $id = $carts['post_id'];
6806 $qu = $carts['quantity'];
6807 if(array_key_exists($id, $res)){
6808 $res[$id] = $res[$id] + $qu;
6809 }else{
6810 $res[$id] = $qu;
6811 }
6812 }
6813 }
6814 arsort($res);
6815 $results = array_keys($res);
6816 return $results;
6817 }
6818
6819 function get_items_num(){
6820 global $wpdb;
6821 $query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM {$wpdb->posts}
6822 WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
6823 'item', 'post', 'trush');
6824 $res = $wpdb->get_var($query);
6825
6826 return $res;
6827 }
6828
6829 function is_gptekiyo( $post_id, $sku, $quant ) {
6830 $skus = $this->get_skus( $post_id, 'code' );
6831 if( !isset($skus[$sku]['gp']) || !$skus[$sku]['gp'] ) return false;
6832
6833 $GpN1 = $this->getItemGpNum1($post_id);
6834 $GpN2 = $this->getItemGpNum2($post_id);
6835 $GpN3 = $this->getItemGpNum3($post_id);
6836
6837 if( empty($GpN1) ) {
6838
6839 return false;
6840
6841 }else if( !empty($GpN1) && empty($GpN2) ) {
6842
6843 if( $quant >= $GpN1 ) {
6844 return true;
6845 }else{
6846 return false;
6847 }
6848
6849 }else if( !empty($GpN1) && !empty($GpN2) && empty($GpN3) ) {
6850
6851 if( $quant >= $GpN2 ) {
6852 return true;
6853 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
6854 return true;
6855 }else{
6856 return false;
6857 }
6858
6859 }else if( !empty($GpN1) && !empty($GpN2) && !empty($GpN3) ) {
6860
6861 if( $quant >= $GpN3 ) {
6862 return true;
6863 }else if( $quant >= $GpN2 && $quant < $GpN3 ) {
6864 return true;
6865 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
6866 return true;
6867 }else{
6868 return false;
6869 }
6870 }
6871 }
6872
6873 function get_available_delivery_method() {
6874 if($this->cart->num_row() > 0) {
6875 $cart = $this->cart->get_cart();
6876 $before_deli = array();
6877 $intersect = array();
6878 $integration = array();
6879 $temp = array();
6880 $in = 0;
6881 foreach($cart as $key => $row){
6882 $deli = $this->getItemDeliveryMethod($row['post_id']);
6883 //usces_p($deli);
6884 if( empty($deli))
6885 continue;
6886
6887 //usces_log('deli : '.print_r($deli, true), 'acting_transaction.log');
6888 if( 0 === $in ){
6889 $intersect = $deli;
6890 }
6891 $intersect = array_intersect($deli, $intersect);
6892 $before_deli = $deli;
6893 foreach($deli as $value){
6894 $integration[] = $value;
6895 }
6896 $in++;
6897 }
6898 $integration = array_unique($integration);
6899 foreach($integration as $id){
6900 $index = $this->get_delivery_method_index($id);
6901 $temp[$index] = $id;
6902 }
6903 ksort($temp);
6904 //20120820ysk start 0000546
6905 //$force = array($temp[0]);
6906 $force = array(array_shift($temp));
6907 //20120820ysk end
6908
6909 if( empty($intersect) ){
6910 return $force;
6911 }else{
6912 return $intersect;
6913 }
6914 }
6915 return array();
6916 }
6917
6918 function get_delivery_method_index($id) {
6919 $index = false;
6920 for($i=0; $i<count($this->options['delivery_method']); $i++){
6921 if( $this->options['delivery_method'][$i]['id'] === (int)$id ){
6922 $index = $i;
6923 }
6924 }
6925 if($index === false)
6926 return -1;
6927 else
6928 return $index;
6929 }
6930
6931 function get_shipping_charge_index($id) {
6932 $index = false;
6933 for($i=0; $i<count($this->options['shipping_charge']); $i++){
6934 //20120710ysk start 0000472
6935 //if( $this->options['shipping_charge'][$i]['id'] === $id ){
6936 if( (int)$this->options['shipping_charge'][$i]['id'] == (int)$id ){
6937 //20120710ysk end
6938 $index = $i;
6939 }
6940 }
6941 if($index === false)
6942 return -1;
6943 else
6944 return $index;
6945 }
6946
6947 function get_initial_data($xml){
6948 $buf = file_get_contents($xml);
6949 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);
6950 return $match;
6951 }
6952
6953 function getCurrencySymbol(){
6954 global $usces_settings;
6955 $cr = $this->options['system']['currency'];
6956 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
6957 return $symbol;
6958 }
6959
6960 function getCartItemName($post_id, $sku){
6961 $name_arr = array();
6962 $name_str = '';
6963
6964 foreach($this->options['indi_item_name'] as $key => $value){
6965 if($value){
6966 $pos = (int)$this->options['pos_item_name'][$key];
6967 $ind = ($pos === 0) ? 'A' : $pos;
6968 switch($key){
6969 case 'item_name':
6970 $name_arr[$ind][$key] = $this->getItemName($post_id);
6971 break;
6972 case 'item_code':
6973 $name_arr[$ind][$key] = $this->getItemCode($post_id);
6974 break;
6975 case 'sku_name':
6976 $name_arr[$ind][$key] = $this->getItemSkuDisp($post_id, $sku);
6977 break;
6978 case 'sku_code':
6979 $name_arr[$ind][$key] = $sku;
6980 break;
6981 }
6982 }
6983
6984 }
6985 ksort($name_arr);
6986 foreach($name_arr as $vals){
6987 foreach($vals as $key => $value){
6988
6989 $name_str .= $value . ' ';
6990 }
6991 }
6992
6993 $name_str = apply_filters('usces_admin_order_item_name_filter', $name_str);
6994
6995 return trim($name_str);
6996 }
6997
6998 function set_reserve_pre_order_id(){
6999 $entry = $this->cart->get_entry();
7000 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : uniqid('');
7001 $this->cart->set_pre_order_id($id);
7002 }
7003
7004 function get_current_pre_order_id(){
7005 $entry = $this->cart->get_entry();
7006 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : NULL;
7007 return $id;
7008 }
7009
7010 function get_reserve($order_id, $key){
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
7019 //20100818ysk start
7020 //20100816ysk start
7021 //function get_order_meta($order_id, $key) {
7022 function get_order_meta_value($key, $order_id) {
7023 global $wpdb;
7024 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7025 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7026 $order_id, $key);
7027 $res = $wpdb->get_var($query);
7028 return $res;
7029 }
7030 //20100816ysk end
7031 function set_order_meta_value($key, $meta_value, $order_id) {
7032 global $wpdb;
7033
7034 //if( empty($meta_value) ) return;
7035 if( empty($order_id) ) return;
7036
7037 $table_name = $wpdb->prefix . "usces_order_meta";
7038 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s",
7039 $order_id, $key);
7040 $res = $wpdb->get_var($query);
7041 if(0 < $res) {
7042 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s",
7043 $meta_value,
7044 $order_id,
7045 $key
7046 );
7047 $res2 = $wpdb->query($query);
7048 } else {
7049 $query = $wpdb->prepare("INSERT INTO $table_name (order_id, meta_key, meta_value)
7050 VALUES(%d, %s, %s)",
7051 $order_id,
7052 $key,
7053 $meta_value
7054 );
7055 $res2 = $wpdb->query($query);
7056 }
7057 return $res2;
7058 }
7059 //20130524ysk start
7060 function del_order_meta( $key, $order_id ) {
7061 global $wpdb;
7062 $table_name = $wpdb->prefix."usces_order_meta";
7063 $query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
7064 $res = $wpdb->query( $query );
7065 return $res;
7066 }
7067 //20130524ysk end
7068 function set_session_custom_member($member_id) {
7069 unset($_SESSION['usces_member']['custom_member']);
7070 $meta = usces_has_custom_field_meta('member');
7071 if(is_array($meta)) {
7072 $keys = array_keys($meta);
7073 foreach($keys as $key) {
7074 $csmb_key = 'csmb_'.$key;
7075 $_SESSION['usces_member']['custom_member'][$key] = maybe_unserialize($this->get_member_meta_value($csmb_key, $member_id));
7076 }
7077 }
7078 }
7079
7080 function reg_custom_member($member_id) {
7081 //20130524ysk start 0000712
7082 $csmb_meta = usces_has_custom_field_meta( 'member' );
7083 if( is_array($csmb_meta) ) {
7084 foreach( $csmb_meta as $key => $entry ) {
7085 if( '4' == $entry['means'] ) {
7086 $this->del_member_meta( 'csmb_'.$key, $member_id );
7087 }
7088 }
7089 }
7090 //20130524ysk end
7091 if( !empty($_POST['custom_member']) ) {
7092 foreach( $_POST['custom_member'] as $key => $value ) {
7093 $csmb_key = 'csmb_'.$key;
7094 if( is_array($value) )
7095 $value = serialize($value);
7096 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7097 if(false === $res)
7098 return false;
7099 }
7100 }elseif( isset($_POST['custom_customer']) ){
7101 foreach( $_POST['custom_customer'] as $key => $value ) {
7102 $csmb_key = 'csmb_'.$key;
7103 if( is_array($value) )
7104 $value = serialize($value);
7105 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7106 if(false === $res)
7107 return false;
7108 }
7109 }
7110 }
7111 //20100818ysk end
7112
7113 function save_order_acting_data($rand){
7114 global $wpdb;
7115 $data = serialize(array( 'cart' => $this->cart->get_cart(), 'entry' => $this->cart->get_entry() ));
7116 $table_name = $wpdb->prefix . "usces_access";
7117 $query = $wpdb->prepare("INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value)
7118 VALUES(%s, %s, now(), %s, %s)",
7119 'acting_data',
7120 $this->get_uscesid(false),
7121 $rand,
7122 $data
7123 );
7124 $res = $wpdb->query($query);
7125 return $res;
7126 }
7127
7128 //20100818ysk start
7129 function set_member_meta_value($key, $meta_value, $member_id = ''){
7130 global $wpdb;
7131
7132 //if( empty($meta_value) ) return;
7133 if( WCUtils::is_blank($member_id) ) {
7134 if( !$this->is_member_logged_in() ) return;
7135 $member = $this->get_member();
7136 $member_id = $member['ID'];
7137 }
7138
7139 $table_name = $wpdb->prefix . "usces_member_meta";
7140 //$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7141 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s",
7142 $member_id, $key);
7143 $res = $wpdb->get_var($query);
7144 //if($res != NULL){
7145 if(0 < $res){
7146 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s",
7147 $meta_value,
7148 $member_id,
7149 $key
7150 );
7151 $res2 = $wpdb->query($query);
7152 }else{
7153 $query = $wpdb->prepare("INSERT INTO $table_name (member_id, meta_key, meta_value)
7154 VALUES(%d, %s, %s)",
7155 $member_id,
7156 $key,
7157 $meta_value
7158 );
7159 $res2 = $wpdb->query($query);
7160 }
7161 return $res2;
7162 }
7163 //20100818ysk end
7164
7165 function get_member_meta_value($key, $member_id){
7166 global $wpdb;
7167 $table_name = $wpdb->prefix . "usces_member_meta";
7168 $query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7169 $member_id, $key);
7170 $res = $wpdb->get_var($query);
7171 return $res;
7172 }
7173
7174 function del_member_meta($key, $member_id){
7175 global $wpdb;
7176 $table_name = $wpdb->prefix . "usces_member_meta";
7177 $query = $wpdb->prepare("DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s",
7178 $member_id, $key);
7179 $res = $wpdb->query($query);
7180 return $res;
7181 }
7182
7183 function get_member_meta($member_id){
7184 global $wpdb;
7185 $table_name = $wpdb->prefix . "usces_member_meta";
7186 $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_%');
7187 $res = $wpdb->get_results($query, ARRAY_A);
7188 return $res;
7189 }
7190
7191 function get_settle_info_field( $order_id ){
7192 global $wpdb;
7193 $fields = array();
7194 $table_name = $wpdb->prefix . "usces_order_meta";
7195 $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)",
7196 $order_id, 'acting_%', 'settlement_id', 'order_number', 'res_tracking_id', 'SID');
7197 $res = $wpdb->get_results($query, ARRAY_A);
7198 if( !$res )
7199 return $fields;
7200
7201 foreach( $res as $value ){
7202 if( 'settlement_id' == $value['meta_key'] ){
7203 $meta_values = maybe_unserialize($value['meta_value']);
7204 if( is_array($meta_values) ){
7205 foreach( $meta_values as $key => $meta_value ){
7206 $fields[$key] = $meta_value;
7207 }
7208 }else{
7209 $fields['settlement_id'] = $meta_values;
7210 }
7211 }elseif( 'order_number' == $value['meta_key'] ){
7212 $fields['order_number'] = $value['meta_value'];
7213 }elseif( 'res_tracking_id' == $value['meta_key'] ){
7214 $fields['res_tracking_id'] = $value['meta_value'];
7215 }elseif( 'SID' == $value['meta_key'] ){
7216 $fields['SID'] = $value['meta_value'];
7217 }elseif( 'acting_' == substr($value['meta_key'], 0, 7) ){
7218 $meta_values = unserialize($value['meta_value']);
7219 if(is_array($meta_values)){
7220 foreach( $meta_values as $key => $meta_value ){
7221 $fields[$key] = $meta_value;
7222 }
7223 }
7224 }
7225 }
7226 return $fields;
7227 }
7228
7229 function get_post_custom($post_id, $orderby='meta_id', $order='ASC'){
7230 global $wpdb;
7231 $table = $wpdb->prefix . "postmeta";
7232 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7233 $post_id), ARRAY_A );
7234
7235 if ( !empty($meta_list) ) {
7236 foreach ( $meta_list as $metarow) {
7237 $mkey = $metarow['meta_key'];
7238 $mval = $metarow['meta_value'];
7239 $res[$mkey][] = $mval;
7240 }
7241 }
7242 return $res;
7243 }
7244
7245 function get_post_user_custom($post_id, $orderby='meta_id', $order='ASC'){
7246 global $wpdb;
7247 $res = array();
7248 $table = $wpdb->prefix . "postmeta";
7249 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7250 $post_id), ARRAY_A );
7251
7252 if ( !empty($meta_list) ) {
7253 foreach ( $meta_list as $metarow) {
7254 if( 0 === strpos($metarow['meta_key'], '_') )
7255 continue;
7256
7257 $mkey = $metarow['meta_key'];
7258 $mval = $metarow['meta_value'];
7259 if( array_key_exists($mkey, $res) ){
7260 $cval = $res[$mkey];
7261 $cval = (array)$cval;
7262 $cval[] = $mval;
7263 $res[$mkey] = $cval;
7264 }else{
7265 $res[$mkey] = $mval;
7266 }
7267 }
7268 }
7269 return $res;
7270 }
7271
7272 function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ){
7273 global $usces_settings;
7274 $cr = $this->options['system']['currency'];
7275 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7276 if( !$seperator_flag ){
7277 $seperator = '';
7278 }
7279 $price = number_format((double)$amount, $decimal, $point, $seperator);//0000652
7280
7281 if( $symbol_pre )
7282 $price = ( usces_is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol ) . $price;
7283
7284 if( $symbol_post )
7285 $price = $price . __($code, 'usces');
7286
7287 return $price;
7288 }
7289
7290 function get_currency_code(){
7291 global $usces_settings;
7292 $cr = $this->options['system']['currency'];
7293 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7294 return $code;
7295 }
7296
7297 //shortcode-----------------------------------------------------------------------------
7298 function sc_company_name() {
7299 return htmlspecialchars($this->options['company_name']);
7300 }
7301 function sc_zip_code() {
7302 return htmlspecialchars($this->options['zip_code']);
7303 }
7304 function sc_address1() {
7305 return htmlspecialchars($this->options['address1']);
7306 }
7307 function sc_address2() {
7308 return htmlspecialchars($this->options['address2']);
7309 }
7310 function sc_tel_number() {
7311 return htmlspecialchars($this->options['tel_number']);
7312 }
7313 function sc_fax_number() {
7314 return htmlspecialchars($this->options['fax_number']);
7315 }
7316 function sc_inquiry_mail() {
7317 return htmlspecialchars($this->options['inquiry_mail']);
7318 }
7319 function sc_payment() {
7320 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
7321 $htm = "<ul>\n";
7322 foreach ( (array)$payments as $payment ) {
7323 $htm .= "<li>" . htmlspecialchars($payment['name']) . "<br />\n";
7324 $htm .= nl2br(htmlspecialchars($payment['explanation'])) . "</li>\n";
7325 }
7326 $htm .= "</ul>\n";
7327 return $htm;
7328 }
7329 function sc_payment_title() {
7330 $payments = $this->options['payment_method'];
7331 $htm = "<ul>\n";
7332 foreach ( (array)$payments as $payment ) {
7333 $htm .= "<li>" . esc_html($payment['name']) . "</li>\n";
7334 }
7335 $htm .= "</ul>\n";
7336 return $htm;
7337 }
7338 function sc_cod_fee() {
7339 return number_format($this->options['cod_fee']);
7340 }
7341 function sc_start_point() {
7342 return number_format($this->options['start_point']);
7343 }
7344 function sc_postage_privilege() {
7345 if(empty($this->options['postage_privilege']))
7346 return;
7347 return number_format($this->options['postage_privilege']);
7348 }
7349 function sc_shipping_charge() {
7350 //20120710ysk start 0000472
7351 $entry = $this->cart->get_entry();
7352 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
7353 //20120710ysk end
7354 $arr = array();
7355 foreach ( (array)$this->options['shipping_charge'] as $charges ) {
7356 //20120710ysk start 0000472
7357 //foreach ( (array)$charges['value'] as $value ) {
7358 foreach ( (array)$charges[$country] as $value ) {
7359 //20120710ysk end
7360 $arr[] = $value;
7361 }
7362 }
7363 sort($arr);
7364 $min = $arr[0];
7365 rsort($arr);
7366 $max = $arr[0];
7367 if($min == $max){
7368 $res = number_format($min);
7369 }else{
7370 $res = number_format($min) . __(' - ', 'usces') . number_format($max);
7371 }
7372 return $res;
7373 }
7374 function sc_site_url() {
7375 return get_option('home');
7376 }
7377 function sc_button_to_cart($atts) {
7378 extract(shortcode_atts(array(
7379 'item' => '',
7380 'sku' => '',
7381 'value' => __('to the cart', 'usces'),
7382 'force' => 0,
7383 'quant' => 0,
7384 'opt' => 1,
7385 ), $atts));
7386
7387 $post_id = $this->get_ID_byItemName($item);
7388 $datas = $this->get_skus( $post_id, 'code' );
7389 $zaikonum = $datas[$sku]['stocknum'];
7390 $zaiko = $datas[$sku]['stock'];
7391 $gptekiyo = $datas[$sku]['gp'];
7392 $skuPrice = $datas[$sku]['price'];
7393 $sku_enc = urlencode($sku);
7394 $mats = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc');
7395 if( ! $this->is_item_zaiko( $post_id, $sku ) ){
7396 return '<div class="button_status">' . esc_html($this->zaiko_status[$zaiko]) . '</div>';
7397 }
7398
7399 $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n";
7400 $html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"{$zaikonum}\" />\n";
7401 $html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"{$zaiko}\" />\n";
7402 $html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"{$gptekiyo}\" />\n";
7403 $html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"{$skuPrice}\" />\n";
7404 if( 1 == $opt ){
7405 $html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' );
7406 }elseif( 2 == $opt ){
7407 $html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' );
7408 }
7409 if( $quant ){
7410 $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;}\" />";
7411 $html .= apply_filters('usces_filter_sc_itemQuant', $quant_field, $mats);
7412 }
7413 $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) . " />";
7414 $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
7415 if( $force )
7416 $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
7417 $html = apply_filters('usces_filter_single_item_inform', $html);
7418 $html .= "</form>";
7419 $html .= '<div class="error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";
7420
7421 return $html;
7422 }
7423
7424 function filter_itemPage($content){
7425 global $post;
7426 $html = '';
7427
7428 if( ($post->post_mime_type != 'item' || !is_single()) ) return $content;
7429 if( post_password_required($post) ) return $content;
7430
7431 $temp_path = apply_filters('usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php');
7432 include( $temp_path );
7433
7434 $content = apply_filters('usces_filter_itemPage', $html, $post->ID);
7435
7436 return $content;
7437 }
7438
7439 function filter_cartContent($content) {
7440 global $post;
7441 $html = '';
7442
7443 switch($this->page){
7444 case 'cart':
7445 $temp_path = apply_filters('usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php');
7446 include( $temp_path );
7447 break;
7448 case 'customer':
7449 $temp_path = apply_filters('usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php');
7450 include( $temp_path );
7451 break;
7452 case 'delivery':
7453 $temp_path = apply_filters('usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php');
7454 include( $temp_path );
7455 break;
7456 case 'confirm':
7457 $temp_path = apply_filters('usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php');
7458 include( $temp_path );
7459 break;
7460 case 'ordercompletion':
7461 $temp_path = apply_filters('usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php');
7462 include( $temp_path );
7463 break;
7464 case 'error':
7465 $temp_path = apply_filters('usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php');
7466 include( $temp_path );
7467 break;
7468 case 'maintenance':
7469 $temp_path = apply_filters('usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php');
7470 include( $temp_path );
7471 break;
7472 case 'search_item':
7473 $temp_path = apply_filters('usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php');
7474 include( $temp_path );
7475 break;
7476 case 'wp_search':
7477 if($post->post_mime_type == 'item'){
7478 $temp_path = apply_filters('usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php');
7479 include( $temp_path );
7480 }else{
7481 $html = $content;
7482 }
7483 break;
7484 default:
7485 $html = $content;
7486 }
7487
7488 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) )
7489 $html = str_replace('src="'.get_option('siteurl'), 'src="'.USCES_SSL_URL_ADMIN, $html);
7490
7491 $html = apply_filters('usces_filter_cartContent', $html);
7492
7493 $content = $html;
7494
7495 remove_filter('the_title', array($this, 'filter_cartTitle'));
7496
7497 return $content;
7498 }
7499
7500 function filter_cartTitle($title) {
7501
7502 if( $title == 'Cart' || $title == __('Cart', 'usces') ){
7503 switch($this->page){
7504 case 'cart':
7505 $newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces'));
7506 break;
7507 case 'customer':
7508 $newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces'));
7509 break;
7510 case 'delivery':
7511 $newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces'));
7512 break;
7513 case 'confirm':
7514 $newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces'));
7515 break;
7516 case 'ordercompletion':
7517 $newtitle = apply_filters('usces_filter_title_ordercompletion', __('Completion', 'usces'));
7518 break;
7519 case 'error':
7520 $newtitle = apply_filters('usces_filter_title_carterror', __('Error', 'usces'));
7521 break;
7522 case 'search_item':
7523 $newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces'));
7524 break;
7525 case 'maintenance':
7526 $newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces'));
7527 break;
7528 case 'login':
7529 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
7530 break;
7531 default:
7532 $newtitle = apply_filters('usces_filter_title_cart_default', $title);
7533 }
7534 }else{
7535 $newtitle = $title;
7536 }
7537
7538 $newtitle = apply_filters('usces_filter_cartTitle', $newtitle);
7539 return $newtitle;
7540 }
7541
7542 function action_cartFilter(){
7543 add_filter('the_title', array($this, 'filter_cartTitle'),20);
7544 add_filter('the_content', array($this, 'filter_cartContent'),20);
7545 }
7546
7547 function action_search_item(){
7548 include(TEMPLATEPATH . '/page.php');
7549 exit;
7550 }
7551
7552 function filter_memberContent($content) {
7553 global $post;
7554 $html = '';
7555
7556 if($this->options['membersystem_state'] == 'activate'){
7557
7558 if( $this->is_member_logged_in() ) {
7559
7560 $member_regmode = 'editmemberform';
7561 $temp_path = apply_filters('usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php');
7562 include( $temp_path );
7563
7564 } else {
7565
7566 switch($this->page){
7567 case 'login':
7568 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
7569 include( $temp_path );
7570 break;
7571 case 'lostmemberpassword':
7572 $temp_path = apply_filters('usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php');
7573 include( $temp_path );
7574 break;
7575 case 'changepassword':
7576 $temp_path = apply_filters('usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php');
7577 include( $temp_path );
7578 break;
7579 case 'newcompletion':
7580 case 'editcompletion':
7581 case 'lostcompletion':
7582 case 'changepasscompletion':
7583 $temp_path = apply_filters('usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php');
7584 include( $temp_path );
7585 break;
7586 case 'newmemberform':
7587 $member_form_title = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
7588 $member_regmode = 'newmemberform';
7589 $temp_path = apply_filters('usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php');
7590 include( $temp_path );
7591 break;
7592 default:
7593 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
7594 include( $temp_path );
7595 }
7596
7597 }
7598 }else{
7599 $html .= "<p>只今会員サービスは提供いたしておりません。</p>";
7600 }
7601
7602 $content = $html;
7603
7604 remove_filter('the_title', array($this, 'filter_memberTitle'));
7605
7606 return $content;
7607 }
7608
7609 function filter_memberTitle($title) {
7610
7611 if( $this->options['membersystem_state'] == 'activate' && ($title == 'Member' || $title == __('Membership', 'usces')) ){
7612 switch($this->page){
7613 case 'login':
7614 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
7615 break;
7616 case 'newmemberform':
7617 $newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
7618 break;
7619 case 'lostmemberpassword':
7620 $newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces'));
7621 break;
7622 case 'changepassword':
7623 $newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces'));
7624 break;
7625 case 'newcompletion':
7626 case 'editcompletion':
7627 case 'lostcompletion':
7628 case 'changepasscompletion':
7629 $newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Completion', 'usces'));
7630 break;
7631 case 'error':
7632 $newtitle = apply_filters('usces_filter_title_membererror', __('Error', 'usces'));
7633 break;
7634 default:
7635 $newtitle = apply_filters('usces_filter_title_member_default', $title);
7636 }
7637 }else{
7638 $newtitle = $title;
7639 }
7640
7641 $newtitle = apply_filters('usces_filter_memberTitle', $newtitle);
7642 return $newtitle;
7643 }
7644
7645 function action_memberFilter(){
7646 add_filter('the_title', array($this, 'filter_memberTitle'),20);
7647 add_filter('the_content', array($this, 'filter_memberContent'),20);
7648 }
7649
7650 function filter_usces_cart_css(){
7651 $path = get_stylesheet_directory_uri() . '/usces_cart.css';
7652 return $path;
7653 }
7654
7655 function filter_divide_item(){
7656 global $wp_query;
7657
7658
7659 if( ($this->options['divide_item'] && !is_category() && !is_search() && !is_singular() && !is_admin()) ){
7660 $ids = $this->getItemIds( 'front' );
7661 $wp_query->query_vars['post__not_in'] = $ids;
7662
7663 }
7664 if( is_admin() ){
7665 $ids = $this->getItemIds( 'back' );
7666 //$wp_query->query_vars['category__not_in'] = array(USCES_ITEM_CAT_PARENT_ID);
7667 $wp_query->query_vars['post__not_in'] = $ids;
7668 }
7669 do_action( 'usces_action_divide_item');
7670 }
7671
7672 function load_upload_template(){
7673 $post_id = $_POST['post_id'];
7674 $file = 'upload_template01.php';
7675 include(TEMPLATEPATH . '/' . $file);
7676 exit;
7677 }
7678
7679 function filter_itemimg_anchor_rel($html){
7680
7681 if( is_single() ){
7682 $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"';
7683 }else{
7684 $str = '';
7685 }
7686 return $html . $str;
7687 }
7688
7689 function filter_permalink( $link ) {
7690
7691 if(false !== strpos('?page_id=4', $link) || false !== strpos('?page_id=3', $link) || false !== strpos('usces-cart', $link) || false !== strpos('usces-member', $link) )
7692 $link = str_replace('http://', 'https://', $link);
7693
7694 return $link;
7695 }
7696
7697 function filter_cart_page_header($html){
7698 if( !empty($this->options['cart_page_data']['header']['cart']) ){
7699 $html = $this->options['cart_page_data']['header']['cart'];
7700 }
7701 return do_shortcode( stripslashes(nl2br($html)) );
7702 }
7703
7704 function filter_cart_page_footer($html){
7705 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
7706 $html = $this->options['cart_page_data']['footer']['cart'];
7707 }
7708 return do_shortcode( stripslashes(nl2br($html)) );
7709 }
7710
7711 function filter_customer_page_header($html){
7712 if( !empty($this->options['cart_page_data']['header']['customer']) ){
7713 $html = $this->options['cart_page_data']['header']['customer'];
7714 }
7715 return do_shortcode( stripslashes(nl2br($html)) );
7716 }
7717
7718 function filter_customer_page_footer($html){
7719 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
7720 $html = $this->options['cart_page_data']['footer']['customer'];
7721 }
7722 return do_shortcode( stripslashes(nl2br($html)) );
7723 }
7724
7725 function filter_delivery_page_header($html){
7726 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
7727 $html = $this->options['cart_page_data']['header']['delivery'];
7728 }
7729 return do_shortcode( stripslashes(nl2br($html)) );
7730 }
7731
7732 function filter_delivery_page_footer($html){
7733 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
7734 $html = $this->options['cart_page_data']['footer']['delivery'];
7735 }
7736 return do_shortcode( stripslashes(nl2br($html)) );
7737 }
7738
7739 function filter_confirm_page_header($html){
7740 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
7741 $html = $this->options['cart_page_data']['header']['confirm'];
7742 }
7743 return do_shortcode( stripslashes(nl2br($html)) );
7744 }
7745
7746 function filter_confirm_page_footer($html){
7747 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
7748 $html = $this->options['cart_page_data']['footer']['confirm'];
7749 }
7750 return do_shortcode( stripslashes(nl2br($html)) );
7751 }
7752
7753 function filter_cartcompletion_page_header($html){
7754 if( !empty($this->options['cart_page_data']['header']['completion']) ){
7755 $html = $this->options['cart_page_data']['header']['completion'];
7756 }
7757 return do_shortcode( stripslashes(nl2br($html)) );
7758 }
7759
7760 function filter_cartcompletion_page_footer($html){
7761 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
7762 $html = $this->options['cart_page_data']['footer']['completion'];
7763 }
7764 return do_shortcode( stripslashes(nl2br($html)) );
7765 }
7766
7767 function filter_login_page_header($html){
7768 if( !empty($this->options['member_page_data']['header']['login']) ){
7769 $html = $this->options['member_page_data']['header']['login'];
7770 }
7771 return do_shortcode( stripslashes(nl2br($html)) );
7772 }
7773
7774 function filter_login_page_footer($html){
7775 if( !empty($this->options['member_page_data']['footer']['login']) ){
7776 $html = $this->options['member_page_data']['footer']['login'];
7777 }
7778 return do_shortcode( stripslashes(nl2br($html)) );
7779 }
7780
7781 function filter_newmember_page_header($html){
7782 if( !empty($this->options['member_page_data']['header']['newmember']) ){
7783 $html = $this->options['member_page_data']['header']['newmember'];
7784 }
7785 return do_shortcode( stripslashes(nl2br($html)) );
7786 }
7787
7788 function filter_newmember_page_footer($html){
7789 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
7790 $html = $this->options['member_page_data']['footer']['newmember'];
7791 }
7792 return do_shortcode( stripslashes(nl2br($html)) );
7793 }
7794
7795 function filter_newpass_page_header($html){
7796 if( !empty($this->options['member_page_data']['header']['newpass']) ){
7797 $html = $this->options['member_page_data']['header']['newpass'];
7798 }
7799 return do_shortcode( stripslashes(nl2br($html)) );
7800 }
7801
7802 function filter_newpass_page_footer($html){
7803 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
7804 $html = $this->options['member_page_data']['footer']['newpass'];
7805 }
7806 return do_shortcode( stripslashes(nl2br($html)) );
7807 }
7808
7809 function filter_changepass_page_header($html){
7810 if( !empty($this->options['member_page_data']['header']['changepass']) ){
7811 $html = $this->options['member_page_data']['header']['changepass'];
7812 }
7813 return do_shortcode( stripslashes(nl2br($html)) );
7814 }
7815
7816 function filter_changepass_page_footer($html){
7817 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
7818 $html = $this->options['member_page_data']['footer']['changepass'];
7819 }
7820 return do_shortcode( stripslashes(nl2br($html)) );
7821 }
7822
7823 function filter_memberinfo_page_header($html){
7824 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
7825 $html = $this->options['member_page_data']['header']['memberinfo'];
7826 }
7827 return do_shortcode( stripslashes(nl2br($html)) );
7828 }
7829
7830 function filter_memberinfo_page_footer($html){
7831 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
7832 $html = $this->options['member_page_data']['footer']['memberinfo'];
7833 }
7834 return do_shortcode( stripslashes(nl2br($html)) );
7835 }
7836
7837 function filter_membercompletion_page_header($html){
7838 if( !empty($this->options['member_page_data']['header']['completion']) ){
7839 $html = $this->options['member_page_data']['header']['completion'];
7840 }
7841 return do_shortcode( stripslashes(nl2br($html)) );
7842 }
7843
7844 function filter_membercompletion_page_footer($html){
7845 if( !empty($this->options['member_page_data']['footer']['completion']) ){
7846 $html = $this->options['member_page_data']['footer']['completion'];
7847 }
7848 return do_shortcode( stripslashes(nl2br($html)) );
7849 }
7850
7851 function action_cart_page_header(){
7852 if( !empty($this->options['cart_page_data']['header']['cart']) ){
7853 $html = $this->options['cart_page_data']['header']['cart'];
7854 echo do_shortcode( stripslashes(nl2br($html)) );
7855 }
7856 }
7857
7858 function action_cart_page_footer(){
7859 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
7860 $html = $this->options['cart_page_data']['footer']['cart'];
7861 echo do_shortcode( stripslashes(nl2br($html)) );
7862 }
7863 }
7864
7865 function action_customer_page_header(){
7866 if( !empty($this->options['cart_page_data']['header']['customer']) ){
7867 $html = $this->options['cart_page_data']['header']['customer'];
7868 echo do_shortcode( stripslashes(nl2br($html)) );
7869 }
7870 }
7871
7872 function action_customer_page_footer(){
7873 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
7874 $html = $this->options['cart_page_data']['footer']['customer'];
7875 echo do_shortcode( stripslashes(nl2br($html)) );
7876 }
7877 }
7878
7879 function action_delivery_page_header(){
7880 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
7881 $html = $this->options['cart_page_data']['header']['delivery'];
7882 echo do_shortcode( stripslashes(nl2br($html)) );
7883 }
7884 }
7885
7886 function action_delivery_page_footer(){
7887 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
7888 $html = $this->options['cart_page_data']['footer']['delivery'];
7889 echo do_shortcode( stripslashes(nl2br($html)) );
7890 }
7891 }
7892
7893 function action_confirm_page_header(){
7894 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
7895 $html = $this->options['cart_page_data']['header']['confirm'];
7896 echo do_shortcode( stripslashes(nl2br($html)) );
7897 }
7898 }
7899
7900 function action_confirm_page_footer(){
7901 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
7902 $html = $this->options['cart_page_data']['footer']['confirm'];
7903 echo do_shortcode( stripslashes(nl2br($html)) );
7904 }
7905 }
7906
7907 function action_cartcompletion_page_header(){
7908 if( !empty($this->options['cart_page_data']['header']['completion']) ){
7909 $html = $this->options['cart_page_data']['header']['completion'];
7910 echo do_shortcode( stripslashes(nl2br($html)) );
7911 }
7912 }
7913
7914 function action_cartcompletion_page_footer(){
7915 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
7916 $html = $this->options['cart_page_data']['footer']['completion'];
7917 echo do_shortcode( stripslashes(nl2br($html)) );
7918 }
7919 }
7920
7921 function action_login_page_header(){
7922 if( !empty($this->options['member_page_data']['header']['login']) ){
7923 $html = $this->options['member_page_data']['header']['login'];
7924 echo do_shortcode( stripslashes(nl2br($html)) );
7925 }
7926 }
7927
7928 function action_login_page_footer(){
7929 if( !empty($this->options['member_page_data']['footer']['login']) ){
7930 $html = $this->options['member_page_data']['footer']['login'];
7931 echo do_shortcode( stripslashes(nl2br($html)) );
7932 }
7933 }
7934
7935 function action_newmember_page_header(){
7936 if( !empty($this->options['member_page_data']['header']['newmember']) ){
7937 $html = $this->options['member_page_data']['header']['newmember'];
7938 echo do_shortcode( stripslashes(nl2br($html)) );
7939 }
7940 }
7941
7942 function action_newmember_page_footer(){
7943 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
7944 $html = $this->options['member_page_data']['footer']['newmember'];
7945 echo do_shortcode( stripslashes(nl2br($html)) );
7946 }
7947 }
7948
7949 function action_newpass_page_header(){
7950 if( !empty($this->options['member_page_data']['header']['newpass']) ){
7951 $html = $this->options['member_page_data']['header']['newpass'];
7952 echo do_shortcode( stripslashes(nl2br($html)) );
7953 }
7954 }
7955
7956 function action_newpass_page_footer(){
7957 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
7958 $html = $this->options['member_page_data']['footer']['newpass'];
7959 echo do_shortcode( stripslashes(nl2br($html)) );
7960 }
7961 }
7962
7963 function action_changepass_page_header(){
7964 if( !empty($this->options['member_page_data']['header']['changepass']) ){
7965 $html = $this->options['member_page_data']['header']['changepass'];
7966 echo do_shortcode( stripslashes(nl2br($html)) );
7967 }
7968 }
7969
7970 function action_changepass_page_footer(){
7971 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
7972 $html = $this->options['member_page_data']['footer']['changepass'];
7973 echo do_shortcode( stripslashes(nl2br($html)) );
7974 }
7975 }
7976
7977 function action_memberinfo_page_header(){
7978 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
7979 $html = $this->options['member_page_data']['header']['memberinfo'];
7980 echo do_shortcode( stripslashes(nl2br($html)) );
7981 }
7982 }
7983
7984 function action_memberinfo_page_footer(){
7985 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
7986 $html = $this->options['member_page_data']['footer']['memberinfo'];
7987 echo do_shortcode( stripslashes(nl2br($html)) );
7988 }
7989 }
7990
7991 function action_membercompletion_page_header(){
7992 if( !empty($this->options['member_page_data']['header']['completion']) ){
7993 $html = $this->options['member_page_data']['header']['completion'];
7994 echo do_shortcode( stripslashes(nl2br($html)) );
7995 }
7996 }
7997
7998 function action_membercompletion_page_footer(){
7999 if( !empty($this->options['member_page_data']['footer']['completion']) ){
8000 $html = $this->options['member_page_data']['footer']['completion'];
8001 echo do_shortcode( stripslashes(nl2br($html)) );
8002 }
8003 }
8004
8005 }
8006 ?>
8007