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

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

8,710 lines 343.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class usc_e_shop
3 {
4
5 var $page; //page action
6 var $cart; //cart object
7 var $use_ssl; //ssl flag
8 var $action, $action_status, $error_status;
9 var $action_message, $error_message;
10 var $itemskus, $itemsku, $itemopts, $itemopt, $item;
11 var $zaiko_status, $payment_structure, $display_mode, $shipping_rule;
12 var $member_status;
13 var $options, $mail_para;
14 var $login_mail, $current_member, $member_form;
15 var $payment_results, $log_flg, $delim, $use_js;
16 var $user_level;
17
18 function usc_e_shop()
19 {
20 global $wpdb, $post, $usces_settings, $usces_states;
21
22 usces_add_role();
23
24 do_action('usces_construct');
25 add_action('after_setup_theme', array(&$this, 'usces_session_start'));
26
27 if ( is_admin() ){
28 clean_term_cache( get_option('usces_item_cat_parent_id'), 'category' );
29 }
30
31 $locales = usces_locales();
32 foreach($locales as $l){
33 $usces_settings['language'][$l] = $l;
34 }
35 $usces_settings['language']['others'] = __('Follow config.php', 'usces');
36
37 $this->options = get_option('usces');
38 if(!isset($this->options['smtp_hostname']) || empty($this->options['smtp_hostname'])){ $this->options['smtp_hostname'] = 'localhost';}
39 if(!isset($this->options['delivery_method']) || !is_array($this->options['delivery_method'])) $this->options['delivery_method'] = array();
40 if(!isset($this->options['shipping_charge']) || !is_array($this->options['shipping_charge'])) $this->options['shipping_charge'] = array();
41 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
42 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = 'activate';
43 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
44 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 0;
45 if(!isset($this->options['use_javascript'])) $this->options['use_javascript'] = 1;
46 if(!isset($this->options['privilege_discount'])) $this->options['privilege_discount'] = '';
47 if(!isset($this->options['privilege_point'])) $this->options['privilege_point'] = '';
48 if(!isset($this->options['campaign_privilege'])) $this->options['campaign_privilege'] = '';
49 if(!isset($this->options['campaign_category'])) $this->options['campaign_category'] = 0;
50 if(!isset($this->options['campaign_schedule']['start'])) $this->options['campaign_schedule']['start'] = array();
51 if(!isset($this->options['campaign_schedule']['end'])) $this->options['campaign_schedule']['end'] = array();
52 if(!isset($this->options['acting_settings']['paypal']['ec_activate'])) $this->options['acting_settings']['paypal']['ec_activate'] = '';
53 if(!isset($this->options['purchase_limit'])) $this->options['purchase_limit'] = '';
54 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
55 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
56 if(!isset($this->options['company_name'])) $this->options['company_name'] = '';
57 if(!isset($this->options['address1'])) $this->options['address1'] = '';
58 if(!isset($this->options['address2'])) $this->options['address2'] = '';
59 if(!isset($this->options['zip_code'])) $this->options['zip_code'] = '';
60 if(!isset($this->options['tel_number'])) $this->options['tel_number'] = '';
61 if(!isset($this->options['fax_number'])) $this->options['fax_number'] = '';
62 if(!isset($this->options['order_mail'])) $this->options['order_mail'] = '';
63 if(!isset($this->options['inquiry_mail'])) $this->options['inquiry_mail'] = '';
64 if(!isset($this->options['sender_mail'])) $this->options['sender_mail'] = '';
65 if(!isset($this->options['error_mail'])) $this->options['error_mail'] = '';
66 if(!isset($this->options['copyright'])) $this->options['copyright'] = '';
67 if(!isset($this->options['postage_privilege'])) $this->options['postage_privilege'] = '';
68 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
69 if(!isset($this->options['tax_rate'])){
70 $this->options['tax_rate'] = '';
71 $this->options['tax_method'] = 'cutting';
72 $this->options['tax_mode'] = 'include';
73 $this->options['tax_target'] = 'products';
74 }
75 if(!isset($this->options['transferee'])) $this->options['transferee'] = '';
76 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
77 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = '';
78 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
79 if(!isset($this->options['start_point'])) $this->options['start_point'] = '';
80 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 1;
81 if(!isset($this->options['point_assign'])) $this->options['point_assign'] = 1;//20120919ysk 0000573
82 if(!isset($this->options['cod_type'])) $this->options['cod_type'] = 'fix';
83 if(!isset($this->options['newmem_admin_mail'])) $this->options['newmem_admin_mail'] = 0;
84 if(!isset($this->options['delmem_admin_mail'])) $this->options['delmem_admin_mail'] = 1;
85 if(!isset($this->options['delmem_customer_mail'])) $this->options['delmem_customer_mail'] = 1;
86 if(!isset($this->options['mail_data']['title'])) $this->options['mail_data']['title'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>'');
87 if(!isset($this->options['mail_data']['header'])) $this->options['mail_data']['header'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>'');
88 if(!isset($this->options['mail_data']['footer'])) $this->options['mail_data']['footer'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>'');
89 if(!isset($this->options['cart_page_data']['header'])) $this->options['cart_page_data']['header'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
90 if(!isset($this->options['cart_page_data']['footer'])) $this->options['cart_page_data']['footer'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
91 if(!isset($this->options['member_page_data']['header'])) $this->options['member_page_data']['header'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
92 if(!isset($this->options['member_page_data']['footer'])) $this->options['member_page_data']['footer'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
93
94 if(!isset($this->options['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = '0';
95 if(!isset($this->options['delivery_after_days'])) $this->options['delivery_after_days'] = 15;
96 if(!isset($this->options['delivery_days'])) $this->options['delivery_days'] = array();
97 if(!isset($this->options['delivery_time_limit']['hour'])) $this->options['delivery_time_limit']['hour'] = '00';
98 if(!isset($this->options['delivery_time_limit']['min'])) $this->options['delivery_time_limit']['min'] = '00';
99
100 if(!isset($this->options['divide_item'])) $this->options['divide_item'] = 0;
101 if(!isset($this->options['itemimg_anchor_rel'])) $this->options['itemimg_anchor_rel'] = '';
102 if(!isset($this->options['fukugo_category_orderby'])) $this->options['fukugo_category_orderby'] = 'ID';
103 if(!isset($this->options['fukugo_category_order'])) $this->options['fukugo_category_order'] = 'ASC';
104 if(!isset($this->options['settlement_path'])) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
105 if(!isset($this->options['logs_path'])) $this->options['logs_path'] = '';
106 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
107 if(!isset($this->options['ssl_url'])) $this->options['ssl_url'] = '';
108 if(!isset($this->options['ssl_url_admin'])) $this->options['ssl_url_admin'] = '';
109 if(!isset($this->options['inquiry_id'])) $this->options['inquiry_id'] = '';
110 if(!isset($this->options['system']['orderby_itemsku'])) $this->options['system']['orderby_itemsku'] = 0;
111 if(!isset($this->options['system']['orderby_itemopt'])) $this->options['system']['orderby_itemopt'] = 0;
112 if(!isset($this->options['system']['front_lang'])) $this->options['system']['front_lang'] = usces_get_local_language();
113 if(!isset($this->options['system']['currency'])) $this->options['system']['currency'] = usces_get_base_country();
114 if(!isset($this->options['system']['addressform'])) $this->options['system']['addressform'] = usces_get_local_addressform();
115 if(!isset($this->options['system']['target_market'])) $this->options['system']['target_market'] = usces_get_local_target_market();
116 if(!isset($this->options['system']['no_cart_css'])) $this->options['system']['no_cart_css'] = 0;
117 if(!isset($this->options['system']['dec_orderID_flag'])) $this->options['system']['dec_orderID_flag'] = 0;
118 if(!isset($this->options['system']['dec_orderID_prefix'])) $this->options['system']['dec_orderID_prefix'] = '';
119 if(!isset($this->options['system']['dec_orderID_digit'])) $this->options['system']['dec_orderID_digit'] = 8;
120 if(!isset($this->options['system']['subimage_rule'])) $this->options['system']['subimage_rule'] = 1;
121 if(!isset($this->options['system']['pdf_delivery'])) $this->options['system']['pdf_delivery'] = 0;
122 if(!isset($this->options['system']['member_pass_rule_min']) || empty($this->options['system']['member_pass_rule_min'])) $this->options['system']['member_pass_rule_min'] = 6;
123 if(!isset($this->options['system']['member_pass_rule_max']) || empty($this->options['system']['member_pass_rule_max'])) $this->options['system']['member_pass_rule_max'] = '';
124 if(!isset($this->options['system']['csv_encode_type'])) $this->options['system']['csv_encode_type'] = 0;
125 if(!isset($this->options['acting_settings']['zeus'])) $this->options['acting_settings']['zeus'] = array('activate'=>'','card_activate'=>'','clientip'=>'','authkey'=>'','connection'=>'','3dsecure'=>'','security'=>'','quickcharge'=>'', 'howpay'=>'','bank_activate'=>'','clientip_bank'=>'','testid_bank'=>'','conv_activate'=>'','clientip_conv'=>'','testid_conv'=>'','test_type_conv'=>'');
126 if(!isset($this->options['acting_settings']['zeus']['connection'])) $this->options['acting_settings']['zeus']['connection'] = '1';
127 if(!isset($this->options['acting_settings']['zeus']['3dsecur'])) $this->options['acting_settings']['zeus']['3dsecur'] = '2';
128 if(!isset($this->options['acting_settings']['zeus']['security'])) $this->options['acting_settings']['zeus']['security'] = '2';
129 if(!isset($this->options['acting_settings']['remise'])) $this->options['acting_settings']['remise'] = array('activate'=>'','plan'=>'','SHOPCO'=>'','HOSTID'=>'','card_activate'=>'','card_jb'=>'', 'payquick'=>'','howpay'=>'','continuation'=>'','card_pc_ope'=>'','send_url_pc'=>'','conv_activate'=>'','S_PAYDATE'=>'','conv_pc_ope'=>'','send_url_cvs_pc'=>'');
130 if(!isset($this->options['acting_settings']['jpayment'])) $this->options['acting_settings']['jpayment'] = array('activate'=>'','aid'=>'','card_activate'=>'','card_jb'=>'','conv_activate'=>'','webm_activate'=>'', 'bitc_activate'=>'','suica_activate'=>'','bank_activate'=>'');
131 if(!isset($this->options['acting_settings']['paypal'])) $this->options['acting_settings']['paypal'] = array('activate'=>'','ec_activate'=>'','sandbox'=>'','user'=>'','pwd'=>'','signature'=>'', 'continuation'=>'');
132
133 //20010420ysk start
134 //if(!isset($this->options['system']['base_country'])) $this->options['system']['base_country'] = usces_get_base_country();
135 $this->options['system']['base_country'] = usces_get_base_country();
136 //20010420ysk end
137 //20110331ysk start
138 if(!isset($this->options['province'])) $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
139 //20110331ysk end
140 if(!isset($this->options['system']['pointreduction'])) $this->options['system']['pointreduction'] = usces_get_pointreduction($this->options['system']['currency']);
141 if(!isset($this->options['indi_item_name'])){
142 $this->options['indi_item_name']['item_name'] = 1;
143 $this->options['indi_item_name']['item_code'] = 1;
144 $this->options['indi_item_name']['sku_name'] = 1;
145 $this->options['indi_item_name']['sku_code'] = 1;
146 $this->options['pos_item_name']['item_name'] = 1;
147 $this->options['pos_item_name']['item_code'] = 2;
148 $this->options['pos_item_name']['sku_name'] = 3;
149 $this->options['pos_item_name']['sku_code'] = 4;
150 }
151 update_option('usces', $this->options);
152
153 $this->check_display_mode();
154 $this->error_message = '';
155 $this->login_mail = '';
156 $this->get_current_member();
157 $this->page = '';
158 $this->payment_results = array();
159 $this->use_js = $this->options['use_javascript'];
160
161 //admin_ssl options
162 // $this->use_ssl = get_option("admin_ssl_use_ssl") === "1" ? true : false;
163 // $use_shared = get_option("admin_ssl_use_shared") === "1" && $this->use_ssl ? true : false;
164 // $shared_url = get_option("admin_ssl_shared_url");
165
166 $this->use_ssl = $this->options['use_ssl'];
167 // if ( $use_shared ) {
168 // $ssl_url = str_replace('/wp-admin/', '', $shared_url);
169 // } else {
170 // $ssl_url = str_replace('http://', 'https://', get_option('home'));
171 // }
172 define('USCES_CART_NUMBER', get_option('usces_cart_number'));
173 define('USCES_MEMBER_NUMBER', get_option('usces_member_number'));
174
175 if ( $this->use_ssl ) {
176 $ssl_url = $this->options['ssl_url'];
177 $ssl_url_admin = $this->options['ssl_url_admin'];
178 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
179 define('USCES_FRONT_PLUGIN_URL', $ssl_url_admin . '/wp-content/plugins/' . USCES_PLUGIN_FOLDER);
180 define('USCES_COOKIEPATH', preg_replace('|https?://[^/]+|i', '', $ssl_url . '/' ) );
181 }else{
182 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
183 define('USCES_COOKIEPATH', COOKIEPATH);
184 }
185 define('USCES_SSL_URL', $ssl_url);
186 define('USCES_SSL_URL_ADMIN', $ssl_url_admin);
187 }else{
188 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
189 define('USCES_SSL_URL', get_option('home'));
190 define('USCES_SSL_URL_ADMIN', site_url());
191 define('USCES_COOKIEPATH', COOKIEPATH);
192 }
193 // if($this->use_ssl) {
194 // define('USCES_CART_URL', $ssl_url . '/?page_id=' . USCES_CART_NUMBER . '&usces=' . $this->get_uscesid());
195 // define('USCES_MEMBER_URL', $ssl_url . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces=' . $this->get_uscesid());
196 // define('USCES_INQUIRY_URL', $ssl_url . '/?page_id=' . $this->options['inquiry_id'] . '&usces=' . $this->get_uscesid());
197 // add_filter('home_url', array($this, 'usces_ssl_page_link'));
198 // add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
199 // add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
200 // add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
201 // add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
202 // add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
203 // } else {
204 // define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
205 // define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
206 // define('USCES_INQUIRY_URL', get_option('home') . '/?page_id=' . $this->options['inquiry_id']);
207 // }
208 define('USCES_ITEM_CAT_PARENT_ID', get_option('usces_item_cat_parent_id'));
209
210 $this->zaiko_status = get_option('usces_zaiko_status');
211 $this->member_status = get_option('usces_customer_status');
212 $this->payment_structure = get_option('usces_payment_structure');
213 $this->display_mode = get_option('usces_display_mode');
214 define('USCES_MYSQL_VERSION', $wpdb->db_version());
215 define('USCES_JP', ('ja' === get_locale() ? true : false));
216
217 }
218
219 function get_default_post_to_edit30( $post_type = 'post', $create_in_db = false ) {
220 global $wpdb;
221
222 $post_title = '';
223 if ( !empty( $_REQUEST['post_title'] ) )
224 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
225
226 $post_content = '';
227 if ( !empty( $_REQUEST['content'] ) )
228 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
229
230 $post_excerpt = '';
231 if ( !empty( $_REQUEST['excerpt'] ) )
232 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
233
234 if ( $create_in_db ) {
235 // Cleanup old auto-drafts more than 7 days old
236 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
237 foreach ( (array) $old_posts as $delete )
238 wp_delete_post( $delete, true ); // Force delete
239 $post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) );
240 } else {
241 $post->ID = 0;
242 $post->post_author = '';
243 $post->post_date = '';
244 $post->post_date_gmt = '';
245 $post->post_password = '';
246 $post->post_type = $post_type;
247 $post->post_status = 'draft';
248 $post->to_ping = '';
249 $post->pinged = '';
250 $post->comment_status = get_option( 'default_comment_status' );
251 $post->ping_status = get_option( 'default_ping_status' );
252 $post->post_pingback = get_option( 'default_pingback_flag' );
253 $post->post_category = get_option( 'default_category' );
254 $post->page_template = 'default';
255 $post->post_parent = 0;
256 $post->menu_order = 0;
257 }
258
259 $post->post_content = apply_filters( 'default_content', $post_content, $post );
260 $post->post_title = apply_filters( 'default_title', $post_title, $post );
261 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
262 $post->post_name = '';
263
264 return $post;
265 }
266
267 function get_default_post_to_edit() {
268 global $post;
269
270 $post_title = '';
271 if ( !empty( $_REQUEST['post_title'] ) )
272 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
273
274 $post_content = '';
275 if ( !empty( $_REQUEST['content'] ) )
276 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
277
278 $post_excerpt = '';
279 if ( !empty( $_REQUEST['excerpt'] ) )
280 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
281
282 $post->ID = 0;
283 $post->post_name = '';
284 $post->post_author = '';
285 $post->post_date = '';
286 $post->post_date_gmt = '';
287 $post->post_password = '';
288 $post->post_status = 'draft';
289 $post->post_type = 'post';
290 $post->to_ping = '';
291 $post->pinged = '';
292 $post->comment_status = get_option( 'default_comment_status' );
293 $post->ping_status = get_option( 'default_ping_status' );
294 $post->post_pingback = get_option( 'default_pingback_flag' );
295 $post->post_category = get_option( 'default_category' );
296 $post->post_content = apply_filters( 'default_content', $post_content);
297 $post->post_title = apply_filters( 'default_title', $post_title );
298 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
299 $post->page_template = 'default';
300 $post->post_parent = 0;
301 $post->menu_order = 0;
302
303 return $post;
304 }
305 function is_cart_or_member_page($link)
306 {
307 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart', ('page_id='.USCES_MEMBER_NUMBER), '/usces-member');
308 $flag = false;
309 foreach($search as $value){
310 $parts = array();
311 if( false !== strpos($link, $value) ){
312 if( $value == ('page_id='.USCES_CART_NUMBER) || $value == ('page_id='.USCES_MEMBER_NUMBER) ){
313 $parts = parse_url($link);
314 parse_str($parts['query'], $query);
315 if( $query['page_id'] == USCES_CART_NUMBER || $query['page_id'] == USCES_MEMBER_NUMBER ){
316 $flag = true;
317 }
318 }else{
319 $flag = true;
320 }
321 }
322 }
323 return $flag;
324 }
325
326 function is_cart_page($link)
327 {
328 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart' );
329 $flag = false;
330 foreach($search as $value){
331 if( false !== strpos($link, $value) ){
332 if( $value == ('page_id='.USCES_CART_NUMBER) ){
333 $parts = parse_url($link);
334 parse_str($parts['query'], $query);
335 if( $query['page_id'] == USCES_CART_NUMBER ){
336 $flag = true;
337 }
338 }else{
339 $flag = true;
340 }
341 }
342 }
343 return $flag;
344 }
345
346 function is_member_page($link)
347 {
348 $search = array(('page_id='.USCES_MEMBER_NUMBER), '/usces-member' );
349 $flag = false;
350 foreach($search as $value){
351 if( false !== strpos($link, $value) ){
352 if( $value == ('page_id='.USCES_MEMBER_NUMBER) ){
353 $parts = parse_url($link);
354 parse_str($parts['query'], $query);
355 if( $query['page_id'] == USCES_MEMBER_NUMBER ){
356 $flag = true;
357 }
358 }else{
359 $flag = true;
360 }
361 }
362 }
363 return $flag;
364 }
365
366 function is_inquiry_page($link)
367 {
368 if( empty($this->options['inquiry_id']) )
369 return false;
370
371 $search = array(('page_id='.$this->options['inquiry_id']), '/usces-inquiry' );
372 $flag = false;
373 foreach($search as $value){
374 if( false !== strpos($link, $value) ){
375 if( $value == ('page_id='.$this->options['inquiry_id']) ){
376 $parts = parse_url($link);
377 parse_str($parts['query'], $query);
378 if( $query['page_id'] == $this->options['inquiry_id'] ){
379 $flag = true;
380 }
381 }else{
382 $flag = true;
383 }
384 }
385 }
386 return $flag;
387 }
388
389 function usces_ssl_page_link($link)
390 {
391 $parts = parse_url($link);
392
393 if( isset($parts['query']) ){
394 parse_str($parts['query'], $query);
395 }
396
397 if( false !== strpos($link, '/usces-cart') || (isset( $query['page_id']) && $query['page_id'] == USCES_CART_NUMBER) ){
398 $link = USCES_CART_URL;
399
400 }elseif( false !== strpos($link, '/usces-member') || (isset( $query['page_id']) && $query['page_id'] == USCES_MEMBER_NUMBER) ){
401 $link = USCES_MEMBER_URL;
402
403 }elseif( !empty($this->options['inquiry_id']) && (false !== strpos($link, '/usces-inquiry') || (isset( $query['page_id']) && $query['page_id'] == $this->options['inquiry_id'])) ){
404 $link = USCES_INQUIRY_URL;
405
406 }else{
407 $link = str_replace('https://', 'http://', $link);
408 $link = apply_filters('usces_ssl_page_link', $link);
409 }
410
411 return $link;
412 }
413 function usces_ssl_contents_link($link)
414 {
415 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])){
416 $req = explode('/wp-content/',$link);
417 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
418 }else{
419 $link = apply_filters('usces_ssl_contents_link', $link);
420 }
421 return $link;
422 }
423
424 function ssl_admin_ajax_url(){
425 $path = '/wp-admin/admin-ajax.php';
426 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) ){
427 $link = USCES_SSL_URL_ADMIN . '/wp-admin/admin-ajax.php';
428 }else{
429 $link = site_url( $path );
430 }
431 $link = apply_filters('ssl_admin_ajax_url', $link);
432 return $link;
433 }
434
435 function usces_ssl_attachment_link($link)
436 {
437 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
438 $link = str_replace(site_url(), USCES_SSL_URL_ADMIN, $link);
439 }else{
440 $link = apply_filters('usces_ssl_attachment_link', $link);
441 }
442 return $link;
443 }
444
445 function usces_ssl_icon_dir_uri($uri)
446 {
447 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
448 $uri = USCES_SSL_URL_ADMIN. '/' . WPINC . '/images/crystal';
449 }else{
450 $link = apply_filters('usces_ssl_icon_dir_uri', $uri);
451 }
452 return $uri;
453 }
454
455 function usces_ssl_script_link($link)
456 {
457 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
458 if(strpos($link, '/wp-content/') !== false){
459 $req = explode('/wp-content/',$link, 2);
460 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
461 }else if(strpos($link, '/wp-includes/') !== false){
462 $req = explode('/wp-includes/',$link, 2);
463 $link = USCES_SSL_URL_ADMIN . '/wp-includes/' . $req[1];
464 }else if(strpos($link, '/wp-admin/') !== false){
465 $req = explode('/wp-admin/',$link, 2);
466 $link = USCES_SSL_URL_ADMIN . '/wp-admin/' . $req[1];
467 }
468 }else{
469 $link = apply_filters('usces_ssl_script_link', $link);
470 }
471 return $link;
472 }
473
474 function set_action_status($status, $message)
475 {
476 $this->action_status = $status;
477 $this->action_message = $message;
478 }
479
480 /******************************************************************************/
481 function add_pages() {
482
483 add_object_page('Welcart Shop', 'Welcart Shop', 'level_2', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
484 add_submenu_page(USCES_PLUGIN_BASENAME, __('Home','usces'), __('Home','usces'), 'level_2', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
485 add_submenu_page(USCES_PLUGIN_BASENAME, __('Master Items','usces'), __('Master Items','usces'), 'level_2', 'usces_itemedit', array($this, 'item_master_page'));
486 add_submenu_page(USCES_PLUGIN_BASENAME, __('Add New Item','usces'), __('Add New Item','usces'), 'level_2', 'usces_itemnew', array($this, 'item_master_page'));
487 add_submenu_page(USCES_PLUGIN_BASENAME, __('General Setting','usces'), __('General Setting','usces'), 'level_6', 'usces_initial', array($this, 'admin_setup_page'));
488 add_submenu_page(USCES_PLUGIN_BASENAME, __('Business Days Setting','usces'), __('Business Days Setting','usces'), 'level_6', 'usces_schedule', array($this, 'admin_schedule_page'));
489 add_submenu_page(USCES_PLUGIN_BASENAME, __('Shipping Setting','usces'), __('Shipping Setting','usces'), 'level_6', 'usces_delivery', array($this, 'admin_delivery_page'));
490 add_submenu_page(USCES_PLUGIN_BASENAME, __('E-mail Setting','usces'), __('E-mail Setting','usces'), 'level_6', 'usces_mail', array($this, 'admin_mail_page'));
491 add_submenu_page(USCES_PLUGIN_BASENAME, __('Cart Page Setting','usces'), __('Cart Page Setting','usces'), 'level_6', 'usces_cart', array($this, 'admin_cart_page'));
492 add_submenu_page(USCES_PLUGIN_BASENAME, __('Member Page Setting','usces'), __('Member Page Setting','usces'), 'level_6', 'usces_member', array($this, 'admin_member_page'));
493 add_submenu_page(USCES_PLUGIN_BASENAME, __('System Setting','usces'), __('System Setting','usces'), 'administrator', 'usces_system', array($this, 'admin_system_page'));
494 add_submenu_page(USCES_PLUGIN_BASENAME, __('Settlement Setting','usces'), __('Settlement Setting','usces'), 'administrator', 'usces_settlement', array($this, 'admin_settlement_page'));
495 //add_submenu_page(USCES_PLUGIN_BASENAME, __('Backup','usces'), __('Backup','usces'), 'level_6', 'usces_backup', array($this, 'admin_backup_page'));
496 do_action('usces_action_shop_admin_menue');
497
498 add_object_page('Welcart Management', 'Welcart Management', 'level_5', 'usces_orderlist', array($this, 'order_list_page'));
499 add_submenu_page('usces_orderlist', __('Order List','usces'), __('Order List','usces'), 'level_5', 'usces_orderlist', array($this, 'order_list_page'));
500 add_submenu_page('usces_orderlist', __('New Order or Estimate','usces'), __('New Order or Estimate','usces'), 'level_5', 'usces_ordernew', array($this, 'order_list_page'));
501 add_submenu_page('usces_orderlist', __('List of Members','usces'), __('List of Members','usces'), 'level_5', 'usces_memberlist', array($this, 'member_list_page'));
502 add_submenu_page('usces_orderlist', __('新規会員登録','usces'), __('新規会員登録','usces'), 'level_5', 'usces_membernew', array($this, 'member_list_page'));
503 do_action('usces_action_management_admin_menue');
504 }
505
506
507 /* Item Master Page */
508 function item_master_page() {
509 global $wpdb, $wp_locale;
510 global $wp_query;
511
512 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
513 $this->action_status = 'none';
514 $this->action_message = '';
515 }
516
517 if($_REQUEST['page'] == 'usces_itemnew'){
518 $action = 'new';
519 }else{
520 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
521 }
522 do_action( 'usces_action_item_master_page', $action );
523 switch ( $action ) {
524 case 'dlitemlist':
525 usces_download_item_list();
526 break;
527 case 'upload_register':
528 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_upload_register.php');
529 break;
530 case 'delete':
531 case 'new':
532 case 'editpost':
533 case 'edit':
534 global $current_user;
535 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_edit.php');
536 break;
537 default:
538 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_list.php');
539 break;
540 }
541 }
542
543 /* order list page */
544 function order_list_page() {
545 $order_edit_form = apply_filters( 'usces_admin_order_edit_form', USCES_PLUGIN_DIR . '/includes/order_edit_form.php' );
546 $order_list = apply_filters( 'usces_admin_order_list', USCES_PLUGIN_DIR . '/includes/order_list.php' );
547
548 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
549 $this->action_status = 'none';
550 $this->action_message = '';
551 }
552 if($_REQUEST['page'] == 'usces_ordernew'){
553 $order_action = 'new';
554 }else{
555 $order_action = isset($_REQUEST['order_action']) ? $_REQUEST['order_action'] : '';
556 }
557 do_action('usces_action_order_list_page', $order_action);
558 switch ($order_action) {
559 //20100908ysk start
560 case 'dlproductlist':
561 usces_download_product_list();
562 break;
563 case 'dlorderlist':
564 usces_download_order_list();
565 break;
566 //20100908ysk end
567 // case 'printpdf':
568 // require_once(USCES_PLUGIN_DIR . '/includes/order_print.php');
569 // break;
570 case 'editpost':
571 do_action('usces_pre_update_orderdata', $_REQUEST['order_id']);
572 $res = usces_update_orderdata();
573 if ( 1 === $res ) {
574 $this->set_action_status('success', __('order date is updated','usces').' <a href="'.stripslashes( $_POST['usces_referer'] ).'">'.__('back to the summary','usces').'</a>');
575 } elseif ( 0 === $res ) {
576 $this->set_action_status('none', '');
577 } else {
578 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
579 }
580 do_action('usces_after_update_orderdata', $_REQUEST['order_id'], $res);
581 require_once($order_edit_form);
582 break;
583 case 'newpost':
584 do_action('usces_pre_new_orderdata');
585 $res = usces_new_orderdata();
586 if ( 1 === $res ) {
587 $this->set_action_status('success', __('New date is add','usces'));
588 } elseif ( 0 === $res ) {
589 $this->set_action_status('none', '');
590 } else {
591 $this->set_action_status('error', 'ERROR : '.__('failure in addition','usces'));
592 }
593 do_action('usces_after_new_orderdata', $res);
594 $_REQUEST['order_action'] = 'edit';
595 $order_action = $_REQUEST['order_action'];
596 require_once($order_edit_form);
597 break;
598 case 'new':
599 case 'edit':
600 require_once($order_edit_form);
601 break;
602 case 'delete':
603 do_action('usces_pre_delete_orderdata', $_REQUEST['order_id']);
604 $res = usces_delete_orderdata();
605 if ( 1 === $res ) {
606 $this->set_action_status('success', __('the order date is deleted','usces'));
607 } elseif ( 0 === $res ) {
608 $this->set_action_status('none', '');
609 } else {
610 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
611 }
612 do_action('usces_after_delete_orderdata', $_REQUEST['order_id'], $res);
613 default:
614 require_once($order_list);
615 }
616 }
617
618 /* member list page */
619 function member_list_page() {
620 $member_edit_form = apply_filters( 'usces_admin_member_edit_form', USCES_PLUGIN_DIR . '/includes/member_edit_form.php' );
621 $member_list = apply_filters( 'usces_admin_member_list', USCES_PLUGIN_DIR . '/includes/member_list.php' );
622
623 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
624 $this->action_status = 'none';
625 $this->action_message = '';
626 }
627 if( $_REQUEST['page'] == 'usces_membernew' && !isset($_REQUEST['member_action']) ){
628 $member_action = 'new';
629 }elseif( $_REQUEST['page'] == 'usces_membernew' && isset($_REQUEST['member_action']) ){
630 $member_action = 'newpost';
631 }else{
632 $member_action = isset($_REQUEST['member_action']) ? $_REQUEST['member_action'] : '';
633 }
634 switch ($member_action) {
635 // case 'upmemberlist':
636 // usces_upload_member_list();
637 // break;
638 //20100908ysk start
639 case 'dlmemberlist':
640 usces_download_member_list();
641 break;
642 //20100908ysk end
643 case 'editpost':
644 $this->error_message = $this->admin_member_check();
645 if( WCUtils::is_blank($this->error_message) ){
646 $res = usces_update_memberdata();
647 if ( 1 === $res ) {
648 $this->set_action_status('success', __('Membership information is updated','usces'));
649 } elseif ( 0 === $res ) {
650 $this->set_action_status('none', '');
651 } else {
652 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
653 }
654 }
655 require_once($member_edit_form);
656 break;
657 case 'newpost':
658 $this->error_message = $this->admin_new_member_check();
659 if( WCUtils::is_blank($this->error_message) ){
660 $res = usces_new_memberdata();
661 if ( 1 === $res ) {
662 $this->set_action_status('success', __('新規会員登録が完了しました', 'usces'));
663 $_REQUEST['member_action'] = 'edit';
664 $member_action = $_REQUEST['member_action'];
665 } elseif ( 0 === $res ) {
666 $this->set_action_status('none', '');
667 } else {
668 $this->set_action_status('error', 'ERROR : '.__('登録できませんでした','usces'));
669 }
670 }
671 require_once($member_edit_form);
672 break;
673
674 case 'new':
675 case 'edit':
676 require_once($member_edit_form);
677 break;
678 case 'delete':
679 $res = usces_delete_memberdata();
680 if ( 1 === $res ) {
681 $this->set_action_status('success', __('The member data is deleted','usces'));
682 } elseif ( 0 === $res ) {
683 $this->set_action_status('none', '');
684 } else {
685 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
686 }
687 default:
688 require_once($member_list);
689 }
690
691 }
692
693 /* admin backup page */
694 function admin_backup_page() {
695
696 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
697 $this->action_status = 'none';
698 $this->action_message = '';
699 }
700 require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
701
702 }
703
704 /* Shop Top Page */
705 function admin_top_page() {
706 $path = apply_filters( 'usces_filter_admin_top_page', USCES_PLUGIN_DIR . '/includes/admin_top.php');
707 require_once($path);
708
709 }
710
711 /* Shop Setup Page */
712 function admin_setup_page() {
713 $this->options = get_option('usces');
714 //$this->options = array();
715
716
717 if(isset($_POST['usces_option_update'])) {
718
719 $_POST = $this->stripslashes_deep_post($_POST);
720 $this->options['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : '';
721 $this->options['campaign_category'] = empty($_POST['cat']) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat'];
722 $this->options['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : '';
723 $this->options['privilege_point'] = isset($_POST['point_num']) ? (int)$_POST['point_num'] : '';
724 $this->options['privilege_discount'] = isset($_POST['discount_num']) ? (int)$_POST['discount_num'] : '';
725 $this->options['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : '';
726 $this->options['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : '';
727 $this->options['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : '';
728 $this->options['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : '';
729 $this->options['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : '';
730 $this->options['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : '';
731 $this->options['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : '';
732 $this->options['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : '';
733 $this->options['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : '';
734 $this->options['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : '';
735 $this->options['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : '';
736 $this->options['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : '';
737 $this->options['point_rate'] = isset($_POST['point_rate']) ? (int)$_POST['point_rate'] : 1;
738 $this->options['start_point'] = isset($_POST['start_point']) ? (int)$_POST['start_point'] : '';
739 $this->options['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : '';
740 $this->options['tax_mode'] = isset($_POST['tax_mode']) ? trim($_POST['tax_mode']) : 'include';
741 $this->options['tax_target'] = isset($_POST['tax_target']) ? trim($_POST['tax_target']) : 'products';
742 $this->options['tax_rate'] = isset($_POST['tax_rate']) ? (int)$_POST['tax_rate'] : '';
743 $this->options['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : '';
744 $this->options['cod_type'] = isset($this->options['cod_type']) ? $this->options['cod_type'] : 'fix';
745 $this->options['transferee'] = isset($_POST['transferee']) ? trim($_POST['transferee']) : '';
746 $this->options['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : '';
747 $this->options['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : '';
748 $this->options['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : '';
749 $this->options['point_coverage'] = isset($_POST['point_coverage']) ? (int)$_POST['point_coverage'] : 0;
750 $this->options['point_assign'] = isset($_POST['point_assign']) ? (int)$_POST['point_assign'] : 1;//20120919ysk 0000573
751
752 $this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options );
753
754 update_option('usces', $this->options);
755
756 $this->action_status = 'success';
757 $this->action_message = __('options are updated','usces');
758
759 } else {
760 $this->action_status = 'none';
761 $this->action_message = '';
762 }
763
764 require_once(USCES_PLUGIN_DIR . '/includes/admin_setup.php');
765
766 }
767
768 /* Shop Schedule Page */
769 function admin_schedule_page() {
770
771 $this->options = get_option('usces');
772
773 if(isset($_POST['usces_option_update'])) {
774 $_POST = $this->stripslashes_deep_post($_POST);
775
776 $this->options['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0';
777 if(isset($_POST['business_days']))
778 $this->options['business_days'] = $_POST['business_days'];
779
780 update_option('usces', $this->options);
781
782 do_action( 'usces_action_admin_schedule_update' );
783
784 $this->action_status = 'success';
785 $this->action_message = __('options are updated','usces');
786 } else {
787 $this->action_status = 'none';
788 $this->action_message = '';
789 }
790
791 require_once(USCES_PLUGIN_DIR . '/includes/admin_schedule.php');
792
793 }
794
795 /* Shop Delivery Page */
796 function admin_delivery_page() {
797
798 $this->options = get_option('usces');
799
800 if(isset($_POST['usces_option_update'])) {
801 $_POST = $this->stripslashes_deep_post($_POST);
802
803 //20101208ysk start
804 if(isset($_POST['delivery_time_limit'])) $this->options['delivery_time_limit'] = $_POST['delivery_time_limit'];
805 if(isset($_POST['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time'];
806 if(isset($_POST['delivery_after_days'])) $this->options['delivery_after_days'] = $_POST['delivery_after_days'];
807 //20101208ysk end
808
809 update_option('usces', $this->options);
810
811 $this->action_status = 'success';
812 $this->action_message = __('options are updated','usces');
813 } else {
814 $this->action_status = 'none';
815 $this->action_message = '';
816 }
817
818 require_once(USCES_PLUGIN_DIR . '/includes/admin_delivery.php');
819
820 }
821
822 /* Shop Mail Page */
823 function admin_mail_page() {
824 global $allowedposttags;
825
826 $this->options = get_option('usces');
827
828 if(isset($_POST['usces_option_update'])) {
829 $_POST = $this->stripslashes_deep_post($_POST);
830
831 $this->options['smtp_hostname'] = trim($_POST['smtp_hostname']);
832 $this->options['newmem_admin_mail'] = (int)$_POST['newmem_admin_mail'];
833 $this->options['delmem_admin_mail'] = (int)$_POST['delmem_admin_mail'];
834 $this->options['delmem_customer_mail'] = (int)$_POST['delmem_customer_mail'];
835
836 foreach ( $_POST['title'] as $key => $value ) {
837 if( WCUtils::is_blank($value) ) {
838 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
839 }else{
840 $this->options['mail_data']['title'][$key] = trim($value);
841 }
842 }
843 foreach ( $_POST['header'] as $key => $value ) {
844 if( WCUtils::is_blank($value) ) {
845 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
846 }else{
847 $this->options['mail_data']['header'][$key] = $value;
848 }
849 }
850 foreach ( $_POST['footer'] as $key => $value ) {
851 if( WCUtils::is_blank($value) ) {
852 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
853 }else{
854 $this->options['mail_data']['footer'][$key] = $value;
855 }
856 }
857
858
859 $this->action_status = 'success';
860 $this->action_message = __('options are updated','usces');
861
862 } else {
863
864 foreach ( (array)$this->options['mail_data']['title'] as $key => $value ) {
865 if( WCUtils::is_blank($value) ) {
866 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
867 }
868 }
869 foreach ( (array)$this->options['mail_data']['header'] as $key => $value ) {
870 if( WCUtils::is_blank($value) ) {
871 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
872 }
873 }
874 foreach ( (array)$this->options['mail_data']['footer'] as $key => $value ) {
875 if( WCUtils::is_blank($value) ) {
876 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
877 }
878 }
879
880 $this->action_status = 'none';
881 $this->action_message = '';
882
883 }
884
885 update_option('usces', $this->options);
886 do_action( 'usces_action_admin_mail_page' );
887
888 require_once(USCES_PLUGIN_DIR . '/includes/admin_mail.php');
889
890 }
891
892 /* Admin Cart Page */
893 function admin_cart_page() {
894 global $allowedposttags;
895 $this->options = get_option('usces');
896
897 if(isset($_POST['usces_option_update'])) {
898 $_POST = $this->stripslashes_deep_post($_POST);
899
900 foreach ( $this->options['indi_item_name'] as $key => $value ) {
901 $this->options['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0;
902 }
903 foreach ( $_POST['position'] as $key => $value ) {
904 $this->options['pos_item_name'][$key] = $value;
905 }
906 foreach ( $_POST['header'] as $key => $value ) {
907 $this->options['cart_page_data']['header'][$key] = addslashes(wp_kses($value, $allowedposttags));
908 }
909 foreach ( $_POST['footer'] as $key => $value ) {
910 $this->options['cart_page_data']['footer'][$key] = addslashes(wp_kses($value, $allowedposttags));
911 }
912
913 update_option('usces', $this->options);
914
915 $this->action_status = 'success';
916 $this->action_message = __('options are updated','usces');
917 } else {
918
919 $this->action_status = 'none';
920 $this->action_message = '';
921 }
922
923
924
925 require_once(USCES_PLUGIN_DIR . '/includes/admin_cart.php');
926
927 }
928
929 /* Admin Member Page */
930 function admin_member_page() {
931
932 $this->options = get_option('usces');
933
934 if(isset($_POST['usces_option_update'])) {
935 $_POST = $this->stripslashes_deep_post($_POST);
936
937 foreach ( $_POST['header'] as $key => $value ) {
938 $this->options['member_page_data']['header'][$key] = $value;
939 }
940 foreach ( $_POST['footer'] as $key => $value ) {
941 $this->options['member_page_data']['footer'][$key] = $value;
942 }
943
944 update_option('usces', $this->options);
945
946 $this->action_status = 'success';
947 $this->action_message = __('options are updated','usces');
948 } else {
949
950 $this->action_status = 'none';
951 $this->action_message = '';
952 }
953
954
955
956 require_once(USCES_PLUGIN_DIR . '/includes/admin_member.php');
957
958 }
959
960
961 /* Admin System Page */
962 function admin_system_page() {
963 //20110331ysk start
964 global $usces_states;
965 //20110331ysk end
966 $action_status = '';//20120511ysk 0000470
967
968 $this->options = get_option('usces');
969
970 if(isset($_POST['usces_option_update'])) {
971 $_POST = $this->stripslashes_deep_post($_POST);
972
973 $this->options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0;
974 $this->options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : '';
975 $this->options['fukugo_category_orderby'] = isset($_POST['fukugo_category_orderby']) ? $_POST['fukugo_category_orderby'] : '';
976 $this->options['fukugo_category_order'] = isset($_POST['fukugo_category_order']) ? $_POST['fukugo_category_order'] : '';
977 $this->options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : '';
978 if( WCUtils::is_blank($this->options['settlement_path']) ) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
979 $sl = substr($this->options['settlement_path'], -1);
980 if($sl != '/' && $sl != '\\') $this->options['settlement_path'] .= '/';
981 $this->options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : '';
982 if( !WCUtils::is_blank($this->options['logs_path']) ){
983 $sl = substr($this->options['logs_path'], -1);
984 if($sl == '/' || $sl == '\\') $this->options['logs_path'] = substr($this->options['logs_path'], 0, -1);
985 }
986 $this->options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0;
987 $this->options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : '';
988 $this->options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : '';
989 if( WCUtils::is_blank($this->options['ssl_url']) || WCUtils::is_blank($this->options['ssl_url_admin']) ) $this->options['use_ssl'] = 0;
990 $this->options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : '';
991 $this->options['use_javascript'] = isset($_POST['use_javascript']) ? (int)$_POST['use_javascript'] : 1;
992 $this->options['system']['front_lang'] = (isset($_POST['front_lang']) && 'others' != $_POST['front_lang']) ? $_POST['front_lang'] : usces_get_local_language();
993 $this->options['system']['currency'] = (isset($_POST['currency']) && 'others' != $_POST['currency']) ? $_POST['currency'] : usces_get_base_country();
994 $this->options['system']['addressform'] = (isset($_POST['addressform']) ) ? $_POST['addressform'] : usces_get_local_addressform();
995 $this->options['system']['target_market'] = (isset($_POST['target_market']) ) ? $_POST['target_market'] : usces_get_local_target_market();
996 $this->options['system']['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0;
997 $this->options['system']['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int)$_POST['dec_orderID_flag'] : 0;
998 $this->options['system']['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : '';
999 $this->options['system']['pdf_delivery'] = isset($_POST['pdf_delivery']) ? (int)$_POST['pdf_delivery'] : 0;
1000 $this->options['system']['member_pass_rule_min'] = isset($_POST['member_pass_rule_min']) ? (int)$_POST['member_pass_rule_min'] : 6;
1001 $this->options['system']['member_pass_rule_max'] = isset($_POST['member_pass_rule_max']) && !empty($_POST['member_pass_rule_max']) ? (int)$_POST['member_pass_rule_max'] : '';
1002 $this->options['system']['csv_encode_type'] = isset($_POST['csv_encode_type']) ? (int)$_POST['csv_encode_type'] : 0;
1003
1004 if( isset($_POST['dec_orderID_digit']) ){
1005 $dec_orderID_digit = (int)rtrim($_POST['dec_orderID_digit']);
1006 if( 6 > $dec_orderID_digit ){
1007 $this->options['system']['dec_orderID_digit'] = 6;
1008 }else{
1009 $this->options['system']['dec_orderID_digit'] = $dec_orderID_digit;
1010 }
1011 }else{
1012 $this->options['system']['dec_orderID_digit'] = 6;
1013 }
1014 $this->options['system']['subimage_rule'] = isset($_POST['subimage_rule']) ? (int)$_POST['subimage_rule'] : 0;
1015 //20110331ysk start
1016 unset($this->options['province']);
1017 //$action_status = '';//20120511ysk 0000470
1018 foreach((array)$this->options['system']['target_market'] as $target_market) {
1019 $province = array();
1020 if(!empty($_POST['province_'.$target_market])) {
1021 $temp_pref = explode("\n", $_POST['province_'.$target_market]);
1022 //20120123ysk start 0000386
1023 //$province[] = __('-- Select --', 'usces');
1024 $province[] = '-- Select --';
1025 //20120123ysk end
1026 //20120725ysk start 0000537
1027 //for($i = 0; $i < count($temp_pref); $i++) {
1028 //$province[] = trim($temp_pref[$i]);
1029 foreach( $temp_pref as $pref ) {
1030 if( !WCUtils::is_blank($pref) )
1031 $province[] = trim($pref);
1032 }
1033 if( 1 == count($province) )
1034 $action_status = 'error';
1035 //20120725ysk end
1036 } else {
1037 if(isset($usces_states[$target_market]) && is_array($usces_states[$target_market])) {
1038 $province = $usces_states[$target_market];
1039 } else {
1040 $action_status = 'error';
1041 }
1042 }
1043 $this->options['province'][$target_market] = $province;
1044 }
1045
1046 if($action_status != '') {
1047 $this->action_status = 'error';
1048 $this->action_message = __('Data have deficiency.','usces');
1049 } else {
1050 $this->action_status = 'success';
1051 $this->action_message = __('options are updated','usces');
1052 }
1053 //20110331ysk end
1054 } else {
1055
1056 if( !isset($this->options['province']) || empty($this->options['province']) ){
1057 //20110331ysk start
1058 //$this->options['province'] = get_option('usces_pref');
1059 $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
1060 //20110331ysk end
1061 }
1062 $this->action_status = 'none';
1063 $this->action_message = '';
1064 }
1065
1066 if($action_status != 'error') //20120511ysk 0000470
1067 update_option('usces', $this->options);
1068
1069 require_once(USCES_PLUGIN_DIR . '/includes/admin_system.php');
1070
1071 }
1072
1073 /* Settlement Setting Page */
1074 function admin_settlement_page() {
1075
1076 $this->action_status = 'none';
1077 $this->action_message = '';
1078
1079 $options = get_option('usces');
1080
1081 if( isset($_POST['usces_option_update']) ) {
1082 $_POST = $this->stripslashes_deep_post($_POST);
1083 $mes = '';
1084
1085 switch( $_POST['acting'] ){
1086 case 'zeus':
1087 unset( $options['acting_settings']['zeus'] );
1088 $options['acting_settings']['zeus']['card_url'] = isset($_POST['card_url']) ? $_POST['card_url'] : '';
1089 $options['acting_settings']['zeus']['card_secureurl'] = isset($_POST['card_secureurl']) ? $_POST['card_secureurl'] : '';
1090 $options['acting_settings']['zeus']['ipaddrs'] = isset($_POST['ipaddrs']) ? $_POST['ipaddrs'] : '';
1091 $options['acting_settings']['zeus']['pay_cvs'] = isset($_POST['pay_cvs']) ? $_POST['pay_cvs'] : '';
1092 $options['acting_settings']['zeus']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1093 $options['acting_settings']['zeus']['connection'] = isset($_POST['connection']) ? $_POST['connection'] : 1;
1094 $options['acting_settings']['zeus']['3dsecur'] = isset($_POST['3dsecur']) ? $_POST['3dsecur'] : 2;
1095 $options['acting_settings']['zeus']['security'] = isset($_POST['security']) ? $_POST['security'] : 2;
1096 if( isset($_POST['authkey']) ){
1097 $options['acting_settings']['zeus']['authkey'] = $_POST['authkey'];
1098 }
1099 // if( 1 == $options['acting_settings']['zeus']['security'] ){
1100 // $options['acting_settings']['zeus']['quickcharge'] = '2';
1101 // }else{
1102 $options['acting_settings']['zeus']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : '';
1103 // }
1104 $options['acting_settings']['zeus']['batch'] = isset($_POST['batch']) ? $_POST['batch'] : '';
1105 $options['acting_settings']['zeus']['clientip'] = isset($_POST['clientip']) ? trim($_POST['clientip']) : '';
1106 $options['acting_settings']['zeus']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1107 $options['acting_settings']['zeus']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1108 $options['acting_settings']['zeus']['bank_ope'] = isset($_POST['bank_ope']) ? $_POST['bank_ope'] : '';
1109 $options['acting_settings']['zeus']['clientip_bank'] = isset($_POST['clientip_bank']) ? trim($_POST['clientip_bank']) : '';
1110 $options['acting_settings']['zeus']['testid_bank'] = isset($_POST['testid_bank']) ? trim($_POST['testid_bank']) : '';
1111 $options['acting_settings']['zeus']['bank_url'] = isset($_POST['bank_url']) ? $_POST['bank_url'] : '';
1112 $options['acting_settings']['zeus']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1113 $options['acting_settings']['zeus']['conv_ope'] = isset($_POST['conv_ope']) ? $_POST['conv_ope'] : '';
1114 $options['acting_settings']['zeus']['clientip_conv'] = isset($_POST['clientip_conv']) ? trim($_POST['clientip_conv']) : '';
1115 $options['acting_settings']['zeus']['testid_conv'] = isset($_POST['testid_conv']) ? trim($_POST['testid_conv']) : '';
1116 $options['acting_settings']['zeus']['test_type_conv'] = ( (isset($_POST['testid_conv']) && WCUtils::is_blank($_POST['testid_conv'])) || !isset($_POST['test_type']) ) ? 0 : $_POST['test_type'];
1117 $options['acting_settings']['zeus']['conv_url'] = isset($_POST['conv_url']) ? $_POST['conv_url'] : '';
1118
1119 if( WCUtils::is_blank($_POST['clientip']) && isset($_POST['card_activate']) && 'on' == $_POST['card_activate'])
1120 $mes .= '※カード決済IPコードを�
1121 �力して下さい<br />';
1122 if( isset($_POST['authkey']) && WCUtils::is_blank($_POST['authkey']) && isset($_POST['security']) && 3 == $_POST['security'])
1123 $mes .= '※認証キーを�
1124 �力して下さい<br />';
1125 if( WCUtils::is_blank($_POST['clientip_bank']) && isset($_POST['bank_activate']) && 'on' == $_POST['bank_activate'] )
1126 $mes .= '※�
1127 �金お任せIPコードを�
1128 �力して下さい<br />';
1129 if( WCUtils::is_blank($_POST['testid_bank']) && isset($_POST['bank_ope']) && 'test' == $_POST['bank_ope'] )
1130 $mes .= '※�
1131 �金お任せテストIDを�
1132 �力して下さい<br />';
1133 if( WCUtils::is_blank($_POST['clientip_conv']) && isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] )
1134 $mes .= '※コンビニ決済IPコードを�
1135 �力して下さい<br />';
1136 if( WCUtils::is_blank($_POST['testid_conv']) && isset($_POST['conv_ope']) && 'test' == $_POST['conv_ope'] )
1137 $mes .= '※コンビニ決済テストIDを�
1138 �力して下さい<br />';
1139 if( isset($_POST['batch']) && 'on' == $_POST['batch'] ) {
1140 if( isset($_POST['quickcharge']) && 'on' == $_POST['quickcharge'] ) {
1141 } else {
1142 $mes .= '※バッチ処理を利用する場合は、クイックチャージを利用するにして下さい<br />';
1143 $options['acting_settings']['zeus']['quickcharge'] = 'on';
1144 }
1145 }
1146 if( !isset($_POST['card_url']) || empty($_POST['card_url']) || !isset($_POST['ipaddrs']) || empty($_POST['ipaddrs']) || !isset($_POST['bank_url']) || empty($_POST['bank_url']) || !isset($_POST['conv_url']) || empty($_POST['conv_url']) )
1147 $mes .= '※設定が不正です!<br />';
1148
1149 if( WCUtils::is_blank($mes) ){
1150 $this->action_status = 'success';
1151 $this->action_message = __('options are updated','usces');
1152 $options['acting_settings']['zeus']['activate'] = 'on';
1153 if( 'on' == $options['acting_settings']['zeus']['card_activate'] ){
1154 $this->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
1155 }else{
1156 unset($this->payment_structure['acting_zeus_card']);
1157 }
1158 if( 'on' == $options['acting_settings']['zeus']['bank_activate'] ){
1159 $this->payment_structure['acting_zeus_bank'] = '�
1160 �金お任せ(ZEUS)';
1161 }else{
1162 unset($this->payment_structure['acting_zeus_bank']);
1163 }
1164 if( 'on' == $options['acting_settings']['zeus']['conv_activate'] ){
1165 $this->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
1166 }else{
1167 unset($this->payment_structure['acting_zeus_conv']);
1168 }
1169 $options['acting_settings']['zeus']['vercheck'] = '115';
1170 update_option( 'usces', $options );
1171 if( 'on' != $options['acting_settings']['zeus']['quickcharge'] ) {
1172 usces_clear_quickcharge( 'zeus_pcid' );
1173 }
1174 }else{
1175 $this->action_status = 'error';
1176 $this->action_message = __('Data have deficiency.','usces');
1177 $options['acting_settings']['zeus']['activate'] = 'off';
1178 unset($this->payment_structure['acting_zeus_card'], $this->payment_structure['acting_zeus_bank'], $this->payment_structure['acting_zeus_conv']);
1179 }
1180 ksort($this->payment_structure);
1181 update_option('usces_payment_structure',$this->payment_structure);
1182 break;
1183
1184 case 'remise':
1185 unset( $options['acting_settings']['remise'] );
1186 $options['acting_settings']['remise']['plan'] = isset($_POST['plan']) ? $_POST['plan'] : '';
1187 $options['acting_settings']['remise']['SHOPCO'] = isset($_POST['SHOPCO']) ? $_POST['SHOPCO'] : '';
1188 $options['acting_settings']['remise']['HOSTID'] = isset($_POST['HOSTID']) ? $_POST['HOSTID'] : '';
1189 $options['acting_settings']['remise']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1190 $options['acting_settings']['remise']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1191 $options['acting_settings']['remise']['card_pc_ope'] = isset($_POST['card_pc_ope']) ? $_POST['card_pc_ope'] : '';
1192 $options['acting_settings']['remise']['payquick'] = isset($_POST['payquick']) ? $_POST['payquick'] : '';
1193 $options['acting_settings']['remise']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1194 $options['acting_settings']['remise']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1195 $options['acting_settings']['remise']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1196 $options['acting_settings']['remise']['conv_pc_ope'] = isset($_POST['conv_pc_ope']) ? $_POST['conv_pc_ope'] : '';
1197 $options['acting_settings']['remise']['S_PAYDATE'] = isset($_POST['S_PAYDATE']) ? $_POST['S_PAYDATE'] : '';
1198 $options['acting_settings']['remise']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1199 $options['acting_settings']['remise']['send_url_pc'] = isset($_POST['send_url_pc']) ? $_POST['send_url_pc'] : '';
1200 $options['acting_settings']['remise']['send_url_cvs_mbl'] = isset($_POST['send_url_cvs_mbl']) ? $_POST['send_url_cvs_mbl'] : '';
1201 $options['acting_settings']['remise']['send_url_cvs_pc'] = isset($_POST['send_url_cvs_pc']) ? $_POST['send_url_cvs_pc'] : '';
1202 $options['acting_settings']['remise']['send_url_mbl_test'] = isset($_POST['send_url_mbl_test']) ? $_POST['send_url_mbl_test'] : '';
1203 $options['acting_settings']['remise']['send_url_pc_test'] = isset($_POST['send_url_pc_test']) ? $_POST['send_url_pc_test'] : '';
1204 $options['acting_settings']['remise']['send_url_cvs_mbl_test'] = isset($_POST['send_url_cvs_mbl_test']) ? $_POST['send_url_cvs_mbl_test'] : '';
1205 $options['acting_settings']['remise']['send_url_cvs_pc_test'] = isset($_POST['send_url_cvs_pc_test']) ? $_POST['send_url_cvs_pc_test'] : '';
1206 $options['acting_settings']['remise']['REMARKS3'] = isset($_POST['REMARKS3']) ? $_POST['REMARKS3'] : '';
1207
1208 if( isset($_POST['plan_remise']) && WCUtils::is_zero($_POST['plan_remise']) )
1209 $mes .= '※サービスプランを選択してください<br />';
1210 if( WCUtils::is_blank($_POST['SHOPCO']) )
1211 $mes .= '※加盟店コードを�
1212 �力して下さい<br />';
1213 if( WCUtils::is_blank($_POST['HOSTID']) )
1214 $mes .= '※ホスト番号を�
1215 �力して下さい<br />';
1216 if( isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] && empty($_POST['S_PAYDATE']) )
1217 $mes .= '※支払期限を�
1218 �力して下さい<br />';
1219 if( isset($_POST['card_pc_ope']) && 'public' == $_POST['card_pc_ope'] && empty($_POST['send_url_pc']) )
1220 $mes .= '※クレジットカード決済の本番URLを�
1221 �力して下さい<br />';
1222 if( isset($_POST['conv_pc_ope']) && 'public' == $_POST['conv_pc_ope'] && empty($_POST['send_url_cvs_pc']) )
1223 $mes .= '※コンビニ・電子マネー決済の本番URLを�
1224 �力して下さい<br />';
1225 if( !isset($_POST['REMARKS3']) || empty($_POST['REMARKS3']) )
1226 $mes .= '※設定が不正です!<br />';
1227
1228 if( WCUtils::is_blank($mes) ){
1229 //$this->zaction_status = 'success';
1230 $this->action_status = 'success';
1231 $this->action_message = __('options are updated','usces');
1232 $options['acting_settings']['remise']['activate'] = 'on';
1233 if( 'on' == $options['acting_settings']['remise']['card_activate'] ){
1234 $this->payment_structure['acting_remise_card'] = 'カード決済(ルミーズ)';
1235 }else{
1236 unset($this->payment_structure['acting_remise_card']);
1237 }
1238 if( 'on' == $options['acting_settings']['remise']['conv_activate'] ){
1239 $this->payment_structure['acting_remise_conv'] = 'コンビニ決済(ルミーズ)';
1240 }else{
1241 unset($this->payment_structure['acting_remise_conv']);
1242 }
1243 update_option('usces', $options);
1244 if( 'on' != $options['acting_settings']['remise']['payquick'] ) {
1245 usces_clear_quickcharge( 'remise_pcid' );
1246 }
1247
1248 }else{
1249 $this->action_status = 'error';
1250 $this->action_message = __('Data have deficiency.','usces');
1251 $options['acting_settings']['remise']['activate'] = 'off';
1252 unset($this->payment_structure['acting_remise_card']);
1253 unset($this->payment_structure['acting_remise_conv']);
1254 }
1255 ksort($this->payment_structure);
1256 update_option('usces_payment_structure',$this->payment_structure);
1257 break;
1258 //20101018ysk start
1259 case 'jpayment':
1260 unset( $options['acting_settings']['jpayment'] );
1261 $options['acting_settings']['jpayment']['aid'] = isset($_POST['aid']) ? $_POST['aid'] : '';
1262 $options['acting_settings']['jpayment']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1263 $options['acting_settings']['jpayment']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1264 $options['acting_settings']['jpayment']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1265 //$options['acting_settings']['jpayment']['webm_activate'] = isset($_POST['webm_activate']) ? $_POST['webm_activate'] : '';
1266 //$options['acting_settings']['jpayment']['bitc_activate'] = isset($_POST['bitc_activate']) ? $_POST['bitc_activate'] : '';
1267 //$options['acting_settings']['jpayment']['suica_activate'] = isset($_POST['suica_activate']) ? $_POST['suica_activate'] : '';
1268 $options['acting_settings']['jpayment']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1269 $options['acting_settings']['jpayment']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1270
1271 if( WCUtils::is_blank($_POST['aid']) )
1272 $mes .= '※店舗IDコードを�
1273 �力して下さい<br />';
1274 if( isset($_POST['card_activate']) && 'on' == $_POST['card_activate'] && empty($_POST['card_jb']) )
1275 $mes .= '※ジョブタイプを指定して下さい<br />';
1276
1277 if( WCUtils::is_blank($mes) ){
1278 $this->action_status = 'success';
1279 $this->action_message = __('options are updated','usces');
1280 $options['acting_settings']['jpayment']['activate'] = 'on';
1281 if( 'on' == $options['acting_settings']['jpayment']['card_activate'] ){
1282 $this->payment_structure['acting_jpayment_card'] = 'カード決済(J-Payment)';
1283 }else{
1284 unset($this->payment_structure['acting_jpayment_card']);
1285 }
1286 if( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ){
1287 $this->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(J-Payment)';
1288 }else{
1289 unset($this->payment_structure['acting_jpayment_conv']);
1290 }
1291 //if( 'on' == $options['acting_settings']['jpayment']['webm_activate'] ){
1292 // $this->payment_structure['acting_jpayment_webm'] = 'WebMoney決済(J-Payment)';
1293 //}else{
1294 // unset($this->payment_structure['acting_jpayment_webm']);
1295 //}
1296 //if( 'on' == $options['acting_settings']['jpayment']['bitc_activate'] ){
1297 // $this->payment_structure['acting_jpayment_bitc'] = 'BitCash決済(J-Payment)';
1298 //}else{
1299 // unset($this->payment_structure['acting_jpayment_bitc']);
1300 //}
1301 //if( 'on' == $options['acting_settings']['jpayment']['suica_activate'] ){
1302 // $this->payment_structure['acting_jpayment_suica'] = 'モバイルSuica決済(J-Payment)';
1303 //}else{
1304 // unset($this->payment_structure['acting_jpayment_suica']);
1305 //}
1306 if( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ){
1307 $this->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(J-Payment)';
1308 }else{
1309 unset($this->payment_structure['acting_jpayment_bank']);
1310 }
1311 update_option('usces', $options);
1312 }else{
1313 $this->action_status = 'error';
1314 $this->action_message = __('Data have deficiency.', 'usces');
1315 $options['acting_settings']['jpayment']['activate'] = 'off';
1316 unset($this->payment_structure['acting_jpayment_card']);
1317 unset($this->payment_structure['acting_jpayment_conv']);
1318 //unset($this->payment_structure['acting_jpayment_webm']);
1319 //unset($this->payment_structure['acting_jpayment_bitc']);
1320 //unset($this->payment_structure['acting_jpayment_suica']);
1321 unset($this->payment_structure['acting_jpayment_bank']);
1322 }
1323 ksort($this->payment_structure);
1324 update_option('usces_payment_structure', $this->payment_structure);
1325 break;
1326 //20101018ysk end
1327 //20110208ysk start
1328 case 'paypal':
1329 unset( $options['acting_settings']['paypal'] );
1330 $options['acting_settings']['paypal']['ec_activate'] = isset($_POST['ec_activate']) ? $_POST['ec_activate'] : '';
1331 $options['acting_settings']['paypal']['sandbox'] = isset($_POST['sandbox']) ? $_POST['sandbox'] : '';
1332 $options['acting_settings']['paypal']['user'] = isset($_POST['user']) ? $_POST['user'] : '';
1333 $options['acting_settings']['paypal']['pwd'] = isset($_POST['pwd']) ? $_POST['pwd'] : '';
1334 $options['acting_settings']['paypal']['signature'] = isset($_POST['signature']) ? $_POST['signature'] : '';
1335 //20110412ysk start
1336 $options['acting_settings']['paypal']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1337 //20110412ysk end
1338 $options['acting_settings']['paypal']['logoimg'] = isset($_POST['logoimg']) ? $_POST['logoimg'] : '';
1339 $options['acting_settings']['paypal']['set_cartbordercolor'] = isset($_POST['set_cartbordercolor']) ? $_POST['set_cartbordercolor'] : 'off';
1340 $options['acting_settings']['paypal']['cartbordercolor'] = ( 'on' == $options['acting_settings']['paypal']['set_cartbordercolor'] ) ? $_POST['cartbordercolor'] : '';
1341
1342 if( !isset($_POST['sandbox']) || empty($_POST['sandbox']) )
1343 $mes .= '※動作環境が不正です<br />';
1344 if( WCUtils::is_blank($_POST['user']) )
1345 $mes .= '※APIユーザー名を�
1346 �力して下さい<br />';
1347 if( WCUtils::is_blank($_POST['pwd']) )
1348 $mes .= '※APIパスワードを�
1349 �力して下さい<br />';
1350 if( WCUtils::is_blank($_POST['signature']) )
1351 $mes .= '※署名を�
1352 �力して下さい<br />';
1353
1354 if( WCUtils::is_blank($mes) ){
1355 $this->action_status = 'success';
1356 $this->action_message = __('options are updated','usces');
1357 if($options['acting_settings']['paypal']['sandbox'] == 1) {
1358 $options['acting_settings']['paypal']['api_host'] = 'api-3t.sandbox.paypal.com';
1359 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.sandbox.paypal.com/nvp';
1360 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
1361 } else {
1362 $options['acting_settings']['paypal']['api_host'] = 'api-3t.paypal.com';
1363 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.paypal.com/nvp';
1364 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.paypal.com/cgi-bin/webscr';
1365 }
1366 $options['acting_settings']['paypal']['activate'] = 'on';
1367 if( 'on' == $options['acting_settings']['paypal']['ec_activate'] ){
1368 $this->payment_structure['acting_paypal_ec'] = 'PayPal決済';
1369 }else{
1370 unset($this->payment_structure['acting_paypal_ec']);
1371 }
1372 update_option('usces', $options);
1373 }else{
1374 $this->action_status = 'error';
1375 $this->action_message = __('Data have deficiency.', 'usces');
1376 $options['acting_settings']['paypal']['activate'] = 'off';
1377 unset($this->payment_structure['acting_paypal_ec']);
1378 }
1379 ksort($this->payment_structure);
1380 update_option('usces_payment_structure', $this->payment_structure);
1381 break;
1382 //20110208ysk end
1383 //20120413ysk start
1384 case 'sbps':
1385 unset( $options['acting_settings']['sbps'] );
1386 $options['acting_settings']['sbps']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : '';
1387 $options['acting_settings']['sbps']['service_id'] = isset($_POST['service_id']) ? $_POST['service_id'] : '';
1388 $options['acting_settings']['sbps']['hash_key'] = isset($_POST['hash_key']) ? $_POST['hash_key'] : '';
1389 $options['acting_settings']['sbps']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1390 //$options['acting_settings']['sbps']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1391 $options['acting_settings']['sbps']['send_url_check'] = isset($_POST['send_url_check']) ? $_POST['send_url_check'] : '';
1392 $options['acting_settings']['sbps']['send_url_test'] = isset($_POST['send_url_test']) ? $_POST['send_url_test'] : '';
1393 $options['acting_settings']['sbps']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1394 $options['acting_settings']['sbps']['3d_secure'] = isset($_POST['3d_secure']) ? $_POST['3d_secure'] : '';
1395 $options['acting_settings']['sbps']['cust'] = isset($_POST['cust']) ? $_POST['cust'] : '';
1396 $options['acting_settings']['sbps']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1397 $options['acting_settings']['sbps']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1398 $options['acting_settings']['sbps']['payeasy_activate'] = isset($_POST['payeasy_activate']) ? $_POST['payeasy_activate'] : '';
1399 $options['acting_settings']['sbps']['wallet_yahoowallet'] = isset($_POST['wallet_yahoowallet']) ? $_POST['wallet_yahoowallet'] : '';
1400 $options['acting_settings']['sbps']['wallet_rakuten'] = isset($_POST['wallet_rakuten']) ? $_POST['wallet_rakuten'] : '';
1401 $options['acting_settings']['sbps']['wallet_paypal'] = isset($_POST['wallet_paypal']) ? $_POST['wallet_paypal'] : '';
1402 $options['acting_settings']['sbps']['wallet_netmile'] = isset($_POST['wallet_netmile']) ? $_POST['wallet_netmile'] : '';
1403 $options['acting_settings']['sbps']['wallet_alipay'] = isset($_POST['wallet_alipay']) ? $_POST['wallet_alipay'] : '';
1404 $options['acting_settings']['sbps']['mobile_docomo'] = isset($_POST['mobile_docomo']) ? $_POST['mobile_docomo'] : '';
1405 $options['acting_settings']['sbps']['mobile_softbank'] = isset($_POST['mobile_softbank']) ? $_POST['mobile_softbank'] : '';
1406 $options['acting_settings']['sbps']['mobile_auone'] = isset($_POST['mobile_auone']) ? $_POST['mobile_auone'] : '';
1407 $options['acting_settings']['sbps']['mobile_mysoftbank'] = isset($_POST['mobile_mysoftbank']) ? $_POST['mobile_mysoftbank'] : '';
1408 $options['acting_settings']['sbps']['mobile_softbank2'] = isset($_POST['mobile_softbank2']) ? $_POST['mobile_softbank2'] : '';
1409
1410 if( WCUtils::is_blank($_POST['merchant_id']) )
1411 $mes .= '※マーチャントIDを�
1412 �力して下さい<br />';
1413 if( WCUtils::is_blank($_POST['service_id']) )
1414 $mes .= '※サービスIDを�
1415 �力して下さい<br />';
1416 if( WCUtils::is_blank($_POST['hash_key']) )
1417 $mes .= '※Hash KEYを�
1418 �力して下さい<br />';
1419 //if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1420 // $mes .= '※本番URLを�
1421 �力して下さい<br />';
1422
1423 if( WCUtils::is_blank($mes) ){
1424 $this->action_status = 'success';
1425 $this->action_message = __('options are updated','usces');
1426 $options['acting_settings']['sbps']['activate'] = 'on';
1427 if( isset($_POST['ope']) && 'public' == $_POST['ope'] ) {
1428 $options['acting_settings']['sbps']['send_url'] = 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do';
1429 }
1430 if( 'on' == $options['acting_settings']['sbps']['card_activate'] ){
1431 $this->payment_structure['acting_sbps_card'] = 'カード決済(ソフトバンク・ペイメント)';
1432 }else{
1433 unset($this->payment_structure['acting_sbps_card']);
1434 }
1435 if( 'on' == $options['acting_settings']['sbps']['conv_activate'] ){
1436 $this->payment_structure['acting_sbps_conv'] = 'コンビニ決済(ソフトバンク・ペイメント)';
1437 }else{
1438 unset($this->payment_structure['acting_sbps_conv']);
1439 }
1440 if( 'on' == $options['acting_settings']['sbps']['payeasy_activate'] ){
1441 $this->payment_structure['acting_sbps_payeasy'] = 'ペイジー決済(ソフトバンク・ペイメント)';
1442 }else{
1443 unset($this->payment_structure['acting_sbps_payeasy']);
1444 }
1445 if( ( 'on' == $options['acting_settings']['sbps']['wallet_yahoowallet'] ) ||
1446 ( 'on' == $options['acting_settings']['sbps']['wallet_rakuten'] ) ||
1447 ( 'on' == $options['acting_settings']['sbps']['wallet_paypal'] ) ||
1448 ( 'on' == $options['acting_settings']['sbps']['wallet_netmile'] ) ||
1449 ( 'on' == $options['acting_settings']['sbps']['wallet_alipay'] ) ) {
1450 $options['acting_settings']['sbps']['wallet_activate'] = 'on';
1451 } else {
1452 $options['acting_settings']['sbps']['wallet_activate'] = 'off';
1453 }
1454 if( 'on' == $options['acting_settings']['sbps']['wallet_activate'] ){
1455 $this->payment_structure['acting_sbps_wallet'] = 'ウォレット決済(ソフトバンク・ペイメント)';
1456 }else{
1457 unset($this->payment_structure['acting_sbps_wallet']);
1458 }
1459 if( ( 'on' == $options['acting_settings']['sbps']['mobile_docomo'] ) ||
1460 ( 'on' == $options['acting_settings']['sbps']['mobile_softbank'] ) ||
1461 ( 'on' == $options['acting_settings']['sbps']['mobile_auone'] ) ||
1462 ( 'on' == $options['acting_settings']['sbps']['mobile_mysoftbank'] ) ||
1463 ( 'on' == $options['acting_settings']['sbps']['mobile_softbank2'] ) ) {
1464 $options['acting_settings']['sbps']['mobile_activate'] = 'on';
1465 } else {
1466 $options['acting_settings']['sbps']['mobile_activate'] = 'off';
1467 }
1468 if( 'on' == $options['acting_settings']['sbps']['mobile_activate'] ){
1469 $this->payment_structure['acting_sbps_mobile'] = '携帯キャリア決済(ソフトバンク・ペイメント)';
1470 }else{
1471 unset($this->payment_structure['acting_sbps_mobile']);
1472 }
1473 update_option('usces', $options);
1474 }else{
1475 $this->action_status = 'error';
1476 $this->action_message = __('Data have deficiency.','usces');
1477 $options['acting_settings']['sbps']['activate'] = 'off';
1478 unset($this->payment_structure['acting_sbps_card']);
1479 unset($this->payment_structure['acting_sbps_conv']);
1480 unset($this->payment_structure['acting_sbps_payeasy']);
1481 unset($this->payment_structure['acting_sbps_wallet']);
1482 unset($this->payment_structure['acting_sbps_mobile']);
1483 }
1484 ksort($this->payment_structure);
1485 update_option('usces_payment_structure', $this->payment_structure);
1486 break;
1487 //20120413ysk end
1488 //20120618ysk start
1489 case 'telecom':
1490 unset( $options['acting_settings']['telecom'] );
1491 $options['acting_settings']['telecom']['clientip'] = isset($_POST['clientip']) ? $_POST['clientip'] : '';
1492 $options['acting_settings']['telecom']['stype'] = isset($_POST['stype']) ? $_POST['stype'] : '';
1493 $options['acting_settings']['telecom']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1494 $options['acting_settings']['telecom']['edy_activate'] = isset($_POST['edy_activate']) ? $_POST['edy_activate'] : '';
1495
1496 if( WCUtils::is_blank($_POST['clientip']) )
1497 $mes .= '※クライアントIPを�
1498 �力して下さい<br />';
1499 if( WCUtils::is_blank($_POST['stype']) )
1500 $mes .= '※決済タイプを�
1501 �力して下さい<br />';
1502
1503 if( WCUtils::is_blank($mes) ){
1504 $this->action_status = 'success';
1505 $this->action_message = __('options are updated','usces');
1506 $options['acting_settings']['telecom']['activate'] = 'on';
1507 if( 'on' == $options['acting_settings']['telecom']['card_activate'] ){
1508 if( 'E' == $options['acting_settings']['telecom']['stype'][0] ) {
1509 $options['acting_settings']['telecom']['send_url'] = "https://www.credit-cgiserver.com/inetcredit/secure/order.pl";
1510 } else {
1511 $options['acting_settings']['telecom']['send_url'] = "https://secure.telecomcredit.co.jp/inetcredit/secure/order.pl";
1512 }
1513 $this->payment_structure['acting_telecom_card'] = 'カード決済(テレコムクレジット)';
1514 }else{
1515 unset($this->payment_structure['acting_telecom_card']);
1516 }
1517 if( 'on' == $options['acting_settings']['telecom']['edy_activate'] ){
1518 $options['acting_settings']['telecom']['send_url_edy'] = "https://secure.telecomcredit.co.jp/payment/edy/order.pl";
1519 $this->payment_structure['acting_telecom_edy'] = 'Edy決済(テレコムクレジット)';
1520 }else{
1521 unset($this->payment_structure['acting_telecom_edy']);
1522 }
1523 update_option('usces', $options);
1524 }else{
1525 $this->action_status = 'error';
1526 $this->action_message = __('Data have deficiency.','usces');
1527 $options['acting_settings']['telecom']['activate'] = 'off';
1528 unset($this->payment_structure['acting_telecom_card']);
1529 unset($this->payment_structure['acting_telecom_edy']);
1530 }
1531 ksort($this->payment_structure);
1532 update_option('usces_payment_structure', $this->payment_structure);
1533 break;
1534 //20120618ysk end
1535 //20121206ysk start
1536 case 'digitalcheck':
1537 unset( $options['acting_settings']['digitalcheck'] );
1538 $options['acting_settings']['digitalcheck']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1539 $options['acting_settings']['digitalcheck']['card_ip'] = isset($_POST['card_ip']) ? $_POST['card_ip'] : '';
1540 $options['acting_settings']['digitalcheck']['card_pass'] = isset($_POST['card_pass']) ? $_POST['card_pass'] : '';
1541 $options['acting_settings']['digitalcheck']['card_kakutei'] = isset($_POST['card_kakutei']) ? $_POST['card_kakutei'] : '';
1542 $options['acting_settings']['digitalcheck']['card_user_id'] = isset($_POST['card_user_id']) ? $_POST['card_user_id'] : '';
1543 $options['acting_settings']['digitalcheck']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1544 $options['acting_settings']['digitalcheck']['conv_ip'] = isset($_POST['conv_ip']) ? $_POST['conv_ip'] : '';
1545 $options['acting_settings']['digitalcheck']['conv_store'] = isset($_POST['conv_store']) ? $_POST['conv_store'] : array();
1546 $options['acting_settings']['digitalcheck']['conv_kigen'] = isset($_POST['conv_kigen']) ? $_POST['conv_kigen'] : '14';
1547
1548 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) {
1549 if( '' == trim($_POST['card_ip']) )
1550 $mes .= '※加盟店コードを�
1551 �力して下さい<br />';
1552 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1553 if( '' == trim($_POST['card_pass']) )
1554 $mes .= '※加盟店パスワードを�
1555 �力して下さい<br />';
1556 }
1557 }
1558 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
1559 if( '' == trim($_POST['conv_ip']) )
1560 $mes .= '※加盟店コードを�
1561 �力して下さい<br />';
1562 if( empty($_POST['conv_store']) )
1563 $mes .= '※利用コンビニを選択して下さい<br />';
1564 }
1565
1566 if( '' == $mes ){
1567 $this->action_status = 'success';
1568 $this->action_message = __('options are updated','usces');
1569 $options['acting_settings']['digitalcheck']['activate'] = 'on';
1570 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ){
1571 $options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
1572 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1573 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.paydesign.jp/settle/settlex/credit2.dll";
1574 } else {
1575 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "";
1576 }
1577 $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(ペイデザイン)';
1578 }else{
1579 unset($this->payment_structure['acting_digitalcheck_card']);
1580 }
1581 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ){
1582 $options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
1583 $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(ペイデザイン)';
1584 }else{
1585 unset($this->payment_structure['acting_digitalcheck_conv']);
1586 }
1587 update_option('usces', $options);
1588 if( 'on' != $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1589 usces_clear_quickcharge( 'digitalcheck_ip_user_id' );
1590 }
1591 }else{
1592 $this->action_status = 'error';
1593 $this->action_message = __('Data have deficiency.','usces');
1594 $options['acting_settings']['digitalcheck']['activate'] = 'off';
1595 unset($this->payment_structure['acting_digitalcheck_card']);
1596 unset($this->payment_structure['acting_digitalcheck_conv']);
1597 }
1598 ksort($this->payment_structure);
1599 update_option('usces_payment_structure', $this->payment_structure);
1600 break;
1601 //20121206ysk end
1602 //20130225ysk start
1603 case 'mizuho':
1604 unset( $options['acting_settings']['mizuho'] );
1605 $options['acting_settings']['mizuho']['shopid'] = isset($_POST['shopid']) ? $_POST['shopid'] : '';
1606 $options['acting_settings']['mizuho']['cshopid'] = isset($_POST['cshopid']) ? $_POST['cshopid'] : '';
1607 $options['acting_settings']['mizuho']['hash_pass'] = isset($_POST['hash_pass']) ? $_POST['hash_pass'] : '';
1608 $options['acting_settings']['mizuho']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1609 $options['acting_settings']['mizuho']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1610 $options['acting_settings']['mizuho']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1611 $options['acting_settings']['mizuho']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1612 $options['acting_settings']['mizuho']['conv1_activate'] = isset($_POST['conv1_activate']) ? $_POST['conv1_activate'] : '';
1613 $options['acting_settings']['mizuho']['conv2_activate'] = isset($_POST['conv2_activate']) ? $_POST['conv2_activate'] : '';
1614
1615 //if( 'on' == $options['acting_settings']['mizuho']['card_activate'] or 'on' == $options['acting_settings']['mizuho']['conv_activate'] ) {
1616 if( '' == trim($_POST['shopid']) )
1617 $mes .= '※加盟店コードを�
1618 �力して下さい<br />';
1619 if( '' == trim($_POST['cshopid']) )
1620 $mes .= '※加盟店サブコードを�
1621 �力して下さい<br />';
1622 if( '' == trim($_POST['hash_pass']) )
1623 $mes .= '※ハッシュ用パスワードを�
1624 �力して下さい<br />';
1625 //}
1626 if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1627 $mes .= '※本番URLを�
1628 �力して下さい<br />';
1629 if( defined('WCEX_MOBILE') and isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url_mbl']) )
1630 $mes .= '※本番URL(携帯)を�
1631 �力して下さい<br />';
1632
1633 if( '' == $mes ) {
1634 $this->action_status = 'success';
1635 $this->action_message = __('options are updated','usces');
1636 $options['acting_settings']['mizuho']['activate'] = 'on';
1637 $options['acting_settings']['mizuho']['send_url_test'] = "https://210.161.141.207/mltbank/MBWebFrontPayment";
1638 if( defined('WCEX_MOBILE') ) $options['acting_settings']['mizuho']['send_url_mbl_test'] = "https://210.161.141.207/mltbank/iMBWebFrontPayment";
1639 if( 'on' == $options['acting_settings']['mizuho']['card_activate'] ) {
1640 $this->payment_structure['acting_mizuho_card'] = 'カード決済(みずほファクター)';
1641 } else {
1642 unset($this->payment_structure['acting_mizuho_card']);
1643 }
1644 if( 'on' == $options['acting_settings']['mizuho']['conv1_activate'] ) {
1645 $this->payment_structure['acting_mizuho_conv1'] = 'コンビニ・ウェルネット決済(みずほファクター)';
1646 } else {
1647 unset($this->payment_structure['acting_mizuho_conv1']);
1648 }
1649 if( 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) {
1650 $this->payment_structure['acting_mizuho_conv2'] = 'コンビニ・セブンイレブン決済(みずほファクター)';
1651 } else {
1652 unset($this->payment_structure['acting_mizuho_conv2']);
1653 }
1654 update_option('usces', $options);
1655 } else {
1656 $this->action_status = 'error';
1657 $this->action_message = __('Data have deficiency.','usces');
1658 $options['acting_settings']['mizuho']['activate'] = 'off';
1659 unset($this->payment_structure['acting_mizuho_card']);
1660 unset($this->payment_structure['acting_mizuho_conv1']);
1661 unset($this->payment_structure['acting_mizuho_conv2']);
1662 }
1663 ksort($this->payment_structure);
1664 update_option('usces_payment_structure', $this->payment_structure);
1665 break;
1666 //20130225ysk end
1667 //20131220ysk start
1668 case 'anotherlane':
1669 unset( $options['acting_settings']['anotherlane'] );
1670 $options['acting_settings']['anotherlane']['siteid'] = isset($_POST['siteid']) ? $_POST['siteid'] : '';
1671 $options['acting_settings']['anotherlane']['sitepass'] = isset($_POST['sitepass']) ? $_POST['sitepass'] : '';
1672 $options['acting_settings']['anotherlane']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : '';
1673 $options['acting_settings']['anotherlane']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1674
1675 if( WCUtils::is_blank($_POST['siteid']) )
1676 $mes .= '※サイトIDを�
1677 �力して下さい<br />';
1678 if( WCUtils::is_blank($_POST['sitepass']) )
1679 $mes .= '※サイトパスワードを�
1680 �力して下さい<br />';
1681
1682 if( WCUtils::is_blank($mes) ) {
1683 $this->action_status = 'success';
1684 $this->action_message = __('options are updated','usces');
1685 $options['acting_settings']['anotherlane']['activate'] = 'on';
1686 if( 'on' == $options['acting_settings']['anotherlane']['card_activate'] ) {
1687 $options['acting_settings']['anotherlane']['send_url'] = "https://credit.alij.ne.jp/service/credit/input.html";
1688 $this->payment_structure['acting_anotherlane_card'] = 'カード決済(アナザーレーン)';
1689 } else {
1690 unset( $this->payment_structure['acting_anotherlane_card'] );
1691 }
1692 update_option( 'usces', $options );
1693 } else {
1694 $this->action_status = 'error';
1695 $this->action_message = __('Data have deficiency.','usces');
1696 $options['acting_settings']['anotherlane']['activate'] = 'off';
1697 unset( $this->payment_structure['acting_anotherlane_card'] );
1698 }
1699 ksort( $this->payment_structure );
1700 update_option( 'usces_payment_structure', $this->payment_structure );
1701 break;
1702 //20131220ysk end
1703 //20140206ysk start
1704 case 'veritrans':
1705 unset( $options['acting_settings']['veritrans'] );
1706 $options['acting_settings']['veritrans']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : '';
1707 $options['acting_settings']['veritrans']['merchanthash'] = isset($_POST['merchanthash']) ? $_POST['merchanthash'] : '';
1708 $options['acting_settings']['veritrans']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1709 $options['acting_settings']['veritrans']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1710 $options['acting_settings']['veritrans']['card_capture_flag'] = isset($_POST['card_capture_flag']) ? $_POST['card_capture_flag'] : '';
1711 $options['acting_settings']['veritrans']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1712
1713 if( WCUtils::is_blank($options['acting_settings']['veritrans']['merchant_id']) )
1714 $mes .= '※マーチャントIDを�
1715 �力して下さい<br />';
1716 if( WCUtils::is_blank($options['acting_settings']['veritrans']['merchanthash']) )
1717 $mes .= '※マーチャントハッシュキーを�
1718 �力して下さい<br />';
1719 if( WCUtils::is_blank($options['acting_settings']['veritrans']['ope']) )
1720 $mes .= '※稼働環境を選択して下さい<br />';
1721 if( 'on' == $options['acting_settings']['veritrans']['card_activate'] ) {
1722 if( WCUtils::is_blank($options['acting_settings']['veritrans']['card_capture_flag']) )
1723 $mes .= '※カード売上フラグを選択して下さい<br />';
1724 }
1725
1726 if( WCUtils::is_blank($mes) ) {
1727 $this->action_status = 'success';
1728 $this->action_message = __('options are updated','usces');
1729 $options['acting_settings']['veritrans']['activate'] = 'on';
1730 $options['acting_settings']['veritrans']['regist_url'] = "https://air.veritrans.co.jp/web/commodityRegist.action";
1731 $options['acting_settings']['veritrans']['payment_url'] = "https://air.veritrans.co.jp/web/paymentStart.action";
1732 if( 'on' == $options['acting_settings']['veritrans']['card_activate'] ) {
1733 $this->payment_structure['acting_veritrans_card'] = 'カード決済(ベリトランス)';
1734 } else {
1735 unset($this->payment_structure['acting_veritrans_card']);
1736 }
1737 if( 'on' == $options['acting_settings']['veritrans']['conv_activate'] ) {
1738 $this->payment_structure['acting_veritrans_conv'] = 'コンビニ決済(ベリトランス)';
1739 } else {
1740 unset($this->payment_structure['acting_veritrans_conv']);
1741 }
1742 update_option('usces', $options);
1743 } else {
1744 $this->action_status = 'error';
1745 $this->action_message = __('Data have deficiency.','usces');
1746 $options['acting_settings']['veritrans']['activate'] = 'off';
1747 unset($this->payment_structure['acting_veritrans_card']);
1748 unset($this->payment_structure['acting_veritrans_conv']);
1749 }
1750 ksort($this->payment_structure);
1751 update_option('usces_payment_structure', $this->payment_structure);
1752 break;
1753 //20140206ysk end
1754 }
1755
1756 }
1757
1758 $this->options = get_option('usces');
1759
1760 require_once(USCES_PLUGIN_DIR . '/includes/admin_settlement.php');
1761 }
1762
1763 /********************************************************************************/
1764 function selected( $selected, $current) {
1765 if ( $selected == $current)
1766 echo ' selected="selected"';
1767 }
1768 /********************************************************************************/
1769
1770 function usces_session_start() {
1771 $options = get_option('usces');
1772 if( !isset($options['usces_key']) || empty($options['usces_key']) ){
1773 $options['usces_key'] = uniqid('uk');
1774 update_option('usces', $options);
1775 }
1776
1777 if(defined( 'USCES_KEY' )){
1778 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1779 session_name( 'adm'.USCES_KEY );
1780 }else{
1781 session_name( USCES_KEY );
1782 }
1783 }else{
1784 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1785 session_name( 'adm'.$options['usces_key'] );
1786 }else{
1787 session_name( $options['usces_key'] );
1788 }
1789 }
1790 if(isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid'])) {
1791 $sessid = $_GET['uscesid'];
1792 $sessid = $this->uscesdc($sessid);
1793 session_id($sessid);
1794 }
1795
1796 @session_start();
1797
1798 //20111222ysk start 0000367
1799 //if ( !isset($_SESSION['usces_member']) ){
1800 if ( !isset($_SESSION['usces_member']) || $options['membersystem_state'] != 'activate' ){
1801 //20111222ysk end
1802 $_SESSION['usces_member'] = array();
1803 }
1804
1805 if(!isset($_SESSION['usces_checked_business_days']))
1806 $this->update_business_days();
1807 }
1808
1809 function usces_cookie() {
1810 if(is_admin()) return;
1811
1812 $actionflag = false;
1813 $sess = NULL;
1814 $addr = NULL;
1815 $rckid = NULL;
1816 $none = NULL;
1817 $cookie = $this->get_cookie();
1818
1819 if( isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid']) ){
1820 $sessid = base64_decode(urldecode($_GET['uscesid']));
1821 list($sess, $addr, $rckid, $none) = explode('_', $sessid, 4);
1822 }
1823 if('acting' == $addr) return;
1824
1825 if( apply_filters( 'usces_filter_cookie', false) ) return;
1826
1827 //There is a need to consider.
1828 return;
1829
1830 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
1831
1832 $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
1833 $sslid = isset($cookie['sslid']) ? $cookie['sslid'] : NULL;
1834 $option = get_option('usces');
1835 $parsed = parse_url(get_option('home'));
1836 $home = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1837 $parsed = parse_url($option['ssl_url']);
1838 $sslhome = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1839
1840 //usces_log('refer : '.$refer, 'acting_transaction.log');
1841 // usces_log('sslid : '.$sslid, 'acting_transaction.log');
1842 // usces_log('rckid : '.$rckid, 'acting_transaction.log');
1843 // usces_log('usces_cookieid : '.$_SESSION['usces_cookieid'], 'acting_transaction.log');
1844 // usces_log('request : '.print_r($_SERVER['REQUEST_URI'],true), 'acting_transaction.log');
1845
1846 if( empty($refer) || (false === strpos($refer, $home) && false === strpos($refer, $sslhome)) ){
1847 if( !empty($sslid) && !empty($rckid) && $sslid === $rckid ){
1848 $actionflag = true;
1849 }else{
1850 $actionflag = false;
1851 }
1852 }else{
1853 if( !empty($sslid) && $sslid !== $rckid ){
1854 $actionflag = false;
1855 }else{
1856 $actionflag = true;
1857 }
1858 }
1859
1860
1861 if( $actionflag ){
1862 $values = array(
1863 'id' => $rckid,
1864 'sslid' => $rckid,
1865 'name' => '',
1866 'rme' => ''
1867 );
1868 if( 'acting' !== $rckid ){
1869 $this->set_cookie($values);
1870 }
1871 }else{
1872 if( 'acting' !== $rckid ){
1873 unset($_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] );
1874 wp_redirect( 'http://'.$home );
1875 }
1876 }
1877 }else{
1878 if( !isset($cookie['id']) || WCUtils::is_blank($cookie['id']) ) {
1879 $values = array(
1880 'id' => md5(uniqid(rand(), true)),
1881 'name' => '',
1882 'rme' => ''
1883 );
1884 $this->set_cookie($values);
1885 $_SESSION['usces_cookieid'] = $values['id'];
1886 } else {
1887 if( !isset($_SESSION['usces_cookieid']) || $_SESSION['usces_cookieid'] != $cookie['id'])
1888 $_SESSION['usces_cookieid'] = $cookie['id'];
1889 }
1890
1891 $actionflag = true;
1892 }
1893
1894 }
1895
1896 function set_cookie($values){
1897 $value = serialize($values);
1898 $timeout = time()+7*86400;
1899 $domain = $_SERVER['SERVER_NAME'];
1900 $res = setcookie('usces_cookie', $value, $timeout, USCES_COOKIEPATH, $domain);
1901 }
1902
1903 function get_cookie() {
1904 $values = isset($_COOKIE['usces_cookie']) ? unserialize(stripslashes($_COOKIE['usces_cookie'])) : NULL;
1905 return $values;
1906 }
1907
1908 function get_access( $key, $type, $date ) {
1909 global $wpdb;
1910 $table_name = $wpdb->prefix . "usces_access";
1911
1912 $query = $wpdb->prepare("SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date);
1913 $value = $wpdb->get_var( $query );
1914 if( !$value ){
1915 $res = NULL;
1916 }else{
1917 $res = unserialize($value);
1918 }
1919
1920 return $res;
1921 }
1922
1923 function get_access_piriod( $key, $type, $startday, $endday ) {
1924 global $wpdb;
1925 $table_name = $wpdb->prefix . "usces_access";
1926 //$wpdb->show_errors();
1927 $query = $wpdb->prepare("SELECT acc_type, acc_value, acc_date FROM $table_name WHERE acc_key = %s AND acc_type = %s AND (acc_date >= %s AND acc_date <= %s)", $key, $type, $startday, $endday);
1928 $res = $wpdb->get_results( $query, ARRAY_A );
1929
1930 return $res;
1931 }
1932
1933 function update_access( $array ) {
1934 global $wpdb;
1935 $table_name = $wpdb->prefix . "usces_access";
1936
1937 $query = $wpdb->prepare("SELECT ID FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $array['acc_key'], $array['acc_type'], $array['acc_date']);
1938 $res = $wpdb->get_var( $query );
1939 //$wpdb->show_errors();
1940 if(empty($res)){
1941 $query = $wpdb->prepare("INSERT INTO $table_name (acc_key, acc_type, acc_value, acc_date) VALUES(%s, %s, %s, %s)", $array['acc_key'], $array['acc_type'], serialize($array['acc_value']), $array['acc_date']);
1942 $wpdb->query( $query );
1943 }else{
1944 $query = $wpdb->prepare("UPDATE $table_name SET acc_value = %s WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", serialize($array['acc_value']), $array['acc_key'], $array['acc_type'], $array['acc_date']);
1945 $wpdb->query( $query );
1946 }
1947 }
1948
1949 function get_uscesid( $flag = true) {
1950
1951 $sessname = session_name();
1952 $sessid = session_id();
1953 $sessid = $this->uscescv($sessid, $flag);
1954 return $sessid;
1955 }
1956
1957 function shop_head() {
1958 global $post;
1959 $this->item = $post;
1960 $no_cart_css = isset($this->options['system']['no_cart_css']) ? $this->options['system']['no_cart_css'] : 0;
1961
1962 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1963 $css_url = USCES_FRONT_PLUGIN_URL . '/css/usces_cart.css';
1964 }else{
1965 $css_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/css/usces_cart.css';
1966 }
1967 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) ){
1968 echo " <meta name='robots' content='noindex,nofollow' />\n";
1969 wp_print_scripts( array( 'sack' ));
1970 }
1971 if( !$no_cart_css ){
1972 echo '<link href="' . $css_url . '" rel="stylesheet" type="text/css" />';
1973 }
1974 if( file_exists(get_stylesheet_directory() . '/usces_cart.css') ){
1975 echo '<link href="' . get_stylesheet_directory_uri() . '/usces_cart.css" rel="stylesheet" type="text/css" />';
1976 }
1977 }
1978
1979 function shop_foot() {
1980 global $current_user;
1981 $item = $this->item;
1982 if( empty($item) ){
1983 $item->ID = 0;
1984 $item->post_mime_type = '';
1985 }
1986 get_currentuserinfo();
1987 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1988 $javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js';
1989 }else{
1990 $javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js';
1991 }
1992 // $this->member_name = ( is_user_logged_in() ) ? esc_js(get_user_meta($current_user->ID,'first_name').get_user_meta($current_user->ID,'last_name')) : '';
1993 $this->previous_url = isset($_SESSION['usces_previous_url']) ? $_SESSION['usces_previous_url'] : get_home_url();
1994
1995 // usces_log('post_type : '.$item->post_mime_type, 'test.log');
1996 // usces_log('is_single : '.(is_single() ? 'true' : 'false'), 'test.log');
1997
1998 if( $this->use_js && empty($this->item) && !is_admin() ) :
1999 ?>
2000 <script type='text/javascript'>
2001 /* <![CDATA[ */
2002 uscesL10n = {
2003 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
2004 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>"
2005 }
2006 /* ]]> */
2007 </script>
2008 <?php elseif( $this->use_js && !empty($this->item) ) :
2009
2010 $ioptkeys = $this->get_itemOptionKey( $item->ID );
2011 $mes_opts_str = "";
2012 $key_opts_str = "";
2013 $opt_means = "";
2014 $opt_esse = "";
2015 if($ioptkeys){
2016 foreach($ioptkeys as $key => $value){
2017 $optValues = $this->get_itemOptions( $value, $item->ID );
2018 if($optValues['means'] < 2){
2019 $mes_opts_str .= "'" . sprintf(__("Chose the %s", 'usces'), esc_js($value)) . "',";
2020 }else{
2021 $mes_opts_str .= "'" . sprintf(__("Input the %s", 'usces'), esc_js($value)) . "',";
2022 }
2023 $key_opts_str .= "'" . urlencode(esc_js($value)) . "',";
2024 $opt_means .= "'" . esc_js($optValues['means']) . "',";
2025 $opt_esse .= "'" . esc_js($optValues['essential']) . "',";
2026 }
2027 $mes_opts_str = rtrim($mes_opts_str, ',');
2028 $key_opts_str = rtrim($key_opts_str, ',');
2029 $opt_means = rtrim($opt_means, ',');
2030 $opt_esse = rtrim($opt_esse, ',');
2031 }
2032 //$itemRestriction = get_post_custom_values('_itemRestriction', $item->ID);
2033 $itemRestriction = get_post_meta($item->ID, '_itemRestriction', true);
2034
2035 ?>
2036 <script type='text/javascript'>
2037 /* <![CDATA[ */
2038 uscesL10n = {
2039 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
2040 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>",
2041 'post_id': "<?php echo $item->ID; ?>",
2042 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
2043 'is_cart_row': <?php echo ( (0 < $this->cart->num_row()) ? 'true' : 'false'); ?>,
2044 'opt_esse': new Array( <?php echo $opt_esse; ?> ),
2045 'opt_means': new Array( <?php echo $opt_means; ?> ),
2046 'mes_opts': new Array( <?php echo $mes_opts_str; ?> ),
2047 'key_opts': new Array( <?php echo $key_opts_str; ?> ),
2048 'previous_url': "<?php echo $this->previous_url; ?>",
2049 'itemRestriction': "<?php echo $itemRestriction; ?>"
2050 }
2051 /* ]]> */
2052 </script>
2053 <script type='text/javascript' src='<?php echo $javascript_url; ?>'></script>
2054 <?php endif; ?>
2055 <?php ob_start(); ?>
2056 <?php if( $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || (is_singular() && 'item' == $item->post_mime_type)) ) : ?>
2057 <script type='text/javascript'>
2058 (function($) {
2059 uscesCart = {
2060 intoCart : function (post_id, sku) {
2061
2062 var zaikonum = document.getElementById("zaikonum["+post_id+"]["+sku+"]").value;
2063 var zaiko = document.getElementById("zaiko["+post_id+"]["+sku+"]").value;
2064 if( (zaiko != '0' && zaiko != '1') || parseInt(zaikonum) == 0 ){
2065 alert('<?php _e('temporaly out of stock now', 'usces'); ?>');
2066 return false;
2067 }
2068
2069 var mes = '';
2070 if(document.getElementById("quant["+post_id+"]["+sku+"]")){
2071 var quant = document.getElementById("quant["+post_id+"]["+sku+"]").value;
2072 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2073 mes += "<?php _e('enter the correct amount', 'usces'); ?>\n";
2074 }
2075 var checknum = '';
2076 var checkmode = '';
2077 if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
2078 checknum = uscesL10n.itemRestriction;
2079 checkmode ='rest';
2080 } else if( parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
2081 checknum = zaikonum;
2082 checkmode ='zaiko';
2083 } else if( (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) {
2084 checknum = zaikonum;
2085 checkmode ='zaiko';
2086 } else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum == '' ) {
2087 checknum = uscesL10n.itemRestriction;
2088 checkmode ='rest';
2089 }
2090
2091
2092 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2093 if(checkmode == 'rest'){
2094 mes += <?php _e("'This article is limited by '+checknum+' at a time.'", 'usces'); ?>+"\n";
2095 }else{
2096 mes += <?php _e("'Stock is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2097 }
2098 }
2099 }
2100 for(i=0; i<uscesL10n.key_opts.length; i++){
2101 var skuob = document.getElementById("itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]");
2102 if( uscesL10n.opt_esse[i] == '1' && null != skuob ){
2103
2104 if( uscesL10n.opt_means[i] < 2 && skuob.value == '#NONE#' ){
2105 mes += uscesL10n.mes_opts[i]+"\n";
2106 }else if( uscesL10n.opt_means[i] >= 2 && skuob.value == '' ){
2107 mes += uscesL10n.mes_opts[i]+"\n";
2108 }
2109 }
2110 }
2111
2112 <?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); //Unavailable ?>
2113 <?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?>
2114
2115 if( mes != '' ){
2116 alert( mes );
2117 return false;
2118 }else{
2119 <?php echo apply_filters('usces_filter_js_intoCart', "return true;\n", $item->ID, NULL); ?>
2120 }
2121 },
2122
2123 upCart : function () {
2124
2125 var zaikoob = $("input[name*='zaikonum']");
2126 var quantob = $("input[name*='quant']");
2127 var postidob = $("input[name*='itempostid']");
2128 var skuob = $("input[name*='itemsku']");
2129
2130 var zaikonum = '';
2131 var zaiko = '';
2132 var quant = '';
2133 var mes = '';
2134 var checknum = '';
2135 var post_id = '';
2136 var sku = '';
2137 var itemRestriction = '';
2138
2139 var ct = zaikoob.length;
2140 for(var i=0; i< ct; i++){
2141 post_id = postidob[i].value;
2142 sku = skuob[i].value;
2143 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2144 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2145
2146 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2147 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2148 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2149 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2150 }
2151 var checknum = '';
2152 var checkmode = '';
2153 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2154 checknum = itemRestriction;
2155 checkmode ='rest';
2156 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2157 checknum = zaikonum;
2158 checkmode ='zaiko';
2159 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2160 checknum = zaikonum;
2161 checkmode ='zaiko';
2162 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2163 checknum = itemRestriction;
2164 checkmode ='rest';
2165 }
2166 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2167 if(checkmode == 'rest'){
2168 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2169 }else{
2170 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2171 }
2172 }
2173 }
2174 }
2175
2176 <?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); //Unavailable ?>
2177 <?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?>
2178
2179 if( mes != '' ){
2180 alert( mes );
2181 return false;
2182 }else{
2183 <?php echo apply_filters('usces_filter_js_upCart', "return true;\n", $item->ID, NULL); ?>
2184 }
2185 },
2186
2187 cartNext : function () {
2188
2189 var zaikoob = $("input[name*='zaikonum']");
2190 var quantob = $("input[name*='quant']");
2191 var postidob = $("input[name*='itempostid']");
2192 var skuob = $("input[name*='itemsku']");
2193
2194 var zaikonum = '';
2195 var zaiko = '';
2196 var quant = '';
2197 var mes = '';
2198 var checknum = '';
2199 var post_id = '';
2200 var sku = '';
2201 var itemRestriction = '';
2202
2203 var ct = zaikoob.length;
2204 for(var i=0; i< ct; i++){
2205 post_id = postidob[i].value;
2206 sku = skuob[i].value;
2207 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2208 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2209
2210 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2211 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2212 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2213 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2214 }
2215 var checknum = '';
2216 var checkmode = '';
2217 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2218 checknum = itemRestriction;
2219 checkmode ='rest';
2220 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2221 checknum = zaikonum;
2222 checkmode ='zaiko';
2223 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2224 checknum = zaikonum;
2225 checkmode ='zaiko';
2226 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2227 checknum = itemRestriction;
2228 checkmode ='rest';
2229 }
2230
2231 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2232 if(checkmode == 'rest'){
2233 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2234 }else{
2235 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2236 }
2237 }
2238 }
2239 }
2240 if( mes != '' ){
2241 alert( mes );
2242 return false;
2243 }else{
2244 return true;
2245 }
2246 },
2247
2248 previousCart : function () {
2249 location.href = uscesL10n.previous_url;
2250 },
2251
2252 settings: {
2253 url: uscesL10n.ajaxurl,
2254 type: 'POST',
2255 cache: false,
2256 success: function(data, dataType){
2257 //$("tbody#item-opt-list").html( data );
2258 },
2259 error: function(msg){
2260 //$("#ajax-response").html(msg);
2261 }
2262 },
2263
2264 changeStates : function( country ) {
2265 var s = this.settings;
2266 s.data = "action=change_states_ajax&country=" + country;
2267 s.success = function(data, dataType){
2268 if( 'error' == data ){
2269 alert('error');
2270 }else{
2271 $("select#pref").html( data );
2272 }
2273 };
2274 s.error = function(msg){
2275 alert("error");
2276 };
2277 $.ajax( s );
2278 return false;
2279 },
2280
2281 isNum : function (num) {
2282 if (num.match(/[^0-9]/g)) {
2283 return false;
2284 }
2285 return true;
2286 },
2287 purchase : 0
2288 };
2289 $("#country").change(function () {
2290 var country = $("#country option:selected").val();
2291 $("#newcharging_type option:selected").val()
2292 uscesCart.changeStates( country );
2293 });
2294 $("#purchase_form").submit(function () {
2295 if( 0 == uscesCart.purchase ){
2296 uscesCart.purchase = 1;
2297 return true;
2298 }else{
2299 $("#purchase_button").attr("disabled", "disabled");
2300 $("#back_button").attr("disabled", "disabled");
2301 return false;
2302 }
2303 });
2304
2305 })(jQuery);
2306 </script>
2307 <?php endif; ?>
2308 <?php
2309 usces_states_form_js();
2310 $js = apply_filters( 'usces_filter_shop_foot_js', ob_get_contents() );
2311 ob_end_clean();
2312 echo $js;
2313
2314 }
2315
2316 function admin_head() {
2317 global $wp_version;
2318 $payments_str = '';
2319 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
2320 foreach ( (array)$payments as $id => $array ) {
2321 $payments_str .= "'" . esc_js($array['name']) . "': '" . esc_js($array['settlement']) . "', ";
2322 }
2323 $payments_str .= "'" . __('Transfer (prepayment)', 'usces') . "': 'transferAdvance', ";
2324 $payments_str .= "'" . __('Transfer (postpay)', 'usces') . "': 'transferDeferred', ";
2325 $payments_str .= "'" . __('COD', 'usces') . "': 'COD', ";
2326 $payments_str = rtrim($payments_str, ', ');
2327 $wcex_str = '';
2328 $wcex = usces_get_wcex();
2329 foreach ( (array)$wcex as $key => $values ) {
2330 $wcex_str .= "'" . esc_js($key) . "-" . esc_js($values['version']) . "', ";
2331 }
2332 $wcex_str = rtrim($wcex_str, ', ');
2333 if ( version_compare($wp_version, '3.4', '>=') ){
2334 $theme_ob = wp_get_theme();
2335 $theme['Name'] = esc_js($theme_ob->get('Name'));
2336 $theme['Version'] = esc_js($theme_ob->get('Version'));
2337 }else{
2338 $theme = get_theme_data( get_stylesheet_directory().'/style.css' );//20120618ysk
2339 }
2340 ?>
2341
2342 <link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" />
2343 <script type='text/javascript'>
2344 /* <![CDATA[ */
2345 uscesL10n = {
2346 <?php echo apply_filters('usces_filter_admin_uscesL10n', NULL ); ?>
2347 'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php",
2348 'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>",
2349 'version': "<?php echo USCES_VERSION; ?>",
2350 'wcid': "<?php echo get_option('usces_wcid'); ?>",
2351 'locale': '<?php echo get_locale(); ?>',
2352 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
2353 'purchase_limit': "<?php echo $this->options['purchase_limit']; ?>",
2354 'point_rate': "<?php echo $this->options['point_rate']; ?>",
2355 'shipping_rule': "<?php echo $this->options['shipping_rule']; ?>",
2356 'theme': "<?php echo $theme['Name'] . '-' . $theme['Version']; ?>",
2357 'wcex': new Array( <?php echo $wcex_str; ?> ),
2358 'now_loading': "<?php _e('now loading', 'usces'); ?>"
2359 };
2360 uscesPayments = {<?php echo $payments_str; ?>};
2361 /* ]]> */
2362 </script>
2363 <script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js'></script>
2364 <?php
2365 if($this->action_status == 'edit' || $this->action_status == 'editpost'){
2366 ?>
2367 <link rel='stylesheet' href='<?php echo site_url(); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' />
2368 <?php
2369 }
2370 if( isset($_REQUEST['page']) ){
2371 switch( $_REQUEST['page'] ){
2372 case 'usces_initial':
2373 ?>
2374 <script type='text/javascript'>
2375 /* <![CDATA[ */
2376 usces_ini = {
2377 'cod_type': "<?php if( 'change' == $this->options['cod_type'] ) {echo 'change';}else{echo 'fix';} ?>",
2378 'cod_type_fix': "<?php echo esc_js(__('Fixation C.O.D.', 'usces')); ?>",
2379 'cod_type_change': "<?php echo esc_js(__('Variable C.O.D.', 'usces')); ?>",
2380 'cod_unit': "<?php echo esc_js(__('dollars', 'usces')); ?>",
2381 'cod_failure': "<?php echo esc_js(__('failure in update', 'usces')); ?>",
2382 'cod_updated': "<?php echo esc_js(__('options are updated', 'usces')); ?>",
2383 'cod_limit': "<?php echo esc_js(__('A value of the amount of upper limit is dirty.', 'usces')); ?>"
2384 };
2385 /* ]]> */
2386 </script>
2387 <?php
2388 break;
2389 case 'usces_itemnew':
2390 case 'usces_itemedit':
2391 ?>
2392 <style type="text/css">
2393 <!--
2394 #usces_mess {
2395 color: #FF0000;
2396 font-weight: bold;
2397 }
2398 -->
2399 </style>
2400 <?php
2401 break;
2402 }
2403 }
2404 ?>
2405 <?php
2406 if( is_admin() && ( (isset($_GET['order_action']) && 'newpost' == $_GET['order_action'])
2407 || (isset($_GET['page']) && 'usces_ordernew' == $_GET['page'])
2408 || (isset($_GET['order_action']) && 'edit' == $_GET['order_action'])
2409 || (isset($_GET['order_action']) && 'editpost' == $_GET['order_action'])
2410 || (isset($_GET['member_action']) && 'edit' == $_GET['member_action'])
2411 || (isset($_GET['member_action']) && 'editpost' == $_GET['member_action'])) ) :
2412 switch( $_GET['page'] ){
2413 case 'usces_ordernew':
2414 case 'usces_orderlist':
2415 $admin_page = 'order';
2416 break;
2417 case 'usces_memberlist':
2418 $admin_page = 'member';
2419 break;
2420 }
2421 ?>
2422 <script type='text/javascript'>
2423 jQuery(function($) {
2424 uscesForm = {
2425 settings: {
2426 url: uscesL10n.requestFile,
2427 type: 'POST',
2428 cache: false,
2429 success: function(data, dataType){
2430 //$("tbody#item-opt-list").html( data );
2431 },
2432 error: function(msg){
2433 //$("#ajax-response").html(msg);
2434 }
2435 },
2436
2437 changeStates : function( country, type ) {
2438 var s = this.settings;
2439 s.data = "action=change_states_ajax&country=" + country;
2440 s.success = function(data, dataType){
2441 if( 'error' == data ){
2442 alert('error');
2443 }else{
2444 $("select#" + type + "_pref").html( data );
2445 if( customercountry == country && 'customer' == type ){
2446 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2447 }else if( deliverycountry == country && 'delivery' == type ){
2448 $("#" + type + "_pref").attr({selectedIndex:deliverystate});
2449 }else if( customercountry == country && 'member' == type ){
2450 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2451 }
2452 }
2453 };
2454 s.error = function(msg){
2455 alert("error");
2456 };
2457 $.ajax( s );
2458 return false;
2459 },
2460
2461 isNum : function (num) {
2462 if (num.match(/[^0-9]/g)) {
2463 return false;
2464 }
2465 return true;
2466 }
2467 };
2468 <?php
2469 if( 'order' == $admin_page ){
2470 ?>
2471 if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) {
2472 var customerstate = $("#customer_pref").get(0).selectedIndex;
2473 var customercountry = $("#customer_country").val();
2474 var deliverystate = $("#delivery_pref").get(0).selectedIndex;
2475 var deliverycountry = $("#delivery_country").val();
2476
2477 $("#customer_country").change(function () {
2478 var country = $("#customer_country option:selected").val();
2479 uscesForm.changeStates( country, 'customer' );
2480 });
2481 $("#delivery_country").change(function () {
2482 var country = $("#delivery_country option:selected").val();
2483 uscesForm.changeStates( country, 'delivery' );
2484 });
2485 }
2486 <?php
2487 }else if( 'member' == $admin_page ){
2488 ?>
2489 if( undefined != $("#member_pref").get(0) ) {
2490 var customerstate = $("#member_pref").get(0).selectedIndex;
2491 var customercountry = $("#member_country").val();
2492 var deliverystate = '';
2493 var deliverycountry = '';
2494
2495 $("#member_country").change(function () {
2496 var country = $("#member_country option:selected").val();
2497 uscesForm.changeStates( country, 'member' );
2498 });
2499 }
2500 <?php
2501 }
2502 ?>
2503 });
2504 </script>
2505 <?php
2506 endif;
2507 }
2508
2509 function main() {
2510 global $wpdb, $wp_locale, $wp_version, $post_ID;
2511 global $wp_query, $usces_action, $post, $action, $editing;
2512
2513 update_option('usces_shipping_rule', apply_filters('usces_filter_shipping_rule', get_option('usces_shipping_rule')));
2514 $this->shipping_rule = get_option('usces_shipping_rule');
2515
2516 // $_wp_http_referer = isset($_POST['_wp_http_referer']) ? $_POST['_wp_http_referer'] : 'a';
2517 // if( isset($_POST) && 1 !== preg_match('/(?:plugin|theme)-editor\.php/', $_wp_http_referer) ){
2518 // $_POST = $this->stripslashes_deep_post($_POST);
2519 // }
2520 usces_upgrade_14();
2521 if( !is_admin() ){
2522 $this->usces_cookie();
2523 }else{
2524 $this->user_level = usces_get_admin_user_level();
2525 }
2526 $this->make_url();
2527
2528 //usces_log('HTTP_REFERER : '.$_SERVER['HTTP_REFERER'], 'acting_transaction.log');
2529 //usces_log('REQUEST_URI : '.$_SERVER['REQUEST_URI'], 'acting_transaction.log');
2530
2531 do_action('usces_main');
2532 $this->update_table();
2533
2534
2535 // if( ( !isset( $_POST['confirm'] ) && $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) && !is_admin() ){
2536 // header('Expires:-1');
2537 // header('Cache-Control:');
2538 // header('Pragma:');
2539 // }
2540
2541 //var_dump($_REQUEST);
2542 require_once(USCES_PLUGIN_DIR . '/classes/cart.class.php');
2543 $this->cart = new usces_cart();
2544
2545 do_action('usces_after_cart_instant');
2546
2547 if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate' ){
2548 $post_id = (int)$_GET['post'];
2549 $new_id = usces_item_dupricate($post_id);
2550 $ref = isset($_REQUEST['usces_referer']) ? urlencode($_REQUEST['usces_referer']) : '';
2551 $url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref;
2552 wp_redirect($url);
2553 exit;
2554 }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'itemcsv' ){
2555 $filename = usces_item_uploadcsv();
2556 $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&regfile='.$filename;
2557 wp_redirect($url);
2558 exit;
2559 //member_up
2560 // }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_memberlist' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'membercsv'){
2561 // $filename = usces_upload_member_list();
2562 // $url = USCES_ADMIN_URL . '?page=usces_memberlist&usces_status=none&usces_message=&member_action=upload_register&regfile='.$filename;
2563 // wp_redirect($url);
2564 // exit;
2565 }
2566 //20110208ysk start
2567 if( isset($this->options['acting_settings']['paypal']) and 'on' == $this->options['acting_settings']['paypal']['ec_activate'] ) {
2568 require_once( USCES_PLUGIN_DIR.'/classes/paymentPaypal.class.php' );
2569 $this->paypal = new usces_paypal();
2570 }
2571 //20110208ysk end
2572
2573 $this->ad_controller();
2574 //$this->controller();
2575
2576
2577
2578 if( isset($_GET['page']) && $_GET['page'] == 'usces_itemnew'){
2579 $itemnew = 'new';
2580 }else{
2581 $itemnew = '';
2582 }
2583
2584 wp_enqueue_script('jquery');
2585
2586 if( is_admin() && isset($_REQUEST['page']) && ((isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') || $itemnew == 'new' || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'editpost'))) {
2587
2588 if(isset($_REQUEST['action']) && $_REQUEST['action'] != 'editpost' && $itemnew == 'new'){
2589 if ( version_compare($wp_version, '3.0-beta', '>') ){
2590 if ( !isset($_GET['post_type']) )
2591 $post_type = 'post';
2592 elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
2593 $post_type = $_GET['post_type'];
2594 else
2595 wp_die( __('Invalid post type') );
2596 $post_type_object = get_post_type_object($post_type);
2597 $editing = true;
2598 // if ( current_user_can($post_type_object->edit_type_cap) ) {
2599 $post = $this->get_default_post_to_edit30( $post_type, true );
2600 $post_ID = $post->ID;
2601 // }
2602
2603 }else{
2604 $post = $this->get_default_post_to_edit();
2605 }
2606 }else{
2607 if ( version_compare($wp_version, '3.0-beta', '>') ){
2608 if ( isset($_GET['post']) )
2609 $post_id = (int) $_GET['post'];
2610 elseif ( isset($_POST['post_ID']) )
2611 $post_id = (int) $_POST['post_ID'];
2612 else
2613 $post_id = 0;
2614 $post_ID = $post_id;
2615 $post = null;
2616 $post_type_object = null;
2617 $post_type = null;
2618 if ( $post_id ) {
2619 $post = get_post($post_id);
2620 if ( $post ) {
2621 $post_type_object = get_post_type_object($post->post_type);
2622 if ( $post_type_object ) {
2623 $post_type = $post->post_type;
2624 if( !isset($current_screen) ){
2625 $current_screen = new stdClass();
2626 }
2627 $current_screen->post_type = $post->post_type;
2628 $current_screen->id = $current_screen->post_type;
2629 }
2630 }
2631 } elseif ( isset($_POST['post_type']) ) {
2632 $post_type_object = get_post_type_object($_POST['post_type']);
2633 if ( $post_type_object ) {
2634 $post_type = $post_type_object->name;
2635 $current_screen->post_type = $post_type;
2636 $current_screen->id = $current_screen->post_type;
2637 }
2638 }
2639
2640
2641 // $post = get_post( $post_id, OBJECT, 'edit' );
2642 // if ( $post->post_type == 'page' )
2643 // $post->page_template = get_post_meta( $id, '_wp_page_template', true );
2644
2645 }else{
2646 if(isset($_GET['post'])){
2647 $post_ID = (int) $_GET['post'];
2648 $post = get_post($post_ID);
2649 }else{
2650 $post_ID = isset($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : 0;
2651 if(!empty($post_ID))
2652 $post = get_post($post_ID);
2653 }
2654 }
2655 // global $wp_query, $usces_action, $post;
2656
2657 }
2658 $editing = true;
2659 wp_enqueue_script('autosave');
2660 wp_enqueue_script('post');
2661 //if ( user_can_richedit() )
2662 //wp_enqueue_script('editor');
2663 add_thickbox();
2664 wp_enqueue_script('media-upload');
2665 wp_enqueue_script('word-count');
2666 wp_enqueue_script( 'admin-comments' );
2667
2668 if ( version_compare($wp_version, '3.3', '<') )
2669 add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
2670 wp_enqueue_script('quicktags');
2671
2672 }
2673
2674
2675 if( is_admin() && isset($_REQUEST['page']) ){
2676
2677 wp_enqueue_script('jquery-color');
2678
2679 switch( $_REQUEST['page'] ){
2680
2681 case 'usces_initial':
2682 $js = USCES_FRONT_PLUGIN_URL.'/js/usces_initial.js';
2683 wp_enqueue_script('usces_initial.js', $js, array('jquery-ui-dialog', 'jquery-ui-sortable'));
2684 //wp_enqueue_script('jquery-ui-sortable');
2685 break;
2686 case 'usces_settlement':
2687 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2688 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2689 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2690 $jquery_colorUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/color/jscolor.js';
2691 wp_enqueue_script( 'jquery-jscolor', $jquery_colorUrl, array('jquery-color') );
2692 break;
2693 case 'usces_cart':
2694 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2695 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2696 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2697 break;
2698 case 'usces_member':
2699 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2700 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2701 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2702 break;
2703 case 'usces_orderlist':
2704 case 'usces_ordernew':
2705 wp_enqueue_script('jquery-ui-dialog');
2706 break;
2707 case 'usces_memberlist':
2708 wp_enqueue_script('jquery-ui-dialog');
2709 break;
2710 case 'usces_itemnew':
2711 wp_enqueue_script('jquery-ui-sortable');
2712 break;
2713 case 'usces_itemedit':
2714 if( isset($_REQUEST['action']) && 'upload_register' == $_REQUEST['action'] ){
2715 @ob_end_clean();
2716 ob_start();
2717 }else{
2718 wp_enqueue_script('jquery-ui-sortable');
2719 wp_enqueue_script('jquery-ui-dialog');
2720 }
2721 break;
2722 case 'usces_delivery':
2723 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2724 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2725 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2726 break;
2727 case 'usces_system':
2728 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2729 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery/jquery.cookie.js';
2730 wp_enqueue_script( 'jquery-cookie', $jquery_cookieUrl, array('jquery') );
2731 break;
2732 }
2733 }
2734
2735 if( isset($_REQUEST['order_action']) && $_REQUEST['order_action'] == 'pdfout' ){
2736 $this->get_current_member();
2737 $mid = $this->current_member['id'];
2738 $oid = $_GET['order_id'];
2739 if( !is_user_logged_in() && !$this->is_order($mid, $oid) )
2740 die('No permission');
2741 require_once( apply_filters('usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php') );
2742 }
2743
2744 do_action( 'usces_after_main' );
2745 }
2746
2747 function stripslashes_deep_post( $array ){
2748 $res = array();
2749 foreach( $array as $key => $value ){
2750 $key = stripslashes($key);
2751 if( is_array($value) ){
2752 $value = $this->stripslashes_deep_post( $value );
2753 }else{
2754 $value = stripslashes($value);
2755 }
2756 $res[$key] = $value;
2757 }
2758 return $res;
2759 }
2760
2761 function make_url(){
2762
2763 $permalink_structure = get_option('permalink_structure');
2764 //usces_log('use_ssl : '.$this->use_ssl, 'acting_transaction.log');
2765 if($this->use_ssl) {
2766 if( $permalink_structure ){
2767 $this->delim = '&';
2768 $home_perse = parse_url(get_option('home'));
2769 $home_perse_path = isset($home_perse['path']) ? $home_perse['path'] : '';
2770 $home_path = $home_perse['host'].$home_perse_path;
2771 $ssl_perse = parse_url($this->options['ssl_url']);
2772 $ssl_perse_path = isset($ssl_perse['path']) ? $ssl_perse['path'] : '';
2773 $ssl_path = $ssl_perse['host'].$ssl_perse_path;
2774 if( $home_perse_path != $ssl_perse_path ){
2775 if( ! defined('USCES_CUSTOMER_URL') )
2776 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2777 if( ! defined('USCES_CART_URL') )
2778 define('USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2779 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2780 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2781 if( ! defined('USCES_NEWMEMBER_URL') )
2782 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2783 if( ! defined('USCES_LOGIN_URL') )
2784 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2785 if( ! defined('USCES_LOGOUT_URL') )
2786 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2787 if( ! defined('USCES_MEMBER_URL') )
2788 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2789 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2790 if( ! defined('USCES_INQUIRY_URL') )
2791 define('USCES_INQUIRY_URL', $inquiry_url);
2792 if( ! defined('USCES_CART_NONSESSION_URL') )
2793 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER);
2794 //20110208ysk start
2795 //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));
2796 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2797 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2798 //20110208ysk end
2799 }else{
2800 $ssl_plink_cart = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_CART_NUMBER) ));
2801 $ssl_plink_member = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_MEMBER_NUMBER) ));
2802 if( ! defined('USCES_CUSTOMER_URL') )
2803 define('USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1');
2804 if( ! defined('USCES_CART_URL') )
2805 define('USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid());
2806 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2807 define('USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2808 if( ! defined('USCES_NEWMEMBER_URL') )
2809 define('USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid(). '&page=newmember');
2810 if( ! defined('USCES_LOGIN_URL') )
2811 define('USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=login');
2812 if( ! defined('USCES_LOGOUT_URL') )
2813 define('USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=logout');
2814 if( ! defined('USCES_MEMBER_URL') )
2815 define('USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid());
2816 if( !isset($this->options['inquiry_id']) || !( (int)$this->options['inquiry_id'] ) ){
2817 $inquiry_url = get_home_url();
2818 }else{
2819 $ssl_plink_inquiry = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link($this->options['inquiry_id']) ));
2820 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid();
2821 }
2822 if( ! defined('USCES_INQUIRY_URL') )
2823 define('USCES_INQUIRY_URL', $inquiry_url);
2824 if( ! defined('USCES_CART_NONSESSION_URL') )
2825 define('USCES_CART_NONSESSION_URL', $ssl_plink_cart);
2826 //20110208ysk start
2827 //define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2828 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2829 define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2830 //20110208ysk end
2831 }
2832 }else{
2833 $this->delim = '&';
2834 if( ! defined('USCES_CUSTOMER_URL') )
2835 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2836 if( ! defined('USCES_CART_URL') )
2837 define('USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2838 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2839 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2840 if( ! defined('USCES_NEWMEMBER_URL') )
2841 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2842 if( ! defined('USCES_LOGIN_URL') )
2843 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2844 if( ! defined('USCES_LOGOUT_URL') )
2845 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2846 if( ! defined('USCES_MEMBER_URL') )
2847 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2848 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2849 if( ! defined('USCES_INQUIRY_URL') )
2850 define('USCES_INQUIRY_URL', $inquiry_url);
2851 if( ! defined('USCES_CART_NONSESSION_URL') )
2852 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER);
2853 //20110208ysk start
2854 //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2855 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2856 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2857 //20110208ysk end
2858 }
2859 if( !is_admin() ){
2860 add_filter('home_url', array($this, 'usces_ssl_page_link'));
2861 add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
2862 add_filter('icon_dir_uri', array($this, 'usces_ssl_icon_dir_uri'));
2863 add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
2864 add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
2865 add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
2866 add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
2867 }
2868 } else {
2869 if( $permalink_structure ){
2870 $this->delim = '?';
2871 if( ! defined('USCES_CUSTOMER_URL') )
2872 define('USCES_CUSTOMER_URL', get_page_link(USCES_CART_NUMBER) . '?customerinfo=1');
2873 if( ! defined('USCES_CART_URL') )
2874 define('USCES_CART_URL', get_page_link(USCES_CART_NUMBER));
2875 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2876 define('USCES_LOSTMEMBERPASSWORD_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=lostmemberpassword');
2877 if( ! defined('USCES_NEWMEMBER_URL') )
2878 define('USCES_NEWMEMBER_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=newmember');
2879 if( ! defined('USCES_LOGIN_URL') )
2880 define('USCES_LOGIN_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=login');
2881 if( ! defined('USCES_LOGOUT_URL') )
2882 define('USCES_LOGOUT_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=logout');
2883 if( ! defined('USCES_MEMBER_URL') )
2884 define('USCES_MEMBER_URL', get_page_link(USCES_MEMBER_NUMBER));
2885 $inquiry_url = ( !isset( $this->options['inquiry_id'] ) || !( (int)$this->options['inquiry_id'] )) ? get_home_url() : get_page_link($this->options['inquiry_id']);
2886 if( ! defined('USCES_INQUIRY_URL') )
2887 define('USCES_INQUIRY_URL', $inquiry_url);
2888 if( ! defined('USCES_CART_NONSESSION_URL') )
2889 define('USCES_CART_NONSESSION_URL', get_page_link(USCES_CART_NUMBER));
2890 //20110208ysk start
2891 //define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2892 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2893 define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2894 //20110208ysk end
2895 }else{
2896 $this->delim = '&';
2897 if( ! defined('USCES_CUSTOMER_URL') )
2898 define('USCES_CUSTOMER_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1');
2899 if( ! defined('USCES_CART_URL') )
2900 define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2901 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2902 define('USCES_LOSTMEMBERPASSWORD_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=lostmemberpassword');
2903 if( ! defined('USCES_NEWMEMBER_URL') )
2904 define('USCES_NEWMEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=newmember');
2905 if( ! defined('USCES_LOGIN_URL') )
2906 define('USCES_LOGIN_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=login');
2907 if( ! defined('USCES_LOGOUT_URL') )
2908 define('USCES_LOGOUT_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2909 if( ! defined('USCES_CART_NONSESSION_URL') )
2910 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2911 if( ! defined('USCES_MEMBER_URL') )
2912 define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
2913 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option('home') . '/?page_id=' . $this->options['inquiry_id'];
2914 if( ! defined('USCES_INQUIRY_URL') )
2915 define('USCES_INQUIRY_URL', $inquiry_url);
2916 if( ! defined('USCES_CART_NONSESSION_URL') )
2917 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2918 //20110208ysk start
2919 //define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2920 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2921 define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2922 //20110208ysk end
2923 }
2924 }
2925 }
2926
2927 function regist_action(){
2928 usces_register_action('inCart', 'post', 'inCart', NULL, 'inCart');
2929 usces_register_action('upButton', 'post', 'upButton', NULL, 'upButton');
2930 usces_register_action('delButton', 'post', 'delButton', NULL, 'delButton');
2931 usces_register_action('backCart', 'post', 'backCart', NULL, 'backCart');
2932 usces_register_action('customerinfo', 'request', 'customerinfo', NULL, 'customerinfo');
2933 usces_register_action('backCustomer', 'post', 'backCustomer', NULL, 'backCustomer');
2934 usces_register_action('customerlogin', 'post', 'customerlogin', NULL, 'customerlogin');
2935 usces_register_action('reganddeliveryinfo', 'post', 'reganddeliveryinfo', NULL, 'reganddeliveryinfo');
2936 usces_register_action('deliveryinfo', 'post', 'deliveryinfo', NULL, 'deliveryinfo');
2937 usces_register_action('backDelivery', 'post', 'backDelivery', NULL, 'backDelivery');
2938 usces_register_action('confirm', 'request', 'confirm', NULL, 'confirm');
2939 usces_register_action('use_point', 'post', 'use_point', NULL, 'use_point');
2940 usces_register_action('backConfirm', 'post', 'backConfirm', NULL, 'backConfirm');
2941 usces_register_action('purchase', 'request', 'purchase', NULL, 'purchase');
2942 usces_register_action('acting_return', 'request', 'acting_return', NULL, 'acting_return');
2943 usces_register_action('settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon');
2944 usces_register_action('inquiry_button', 'post', 'inquiry_button', NULL, 'inquiry_button');
2945 usces_register_action('member_login', 'request', 'member_login', NULL, 'member_login_page');
2946 usces_register_action('regmember', 'request', 'regmember', NULL, 'regmember');
2947 usces_register_action('editmember', 'request', 'editmember', NULL, 'editmember');
2948 usces_register_action('deletemember', 'request', 'deletemember', NULL, 'deletemember');
2949 usces_register_action('page_login', 'get', 'page', 'login', 'member_login_page');
2950 usces_register_action('page_logout', 'get', 'page', 'logout', 'page_logout');
2951 usces_register_action('page_lostmemberpassword', 'get', 'page', 'lostmemberpassword', 'page_lostmemberpassword');
2952 usces_register_action('lostpassword', 'request', 'lostpassword', NULL, 'lostpassword');
2953 usces_register_action('uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword');
2954 usces_register_action('changepassword', 'request', 'changepassword', NULL, 'changepassword_page');
2955 usces_register_action('page_newmember', 'get', 'page', 'newmember', 'page_newmember');
2956 usces_register_action('usces_export', 'post', 'usces_export', NULL, 'usces_export');
2957 usces_register_action('usces_import', 'post', 'usces_import', NULL, 'usces_import');
2958 usces_register_action('page_search_item', 'get', 'page', 'search_item', 'page_search_item');
2959 usces_register_action('front_ajax', 'post', 'usces_ajax_action', NULL, 'front_ajax');
2960 }
2961
2962 function ad_controller(){
2963 global $usces_action;
2964 ksort($usces_action);
2965 //if($this->is_maintenance()){
2966 if($this->is_maintenance() and !is_user_logged_in()){//0000651
2967 $this->maintenance();
2968 }else{
2969 $action_array = array('inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer',
2970 'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point',
2971 'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login',
2972 'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword',
2973 'uscesmode_changepassword', 'changepassword', 'page_newmember', 'usces_export', 'usces_import',
2974 'page_search_item', 'front_ajax');
2975 $flg = 0;
2976 $res = true;
2977 foreach( $usces_action as $handle => $action ){
2978 extract($action);
2979 switch($type){
2980 case 'post':
2981 if( empty($value) ){
2982 if( isset($_POST[$key]) ){
2983 if(in_array($handle, $action_array)){
2984 $res = call_user_func(array($this, $function));
2985 }else{
2986 $res = call_user_func($function);
2987 }
2988 $flg = 1;
2989 }
2990 }else{
2991 if( isset($_POST[$key]) && $_POST[$key] == $value ){
2992 if(in_array($handle, $action_array)){
2993 $res = call_user_func(array($this, $function));
2994 }else{
2995 $res = call_user_func($function);
2996 }
2997 $flg = 1;
2998 }
2999 }
3000 break;
3001 case 'get':
3002 if( empty($value) ){
3003 if( isset($_GET[$key]) ){
3004 if(in_array($handle, $action_array)){
3005 $res = call_user_func(array($this, $function));
3006 }else{
3007 $res = call_user_func($function);
3008 }
3009 $flg = 1;
3010 }
3011 }else{
3012 if( isset($_GET[$key]) && $_GET[$key] == $value ){
3013 if(in_array($handle, $action_array)){
3014 $res = call_user_func(array($this, $function));
3015 }else{
3016 $res = call_user_func($function);
3017 }
3018 $flg = 1;
3019 }
3020 }
3021 break;
3022 case 'request':
3023 if( empty($value) ){
3024 if( isset($_REQUEST[$key]) ){
3025 if(in_array($handle, $action_array)){
3026 $res = call_user_func(array($this, $function));
3027 }else{
3028 $res = call_user_func($function);
3029 }
3030 $flg = 1;
3031 }
3032 }else{
3033 if( isset($_REQUEST[$key]) && $_REQUEST[$key] == $value ){
3034 if(in_array($handle, $action_array)){
3035 $res = call_user_func(array($this, $function));
3036 }else{
3037 $res = call_user_func($function);
3038 }
3039 $flg = 1;
3040 }
3041 }
3042 break;
3043 }
3044 if( ! $res ) break;
3045 }
3046 if( !$flg ) $this->default_page();
3047 }
3048 }
3049
3050 //action function------------------------------------------------------------
3051 function front_ajax(){
3052 switch ($_POST['usces_ajax_action']){
3053 case 'change_states':
3054 change_states_ajax();
3055 break;
3056 }
3057 do_action('usces_front_ajax');
3058 }
3059
3060 function maintenance(){
3061 $this->page = 'maintenance';
3062 add_action('the_post', array($this, 'action_cartFilter'));
3063 }
3064
3065 function inCart(){
3066 global $wp_query;
3067 $this->page = 'cart';
3068 $this->incart_check();
3069 $this->cart->inCart();
3070 add_action('the_post', array($this, 'action_cartFilter'));
3071 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3072 add_action('template_redirect', array($this, 'template_redirect'));
3073 }
3074
3075 function upButton(){
3076 global $wp_query;
3077 $this->page = 'cart';
3078 $this->cart->upCart();
3079 $this->error_message = $this->zaiko_check();
3080 add_action('the_post', array($this, 'action_cartFilter'));
3081 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3082 add_action('template_redirect', array($this, 'template_redirect'));
3083 }
3084
3085 function delButton(){
3086 global $wp_query;
3087 $this->page = 'cart';
3088 $this->cart->del_row();
3089 add_action('the_post', array($this, 'action_cartFilter'));
3090 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3091 add_action('template_redirect', array($this, 'template_redirect'));
3092 }
3093
3094 function backCart(){
3095 global $wp_query;
3096 $this->page = 'cart';
3097 add_action('the_post', array($this, 'action_cartFilter'));
3098 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3099 add_action('template_redirect', array($this, 'template_redirect'));
3100 }
3101
3102 function customerinfo(){
3103 global $wp_query;
3104 if( false === $this->cart->num_row() ){
3105 header('location: ' . get_option('home'));
3106 exit;
3107 }
3108 do_action( 'usces_action_customerinfo' );
3109 $this->cart->entry();
3110 $this->error_message = $this->zaiko_check();
3111 $this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message );
3112 if( WCUtils::is_blank($this->error_message) ){
3113 if($this->is_member_logged_in()){
3114 //20100818ysk start
3115 //$this->page = 'delivery';
3116 $this->error_message = has_custom_customer_field_essential();
3117 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'delivery' : 'customer';
3118 //20100818ysk end
3119 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3120 }else{
3121 $this->page = 'customer';
3122 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3123 }
3124 }else{
3125 $this->page = 'cart';
3126 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3127 }
3128 if ( !$this->cart->is_order_condition() ) {
3129 $order_conditions = $this->get_condition();
3130 $this->cart->set_order_condition($order_conditions);
3131 }
3132 add_action('the_post', array($this, 'action_cartFilter'));
3133 add_action('template_redirect', array($this, 'template_redirect'));
3134 }
3135
3136 function backCustomer(){
3137 global $wp_query;
3138 if( false === $this->cart->num_row() ){
3139 header('location: ' . get_option('home'));
3140 exit;
3141 }
3142 $this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' );
3143 add_action('the_post', array($this, 'action_cartFilter'));
3144 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3145 add_action('template_redirect', array($this, 'template_redirect'));
3146 // $this->cart->entry();
3147 // $this->error_message = $this->delivery_check();
3148 // $this->page = ($this->error_message == '') ? 'customer' : 'delivery';
3149 }
3150
3151 function customerlogin(){
3152 global $wp_query;
3153 if( false === $this->cart->num_row() ){
3154 header('location: ' . get_option('home'));
3155 exit;
3156 }
3157 //20100818ysk start
3158 //$this->cart->entry();
3159 //$this->page = ($this->member_login() == 'member') ? 'delivery' : 'customer';
3160 if($this->member_login() == 'member') {
3161 $this->cart->entry();
3162 $this->error_message = has_custom_customer_field_essential();
3163 if( WCUtils::is_blank($this->error_message) ){
3164 $this->page = 'delivery';
3165 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3166 }else{
3167 $this->page = 'customer';
3168 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3169 }
3170 } else {
3171 $this->cart->entry();
3172 $this->page = 'customer';
3173 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3174 }
3175 //20100818ysk end
3176 add_action('the_post', array($this, 'action_cartFilter'));
3177 add_action('template_redirect', array($this, 'template_redirect'));
3178 }
3179
3180 function reganddeliveryinfo(){
3181 global $wp_query;
3182 if( false === $this->cart->num_row() ){
3183 header('location: ' . get_option('home'));
3184 exit;
3185 }
3186 $this->cart->entry();
3187 //20110715ysk start 0000203
3188 //$_POST['member_regmode'] = 'newmemberfromcart';
3189 if(empty($_POST['member_regmode']) or $_POST['member_regmode'] != 'editmemberfromcart') $_POST['member_regmode'] = 'newmemberfromcart';
3190 //20110715ysk end
3191
3192 if( $this->regist_member() == 'newcompletion' ){
3193 $this->page = 'delivery';
3194 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3195 }else{
3196 $this->page = 'customer';
3197 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3198 }
3199 add_action('the_post', array($this, 'action_cartFilter'));
3200 add_action('template_redirect', array($this, 'template_redirect'));
3201 }
3202
3203 function deliveryinfo(){
3204 global $wp_query;
3205 if( false === $this->cart->num_row() ){
3206 header('location: ' . get_option('home'));
3207 exit;
3208 }
3209 $this->cart->entry();
3210 $this->error_message = $this->customer_check();
3211
3212 if( WCUtils::is_blank($this->error_message) ){
3213 $this->page = 'delivery';
3214 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3215 }else{
3216 $this->page = 'customer';
3217 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3218 }
3219 add_action('the_post', array($this, 'action_cartFilter'));
3220 add_action('template_redirect', array($this, 'template_redirect'));
3221 }
3222
3223 function backDelivery(){
3224 global $wp_query;
3225 if( false === $this->cart->num_row() ){
3226 header('location: ' . get_option('home'));
3227 exit;
3228 }
3229 $this->page = 'delivery';
3230 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3231 add_action('the_post', array($this, 'action_cartFilter'));
3232 add_action('template_redirect', array($this, 'template_redirect'));
3233 }
3234
3235 function confirm(){
3236 global $wpdb, $wp_query;
3237 if( false === $this->cart->num_row() ){
3238 header('location: ' . get_option('home'));
3239 exit;
3240 }
3241
3242 $this->cart->entry();
3243 $this->error_message = $this->zaiko_check();
3244 if( $this->error_message != '' ){
3245 $this->page = 'cart';
3246 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3247 add_action('the_post', array($this, 'action_cartFilter'));
3248 add_action('template_redirect', array($this, 'template_redirect'));
3249 return;
3250 }
3251
3252 $this->set_reserve_pre_order_id();
3253 if(isset($_POST['confirm'])){
3254 $this->error_message = $this->delivery_check();
3255 }
3256 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'confirm' : 'delivery';
3257 if( WCUtils::is_blank($this->error_message) ){
3258 //20120919ysk start 0000573
3259 if( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) {
3260 $member_table = $wpdb->prefix."usces_member";
3261 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID']);
3262 $mem_point = $wpdb->get_var( $query );
3263 $_SESSION['usces_member']['point'] = $mem_point;
3264 }
3265 //20120919ysk end
3266 $this->page = 'confirm';
3267 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3268 }else{
3269 $this->page = 'delivery';
3270 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3271 }
3272 add_action('the_post', array($this, 'action_cartFilter'));
3273 add_action('template_redirect', array($this, 'template_redirect'));
3274 }
3275
3276 function use_point(){
3277 global $wp_query;
3278 $this->error_message = $this->point_check( $this->cart->get_entry() );
3279 if( empty($this->error_message) )
3280 $this->cart->entry();
3281 $this->page = 'confirm';
3282 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3283 add_action('the_post', array($this, 'action_cartFilter'));
3284 add_action('template_redirect', array($this, 'template_redirect'));
3285 }
3286
3287 function backConfirm(){
3288 global $wp_query;
3289 if( false === $this->cart->num_row() ){
3290 header('location: ' . get_option('home'));
3291 exit;
3292 }
3293 $this->page = 'confirm';
3294 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3295 add_action('the_post', array($this, 'action_cartFilter'));
3296 add_action('template_redirect', array($this, 'template_redirect'));
3297 }
3298
3299 function purchase(){
3300 global $wp_query;
3301 if( false === $this->cart->num_row() ){
3302 header('location: ' . get_option('home'));
3303 exit;
3304 }
3305
3306 if( !apply_filters('usces_purchase_check', true) ) return;
3307
3308 do_action('usces_purchase_validate');
3309 $entry = $this->cart->get_entry();
3310 $this->error_message = $this->zaiko_check();
3311 if( WCUtils::is_blank($this->error_message) && 0 < $this->cart->num_row()){
3312 $acting_status = '';
3313 $payments = $this->getPayments( $entry['order']['payment_name'] );
3314 if( substr($payments['settlement'], 0, 6) == 'acting' && $entry['order']['total_full_price'] > 0 ){
3315 $acting_flg = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3316 //$query = '';
3317 //foreach($_POST as $key => $value){
3318 // if($key != 'purchase')
3319 // $query .= '&' . $key . '=' . urlencode(maybe_serialize($value));
3320 //}
3321 unset( $_POST['purchase'] );
3322 $query = '&'.http_build_query( $_POST );
3323 $acting_status = $this->acting_processing($acting_flg, $query);
3324 }
3325
3326 if($acting_status == 'error'){
3327 $this->page = 'error';
3328 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3329 }else{
3330 $res = $this->order_processing();
3331 if( 'ordercompletion' == $res ){
3332 $this->page = 'ordercompletion';
3333 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3334 }else{
3335 $this->page = 'error';
3336 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3337 }
3338 }
3339 }else{
3340 $this->page = 'cart';
3341 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3342 }
3343 add_action('the_post', array($this, 'action_cartFilter'));
3344 add_action('template_redirect', array($this, 'template_redirect'));
3345 }
3346
3347 function acting_return(){
3348 global $wp_query;
3349 $entry = $this->cart->get_entry();
3350
3351 //20110208ysk start
3352 /* if( 'paypal_ipn' == $_REQUEST['acting_return'] ){
3353 usces_log('paypal_ipn in ', 'acting_transaction.log');
3354 require_once($this->options['settlement_path'] . 'paypal.php');
3355 $ipn_res = paypal_ipn_check($usces_paypal_url);
3356 if( $ipn_res[0] === true ){
3357 $res = $this->order_processing( $ipn_res );
3358 if( 'ordercompletion' == $res ){
3359 $this->cart->crear_cart();
3360 }else{
3361 usces_log('paypal_ipn regorder error (acting_return) : '.print_r($entry, true), 'acting_transaction.log');
3362 }
3363 }
3364 exit;
3365 }*/
3366 //20110208ysk end
3367 if( isset($_GET['acting']) and 'anotherlane_card' != $_GET['acting'] ) {//20131220ysk
3368 if( false === $this->cart->num_row() && ('paypal' != $_GET['acting'] && 1 !== (int)$_GET['acting_return']) ){
3369 header('location: ' . get_option('home'));
3370 exit;
3371 }
3372 }//20131220ysk
3373
3374 $this->payment_results = usces_check_acting_return();
3375
3376 if( isset($this->payment_results[0]) && $this->payment_results[0] === 'duplicate' ){
3377
3378 header('location: ' . get_option('home'));
3379 exit;
3380
3381 }else if( isset($this->payment_results[0]) && $this->payment_results[0] ){//result OK
3382
3383 if( ! $this->payment_results['reg_order'] ){//without Registration Order
3384 $this->page = 'ordercompletion';
3385 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3386
3387 }else{
3388 $res = $this->order_processing( $this->payment_results );
3389
3390 if( 'ordercompletion' == $res ){
3391 if( isset($_REQUEST['wctid']) ){
3392 usces_ordered_acting_data($_REQUEST['wctid']);
3393 }
3394 $this->page = 'ordercompletion';
3395 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3396 }else{
3397 $this->page = 'error';
3398 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3399 }
3400 }
3401
3402 }else{//result NG
3403 $this->page = 'error';
3404 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3405 }
3406
3407 add_action('the_post', array($this, 'action_cartFilter'));
3408 add_action('template_redirect', array($this, 'template_redirect'));
3409 }
3410
3411 function settlement_epsilon(){
3412 global $wp_query;
3413 require_once($this->options['settlement_path'] . 'epsilon.php');
3414 }
3415
3416 function inquiry_button(){
3417 if( (isset($_POST['kakuninyou']) && empty($_POST['kakuninyou'])) && isset($_POST['inq_name']) && !WCUtils::is_blank($_POST['inq_name']) && isset($_POST['inq_mailaddress']) && is_email( trim($_POST['inq_mailaddress']) ) && !WCUtils::is_blank($_POST['inq_contents']) ){
3418 $res = $this->inquiry_processing();
3419 }else{
3420 $res = 'deficiency';
3421 }
3422
3423 $this->page = $res;
3424 }
3425
3426 function member_login_page(){
3427 global $wp_query;
3428 $res = $this->member_login();
3429 if( 'member' == $res ){
3430 $this->page = 'member';
3431 do_action('usces_action_member_logined');
3432 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_member');
3433 }elseif( 'login' == $res ){
3434 $this->page = 'login';
3435 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_login');
3436 }
3437 add_action('the_post', array($this, 'action_memberFilter'));
3438 add_action('template_redirect', array($this, 'template_redirect'));
3439 }
3440
3441 function regmember(){
3442 global $wp_query;
3443 $res = $this->regist_member();
3444 if( 'editmemberform' == $res ){
3445 $this->page = 'editmemberform';
3446 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3447 }elseif( 'newcompletion' == $res ){
3448 $this->page = 'newcompletion';
3449 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3450 }else{
3451 $this->page = $res;
3452 }
3453 add_action('the_post', array($this, 'action_memberFilter'));
3454 add_action('template_redirect', array($this, 'template_redirect'));
3455 }
3456
3457 function editmember(){
3458 global $wp_query;
3459 $res = $this->regist_member();
3460 if( 'editmemberform' == $res ){
3461 $this->page = 'editmemberform';
3462 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3463 }elseif( 'newcompletion' == $res ){
3464 $this->page = 'newcompletion';
3465 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3466 }else{
3467 $this->page = $res;
3468 }
3469 add_action('the_post', array($this, 'action_memberFilter'));
3470 add_action('template_redirect', array($this, 'template_redirect'));
3471 }
3472
3473 function deletemember(){
3474 $res = $this->delete_member();
3475 if( $res ){
3476 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember');
3477 $this->member_logout();
3478 }else{
3479 $this->page = 'editmemberform';
3480 add_action('the_post', array($this, 'action_memberFilter'));
3481 }
3482 add_action('template_redirect', array($this, 'template_redirect'));
3483 }
3484
3485 function page_logout(){
3486 global $wp_query;
3487 $this->member_logout();
3488 add_action('the_post', array($this, 'action_memberFilter'));
3489 add_action('template_redirect', array($this, 'template_redirect'));
3490 }
3491
3492 function page_lostmemberpassword(){
3493 global $wp_query;
3494 $this->page = 'lostmemberpassword';
3495 add_action('the_post', array($this, 'action_memberFilter'));
3496 add_action('template_redirect', array($this, 'template_redirect'));
3497 }
3498
3499 function lostpassword(){
3500 global $wp_query;
3501 $this->error_message = $this->lostpass_mailaddcheck();
3502 if ( $this->error_message != '' ) {
3503 $this->page = 'lostmemberpassword';
3504 } else {
3505 $res = $this->lostmail();
3506 $this->page = $res;//'lostcompletion';
3507 }
3508 add_action('the_post', array($this, 'action_memberFilter'));
3509 add_action('template_redirect', array($this, 'template_redirect'));
3510 }
3511
3512 function uscesmode_changepassword(){
3513 global $wp_query;
3514 $this->page = 'changepassword';
3515 add_action('the_post', array($this, 'action_memberFilter'));
3516 add_action('template_redirect', array($this, 'template_redirect'));
3517 }
3518
3519 function changepassword_page(){
3520 global $wp_query;
3521 $this->error_message = $this->changepass_check();
3522 if ( $this->error_message != '' ) {
3523 $this->page = 'changepassword';
3524 } else {
3525 $res = $this->changepassword();
3526 $this->page = $res;//'changepasscompletion';
3527 }
3528 add_action('the_post', array($this, 'action_memberFilter'));
3529 add_action('template_redirect', array($this, 'template_redirect'));
3530 }
3531
3532 function page_newmember(){
3533
3534 global $wp_query;
3535 $this->page = 'newmemberform';
3536 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform');
3537 add_action('the_post', array($this, 'action_memberFilter'));
3538 add_action('template_redirect', array($this, 'template_redirect'));
3539 }
3540
3541 function usces_export(){
3542 $this->export();
3543 }
3544
3545 function usces_import(){
3546 $this->import();
3547 }
3548
3549 function page_search_item(){
3550 global $wp_query;
3551 $this->page = 'search_item';
3552 //add_action('template_redirect', array($this, 'action_search_item'));
3553 add_action('the_post', array($this, 'action_cartFilter'));
3554 add_action('template_redirect', array($this, 'template_redirect'));
3555 }
3556
3557 function default_page(){
3558 global $wp_query;
3559 add_action('the_post', array($this, 'goDefaultPage'));
3560 add_action('template_redirect', array($this, 'template_redirect'));
3561 }
3562 //--------------------------------------------------------------------------------------
3563
3564
3565 function goDefaultPage(){
3566 global $post;
3567
3568 if( $post->ID == USCES_CART_NUMBER ) {
3569
3570 $this->page = 'cart';
3571 add_filter('the_content', array($this, 'filter_cartContent'),20);
3572
3573 }else if( $post->ID == USCES_MEMBER_NUMBER ) {
3574
3575 $this->page = 'member';
3576 add_filter('the_content', array($this, 'filter_memberContent'),20);
3577
3578 }else if( !is_singular() ) {
3579 $this->page = 'wp_search';
3580 add_filter('the_excerpt', array($this, 'filter_cartContent'),20);
3581 add_filter('the_content', array($this, 'filter_cartContent'),20);
3582
3583 }else{
3584 add_filter('the_content', array(&$this, 'filter_itemPage'));
3585
3586 }
3587 }
3588
3589 function template_redirect () {
3590 global $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode;
3591
3592 if( apply_filters('usces_action_template_redirect', false) ) return;//Deprecated
3593 if( apply_filters('usces_filter_template_redirect', false) ) return;
3594
3595 if( is_single() && 'item' == $post->post_mime_type ) {
3596 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_item_single.php') ){
3597 if( !post_password_required($post) ){
3598 include(get_stylesheet_directory() . '/wc_templates/wc_item_single.php');
3599 exit;
3600 }
3601 }
3602 }elseif( isset($_REQUEST['page']) && ('search_item' == $_REQUEST['page'] || 'usces_search' == $_REQUEST['page']) && $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3603 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_search_page.php') ){
3604 include(get_stylesheet_directory() . '/wc_templates/wc_search_page.php');
3605 exit;
3606 }
3607
3608 }else if( $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3609 switch( $this->page ){
3610 case 'customer':
3611 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php') ){
3612 usces_get_entries();
3613 usces_get_member_regmode();
3614 include(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php');
3615 exit;
3616 }
3617 break;
3618 case 'delivery':
3619 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php') ){
3620 usces_get_entries();
3621 usces_get_carts();
3622 include(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php');
3623 exit;
3624 }
3625 break;
3626 case 'confirm':
3627 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php') ){
3628 usces_get_entries();
3629 usces_get_carts();
3630 usces_get_members();
3631 include(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php');
3632 exit;
3633 }
3634 break;
3635 case 'ordercompletion':
3636 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php') ){
3637 usces_get_entries();
3638 usces_get_carts();
3639 include(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php');
3640 exit;
3641 }
3642 break;
3643 case 'error':
3644 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php') ){
3645 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php');
3646 exit;
3647 }
3648 break;
3649 case 'cart':
3650 default:
3651 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php') ){
3652 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php');
3653 exit;
3654 }
3655
3656 }
3657 }else if($this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
3658
3659 }else if( $this->is_member_page($_SERVER['REQUEST_URI']) ){
3660 if($this->options['membersystem_state'] != 'activate') return;
3661
3662 if( $this->is_member_logged_in() ) {
3663 $member_regmode = 'editmemberform';
3664 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php') ){
3665 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php');
3666 exit;
3667 }
3668
3669 } else {
3670
3671 switch( $this->page ){
3672 case 'login':
3673 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3674 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3675 exit;
3676 }
3677 break;
3678 case 'newmemberform':
3679 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php') ){
3680 $member_regmode = 'newmemberform';
3681 include(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php');
3682 exit;
3683 }
3684 break;
3685 case 'lostmemberpassword':
3686 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php') ){
3687 include(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php');
3688 exit;
3689 }
3690 break;
3691 case 'changepassword':
3692 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php') ){
3693 include(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php');
3694 exit;
3695 }
3696 break;
3697 case 'newcompletion':
3698 case 'editcompletion':
3699 case 'lostcompletion':
3700 case 'changepasscompletion':
3701 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php') ){
3702 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php');
3703 exit;
3704 }
3705 break;
3706 default:
3707 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3708 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3709 exit;
3710 }
3711 }
3712 }
3713
3714 }else{
3715 // remove_action('the_post', array(&$this, 'goDefaultPage'));
3716 }
3717 }
3718
3719 function import() {
3720 $res = usces_import_xml();
3721 if ( $res === false ) :
3722 $this->action_status = 'error';
3723 //$this->action_message = __('Import was not completed.', 'usces');
3724 else :
3725 $this->action_status = 'success';
3726 $this->action_message = __('Import is cmpleted', 'usces');
3727 endif;
3728
3729 // require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
3730 }
3731
3732 function export() {
3733 $filename = 'usces.' . substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10) . '.xml';
3734
3735 header('Content-Description: File Transfer');
3736 header("Content-Disposition: attachment; filename=$filename");
3737 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
3738
3739 usces_export_xml();
3740 die();
3741
3742 }
3743
3744
3745 function changepassword() {
3746 global $wpdb;
3747
3748 if ( !isset($_SESSION['usces_lostmail']) ) :
3749 $this->error_message = __('Failed in update due to time-out', 'usces');
3750 return 'login';
3751 else :
3752
3753 $member_table = $wpdb->prefix . "usces_member";
3754
3755 $query = $wpdb->prepare("UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s",
3756 md5(trim($_POST['loginpass1'])), $_SESSION['usces_lostmail']);
3757 $res = $wpdb->query( $query );
3758 //$res = $wpdb->last_results;
3759
3760 if ( $res === false ) :
3761 $this->error_message = __('Error: failure in updating password', 'usces');
3762 return 'login';
3763 else :
3764 return 'changepasscompletion';
3765 endif;
3766
3767 endif;
3768 }
3769
3770 function lostmail() {
3771 $delim = apply_filters( 'usces_filter_delim', $this->delim );
3772
3773 $_SESSION['usces_lostmail'] = trim($_POST['loginmail']);
3774 $id = session_id();
3775 $uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword';
3776 $res = usces_lostmail($uri);
3777 return $res;
3778
3779 }
3780
3781 function regist_member() {
3782 global $wpdb;
3783 $_POST = $this->stripslashes_deep_post($_POST);
3784
3785 $member = $this->get_member();
3786 $mode = $_POST['member_regmode'];
3787 $member_table = $wpdb->prefix . "usces_member";
3788 $member_meta_table = $wpdb->prefix . "usces_member_meta";
3789
3790 //20110715ysk start 0000203
3791 //$error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3792 $error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' or $_POST['member_regmode'] == 'editmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3793 //20110715ysk end
3794
3795 if ( $error_mes != '' ) {
3796
3797 $this->error_message = $error_mes;
3798 return $mode;
3799
3800 } elseif ( $_POST['member_regmode'] == 'editmemberform' ) {
3801
3802 $this->get_current_member();
3803 $mem_id = $this->current_member['id'];
3804 do_action('usces_action_pre_edit_memberdata', $_POST['member'], $mem_id);
3805
3806 //20130802ysk start 0000741
3807 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3808 $id = $wpdb->get_var( $query );
3809 if ( !empty($id) and $id != $mem_id ) {
3810 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3811 return $mode;
3812 }
3813 //20130802ysk end
3814
3815 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3816 $pass = $wpdb->get_var( $query );
3817
3818 $password = ( !empty($_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? md5(trim($_POST['member']['password1'])) : $pass;
3819 $query = $wpdb->prepare("UPDATE $member_table SET
3820 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3821 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3822 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3823 $password,
3824 trim($_POST['member']['name1']),
3825 trim($_POST['member']['name2']),
3826 trim($_POST['member']['name3']),
3827 trim($_POST['member']['name4']),
3828 trim($_POST['member']['zipcode']),
3829 trim($_POST['member']['pref']),
3830 trim($_POST['member']['address1']),
3831 trim($_POST['member']['address2']),
3832 trim($_POST['member']['address3']),
3833 trim($_POST['member']['tel']),
3834 trim($_POST['member']['fax']),
3835 trim($_POST['member']['mailaddress1']),
3836 $mem_id
3837 );
3838 $res = $wpdb->query( $query );
3839
3840 if( $res !== false ){
3841 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $mem_id);
3842 //20100818ysk start
3843 $res = $this->reg_custom_member($mem_id);
3844 //20100818ysk end
3845 do_action('usces_action_edit_memberdata', $_POST['member'], $mem_id);
3846 //$meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" );
3847 $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'remise_pcid', 'digitalcheck_ip_user_id'" );
3848 $query = $wpdb->prepare("DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )",
3849 $mem_id
3850 );
3851 $res = $wpdb->query( $query );
3852
3853 $this->get_current_member();
3854 return 'editmemberform';
3855
3856 } else {
3857 $this->error_message = __('Error:failure in update', 'usces');
3858 return $mode;
3859 }
3860
3861 } elseif ( $_POST['member_regmode'] == 'newmemberform' ) {
3862
3863 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3864 $id = $wpdb->get_var( $query );
3865 if ( !empty($id) ) {
3866 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3867 return $mode;
3868 } else {
3869
3870 $point = $this->options['start_point'];
3871 $pass = md5(trim($_POST['member']['password1']));
3872 $query = $wpdb->prepare("INSERT INTO $member_table
3873 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3874 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3875 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3876 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3877 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3878 trim($_POST['member']['mailaddress1']),
3879 $pass,
3880 0,
3881 "",
3882 $point,
3883 trim($_POST['member']['name1']),
3884 trim($_POST['member']['name2']),
3885 trim($_POST['member']['name3']),
3886 trim($_POST['member']['name4']),
3887 trim($_POST['member']['zipcode']),
3888 trim($_POST['member']['pref']),
3889 trim($_POST['member']['address1']),
3890 trim($_POST['member']['address2']),
3891 trim($_POST['member']['address3']),
3892 trim($_POST['member']['tel']),
3893 trim($_POST['member']['fax']),
3894 '',
3895 '',
3896 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3897 '');
3898 $res = $wpdb->query( $query );
3899
3900 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3901 //$this->get_current_member();
3902 if($res !== false) {
3903 $user = $_POST['member'];
3904 $user['ID'] = $wpdb->insert_id;
3905 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $user['ID']);
3906 //20110714ysk start 0000207
3907 //20100818ysk start
3908 //$res = $this->reg_custom_member($wpdb->insert_id);
3909 $res = $this->reg_custom_member($user['ID']);
3910 //20100818ysk end
3911 //20110714ysk end
3912 $mser = usces_send_regmembermail($user);
3913
3914 do_action('usces_action_member_registered', $_POST['member'], $user['ID']);
3915
3916 return 'newcompletion';
3917
3918 } else {
3919 $this->error_message = __('Error:failure in update', 'usces');
3920 return $mode;
3921 }
3922 }
3923
3924 } elseif ( $_POST['member_regmode'] == 'newmemberfromcart' ) {
3925
3926 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1']));
3927 $id = $wpdb->get_var( $query );
3928 if ( !empty($id) ) {
3929 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3930 return $mode;
3931 } else {
3932
3933 $point = $this->options['start_point'];
3934 $pass = md5(trim($_POST['customer']['password1']));
3935 $query = $wpdb->prepare("INSERT INTO $member_table
3936 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3937 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3938 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3939 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3940 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3941 trim($_POST['customer']['mailaddress1']),
3942 $pass,
3943 0,
3944 "",
3945 $point,
3946 trim($_POST['customer']['name1']),
3947 trim($_POST['customer']['name2']),
3948 trim($_POST['customer']['name3']),
3949 trim($_POST['customer']['name4']),
3950 trim($_POST['customer']['zipcode']),
3951 trim($_POST['customer']['pref']),
3952 trim($_POST['customer']['address1']),
3953 trim($_POST['customer']['address2']),
3954 trim($_POST['customer']['address3']),
3955 trim($_POST['customer']['tel']),
3956 trim($_POST['customer']['fax']),
3957 '',
3958 '',
3959 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3960 '');
3961 $res = $wpdb->query( $query );
3962
3963 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3964 //$this->get_current_member();
3965 if($res !== false) {
3966 //20110714ysk start 0000207
3967 $member_id = $wpdb->insert_id;
3968 //$this->set_member_meta_value('customer_country', $_POST['member']['country'], $wpdb->insert_id);
3969 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $member_id);
3970 //20100818ysk start
3971 //$res = $this->reg_custom_member($wpdb->insert_id);
3972 $res = $this->reg_custom_member($member_id);
3973 //20100818ysk end
3974 //20110714ysk end
3975 //usces_send_regmembermail();
3976 do_action('usces_action_member_registered', $_POST['customer'], $member_id);
3977 $user = $_POST['customer'];
3978 $user['ID'] = $member_id;
3979 $mser = usces_send_regmembermail($user);
3980 $_POST['loginmail'] = trim($_POST['customer']['mailaddress1']);
3981 $_POST['loginpass'] = trim($_POST['customer']['password1']);
3982 if( $this->member_login() == 'member' ){
3983 $_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart';
3984 return 'newcompletion';
3985 }
3986
3987 } else {
3988 $this->error_message = __('Error:failure in update', 'usces');
3989 return $mode;
3990 }
3991 }
3992
3993 //20110715ysk start 0000203
3994 } elseif ( $_POST['member_regmode'] == 'editmemberfromcart' ) {
3995
3996 $this->get_current_member();
3997 $mem_id = $this->current_member['id'];
3998 do_action('usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id);
3999
4000 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
4001 $pass = $wpdb->get_var( $query );
4002
4003 $password = ( !empty($_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? md5(trim($_POST['customer']['password1'])) : $pass;
4004 $query = $wpdb->prepare("UPDATE $member_table SET
4005 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
4006 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
4007 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
4008 $password,
4009 trim($_POST['customer']['name1']),
4010 trim($_POST['customer']['name2']),
4011 trim($_POST['customer']['name3']),
4012 trim($_POST['customer']['name4']),
4013 trim($_POST['customer']['zipcode']),
4014 trim($_POST['customer']['pref']),
4015 trim($_POST['customer']['address1']),
4016 trim($_POST['customer']['address2']),
4017 trim($_POST['customer']['address3']),
4018 trim($_POST['customer']['tel']),
4019 trim($_POST['customer']['fax']),
4020 trim($_POST['customer']['mailaddress1']),
4021 $mem_id
4022 );
4023 $res = $wpdb->query( $query );
4024 if( $res !== false ){
4025 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $mem_id);
4026 $res = $this->reg_custom_member($mem_id);
4027 do_action('usces_action_edit_memberdata', $_POST['customer'], $mem_id);
4028 unset($_SESSION['usces_member']);
4029 $this->member_just_login(trim($_POST['customer']['mailaddress1']), trim($_POST['customer']['password1']));
4030 return 'newcompletion';
4031
4032 } else {
4033 $this->error_message = __('Error:failure in update', 'usces');
4034 return $mode;
4035 }
4036 //20110715ysk end
4037 }
4038 }
4039
4040 function delete_member() {
4041 if( ! $this->is_member_logged_in() )
4042 return false;
4043 $mem = $this->get_member();
4044 if( ! $mem['ID'] )
4045 return false;
4046
4047 $res = usces_delete_memberdata( $mem['ID'] );
4048 if( $res ) {
4049 usces_send_delmembermail( $mem );
4050 }
4051
4052 return $res;
4053 }
4054
4055 function is_member_logged_in( $id = false ) {
4056 if( $id === false ){
4057 if( !empty($_SESSION['usces_member']['ID']) )
4058 return true;
4059 else
4060 return false;
4061 }else{
4062 if( !empty($_SESSION['usces_member']['ID']) && $_SESSION['usces_member']['ID'] == $id )
4063 return true;
4064 else
4065 return false;
4066 }
4067 }
4068
4069 function is_member($email) {
4070 global $wpdb;
4071
4072 $member_table = $wpdb->prefix . "usces_member";
4073 $query = $wpdb->prepare("SELECT mem_email FROM $member_table WHERE mem_email = %s", $email);
4074 $member = $wpdb->get_row( $query, ARRAY_A );
4075 if ( empty($member) ) {
4076 return false;
4077 }else{
4078 return true;
4079 }
4080 }
4081
4082 function member_login() {
4083 global $wpdb;
4084 $_POST = $this->stripslashes_deep_post($_POST);
4085
4086 $cookie = $this->get_cookie();
4087
4088
4089 if ( isset($cookie['rme']) && $cookie['rme'] == 'forever' && !isset($_POST['rememberme']) && !isset($_POST['loginmail'])) {
4090 $email = $cookie['name'];
4091 $member_table = $wpdb->prefix . "usces_member";
4092
4093 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
4094 $id = $wpdb->get_var( $query );
4095
4096 if ( !$id ) {
4097 $this->current_member['email'] = htmlspecialchars($email);
4098 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
4099 return 'login';
4100 } else {
4101 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s", $email);
4102 $member = $wpdb->get_row( $query, ARRAY_A );
4103 if ( empty($member) ) {
4104 $this->current_member['email'] = htmlspecialchars($email);
4105 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4106 return 'login';
4107 } else {
4108 $_SESSION['usces_member']['ID'] = $member['ID'];
4109 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4110 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4111 $_SESSION['usces_member']['point'] = $member['mem_point'];
4112 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4113 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4114 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4115 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4116 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4117 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4118 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4119 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4120 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4121 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4122 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4123 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4124 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4125 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4126 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4127 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4128 $_SESSION['usces_member']['status'] = $member['mem_status'];
4129 //20100818ysk start
4130 $this->set_session_custom_member($member['ID']);
4131 //20100818ysk end
4132 $this->get_current_member();
4133
4134 do_action( 'usces_action_after_login' );
4135 return apply_filters( 'usces_filter_member_login', 'member', $member );
4136 }
4137 }
4138 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginmail']) && isset($_POST['loginpass']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
4139 return 'login';
4140 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
4141 $this->current_member['email'] = trim($_POST['loginmail']);
4142 $this->error_message = __('<b>Error:</b> Enter the password.', 'usces');
4143 return 'login';
4144 } else if ( !isset($_POST['loginmail']) ){
4145 return 'login';
4146 } else {
4147 $email = isset($_POST['loginmail']) ? trim($_POST['loginmail']) : '';
4148 $pass = isset($_POST['loginpass']) ? md5(trim($_POST['loginpass'])) : '';
4149 $member_table = $wpdb->prefix . "usces_member";
4150
4151 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
4152 $id = $wpdb->get_var( $query );
4153
4154 if ( !$id ) {
4155 $this->current_member['email'] = htmlspecialchars($email);
4156 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
4157 return 'login';
4158 } else {
4159 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4160 $member = $wpdb->get_row( $query, ARRAY_A );
4161 if ( empty($member) ) {
4162 $this->current_member['email'] = htmlspecialchars($email);
4163 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4164 return 'login';
4165 } else {
4166 $_SESSION['usces_member']['ID'] = $member['ID'];
4167 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4168 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4169 $_SESSION['usces_member']['point'] = $member['mem_point'];
4170 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4171 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4172 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4173 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4174 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4175 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4176 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4177 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4178 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4179 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4180 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4181 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4182 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4183 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4184 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4185 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4186 $_SESSION['usces_member']['status'] = $member['mem_status'];
4187 //20100818ysk start
4188 $this->set_session_custom_member($member['ID']);
4189 //20100818ysk end
4190 $this->get_current_member();
4191
4192 if( isset($_POST['rememberme']) ){
4193 $cookie['name'] = $email;
4194 $cookie['rme'] = 'forever';
4195 $this->set_cookie($cookie);
4196 }else{
4197 $cookie['name'] = '';
4198 $cookie['rme'] = '';
4199 $this->set_cookie($cookie);
4200 }
4201
4202 do_action( 'usces_action_after_login' );
4203 return apply_filters( 'usces_filter_member_login', 'member', $member );
4204 }
4205 }
4206 }
4207 }
4208
4209 function member_just_login($email, $pass) {
4210 global $wpdb;
4211 $pass = md5($pass);
4212 $member_table = $wpdb->prefix . "usces_member";
4213
4214 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4215 $member = $wpdb->get_row( $query, ARRAY_A );
4216 if ( empty($member) ) {
4217 $this->current_member['email'] = htmlspecialchars($email);
4218 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4219 return 'login';
4220 } else {
4221 $_SESSION['usces_member']['ID'] = $member['ID'];
4222 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4223 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4224 $_SESSION['usces_member']['point'] = $member['mem_point'];
4225 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4226 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4227 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4228 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4229 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4230 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4231 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4232 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4233 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4234 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4235 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4236 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4237 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4238 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4239 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4240 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4241 $_SESSION['usces_member']['status'] = $member['mem_status'];
4242 //20100818ysk start
4243 $this->set_session_custom_member($member['ID']);
4244 //20100818ysk end
4245 $this->get_current_member();
4246
4247 // $cookie = $this->get_cookie();
4248 // if(isset($_POST['rememberme']) && $cookie){
4249 // $cookie['name'] = $email;
4250 // $cookie['pass'] = trim($_POST['loginpass']);
4251 // $this->set_cookie($cookie);
4252 // }else{
4253 // $cookie['name'] = '';
4254 // $cookie['pass'] = '';
4255 // $this->set_cookie($cookie);
4256 // }
4257
4258 do_action( 'usces_action_after_login' );
4259 return apply_filters( 'usces_filter_member_login', 'member', $member );
4260 }
4261 }
4262
4263 function member_logout() {
4264 unset($_SESSION['usces_member'], $_SESSION['usces_entry']);
4265 do_action('usces_action_member_logout');
4266 wp_redirect(get_option('home'));
4267 exit;
4268 }
4269
4270 function get_current_member() {
4271
4272 if ( isset($_SESSION['usces_member']['ID']) ) {
4273 $this->current_member['id'] = $_SESSION['usces_member']['ID'];
4274 $this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return');
4275 } else {
4276 $this->current_member['id'] = 0;
4277 $this->current_member['name'] = __('guest', 'usces');
4278 }
4279 }
4280
4281 function get_member() {
4282 $res = array(
4283 'ID' => '',
4284 'registered' => '',
4285 'mailaddress1' => '',
4286 'mailaddress2' => '',
4287 'password1' => '',
4288 'password2' => '',
4289 'point' => '',
4290 'name1' => '',
4291 'name2' => '',
4292 'name3' => '',
4293 'name4' => '',
4294 'zipcode' => '',
4295 'address1' => '',
4296 'address2' => '',
4297 'address3' => '',
4298 'tel' => '',
4299 'fax' => '',
4300 'country' => '',
4301 'pref' => '',
4302 'status' => ''
4303 );
4304 if(!empty($_SESSION['usces_member'])) {
4305 foreach ( $_SESSION['usces_member'] as $key => $value ) {
4306 //20100818ysk start
4307 if(is_array($_SESSION['usces_member'][$key]))
4308 $res[$key] = stripslashes_deep($value);
4309 else
4310 //20100818ysk end
4311 $res[$key] = stripslashes($value);
4312 }
4313 }
4314 return $res;
4315 }
4316
4317 function get_member_info( $mid ) {
4318 global $wpdb;
4319 $infos = array();
4320
4321 //if( !current_user_can('activate_plugins') ) return array();
4322
4323 $table = $wpdb->prefix . "usces_member";
4324 $query = $wpdb->prepare("SELECT * FROM $table WHERE ID = %d", $mid);
4325 $datas = $wpdb->get_results( $query, ARRAY_A );
4326 if( $datas ) {
4327 $infos = $datas[0];
4328
4329 $table = $wpdb->prefix . "usces_member_meta";
4330 $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid);
4331 $metas = $wpdb->get_results( $query, ARRAY_A );
4332
4333 foreach( $metas as $meta ){
4334 $infos[$meta['meta_key']] = maybe_unserialize($meta['meta_value']);
4335 }
4336 }
4337 return $infos;
4338 }
4339
4340 function set_member_info( $data=array(), $mid ) {
4341 global $wpdb;
4342
4343 $table = $wpdb->prefix . "usces_member";
4344 $res = $wpdb->update( $table, $data, array('ID'=>$mid), NULL, array('%d'));
4345 return $res;
4346 }
4347
4348 function is_order($mid, $oid) {
4349 global $wpdb;
4350
4351 $table = $wpdb->prefix . "usces_order";
4352 $query = $wpdb->prepare("SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid);
4353 $mem_id = $wpdb->get_var( $query );
4354 if ( empty($mem_id) ) {
4355 return false;
4356 }else{
4357 return true;
4358 }
4359 }
4360
4361 function is_purchased_item($mid, $post_id, $sku = NULL) {
4362 global $wpdb;
4363 $res = false;
4364
4365 $history = $this->get_member_history($mid);
4366 foreach ( $history as $umhs ) {
4367 $cart = $umhs['cart'];
4368 $status = $umhs['order_status'];
4369 for($i=0; $i<count($cart); $i++) {
4370 $cart_row = $cart[$i];
4371 $sku_code = urldecode($cart_row['sku']);
4372 if( empty($sku) ){
4373 if( $cart_row['post_id'] == $post_id && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4374 $res = true;
4375 break 2;
4376 }elseif( $cart_row['post_id'] == $post_id && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4377 $res = 'noreceipt';
4378 break 2;
4379 }
4380 }else{
4381 if( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4382 $res = true;
4383 break 2;
4384 }elseif( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4385 $res = 'noreceipt';
4386 break 2;
4387 }
4388 }
4389 }
4390
4391 }
4392 return $res;
4393 }
4394
4395 function get_order_data($order_id, $mode = '' ) {
4396 global $wpdb, $usces;
4397 $order_table = $wpdb->prefix . "usces_order";
4398
4399 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $order_id);
4400
4401 if( 'direct' == $mode ){
4402 $value = $wpdb->get_row( $query, ARRAY_A );
4403 return $value;
4404 }
4405
4406 $value = $wpdb->get_row( $query );
4407
4408 if( $value == NULL ) {
4409 return false;
4410 }else{
4411 $res =array();
4412 }
4413 if(strpos($value->order_status, 'cancel') !== false || strpos($value->order_status, 'estimate') !== false){
4414 return false;
4415 }
4416
4417 $res = array(
4418 'ID' => $value->ID,
4419 'mem_id' => $value->mem_id,
4420 'cart' => unserialize($value->order_cart),
4421 'condition' => unserialize($value->order_condition),
4422 'getpoint' => $value->order_getpoint,
4423 'usedpoint' => $value->order_usedpoint,
4424 'discount' => $value->order_discount,
4425 'payment_name' => $value->order_payment_name,
4426 'shipping_charge' => $value->order_shipping_charge,
4427 'cod_fee' => $value->order_cod_fee,
4428 'tax' => $value->order_tax,
4429 'end_price' => $value->order_item_total_price - $value->order_usedpoint + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax,
4430 'status' => $value->order_status,
4431 'date' => mysql2date(__('Y/m/d'), $value->order_date),
4432 'modified' => mysql2date(__('Y/m/d'), $value->order_modified)
4433 );
4434
4435 return $res;
4436 }
4437
4438 function get_orderIDs_by_postID($mem_id, $post_id) {
4439 global $wpdb;
4440 $order_table = $wpdb->prefix . "usces_order";
4441
4442 $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);
4443 $rows = $wpdb->get_query( $query, ARRAY_A );
4444
4445 if( $value == NULL ) {
4446 return false;
4447 }else{
4448 foreach($rows as $row){
4449 if(strpos($row['order_status'], 'cancel') !== false || strpos($row['order_status'], 'estimate') !== false){
4450 continue;
4451 }else{
4452 $carts = unserialize($row['order_cart']);
4453 foreach($carts as $cart){
4454 if( $post_id == $cart['post_id'] ){
4455 $res[] = $row['ID'];
4456 break;
4457 }
4458 }
4459 }
4460 }
4461 }
4462 return $res;
4463 }
4464
4465 function incart_check() {
4466 //$_POST = $this->stripslashes_deep_post($_POST);
4467 $mes = array();
4468
4469 $ids = array_keys($_POST['inCart']);
4470 $post_id = $ids[0];
4471 $skus = array_keys($_POST['inCart'][$post_id]);
4472 $sku = $skus[0];
4473 $quant = isset($_POST['quant'][$post_id][$sku]) ? (int)$_POST['quant'][$post_id][$sku] : 1;
4474 $stock = $this->getItemZaikoNum($post_id, $sku);
4475 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku);
4476 $itemRestriction = get_post_meta($post_id, '_itemRestriction',true );
4477
4478 if( 1 > $quant ){
4479 $mes[$post_id][$sku] = __('enter the correct amount', 'usces') . "<br />";
4480 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4481 $mes[$post_id][$sku] = sprintf(__("This article is limited by %d at a time.", 'usces'), $itemRestriction) . "<br />";
4482 }else if( $quant > (int)$stock && !WCUtils::is_blank($stock) ){
4483 $mes[$post_id][$sku] = __('Sorry, stock is insufficient.', 'usces') . ' ' . __('Current stock', 'usces') . $stock . "<br />";
4484 }else if( 1 < $zaiko_id ){
4485 $mes[$post_id][$sku] = __('Sorry, this item is sold out.', 'usces') . "<br />";
4486 }
4487
4488 $ioptkeys = $this->get_itemOptionKey( $post_id, true );
4489 if($ioptkeys){
4490 foreach($ioptkeys as $key => $value){
4491 $optValues = $this->get_itemOptions( urldecode($value), $post_id );
4492 if( 0 == $optValues['means'] ){ //case of select
4493 if( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][$post_id][$sku][$value] ){
4494 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4495 }
4496 }elseif( 1 == $optValues['means'] ){ //case of multiselect
4497 if( $optValues['essential'] ){
4498 $mselect = 0;
4499 foreach((array)$_POST['itemOption'][$post_id][$sku][$value] as $mvalue){
4500 if(!empty($mvalue) and '#NONE#' != $mvalue) $mselect++;
4501 }
4502 if( $mselect == 0 ){
4503 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4504 }
4505 }
4506 }else{ //case of text
4507 if( $optValues['essential'] && WCUtils::is_blank($_POST['itemOption'][$post_id][$sku][$value]) ){
4508 $mes[$post_id][$sku] .= sprintf(__("Input the %s", 'usces'), urldecode($value)) . "<br />";
4509 }
4510 }
4511 }
4512 }
4513
4514 $mes = apply_filters('usces_filter_incart_check', $mes, $post_id, $sku);
4515
4516 if( isset($mes[$post_id]) && is_array($mes[$post_id]) ){
4517 foreach( $mes[$post_id] as $skukey => $skuvalue ){
4518 $mes[$post_id][$skukey] = rtrim($skuvalue, "<br />");
4519 }
4520 }
4521
4522 if( !empty($mes) ){
4523 $_SESSION['usces_singleitem']['itemOption'] = $_POST['itemOption'];
4524 $_SESSION['usces_singleitem']['quant'] = $_POST['quant'];
4525 $_SESSION['usces_singleitem']['error_message'] = $mes;
4526 if( false === strpos($_POST['usces_referer'], 'http') ){
4527 $parse_url = parse_url(get_home_url());
4528 header('location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $_POST['usces_referer'] . '#cart_button');
4529 }else{
4530 header('location: ' . $_POST['usces_referer'] . '#cart_button');
4531 }
4532 exit;
4533 }
4534
4535 do_action('usces_action_incart_checked', $mes, $post_id, $sku);
4536 }
4537
4538 function zaiko_check() {
4539 $mes = '';
4540 $cart = $this->cart->get_cart();
4541 $stocks = array();
4542
4543 for($i=0; $i<count($cart); $i++) {
4544 $cart_row = $cart[$i];
4545 $post_id = $cart_row['post_id'];
4546 $sku = $cart_row['sku'];
4547 $sku_code = urldecode($cart_row['sku']);
4548
4549 $quant = ( isset($_POST['quant']) ) ? trim($_POST['quant'][$i][$post_id][$sku]) : $cart_row['quantity'];
4550 //$zaiko_status = $this->getItemZaiko($post_id, $sku);
4551 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku_code);
4552 $stock = $this->getItemZaikoNum($post_id, $sku_code);
4553 if( !isset($stocks[$post_id][$sku]) ){
4554 if( !WCUtils::is_blank($stock) ){
4555 $stocks[$post_id][$sku] = $stock;
4556 }else{
4557 $stocks[$post_id][$sku] = NULL;
4558 }
4559 }
4560 $checkstock = $stocks[$post_id][$sku];
4561 $stocks[$post_id][$sku] = $stocks[$post_id][$sku] - $quant;
4562 $itemRestriction = get_post_meta($post_id, '_itemRestriction', true);
4563
4564 //$red = (in_array($zaiko_status, array(__('Sold Out', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'red' : '';
4565
4566 if( 1 > (int)$quant ){
4567 $mes .= sprintf(__("Enter the correct amount for the No.%d item.", 'usces'), ($i+1)) . "<br />";
4568 }else if( 1 < $zaiko_id || WCUtils::is_zero($stock) ){
4569 $mes .= sprintf(__('Sorry, No.%d item is sold out.', 'usces'), ($i+1)) . "<br />";
4570 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4571 $mes .= sprintf(__('This article is limited by %1$d at a time for the No.%2$d item.', 'usces'), $itemRestriction, ($i+1)) . "<br />";
4572 }else if( 0 > $stocks[$post_id][$sku] && !WCUtils::is_blank($stock) ){
4573 $mes .= sprintf(__('Stock of No.%1$d item is remainder %2$d.', 'usces'), ($i+1), $checkstock) . "<br />";
4574 }
4575 }
4576 $mes = apply_filters('usces_filter_zaiko_check', $mes, $cart);
4577 return $mes;
4578 }
4579
4580 function member_check() {
4581 $mes = '';
4582 foreach ( $_POST['member'] as $key => $vlue ) {
4583 $_SESSION['usces_member'][$key] = trim($vlue);
4584 }
4585 //0000526
4586 $member_pass_rule_min = $this->options['system']['member_pass_rule_min'];
4587 $member_pass_rule_max = $this->options['system']['member_pass_rule_max'];
4588
4589 if ( !WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ){
4590 if( !empty( $member_pass_rule_max ) ){
4591 if( $member_pass_rule_min > strlen( trim($_POST['member']['password1']) ) || strlen( trim($_POST['member']['password1']) ) > $member_pass_rule_max ){
4592 $mes .= sprintf(__('Please enter %2$s characters a minimum of %1$s characters and a maximum password.', 'usces'), $member_pass_rule_min, $member_pass_rule_max ) . "<br />";
4593 }
4594 }else{
4595 if( $member_pass_rule_min > strlen( trim($_POST['member']['password1']) ) ){
4596 $mes .= sprintf(__('Please enter at least %s characters password.', 'usces'), $member_pass_rule_min) . "<br />";
4597 }
4598 }
4599 }
4600 if ( $_POST['member_regmode'] == 'editmemberform' ) {
4601 if ( (!WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ) && trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4602 $mes .= __('Password is not correct.', 'usces') . "<br />";
4603
4604 if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) )
4605 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4606
4607 } else {
4608 if ( WCUtils::is_blank($_POST['member']['password1']) || WCUtils::is_blank($_POST['member']['password2']) || trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4609 $mes .= __('Password is not correct.', 'usces') . "<br />";
4610 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']) )
4611 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4612
4613 }
4614 if ( WCUtils::is_blank($_POST["member"]["name1"]) )
4615 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4616 // if ( trim($_POST["member"]["name3"]) == "" && USCES_JP )
4617 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4618 if ( WCUtils::is_blank($_POST["member"]["zipcode"]) )
4619 $mes .= __('postal code is not correct', 'usces') . "<br />";
4620 if ( $_POST["member"]["pref"] == __('-- Select --', 'usces') )
4621 $mes .= __('enter the prefecture', 'usces') . "<br />";
4622 if ( WCUtils::is_blank($_POST["member"]["address1"]) )
4623 $mes .= __('enter the city name', 'usces') . "<br />";
4624 if ( WCUtils::is_blank($_POST["member"]["address2"]) )
4625 $mes .= __('enter house numbers', 'usces') . "<br />";
4626 if ( WCUtils::is_blank($_POST["member"]["tel"]) )
4627 $mes .= __('enter phone numbers', 'usces') . "<br />";
4628 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4629 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4630
4631 $mes = apply_filters('usces_filter_member_check', $mes);
4632
4633 return $mes;
4634 }
4635
4636 function member_check_fromcart() {
4637 $mes = '';
4638 //0000526
4639 $member_pass_rule_min = $this->options['system']['member_pass_rule_min'];
4640 $member_pass_rule_max = $this->options['system']['member_pass_rule_max'];
4641
4642 if ( !WCUtils::is_blank($_POST['customer']['password1']) || !WCUtils::is_blank($_POST['customer']['password2']) ){
4643 if( !empty( $member_pass_rule_max ) ){
4644 if( $member_pass_rule_min > strlen( trim($_POST['customer']['password1']) ) || strlen( trim($_POST['customer']['password1']) ) > $member_pass_rule_max )
4645 $mes .= sprintf(__('Please enter %2$s characters a minimum of %1$s characters and a maximum password.', 'usces'), $member_pass_rule_min, $member_pass_rule_max ) . "<br />";
4646 }else{
4647 if( $member_pass_rule_min > strlen( trim($_POST['customer']['password1']) ) )
4648 $mes .= sprintf(__('Please enter at least %s characters password.', 'usces'), $member_pass_rule_min) . "<br />";
4649 }
4650 }
4651 if ( WCUtils::is_blank($_POST['customer']['password1']) || WCUtils::is_blank($_POST['customer']['password2']) || trim($_POST['customer']['password1']) != trim($_POST['customer']['password2']) )
4652 $mes .= __('Password is not correct.', 'usces') . "<br />";
4653 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']) )
4654 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4655 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4656 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4657 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4658 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4659 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4660 $mes .= __('postal code is not correct', 'usces') . "<br />";
4661 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4662 $mes .= __('enter the prefecture', 'usces') . "<br />";
4663 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4664 $mes .= __('enter the city name', 'usces') . "<br />";
4665 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4666 $mes .= __('enter house numbers', 'usces') . "<br />";
4667 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4668 $mes .= __('enter phone numbers', 'usces') . "<br />";
4669 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4670 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4671
4672 $mes = apply_filters('usces_filter_member_check_fromcart', $mes);
4673
4674 return $mes;
4675 }
4676
4677 function admin_member_check() {
4678 global $wpdb;
4679 $mes = '';
4680 if ( !is_email( trim($_POST['member']["email"]) ) ){
4681 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4682 }else{
4683 $member_table = $wpdb->prefix . "usces_member";
4684 $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
4685 if( trim($_POST['member']["email"]) != $mem_email ){
4686 $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
4687 if( !empty($mem_ID) )
4688 $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />";
4689 }
4690 }
4691 if ( WCUtils::is_blank($_POST['member']["name1"]) )
4692 $mes .= __('Name is not correct', 'usces') . "<br />";
4693 // if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
4694 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4695 // if ( trim($_POST['member']["zipcode"]) == "" )
4696 // $mes .= __('postal code is not correct', 'usces') . "<br />";
4697 // if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
4698 // $mes .= __('enter the prefecture', 'usces') . "<br />";
4699 // if ( trim($_POST['member']["address1"]) == "" )
4700 // $mes .= __('enter the city name', 'usces') . "<br />";
4701 // if ( trim($_POST['member']["address2"]) == "" )
4702 // $mes .= __('enter house numbers', 'usces') . "<br />";
4703 // if ( trim($_POST['member']["tel"]) == "" )
4704 // $mes .= __('enter phone numbers', 'usces') . "<br />";
4705 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4706 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4707
4708 $mes = apply_filters('usces_filter_admin_member_check', $mes);
4709
4710 return $mes;
4711 }
4712
4713 function customer_check() {
4714 $mes = '';
4715 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']) )
4716 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4717 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4718 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4719 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4720 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4721 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4722 $mes .= __('postal code is not correct', 'usces') . "<br />";
4723 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4724 $mes .= __('enter the prefecture', 'usces') . "<br />";
4725 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4726 $mes .= __('enter the city name', 'usces') . "<br />";
4727 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4728 $mes .= __('enter house numbers', 'usces') . "<br />";
4729 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4730 $mes .= __('enter phone numbers', 'usces') . "<br />";
4731 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4732 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4733
4734 $mes = apply_filters('usces_filter_customer_check', $mes);
4735
4736 return $mes;
4737 }
4738
4739 function admin_new_member_check() {
4740 global $wpdb;
4741
4742 $member_pass_rule_min = $this->options['system']['member_pass_rule_min'];
4743 $member_pass_rule_max = $this->options['system']['member_pass_rule_max'];
4744 $mes = '';
4745
4746 if ( !WCUtils::is_blank( $_POST['member']['password'] ) ){
4747 if( !empty( $member_pass_rule_max ) ){
4748 if( $member_pass_rule_min > strlen( trim($_POST['member']['password']) ) || strlen( trim($_POST['member']['password']) ) > $member_pass_rule_max ){
4749 $mes .= sprintf(__('Please enter %2$s characters a minimum of %1$s characters and a maximum password.', 'usces'), $member_pass_rule_min, $member_pass_rule_max ) . "<br />";
4750 }
4751 }else{
4752 if( $member_pass_rule_min > strlen( trim($_POST['member']['password']) ) ){
4753 $mes .= sprintf(__('Please enter at least %s characters password.', 'usces'), $member_pass_rule_min) . "<br />";
4754 }
4755 }
4756 }
4757 if ( !is_email( trim($_POST['member']["email"]) ) ){
4758 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4759 }else{
4760 $member_table = $wpdb->prefix . "usces_member";
4761 $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
4762 if( trim($_POST['member']["email"]) != $mem_email ){
4763 $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
4764 if( !empty($mem_ID) )
4765 $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />";
4766 }
4767 }
4768 if ( WCUtils::is_blank($_POST['member']["name1"]) )
4769 $mes .= __('Name is not correct', 'usces') . "<br />";
4770 // if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
4771 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4772 // if ( trim($_POST['member']["zipcode"]) == "" )
4773 // $mes .= __('postal code is not correct', 'usces') . "<br />";
4774 // if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
4775 // $mes .= __('enter the prefecture', 'usces') . "<br />";
4776 // if ( trim($_POST['member']["address1"]) == "" )
4777 // $mes .= __('enter the city name', 'usces') . "<br />";
4778 // if ( trim($_POST['member']["address2"]) == "" )
4779 // $mes .= __('enter house numbers', 'usces') . "<br />";
4780 // if ( trim($_POST['member']["tel"]) == "" )
4781 // $mes .= __('enter phone numbers', 'usces') . "<br />";
4782 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4783 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4784
4785 $mes = apply_filters('usces_filter_admin_member_check', $mes);
4786
4787 return $mes;
4788 }
4789
4790 function delivery_check() {
4791 $mes = '';
4792 if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
4793 if ( WCUtils::is_blank($_POST["delivery"]["name1"]) )
4794 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4795 // if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP )
4796 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4797 if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) )
4798 $mes .= __('postal code is not correct', 'usces') . "<br />";
4799 if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') )
4800 $mes .= __('enter the prefecture', 'usces') . "<br />";
4801 if ( WCUtils::is_blank($_POST["delivery"]["address1"]) )
4802 $mes .= __('enter the city name', 'usces') . "<br />";
4803 if ( WCUtils::is_blank($_POST["delivery"]["address2"]) )
4804 $mes .= __('enter house numbers', 'usces') . "<br />";
4805 if ( WCUtils::is_blank($_POST["delivery"]["tel"]) )
4806 $mes .= __('enter phone numbers', 'usces') . "<br />";
4807 }
4808 if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) )
4809 $mes .= __('chose one from delivery method.', 'usces') . "<br />";
4810 if ( !isset($_POST['offer']['payment_name']) ){
4811 $mes .= __('chose one from payment options.', 'usces') . "<br />";
4812 }else{
4813 $payments = $this->getPayments($_POST['offer']['payment_name']);
4814 if('COD' == $payments['settlement']){
4815 $total_items_price = $this->get_total_price();
4816 $usces_entries = $this->cart->get_entry();
4817 $materials = array(
4818 'total_items_price' => $usces_entries['order']['total_items_price'],
4819 'discount' => $usces_entries['order']['discount'],
4820 'shipping_charge' => $usces_entries['order']['shipping_charge'],
4821 'cod_fee' => $usces_entries['order']['cod_fee'],
4822 );
4823 $tax = $this->getTax( $total_items_price, $materials );
4824 $total_items_price = $total_items_price + $tax;
4825 $cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
4826 if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount )
4827 $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 />";
4828 }
4829 }
4830 //20101119ysk start
4831 if(isset($_POST['offer']['delivery_method']) and isset($_POST['offer']['payment_name'])) {
4832 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4833 if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) {
4834 $payments = $this->getPayments($_POST['offer']['payment_name']);
4835 if('COD' == $payments['settlement'])
4836 $mes .= __('COD is not available.', 'usces') . "<br />";
4837 }
4838 }
4839 //20101119ysk end
4840 //20110317ysk start
4841 if(isset($_POST['offer']['delivery_method'])) {
4842 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4843 $country = $_SESSION['usces_entry']["delivery"]["country"];
4844 $local_country = usces_get_base_country();
4845 if($country == $local_country) {
4846 if($this->options['delivery_method'][$d_method_index]['intl'] == 1) {
4847 $mes .= __('Delivery method is incorrect. Can not specify an international flight.', 'usces') . "<br />";
4848 }
4849 } else {
4850 if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) {
4851 $mes .= __('Delivery method is incorrect. Specify the international flights.', 'usces') . "<br />";
4852 }
4853 }
4854 }
4855 //20110317ysk end
4856
4857 $mes = apply_filters('usces_filter_delivery_check', $mes);
4858
4859 return $mes;
4860 }
4861
4862 function point_check( $entries ) {
4863 $member = $this->get_member();
4864 $this->set_cart_fees( $member, $entries );
4865 $mes = '';
4866 if( isset($_POST['offer']["usedpoint"]) ) {
4867 if ( WCUtils::is_blank($_POST['offer']["usedpoint"]) || !preg_match("/^[0-9]+$/", $_POST['offer']["usedpoint"]) || (int)$_POST['offer']["usedpoint"] < 0 ) {
4868 $mes .= __('Invalid value. Please enter in the numbers.', 'usces') . "<br />";
4869 } else {
4870 /* if ( trim($_POST['offer']["usedpoint"]) > $member['point'] ){
4871 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".$member['point']."pt<br />";
4872 $_POST['offer']["usedpoint"] = 0;
4873 $array = array(
4874 'usedpoint' => 0
4875 );
4876 $this->cart->set_order_entry( $array );
4877 }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'])){
4878 $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 />";
4879 $_POST['offer']["usedpoint"] = 0;
4880 $array = array(
4881 'usedpoint' => 0
4882 );
4883 $this->cart->set_order_entry( $array );
4884 }elseif(!$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'])){
4885 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4886 $_POST['offer']["usedpoint"] = 0;
4887 $array = array(
4888 'usedpoint' => 0
4889 );
4890 $this->cart->set_order_entry( $array );
4891 }
4892 */ if( trim($_POST['offer']["usedpoint"]) > $member['point'] ) {
4893 $mes .= __('You have exceeded the maximum available.', 'usces')."max".$member['point']."pt<br />";
4894 } 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']) ) {
4895 $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 />";
4896 } elseif( !$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount']) ) {
4897 $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4898 }
4899 $mes = apply_filters( 'usces_filter_point_check', $mes );
4900 if( '' != $mes ) {
4901 $_POST['offer']["usedpoint"] = 0;
4902 $array = array(
4903 'usedpoint' => 0
4904 );
4905 $this->cart->set_order_entry( $array );
4906 }
4907 }
4908 }
4909 $mes = apply_filters('usces_filter_point_check_last', $mes);
4910 return $mes;
4911 }
4912
4913 function lostpass_mailaddcheck() {
4914 $mes = '';
4915 if ( !is_email($_POST['loginmail']) || WCUtils::is_blank($_POST['loginmail']) ) {
4916 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4917 }elseif( !$this->is_member($_POST['loginmail']) ){
4918 $mes .= __('It is the e-mail address that there is not.', 'usces') . "<br />";
4919 }
4920
4921 return $mes;
4922 }
4923
4924 function changepass_check() {
4925 $mes = '';
4926 if ( WCUtils::is_blank($_POST['loginpass1']) || WCUtils::is_blank($_POST['loginpass2']) || (trim($_POST['loginpass1']) != trim($_POST['loginpass2'])))
4927 $mes .= __('Password is not correct.', 'usces') . "<br />";
4928
4929 return $mes;
4930 }
4931
4932 function get_page() {
4933 return $this->page;
4934 }
4935
4936 function check_display_mode() {
4937 $options = get_option('usces');
4938 if( isset($options['display_mode']) && $options['display_mode'] == 'Maintenancemode' ) return;
4939
4940 $start['hour'] = empty($options['campaign_schedule']['start']['hour']) ? 0 : $options['campaign_schedule']['start']['hour'];
4941 $start['min'] = empty($options['campaign_schedule']['start']['min']) ? 0 : $options['campaign_schedule']['start']['min'];
4942 $start['month'] = empty($options['campaign_schedule']['start']['month']) ? 0 : $options['campaign_schedule']['start']['month'];
4943 $start['day'] = empty($options['campaign_schedule']['start']['day']) ? 0 : $options['campaign_schedule']['start']['day'];
4944 $start['year'] = empty($options['campaign_schedule']['start']['year']) ? 0 : $options['campaign_schedule']['start']['year'];
4945 $end['hour'] = empty($options['campaign_schedule']['end']['hour']) ? 0 : $options['campaign_schedule']['end']['hour'];
4946 $end['min'] = empty($options['campaign_schedule']['end']['min']) ? 0 : $options['campaign_schedule']['end']['min'];
4947 $end['month'] = empty($options['campaign_schedule']['end']['month']) ? 0 : $options['campaign_schedule']['end']['month'];
4948 $end['day'] = empty($options['campaign_schedule']['end']['day']) ? 0 : $options['campaign_schedule']['end']['day'];
4949 $end['year'] = empty($options['campaign_schedule']['end']['year']) ? 0 : $options['campaign_schedule']['end']['year'];
4950 $starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']);
4951 $endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']);
4952 $current_time = current_time('timestamp');
4953
4954 if( ($current_time >= $starttime) && ($current_time <= $endtime) )
4955 $options['display_mode'] = 'Promotionsale';
4956 else
4957 $options['display_mode'] = 'Usualsale';
4958
4959 update_option('usces', $options);
4960
4961 }
4962
4963 function update_business_days() {
4964 $options = get_option('usces');
4965 $datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
4966 $dhour = (int)substr($datetimestr, 11, 2);
4967 $dminute = (int)substr($datetimestr, 14, 2);
4968 $dsecond = (int)substr($datetimestr, 17, 2);
4969 $dmonth = (int)substr($datetimestr, 5, 2);
4970 $dday = (int)substr($datetimestr, 8, 2);
4971 $dyear = (int)substr($datetimestr, 0, 4);
4972 $dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear);
4973 $datenow = getdate($dtimestamp);
4974 //list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1);
4975 list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], 1, 1);
4976
4977 if(isset($options['business_days'][$year][$mon][1]))
4978 unset($options['business_days'][$year][$mon]);
4979
4980 for($i=0; $i<12; $i++){
4981 //list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i);
4982 list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], 1, $i);
4983 $last = getLastDay($year, $mon);
4984 for($j=1; $j<=$last; $j++){
4985 if(!isset($options['business_days'][$year][$mon][$j]))
4986 $options['business_days'][$year][$mon][$j] = 1;
4987 }
4988 }
4989 update_option('usces', $options);
4990 $this->options = get_option('usces');
4991 $_SESSION['usces_checked_business_days'] = '';
4992 }
4993
4994 function display_cart() {
4995 if($this->cart->num_row() > 0) {
4996 include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
4997 } else {
4998 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4999 }
5000 }
5001
5002 function display_cart_confirm() {
5003 if($this->cart->num_row() > 0) {
5004 include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php');
5005 } else {
5006 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
5007 }
5008 }
5009
5010 function set_initial() {
5011
5012 $rets07 = usces_upgrade_07();
5013 $rets11 = usces_upgrade_11();
5014 //$rets14 = usces_upgrade_14();
5015 $this->set_default_theme();
5016 $this->set_default_page();
5017 $this->set_default_categories();
5018 $this->create_table();
5019 $this->update_table();
5020 $this->update_options();//20120710ysk 0000472
5021 }
5022
5023 function create_table() {
5024 global $wpdb;
5025
5026 if ( ! empty($wpdb->charset) )
5027 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
5028 if ( ! empty($wpdb->collate) )
5029 $charset_collate .= " COLLATE $wpdb->collate";
5030
5031 $access_table = $wpdb->prefix . "usces_access";
5032 $member_table = $wpdb->prefix . "usces_member";
5033 $member_meta_table = $wpdb->prefix . "usces_member_meta";
5034 $order_table = $wpdb->prefix . "usces_order";
5035 $order_meta_table = $wpdb->prefix . "usces_order_meta";
5036 $ordercart_table = $wpdb->prefix . "usces_ordercart";
5037 $ordercart_meta_table = $wpdb->prefix . "usces_ordercart_meta";
5038 $log_table = $wpdb->prefix . "usces_log";
5039
5040 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5041
5042 if($wpdb->get_var("show tables like '$access_table'") != $access_table) {
5043
5044 $sql = "CREATE TABLE " . $access_table . " (
5045 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5046 acc_key VARCHAR( 50 ) NOT NULL ,
5047 acc_type VARCHAR( 50 ) NULL ,
5048 acc_value LONGTEXT NULL ,
5049 acc_date DATE NOT NULL DEFAULT '0000-00-00',
5050 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
5051 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
5052 acc_str1 VARCHAR( 200 ) NULL ,
5053 acc_str2 VARCHAR( 200 ) NULL ,
5054 KEY acc_key ( acc_key ),
5055 KEY acc_type ( acc_type ),
5056 KEY acc_date ( acc_date ),
5057 KEY acc_num1 ( acc_num1 ),
5058 KEY acc_num2 ( acc_num2 )
5059 ) ENGINE = MYISAM AUTO_INCREMENT=0 $charset_collate;";
5060
5061 dbDelta($sql);
5062 add_option("usces_db_access", USCES_DB_ACCESS);
5063 }
5064 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
5065
5066 $sql = "CREATE TABLE " . $member_table . " (
5067 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5068 mem_email VARCHAR( 100 ) NOT NULL ,
5069 mem_pass VARCHAR( 64 ) NOT NULL ,
5070 mem_status INT( 11 ) NOT NULL DEFAULT '0',
5071 mem_cookie VARCHAR( 13 ) NULL ,
5072 mem_point INT( 11 ) NOT NULL DEFAULT '0',
5073 mem_name1 VARCHAR( 100 ) NOT NULL ,
5074 mem_name2 VARCHAR( 100 ) NULL ,
5075 mem_name3 VARCHAR( 100 ) NULL ,
5076 mem_name4 VARCHAR( 100 ) NULL ,
5077 mem_zip VARCHAR( 50 ) NULL ,
5078 mem_pref VARCHAR( 100 ) NOT NULL ,
5079 mem_address1 VARCHAR( 100 ) NOT NULL ,
5080 mem_address2 VARCHAR( 100 ) NULL ,
5081 mem_address3 VARCHAR( 100 ) NULL ,
5082 mem_tel VARCHAR( 100 ) NOT NULL ,
5083 mem_fax VARCHAR( 100 ) NULL ,
5084 mem_delivery_flag TINYINT ( 1 ) NULL ,
5085 mem_delivery LONGTEXT,
5086 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5087 mem_nicename VARCHAR( 50 ) NULL ,
5088 KEY mem_email ( mem_email ) ,
5089 KEY mem_pass ( mem_pass )
5090 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
5091
5092 dbDelta($sql);
5093 add_option("usces_db_member", USCES_DB_MEMBER);
5094 }
5095 if($wpdb->get_var("show tables like '$member_meta_table'") != $member_meta_table) {
5096
5097 $sql = "CREATE TABLE " . $member_meta_table . " (
5098 mmeta_id bigint(20) NOT NULL auto_increment,
5099 member_id bigint(20) NOT NULL default '0',
5100 meta_key varchar(255) default NULL,
5101 meta_value longtext,
5102 PRIMARY KEY (mmeta_id),
5103 KEY order_id (member_id),
5104 KEY meta_key (meta_key)
5105 ) ENGINE = MYISAM $charset_collate;";
5106
5107 dbDelta($sql);
5108 add_option("usces_db_member_meta", USCES_DB_MEMBER_META);
5109 }
5110 if($wpdb->get_var("show tables like '$order_table'") != $order_table) {
5111
5112 $sql = "CREATE TABLE " . $order_table . " (
5113 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5114 mem_id BIGINT( 20 ) UNSIGNED NULL ,
5115 order_email VARCHAR( 100 ) NOT NULL ,
5116 order_name1 VARCHAR( 100 ) NOT NULL ,
5117 order_name2 VARCHAR( 100 ) NULL ,
5118 order_name3 VARCHAR( 100 ) NULL ,
5119 order_name4 VARCHAR( 100 ) NULL ,
5120 order_zip VARCHAR( 50 ) NULL ,
5121 order_pref VARCHAR( 100 ) NOT NULL ,
5122 order_address1 VARCHAR( 100 ) NOT NULL ,
5123 order_address2 VARCHAR( 100 ) NULL ,
5124 order_address3 VARCHAR( 100 ) NULL ,
5125 order_tel VARCHAR( 100 ) NOT NULL ,
5126 order_fax VARCHAR( 100 ) NULL ,
5127 order_delivery LONGTEXT,
5128 order_cart LONGTEXT,
5129 order_note TEXT,
5130 order_delivery_time VARCHAR( 100 ) NOT NULL ,
5131 order_payment_name VARCHAR( 100 ) NOT NULL ,
5132 order_condition TEXT,
5133 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5134 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
5135 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
5136 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5137 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5138 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5139 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5140 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5141 order_modified VARCHAR( 20 ) NULL ,
5142 order_status VARCHAR( 255 ) NULL ,
5143 order_check TEXT NULL ,
5144 order_delidue_date VARCHAR( 30 ) NULL ,
5145 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
5146 order_delivery_date VARCHAR( 100 ) NULL,
5147 KEY order_email ( order_email ) ,
5148 KEY order_name1 ( order_name1 ) ,
5149 KEY order_name2 ( order_name2 ) ,
5150 KEY order_pref ( order_pref ) ,
5151 KEY order_address1 ( order_address1 ) ,
5152 KEY order_tel ( order_tel ) ,
5153 KEY order_date ( order_date )
5154 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
5155
5156 dbDelta($sql);
5157 add_option("usces_db_order", USCES_DB_ORDER);
5158 }
5159 if($wpdb->get_var("show tables like '$order_meta_table'") != $order_meta_table) {
5160
5161 $sql = "CREATE TABLE " . $order_meta_table . " (
5162 ometa_id bigint(20) NOT NULL auto_increment,
5163 order_id bigint(20) NOT NULL default '0',
5164 meta_key varchar(255) default NULL,
5165 meta_value longtext,
5166 PRIMARY KEY (ometa_id),
5167 KEY order_id (order_id),
5168 KEY meta_key (meta_key)
5169 ) ENGINE = MYISAM $charset_collate;";
5170
5171 dbDelta($sql);
5172 add_option("usces_db_order_meta", USCES_DB_ORDER_META);
5173 }
5174
5175 if($wpdb->get_var("show tables like '$ordercart_table'") != $ordercart_table) {
5176
5177 $sql = "CREATE TABLE " . $ordercart_table . " (
5178 `cart_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
5179 `order_id` bigint( 20 ) NOT NULL ,
5180 `group_id` int( 3 ) NOT NULL DEFAULT '0',
5181 `row_index` int( 3 ) NOT NULL ,
5182 `post_id` bigint( 20 ) NOT NULL ,
5183 `item_code` varchar( 100 ) NOT NULL ,
5184 `item_name` varchar( 250 ) NOT NULL ,
5185 `cprice` decimal( 12, 0 ) DEFAULT NULL ,
5186 `sku_code` varchar( 100 ) NOT NULL ,
5187 `sku_name` varchar( 250 ) DEFAULT NULL ,
5188 `price` decimal( 12, 0 ) NOT NULL ,
5189 `quantity` float NOT NULL ,
5190 `unit` varchar( 50 ) DEFAULT NULL ,
5191 `tax` decimal( 10, 0 ) DEFAULT NULL ,
5192 `destination_id` int( 10 ) DEFAULT NULL ,
5193 `cart_serial` text,
5194 PRIMARY KEY ( `cart_id` ) ,
5195 UNIQUE KEY `row` ( `row_index` , `destination_id` , `order_id` ) ,
5196 KEY `order_id` ( `order_id` ) ,
5197 KEY `post_id` ( `post_id` ) ,
5198 KEY `item_code` ( `item_code` ) ,
5199 KEY `item_name` ( `item_name` ) ,
5200 KEY `sku_code` ( `sku_code` ) ,
5201 KEY `sku_name` ( `sku_name` )
5202 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
5203
5204 dbDelta($sql);
5205 add_option("usces_db_ordercart", USCES_DB_ORDERCART);
5206 }
5207 if($wpdb->get_var("show tables like '$ordercart_meta_table'") != $ordercart_meta_table) {
5208
5209 $sql = "CREATE TABLE " . $ordercart_meta_table . " (
5210 `cartmeta_id` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5211 `cart_id` bigint( 20 ) NOT NULL DEFAULT '0',
5212 `meta_type` varchar( 100 ) NOT NULL ,
5213 `meta_key` varchar( 255 ) DEFAULT NULL ,
5214 `meta_value` longtext,
5215 PRIMARY KEY ( `cartmeta_id` ) ,
5216 KEY `cart_id` ( `cart_id` ) ,
5217 KEY `meta_key` ( `meta_key` )
5218 ) ENGINE = MYISAM $charset_collate;";
5219
5220 dbDelta($sql);
5221 add_option("usces_db_ordercart_meta", USCES_DB_ORDERCART_META);
5222 }
5223 if($wpdb->get_var("show tables like '$log_table'") != $log_table) {
5224
5225 $sql = "CREATE TABLE " . $log_table . " (
5226 `ID` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5227 `datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5228 `log` LONGTEXT NULL ,
5229 PRIMARY KEY ( `ID` ) ,
5230 KEY `datetime` ( `datetime` )
5231 ) ENGINE = MYISAM $charset_collate;";
5232
5233 dbDelta($sql);
5234 add_option("usces_db_log", USCES_DB_LOG);
5235 }
5236
5237 }
5238
5239 function update_table()
5240 {
5241 global $wpdb;
5242 $access_table = $wpdb->prefix . "usces_access";
5243 $member_table = $wpdb->prefix . "usces_member";
5244 $member_meta_table = $wpdb->prefix . "usces_member_meta";
5245 $order_table = $wpdb->prefix . "usces_order";
5246 $order_meta_table = $wpdb->prefix . "usces_order_meta";
5247 $ordercart_table = $wpdb->prefix . "usces_ordercart";
5248 $ordercart_meta_table = $wpdb->prefix . "usces_ordercart_meta";
5249 $log_table = $wpdb->prefix . "usces_log";
5250
5251 $access_ver = get_option( "usces_db_access" );
5252 $member_ver = get_option( "usces_db_member" );
5253 $member_meta_ver = get_option( "usces_db_member_meta" );
5254 $order_ver = get_option( "usces_db_order" );
5255 $order_meta_ver = get_option( "usces_db_order_meta" );
5256 $ordercart_ver = get_option( "usces_db_ordercart" );
5257 $ordercart_meta_ver = get_option( "usces_db_ordercart_meta" );
5258 $log_ver = get_option( "usces_db_log" );
5259
5260 if( $access_ver != USCES_DB_ACCESS ) {
5261 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5262 $sql = "CREATE TABLE " . $access_table . " (
5263 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5264 acc_key VARCHAR( 50 ) NOT NULL ,
5265 acc_type VARCHAR( 50 ) NULL ,
5266 acc_value LONGTEXT NULL ,
5267 acc_date DATE NOT NULL DEFAULT '0000-00-00',
5268 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
5269 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
5270 acc_str1 VARCHAR( 200 ) NULL ,
5271 acc_str2 VARCHAR( 200 ) NULL ,
5272 KEY acc_key ( acc_key ),
5273 KEY acc_type ( acc_type ),
5274 KEY acc_date ( acc_date ),
5275 KEY acc_num1 ( acc_num1 ),
5276 KEY acc_num2 ( acc_num2 )
5277 ) ENGINE = MYISAM;";
5278
5279 dbDelta($sql);
5280 update_option( "usces_db_access", USCES_DB_ACCESS );
5281 }
5282 if( $member_ver != USCES_DB_MEMBER ) {
5283 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5284 $sql = "CREATE TABLE " . $member_table . " (
5285 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5286 mem_email VARCHAR( 100 ) NOT NULL ,
5287 mem_pass VARCHAR( 64 ) NOT NULL ,
5288 mem_status INT( 11 ) NOT NULL DEFAULT '0',
5289 mem_cookie VARCHAR( 13 ) NULL ,
5290 mem_point INT( 11 ) NOT NULL DEFAULT '0',
5291 mem_name1 VARCHAR( 100 ) NOT NULL ,
5292 mem_name2 VARCHAR( 100 ) NULL ,
5293 mem_name3 VARCHAR( 100 ) NULL ,
5294 mem_name4 VARCHAR( 100 ) NULL ,
5295 mem_zip VARCHAR( 50 ) NULL ,
5296 mem_pref VARCHAR( 100 ) NOT NULL ,
5297 mem_address1 VARCHAR( 100 ) NOT NULL ,
5298 mem_address2 VARCHAR( 100 ) NULL ,
5299 mem_address3 VARCHAR( 100 ) NULL ,
5300 mem_tel VARCHAR( 100 ) NOT NULL ,
5301 mem_fax VARCHAR( 100 ) NULL ,
5302 mem_delivery_flag TINYINT ( 1 ) NULL ,
5303 mem_delivery LONGTEXT,
5304 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5305 mem_nicename VARCHAR( 50 ) NULL ,
5306 KEY mem_email ( mem_email ) ,
5307 KEY mem_pass ( mem_pass )
5308 ) ENGINE = MYISAM;";
5309
5310 dbDelta($sql);
5311 update_option( "usces_db_member", USCES_DB_MEMBER );
5312 }
5313 if( $member_meta_ver != USCES_DB_MEMBER_META ) {
5314 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5315 $sql = "CREATE TABLE " . $member_meta_table . " (
5316 mmeta_id bigint(20) NOT NULL auto_increment,
5317 member_id bigint(20) NOT NULL default '0',
5318 meta_key varchar(255) default NULL,
5319 meta_value longtext,
5320 PRIMARY KEY (mmeta_id),
5321 KEY order_id (member_id),
5322 KEY meta_key (meta_key)
5323 ) ENGINE = MYISAM;";
5324
5325 dbDelta($sql);
5326 update_option("usces_db_member_meta", USCES_DB_MEMBER_META);
5327 }
5328 if( $order_ver != USCES_DB_ORDER ) {
5329 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5330 $sql = "CREATE TABLE " . $order_table . " (
5331 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5332 mem_id BIGINT( 20 ) UNSIGNED NULL ,
5333 order_email VARCHAR( 100 ) NOT NULL ,
5334 order_name1 VARCHAR( 100 ) NOT NULL ,
5335 order_name2 VARCHAR( 100 ) NULL ,
5336 order_name3 VARCHAR( 100 ) NULL ,
5337 order_name4 VARCHAR( 100 ) NULL ,
5338 order_zip VARCHAR( 50 ) NULL ,
5339 order_pref VARCHAR( 100 ) NOT NULL ,
5340 order_address1 VARCHAR( 100 ) NOT NULL ,
5341 order_address2 VARCHAR( 100 ) NULL ,
5342 order_address3 VARCHAR( 100 ) NULL ,
5343 order_tel VARCHAR( 100 ) NOT NULL ,
5344 order_fax VARCHAR( 100 ) NULL ,
5345 order_delivery LONGTEXT,
5346 order_cart LONGTEXT,
5347 order_note TEXT,
5348 order_delivery_time VARCHAR( 100 ) NOT NULL ,
5349 order_payment_name VARCHAR( 100 ) NOT NULL ,
5350 order_condition TEXT,
5351 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5352 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
5353 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
5354 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5355 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5356 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5357 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5358 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5359 order_modified VARCHAR( 20 ) NULL ,
5360 order_status VARCHAR( 255 ) NULL ,
5361 order_check TEXT NULL ,
5362 order_delidue_date VARCHAR( 30 ) NULL ,
5363 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
5364 order_delivery_date VARCHAR( 100 ) NULL,
5365 KEY order_email ( order_email ) ,
5366 KEY order_name1 ( order_name1 ) ,
5367 KEY order_name2 ( order_name2 ) ,
5368 KEY order_pref ( order_pref ) ,
5369 KEY order_address1 ( order_address1 ) ,
5370 KEY order_tel ( order_tel ) ,
5371 KEY order_date ( order_date )
5372 ) ENGINE = MYISAM;";
5373
5374 dbDelta($sql);
5375 update_option("usces_db_order", USCES_DB_ORDER);
5376 }
5377 if( $order_meta_ver != USCES_DB_ORDER_META ) {
5378 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5379 $sql = "CREATE TABLE " . $order_meta_table . " (
5380 ometa_id bigint(20) NOT NULL auto_increment,
5381 order_id bigint(20) NOT NULL default '0',
5382 meta_key varchar(255) default NULL,
5383 meta_value longtext,
5384 PRIMARY KEY (ometa_id),
5385 KEY order_id (order_id),
5386 KEY meta_key (meta_key)
5387 ) ENGINE = MYISAM;";
5388
5389 dbDelta($sql);
5390 update_option("usces_db_order_meta", USCES_DB_ORDER_META);
5391 }
5392 if( $ordercart_ver != USCES_DB_ORDERCART ) {
5393 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5394 $sql = "CREATE TABLE " . $ordercart_table . " (
5395 `cart_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
5396 `order_id` bigint( 20 ) NOT NULL ,
5397 `group_id` int( 3 ) NOT NULL DEFAULT '0',
5398 `row_index` int( 3 ) NOT NULL ,
5399 `post_id` bigint( 20 ) NOT NULL ,
5400 `item_code` varchar( 100 ) NOT NULL ,
5401 `item_name` varchar( 250 ) NOT NULL ,
5402 `cprice` decimal( 12, 0 ) DEFAULT NULL ,
5403 `sku_code` varchar( 100 ) NOT NULL ,
5404 `sku_name` varchar( 250 ) DEFAULT NULL ,
5405 `price` decimal( 12, 0 ) NOT NULL ,
5406 `quantity` float NOT NULL ,
5407 `unit` varchar( 50 ) DEFAULT NULL ,
5408 `tax` decimal( 10, 0 ) DEFAULT NULL ,
5409 `destination_id` int( 10 ) DEFAULT NULL ,
5410 `cart_serial` text,
5411 PRIMARY KEY ( `cart_id` ) ,
5412 UNIQUE KEY `row` ( `row_index` , `destination_id` , `order_id` ) ,
5413 KEY `order_id` ( `order_id` ) ,
5414 KEY `post_id` ( `post_id` ) ,
5415 KEY `item_code` ( `item_code` ) ,
5416 KEY `item_name` ( `item_name` ) ,
5417 KEY `sku_code` ( `sku_code` ) ,
5418 KEY `sku_name` ( `sku_name` )
5419 ) ENGINE = MYISAM;";
5420
5421 dbDelta($sql);
5422 update_option("usces_db_ordercart", USCES_DB_ORDERCART);
5423 }
5424 if( $ordercart_meta_ver != USCES_DB_ORDERCART_META ) {
5425 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5426 $sql = "CREATE TABLE " . $ordercart_meta_table . " (
5427 `cartmeta_id` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5428 `cart_id` bigint( 20 ) NOT NULL DEFAULT '0',
5429 `meta_type` varchar( 100 ) NOT NULL ,
5430 `meta_key` varchar( 255 ) DEFAULT NULL ,
5431 `meta_value` longtext,
5432 PRIMARY KEY ( `cartmeta_id` ) ,
5433 KEY `cart_id` ( `cart_id` ) ,
5434 KEY `meta_key` ( `meta_key` )
5435 ) ENGINE = MYISAM;";
5436
5437 dbDelta($sql);
5438 update_option("usces_db_ordercart_meta", USCES_DB_ORDERCART_META);
5439 }
5440 if( $log_ver != USCES_DB_LOG ) {
5441 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5442 $sql = "CREATE TABLE " . $log_table . " (
5443 `ID` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
5444 `datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5445 `log` LONGTEXT NULL ,
5446 PRIMARY KEY ( `ID` ) ,
5447 KEY `datetime` ( `datetime` )
5448 ) ENGINE = MYISAM;";
5449
5450 dbDelta($sql);
5451 update_option("usces_db_log", USCES_DB_LOG);
5452 }
5453 }
5454
5455 function set_default_theme()
5456 {
5457 $themepath = USCES_WP_CONTENT_DIR.'/themes/welcart_default';
5458 $resourcepath = USCES_WP_CONTENT_DIR.'/plugins/usc-e-shop/theme/welcart_default';
5459 if( file_exists($themepath) ) return false;
5460 if(!file_exists($resourcepath) ) return false;
5461
5462 mkdir($themepath, 0775);
5463 $this->dir_copy($resourcepath, $themepath);
5464
5465 }
5466
5467 function dir_copy($source, $dest){
5468 if ($res = opendir($source)) {
5469 while (($file = readdir($res)) !== false) {
5470 $sorce_path = $source . '/' . $file;
5471 $dest_path = $dest . '/' . $file;
5472 $filetype = @filetype($sorce_path);
5473 if( $filetype == 'file' ) {
5474 copy($sorce_path, $dest_path);
5475 }elseif( $filetype == 'dir' && $file != '..' && $file != '.' ){
5476 mkdir($dest_path);
5477 $this->dir_copy($sorce_path, $dest_path);
5478 }
5479 }
5480 closedir($res);
5481 }
5482 }
5483
5484 function set_default_page()
5485 {
5486 global $wpdb;
5487 $datetime = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
5488 $datetime_gmt = gmdate('Y-m-d H:i:s', time());
5489
5490 //cart_page
5491 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER);
5492 $cart_number = $wpdb->get_var( $query );
5493 if( $cart_number === NULL ) {
5494 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5495 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5496 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5497 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5498 VALUES (%d, %s, %s, %s, %s, %s, %s,
5499 %s, %s, %s, %s, %s, %s, %s, %s,
5500 %s, %d, %s, %d, %s, %s, %d)",
5501 1, $datetime, $datetime_gmt, '', __('Cart', 'usces'), '', 'publish',
5502 'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt,
5503 '', 0, '', 0, 'page', '', 0);
5504 $wpdb->query($query);
5505 $cart_number = $wpdb->insert_id;
5506 if( $cart_number !== NULL ) {
5507 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5508 $cart_number, '_wp_page_template', 'uscescart.php');
5509 $wpdb->query($query);
5510 }
5511 }
5512 update_option('usces_cart_number', $cart_number);
5513
5514 //member_page
5515 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER);
5516 $member_number = $wpdb->get_var( $query );
5517 if( $member_number === NULL ) {
5518 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5519 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5520 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5521 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5522 VALUES (%d, %s, %s, %s, %s, %s, %s,
5523 %s, %s, %s, %s, %s, %s, %s, %s,
5524 %s, %d, %s, %d, %s, %s, %d)",
5525 1, $datetime, $datetime_gmt, '', __('Membership', 'usces'), '', 'publish',
5526 'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt,
5527 '', 0, '', 0, 'page', '', 0);
5528 $wpdb->query($query);
5529 $member_number = $wpdb->insert_id;
5530 if( $member_number !== NULL ) {
5531 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5532 $member_number, '_wp_page_template', 'uscesmember.php');
5533 $wpdb->query($query);
5534 }
5535 }
5536 update_option('usces_member_number', $member_number);
5537
5538 }
5539
5540 function set_default_categories()
5541 {
5542 global $wpdb;
5543
5544 $idObj = get_category_by_slug('item');
5545 if( empty($idObj) ) {
5546 $item_cat = array('cat_name' => __('Items', 'usces'), 'category_description' => '', 'category_nicename' => 'item', 'category_parent' => 0);
5547 $item_cat_id = wp_insert_category($item_cat);
5548 update_option('usces_item_cat_parent_id', $item_cat_id);
5549 }
5550
5551 $idObj = get_category_by_slug('itemreco');
5552 if( empty($idObj) && isset($item_cat_id) ) {
5553 $itemreco_cat = array('cat_name' => __('Items recommended', 'usces'), 'category_description' => '', 'category_nicename' => 'itemreco', 'category_parent' => $item_cat_id);
5554 $itemreco_cat_id = wp_insert_category($itemreco_cat);
5555 }
5556
5557 $idObj = get_category_by_slug('itemnew');
5558 if( empty($idObj) && isset($item_cat_id) ) {
5559 $itemnew_cat = array('cat_name' => __('New items', 'usces'), 'category_description' => '', 'category_nicename' => 'itemnew', 'category_parent' => $item_cat_id);
5560 $itemnew_cat_id = wp_insert_category($itemnew_cat);
5561 }
5562
5563 $idObj = get_category_by_slug('itemgenre');
5564 if( empty($idObj) && isset($item_cat_id) ) {
5565 $itemgenre_cat = array('cat_name' => __('Item genre', 'usces'), 'category_description' => '', 'category_nicename' => 'itemgenre', 'category_parent' => $item_cat_id);
5566 $itemgenre_cat_id = wp_insert_category($itemgenre_cat);
5567 }
5568 }
5569 //20120710ysk start 0000472
5570 function update_options() {
5571 $target_market = $this->options['system']['target_market'];
5572
5573 $update_shipping_charge = false;
5574 $shipping_charge = isset($this->options['shipping_charge']) ? $this->options['shipping_charge'] : array();
5575 foreach( (array)$target_market as $tm ) {
5576 for( $i = 0; $i < count($shipping_charge); $i++ ) {
5577 if( isset($shipping_charge[$i]['country']) and $shipping_charge[$i]['country'] == $tm ) {
5578 foreach( $shipping_charge[$i]['value'] as $pref => $value ) {
5579 $shipping_charge[$i][$tm][$pref] = $value;
5580 }
5581 unset($shipping_charge[$i]['country']);
5582 unset($shipping_charge[$i]['value']);
5583 $update_shipping_charge = true;
5584 }
5585 }
5586 }
5587 if( $update_shipping_charge ) $this->options['shipping_charge'] = $shipping_charge;
5588
5589 $update_delivery_days = false;
5590 $delivery_days = isset($this->options['delivery_days']) ? $this->options['delivery_days'] : array();
5591 foreach( (array)$target_market as $tm ) {
5592 for( $i = 0; $i < count($delivery_days); $i++ ) {
5593 if( isset($delivery_days[$i]['country']) and $delivery_days[$i]['country'] == $tm ) {
5594 foreach( $delivery_days[$i]['value'] as $pref => $value ) {
5595 $delivery_days[$i][$tm][$pref] = $value;
5596 }
5597 unset($delivery_days[$i]['country']);
5598 unset($delivery_days[$i]['value']);
5599 $update_delivery_days = true;
5600 }
5601 }
5602 }
5603 if( $update_delivery_days ) $this->options['delivery_days'] = $delivery_days;
5604
5605 //20140131ysk start
5606 $update_acting_settings_sbps = false;
5607 if( isset($this->options['acting_settings']['sbps']['card_activate']) and 'on' == $this->options['acting_settings']['sbps']['card_activate'] ) {
5608 if( empty($this->options['acting_settings']['sbps']['send_url']) or 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do' != $this->options['acting_settings']['sbps']['send_url'] ) {
5609 $this->options['acting_settings']['sbps']['send_url'] = 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do';
5610 $update_acting_settings_sbps = true;
5611 }
5612 }
5613
5614 $update_acting_settings_paydesign = false;
5615 if( isset($this->options['acting_settings']['digitalcheck']['card_activate']) and 'on' == $this->options['acting_settings']['digitalcheck']['card_activate'] ) {
5616 $pos = strpos( $this->options['acting_settings']['digitalcheck']['send_url_card'], 'paydesign' );
5617 if( $pos === false ) {
5618 $this->options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
5619 $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(ペイデザイン)';
5620 $update_acting_settings_paydesign = true;
5621 }
5622 if( isset($this->options['acting_settings']['digitalcheck']['card_user_id']) and 'on' == $this->options['acting_settings']['digitalcheck']['card_user_id'] ) {
5623 $pos = strpos( $this->options['acting_settings']['digitalcheck']['send_url_user_id'], 'paydesign' );
5624 if( $pos === false ) {
5625 $this->options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.paydesign.jp/settle/settlex/credit2.dll";
5626 $update_acting_settings_paydesign = true;
5627 }
5628 }
5629 }
5630 if( isset($this->options['acting_settings']['digitalcheck']['conv_activate']) and 'on' == $this->options['acting_settings']['digitalcheck']['conv_activate'] ) {
5631 $pos = strpos( $this->options['acting_settings']['digitalcheck']['send_url_conv'], 'paydesign' );
5632 if( $pos === false ) {
5633 $this->options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.paydesign.jp/settle/settle3/bp3.dll";
5634 $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(ペイデザイン)';
5635 $update_acting_settings_paydesign = true;
5636 }
5637 }
5638
5639 if( $update_shipping_charge or $update_delivery_days or $update_acting_settings_sbps or $update_acting_settings_paydesign )
5640 update_option( 'usces', $this->options );
5641
5642 if( $update_acting_settings_paydesign )
5643 update_option( 'usces_payment_structure', $this->payment_structure );
5644 //20140131ysk end
5645 }
5646 //20120710ysk end
5647 function get_item_cat_ids(){
5648 $args = array('child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0, 'hierarchical' => 0);
5649 $categories = get_categories( $args );
5650 foreach($categories as $category){
5651 $ids[] = $category->term_id;
5652 }
5653 return $ids;
5654 }
5655
5656 function get_item_post_ids(){
5657 global $wpdb;
5658 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5659 $ids = $wpdb->get_col( $query );
5660
5661 return $ids;
5662 }
5663
5664 function get_item_cat_genre_ids( $post_id ){
5665 $ids = array();
5666 $all_ids = array();
5667 $genre = get_category_by_slug( 'itemgenre' );
5668 $genre_id = $genre->term_id;
5669 $args = array('child_of' => $genre_id, 'hide_empty' => 0, 'hierarchical' => 0);
5670 $categories = get_categories( $args );
5671 foreach($categories as $category){
5672 $ids[] = $category->term_id;
5673 }
5674 $allcats = get_the_category( $post_id );
5675 foreach($allcats as $cat){
5676 $all_ids[] = $cat->term_id;
5677 }
5678 //$all_ids =
5679 $results = array_intersect($ids, $all_ids);
5680
5681 return $results;
5682 }
5683
5684 function set_item_mime($post_id, $str)
5685 {
5686 global $wpdb;
5687 if( WCUtils::is_blank($str) ) return;
5688
5689 $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id);
5690 $results = $wpdb->query( $query );
5691 return $results;
5692 }
5693
5694 function isAdnminSSL()
5695 {
5696 $plugins = get_option('active_plugins');
5697 foreach($plugins as $plugin) {
5698 if( false !== strpos($plugin, USCES_ADMIN_SSL_BASE_NAME) )
5699 return true;
5700 }
5701 return false;
5702 }
5703
5704 function getGuidTax() {
5705 $tax_rate = (int)$this->options['tax_rate'];
5706
5707 if( isset($this->options['tax_mode']) ){
5708 if ( 'exclude' == $this->options['tax_mode'] )
5709 $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>';
5710 else
5711 $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>';
5712 }else{
5713 if ( 0 < $tax_rate )
5714 $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>';
5715 else
5716 $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>';
5717 }
5718
5719 return apply_filters('usces_filter_tax_guid', $str, $tax_rate);
5720 }
5721
5722 function getItemCode($post_id) {
5723 $str = get_post_meta($post_id, '_itemCode', true);
5724 return $str;
5725 }
5726
5727 function getItemName($post_id) {
5728 $str = get_post_meta($post_id, '_itemName', true);
5729 return $str;
5730 }
5731
5732 function getItemRestriction($post_id) {
5733 $str = get_post_meta($post_id, '_itemRestriction', true);
5734 return $str;
5735 }
5736
5737 function getItemPointrate($post_id) {
5738 $str = get_post_meta($post_id, '_itemPointrate', true);
5739 return $str;
5740 }
5741
5742 function getItemShipping($post_id) {
5743 $str = get_post_meta($post_id, '_itemShipping', true);
5744 return $str;
5745 }
5746
5747 function getItemShippingCharge($post_id) {
5748 $str = get_post_meta($post_id, '_itemShippingCharge', true);
5749 return (float)$str;
5750 }
5751
5752 function getItemDeliveryMethod($post_id) {
5753 $str = get_post_meta($post_id, '_itemDeliveryMethod', true);
5754 if( empty($str) )
5755 return array();
5756 else
5757 return $str;
5758 }
5759
5760 function getItemIndividualSCharge($post_id) {
5761 $str = get_post_meta($post_id, '_itemIndividualSCharge', true);
5762 return $str;
5763 }
5764
5765 function getItemGpNum1($post_id) {
5766 $str = get_post_meta($post_id, '_itemGpNum1', true);
5767 return $str;
5768 }
5769
5770 function getItemGpNum2($post_id) {
5771 $str = get_post_meta($post_id, '_itemGpNum2', true);
5772 return $str;
5773 }
5774
5775 function getItemGpNum3($post_id) {
5776 $str = get_post_meta($post_id, '_itemGpNum3', true);
5777 return $str;
5778 }
5779
5780 function getItemGpDis1($post_id) {
5781 $str = get_post_meta($post_id, '_itemGpDis1', true);
5782 return $str;
5783 }
5784
5785 function getItemGpDis2($post_id) {
5786 $str = get_post_meta($post_id, '_itemGpDis2', true);
5787 return $str;
5788 }
5789
5790 function getItemGpDis3($post_id) {
5791 $str = get_post_meta($post_id, '_itemGpDis3', true);
5792 return $str;
5793 }
5794
5795 function getItemSku($post_id, $index = '') {
5796 $array = array();
5797 $skus = $this->get_skus($post_id, 'sort');
5798 foreach((array)$skus as $sku){
5799 $array[] = $sku['code'];
5800 }
5801 if(!$array) return false;
5802 if($index == ''){
5803 return $array;
5804 }else if(isset($array[$index])){
5805 return $array[$index];
5806 }else{
5807 return false;
5808 }
5809 }
5810
5811 function getItemPrice($post_id, $skukey = '') {
5812 $array = array();
5813 $skus = $this->get_skus($post_id, 'code');
5814 foreach((array)$skus as $key => $sku){
5815 $array[$key] = (float)str_replace('.', '', $sku['price']);
5816 }
5817 if(!$array) return false;
5818 if($skukey == ''){
5819 return $array;
5820 }else if(isset($array[$skukey])){
5821 return $array[$skukey];
5822 }else{
5823 return false;
5824 }
5825 }
5826
5827 function getItemDiscount($post_id, $skukey = '') {
5828 $display_mode = $this->options['display_mode'];
5829 $array = array();
5830 $skus = $this->get_skus($post_id, 'code');
5831 foreach((array)$skus as $key => $sku){
5832 $price = (float)str_replace(',', '', $sku['price']);
5833 if ( $display_mode == 'Promotionsale' ) {
5834 if ( $this->options['campaign_privilege'] == 'discount' ){
5835 if( 0 === (int)$this->options['campaign_category'] || in_category((int)$this->options['campaign_category'], $post_id) ){
5836 $discount = $price * $this->options['privilege_discount'] / 100;
5837 }else{
5838 $discount = 0;
5839 }
5840 }else if ( $this->options['campaign_privilege'] == 'point' ){
5841 $discount = 0;
5842 }
5843 }
5844
5845 $discount = ceil($discount);
5846 $array[$key] = $discount;
5847 }
5848 if(!$array) return false;
5849 if($skukey == ''){
5850 return $array;
5851 }else if(isset($array[$skukey])){
5852 return $array[$skukey];
5853 }else{
5854 return false;
5855 }
5856 }
5857
5858 function getItemZaiko($post_id, $skukey = '') {
5859 $array = array();
5860 $skus = $this->get_skus($post_id, 'code');
5861 foreach((array)$skus as $key => $sku){
5862 $num = $sku['stock'];
5863 $array[$key] = $this->zaiko_status[$num];
5864 }
5865 if(!$array) return false;
5866 if($skukey == ''){
5867 return $array;
5868 }else if(isset($array[$skukey])){
5869 return $array[$skukey];
5870 }else{
5871 return false;
5872 }
5873 }
5874
5875 function getItemZaikoStatusId($post_id, $skukey = '') {
5876 $array = array();
5877 $skus = $this->get_skus($post_id, 'code');
5878 foreach((array)$skus as $key => $sku){
5879 $num = $sku['stock'];
5880 $array[$key] = $num;
5881 }
5882 if(!$array) return false;
5883 if($skukey == ''){
5884 return $array;
5885 }else if(isset($array[$skukey])){
5886 return $array[$skukey];
5887 }else{
5888 return false;
5889 }
5890 }
5891
5892 function updateItemZaiko($post_id, $skucode, $value) {
5893 $res = usces_update_sku( $post_id, $skucode, 'stock', $value );
5894 if( !$res ){
5895 return false;
5896 }else{
5897 return true;
5898 }
5899 }
5900
5901 function getItemZaikoNum($post_id, $skukey = '') {
5902 $array = array();
5903 $skus = $this->get_skus($post_id, 'code');
5904 foreach((array)$skus as $key => $sku){
5905 $array[$key] = $sku['stocknum'];
5906 }
5907 if(!$array) return false;
5908 if($skukey == ''){
5909 return $array;
5910 }else if(isset($array[$skukey])){
5911 return $array[$skukey];
5912 }else{
5913 return false;
5914 }
5915 }
5916
5917 function updateItemZaikoNum($post_id, $skucode, $value) {
5918 $res = usces_update_sku( $post_id, $skucode, 'stocknum', $value );
5919 if( !$res ){
5920 return false;
5921 }else{
5922 return true;
5923 }
5924 }
5925 //20120629ysk start 0000520
5926 function getItemDivision( $post_id ){
5927 if( usces_is_item($post_id) ){
5928 $item_division = get_post_meta($post_id, '_item_division', true);
5929 $division = empty($item_division) ? 'shipped' : $item_division;
5930 }else{
5931 $division = NULL;
5932 }
5933 return $division;
5934 }
5935 //20120629ysk end
5936 function getItemChargingType( $post_id, $cart = array() ){
5937 if( usces_is_item($post_id) ){
5938 $charging = get_post_meta($post_id, '_item_charging_type', true);
5939 //if( !defined('WCEX_DLSELLER') )
5940 if( !defined('WCEX_DLSELLER') and !defined('WCEX_AUTO_DELIVERY') )
5941 $charging = NULL;
5942 }else{
5943 $charging = NULL;
5944 }
5945 switch( $charging ){
5946 case 0:
5947 $type = 'once';
5948 break;
5949 case 1:
5950 $type = 'continue';
5951 break;
5952 case 2:
5953 $type = 'regular';
5954 if( !empty($cart) ) {
5955 if( empty($cart['advance']) ) {
5956 $type = 'once';
5957 } else {
5958 if( is_array($cart['advance']) and array_key_exists( 'regular', $cart['advance'] ) ) {
5959 $regular = maybe_unserialize( $cart['advance']['regular'] );
5960 } else {
5961 $advance = $this->cart->wc_unserialize( $cart['advance'] );
5962 $sku = urldecode( $cart['sku'] );
5963 $sku_encoded = $cart['sku'];
5964 $regular = $advance[$post_id][$sku_encoded]['regular'];
5965 }
5966 $unit = isset( $regular['unit'] ) ? $regular['unit'] : '';
5967 $interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0;
5968 if( empty($unit) or 1 > $interval ) //通常課金扱い
5969 $type = 'once';
5970 }
5971 }
5972 break;
5973 default:
5974 $type = NULL;
5975 }
5976 return $type;
5977 }
5978
5979 function getItemFrequency( $post_id ){
5980 $frequency = get_post_meta($post_id, '_item_frequency',true );
5981 return $frequency;
5982 }
5983
5984 function getItemChargingDay( $post_id ){
5985 $array = get_post_meta($post_id, '_item_chargingday',true );
5986 $day = (int)$array;
5987 $chargingday = empty($day) ? 1 : $day;
5988 return $chargingday;
5989 }
5990
5991 function getItemSkuDisp($post_id, $skukey = '') {
5992 $array = array();
5993 $skus = $this->get_skus($post_id, 'code');
5994 foreach((array)$skus as $key => $sku){
5995 $array[$key] = $sku['name'];
5996 }
5997 if(!$array) return false;
5998 if($skukey == ''){
5999 return $array;
6000 }else if(isset($array[$skukey])){
6001 return $array[$skukey];
6002 }else{
6003 return false;
6004 }
6005 }
6006
6007 // function getItemSkuChargingType($post_id, $skukey = '') {
6008 // $fields = get_post_custom($post_id);
6009 // $skus = array();
6010 // foreach((array)$fields as $key => $value){
6011 // if( preg_match('/^_isku_/', $key, $match) ){
6012 // $key = substr($key, 6);
6013 // $values = maybe_unserialize($value[0]);
6014 // if( isset($values['charging_type']) && "undefined" != $values['charging_type'] && !empty($values['charging_type']) ){
6015 // $skus[$key] = $values['charging_type'];
6016 // }else{
6017 // continue;
6018 // }
6019 // }
6020 // }
6021 // if( empty($skus) ) return false;
6022 // if($skukey == ''){
6023 // return $skus;
6024 // }elseif( isset($skus[$skukey]) ){
6025 // return $skus[$skukey];
6026 // }else{
6027 // return false;
6028 // }
6029 // }
6030
6031 function getItemSkuUnit($post_id, $skukey = '') {
6032 $array = array();
6033 $skus = $this->get_skus($post_id, 'code');
6034 foreach((array)$skus as $key => $sku){
6035 $array[$key] = $sku['unit'];
6036 }
6037 if(!$array) return false;
6038 if($skukey == ''){
6039 return $array;
6040 }else if(isset($array[$skukey])){
6041 return $array[$skukey];
6042 }else{
6043 return false;
6044 }
6045 }
6046
6047 function get_item( $post_id ) {
6048 $usces_item['post_id'] = $post_id;
6049 $usces_item['itemCode'] = $this->getItemCode($post_id);
6050 $usces_item['itemName'] = $this->getItemName($post_id);
6051
6052 $skus = $this->get_skus($post_id, 'code');
6053 foreach((array)$skus as $key => $sku){
6054 $usces_item['skuCodes'][] = $key;
6055 $usces_item['skuValues'][] = $sku;
6056 }
6057
6058 $usces_item = apply_filters('usces_filter_get_item', $usces_item, $post_id);
6059
6060 return $usces_item;
6061 }
6062
6063 function get_itemOptionKey( $post_id, $enc = false ) {
6064 $opts = usces_get_opts( $post_id );
6065 if(empty($opts)) return;
6066
6067 $res = array();
6068 foreach ( (array)$opts as $opt ) {
6069 if( $enc )
6070 $res[] = urlencode($opt['name']);
6071 else
6072 $res[] = $opt['name'];
6073 }
6074 return $res;
6075 }
6076
6077 function get_itemOptions( $key, $post_id ) {
6078 $opts = usces_get_opts( $post_id, 'name' );
6079 if(empty($opts[$key]))
6080 return;
6081 else
6082 return $opts[$key];
6083 }
6084
6085 function get_postIDbyCode( $itemcode ) {
6086 global $wpdb;
6087
6088 $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_itemCode', $itemcode);
6089 $res = $wpdb->get_var( $query );
6090 return $res;
6091 }
6092
6093 function get_pictids($item_code) {
6094 global $wpdb, $usces;
6095
6096 if( empty($item_code) )
6097 return false;
6098
6099 if( !$usces->options['system']['subimage_rule'] ){
6100 $codestr = $item_code.'%';
6101 $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);
6102 }else{
6103 $codestr = $item_code.'--%';
6104 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr);
6105 }
6106 $results = $wpdb->get_col( $query );
6107 return $results;
6108 }
6109
6110 function get_mainpictid($item_code) {
6111 global $wpdb;
6112 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $item_code);
6113 $id = $wpdb->get_var( $query );
6114 $id = apply_filters( 'usces_filter_get_mainpictid', $id, $item_code );
6115 return $id;
6116 }
6117
6118 function get_skus( $post_id, $keyflag = 'sort' ) {
6119 if( !$post_id )
6120 return array();
6121
6122 $skus = array();
6123 $metas = usces_get_post_meta($post_id, '_isku_');
6124 if( empty($metas) ) return $skus;
6125
6126 foreach( $metas as $rows ){
6127 $values = unserialize($rows['meta_value']);
6128 $key = isset($values[$keyflag]) ? $values[$keyflag] : $values['sort'];
6129 $skus[$key] = array(
6130 'meta_id' => $rows['meta_id'],
6131 'code' => $values['code'],
6132 'name' => $values['name'],
6133 'cprice' => $values['cprice'],
6134 'price' => $values['price'],
6135 'unit' => $values['unit'],
6136 'stocknum' => $values['stocknum'],
6137 'stock' => $values['stock'],
6138 'gp' => $values['gp'],
6139 'sort' => $values['sort'],
6140 'advance' => isset($values['advance']) ? $values['advance'] : ''
6141 );
6142 }
6143 $skus = apply_filters( 'usces_filter_get_skus', $skus, $post_id, $keyflag );
6144 ksort($skus);
6145
6146 return $skus;
6147 }
6148
6149 function is_item( $post ) {
6150
6151 if( $post->post_mime_type == 'item' )
6152 return true;
6153 else
6154 return false;
6155 }
6156
6157 function getItemIds( $end_type ) {
6158 global $wpdb;
6159 if( 'front' == $end_type )
6160 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item');
6161 if( 'back' == $end_type )
6162 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
6163 $ids = $wpdb->get_col( $query );
6164 if( empty($ids) ) $ids = array();
6165 return $ids;
6166 }
6167
6168 function getNotItemIds() {
6169 global $wpdb;
6170 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item');
6171 $ids = $wpdb->get_col( $query );
6172 if( empty($ids) ) $ids = array();
6173 return $ids;
6174 }
6175
6176 function getPaymentMethod( $name ) {
6177 $res = array();
6178 $payments = $this->options['payment_method'];
6179 foreach ( (array)$payments as $payment ) {
6180 if($name = $payment['name']) {
6181 $res = $payment;
6182 break;
6183 }
6184 }
6185 return $res;
6186 }
6187
6188 function order_processing( $results = array() ) {
6189 do_action('usces_pre_reg_orderdata');
6190 //db(function.php)
6191 //20110203ysk start
6192 $res = usces_check_acting_return_duplicate( $results );
6193 if($res != NULL) {
6194 usces_log('order processing duplicate : acting='.$_REQUEST['acting'].', order_id='.$res, 'acting_transaction.log');
6195 return 'ordercompletion';
6196 }
6197 if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) {
6198 usces_log($_REQUEST['acting'].' transaction : '.$_REQUEST['gid'], 'acting_transaction.log');//OK
6199 }
6200 //20110203ysk end
6201 //20110621ysk start 0000184
6202 if(isset($_REQUEST['acting']) && ('paypal_ec' == $_REQUEST['acting'])) {
6203 if( !usces_paypal_doecp( $results ) )
6204 return 'error';
6205 }
6206 //20110621ysk end
6207 $order_id = usces_reg_orderdata( $results );
6208 do_action('usces_post_reg_orderdata', $order_id, $results);
6209
6210 if ( $order_id ) {
6211 //mail(function.php)
6212 $mail_res = usces_send_ordermail( $order_id );
6213 return 'ordercompletion';
6214
6215 } else {
6216 return 'error';
6217 }
6218
6219 }
6220
6221 function acting_processing($acting_flg, $query) {
6222 global $wpdb;
6223 $entry = $this->cart->get_entry();
6224 $delim = apply_filters( 'usces_filter_delim', $this->delim );
6225 $acting_flg = trim($acting_flg);
6226 //$usces_entries = $this->cart->get_entry();
6227
6228 if( empty($acting_flg) ) return 'error';
6229
6230
6231 //include(USCES_PLUGIN_DIR . '/settlement/' . $acting_flg);
6232 if($acting_flg == 'paypal.php'){
6233 // if( !file_exists($this->options['settlement_path'] . $acting_flg) )
6234 // return 'error';
6235 //
6236 // require_once($this->options['settlement_path'] . "paypal.php");
6237 // paypal_submit();
6238
6239 }else if($acting_flg == 'epsilon.php'){
6240 if( !file_exists($this->options['settlement_path'] . $acting_flg) )
6241 return 'error';
6242
6243 if ( $this->use_ssl ) {
6244 $redirect = str_replace('http://', 'https://', USCES_CART_URL);
6245 }else{
6246 $redirect = USCES_CART_URL;
6247 }
6248 usces_log('epsilon card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6249 $query .= '&settlement=epsilon&redirect_url=' . urlencode($redirect);
6250 $query = $delim . ltrim($query, '&');
6251 header("location: " . $redirect . $query);
6252 exit;
6253
6254 }else if($acting_flg == 'acting_zeus_card' && 2 == $this->options['acting_settings']['zeus']['connection'] ){
6255 if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] ){
6256 if( !isset($_REQUEST['PaRes'])){
6257
6258 usces_log('zeus card 3dsecure entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6259 usces_zeus_3dsecure_enrol();
6260
6261 }else{
6262
6263 usces_log('zeus card 3dsecure : auth', 'acting_transaction.log');
6264 usces_zeus_3dsecure_auth();
6265 }
6266 }else{
6267 usces_log('zeus card no3d entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6268 $res = usces_zeus_secure_payreq();
6269 return $res;
6270 }
6271 }else if($acting_flg == 'acting_zeus_card' && 1 == $this->options['acting_settings']['zeus']['connection'] ){
6272
6273 $acting_opts = $this->options['acting_settings']['zeus'];
6274 $interface = parse_url($acting_opts['card_url']);
6275
6276 usces_log('zeus card securelink entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6277
6278 $vars = 'send=mall';
6279 $vars .= '&clientip=' . $acting_opts['clientip'];
6280 $vars .= '&cardnumber=' . $_POST['cardnumber'];
6281 if( 1 == $this->options['acting_settings']['zeus']['security'] ){
6282 $vars .= '&seccode=' . $_POST['securecode'];
6283 }
6284 $vars .= '&expyy=' . substr($_POST['expyy'], 2);
6285 $vars .= '&expmm=' . $_POST['expmm'];
6286 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
6287 $vars .= '&email=' . $_POST['email'];
6288 $vars .= '&sendid=' . $_POST['sendid'];
6289 $vars .= '&username=' . $_POST['username'];
6290 $vars .= '&money=' . $_POST['money'];
6291 $vars .= '&sendpoint=' . $_POST['sendpoint'];
6292 $vars .= '&printord=' . $_POST['printord'];
6293 $vars .= '&return_value=yes';
6294 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
6295 $vars .= '&div=' . $_POST['div'];
6296 }
6297
6298 //usces_log('zeus card *****vars : '.print_r($vars, true), 'acting_transaction.log');
6299
6300 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
6301 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
6302 //$header .= "Host: usctest.securesites.com\r\n";
6303 $header .= "User-Agent: PHP Script\r\n";
6304 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6305 $header .= "Content-Length: " . strlen($vars) . "\r\n";
6306 $header .= "Connection: close\r\n\r\n";
6307 $header .= $vars;
6308 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6309
6310 if ($fp){
6311 fwrite($fp, $header);
6312 while ( !feof($fp) ) {
6313 $scr = fgets($fp, 1024);
6314 $page .= $scr;
6315 }
6316 fclose($fp);
6317
6318 //usces_log('zeus card *****2 : '.print_r($page, true), 'acting_transaction.log');
6319 if( false !== strpos( $page, 'Success_order') ){
6320 usces_auth_order_acting_data($_POST['sendpoint']);
6321 usces_log('zeus card : Success_order ', 'acting_transaction.log');
6322 $ordd = usces_get_order_number( $page );
6323 //20120904ysk start 0000541
6324 if ( !isset($_POST['cbrand']) || (isset($_POST['howpay']) && 1 == $_POST['howpay']) ) {
6325 $args = '';
6326 } else {
6327 $div = 'div_'.$_POST['cbrand'];
6328 $args = '&cbrand='.$_POST['cbrand'].'&howpay='.$_POST['howpay'].'&'.$div.'='.$_POST[$div];
6329 }
6330 $args .= '&order_number='.$ordd.'&wctid='.$_POST['sendpoint'];
6331 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=1'.$args);
6332 //20120904ysk end
6333 exit;
6334 }else{
6335 $err_code = usces_get_err_code( $page );
6336 usces_log('zeus card : Certification Error : '.$err_code, 'acting_transaction.log');
6337 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0&err_code='.substr( $err_code, -3 ) );
6338 exit;
6339 }
6340 }else{
6341 usces_log('zeus card : Socket Error', 'acting_transaction.log');
6342 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
6343 }
6344 exit;
6345
6346 }else if($acting_flg == 'acting_zeus_conv'){
6347
6348 $acting_opts = $this->options['acting_settings']['zeus'];
6349 $interface = parse_url($acting_opts['conv_url']);
6350
6351 $vars .= 'clientip=' . $acting_opts['clientip_conv'];
6352 $vars .= '&act=' . $_POST['act'];
6353 $vars .= '&money=' . $_POST['money'];
6354 $vars .= '&username=' . mb_convert_encoding($_POST['username'], 'SJIS', 'UTF-8');
6355 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
6356 $vars .= '&email=' . $_POST['email'];
6357 $vars .= '&pay_cvs=' . $_POST['pay_cvs'];
6358 $vars .= '&sendid=' . $_POST['sendid'];
6359 $vars .= '&sendpoint=' . $_POST['sendpoint'];
6360 if( isset($acting_opts['conv_ope']) && 'test' == $acting_opts['conv_ope'] ) {
6361 $vars .= '&testid=' . $acting_opts['testid_conv'];
6362 $vars .= '&test_type=' . $acting_opts['test_type_conv'];
6363 }
6364
6365 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
6366 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
6367 $header .= "User-Agent: PHP Script\r\n";
6368 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6369 $header .= "Content-Length: " . strlen($vars) . "\r\n";
6370 $header .= "Connection: close\r\n\r\n";
6371 $header .= $vars;
6372 //usces_log('zeus conv header : '.print_r($header, true), 'acting_transaction.log');
6373 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6374
6375 if ($fp){
6376 fwrite($fp, $header);
6377 while ( !feof($fp) ) {
6378 $scr = fgets($fp, 1024);
6379 $page .= $scr;
6380 if( false !== strpos( $scr, 'order_no') )
6381 $qstr .= trim($scr) . '&';
6382 if( false !== strpos( $scr, 'pay_no1') )
6383 $qstr .= trim($scr) . '&';
6384 if( false !== strpos( $scr, 'pay_no2') )
6385 $qstr .= trim($scr) . '&';
6386 if( false !== strpos( $scr, 'pay_limit') )
6387 $qstr .= trim($scr) . '&';
6388 if( false !== strpos( $scr, 'pay_url') )
6389 $qstr .= trim($scr) . '&';
6390 if( false !== strpos( $scr, 'error_code') )
6391 $qstr .= trim($scr) . '&';
6392 if( false !== strpos( $scr, 'sendpoint') )
6393 $qstr .= trim($scr) . '&';
6394 }
6395 $qstr .= 'pay_cvs=' . $_POST['pay_cvs'].'&wctid='.$_POST['sendpoint'];
6396 fclose($fp);
6397 //usces_log('zeus page : '.$page, 'acting_transaction.log');
6398
6399 if( false !== strpos( $page, 'Success_order') ){
6400 usces_log('zeus conv entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6401 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=1&' . $qstr);
6402 exit;
6403 }else{
6404 usces_log('zeus data NG : '.$page, 'acting_transaction.log');
6405 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
6406 exit;
6407 }
6408 }else{
6409 usces_log('zeus : sockopen NG', 'acting_transaction.log');
6410 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
6411 }
6412 exit;
6413
6414 //20110208ysk start
6415 }else if($acting_flg == 'acting_paypal_ec') {
6416 $acting_opts = $this->options['acting_settings']['paypal'];
6417 $currency_code = $this->get_currency_code();
6418 $addroverride = '1';
6419 if( isset( $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) ) {
6420 if( 'US' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] or 'CA' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) $addroverride = '0';
6421 } else {
6422 $addroverride = '0';
6423 }
6424
6425 $nvpstr = $query;
6426 $nvpstr .= '&SESSION_ID='.$currency_code;
6427 $nvpstr .= '&CURRENCYCODE='.$currency_code;
6428 $nvpstr .= '&ADDROVERRIDE='.$addroverride;
6429 $nvpstr .= '&PAYMENTACTION=' . apply_filters('usces_filter_paypal_ec_paymentaction', 'Sale');
6430
6431 //The returnURL is the location where buyers return to when a payment has been succesfully authorized.
6432 $nvpstr .= '&RETURNURL='.urlencode(USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=1');
6433
6434 //The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow
6435 $nvpstr .= '&CANCELURL='.apply_filters( 'usces_filter_paypal_ec_cancelurl', urlencode(USCES_CART_URL.$delim.'confirm=1'), $query );
6436
6437 $nvpstr .= '&NOTIFYURL='.urlencode(USCES_PAYPAL_NOTIFY_URL);
6438
6439 $this->paypal->setMethod('SetExpressCheckout');
6440 $this->paypal->setData($nvpstr);
6441 $res = $this->paypal->doExpressCheckout();
6442 $resArray = $this->paypal->getResponse();
6443 $ack = strtoupper($resArray["ACK"]);
6444 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
6445 $token = urldecode($resArray["TOKEN"]);
6446 $payPalURL = $acting_opts['paypal_url'].'?cmd=_express-checkout&token='.$token.'&useraction=commit';
6447 header("Location: ".$payPalURL);
6448
6449 } else {
6450 //Display a user friendly Error on the page using any of the following error information returned by PayPal
6451 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
6452 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
6453 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
6454 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
6455 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');
6456 header("Location: ".USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=0');
6457 }
6458 exit;
6459 //20110208ysk end
6460 //20121030ysk start
6461 } elseif( $acting_flg == 'acting_telecom_edy' ) {
6462 $table_meta_name = $wpdb->prefix."usces_order_meta";
6463 $value = array();
6464 $value['usces_cart'] = $_SESSION['usces_cart'];
6465 $value['usces_entry'] = $_SESSION['usces_entry'];
6466 $value['usces_member'] = $_SESSION['usces_member'];
6467 $mvalue = serialize( $value );
6468 $mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue );
6469 $res = $wpdb->query( $mquery );
6470
6471 unset( $_SESSION['usces_cart'] );
6472 unset( $_SESSION['usces_entry'] );
6473
6474 $acting_opts = $this->options['acting_settings']['telecom'];
6475 header( "location: ".$acting_opts['send_url_edy'].'?acting=telecom_edy'.$query );
6476 exit;
6477 //20121030ysk end
6478 //20121206ysk start
6479 } else if( $acting_flg == 'acting_digitalcheck_card' ) {
6480 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6481 $interface = parse_url($acting_opts['send_url_user_id']);
6482 $kakutei = ( empty($acting_opts['card_kakutei']) ) ? '0' : $acting_opts['card_kakutei'];
6483
6484 $vars = 'IP='.$acting_opts['card_ip'];
6485 $vars .= '&PASS='.$acting_opts['card_pass'];
6486 $vars .= '&IP_USER_ID='.$_POST['IP_USER_ID'];
6487 $vars .= '&SID='.$_POST['SID'];
6488 $vars .= '&STORE=51';
6489 $vars .= '&N1='.$_POST['N1'];
6490 $vars .= '&K1='.$_POST['K1'];
6491 $vars .= '&KAKUTEI='.$kakutei;
6492 $vars .= '&FUKA='.$acting_flg;
6493
6494 $header = "POST ".$interface['path']." HTTP/1.1\r\n";
6495 $header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
6496 $header .= "User-Agent: PHP Script\r\n";
6497 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6498 $header .= "Content-Length: ".strlen($vars)."\r\n";
6499 $header .= "Connection: close\r\n\r\n";
6500 $header .= $vars;
6501 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6502
6503 if( $fp ) {
6504 fwrite( $fp, $header );
6505 $page = '';
6506 while( !feof($fp) ) {
6507 $line = fgets( $fp, 1024 );
6508 if( strcmp($line, "\r\n") == 0 ) {
6509 $headerdone = true;
6510 } elseif( $headerdone ) {
6511 $page .= $line;
6512 }
6513 }
6514 fclose($fp);
6515 $lines = explode("\n", $page);
6516 if( false !== strpos( $lines[0], 'OK') ) {
6517 usces_log('digitalcheck card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6518 //$args = '&SID='.$lines[1];
6519 $args = '&SID='.$_POST['SID'].'&FUKA='.$acting_flg;
6520 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=1'.$args );
6521 } else {
6522 usces_log('digitalcheck card : Certification Error : '.$page, 'acting_transaction.log');
6523 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6524 }
6525 } else {
6526 usces_log('digitalcheck card : Socket Error', 'acting_transaction.log');
6527 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6528 }
6529 exit;
6530 } else if( $acting_flg == 'acting_digitalcheck_conv' ) {
6531 if( isset($_REQUEST['STORE']) and '99' != $_REQUEST['STORE'] ) {
6532 $res = $this->order_processing();
6533 if( 'ordercompletion' == $res ) {
6534 $table_meta_name = $wpdb->prefix."usces_order_meta";
6535 $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] );
6536 $order_id = $wpdb->get_var($mquery);
6537 if( $order_id ) {
6538 $data = array( "settltment_status" => __("Failure",'usces'), "settltment_errmsg" => __("Settlement was not completed.",'usces') );
6539 $this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
6540 }
6541 $this->cart->crear_cart();
6542 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6543 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6544 exit;
6545 } else {
6546 usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
6547 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=0' );
6548 }
6549 } else {
6550 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6551 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6552 exit;
6553 }
6554 //20121206ysk end
6555 //20140206ysk start
6556 } else if( $acting_flg == 'acting_veritrans_card' or $acting_flg == 'acting_veritrans_conv' ) {
6557 $acting_opts = $this->options['acting_settings']['veritrans'];
6558 $acting = substr( $acting_flg, 7 );
6559 $dummy_payment_flag = ( 'public' == $acting_opts['ope'] ) ? '0' : '1';
6560 $order_id = isset( $_POST['ORDER_ID'] ) ? $_POST['ORDER_ID'] : '';
6561 $url = parse_url( $acting_opts['regist_url'] );
6562 $path = empty($url['path']) ? '/' : $url['path'];
6563
6564 $postdata = $query;
6565 if( 'acting_veritrans_card' == $acting_flg ) {
6566 $card_capture_flag = ( 'capture' == $acting_opts['card_capture_flag'] ) ? '1' : '0';
6567 $postdata .= '&CARD_CAPTURE_FLAG='.$card_capture_flag;
6568 }
6569 if( 'acting_veritrans_conv' == $acting_flg ) {
6570 $postdata .= '&NAME1='.urlencode( mb_substr( mb_convert_kana( $entry['customer']['name1'], 'ASKV', 'UTF-8' ), 0, 10 ) );
6571 $postdata .= '&NAME2='.urlencode( mb_substr( mb_convert_kana( $entry['customer']['name2'], 'ASKV', 'UTF-8' ), 0, 10 ) );
6572 if( !empty($entry['customer']['name3']) ) {
6573 $kana1 = mb_substr( mb_convert_kana( $entry['customer']['name3'], 'ASKV', 'UTF-8' ), 0, 10 );
6574 mb_regex_encoding( 'UTF-8' );
6575 if( mb_ereg("^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana1) )
6576 $postdata .= '&KANA1='.urlencode( $kana1 );
6577 }
6578 if( !empty($entry['customer']['name4']) ) {
6579 $kana2 = mb_substr( mb_convert_kana( $entry['customer']['name4'], 'ASKV', 'UTF-8' ), 0, 10 );
6580 mb_regex_encoding( 'UTF-8' );
6581 if( mb_ereg("^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana2) )
6582 $postdata .= '&KANA2='.urlencode( $kana2 );
6583 }
6584 $postdata .= '&TELEPHONE_NO='.str_replace( '-', '', $entry['customer']['tel'] );
6585 }
6586 $postdata .= '&MERCHANT_ID='.$acting_opts['merchant_id'];
6587 $postdata .= '&SESSION_ID='.session_id();
6588 $postdata .= '&FINISH_PAYMENT_RETURN_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting.'&acting_return=1&result=1' );
6589 $postdata .= '&UNFINISH_PAYMENT_RETURN_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting.'&confirm=1' );
6590 $postdata .= '&ERROR_PAYMENT_RETURN_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting.'&acting_return=0' );
6591 $postdata .= '&FINISH_PAYMENT_ACCESS_URL='.urlencode( USCES_CART_URL.$delim.'acting='.$acting );
6592 $postdata .= '&DUMMY_PAYMENT_FLAG='.$dummy_payment_flag;
6593
6594 $postlength = strlen( $postdata );
6595
6596 $request = "POST ".$path." HTTP/1.1"."\r\n";
6597 $request .= "Host: ".$url['host']."\r\n";
6598 $request .= "User-Agent: HttpRequest Powered by ".phpversion()."\r\n";
6599 $request .= "Connection: close"."\r\n";
6600 $request .= "Accept-Language: ja"."\r\n";
6601 $request .= "Content-Type: application/x-www-form-urlencoded"."\r\n";
6602 $request .= "Content-Length: ".$postlength."\r\n\r\n";
6603 $request .= $postdata;
6604
6605 $code = 0;
6606 $resBody = "";
6607 $con = @fsockopen( 'ssl://'.$url['host'], 443 );
6608
6609 if( $con ) {
6610 $ret = fwrite( $con, $request );
6611 if( $ret == strlen($request) ) {
6612 $res = $this->readResponse( $con );
6613 //usces_log( print_r($res,true), "veritrans.log" );
6614 $code = $res['Code'];
6615 $resBody = $res['Body'];
6616
6617 } else {
6618 usces_log( 'Veritrans Write NG: Sent:'.strlen($request).' Send:'.$ret, "acting_transaction.log" );
6619 }
6620 fclose( $con );
6621
6622 } else {
6623 usces_log( "Veritrans Connect NG: ".$url['host'], "acting_transaction.log" );
6624 header( "location: ".USCES_CART_URL.$delim.'acting='.$acting_flg.'&acting_return=0' );
6625 exit;
6626 }
6627
6628 // 正常終了(200 OK)が返ったか
6629 if( intval($code) == 200 ) {
6630 $merchantKey = null;
6631 $browserKey = null;
6632 $scd = null;
6633 $error_message = null;
6634
6635 // レスポンスデータからマーチャントキー、ブラウザキーを取得
6636 $bodyLine = explode( "\n", $resBody );
6637 foreach( $bodyLine as $line ) {
6638 if( preg_match( '/^MERCHANT_ENCRYPTION_KEY=(.+)/', $line, $match ) ) {
6639 $merchantKey = $match[1];
6640 } elseif( preg_match( '/^BROWSER_ENCRYPTION_KEY=(.+)/', $line, $match ) ) {
6641 $browserKey = $match[1];
6642 } elseif( preg_match('/^SCD=(.+)/', $line, $match ) ) {
6643 $scd = $match[1];
6644 } elseif( preg_match( '/^ERROR_MESSAGE=(.+)/', $line, $match ) ) {
6645 $error_message = $match[1];
6646 }
6647 }
6648
6649 // 両方取れたらOK。SCDはカードでセキュリティコードが�
6650 �力された場合のみ
6651 if( !is_null($merchantKey) && !is_null($browserKey) ) {
6652 $getdata = '?MERCHANT_ID='.$acting_opts['merchant_id'];
6653 $getdata .= '&ORDER_ID='.$order_id;
6654 $getdata .= '&BROWSER_ENCRYPTION_KEY='.urlencode($browserKey);
6655 header( "location: ".$acting_opts['payment_url'].$getdata );
6656
6657 } else {
6658 if( !is_null($error_message) )
6659 usces_log( "Veritrans AWeb:".$error_message, "acting_transaction.log" );
6660 header( "location: ".USCES_CART_URL.$delim.'acting='.$acting_flg.'&acting_return=0' );
6661 }
6662
6663 } else {
6664 usces_log( "Veritrans Response NG: ".$resBody, "acting_transaction.log" );
6665 header( "location: ".USCES_CART_URL.$delim.'acting='.$acting_flg.'&acting_return=0' );
6666 }
6667 exit;
6668 //20140206ysk end
6669 }
6670 do_action('usces_action_acting_processing', $acting_flg, $query);
6671 }
6672
6673 private function readResponse( $fp ) {
6674 $res = array( 'Status'=>'', 'Version'=>'', 'Code'=>0, 'Message'=>'', 'Headers'=>array(), 'Body'=>'' );
6675
6676 // HTTPステータスの読み込み
6677 $line = $this->readLine( $fp );
6678 if( preg_match( '/^(HTTP\/1\.[0-9x]+)\s+([0-9]+)\s+(.+)/i', $line, $match ) == 0 ) {
6679 return $res;
6680 }
6681 $res['Status'] = $line;
6682 $res['Version'] = $match[1];
6683 $res['Code'] = $match[2];
6684 $res['Message'] = $match[3];
6685
6686 // レスポンスヘッダの読み込み
6687 while( !feof($fp) ) {
6688 $line = $this->readLine( $fp );
6689 if( $line != '' ) {
6690 list( $hname, $hvalue ) = explode( ':', $line, 2 );
6691 $res['Headers'][strtolower($hname)] = ltrim($hvalue);
6692 } else {
6693 break;
6694 }
6695 }
6696 // レスポンスデータの読み込み
6697 while( !feof($fp) ) {
6698 $data = $this->readLine( $fp )."\n";
6699 if( '' == $data ) {
6700 break;
6701 }
6702 $res['Body'] .= $data;
6703 }
6704 return $res;
6705 }
6706
6707 private function readLine( $fp ) {
6708 if( !$fp ) {
6709 return '';
6710 }
6711 // レスポンスデータを受信
6712 $line = null;
6713 while( !feof($fp) ) {
6714 $line .= @fgets( $fp, 4096 );
6715 if( substr($line, -1) == "\n" ) {
6716 return rtrim( $line, "\r\n" );
6717 }
6718 }
6719 return $line;
6720 }
6721
6722 function inquiry_processing() {
6723
6724 $mail_res = usces_send_inquirymail();
6725
6726 if ( $mail_res )
6727 return 'inquiry_comp';
6728 else
6729 return 'inquiry_error';
6730 }
6731
6732 function lastprocessing() {
6733
6734 if ( $this->page == 'ordercompletion' )
6735 $this->cart->crear_cart();
6736
6737 do_action( 'usces_action_lastprocessing' );
6738
6739 unset($_SESSION['usces_singleitem']);
6740
6741 }
6742
6743 function is_item_zaiko( $post_id, $sku ){
6744 $status_num = (int)$this->getItemZaikoStatusId($post_id, $sku);
6745 $zaiko_num = $this->getItemZaikoNum($post_id, $sku);
6746
6747 if( false !== $zaiko_num
6748 && ( 0 < (int)$zaiko_num || WCUtils::is_blank($zaiko_num) )
6749 && false !== $status_num
6750 && 2 > $status_num
6751 ){
6752 return true;
6753 }else{
6754 return false;
6755 }
6756 }
6757
6758 // function for the cart ***********************************************************
6759 function get_total_price( $cart = array() ) {
6760 if( empty($cart) )
6761 $cart = $this->cart->get_cart();
6762
6763 $total_price = 0;
6764
6765 if( !empty($cart) ) {
6766 for($i=0; $i<count($cart); $i++) {
6767 $quantity = $cart[$i]['quantity'];
6768 $skuPrice = $cart[$i]['price'];
6769
6770 $total_price += ($skuPrice * $quantity);
6771 }
6772 }
6773 return apply_filters( 'usces_filter_get_total_price', $total_price, $cart);
6774 }
6775
6776 function get_total_quantity( $cart = array() ) {
6777 if( empty($cart) )
6778 $cart = $this->cart->get_cart();
6779
6780 $total_quantity = 0;
6781
6782 if( !empty($cart) ) {
6783 for($i=0; $i<count($cart); $i++) {
6784 $total_quantity += $cart[$i]['quantity'];
6785 }
6786 }
6787 return $total_quantity;
6788 }
6789
6790 function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) {
6791 if( $mem_id == '' || $this->options['membersystem_state'] == 'deactivate' || $this->options['membersystem_point'] == 'deactivate') return 0;
6792
6793 if ( empty($cart) )
6794 $cart = $this->cart->get_cart();
6795
6796 if ( empty($display_mode) )
6797 $display_mode = $this->options['display_mode'];
6798
6799 $point = 0;
6800 $total = $this->get_total_price( $cart );
6801 if ( $display_mode == 'Promotionsale' ) {
6802 if ( $this->options['campaign_privilege'] == 'discount' ) {
6803 foreach ( $cart as $rows ) {
6804 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6805 if ( !in_array($this->options['campaign_category'], $cats) ){
6806 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6807 $price = $rows['price'] * $rows['quantity'];
6808 $point += $price * $rate / 100;
6809 }
6810 }
6811 } elseif ( $this->options['campaign_privilege'] == 'point' ) {
6812 foreach ( $cart as $rows ) {
6813 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6814 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6815 $price = $rows['price'] * $rows['quantity'];
6816 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6817 if ( in_array($this->options['campaign_category'], $cats) )
6818 $point += $price * $rate / 100 * $this->options['privilege_point'];
6819 else
6820 $point += $price * $rate / 100;
6821 }
6822 }
6823 } else {
6824 foreach ( $cart as $rows ) {
6825 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6826 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6827 $price = $rows['price'] * $rows['quantity'];
6828 $point += $price * $rate / 100;
6829 }
6830 }
6831
6832 //20130425ysk start 0000699
6833 if( 0 < $point ) $point = ceil( $point );
6834
6835 $entry = $this->cart->get_entry();
6836 $use_point = isset( $entry['order']['usedpoint'] ) ? (int)$entry['order']['usedpoint'] : 0;
6837 if( 0 < $use_point ) {
6838 $point = ceil( $point - ( $point * $use_point / $total ) );
6839 if( 0 > $point )
6840 $point = 0;
6841 }
6842
6843 return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart );
6844 //20130425ysk end
6845 }
6846
6847 function get_order_discount( $display_mode = '', $cart = array() ) {
6848 if ( empty($cart) )
6849 $cart = $this->cart->get_cart();
6850
6851 if ( empty($display_mode) )
6852 $display_mode = $this->options['display_mode'];
6853
6854 $discount = 0;
6855 $total = $this->get_total_price( $cart );
6856 if ( $display_mode == 'Promotionsale' ) {
6857 if ( $this->options['campaign_privilege'] == 'discount' ){
6858 if( 0 === (int)$this->options['campaign_category'] ){
6859 $discount = $total * $this->options['privilege_discount'] / 100;
6860 }else{
6861 foreach($cart as $cart_row){
6862 if( in_category((int)$this->options['campaign_category'], $cart_row['post_id']) ){
6863 $discount += $cart_row['price'] * $cart_row['quantity'] * $this->options['privilege_discount'] / 100;
6864 }
6865 }
6866 }
6867 }else if ( $this->options['campaign_privilege'] == 'point' ){
6868 $discount = 0;
6869 }
6870 }
6871
6872 $discount = ceil($discount * -1);
6873 $discount = apply_filters('usces_order_discount', $discount, $cart);
6874 return $discount;
6875 }
6876
6877 function getShippingCharge( $pref, $cart = array(), $entry = array() ) {
6878 if( empty($cart) )
6879 $cart = $this->cart->get_cart();
6880 if( empty($entry) )
6881 $entry = $this->cart->get_entry();
6882 if( function_exists('dlseller_have_shipped') && !dlseller_have_shipped() ){
6883 $charge = 0;
6884 $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
6885 return $charge;
6886 }
6887
6888 //�
6889 �送方法ID
6890 $d_method_id = $entry['order']['delivery_method'];
6891 //�
6892 �送方法index
6893 $d_method_index = $this->get_delivery_method_index($d_method_id);
6894 //送料ID
6895 $fixed_charge_id = ( isset($this->options['delivery_method'][$d_method_index]['charge']) ) ? $this->options['delivery_method'][$d_method_index]['charge'] : -1;
6896 $individual_quant = 0;
6897 $total_quant = 0;
6898 $charges = array();
6899 $individual_charges = array();
6900 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
6901
6902 foreach ( $cart as $rows ) {
6903
6904 if( -1 == $fixed_charge_id ){
6905 //商品送料ID
6906 $s_charge_id = $this->getItemShippingCharge($rows['post_id']);
6907 //商品送料index
6908 $s_charge_index = $this->get_shipping_charge_index($s_charge_id);
6909 //20120710ysk start 0000472
6910 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6911 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6912 //20120710ysk end
6913 }else{
6914
6915 $s_charge_index = $this->get_shipping_charge_index($fixed_charge_id);
6916 //20120710ysk start 0000472
6917 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6918 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6919 //20120710ysk end
6920 }
6921
6922 if($this->getItemIndividualSCharge($rows['post_id'])){
6923 $individual_quant += $rows['quantity'];
6924 $individual_charges[] = $rows['quantity'] * $charge;
6925 }else{
6926 $charges[] = $charge;
6927 }
6928 $total_quant += $rows['quantity'];
6929 }
6930
6931 if( count($charges) > 0 ){
6932 rsort($charges);
6933 $max_charge = $charges[0];
6934 $charge = $max_charge + array_sum($individual_charges);
6935 }else{
6936 $charge = array_sum($individual_charges);
6937 }
6938
6939 $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
6940
6941 return $charge;
6942 }
6943
6944 function getCODFee($payment_name, $amount_by_cod) {
6945 global $usces_entries;
6946
6947 $payments = $this->getPayments($payment_name);
6948 if( 'COD' != $payments['settlement'] ){
6949 $fee = 0;
6950
6951 }else if( 'change' != $this->options['cod_type'] ){
6952 //$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : '';
6953 $fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : 0;
6954
6955 }else{
6956 $materials = array(
6957 'total_items_price' => $usces_entries['order']['total_items_price'],
6958 'discount' => $usces_entries['order']['discount'],
6959 'shipping_charge' => $usces_entries['order']['shipping_charge'],
6960 'cod_fee' => $usces_entries['order']['cod_fee'],
6961 );
6962 $price = $amount_by_cod + $this->getTax( $amount_by_cod, $materials );
6963 if( $price <= $this->options['cod_first_amount'] ){
6964 $fee = $this->options['cod_first_fee'];
6965
6966 }else if( isset($this->options['cod_amounts']) ){
6967 $last = count( $this->options['cod_amounts'] ) - 1;
6968 if( $price > $this->options['cod_amounts'][$last] ){
6969 $fee = $this->options['cod_end_fee'];
6970
6971 }else{
6972 $fee = 0;
6973 foreach( $this->options['cod_amounts'] as $key => $value ){
6974 if( $price <= $value ){
6975 $fee = $this->options['cod_fees'][$key];
6976 break;
6977 }
6978 }
6979 }
6980 }else{
6981 $fee = $this->options['cod_end_fee'];
6982 }
6983 }
6984 $fee = apply_filters('usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod);
6985 return $fee;
6986 }
6987
6988 function getTax( $total, $materials ) {
6989 global $usces_settings;
6990
6991 if( 'include' == $this->options['tax_mode'] )
6992 return 0;
6993
6994 if( empty($this->options['tax_rate']) )
6995 return 0;
6996
6997 extract($materials);//need( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point' )
6998
6999 if( 'products' == $this->options['tax_target'] ){
7000 $total = $total_items_price + $discount;
7001 }else{
7002 $total = $total_items_price + $discount + $shipping_charge + $cod_fee;
7003 }
7004 $total = apply_filters( 'usces_filter_getTax_total', $total, $materials);
7005
7006 $tax = $total * $this->options['tax_rate'] / 100;
7007 $cr = $this->options['system']['currency'];
7008 $decimal = $usces_settings['currency'][$cr][1];
7009 $decipad = (int)str_pad( '1', $decimal+1, '0', STR_PAD_RIGHT );
7010 switch( $this->options['tax_method'] ){
7011 case 'cutting':
7012 $tax = floor($tax*$decipad)/$decipad;
7013 break;
7014 case 'bring':
7015 $tax = ceil($tax*$decipad)/$decipad;
7016 break;
7017 case 'rounding':
7018 if( 0 < $decimal ){
7019 $tax = round($tax, (int)$decimal);
7020 }else{
7021 $tax = round($tax);
7022 }
7023 break;
7024 }
7025 return $tax;
7026 }
7027
7028 function set_cart_fees( $member, $entries ) {
7029 $carts = $this->cart->get_cart();
7030 $total_items_price = $this->get_total_price();
7031 if ( empty($this->options['postage_privilege']) || $total_items_price < $this->options['postage_privilege'] ) {
7032 $shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'] );
7033 } else {
7034 $shipping_charge = 0;
7035 }
7036 $shipping_charge = apply_filters('usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries);
7037 $payments = $this->getPayments( $entries['order']['payment_name'] );
7038 $discount = $this->get_order_discount();
7039 $use_point = $entries['order']['usedpoint'];
7040 $amount_by_cod = $total_items_price - $use_point + $discount + $shipping_charge;
7041 $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);
7042 $cod_fee = $this->getCODFee($entries['order']['payment_name'], $amount_by_cod);
7043 $cod_fee = apply_filters('usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge);
7044 $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
7045 $total_price = apply_filters('usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee);
7046 $materials = compact( 'member', 'entries', 'carts', 'total_items_price', 'shipping_charge', 'payments', 'discount', 'cod_fee', 'use_point', 'discount' );
7047 $tax = $this->getTax( $total_price, $materials );
7048 $total_full_price = $total_price + ( 'exclude' == $this->options['tax_mode'] ? $tax : 0 );
7049 $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);
7050 $get_point = $this->get_order_point( $member['ID'] );
7051 //20130425ysk start 0000699
7052 //if(0 < (int)$use_point){
7053 // $get_point = ceil( $get_point - ($get_point * $use_point / $total_items_price) );
7054 // if(0 > $get_point)
7055 // $get_point = 0;
7056 //}
7057 //20130425ysk end
7058
7059 $array = array(
7060 'total_items_price' => $total_items_price,
7061 'total_price' => $total_price,
7062 'total_full_price' => $total_full_price,
7063 'getpoint' => $get_point,
7064 'usedpoint' => $use_point,
7065 'discount' => $discount,
7066 'shipping_charge' => $shipping_charge,
7067 'cod_fee' => $cod_fee,
7068 'tax' => $tax
7069 );
7070 $this->cart->set_order_entry( $array );
7071 //$entries = $this->cart->get_entry();
7072 //var_dump($entries);
7073 }
7074
7075 function getPayments( $payment_name ) {
7076 if( '#none#' == $payment_name )
7077 return NULL;
7078
7079 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
7080 if( isset($payments[$payment_name]) )
7081 return $payments[$payment_name];
7082 return NULL;
7083 }
7084
7085 function is_maintenance() {
7086 if ( $this->options['display_mode'] == 'Maintenancemode' )
7087 return true;
7088 else
7089 return false;
7090 }
7091
7092 // function maintenance_mode() {
7093 // if ( $this->is_maintenance() && !is_user_logged_in() && (!strstr($_SERVER['REQUEST_URI'], 'wp-admin') || !strstr($_SERVER['REQUEST_URI'], 'wp-login') ) ) {
7094 // include ( TEMPLATEPATH . '/maintenance.php ');
7095 // exit;
7096 // } elseif ( isset($_GET['uscesmode']) && $_GET['uscesmode'] == 'lostpassword' ) {
7097 // $error = isset($_GET['error']) ? '?error='.$_GET['error'] : '';
7098 // include ( TEMPLATEPATH . '/member/changepassword.php ');
7099 // exit;
7100 // }
7101 // }
7102
7103 function get_member_history($mem_id) {
7104 global $wpdb;
7105 $order_table = $wpdb->prefix . "usces_order";
7106
7107 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
7108 $query = apply_filters( 'usces_filter_member_history_query', $query, $mem_id );
7109 // $query = $wpdb->prepare("SELECT ID, order_cart, order_condition, order_date, order_usedpoint, order_getpoint,
7110 // order_discount, order_shipping_charge, order_cod_fee, order_tax, order_status
7111 // FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
7112 $results = $wpdb->get_results( $query );
7113
7114 $i=0;
7115 $res = array();
7116
7117 if( is_user_logged_in() && is_admin() ){
7118
7119 foreach ( $results as $value ) {
7120
7121 $res[] = array(
7122 'ID' => $value->ID,
7123 // 'cart' => unserialize($value->order_cart),
7124 'cart' => usces_get_ordercartdata( $value->ID ),
7125 'condition' => unserialize($value->order_condition),
7126 'getpoint' => $value->order_getpoint,
7127 'usedpoint' => $value->order_usedpoint,
7128 'discount' => $value->order_discount,
7129 'shipping_charge' => $value->order_shipping_charge,
7130 'payment_name' => $value->order_payment_name,
7131 'cod_fee' => $value->order_cod_fee,
7132 'tax' => $value->order_tax,
7133 'order_status' => $value->order_status,
7134 'date' => mysql2date(__('Y/m/d'), $value->order_date),
7135 'order_date' => $value->order_date
7136 );
7137 $i++;
7138 }
7139
7140 }elseif( !is_admin() ){
7141
7142 foreach ( $results as $value ) {
7143
7144 if( strpos($value->order_status, 'cancel') === false && strpos($value->order_status, 'estimate') === false ){
7145 $res[] = array(
7146 'ID' => $value->ID,
7147 // 'cart' => unserialize($value->order_cart),
7148 'cart' => usces_get_ordercartdata( $value->ID ),
7149 'condition' => unserialize($value->order_condition),
7150 'getpoint' => $value->order_getpoint,
7151 'usedpoint' => $value->order_usedpoint,
7152 'discount' => $value->order_discount,
7153 'shipping_charge' => $value->order_shipping_charge,
7154 'payment_name' => $value->order_payment_name,
7155 'cod_fee' => $value->order_cod_fee,
7156 'tax' => $value->order_tax,
7157 'order_status' => $value->order_status,
7158 'date' => mysql2date(__('Y/m/d'), $value->order_date),
7159 'order_date' => $value->order_date
7160 );
7161 $i++;
7162 }
7163
7164 }
7165 }
7166
7167 return $res;
7168
7169 }
7170
7171 function get_post_term_ids( $post_id, $taxonomy ){
7172 global $wpdb;
7173 $query = $wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_relationships AS tr
7174 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
7175 WHERE tt.taxonomy = %s AND tr.object_id = %d", $taxonomy, $post_id);
7176 $ids = $wpdb->get_col( $query );
7177
7178 return $ids;
7179
7180 }
7181
7182 function get_tag_names($post_id) {
7183 global $wpdb;
7184 $tag = 'post_tag';
7185 $query = $wpdb->prepare("SELECT t.name FROM $wpdb->term_relationships AS tr
7186 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
7187 INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id
7188 WHERE tt.taxonomy = %s AND tr.object_id = %d", $tag, $post_id);
7189 $names = $wpdb->get_col( $query );
7190
7191 return apply_filters('usces_filter_get_tag_names', $names, $post_id);
7192
7193 }
7194
7195 function get_ID_byItemName($itemname, $status = 'publish') {
7196 global $wpdb;
7197 $meta_key = '_itemCode';
7198 $query = $wpdb->prepare("SELECT p.ID FROM $wpdb->posts AS p
7199 INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id
7200 WHERE p.post_status = %s AND pm.meta_key = %s AND meta_value = %s ", $status, $meta_key, $itemname);
7201 $id = $wpdb->get_var( $query );
7202
7203 // $wpdb->show_errors();
7204 // $wpdb->print_error();
7205
7206 return $id;
7207
7208 }
7209
7210 function uscescv( $sessid, $flag ) {
7211
7212 $chars = '';
7213 $i=0;
7214 $h=0;
7215 $usces_cookie = $this->get_cookie();
7216 if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
7217 $cid = $usces_cookie['id'];
7218 }elseif( isset($_SESSION['usces_cookieid']) && !empty($_SESSION['usces_cookieid']) ){
7219 $cid = $_SESSION['usces_cookieid'];
7220 }else{
7221 $cid = 0;
7222 }
7223 while($h<strlen($sessid)){
7224 if(0 == $i % 3){
7225 $chars .= substr($i, -1);
7226 }else{
7227 $chars .= substr($sessid, $h, 1);
7228 $h++;
7229 }
7230 $i++;
7231 }
7232 if( $flag ){
7233 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
7234 $postfix = apply_filters('usces_sessid_force', $postfix);
7235 $sessid = $chars . '_' . $postfix . '_' . $cid . '_A';
7236 }else{
7237 $sessid = $chars . '_' . apply_filters('usces_sessid_flag', 'acting') . '_' . $cid . '_A';
7238 }
7239 $sessid = urlencode(base64_encode($sessid));
7240 //usces_log('sessid2 : '.$sessid, 'acting_transaction.log');
7241
7242 return $sessid;
7243 }
7244
7245 function uscesdc( $sessid ) {
7246 // $usces_cookie = $this->get_cookie();
7247 // if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
7248 // if( isset($usces_cookie['sslid']) && !empty($usces_cookie['sslid']) ){
7249 // $cid = $usces_cookie['sslid'];
7250 // }else{
7251 // $cid = 0;
7252 // }
7253 // }else{
7254 // if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
7255 // $cid = $usces_cookie['id'];
7256 // }else{
7257 // $cid = 0;
7258 // }
7259 // }
7260 $sessid = base64_decode(urldecode($sessid));
7261 list($sess, $addr, $cookieid, $none) = explode('_', $sessid, 4);
7262 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
7263 $postfix = apply_filters('usces_sessid_force', $postfix);
7264 //usces_log('cid : '.$cid, 'acting_transaction.log');
7265 //usces_log('cookieid : '.$cookieid, 'acting_transaction.log');
7266 //usces_log('postfix : '.$postfix, 'acting_transaction.log');
7267 //usces_log('addr : '.$addr, 'acting_transaction.log');
7268 if( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) {
7269 $sessid = '';
7270 return NULL;
7271 }
7272 $chars = '';
7273 $h=0;
7274 while($h<strlen($sess)){
7275 if(0 != $h % 3){
7276 $chars .= substr($sess, $h, 1);
7277 }
7278 $h++;
7279 }
7280 $sessid = $chars;
7281
7282 return $sessid;
7283
7284 }
7285
7286 function get_visiter( $period ) {
7287 global $wpdb;
7288 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7289 $yearstr = substr($datestr, 0, 4);
7290 $monthstr = substr($datestr, 5, 2);
7291 $daystr = substr($datestr, 8, 2);
7292 if($period == 'today') {
7293 $date = $datestr;
7294 $today = $datestr;
7295 }else if($period == 'thismonth') {
7296 $date = date('Y-m-01');
7297 $today = $datestr;
7298 }else if($period == 'lastyear') {
7299 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7300 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
7301 }
7302 $table_name = $wpdb->prefix . 'usces_access';
7303
7304 $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);
7305 $res = $wpdb->get_row($query, ARRAY_A);
7306
7307 if( $res == NULL )
7308 return 0;
7309 else
7310 return $res['ct1']+$res['ct2'];
7311 }
7312
7313 function get_fvisiter( $period ) {
7314 global $wpdb;
7315 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7316 $yearstr = substr($datestr, 0, 4);
7317 $monthstr = substr($datestr, 5, 2);
7318 $daystr = substr($datestr, 8, 2);
7319 if($period == 'today') {
7320 $date = $datestr;
7321 $today = $datestr;
7322 }else if($period == 'thismonth') {
7323 $date = date('Y-m-01');
7324 $today = $datestr;
7325 }else if($period == 'lastyear') {
7326 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7327 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
7328 }
7329 $table_name = $wpdb->prefix . 'usces_access';
7330
7331 $query = $wpdb->prepare("SELECT SUM(acc_num2) AS ct FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today);
7332 $res = $wpdb->get_var($query);
7333
7334 if( $res == NULL )
7335 return 0;
7336 else
7337 return $res;
7338 }
7339
7340 function get_order_num( $period ) {
7341 global $wpdb;
7342 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7343 $yearstr = substr($datestr, 0, 4);
7344 $monthstr = substr($datestr, 5, 2);
7345 $daystr = substr($datestr, 8, 2);
7346 if($period == 'today') {
7347 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
7348 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7349 }else if($period == 'thismonth') {
7350 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
7351 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7352 }else if($period == 'lastyear') {
7353 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7354 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
7355 }
7356 $table_name = $wpdb->prefix . 'usces_order';
7357
7358 $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');
7359 $res = $wpdb->get_var($query);
7360
7361 if( $res == NULL )
7362 return 0;
7363 else
7364 return $res;
7365 }
7366
7367 function get_order_amount( $period ) {
7368 global $wpdb;
7369 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7370 $yearstr = substr($datestr, 0, 4);
7371 $monthstr = substr($datestr, 5, 2);
7372 $daystr = substr($datestr, 8, 2);
7373 if($period == 'today') {
7374 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
7375 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7376 }else if($period == 'thismonth') {
7377 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
7378 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
7379 }else if($period == 'lastyear') {
7380 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
7381 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
7382 }
7383 $table_name = $wpdb->prefix . 'usces_order';
7384
7385 $query = $wpdb->prepare("SELECT
7386 SUM(order_item_total_price) AS price,
7387 SUM(order_usedpoint) AS point,
7388 SUM(order_discount) AS discount,
7389 SUM(order_shipping_charge) AS shipping,
7390 SUM(order_cod_fee) AS cod,
7391 SUM(order_tax) AS tax
7392 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');
7393 $res = $wpdb->get_row($query, ARRAY_A);
7394
7395 if( $res == NULL )
7396 return 0;
7397 else
7398 return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax'];
7399 }
7400
7401 function is_status($need, $str){
7402 $array = explode(',', $str);
7403 return in_array($need, $array);
7404 }
7405
7406 function make_status( $taio='', $receipt='', $admin='' ){
7407 $str = '';
7408 if($taio != '' && $taio != '#none#')
7409 $str .= $taio . ',';
7410 if($receipt != '' && $receipt != '#none#')
7411 $str .= $receipt . ',';
7412 if($admin != '' && $admin != '#none#')
7413 $str .= $admin . ',';
7414 return $str;
7415 }
7416
7417 function get_memberid_by_email($email){
7418 global $wpdb;
7419 $table_name = $wpdb->prefix . "usces_member";
7420 $query = $wpdb->prepare("SELECT ID FROM $table_name WHERE mem_email = %s", $email);
7421 $res = $wpdb->get_var($query);
7422 return $res;
7423 }
7424
7425 function get_condition(){
7426 //20120807ysk start 0000544
7427 $order_conditions = array(
7428 'display_mode' => $this->options['display_mode'],
7429 'campaign_privilege' => $this->options['campaign_privilege'],
7430 'campaign_category' => $this->options['campaign_category'],
7431 'privilege_point' => $this->options['privilege_point'],
7432 'privilege_discount' => $this->options['privilege_discount'],
7433 'tax_mode' => $this->options['tax_mode'],
7434 'tax_target' => $this->options['tax_target'],
7435 'tax_rate' => $this->options['tax_rate'],
7436 'tax_method' => $this->options['tax_method'],
7437 'membersystem_state' => $this->options['membersystem_state'],
7438 'membersystem_point' => $this->options['membersystem_point'],
7439 );
7440 return $order_conditions;
7441 //20120807ysk end
7442 }
7443
7444 function get_bestseller_ids( $days = "" ){
7445 global $wpdb;
7446 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
7447 $yearstr = substr($datestr, 0, 4);
7448 $monthstr = substr($datestr, 5, 2);
7449 $daystr = substr($datestr, 8, 2);
7450 $res = array();
7451 $order_table_name = $wpdb->prefix . "usces_order";
7452 $where = "";
7453 if( empty($days) ){
7454 $days = 30;
7455 }
7456 $order_date = date('Y-m-d H:i:s', mktime(0, 0, 0, (int)$monthstr, ((int)$daystr-$days), (int)$yearstr));
7457 $where = " WHERE order_date >= '{$order_date}'";
7458 $query = "SELECT order_cart FROM {$order_table_name}" . $where;
7459 $dbres = $wpdb->get_col($query);
7460 if(!$dbres) return false;
7461
7462 foreach((array)$dbres as $carts){
7463 $rows = unserialize($carts);
7464 foreach((array)$rows as $carts){
7465 if( 'publish' != get_post_status($carts['post_id']) )
7466 continue;
7467
7468 $id = $carts['post_id'];
7469 $qu = $carts['quantity'];
7470 if(array_key_exists($id, $res)){
7471 $res[$id] = $res[$id] + $qu;
7472 }else{
7473 $res[$id] = $qu;
7474 }
7475 }
7476 }
7477 arsort($res);
7478 $results = array_keys($res);
7479 return $results;
7480 }
7481
7482 function get_items_num(){
7483 global $wpdb;
7484 $query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM {$wpdb->posts}
7485 WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
7486 'item', 'post', 'trush');
7487 $res = $wpdb->get_var($query);
7488
7489 return $res;
7490 }
7491
7492 function is_gptekiyo( $post_id, $sku, $quant ) {
7493 $skus = $this->get_skus( $post_id, 'code' );
7494 if( !isset($skus[$sku]['gp']) || !$skus[$sku]['gp'] ) return false;
7495
7496 $GpN1 = $this->getItemGpNum1($post_id);
7497 $GpN2 = $this->getItemGpNum2($post_id);
7498 $GpN3 = $this->getItemGpNum3($post_id);
7499
7500 if( empty($GpN1) ) {
7501
7502 return false;
7503
7504 }else if( !empty($GpN1) && empty($GpN2) ) {
7505
7506 if( $quant >= $GpN1 ) {
7507 return true;
7508 }else{
7509 return false;
7510 }
7511
7512 }else if( !empty($GpN1) && !empty($GpN2) && empty($GpN3) ) {
7513
7514 if( $quant >= $GpN2 ) {
7515 return true;
7516 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
7517 return true;
7518 }else{
7519 return false;
7520 }
7521
7522 }else if( !empty($GpN1) && !empty($GpN2) && !empty($GpN3) ) {
7523
7524 if( $quant >= $GpN3 ) {
7525 return true;
7526 }else if( $quant >= $GpN2 && $quant < $GpN3 ) {
7527 return true;
7528 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
7529 return true;
7530 }else{
7531 return false;
7532 }
7533 }
7534 }
7535
7536 function get_available_delivery_method() {
7537 if($this->cart->num_row() > 0) {
7538 $cart = $this->cart->get_cart();
7539 $before_deli = array();
7540 $intersect = array();
7541 $integration = array();
7542 $temp = array();
7543 $in = 0;
7544 foreach($cart as $key => $row){
7545 $deli = $this->getItemDeliveryMethod($row['post_id']);
7546 //usces_p($deli);
7547 if( empty($deli))
7548 continue;
7549
7550 //usces_log('deli : '.print_r($deli, true), 'acting_transaction.log');
7551 if( 0 === $in ){
7552 $intersect = $deli;
7553 }
7554 $intersect = array_intersect($deli, $intersect);
7555 $before_deli = $deli;
7556 foreach($deli as $value){
7557 $integration[] = $value;
7558 }
7559 $in++;
7560 }
7561 $integration = array_unique($integration);
7562 foreach($integration as $id){
7563 $index = $this->get_delivery_method_index($id);
7564 $temp[$index] = $id;
7565 }
7566 ksort($temp);
7567 //20120820ysk start 0000546
7568 //$force = array($temp[0]);
7569 $force = array(array_shift($temp));
7570 //20120820ysk end
7571
7572 if( empty($intersect) ){
7573 return $force;
7574 }else{
7575 return $intersect;
7576 }
7577 }
7578 return array();
7579 }
7580
7581 function get_delivery_method_index($id) {
7582 $index = false;
7583 for($i=0; $i<count($this->options['delivery_method']); $i++){
7584 if( $this->options['delivery_method'][$i]['id'] === (int)$id ){
7585 $index = $i;
7586 }
7587 }
7588 if($index === false)
7589 return -1;
7590 else
7591 return $index;
7592 }
7593
7594 function get_shipping_charge_index($id) {
7595 $index = false;
7596 for($i=0; $i<count($this->options['shipping_charge']); $i++){
7597 //20120710ysk start 0000472
7598 //if( $this->options['shipping_charge'][$i]['id'] === $id ){
7599 if( (int)$this->options['shipping_charge'][$i]['id'] == (int)$id ){
7600 //20120710ysk end
7601 $index = $i;
7602 }
7603 }
7604 if($index === false)
7605 return -1;
7606 else
7607 return $index;
7608 }
7609
7610 function get_initial_data($xml){
7611 $buf = file_get_contents($xml);
7612 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);
7613 return $match;
7614 }
7615
7616 function getCurrencySymbol(){
7617 global $usces_settings;
7618 $cr = $this->options['system']['currency'];
7619 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7620 return $symbol;
7621 }
7622
7623 function getCartItemName($post_id, $sku){
7624 $name_arr = array();
7625 $name_str = '';
7626
7627 foreach($this->options['indi_item_name'] as $key => $value){
7628 if($value){
7629 $pos = (int)$this->options['pos_item_name'][$key];
7630 $ind = ($pos === 0) ? 'A' : $pos;
7631 switch($key){
7632 case 'item_name':
7633 $name_arr[$ind][$key] = $this->getItemName($post_id);
7634 break;
7635 case 'item_code':
7636 $name_arr[$ind][$key] = $this->getItemCode($post_id);
7637 break;
7638 case 'sku_name':
7639 $name_arr[$ind][$key] = $this->getItemSkuDisp($post_id, $sku);
7640 break;
7641 case 'sku_code':
7642 $name_arr[$ind][$key] = $sku;
7643 break;
7644 }
7645 }
7646
7647 }
7648 ksort($name_arr);
7649 foreach($name_arr as $vals){
7650 foreach($vals as $key => $value){
7651
7652 $name_str .= $value . ' ';
7653 }
7654 }
7655
7656 $name_str = apply_filters('usces_admin_order_item_name_filter', $name_str, $post_id, $sku);
7657
7658 return trim($name_str);
7659 }
7660
7661 function getCartItemName_byOrder($cart_row){
7662 $name_arr = array();
7663 $name_str = '';
7664
7665 foreach($this->options['indi_item_name'] as $key => $value){
7666 if($value){
7667 $pos = (int)$this->options['pos_item_name'][$key];
7668 $ind = ($pos === 0) ? 'A' : $pos;
7669 switch($key){
7670 case 'item_name':
7671 $name_arr[$ind][$key] = $cart_row['item_name'];
7672 break;
7673 case 'item_code':
7674 $name_arr[$ind][$key] = $cart_row['item_code'];
7675 break;
7676 case 'sku_name':
7677 $name_arr[$ind][$key] = $cart_row['sku_name'];
7678 break;
7679 case 'sku_code':
7680 $name_arr[$ind][$key] = $cart_row['sku_code'];
7681 break;
7682 }
7683 }
7684
7685 }
7686 ksort($name_arr);
7687 foreach($name_arr as $vals){
7688 foreach($vals as $key => $value){
7689
7690 $name_str .= $value . ' ';
7691 }
7692 }
7693
7694 $name_str = apply_filters('usces_filter_item_mame_by_order', $name_str, $cart_row);
7695
7696 return trim($name_str);
7697 }
7698
7699 function set_reserve_pre_order_id(){
7700 $entry = $this->cart->get_entry();
7701 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : uniqid('');
7702 $this->cart->set_pre_order_id($id);
7703 }
7704
7705 function get_current_pre_order_id(){
7706 $entry = $this->cart->get_entry();
7707 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : NULL;
7708 return $id;
7709 }
7710
7711 function get_reserve($order_id, $key){
7712 global $wpdb;
7713 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7714 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7715 $order_id, $key);
7716 $res = $wpdb->get_var($query);
7717 return $res;
7718 }
7719
7720 //20100818ysk start
7721 //20100816ysk start
7722 //function get_order_meta($order_id, $key) {
7723 function get_order_meta_value($key, $order_id) {
7724 global $wpdb;
7725 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7726 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7727 $order_id, $key);
7728 $res = $wpdb->get_var($query);
7729 return $res;
7730 }
7731 //20100816ysk end
7732 function set_order_meta_value($key, $meta_value, $order_id) {
7733 global $wpdb;
7734
7735 //if( empty($meta_value) ) return;
7736 if( empty($order_id) ) return;
7737
7738 $table_name = $wpdb->prefix . "usces_order_meta";
7739 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s",
7740 $order_id, $key);
7741 $res = $wpdb->get_var($query);
7742 if(0 < $res) {
7743 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s",
7744 $meta_value,
7745 $order_id,
7746 $key
7747 );
7748 $res2 = $wpdb->query($query);
7749 } else {
7750 $query = $wpdb->prepare("INSERT INTO $table_name (order_id, meta_key, meta_value)
7751 VALUES(%d, %s, %s)",
7752 $order_id,
7753 $key,
7754 $meta_value
7755 );
7756 $res2 = $wpdb->query($query);
7757 }
7758 return $res2;
7759 }
7760 //20130524ysk start
7761 function del_order_meta( $key, $order_id ) {
7762 global $wpdb;
7763 $table_name = $wpdb->prefix."usces_order_meta";
7764 $query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
7765 $res = $wpdb->query( $query );
7766 return $res;
7767 }
7768 //20130524ysk end
7769 function set_session_custom_member($member_id) {
7770 unset($_SESSION['usces_member']['custom_member']);
7771 $meta = usces_has_custom_field_meta('member');
7772 if(is_array($meta)) {
7773 $keys = array_keys($meta);
7774 foreach($keys as $key) {
7775 $csmb_key = 'csmb_'.$key;
7776 $_SESSION['usces_member']['custom_member'][$key] = maybe_unserialize($this->get_member_meta_value($csmb_key, $member_id));
7777 }
7778 }
7779 }
7780
7781 function reg_custom_member($member_id) {
7782 //20130524ysk start 0000712
7783 $csmb_meta = usces_has_custom_field_meta( 'member' );
7784 if( is_array($csmb_meta) ) {
7785 foreach( $csmb_meta as $key => $entry ) {
7786 if( '4' == $entry['means'] ) {
7787 $this->del_member_meta( 'csmb_'.$key, $member_id );
7788 }
7789 }
7790 }
7791 //20130524ysk end
7792 if( !empty($_POST['custom_member']) ) {
7793 foreach( $_POST['custom_member'] as $key => $value ) {
7794 $csmb_key = 'csmb_'.$key;
7795 if( is_array($value) )
7796 $value = serialize($value);
7797 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7798 if(false === $res)
7799 return false;
7800 }
7801 }elseif( isset($_POST['custom_customer']) ){
7802 foreach( $_POST['custom_customer'] as $key => $value ) {
7803 $csmb_key = 'csmb_'.$key;
7804 if( is_array($value) )
7805 $value = serialize($value);
7806 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7807 if(false === $res)
7808 return false;
7809 }
7810 }
7811 }
7812 //20100818ysk end
7813
7814 function save_order_acting_data($rand){
7815 global $wpdb;
7816 $data = serialize(array( 'cart' => $this->cart->get_cart(), 'entry' => $this->cart->get_entry() ));
7817 $table_name = $wpdb->prefix . "usces_access";
7818 $query = $wpdb->prepare("INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value)
7819 VALUES(%s, %s, now(), %s, %s)",
7820 'acting_data',
7821 $this->get_uscesid(false),
7822 $rand,
7823 $data
7824 );
7825 $res = $wpdb->query($query);
7826 return $res;
7827 }
7828
7829 //20100818ysk start
7830 function set_member_meta_value($key, $meta_value, $member_id = ''){
7831 global $wpdb;
7832
7833 //if( empty($meta_value) ) return;
7834 if( WCUtils::is_blank($member_id) ) {
7835 if( !$this->is_member_logged_in() ) return;
7836 $member = $this->get_member();
7837 $member_id = $member['ID'];
7838 }
7839
7840 $table_name = $wpdb->prefix . "usces_member_meta";
7841 //$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7842 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s",
7843 $member_id, $key);
7844 $res = $wpdb->get_var($query);
7845 //if($res != NULL){
7846 if(0 < $res){
7847 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s",
7848 $meta_value,
7849 $member_id,
7850 $key
7851 );
7852 $res2 = $wpdb->query($query);
7853 }else{
7854 $query = $wpdb->prepare("INSERT INTO $table_name (member_id, meta_key, meta_value)
7855 VALUES(%d, %s, %s)",
7856 $member_id,
7857 $key,
7858 $meta_value
7859 );
7860 $res2 = $wpdb->query($query);
7861 }
7862 return $res2;
7863 }
7864 //20100818ysk end
7865
7866 function get_member_meta_value($key, $member_id){
7867 global $wpdb;
7868 $table_name = $wpdb->prefix . "usces_member_meta";
7869 $query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7870 $member_id, $key);
7871 $res = $wpdb->get_var($query);
7872 return $res;
7873 }
7874
7875 function del_member_meta($key, $member_id){
7876 global $wpdb;
7877 $table_name = $wpdb->prefix . "usces_member_meta";
7878 $query = $wpdb->prepare("DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s",
7879 $member_id, $key);
7880 $res = $wpdb->query($query);
7881 return $res;
7882 }
7883
7884 function get_member_meta($member_id){
7885 global $wpdb;
7886 $table_name = $wpdb->prefix . "usces_member_meta";
7887 $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_%');
7888 $res = $wpdb->get_results($query, ARRAY_A);
7889 return $res;
7890 }
7891
7892 function get_settle_info_field( $order_id ){
7893 global $wpdb;
7894 $fields = array();
7895 $table_name = $wpdb->prefix . "usces_order_meta";
7896 $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table_name WHERE order_id = %d AND (meta_key LIKE %s OR meta_key = %s OR meta_key = %s OR meta_key = %s OR meta_key = %s OR meta_key = %s)",
7897 $order_id, 'acting_%', 'settlement_id', 'order_number', 'res_tracking_id', 'SID', 'TransactionId');
7898 $res = $wpdb->get_results($query, ARRAY_A);
7899 if( !$res )
7900 return $fields;
7901
7902 foreach( $res as $value ){
7903 if( 'settlement_id' == $value['meta_key'] ){
7904 $meta_values = maybe_unserialize($value['meta_value']);
7905 if( is_array($meta_values) ){
7906 foreach( $meta_values as $key => $meta_value ){
7907 $fields[$key] = $meta_value;
7908 }
7909 }else{
7910 $fields['settlement_id'] = $meta_values;
7911 }
7912 }elseif( 'order_number' == $value['meta_key'] ){
7913 $fields['order_number'] = $value['meta_value'];
7914 }elseif( 'res_tracking_id' == $value['meta_key'] ){
7915 $fields['res_tracking_id'] = $value['meta_value'];
7916 }elseif( 'SID' == $value['meta_key'] ){
7917 $fields['SID'] = $value['meta_value'];
7918 }elseif( 'TransactionId' == $value['meta_key'] ){
7919 $fields['TransactionId'] = $value['meta_value'];
7920 }elseif( 'acting_' == substr($value['meta_key'], 0, 7) ){
7921 $meta_values = maybe_unserialize($value['meta_value']);
7922 if(is_array($meta_values)){
7923 foreach( $meta_values as $key => $meta_value ){
7924 $fields[$key] = $meta_value;
7925 }
7926 }
7927 }
7928 }
7929 return $fields;
7930 }
7931
7932 function get_post_custom($post_id, $orderby='meta_id', $order='ASC'){
7933 global $wpdb;
7934 $table = $wpdb->prefix . "postmeta";
7935 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7936 $post_id), ARRAY_A );
7937
7938 if ( !empty($meta_list) ) {
7939 foreach ( $meta_list as $metarow) {
7940 $mkey = $metarow['meta_key'];
7941 $mval = $metarow['meta_value'];
7942 $res[$mkey][] = $mval;
7943 }
7944 }
7945 return $res;
7946 }
7947
7948 function get_post_user_custom($post_id, $orderby='meta_id', $order='ASC'){
7949 global $wpdb;
7950 $res = array();
7951 $table = $wpdb->prefix . "postmeta";
7952 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7953 $post_id), ARRAY_A );
7954
7955 if ( !empty($meta_list) ) {
7956 foreach ( $meta_list as $metarow) {
7957 if( 0 === strpos($metarow['meta_key'], '_') )
7958 continue;
7959
7960 $mkey = $metarow['meta_key'];
7961 $mval = $metarow['meta_value'];
7962 if( array_key_exists($mkey, $res) ){
7963 $cval = $res[$mkey];
7964 $cval = (array)$cval;
7965 $cval[] = $mval;
7966 $res[$mkey] = $cval;
7967 }else{
7968 $res[$mkey] = $mval;
7969 }
7970 }
7971 }
7972 return $res;
7973 }
7974
7975 function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ){
7976 global $usces_settings;
7977 $cr = $this->options['system']['currency'];
7978 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7979 if( !$seperator_flag ){
7980 $seperator = '';
7981 }
7982 $price = number_format((double)$amount, $decimal, $point, $seperator);//0000652
7983
7984 if( $symbol_pre )
7985 $price = ( usces_is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol ) . $price;
7986
7987 if( $symbol_post )
7988 $price = $price . __($code, 'usces');
7989
7990 return $price;
7991 }
7992
7993 function get_currency_code(){
7994 global $usces_settings;
7995 $cr = $this->options['system']['currency'];
7996 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7997 return $code;
7998 }
7999
8000 //shortcode-----------------------------------------------------------------------------
8001 function sc_company_name() {
8002 return htmlspecialchars($this->options['company_name']);
8003 }
8004 function sc_zip_code() {
8005 return htmlspecialchars($this->options['zip_code']);
8006 }
8007 function sc_address1() {
8008 return htmlspecialchars($this->options['address1']);
8009 }
8010 function sc_address2() {
8011 return htmlspecialchars($this->options['address2']);
8012 }
8013 function sc_tel_number() {
8014 return htmlspecialchars($this->options['tel_number']);
8015 }
8016 function sc_fax_number() {
8017 return htmlspecialchars($this->options['fax_number']);
8018 }
8019 function sc_inquiry_mail() {
8020 return htmlspecialchars($this->options['inquiry_mail']);
8021 }
8022 function sc_payment() {
8023 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
8024 $htm = "<ul>\n";
8025 foreach ( (array)$payments as $payment ) {
8026 $htm .= "<li>" . htmlspecialchars($payment['name']) . "<br />\n";
8027 $htm .= nl2br(htmlspecialchars($payment['explanation'])) . "</li>\n";
8028 }
8029 $htm .= "</ul>\n";
8030 return $htm;
8031 }
8032 function sc_payment_title() {
8033 $payments = $this->options['payment_method'];
8034 $htm = "<ul>\n";
8035 foreach ( (array)$payments as $payment ) {
8036 $htm .= "<li>" . esc_html($payment['name']) . "</li>\n";
8037 }
8038 $htm .= "</ul>\n";
8039 return $htm;
8040 }
8041 function sc_cod_fee() {
8042 return number_format($this->options['cod_fee']);
8043 }
8044 function sc_start_point() {
8045 return number_format($this->options['start_point']);
8046 }
8047 function sc_postage_privilege() {
8048 if(empty($this->options['postage_privilege']))
8049 return;
8050 return number_format($this->options['postage_privilege']);
8051 }
8052 function sc_shipping_charge() {
8053 //20120710ysk start 0000472
8054 $entry = $this->cart->get_entry();
8055 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
8056 //20120710ysk end
8057 $arr = array();
8058 foreach ( (array)$this->options['shipping_charge'] as $charges ) {
8059 //20120710ysk start 0000472
8060 //foreach ( (array)$charges['value'] as $value ) {
8061 foreach ( (array)$charges[$country] as $value ) {
8062 //20120710ysk end
8063 $arr[] = $value;
8064 }
8065 }
8066 sort($arr);
8067 $min = $arr[0];
8068 rsort($arr);
8069 $max = $arr[0];
8070 if($min == $max){
8071 $res = number_format($min);
8072 }else{
8073 $res = number_format($min) . __(' - ', 'usces') . number_format($max);
8074 }
8075 return $res;
8076 }
8077 function sc_site_url() {
8078 return get_option('home');
8079 }
8080 function sc_button_to_cart($atts) {
8081 extract(shortcode_atts(array(
8082 'item' => '',
8083 'sku' => '',
8084 'value' => __('to the cart', 'usces'),
8085 'force' => 0,
8086 'quant' => 0,
8087 'opt' => 1,
8088 ), $atts));
8089
8090 $post_id = $this->get_ID_byItemName($item);
8091 $datas = $this->get_skus( $post_id, 'code' );
8092 $zaikonum = $datas[$sku]['stocknum'];
8093 $zaiko = $datas[$sku]['stock'];
8094 $gptekiyo = $datas[$sku]['gp'];
8095 $skuPrice = $datas[$sku]['price'];
8096 $sku_enc = urlencode($sku);
8097 $mats = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc');
8098 if( ! $this->is_item_zaiko( $post_id, $sku ) ){
8099 return '<div class="button_status">' . esc_html($this->zaiko_status[$zaiko]) . '</div>';
8100 }
8101
8102 $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n";
8103 $html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"{$zaikonum}\" />\n";
8104 $html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"{$zaiko}\" />\n";
8105 $html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"{$gptekiyo}\" />\n";
8106 $html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"{$skuPrice}\" />\n";
8107 if( 1 == $opt ){
8108 $html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' );
8109 }elseif( 2 == $opt ){
8110 $html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' );
8111 }
8112 if( $quant ){
8113 $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;}\" />";
8114 $html .= apply_filters('usces_filter_sc_itemQuant', $quant_field, $mats);
8115 }
8116 $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) . " />";
8117 $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
8118 if( $force )
8119 $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
8120 $html = apply_filters('usces_filter_single_item_inform', $html);
8121 $html .= "</form>";
8122 $html .= '<div class="error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";
8123
8124 return $html;
8125 }
8126
8127 function filter_itemPage($content){
8128 global $post;
8129 $html = '';
8130
8131 if( ($post->post_mime_type != 'item' || !is_single()) ) return $content;
8132 if( post_password_required($post) ) return $content;
8133
8134 $temp_path = apply_filters('usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php');
8135 include( $temp_path );
8136
8137 $content = apply_filters('usces_filter_itemPage', $html, $post->ID);
8138
8139 return $content;
8140 }
8141
8142 function filter_cartContent($content) {
8143 global $post;
8144 $html = '';
8145
8146 switch($this->page){
8147 case 'cart':
8148 $temp_path = apply_filters('usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php');
8149 include( $temp_path );
8150 break;
8151 case 'customer':
8152 $temp_path = apply_filters('usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php');
8153 include( $temp_path );
8154 break;
8155 case 'delivery':
8156 $temp_path = apply_filters('usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php');
8157 include( $temp_path );
8158 break;
8159 case 'confirm':
8160 $temp_path = apply_filters('usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php');
8161 include( $temp_path );
8162 break;
8163 case 'ordercompletion':
8164 $temp_path = apply_filters('usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php');
8165 include( $temp_path );
8166 break;
8167 case 'error':
8168 $temp_path = apply_filters('usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php');
8169 include( $temp_path );
8170 break;
8171 case 'maintenance':
8172 $temp_path = apply_filters('usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php');
8173 include( $temp_path );
8174 break;
8175 case 'search_item':
8176 $temp_path = apply_filters('usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php');
8177 include( $temp_path );
8178 break;
8179 case 'wp_search':
8180 if($post->post_mime_type == 'item'){
8181 $temp_path = apply_filters('usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php');
8182 include( $temp_path );
8183 }else{
8184 $html = $content;
8185 }
8186 break;
8187 default:
8188 $html = $content;
8189 }
8190
8191 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) )
8192 $html = str_replace('src="'.site_url(), 'src="'.USCES_SSL_URL_ADMIN, $html);
8193
8194 $html = apply_filters('usces_filter_cartContent', $html);
8195
8196 $content = $html;
8197
8198 remove_filter('the_title', array($this, 'filter_cartTitle'));
8199
8200 return $content;
8201 }
8202
8203 function filter_cartTitle($title) {
8204
8205 if( $title == 'Cart' || $title == __('Cart', 'usces') ){
8206 switch($this->page){
8207 case 'cart':
8208 $newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces'));
8209 break;
8210 case 'customer':
8211 $newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces'));
8212 break;
8213 case 'delivery':
8214 $newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces'));
8215 break;
8216 case 'confirm':
8217 $newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces'));
8218 break;
8219 case 'ordercompletion':
8220 $newtitle = apply_filters('usces_filter_title_ordercompletion', __('Completion', 'usces'));
8221 break;
8222 case 'error':
8223 $newtitle = apply_filters('usces_filter_title_carterror', __('Error', 'usces'));
8224 break;
8225 case 'search_item':
8226 $newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces'));
8227 break;
8228 case 'maintenance':
8229 $newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces'));
8230 break;
8231 case 'login':
8232 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
8233 break;
8234 default:
8235 $newtitle = apply_filters('usces_filter_title_cart_default', $title);
8236 }
8237 }else{
8238 $newtitle = $title;
8239 }
8240
8241 $newtitle = apply_filters('usces_filter_cartTitle', $newtitle);
8242 return $newtitle;
8243 }
8244
8245 function action_cartFilter(){
8246 add_filter('the_title', array($this, 'filter_cartTitle'),20);
8247 add_filter('the_content', array($this, 'filter_cartContent'),20);
8248 }
8249
8250 function action_search_item(){
8251 include(TEMPLATEPATH . '/page.php');
8252 exit;
8253 }
8254
8255 function filter_memberContent($content) {
8256 global $post;
8257 $html = '';
8258
8259 if($this->options['membersystem_state'] == 'activate'){
8260
8261 if( $this->is_member_logged_in() ) {
8262
8263 $member_regmode = 'editmemberform';
8264 $temp_path = apply_filters('usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php');
8265 include( $temp_path );
8266
8267 } else {
8268
8269 switch($this->page){
8270 case 'login':
8271 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
8272 include( $temp_path );
8273 break;
8274 case 'lostmemberpassword':
8275 $temp_path = apply_filters('usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php');
8276 include( $temp_path );
8277 break;
8278 case 'changepassword':
8279 $temp_path = apply_filters('usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php');
8280 include( $temp_path );
8281 break;
8282 case 'newcompletion':
8283 case 'editcompletion':
8284 case 'lostcompletion':
8285 case 'changepasscompletion':
8286 $temp_path = apply_filters('usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php');
8287 include( $temp_path );
8288 break;
8289 case 'newmemberform':
8290 $member_form_title = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
8291 $member_regmode = 'newmemberform';
8292 $temp_path = apply_filters('usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php');
8293 include( $temp_path );
8294 break;
8295 default:
8296 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
8297 include( $temp_path );
8298 }
8299
8300 }
8301 }else{
8302 $html .= "<p>".__('Member Services is not running currently.','usces')."</p>";
8303 }
8304
8305 $content = $html;
8306
8307 remove_filter('the_title', array($this, 'filter_memberTitle'));
8308
8309 return $content;
8310 }
8311
8312 function filter_memberTitle($title) {
8313
8314 if( $this->options['membersystem_state'] == 'activate' && ($title == 'Member' || $title == __('Membership', 'usces')) ){
8315 switch($this->page){
8316 case 'login':
8317 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
8318 break;
8319 case 'newmemberform':
8320 $newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
8321 break;
8322 case 'lostmemberpassword':
8323 $newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces'));
8324 break;
8325 case 'changepassword':
8326 $newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces'));
8327 break;
8328 case 'newcompletion':
8329 case 'editcompletion':
8330 case 'lostcompletion':
8331 case 'changepasscompletion':
8332 $newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Completion', 'usces'));
8333 break;
8334 case 'error':
8335 $newtitle = apply_filters('usces_filter_title_membererror', __('Error', 'usces'));
8336 break;
8337 default:
8338 $newtitle = apply_filters('usces_filter_title_member_default', $title);
8339 }
8340 }else{
8341 $newtitle = $title;
8342 }
8343
8344 $newtitle = apply_filters('usces_filter_memberTitle', $newtitle);
8345 return $newtitle;
8346 }
8347
8348 function action_memberFilter(){
8349 add_filter('the_title', array($this, 'filter_memberTitle'),20);
8350 add_filter('the_content', array($this, 'filter_memberContent'),20);
8351 }
8352
8353 function filter_usces_cart_css(){
8354 $path = get_stylesheet_directory_uri() . '/usces_cart.css';
8355 return $path;
8356 }
8357
8358 function filter_divide_item(){
8359 global $wp_query;
8360
8361
8362 if( ($this->options['divide_item'] && !is_category() && !is_search() && !is_singular() && !is_admin()) ){
8363 $ids = $this->getItemIds( 'front' );
8364 $wp_query->query_vars['post__not_in'] = $ids;
8365
8366 }
8367 if( is_admin() ){
8368 $ids = $this->getItemIds( 'back' );
8369 //$wp_query->query_vars['category__not_in'] = array(USCES_ITEM_CAT_PARENT_ID);
8370 $wp_query->query_vars['post__not_in'] = $ids;
8371 }
8372 do_action( 'usces_action_divide_item');
8373 }
8374
8375 function load_upload_template(){
8376 $post_id = $_POST['post_id'];
8377 $file = 'upload_template01.php';
8378 include(TEMPLATEPATH . '/' . $file);
8379 exit;
8380 }
8381
8382 function filter_itemimg_anchor_rel($html){
8383
8384 if( is_single() ){
8385 $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"';
8386 }else{
8387 $str = '';
8388 }
8389 return $html . $str;
8390 }
8391
8392 function filter_permalink( $link ) {
8393
8394 if(false !== strpos('?page_id=4', $link) || false !== strpos('?page_id=3', $link) || false !== strpos('usces-cart', $link) || false !== strpos('usces-member', $link) )
8395 $link = str_replace('http://', 'https://', $link);
8396
8397 return $link;
8398 }
8399
8400 function filter_cart_page_header($html){
8401 if( !empty($this->options['cart_page_data']['header']['cart']) ){
8402 $html = $this->options['cart_page_data']['header']['cart'];
8403 }
8404 return do_shortcode( stripslashes(nl2br($html)) );
8405 }
8406
8407 function filter_cart_page_footer($html){
8408 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
8409 $html = $this->options['cart_page_data']['footer']['cart'];
8410 }
8411 return do_shortcode( stripslashes(nl2br($html)) );
8412 }
8413
8414 function filter_customer_page_header($html){
8415 if( !empty($this->options['cart_page_data']['header']['customer']) ){
8416 $html = $this->options['cart_page_data']['header']['customer'];
8417 }
8418 return do_shortcode( stripslashes(nl2br($html)) );
8419 }
8420
8421 function filter_customer_page_footer($html){
8422 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
8423 $html = $this->options['cart_page_data']['footer']['customer'];
8424 }
8425 return do_shortcode( stripslashes(nl2br($html)) );
8426 }
8427
8428 function filter_delivery_page_header($html){
8429 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
8430 $html = $this->options['cart_page_data']['header']['delivery'];
8431 }
8432 return do_shortcode( stripslashes(nl2br($html)) );
8433 }
8434
8435 function filter_delivery_page_footer($html){
8436 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
8437 $html = $this->options['cart_page_data']['footer']['delivery'];
8438 }
8439 return do_shortcode( stripslashes(nl2br($html)) );
8440 }
8441
8442 function filter_confirm_page_header($html){
8443 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
8444 $html = $this->options['cart_page_data']['header']['confirm'];
8445 }
8446 return do_shortcode( stripslashes(nl2br($html)) );
8447 }
8448
8449 function filter_confirm_page_footer($html){
8450 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
8451 $html = $this->options['cart_page_data']['footer']['confirm'];
8452 }
8453 return do_shortcode( stripslashes(nl2br($html)) );
8454 }
8455
8456 function filter_cartcompletion_page_header($html){
8457 if( !empty($this->options['cart_page_data']['header']['completion']) ){
8458 $html = $this->options['cart_page_data']['header']['completion'];
8459 }
8460 return do_shortcode( stripslashes(nl2br($html)) );
8461 }
8462
8463 function filter_cartcompletion_page_footer($html){
8464 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
8465 $html = $this->options['cart_page_data']['footer']['completion'];
8466 }
8467 return do_shortcode( stripslashes(nl2br($html)) );
8468 }
8469
8470 function filter_login_page_header($html){
8471 if( !empty($this->options['member_page_data']['header']['login']) ){
8472 $html = $this->options['member_page_data']['header']['login'];
8473 }
8474 return do_shortcode( stripslashes(nl2br($html)) );
8475 }
8476
8477 function filter_login_page_footer($html){
8478 if( !empty($this->options['member_page_data']['footer']['login']) ){
8479 $html = $this->options['member_page_data']['footer']['login'];
8480 }
8481 return do_shortcode( stripslashes(nl2br($html)) );
8482 }
8483
8484 function filter_newmember_page_header($html){
8485 if( !empty($this->options['member_page_data']['header']['newmember']) ){
8486 $html = $this->options['member_page_data']['header']['newmember'];
8487 }
8488 return do_shortcode( stripslashes(nl2br($html)) );
8489 }
8490
8491 function filter_newmember_page_footer($html){
8492 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
8493 $html = $this->options['member_page_data']['footer']['newmember'];
8494 }
8495 return do_shortcode( stripslashes(nl2br($html)) );
8496 }
8497
8498 function filter_newpass_page_header($html){
8499 if( !empty($this->options['member_page_data']['header']['newpass']) ){
8500 $html = $this->options['member_page_data']['header']['newpass'];
8501 }
8502 return do_shortcode( stripslashes(nl2br($html)) );
8503 }
8504
8505 function filter_newpass_page_footer($html){
8506 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
8507 $html = $this->options['member_page_data']['footer']['newpass'];
8508 }
8509 return do_shortcode( stripslashes(nl2br($html)) );
8510 }
8511
8512 function filter_changepass_page_header($html){
8513 if( !empty($this->options['member_page_data']['header']['changepass']) ){
8514 $html = $this->options['member_page_data']['header']['changepass'];
8515 }
8516 return do_shortcode( stripslashes(nl2br($html)) );
8517 }
8518
8519 function filter_changepass_page_footer($html){
8520 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
8521 $html = $this->options['member_page_data']['footer']['changepass'];
8522 }
8523 return do_shortcode( stripslashes(nl2br($html)) );
8524 }
8525
8526 function filter_memberinfo_page_header($html){
8527 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
8528 $html = $this->options['member_page_data']['header']['memberinfo'];
8529 }
8530 return do_shortcode( stripslashes(nl2br($html)) );
8531 }
8532
8533 function filter_memberinfo_page_footer($html){
8534 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
8535 $html = $this->options['member_page_data']['footer']['memberinfo'];
8536 }
8537 return do_shortcode( stripslashes(nl2br($html)) );
8538 }
8539
8540 function filter_membercompletion_page_header($html){
8541 if( !empty($this->options['member_page_data']['header']['completion']) ){
8542 $html = $this->options['member_page_data']['header']['completion'];
8543 }
8544 return do_shortcode( stripslashes(nl2br($html)) );
8545 }
8546
8547 function filter_membercompletion_page_footer($html){
8548 if( !empty($this->options['member_page_data']['footer']['completion']) ){
8549 $html = $this->options['member_page_data']['footer']['completion'];
8550 }
8551 return do_shortcode( stripslashes(nl2br($html)) );
8552 }
8553
8554 function action_cart_page_header(){
8555 if( !empty($this->options['cart_page_data']['header']['cart']) ){
8556 $html = $this->options['cart_page_data']['header']['cart'];
8557 echo do_shortcode( stripslashes(nl2br($html)) );
8558 }
8559 }
8560
8561 function action_cart_page_footer(){
8562 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
8563 $html = $this->options['cart_page_data']['footer']['cart'];
8564 echo do_shortcode( stripslashes(nl2br($html)) );
8565 }
8566 }
8567
8568 function action_customer_page_header(){
8569 if( !empty($this->options['cart_page_data']['header']['customer']) ){
8570 $html = $this->options['cart_page_data']['header']['customer'];
8571 echo do_shortcode( stripslashes(nl2br($html)) );
8572 }
8573 }
8574
8575 function action_customer_page_footer(){
8576 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
8577 $html = $this->options['cart_page_data']['footer']['customer'];
8578 echo do_shortcode( stripslashes(nl2br($html)) );
8579 }
8580 }
8581
8582 function action_delivery_page_header(){
8583 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
8584 $html = $this->options['cart_page_data']['header']['delivery'];
8585 echo do_shortcode( stripslashes(nl2br($html)) );
8586 }
8587 }
8588
8589 function action_delivery_page_footer(){
8590 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
8591 $html = $this->options['cart_page_data']['footer']['delivery'];
8592 echo do_shortcode( stripslashes(nl2br($html)) );
8593 }
8594 }
8595
8596 function action_confirm_page_header(){
8597 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
8598 $html = $this->options['cart_page_data']['header']['confirm'];
8599 echo do_shortcode( stripslashes(nl2br($html)) );
8600 }
8601 }
8602
8603 function action_confirm_page_footer(){
8604 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
8605 $html = $this->options['cart_page_data']['footer']['confirm'];
8606 echo do_shortcode( stripslashes(nl2br($html)) );
8607 }
8608 }
8609
8610 function action_cartcompletion_page_header(){
8611 if( !empty($this->options['cart_page_data']['header']['completion']) ){
8612 $html = $this->options['cart_page_data']['header']['completion'];
8613 echo do_shortcode( stripslashes(nl2br($html)) );
8614 }
8615 }
8616
8617 function action_cartcompletion_page_footer(){
8618 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
8619 $html = $this->options['cart_page_data']['footer']['completion'];
8620 echo do_shortcode( stripslashes(nl2br($html)) );
8621 }
8622 }
8623
8624 function action_login_page_header(){
8625 if( !empty($this->options['member_page_data']['header']['login']) ){
8626 $html = $this->options['member_page_data']['header']['login'];
8627 echo do_shortcode( stripslashes(nl2br($html)) );
8628 }
8629 }
8630
8631 function action_login_page_footer(){
8632 if( !empty($this->options['member_page_data']['footer']['login']) ){
8633 $html = $this->options['member_page_data']['footer']['login'];
8634 echo do_shortcode( stripslashes(nl2br($html)) );
8635 }
8636 }
8637
8638 function action_newmember_page_header(){
8639 if( !empty($this->options['member_page_data']['header']['newmember']) ){
8640 $html = $this->options['member_page_data']['header']['newmember'];
8641 echo do_shortcode( stripslashes(nl2br($html)) );
8642 }
8643 }
8644
8645 function action_newmember_page_footer(){
8646 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
8647 $html = $this->options['member_page_data']['footer']['newmember'];
8648 echo do_shortcode( stripslashes(nl2br($html)) );
8649 }
8650 }
8651
8652 function action_newpass_page_header(){
8653 if( !empty($this->options['member_page_data']['header']['newpass']) ){
8654 $html = $this->options['member_page_data']['header']['newpass'];
8655 echo do_shortcode( stripslashes(nl2br($html)) );
8656 }
8657 }
8658
8659 function action_newpass_page_footer(){
8660 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
8661 $html = $this->options['member_page_data']['footer']['newpass'];
8662 echo do_shortcode( stripslashes(nl2br($html)) );
8663 }
8664 }
8665
8666 function action_changepass_page_header(){
8667 if( !empty($this->options['member_page_data']['header']['changepass']) ){
8668 $html = $this->options['member_page_data']['header']['changepass'];
8669 echo do_shortcode( stripslashes(nl2br($html)) );
8670 }
8671 }
8672
8673 function action_changepass_page_footer(){
8674 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
8675 $html = $this->options['member_page_data']['footer']['changepass'];
8676 echo do_shortcode( stripslashes(nl2br($html)) );
8677 }
8678 }
8679
8680 function action_memberinfo_page_header(){
8681 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
8682 $html = $this->options['member_page_data']['header']['memberinfo'];
8683 echo do_shortcode( stripslashes(nl2br($html)) );
8684 }
8685 }
8686
8687 function action_memberinfo_page_footer(){
8688 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
8689 $html = $this->options['member_page_data']['footer']['memberinfo'];
8690 echo do_shortcode( stripslashes(nl2br($html)) );
8691 }
8692 }
8693
8694 function action_membercompletion_page_header(){
8695 if( !empty($this->options['member_page_data']['header']['completion']) ){
8696 $html = $this->options['member_page_data']['header']['completion'];
8697 echo do_shortcode( stripslashes(nl2br($html)) );
8698 }
8699 }
8700
8701 function action_membercompletion_page_footer(){
8702 if( !empty($this->options['member_page_data']['footer']['completion']) ){
8703 $html = $this->options['member_page_data']['footer']['completion'];
8704 echo do_shortcode( stripslashes(nl2br($html)) );
8705 }
8706 }
8707 }
8708
8709
8710