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

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

8,011 lines 311.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class usc_e_shop
3 {
4
5 var $page; //page action
6 var $cart; //cart object
7 var $use_ssl; //ssl flag
8 var $action, $action_status, $error_status;
9 var $action_message, $error_message;
10 var $itemskus, $itemsku, $itemopts, $itemopt, $item;
11 var $zaiko_status, $payment_structure, $display_mode, $shipping_rule;
12 var $member_status;
13 var $options, $mail_para;
14 var $login_mail, $current_member, $member_form;
15 var $payment_results, $log_flg, $delim, $use_js;
16
17 function usc_e_shop()
18 {
19 //20110331ysk start
20 //global $post, $usces_settings;
21 global $post, $usces_settings, $usces_states;
22 //20110331ysk end
23 do_action('usces_construct');
24 add_action('after_setup_theme', array(&$this, 'usces_session_start'));
25
26 if ( is_admin() ){
27 clean_term_cache( get_option('usces_item_cat_parent_id'), 'category' );
28 }
29
30 $locales = usces_locales();
31 foreach($locales as $l){
32 $usces_settings['language'][$l] = $l;
33 }
34 $usces_settings['language']['others'] = __('Follow config.php', 'usces');
35
36 $this->options = get_option('usces');
37 if(!isset($this->options['smtp_hostname']) || empty($this->options['smtp_hostname'])){ $this->options['smtp_hostname'] = 'localhost';}
38 if(!isset($this->options['delivery_method']) || !is_array($this->options['delivery_method'])) $this->options['delivery_method'] = array();
39 if(!isset($this->options['shipping_charge']) || !is_array($this->options['shipping_charge'])) $this->options['shipping_charge'] = array();
40 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
41 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = 'activate';
42 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
43 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 0;
44 if(!isset($this->options['use_javascript'])) $this->options['use_javascript'] = 1;
45 if(!isset($this->options['privilege_discount'])) $this->options['privilege_discount'] = '';
46 if(!isset($this->options['privilege_point'])) $this->options['privilege_point'] = '';
47 if(!isset($this->options['campaign_privilege'])) $this->options['campaign_privilege'] = '';
48 if(!isset($this->options['campaign_category'])) $this->options['campaign_category'] = 0;
49 if(!isset($this->options['campaign_schedule']['start'])) $this->options['campaign_schedule']['start'] = array();
50 if(!isset($this->options['campaign_schedule']['end'])) $this->options['campaign_schedule']['end'] = array();
51 if(!isset($this->options['acting_settings']['paypal']['ec_activate'])) $this->options['acting_settings']['paypal']['ec_activate'] = '';
52 if(!isset($this->options['purchase_limit'])) $this->options['purchase_limit'] = '';
53 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
54 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
55 if(!isset($this->options['company_name'])) $this->options['company_name'] = '';
56 if(!isset($this->options['address1'])) $this->options['address1'] = '';
57 if(!isset($this->options['address2'])) $this->options['address2'] = '';
58 if(!isset($this->options['zip_code'])) $this->options['zip_code'] = '';
59 if(!isset($this->options['tel_number'])) $this->options['tel_number'] = '';
60 if(!isset($this->options['fax_number'])) $this->options['fax_number'] = '';
61 if(!isset($this->options['order_mail'])) $this->options['order_mail'] = '';
62 if(!isset($this->options['inquiry_mail'])) $this->options['inquiry_mail'] = '';
63 if(!isset($this->options['sender_mail'])) $this->options['sender_mail'] = '';
64 if(!isset($this->options['error_mail'])) $this->options['error_mail'] = '';
65 if(!isset($this->options['copyright'])) $this->options['copyright'] = '';
66 if(!isset($this->options['postage_privilege'])) $this->options['postage_privilege'] = '';
67 if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = '';
68 if(!isset($this->options['tax_rate'])) $this->options['tax_rate'] = '';
69 if(!isset($this->options['tax_method'])) $this->options['tax_method'] = 'cutting';
70 if(!isset($this->options['transferee'])) $this->options['transferee'] = '';
71 if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate';
72 if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = '';
73 if(!isset($this->options['point_rate'])) $this->options['point_rate'] = '';
74 if(!isset($this->options['start_point'])) $this->options['start_point'] = '';
75 if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 1;
76 if(!isset($this->options['point_assign'])) $this->options['point_assign'] = 1;//20120919ysk 0000573
77 if(!isset($this->options['cod_type'])) $this->options['cod_type'] = 'fix';
78 if(!isset($this->options['newmem_admin_mail'])) $this->options['newmem_admin_mail'] = 0;
79 if(!isset($this->options['delmem_admin_mail'])) $this->options['delmem_admin_mail'] = 1;
80 if(!isset($this->options['delmem_customer_mail'])) $this->options['delmem_customer_mail'] = 1;
81 if(!isset($this->options['mail_data']['title'])) $this->options['mail_data']['title'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>'');
82 if(!isset($this->options['mail_data']['header'])) $this->options['mail_data']['header'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>'');
83 if(!isset($this->options['mail_data']['footer'])) $this->options['mail_data']['footer'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>'');
84 if(!isset($this->options['cart_page_data']['header'])) $this->options['cart_page_data']['header'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
85 if(!isset($this->options['cart_page_data']['footer'])) $this->options['cart_page_data']['footer'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>'');
86 if(!isset($this->options['member_page_data']['header'])) $this->options['member_page_data']['header'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
87 if(!isset($this->options['member_page_data']['footer'])) $this->options['member_page_data']['footer'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>'');
88
89 if(!isset($this->options['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = '0';
90 if(!isset($this->options['delivery_after_days'])) $this->options['delivery_after_days'] = 15;
91 if(!isset($this->options['delivery_days'])) $this->options['delivery_days'] = array();
92 if(!isset($this->options['delivery_time_limit']['hour'])) $this->options['delivery_time_limit']['hour'] = '00';
93 if(!isset($this->options['delivery_time_limit']['min'])) $this->options['delivery_time_limit']['min'] = '00';
94
95 if(!isset($this->options['divide_item'])) $this->options['divide_item'] = 0;
96 if(!isset($this->options['itemimg_anchor_rel'])) $this->options['itemimg_anchor_rel'] = '';
97 if(!isset($this->options['fukugo_category_orderby'])) $this->options['fukugo_category_orderby'] = 'ID';
98 if(!isset($this->options['fukugo_category_order'])) $this->options['fukugo_category_order'] = 'ASC';
99 if(!isset($this->options['settlement_path'])) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
100 if(!isset($this->options['logs_path'])) $this->options['logs_path'] = '';
101 if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0;
102 if(!isset($this->options['ssl_url'])) $this->options['ssl_url'] = '';
103 if(!isset($this->options['ssl_url_admin'])) $this->options['ssl_url_admin'] = '';
104 if(!isset($this->options['inquiry_id'])) $this->options['inquiry_id'] = '';
105 if(!isset($this->options['system']['orderby_itemsku'])) $this->options['system']['orderby_itemsku'] = 0;
106 if(!isset($this->options['system']['orderby_itemopt'])) $this->options['system']['orderby_itemopt'] = 0;
107 if(!isset($this->options['system']['front_lang'])) $this->options['system']['front_lang'] = usces_get_local_language();
108 if(!isset($this->options['system']['currency'])) $this->options['system']['currency'] = usces_get_base_country();
109 if(!isset($this->options['system']['addressform'])) $this->options['system']['addressform'] = usces_get_local_addressform();
110 if(!isset($this->options['system']['target_market'])) $this->options['system']['target_market'] = usces_get_local_target_market();
111 if(!isset($this->options['system']['no_cart_css'])) $this->options['system']['no_cart_css'] = 0;
112 if(!isset($this->options['system']['dec_orderID_flag'])) $this->options['system']['dec_orderID_flag'] = 0;
113 if(!isset($this->options['system']['dec_orderID_prefix'])) $this->options['system']['dec_orderID_prefix'] = '';
114 if(!isset($this->options['system']['dec_orderID_digit'])) $this->options['system']['dec_orderID_digit'] = 6;
115 if(!isset($this->options['system']['subimage_rule'])) $this->options['system']['subimage_rule'] = 0;
116
117 if(!isset($this->options['acting_settings']['zeus'])) $this->options['acting_settings']['zeus'] = array('activate'=>'','card_activate'=>'','clientip'=>'','authkey'=>'','connection'=>'','3dsecure'=>'','security'=>'','quickcharge'=>'', 'howpay'=>'','bank_activate'=>'','clientip_bank'=>'','testid_bank'=>'','conv_activate'=>'','clientip_conv'=>'','testid_conv'=>'','test_type_conv'=>'');
118 if(!isset($this->options['acting_settings']['zeus']['connection'])) $this->options['acting_settings']['zeus']['connection'] = '1';
119 if(!isset($this->options['acting_settings']['zeus']['3dsecur'])) $this->options['acting_settings']['zeus']['3dsecur'] = '2';
120 if(!isset($this->options['acting_settings']['zeus']['security'])) $this->options['acting_settings']['zeus']['security'] = '2';
121 if(!isset($this->options['acting_settings']['remise'])) $this->options['acting_settings']['remise'] = array('activate'=>'','plan'=>'','SHOPCO'=>'','HOSTID'=>'','card_activate'=>'','card_jb'=>'', 'payquick'=>'','howpay'=>'','continuation'=>'','card_pc_ope'=>'','send_url_pc'=>'','conv_activate'=>'','S_PAYDATE'=>'','conv_pc_ope'=>'','send_url_cvs_pc'=>'');
122 if(!isset($this->options['acting_settings']['jpayment'])) $this->options['acting_settings']['jpayment'] = array('activate'=>'','aid'=>'','card_activate'=>'','card_jb'=>'','conv_activate'=>'','webm_activate'=>'', 'bitc_activate'=>'','suica_activate'=>'','bank_activate'=>'');
123 if(!isset($this->options['acting_settings']['paypal'])) $this->options['acting_settings']['paypal'] = array('activate'=>'','ec_activate'=>'','sandbox'=>'','user'=>'','pwd'=>'','signature'=>'', 'continuation'=>'');
124 $this->options['acting_settings']['sbps']['send_url'] = 'https://fep.sps-system.com/f01/FepBuyInfoReceive.do';
125
126 //20010420ysk start
127 //if(!isset($this->options['system']['base_country'])) $this->options['system']['base_country'] = usces_get_base_country();
128 $this->options['system']['base_country'] = usces_get_base_country();
129 //20010420ysk end
130 //20110331ysk start
131 if(!isset($this->options['province'])) $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
132 //20110331ysk end
133 if(!isset($this->options['system']['pointreduction'])) $this->options['system']['pointreduction'] = usces_get_pointreduction($this->options['system']['currency']);
134 if(!isset($this->options['indi_item_name'])){
135 $this->options['indi_item_name']['item_name'] = 1;
136 $this->options['indi_item_name']['item_code'] = 1;
137 $this->options['indi_item_name']['sku_name'] = 1;
138 $this->options['indi_item_name']['sku_code'] = 1;
139 $this->options['pos_item_name']['item_name'] = 1;
140 $this->options['pos_item_name']['item_code'] = 2;
141 $this->options['pos_item_name']['sku_name'] = 3;
142 $this->options['pos_item_name']['sku_code'] = 4;
143 }
144 update_option('usces', $this->options);
145
146 $this->check_display_mode();
147 $this->error_message = '';
148 $this->login_mail = '';
149 $this->get_current_member();
150 $this->page = '';
151 $this->payment_results = array();
152 $this->use_js = $this->options['use_javascript'];
153
154 //admin_ssl options
155 // $this->use_ssl = get_option("admin_ssl_use_ssl") === "1" ? true : false;
156 // $use_shared = get_option("admin_ssl_use_shared") === "1" && $this->use_ssl ? true : false;
157 // $shared_url = get_option("admin_ssl_shared_url");
158
159 $this->use_ssl = $this->options['use_ssl'];
160 // if ( $use_shared ) {
161 // $ssl_url = str_replace('/wp-admin/', '', $shared_url);
162 // } else {
163 // $ssl_url = str_replace('http://', 'https://', get_option('home'));
164 // }
165 define('USCES_CART_NUMBER', get_option('usces_cart_number'));
166 define('USCES_MEMBER_NUMBER', get_option('usces_member_number'));
167
168 if ( $this->use_ssl ) {
169 $ssl_url = $this->options['ssl_url'];
170 $ssl_url_admin = $this->options['ssl_url_admin'];
171 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
172 define('USCES_FRONT_PLUGIN_URL', $ssl_url_admin . '/wp-content/plugins/' . USCES_PLUGIN_FOLDER);
173 define('USCES_COOKIEPATH', preg_replace('|https?://[^/]+|i', '', $ssl_url . '/' ) );
174 }else{
175 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
176 define('USCES_COOKIEPATH', COOKIEPATH);
177 }
178 define('USCES_SSL_URL', $ssl_url);
179 define('USCES_SSL_URL_ADMIN', $ssl_url_admin);
180 }else{
181 define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER);
182 define('USCES_SSL_URL', get_option('home'));
183 define('USCES_SSL_URL_ADMIN', site_url());
184 define('USCES_COOKIEPATH', COOKIEPATH);
185 }
186 // if($this->use_ssl) {
187 // define('USCES_CART_URL', $ssl_url . '/?page_id=' . USCES_CART_NUMBER . '&usces=' . $this->get_uscesid());
188 // define('USCES_MEMBER_URL', $ssl_url . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces=' . $this->get_uscesid());
189 // define('USCES_INQUIRY_URL', $ssl_url . '/?page_id=' . $this->options['inquiry_id'] . '&usces=' . $this->get_uscesid());
190 // add_filter('home_url', array($this, 'usces_ssl_page_link'));
191 // add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
192 // add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
193 // add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
194 // add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
195 // add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
196 // } else {
197 // define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
198 // define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
199 // define('USCES_INQUIRY_URL', get_option('home') . '/?page_id=' . $this->options['inquiry_id']);
200 // }
201 define('USCES_ITEM_CAT_PARENT_ID', get_option('usces_item_cat_parent_id'));
202
203 $this->zaiko_status = get_option('usces_zaiko_status');
204 $this->member_status = get_option('usces_customer_status');
205 $this->payment_structure = get_option('usces_payment_structure');
206 $this->display_mode = get_option('usces_display_mode');
207 define('USCES_MYSQL_VERSION', (int)substr(mysql_get_server_info(), 0, 1));
208 define('USCES_JP', ('ja' === get_locale() ? true : false));
209
210 }
211
212 function get_default_post_to_edit30( $post_type = 'post', $create_in_db = false ) {
213 global $wpdb;
214
215 $post_title = '';
216 if ( !empty( $_REQUEST['post_title'] ) )
217 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
218
219 $post_content = '';
220 if ( !empty( $_REQUEST['content'] ) )
221 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
222
223 $post_excerpt = '';
224 if ( !empty( $_REQUEST['excerpt'] ) )
225 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
226
227 if ( $create_in_db ) {
228 // Cleanup old auto-drafts more than 7 days old
229 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
230 foreach ( (array) $old_posts as $delete )
231 wp_delete_post( $delete, true ); // Force delete
232 $post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) );
233 } else {
234 $post->ID = 0;
235 $post->post_author = '';
236 $post->post_date = '';
237 $post->post_date_gmt = '';
238 $post->post_password = '';
239 $post->post_type = $post_type;
240 $post->post_status = 'draft';
241 $post->to_ping = '';
242 $post->pinged = '';
243 $post->comment_status = get_option( 'default_comment_status' );
244 $post->ping_status = get_option( 'default_ping_status' );
245 $post->post_pingback = get_option( 'default_pingback_flag' );
246 $post->post_category = get_option( 'default_category' );
247 $post->page_template = 'default';
248 $post->post_parent = 0;
249 $post->menu_order = 0;
250 }
251
252 $post->post_content = apply_filters( 'default_content', $post_content, $post );
253 $post->post_title = apply_filters( 'default_title', $post_title, $post );
254 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
255 $post->post_name = '';
256
257 return $post;
258 }
259
260 function get_default_post_to_edit() {
261 global $post;
262
263 $post_title = '';
264 if ( !empty( $_REQUEST['post_title'] ) )
265 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
266
267 $post_content = '';
268 if ( !empty( $_REQUEST['content'] ) )
269 $post_content = esc_html( stripslashes( $_REQUEST['content'] ));
270
271 $post_excerpt = '';
272 if ( !empty( $_REQUEST['excerpt'] ) )
273 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
274
275 $post->ID = 0;
276 $post->post_name = '';
277 $post->post_author = '';
278 $post->post_date = '';
279 $post->post_date_gmt = '';
280 $post->post_password = '';
281 $post->post_status = 'draft';
282 $post->post_type = 'post';
283 $post->to_ping = '';
284 $post->pinged = '';
285 $post->comment_status = get_option( 'default_comment_status' );
286 $post->ping_status = get_option( 'default_ping_status' );
287 $post->post_pingback = get_option( 'default_pingback_flag' );
288 $post->post_category = get_option( 'default_category' );
289 $post->post_content = apply_filters( 'default_content', $post_content);
290 $post->post_title = apply_filters( 'default_title', $post_title );
291 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
292 $post->page_template = 'default';
293 $post->post_parent = 0;
294 $post->menu_order = 0;
295
296 return $post;
297 }
298 function is_cart_or_member_page($link)
299 {
300 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart', ('page_id='.USCES_MEMBER_NUMBER), '/usces-member');
301 $flag = false;
302 foreach($search as $value){
303 $parts = array();
304 if( false !== strpos($link, $value) ){
305 if( $value == ('page_id='.USCES_CART_NUMBER) || $value == ('page_id='.USCES_MEMBER_NUMBER) ){
306 $parts = parse_url($link);
307 parse_str($parts['query'], $query);
308 if( $query['page_id'] == USCES_CART_NUMBER || $query['page_id'] == USCES_MEMBER_NUMBER ){
309 $flag = true;
310 }
311 }else{
312 $flag = true;
313 }
314 }
315 }
316 return $flag;
317 }
318
319 function is_cart_page($link)
320 {
321 $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart' );
322 $flag = false;
323 foreach($search as $value){
324 if( false !== strpos($link, $value) ){
325 if( $value == ('page_id='.USCES_CART_NUMBER) ){
326 $parts = parse_url($link);
327 parse_str($parts['query'], $query);
328 if( $query['page_id'] == USCES_CART_NUMBER ){
329 $flag = true;
330 }
331 }else{
332 $flag = true;
333 }
334 }
335 }
336 return $flag;
337 }
338
339 function is_member_page($link)
340 {
341 $search = array(('page_id='.USCES_MEMBER_NUMBER), '/usces-member' );
342 $flag = false;
343 foreach($search as $value){
344 if( false !== strpos($link, $value) ){
345 if( $value == ('page_id='.USCES_MEMBER_NUMBER) ){
346 $parts = parse_url($link);
347 parse_str($parts['query'], $query);
348 if( $query['page_id'] == USCES_MEMBER_NUMBER ){
349 $flag = true;
350 }
351 }else{
352 $flag = true;
353 }
354 }
355 }
356 return $flag;
357 }
358
359 function is_inquiry_page($link)
360 {
361 if( empty($this->options['inquiry_id']) )
362 return false;
363
364 $search = array(('page_id='.$this->options['inquiry_id']), '/usces-inquiry' );
365 $flag = false;
366 foreach($search as $value){
367 if( false !== strpos($link, $value) ){
368 if( $value == ('page_id='.$this->options['inquiry_id']) ){
369 $parts = parse_url($link);
370 parse_str($parts['query'], $query);
371 if( $query['page_id'] == $this->options['inquiry_id'] ){
372 $flag = true;
373 }
374 }else{
375 $flag = true;
376 }
377 }
378 }
379 return $flag;
380 }
381
382 function usces_ssl_page_link($link)
383 {
384 $parts = parse_url($link);
385
386 if( isset($parts['query']) ){
387 parse_str($parts['query'], $query);
388 }
389
390 if( false !== strpos($link, '/usces-cart') || (isset( $query['page_id']) && $query['page_id'] == USCES_CART_NUMBER) ){
391 $link = USCES_CART_URL;
392
393 }elseif( false !== strpos($link, '/usces-member') || (isset( $query['page_id']) && $query['page_id'] == USCES_MEMBER_NUMBER) ){
394 $link = USCES_MEMBER_URL;
395
396 }elseif( !empty($this->options['inquiry_id']) && (false !== strpos($link, '/usces-inquiry') || (isset( $query['page_id']) && $query['page_id'] == $this->options['inquiry_id'])) ){
397 $link = USCES_INQUIRY_URL;
398
399 }else{
400 $link = str_replace('https://', 'http://', $link);
401 $link = apply_filters('usces_ssl_page_link', $link);
402 }
403
404 return $link;
405 }
406 function usces_ssl_contents_link($link)
407 {
408 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])){
409 $req = explode('/wp-content/',$link);
410 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
411 }else{
412 $link = apply_filters('usces_ssl_contents_link', $link);
413 }
414 return $link;
415 }
416
417 function ssl_admin_ajax_url(){
418 $path = '/wp-admin/admin-ajax.php';
419 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) ){
420 $link = USCES_SSL_URL_ADMIN . '/wp-admin/admin-ajax.php';
421 }else{
422 $link = site_url( $path );
423 }
424 $link = apply_filters('ssl_admin_ajax_url', $link);
425 return $link;
426 }
427
428 function usces_ssl_attachment_link($link)
429 {
430 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
431 $link = str_replace(site_url(), USCES_SSL_URL_ADMIN, $link);
432 }else{
433 $link = apply_filters('usces_ssl_attachment_link', $link);
434 }
435 return $link;
436 }
437
438 function usces_ssl_icon_dir_uri($uri)
439 {
440 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
441 $uri = USCES_SSL_URL_ADMIN. '/' . WPINC . '/images/crystal';
442 }else{
443 $link = apply_filters('usces_ssl_icon_dir_uri', $uri);
444 }
445 return $uri;
446 }
447
448 function usces_ssl_script_link($link)
449 {
450 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
451 if(strpos($link, '/wp-content/') !== false){
452 $req = explode('/wp-content/',$link, 2);
453 $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
454 }else if(strpos($link, '/wp-includes/') !== false){
455 $req = explode('/wp-includes/',$link, 2);
456 $link = USCES_SSL_URL_ADMIN . '/wp-includes/' . $req[1];
457 }else if(strpos($link, '/wp-admin/') !== false){
458 $req = explode('/wp-admin/',$link, 2);
459 $link = USCES_SSL_URL_ADMIN . '/wp-admin/' . $req[1];
460 }
461 }else{
462 $link = apply_filters('usces_ssl_script_link', $link);
463 }
464 return $link;
465 }
466
467 function set_action_status($status, $message)
468 {
469 $this->action_status = $status;
470 $this->action_message = $message;
471 }
472
473
474 /******************************************************************************/
475 function add_pages() {
476
477 add_object_page('Welcart Shop', 'Welcart Shop', 'level_6', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
478 add_submenu_page(USCES_PLUGIN_BASENAME, __('Home','usces'), __('Home','usces'), 'level_6', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page'));
479 add_submenu_page(USCES_PLUGIN_BASENAME, __('Master Items','usces'), __('Master Items','usces'), 'level_6', 'usces_itemedit', array($this, 'item_master_page'));
480 add_submenu_page(USCES_PLUGIN_BASENAME, __('Add New Item','usces'), __('Add New Item','usces'), 'level_6', 'usces_itemnew', array($this, 'item_master_page'));
481 add_submenu_page(USCES_PLUGIN_BASENAME, __('General Setting','usces'), __('General Setting','usces'), 'level_6', 'usces_initial', array($this, 'admin_setup_page'));
482 add_submenu_page(USCES_PLUGIN_BASENAME, __('Business Days Setting','usces'), __('Business Days Setting','usces'), 'level_6', 'usces_schedule', array($this, 'admin_schedule_page'));
483 add_submenu_page(USCES_PLUGIN_BASENAME, __('Shipping Setting','usces'), __('Shipping Setting','usces'), 'level_6', 'usces_delivery', array($this, 'admin_delivery_page'));
484 add_submenu_page(USCES_PLUGIN_BASENAME, __('E-mail Setting','usces'), __('E-mail Setting','usces'), 'level_6', 'usces_mail', array($this, 'admin_mail_page'));
485 add_submenu_page(USCES_PLUGIN_BASENAME, __('Cart Page Setting','usces'), __('Cart Page Setting','usces'), 'level_6', 'usces_cart', array($this, 'admin_cart_page'));
486 add_submenu_page(USCES_PLUGIN_BASENAME, __('Member Page Setting','usces'), __('Member Page Setting','usces'), 'level_6', 'usces_member', array($this, 'admin_member_page'));
487 add_submenu_page(USCES_PLUGIN_BASENAME, __('System Setting','usces'), __('System Setting','usces'), 'administrator', 'usces_system', array($this, 'admin_system_page'));
488 add_submenu_page(USCES_PLUGIN_BASENAME, __('Settlement Setting','usces'), __('Settlement Setting','usces'), 'administrator', 'usces_settlement', array($this, 'admin_settlement_page'));
489 //add_submenu_page(USCES_PLUGIN_BASENAME, __('Backup','usces'), __('Backup','usces'), 'level_6', 'usces_backup', array($this, 'admin_backup_page'));
490 do_action('usces_action_shop_admin_menue');
491
492 add_object_page('Welcart Management', 'Welcart Management', 'level_6', 'usces_orderlist', array($this, 'order_list_page'));
493 add_submenu_page('usces_orderlist', __('Order List','usces'), __('Order List','usces'), 'level_6', 'usces_orderlist', array($this, 'order_list_page'));
494 add_submenu_page('usces_orderlist', __('New Order or Estimate','usces'), __('New Order or Estimate','usces'), 'level_6', 'usces_ordernew', array($this, 'order_list_page'));
495 add_submenu_page('usces_orderlist', __('List of Members','usces'), __('List of Members','usces'), 'level_6', 'usces_memberlist', array($this, 'member_list_page'));
496 //add_submenu_page('usces_orderlist', __('New Member','usces'), __('New Member','usces'), 'level_6', 'usces_membernew', array($this, 'member_list_page'));
497 do_action('usces_action_management_admin_menue');
498 }
499
500
501 /* Item Master Page */
502 function item_master_page() {
503 global $wpdb, $wp_locale;
504 global $wp_query;
505
506 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
507 $this->action_status = 'none';
508 $this->action_message = '';
509 }
510
511 if($_REQUEST['page'] == 'usces_itemnew'){
512 $action = 'new';
513 }else{
514 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
515 }
516 do_action( 'usces_action_item_master_page', $action );
517 switch ( $action ) {
518 case 'dlitemlist':
519 usces_download_item_list();
520 break;
521 case 'upload_register':
522 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_upload_register.php');
523 break;
524 case 'delete':
525 case 'new':
526 case 'editpost':
527 case 'edit':
528 global $current_user;
529 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_edit.php');
530 break;
531 default:
532 require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_list.php');
533 break;
534 }
535 }
536
537 /* order list page */
538 function order_list_page() {
539 $order_edit_form = apply_filters( 'usces_admin_order_edit_form', USCES_PLUGIN_DIR . '/includes/order_edit_form.php' );
540 $order_list = apply_filters( 'usces_admin_order_list', USCES_PLUGIN_DIR . '/includes/order_list.php' );
541
542 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
543 $this->action_status = 'none';
544 $this->action_message = '';
545 }
546 if($_REQUEST['page'] == 'usces_ordernew'){
547 $order_action = 'new';
548 }else{
549 $order_action = isset($_REQUEST['order_action']) ? $_REQUEST['order_action'] : '';
550 }
551 do_action('usces_action_order_list_page', $order_action);
552 switch ($order_action) {
553 //20100908ysk start
554 case 'dlproductlist':
555 usces_download_product_list();
556 break;
557 case 'dlorderlist':
558 usces_download_order_list();
559 break;
560 //20100908ysk end
561 // case 'printpdf':
562 // require_once(USCES_PLUGIN_DIR . '/includes/order_print.php');
563 // break;
564 case 'editpost':
565 do_action('usces_pre_update_orderdata', $_REQUEST['order_id']);
566 $res = usces_update_orderdata();
567 if ( 1 === $res ) {
568 $this->set_action_status('success', __('order date is updated','usces').' <a href="'.stripslashes( $_POST['usces_referer'] ).'">'.__('back to the summary','usces').'</a>');
569 } elseif ( 0 === $res ) {
570 $this->set_action_status('none', '');
571 } else {
572 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
573 }
574 do_action('usces_after_update_orderdata', $_REQUEST['order_id'], $res);
575 require_once($order_edit_form);
576 break;
577 case 'newpost':
578 do_action('usces_pre_new_orderdata');
579 $res = usces_new_orderdata();
580 if ( 1 === $res ) {
581 $this->set_action_status('success', __('New date is add','usces'));
582 } elseif ( 0 === $res ) {
583 $this->set_action_status('none', '');
584 } else {
585 $this->set_action_status('error', 'ERROR : '.__('failure in addition','usces'));
586 }
587 do_action('usces_after_new_orderdata', $res);
588 $_REQUEST['order_action'] = 'edit';
589 $order_action = $_REQUEST['order_action'];
590 require_once($order_edit_form);
591 break;
592 case 'new':
593 case 'edit':
594 require_once($order_edit_form);
595 break;
596 case 'delete':
597 do_action('usces_pre_delete_orderdata', $_REQUEST['order_id']);
598 $res = usces_delete_orderdata();
599 if ( 1 === $res ) {
600 $this->set_action_status('success', __('the order date is deleted','usces'));
601 } elseif ( 0 === $res ) {
602 $this->set_action_status('none', '');
603 } else {
604 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
605 }
606 do_action('usces_after_delete_orderdata', $_REQUEST['order_id'], $res);
607 default:
608 require_once($order_list);
609 }
610 }
611
612 /* member list page */
613 function member_list_page() {
614 $member_edit_form = apply_filters( 'usces_admin_member_edit_form', USCES_PLUGIN_DIR . '/includes/member_edit_form.php' );
615 $member_list = apply_filters( 'usces_admin_member_list', USCES_PLUGIN_DIR . '/includes/member_list.php' );
616
617 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
618 $this->action_status = 'none';
619 $this->action_message = '';
620 }
621 $member_action = isset($_REQUEST['member_action']) ? $_REQUEST['member_action'] : '';
622 switch ($member_action) {
623 //20100908ysk start
624 case 'dlmemberlist':
625 usces_download_member_list();
626 break;
627 //20100908ysk end
628 case 'editpost':
629 $this->error_message = $this->admin_member_check();
630 if( WCUtils::is_blank($this->error_message) ){
631 $res = usces_update_memberdata();
632 if ( 1 === $res ) {
633 $this->set_action_status('success', __('Membership information is updated','usces'));
634 } elseif ( 0 === $res ) {
635 $this->set_action_status('none', '');
636 } else {
637 $this->set_action_status('error', 'ERROR : '.__('failure in update','usces'));
638 }
639 }
640 require_once($member_edit_form);
641 break;
642 case 'new':
643 case 'edit':
644 require_once($member_edit_form);
645 break;
646 case 'delete':
647 $res = usces_delete_memberdata();
648 if ( 1 === $res ) {
649 $this->set_action_status('success', __('The member data is deleted','usces'));
650 } elseif ( 0 === $res ) {
651 $this->set_action_status('none', '');
652 } else {
653 $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces'));
654 }
655 default:
656 require_once($member_list);
657 }
658
659 }
660
661 /* admin backup page */
662 function admin_backup_page() {
663
664 if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) {
665 $this->action_status = 'none';
666 $this->action_message = '';
667 }
668 require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
669
670 }
671
672 /* Shop Top Page */
673 function admin_top_page() {
674
675 require_once(USCES_PLUGIN_DIR . '/includes/admin_top.php');
676
677 }
678
679 /* Shop Setup Page */
680 function admin_setup_page() {
681 $this->options = get_option('usces');
682 //$this->options = array();
683
684
685 if(isset($_POST['usces_option_update'])) {
686
687 $_POST = $this->stripslashes_deep_post($_POST);
688 $this->options['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : '';
689 $this->options['campaign_category'] = empty($_POST['cat']) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat'];
690 $this->options['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : '';
691 $this->options['privilege_point'] = isset($_POST['point_num']) ? (int)$_POST['point_num'] : '';
692 $this->options['privilege_discount'] = isset($_POST['discount_num']) ? (int)$_POST['discount_num'] : '';
693 $this->options['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : '';
694 $this->options['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : '';
695 $this->options['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : '';
696 $this->options['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : '';
697 $this->options['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : '';
698 $this->options['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : '';
699 $this->options['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : '';
700 $this->options['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : '';
701 $this->options['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : '';
702 $this->options['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : '';
703 $this->options['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : '';
704 $this->options['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : '';
705 $this->options['point_rate'] = isset($_POST['point_rate']) ? (int)$_POST['point_rate'] : '';
706 $this->options['start_point'] = isset($_POST['start_point']) ? (int)$_POST['start_point'] : '';
707 $this->options['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : '';
708 $this->options['tax_rate'] = isset($_POST['tax_rate']) ? (int)$_POST['tax_rate'] : '';
709 $this->options['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : '';
710 $this->options['cod_type'] = isset($this->options['cod_type']) ? $this->options['cod_type'] : 'fix';
711 $this->options['transferee'] = isset($_POST['transferee']) ? trim($_POST['transferee']) : '';
712 $this->options['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : '';
713 $this->options['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : '';
714 $this->options['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : '';
715 $this->options['point_coverage'] = isset($_POST['point_coverage']) ? (int)$_POST['point_coverage'] : 0;
716 $this->options['point_assign'] = isset($_POST['point_assign']) ? (int)$_POST['point_assign'] : 1;//20120919ysk 0000573
717
718 $this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options );
719
720 update_option('usces', $this->options);
721
722 $this->action_status = 'success';
723 $this->action_message = __('options are updated','usces');
724
725 } else {
726 $this->action_status = 'none';
727 $this->action_message = '';
728 }
729
730 require_once(USCES_PLUGIN_DIR . '/includes/admin_setup.php');
731
732 }
733
734 /* Shop Schedule Page */
735 function admin_schedule_page() {
736
737 $this->options = get_option('usces');
738
739 if(isset($_POST['usces_option_update'])) {
740 $_POST = $this->stripslashes_deep_post($_POST);
741
742 $this->options['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0';
743 if(isset($_POST['business_days']))
744 $this->options['business_days'] = $_POST['business_days'];
745
746 update_option('usces', $this->options);
747
748 do_action( 'usces_action_admin_schedule_update' );
749
750 $this->action_status = 'success';
751 $this->action_message = __('options are updated','usces');
752 } else {
753 $this->action_status = 'none';
754 $this->action_message = '';
755 }
756
757 require_once(USCES_PLUGIN_DIR . '/includes/admin_schedule.php');
758
759 }
760
761 /* Shop Delivery Page */
762 function admin_delivery_page() {
763
764 $this->options = get_option('usces');
765
766 if(isset($_POST['usces_option_update'])) {
767 $_POST = $this->stripslashes_deep_post($_POST);
768
769 //20101208ysk start
770 if(isset($_POST['delivery_time_limit'])) $this->options['delivery_time_limit'] = $_POST['delivery_time_limit'];
771 if(isset($_POST['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time'];
772 if(isset($_POST['delivery_after_days'])) $this->options['delivery_after_days'] = $_POST['delivery_after_days'];
773 //20101208ysk end
774
775 update_option('usces', $this->options);
776
777 $this->action_status = 'success';
778 $this->action_message = __('options are updated','usces');
779 } else {
780 $this->action_status = 'none';
781 $this->action_message = '';
782 }
783
784 require_once(USCES_PLUGIN_DIR . '/includes/admin_delivery.php');
785
786 }
787
788 /* Shop Mail Page */
789 function admin_mail_page() {
790 global $allowedposttags;
791
792 $this->options = get_option('usces');
793
794 if(isset($_POST['usces_option_update'])) {
795 $_POST = $this->stripslashes_deep_post($_POST);
796
797 $this->options['smtp_hostname'] = trim($_POST['smtp_hostname']);
798 $this->options['newmem_admin_mail'] = (int)$_POST['newmem_admin_mail'];
799 $this->options['delmem_admin_mail'] = (int)$_POST['delmem_admin_mail'];
800 $this->options['delmem_customer_mail'] = (int)$_POST['delmem_customer_mail'];
801
802 foreach ( $_POST['title'] as $key => $value ) {
803 if( WCUtils::is_blank($value) ) {
804 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
805 }else{
806 $this->options['mail_data']['title'][$key] = trim($value);
807 }
808 }
809 foreach ( $_POST['header'] as $key => $value ) {
810 if( WCUtils::is_blank($value) ) {
811 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
812 }else{
813 $this->options['mail_data']['header'][$key] = $value;
814 }
815 }
816 foreach ( $_POST['footer'] as $key => $value ) {
817 if( WCUtils::is_blank($value) ) {
818 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
819 }else{
820 $this->options['mail_data']['footer'][$key] = $value;
821 }
822 }
823
824
825 $this->action_status = 'success';
826 $this->action_message = __('options are updated','usces');
827
828 } else {
829
830 foreach ( (array)$this->options['mail_data']['title'] as $key => $value ) {
831 if( WCUtils::is_blank($value) ) {
832 $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key];
833 }
834 }
835 foreach ( (array)$this->options['mail_data']['header'] as $key => $value ) {
836 if( WCUtils::is_blank($value) ) {
837 $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key];
838 }
839 }
840 foreach ( (array)$this->options['mail_data']['footer'] as $key => $value ) {
841 if( WCUtils::is_blank($value) ) {
842 $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key];
843 }
844 }
845
846 $this->action_status = 'none';
847 $this->action_message = '';
848
849 }
850
851 update_option('usces', $this->options);
852 do_action( 'usces_action_admin_mail_page' );
853
854 require_once(USCES_PLUGIN_DIR . '/includes/admin_mail.php');
855
856 }
857
858 /* Admin Cart Page */
859 function admin_cart_page() {
860 global $allowedposttags;
861 $this->options = get_option('usces');
862
863 if(isset($_POST['usces_option_update'])) {
864 $_POST = $this->stripslashes_deep_post($_POST);
865
866 foreach ( $this->options['indi_item_name'] as $key => $value ) {
867 $this->options['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0;
868 }
869 foreach ( $_POST['position'] as $key => $value ) {
870 $this->options['pos_item_name'][$key] = $value;
871 }
872 foreach ( $_POST['header'] as $key => $value ) {
873 $this->options['cart_page_data']['header'][$key] = addslashes(wp_kses($value, $allowedposttags));
874 }
875 foreach ( $_POST['footer'] as $key => $value ) {
876 $this->options['cart_page_data']['footer'][$key] = addslashes(wp_kses($value, $allowedposttags));
877 }
878
879 update_option('usces', $this->options);
880
881 $this->action_status = 'success';
882 $this->action_message = __('options are updated','usces');
883 } else {
884
885 $this->action_status = 'none';
886 $this->action_message = '';
887 }
888
889
890
891 require_once(USCES_PLUGIN_DIR . '/includes/admin_cart.php');
892
893 }
894
895 /* Admin Member Page */
896 function admin_member_page() {
897
898 $this->options = get_option('usces');
899
900 if(isset($_POST['usces_option_update'])) {
901 $_POST = $this->stripslashes_deep_post($_POST);
902
903 foreach ( $_POST['header'] as $key => $value ) {
904 $this->options['member_page_data']['header'][$key] = $value;
905 }
906 foreach ( $_POST['footer'] as $key => $value ) {
907 $this->options['member_page_data']['footer'][$key] = $value;
908 }
909
910 update_option('usces', $this->options);
911
912 $this->action_status = 'success';
913 $this->action_message = __('options are updated','usces');
914 } else {
915
916 $this->action_status = 'none';
917 $this->action_message = '';
918 }
919
920
921
922 require_once(USCES_PLUGIN_DIR . '/includes/admin_member.php');
923
924 }
925
926
927 /* Admin System Page */
928 function admin_system_page() {
929 //20110331ysk start
930 global $usces_states;
931 //20110331ysk end
932 $action_status = '';//20120511ysk 0000470
933
934 $this->options = get_option('usces');
935
936 if(isset($_POST['usces_option_update'])) {
937 $_POST = $this->stripslashes_deep_post($_POST);
938
939 $this->options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0;
940 $this->options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : '';
941 $this->options['fukugo_category_orderby'] = isset($_POST['fukugo_category_orderby']) ? $_POST['fukugo_category_orderby'] : '';
942 $this->options['fukugo_category_order'] = isset($_POST['fukugo_category_order']) ? $_POST['fukugo_category_order'] : '';
943 $this->options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : '';
944 if( WCUtils::is_blank($this->options['settlement_path']) ) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/';
945 $sl = substr($this->options['settlement_path'], -1);
946 if($sl != '/' && $sl != '\\') $this->options['settlement_path'] .= '/';
947 $this->options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : '';
948 if( !WCUtils::is_blank($this->options['logs_path']) ){
949 $sl = substr($this->options['logs_path'], -1);
950 if($sl == '/' || $sl == '\\') $this->options['logs_path'] = substr($this->options['logs_path'], 0, -1);
951 }
952 $this->options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0;
953 $this->options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : '';
954 $this->options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : '';
955 if( WCUtils::is_blank($this->options['ssl_url']) || WCUtils::is_blank($this->options['ssl_url_admin']) ) $this->options['use_ssl'] = 0;
956 $this->options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : '';
957 $this->options['use_javascript'] = isset($_POST['use_javascript']) ? (int)$_POST['use_javascript'] : 1;
958 $this->options['system']['front_lang'] = (isset($_POST['front_lang']) && 'others' != $_POST['front_lang']) ? $_POST['front_lang'] : usces_get_local_language();
959 $this->options['system']['currency'] = (isset($_POST['currency']) && 'others' != $_POST['currency']) ? $_POST['currency'] : usces_get_base_country();
960 $this->options['system']['addressform'] = (isset($_POST['addressform']) ) ? $_POST['addressform'] : usces_get_local_addressform();
961 $this->options['system']['target_market'] = (isset($_POST['target_market']) ) ? $_POST['target_market'] : usces_get_local_target_market();
962 $this->options['system']['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0;
963 $this->options['system']['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int)$_POST['dec_orderID_flag'] : 0;
964 $this->options['system']['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : '';
965 if( isset($_POST['dec_orderID_digit']) ){
966 $dec_orderID_digit = (int)rtrim($_POST['dec_orderID_digit']);
967 if( 6 > $dec_orderID_digit ){
968 $this->options['system']['dec_orderID_digit'] = 6;
969 }else{
970 $this->options['system']['dec_orderID_digit'] = $dec_orderID_digit;
971 }
972 }else{
973 $this->options['system']['dec_orderID_digit'] = 6;
974 }
975 $this->options['system']['subimage_rule'] = isset($_POST['subimage_rule']) ? (int)$_POST['subimage_rule'] : 0;
976 //20110331ysk start
977 unset($this->options['province']);
978 //$action_status = '';//20120511ysk 0000470
979 foreach((array)$this->options['system']['target_market'] as $target_market) {
980 $province = array();
981 if(!empty($_POST['province_'.$target_market])) {
982 $temp_pref = explode("\n", $_POST['province_'.$target_market]);
983 //20120123ysk start 0000386
984 //$province[] = __('-- Select --', 'usces');
985 $province[] = '-- Select --';
986 //20120123ysk end
987 //20120725ysk start 0000537
988 //for($i = 0; $i < count($temp_pref); $i++) {
989 //$province[] = trim($temp_pref[$i]);
990 foreach( $temp_pref as $pref ) {
991 if( !WCUtils::is_blank($pref) )
992 $province[] = trim($pref);
993 }
994 if( 1 == count($province) )
995 $action_status = 'error';
996 //20120725ysk end
997 } else {
998 if(isset($usces_states[$target_market]) && is_array($usces_states[$target_market])) {
999 $province = $usces_states[$target_market];
1000 } else {
1001 $action_status = 'error';
1002 }
1003 }
1004 $this->options['province'][$target_market] = $province;
1005 }
1006
1007 if($action_status != '') {
1008 $this->action_status = 'error';
1009 $this->action_message = __('Data have deficiency.','usces');
1010 } else {
1011 $this->action_status = 'success';
1012 $this->action_message = __('options are updated','usces');
1013 }
1014 //20110331ysk end
1015 } else {
1016
1017 if( !isset($this->options['province']) || empty($this->options['province']) ){
1018 //20110331ysk start
1019 //$this->options['province'] = get_option('usces_pref');
1020 $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']];
1021 //20110331ysk end
1022 }
1023 $this->action_status = 'none';
1024 $this->action_message = '';
1025 }
1026
1027 if($action_status != 'error') //20120511ysk 0000470
1028 update_option('usces', $this->options);
1029
1030 require_once(USCES_PLUGIN_DIR . '/includes/admin_system.php');
1031
1032 }
1033
1034 /* Settlement Setting Page */
1035 function admin_settlement_page() {
1036
1037 $this->action_status = 'none';
1038 $this->action_message = '';
1039
1040 $options = get_option('usces');
1041
1042 if( isset($_POST['usces_option_update']) ) {
1043 $_POST = $this->stripslashes_deep_post($_POST);
1044 $mes = '';
1045
1046 switch( $_POST['acting'] ){
1047 case 'zeus':
1048 unset( $options['acting_settings']['zeus'] );
1049 $options['acting_settings']['zeus']['card_url'] = isset($_POST['card_url']) ? $_POST['card_url'] : '';
1050 $options['acting_settings']['zeus']['card_secureurl'] = isset($_POST['card_secureurl']) ? $_POST['card_secureurl'] : '';
1051 $options['acting_settings']['zeus']['ipaddrs'] = isset($_POST['ipaddrs']) ? $_POST['ipaddrs'] : '';
1052 $options['acting_settings']['zeus']['pay_cvs'] = isset($_POST['pay_cvs']) ? $_POST['pay_cvs'] : '';
1053 $options['acting_settings']['zeus']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1054 $options['acting_settings']['zeus']['connection'] = isset($_POST['connection']) ? $_POST['connection'] : 1;
1055 $options['acting_settings']['zeus']['3dsecur'] = isset($_POST['3dsecur']) ? $_POST['3dsecur'] : 2;
1056 $options['acting_settings']['zeus']['security'] = isset($_POST['security']) ? $_POST['security'] : 2;
1057 if( isset($_POST['authkey']) ){
1058 $options['acting_settings']['zeus']['authkey'] = $_POST['authkey'];
1059 }
1060 // if( 1 == $options['acting_settings']['zeus']['security'] ){
1061 // $options['acting_settings']['zeus']['quickcharge'] = '2';
1062 // }else{
1063 $options['acting_settings']['zeus']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : '';
1064 // }
1065 $options['acting_settings']['zeus']['batch'] = isset($_POST['batch']) ? $_POST['batch'] : '';
1066 $options['acting_settings']['zeus']['clientip'] = isset($_POST['clientip']) ? trim($_POST['clientip']) : '';
1067 $options['acting_settings']['zeus']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1068 $options['acting_settings']['zeus']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1069 $options['acting_settings']['zeus']['clientip_bank'] = isset($_POST['clientip_bank']) ? trim($_POST['clientip_bank']) : '';
1070 $options['acting_settings']['zeus']['testid_bank'] = isset($_POST['testid_bank']) ? trim($_POST['testid_bank']) : '';
1071 $options['acting_settings']['zeus']['bank_url'] = isset($_POST['bank_url']) ? $_POST['bank_url'] : '';
1072 $options['acting_settings']['zeus']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1073 $options['acting_settings']['zeus']['clientip_conv'] = isset($_POST['clientip_conv']) ? trim($_POST['clientip_conv']) : '';
1074 $options['acting_settings']['zeus']['testid_conv'] = isset($_POST['testid_conv']) ? trim($_POST['testid_conv']) : '';
1075 $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'];
1076 $options['acting_settings']['zeus']['conv_url'] = isset($_POST['conv_url']) ? $_POST['conv_url'] : '';
1077
1078 if( WCUtils::is_blank($_POST['clientip']) && isset($_POST['card_activate']) && 'on' == $_POST['card_activate'])
1079 $mes .= '※カード決済IPコードを�
1080 �力して下さい<br />';
1081 if( isset($_POST['authkey']) && WCUtils::is_blank($_POST['authkey']) && isset($_POST['security']) && 3 == $_POST['security'])
1082 $mes .= '※認証キーを�
1083 �力して下さい<br />';
1084 if( WCUtils::is_blank($_POST['clientip_bank']) && isset($_POST['bank_activate']) && 'on' == $_POST['bank_activate'] )
1085 $mes .= '※�
1086 �金お任せIPコードを�
1087 �力して下さい<br />';
1088 if( WCUtils::is_blank($_POST['clientip_conv']) && isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] )
1089 $mes .= '※コンビニ決済IPコードを�
1090 �力して下さい<br />';
1091 if( isset($_POST['batch']) && 'on' == $_POST['batch'] ) {
1092 if( isset($_POST['quickcharge']) && 'on' == $_POST['quickcharge'] ) {
1093 } else {
1094 $mes .= '※バッチ処理を利用する場合は、クイックチャージを利用するにして下さい<br />';
1095 $options['acting_settings']['zeus']['quickcharge'] = 'on';
1096 }
1097 }
1098 if( !isset($_POST['card_url']) || empty($_POST['card_url']) || !isset($_POST['ipaddrs']) || empty($_POST['ipaddrs']) || !isset($_POST['bank_url']) || empty($_POST['bank_url']) || !isset($_POST['conv_url']) || empty($_POST['conv_url']) )
1099 $mes .= '※設定が不正です!<br />';
1100
1101 if( WCUtils::is_blank($mes) ){
1102 $this->action_status = 'success';
1103 $this->action_message = __('options are updated','usces');
1104 $options['acting_settings']['zeus']['activate'] = 'on';
1105 if( 'on' == $options['acting_settings']['zeus']['card_activate'] ){
1106 $this->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)';
1107 }else{
1108 unset($this->payment_structure['acting_zeus_card']);
1109 }
1110 if( 'on' == $options['acting_settings']['zeus']['bank_activate'] ){
1111 $this->payment_structure['acting_zeus_bank'] = '�
1112 �金お任せ(ZEUS)';
1113 }else{
1114 unset($this->payment_structure['acting_zeus_bank']);
1115 }
1116 if( 'on' == $options['acting_settings']['zeus']['conv_activate'] ){
1117 $this->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)';
1118 }else{
1119 unset($this->payment_structure['acting_zeus_conv']);
1120 }
1121 $options['acting_settings']['zeus']['vercheck'] = '115';
1122 update_option( 'usces', $options );
1123 if( 'on' != $options['acting_settings']['zeus']['quickcharge'] ) {
1124 usces_clear_quickcharge( 'zeus_pcid' );
1125 }
1126 }else{
1127 $this->action_status = 'error';
1128 $this->action_message = __('Data have deficiency.','usces');
1129 $options['acting_settings']['zeus']['activate'] = 'off';
1130 unset($this->payment_structure['acting_zeus_card'], $this->payment_structure['acting_zeus_bank'], $this->payment_structure['acting_zeus_conv']);
1131 }
1132 ksort($this->payment_structure);
1133 update_option('usces_payment_structure',$this->payment_structure);
1134 break;
1135
1136 case 'remise':
1137 unset( $options['acting_settings']['remise'] );
1138 $options['acting_settings']['remise']['plan'] = isset($_POST['plan']) ? $_POST['plan'] : '';
1139 $options['acting_settings']['remise']['SHOPCO'] = isset($_POST['SHOPCO']) ? $_POST['SHOPCO'] : '';
1140 $options['acting_settings']['remise']['HOSTID'] = isset($_POST['HOSTID']) ? $_POST['HOSTID'] : '';
1141 $options['acting_settings']['remise']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1142 $options['acting_settings']['remise']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1143 $options['acting_settings']['remise']['card_pc_ope'] = isset($_POST['card_pc_ope']) ? $_POST['card_pc_ope'] : '';
1144 $options['acting_settings']['remise']['payquick'] = isset($_POST['payquick']) ? $_POST['payquick'] : '';
1145 $options['acting_settings']['remise']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : '';
1146 $options['acting_settings']['remise']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1147 $options['acting_settings']['remise']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1148 $options['acting_settings']['remise']['conv_pc_ope'] = isset($_POST['conv_pc_ope']) ? $_POST['conv_pc_ope'] : '';
1149 $options['acting_settings']['remise']['S_PAYDATE'] = isset($_POST['S_PAYDATE']) ? $_POST['S_PAYDATE'] : '';
1150 $options['acting_settings']['remise']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1151 $options['acting_settings']['remise']['send_url_pc'] = isset($_POST['send_url_pc']) ? $_POST['send_url_pc'] : '';
1152 $options['acting_settings']['remise']['send_url_cvs_mbl'] = isset($_POST['send_url_cvs_mbl']) ? $_POST['send_url_cvs_mbl'] : '';
1153 $options['acting_settings']['remise']['send_url_cvs_pc'] = isset($_POST['send_url_cvs_pc']) ? $_POST['send_url_cvs_pc'] : '';
1154 $options['acting_settings']['remise']['send_url_mbl_test'] = isset($_POST['send_url_mbl_test']) ? $_POST['send_url_mbl_test'] : '';
1155 $options['acting_settings']['remise']['send_url_pc_test'] = isset($_POST['send_url_pc_test']) ? $_POST['send_url_pc_test'] : '';
1156 $options['acting_settings']['remise']['send_url_cvs_mbl_test'] = isset($_POST['send_url_cvs_mbl_test']) ? $_POST['send_url_cvs_mbl_test'] : '';
1157 $options['acting_settings']['remise']['send_url_cvs_pc_test'] = isset($_POST['send_url_cvs_pc_test']) ? $_POST['send_url_cvs_pc_test'] : '';
1158 $options['acting_settings']['remise']['REMARKS3'] = isset($_POST['REMARKS3']) ? $_POST['REMARKS3'] : '';
1159
1160 if( isset($_POST['plan_remise']) && WCUtils::is_zero($_POST['plan_remise']) )
1161 $mes .= '※サービスプランを選択してください<br />';
1162 if( WCUtils::is_blank($_POST['SHOPCO']) )
1163 $mes .= '※加盟店コードを�
1164 �力して下さい<br />';
1165 if( WCUtils::is_blank($_POST['HOSTID']) )
1166 $mes .= '※ホスト番号を�
1167 �力して下さい<br />';
1168 if( isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] && empty($_POST['S_PAYDATE']) )
1169 $mes .= '※支払期限を�
1170 �力して下さい<br />';
1171 if( isset($_POST['card_pc_ope']) && 'public' == $_POST['card_pc_ope'] && empty($_POST['send_url_pc']) )
1172 $mes .= '※クレジットカード決済の本番URLを�
1173 �力して下さい<br />';
1174 if( isset($_POST['conv_pc_ope']) && 'public' == $_POST['conv_pc_ope'] && empty($_POST['send_url_cvs_pc']) )
1175 $mes .= '※コンビニ・電子マネー決済の本番URLを�
1176 �力して下さい<br />';
1177 if( !isset($_POST['REMARKS3']) || empty($_POST['REMARKS3']) )
1178 $mes .= '※設定が不正です!<br />';
1179
1180 if( WCUtils::is_blank($mes) ){
1181 //$this->zaction_status = 'success';
1182 $this->action_status = 'success';
1183 $this->action_message = __('options are updated','usces');
1184 $options['acting_settings']['remise']['activate'] = 'on';
1185 if( 'on' == $options['acting_settings']['remise']['card_activate'] ){
1186 $this->payment_structure['acting_remise_card'] = 'カード決済(ルミーズ)';
1187 }else{
1188 unset($this->payment_structure['acting_remise_card']);
1189 }
1190 if( 'on' == $options['acting_settings']['remise']['conv_activate'] ){
1191 $this->payment_structure['acting_remise_conv'] = 'コンビニ決済(ルミーズ)';
1192 }else{
1193 unset($this->payment_structure['acting_remise_conv']);
1194 }
1195 update_option('usces', $options);
1196 if( 'on' != $options['acting_settings']['remise']['payquick'] ) {
1197 usces_clear_quickcharge( 'remise_pcid' );
1198 }
1199
1200 }else{
1201 $this->action_status = 'error';
1202 $this->action_message = __('Data have deficiency.','usces');
1203 $options['acting_settings']['remise']['activate'] = 'off';
1204 unset($this->payment_structure['acting_remise_card']);
1205 unset($this->payment_structure['acting_remise_conv']);
1206 }
1207 ksort($this->payment_structure);
1208 update_option('usces_payment_structure',$this->payment_structure);
1209 break;
1210 //20101018ysk start
1211 case 'jpayment':
1212 unset( $options['acting_settings']['jpayment'] );
1213 $options['acting_settings']['jpayment']['aid'] = isset($_POST['aid']) ? $_POST['aid'] : '';
1214 $options['acting_settings']['jpayment']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1215 $options['acting_settings']['jpayment']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : '';
1216 $options['acting_settings']['jpayment']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1217 //$options['acting_settings']['jpayment']['webm_activate'] = isset($_POST['webm_activate']) ? $_POST['webm_activate'] : '';
1218 //$options['acting_settings']['jpayment']['bitc_activate'] = isset($_POST['bitc_activate']) ? $_POST['bitc_activate'] : '';
1219 //$options['acting_settings']['jpayment']['suica_activate'] = isset($_POST['suica_activate']) ? $_POST['suica_activate'] : '';
1220 $options['acting_settings']['jpayment']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : '';
1221 $options['acting_settings']['jpayment']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1222
1223 if( WCUtils::is_blank($_POST['aid']) )
1224 $mes .= '※店舗IDコードを�
1225 �力して下さい<br />';
1226 if( isset($_POST['card_activate']) && 'on' == $_POST['card_activate'] && empty($_POST['card_jb']) )
1227 $mes .= '※ジョブタイプを指定して下さい<br />';
1228
1229 if( WCUtils::is_blank($mes) ){
1230 $this->action_status = 'success';
1231 $this->action_message = __('options are updated','usces');
1232 $options['acting_settings']['jpayment']['activate'] = 'on';
1233 if( 'on' == $options['acting_settings']['jpayment']['card_activate'] ){
1234 $this->payment_structure['acting_jpayment_card'] = 'カード決済(J-Payment)';
1235 }else{
1236 unset($this->payment_structure['acting_jpayment_card']);
1237 }
1238 if( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ){
1239 $this->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(J-Payment)';
1240 }else{
1241 unset($this->payment_structure['acting_jpayment_conv']);
1242 }
1243 //if( 'on' == $options['acting_settings']['jpayment']['webm_activate'] ){
1244 // $this->payment_structure['acting_jpayment_webm'] = 'WebMoney決済(J-Payment)';
1245 //}else{
1246 // unset($this->payment_structure['acting_jpayment_webm']);
1247 //}
1248 //if( 'on' == $options['acting_settings']['jpayment']['bitc_activate'] ){
1249 // $this->payment_structure['acting_jpayment_bitc'] = 'BitCash決済(J-Payment)';
1250 //}else{
1251 // unset($this->payment_structure['acting_jpayment_bitc']);
1252 //}
1253 //if( 'on' == $options['acting_settings']['jpayment']['suica_activate'] ){
1254 // $this->payment_structure['acting_jpayment_suica'] = 'モバイルSuica決済(J-Payment)';
1255 //}else{
1256 // unset($this->payment_structure['acting_jpayment_suica']);
1257 //}
1258 if( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ){
1259 $this->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(J-Payment)';
1260 }else{
1261 unset($this->payment_structure['acting_jpayment_bank']);
1262 }
1263 update_option('usces', $options);
1264 }else{
1265 $this->action_status = 'error';
1266 $this->action_message = __('Data have deficiency.', 'usces');
1267 $options['acting_settings']['jpayment']['activate'] = 'off';
1268 unset($this->payment_structure['acting_jpayment_card']);
1269 unset($this->payment_structure['acting_jpayment_conv']);
1270 //unset($this->payment_structure['acting_jpayment_webm']);
1271 //unset($this->payment_structure['acting_jpayment_bitc']);
1272 //unset($this->payment_structure['acting_jpayment_suica']);
1273 unset($this->payment_structure['acting_jpayment_bank']);
1274 }
1275 ksort($this->payment_structure);
1276 update_option('usces_payment_structure', $this->payment_structure);
1277 break;
1278 //20101018ysk end
1279 //20110208ysk start
1280 case 'paypal':
1281 unset( $options['acting_settings']['paypal'] );
1282 $options['acting_settings']['paypal']['ec_activate'] = isset($_POST['ec_activate']) ? $_POST['ec_activate'] : '';
1283 $options['acting_settings']['paypal']['sandbox'] = isset($_POST['sandbox']) ? $_POST['sandbox'] : '';
1284 $options['acting_settings']['paypal']['user'] = isset($_POST['user']) ? $_POST['user'] : '';
1285 $options['acting_settings']['paypal']['pwd'] = isset($_POST['pwd']) ? $_POST['pwd'] : '';
1286 $options['acting_settings']['paypal']['signature'] = isset($_POST['signature']) ? $_POST['signature'] : '';
1287 //20110412ysk start
1288 $options['acting_settings']['paypal']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1289 //20110412ysk end
1290
1291 if( !isset($_POST['sandbox']) || empty($_POST['sandbox']) )
1292 $mes .= '※PayPalサーバーが不正です<br />';
1293 if( WCUtils::is_blank($_POST['user']) )
1294 $mes .= '※APIユーザー名を�
1295 �力して下さい<br />';
1296 if( WCUtils::is_blank($_POST['pwd']) )
1297 $mes .= '※APIパスワードを�
1298 �力して下さい<br />';
1299 if( WCUtils::is_blank($_POST['signature']) )
1300 $mes .= '※署名を�
1301 �力して下さい<br />';
1302
1303 if( WCUtils::is_blank($mes) ){
1304 $this->action_status = 'success';
1305 $this->action_message = __('options are updated','usces');
1306 if($options['acting_settings']['paypal']['sandbox'] == 1) {
1307 $options['acting_settings']['paypal']['api_host'] = 'api-3t.sandbox.paypal.com';
1308 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.sandbox.paypal.com/nvp';
1309 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
1310 } else {
1311 $options['acting_settings']['paypal']['api_host'] = 'api-3t.paypal.com';
1312 $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.paypal.com/nvp';
1313 $options['acting_settings']['paypal']['paypal_url'] = 'https://www.paypal.com/cgi-bin/webscr';
1314 }
1315 $options['acting_settings']['paypal']['activate'] = 'on';
1316 if( 'on' == $options['acting_settings']['paypal']['ec_activate'] ){
1317 $this->payment_structure['acting_paypal_ec'] = 'PayPal決済';
1318 }else{
1319 unset($this->payment_structure['acting_paypal_ec']);
1320 }
1321 update_option('usces', $options);
1322 }else{
1323 $this->action_status = 'error';
1324 $this->action_message = __('Data have deficiency.', 'usces');
1325 $options['acting_settings']['paypal']['activate'] = 'off';
1326 unset($this->payment_structure['acting_paypal_ec']);
1327 }
1328 ksort($this->payment_structure);
1329 update_option('usces_payment_structure', $this->payment_structure);
1330 break;
1331 //20110208ysk end
1332 //20120413ysk start
1333 case 'sbps':
1334 unset( $options['acting_settings']['sbps'] );
1335 $options['acting_settings']['sbps']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : '';
1336 $options['acting_settings']['sbps']['service_id'] = isset($_POST['service_id']) ? $_POST['service_id'] : '';
1337 $options['acting_settings']['sbps']['hash_key'] = isset($_POST['hash_key']) ? $_POST['hash_key'] : '';
1338 $options['acting_settings']['sbps']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1339 //$options['acting_settings']['sbps']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1340 $options['acting_settings']['sbps']['send_url_check'] = isset($_POST['send_url_check']) ? $_POST['send_url_check'] : '';
1341 $options['acting_settings']['sbps']['send_url_test'] = isset($_POST['send_url_test']) ? $_POST['send_url_test'] : '';
1342 $options['acting_settings']['sbps']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1343 $options['acting_settings']['sbps']['3d_secure'] = isset($_POST['3d_secure']) ? $_POST['3d_secure'] : '';
1344 $options['acting_settings']['sbps']['cust'] = isset($_POST['cust']) ? $_POST['cust'] : '';
1345 $options['acting_settings']['sbps']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : '';
1346 $options['acting_settings']['sbps']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1347 $options['acting_settings']['sbps']['payeasy_activate'] = isset($_POST['payeasy_activate']) ? $_POST['payeasy_activate'] : '';
1348 $options['acting_settings']['sbps']['wallet_yahoowallet'] = isset($_POST['wallet_yahoowallet']) ? $_POST['wallet_yahoowallet'] : '';
1349 $options['acting_settings']['sbps']['wallet_rakuten'] = isset($_POST['wallet_rakuten']) ? $_POST['wallet_rakuten'] : '';
1350 $options['acting_settings']['sbps']['wallet_paypal'] = isset($_POST['wallet_paypal']) ? $_POST['wallet_paypal'] : '';
1351 $options['acting_settings']['sbps']['wallet_netmile'] = isset($_POST['wallet_netmile']) ? $_POST['wallet_netmile'] : '';
1352 $options['acting_settings']['sbps']['wallet_alipay'] = isset($_POST['wallet_alipay']) ? $_POST['wallet_alipay'] : '';
1353 $options['acting_settings']['sbps']['mobile_docomo'] = isset($_POST['mobile_docomo']) ? $_POST['mobile_docomo'] : '';
1354 $options['acting_settings']['sbps']['mobile_softbank'] = isset($_POST['mobile_softbank']) ? $_POST['mobile_softbank'] : '';
1355 $options['acting_settings']['sbps']['mobile_auone'] = isset($_POST['mobile_auone']) ? $_POST['mobile_auone'] : '';
1356 $options['acting_settings']['sbps']['mobile_mysoftbank'] = isset($_POST['mobile_mysoftbank']) ? $_POST['mobile_mysoftbank'] : '';
1357
1358 if( WCUtils::is_blank($_POST['merchant_id']) )
1359 $mes .= '※マーチャントIDを�
1360 �力して下さい<br />';
1361 if( WCUtils::is_blank($_POST['service_id']) )
1362 $mes .= '※サービスIDを�
1363 �力して下さい<br />';
1364 if( WCUtils::is_blank($_POST['hash_key']) )
1365 $mes .= '※Hash KEYを�
1366 �力して下さい<br />';
1367 //if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1368 // $mes .= '※本番URLを�
1369 �力して下さい<br />';
1370
1371 if( WCUtils::is_blank($mes) ){
1372 $this->action_status = 'success';
1373 $this->action_message = __('options are updated','usces');
1374 $options['acting_settings']['sbps']['activate'] = 'on';
1375 if( 'on' == $options['acting_settings']['sbps']['card_activate'] ){
1376 $this->payment_structure['acting_sbps_card'] = 'カード決済(ソフトバンク・ペイメント)';
1377 }else{
1378 unset($this->payment_structure['acting_sbps_card']);
1379 }
1380 if( 'on' == $options['acting_settings']['sbps']['conv_activate'] ){
1381 $this->payment_structure['acting_sbps_conv'] = 'コンビニ決済(ソフトバンク・ペイメント)';
1382 }else{
1383 unset($this->payment_structure['acting_sbps_conv']);
1384 }
1385 if( 'on' == $options['acting_settings']['sbps']['payeasy_activate'] ){
1386 $this->payment_structure['acting_sbps_payeasy'] = 'ペイジー決済(ソフトバンク・ペイメント)';
1387 }else{
1388 unset($this->payment_structure['acting_sbps_payeasy']);
1389 }
1390 if( ( 'on' == $options['acting_settings']['sbps']['wallet_yahoowallet'] ) ||
1391 ( 'on' == $options['acting_settings']['sbps']['wallet_rakuten'] ) ||
1392 ( 'on' == $options['acting_settings']['sbps']['wallet_paypal'] ) ||
1393 ( 'on' == $options['acting_settings']['sbps']['wallet_netmile'] ) ||
1394 ( 'on' == $options['acting_settings']['sbps']['wallet_alipay'] ) ) {
1395 $options['acting_settings']['sbps']['wallet_activate'] = 'on';
1396 } else {
1397 $options['acting_settings']['sbps']['wallet_activate'] = 'off';
1398 }
1399 if( 'on' == $options['acting_settings']['sbps']['wallet_activate'] ){
1400 $this->payment_structure['acting_sbps_wallet'] = 'ウォレット決済(ソフトバンク・ペイメント)';
1401 }else{
1402 unset($this->payment_structure['acting_sbps_wallet']);
1403 }
1404 if( ( 'on' == $options['acting_settings']['sbps']['mobile_docomo'] ) ||
1405 ( 'on' == $options['acting_settings']['sbps']['mobile_softbank'] ) ||
1406 ( 'on' == $options['acting_settings']['sbps']['mobile_auone'] ) ||
1407 ( 'on' == $options['acting_settings']['sbps']['mobile_mysoftbank'] ) ) {
1408 $options['acting_settings']['sbps']['mobile_activate'] = 'on';
1409 } else {
1410 $options['acting_settings']['sbps']['mobile_activate'] = 'off';
1411 }
1412 if( 'on' == $options['acting_settings']['sbps']['mobile_activate'] ){
1413 $this->payment_structure['acting_sbps_mobile'] = '携帯キャリア決済(ソフトバンク・ペイメント)';
1414 }else{
1415 unset($this->payment_structure['acting_sbps_mobile']);
1416 }
1417 update_option('usces', $options);
1418 }else{
1419 $this->action_status = 'error';
1420 $this->action_message = __('Data have deficiency.','usces');
1421 $options['acting_settings']['sbps']['activate'] = 'off';
1422 unset($this->payment_structure['acting_sbps_card']);
1423 unset($this->payment_structure['acting_sbps_conv']);
1424 unset($this->payment_structure['acting_sbps_payeasy']);
1425 unset($this->payment_structure['acting_sbps_wallet']);
1426 unset($this->payment_structure['acting_sbps_mobile']);
1427 }
1428 ksort($this->payment_structure);
1429 update_option('usces_payment_structure', $this->payment_structure);
1430 break;
1431 //20120413ysk end
1432 //20120618ysk start
1433 case 'telecom':
1434 unset( $options['acting_settings']['telecom'] );
1435 $options['acting_settings']['telecom']['clientip'] = isset($_POST['clientip']) ? $_POST['clientip'] : '';
1436 $options['acting_settings']['telecom']['stype'] = isset($_POST['stype']) ? $_POST['stype'] : '';
1437 $options['acting_settings']['telecom']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1438 $options['acting_settings']['telecom']['edy_activate'] = isset($_POST['edy_activate']) ? $_POST['edy_activate'] : '';
1439
1440 if( WCUtils::is_blank($_POST['clientip']) )
1441 $mes .= '※クライアントIPを�
1442 �力して下さい<br />';
1443 if( WCUtils::is_blank($_POST['stype']) )
1444 $mes .= '※決済タイプを�
1445 �力して下さい<br />';
1446
1447 if( WCUtils::is_blank($mes) ){
1448 $this->action_status = 'success';
1449 $this->action_message = __('options are updated','usces');
1450 $options['acting_settings']['telecom']['activate'] = 'on';
1451 if( 'on' == $options['acting_settings']['telecom']['card_activate'] ){
1452 if( 'E' == $options['acting_settings']['telecom']['stype'][0] ) {
1453 $options['acting_settings']['telecom']['send_url'] = "https://www.credit-cgiserver.com/inetcredit/secure/order.pl";
1454 } else {
1455 $options['acting_settings']['telecom']['send_url'] = "https://secure.telecomcredit.co.jp/inetcredit/secure/order.pl";
1456 }
1457 $this->payment_structure['acting_telecom_card'] = 'カード決済(テレコムクレジット)';
1458 }else{
1459 unset($this->payment_structure['acting_telecom_card']);
1460 }
1461 if( 'on' == $options['acting_settings']['telecom']['edy_activate'] ){
1462 $options['acting_settings']['telecom']['send_url_edy'] = "https://secure.telecomcredit.co.jp/payment/edy/order.pl";
1463 $this->payment_structure['acting_telecom_edy'] = 'Edy決済(テレコムクレジット)';
1464 }else{
1465 unset($this->payment_structure['acting_telecom_edy']);
1466 }
1467 update_option('usces', $options);
1468 }else{
1469 $this->action_status = 'error';
1470 $this->action_message = __('Data have deficiency.','usces');
1471 $options['acting_settings']['telecom']['activate'] = 'off';
1472 unset($this->payment_structure['acting_telecom_card']);
1473 unset($this->payment_structure['acting_telecom_edy']);
1474 }
1475 ksort($this->payment_structure);
1476 update_option('usces_payment_structure', $this->payment_structure);
1477 break;
1478 //20120618ysk end
1479 //20121206ysk start
1480 case 'digitalcheck':
1481 unset( $options['acting_settings']['digitalcheck'] );
1482 $options['acting_settings']['digitalcheck']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1483 $options['acting_settings']['digitalcheck']['card_ip'] = isset($_POST['card_ip']) ? $_POST['card_ip'] : '';
1484 $options['acting_settings']['digitalcheck']['card_pass'] = isset($_POST['card_pass']) ? $_POST['card_pass'] : '';
1485 $options['acting_settings']['digitalcheck']['card_kakutei'] = isset($_POST['card_kakutei']) ? $_POST['card_kakutei'] : '';
1486 $options['acting_settings']['digitalcheck']['card_user_id'] = isset($_POST['card_user_id']) ? $_POST['card_user_id'] : '';
1487 $options['acting_settings']['digitalcheck']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : '';
1488 $options['acting_settings']['digitalcheck']['conv_ip'] = isset($_POST['conv_ip']) ? $_POST['conv_ip'] : '';
1489 $options['acting_settings']['digitalcheck']['conv_store'] = isset($_POST['conv_store']) ? $_POST['conv_store'] : array();
1490 $options['acting_settings']['digitalcheck']['conv_kigen'] = isset($_POST['conv_kigen']) ? $_POST['conv_kigen'] : '14';
1491
1492 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) {
1493 if( '' == trim($_POST['card_ip']) )
1494 $mes .= '※加盟店コードを�
1495 �力して下さい<br />';
1496 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1497 if( '' == trim($_POST['card_pass']) )
1498 $mes .= '※加盟店パスワードを�
1499 �力して下さい<br />';
1500 }
1501 }
1502 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) {
1503 if( '' == trim($_POST['conv_ip']) )
1504 $mes .= '※加盟店コードを�
1505 �力して下さい<br />';
1506 if( empty($_POST['conv_store']) )
1507 $mes .= '※利用コンビニを選択して下さい<br />';
1508 }
1509
1510 if( '' == $mes ){
1511 $this->action_status = 'success';
1512 $this->action_message = __('options are updated','usces');
1513 $options['acting_settings']['digitalcheck']['activate'] = 'on';
1514 if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ){
1515 $options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll";
1516 if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1517 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.digitalcheck.jp/settle/settlex/credit2.dll";
1518 } else {
1519 $options['acting_settings']['digitalcheck']['send_url_user_id'] = "";
1520 }
1521 $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(デジタルチェック)';
1522 }else{
1523 unset($this->payment_structure['acting_digitalcheck_card']);
1524 }
1525 if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ){
1526 //$options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle2/ubp3.dll";
1527 $options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll";
1528 $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(デジタルチェック)';
1529 }else{
1530 unset($this->payment_structure['acting_digitalcheck_conv']);
1531 }
1532 update_option('usces', $options);
1533 if( 'on' != $options['acting_settings']['digitalcheck']['card_user_id'] ) {
1534 usces_clear_quickcharge( 'digitalcheck_ip_user_id' );
1535 }
1536 }else{
1537 $this->action_status = 'error';
1538 $this->action_message = __('Data have deficiency.','usces');
1539 $options['acting_settings']['digitalcheck']['activate'] = 'off';
1540 unset($this->payment_structure['acting_digitalcheck_card']);
1541 unset($this->payment_structure['acting_digitalcheck_conv']);
1542 }
1543 ksort($this->payment_structure);
1544 update_option('usces_payment_structure', $this->payment_structure);
1545 break;
1546 //20121206ysk end
1547 //20130225ysk start
1548 case 'mizuho':
1549 unset( $options['acting_settings']['mizuho'] );
1550 $options['acting_settings']['mizuho']['shopid'] = isset($_POST['shopid']) ? $_POST['shopid'] : '';
1551 $options['acting_settings']['mizuho']['cshopid'] = isset($_POST['cshopid']) ? $_POST['cshopid'] : '';
1552 $options['acting_settings']['mizuho']['hash_pass'] = isset($_POST['hash_pass']) ? $_POST['hash_pass'] : '';
1553 $options['acting_settings']['mizuho']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : '';
1554 $options['acting_settings']['mizuho']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : '';
1555 $options['acting_settings']['mizuho']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : '';
1556 $options['acting_settings']['mizuho']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : '';
1557 $options['acting_settings']['mizuho']['conv1_activate'] = isset($_POST['conv1_activate']) ? $_POST['conv1_activate'] : '';
1558 $options['acting_settings']['mizuho']['conv2_activate'] = isset($_POST['conv2_activate']) ? $_POST['conv2_activate'] : '';
1559
1560 //if( 'on' == $options['acting_settings']['mizuho']['card_activate'] or 'on' == $options['acting_settings']['mizuho']['conv_activate'] ) {
1561 if( '' == trim($_POST['shopid']) )
1562 $mes .= '※加盟店コードを�
1563 �力して下さい<br />';
1564 if( '' == trim($_POST['cshopid']) )
1565 $mes .= '※加盟店サブコードを�
1566 �力して下さい<br />';
1567 if( '' == trim($_POST['hash_pass']) )
1568 $mes .= '※ハッシュ用パスワードを�
1569 �力して下さい<br />';
1570 //}
1571 if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) )
1572 $mes .= '※本番URLを�
1573 �力して下さい<br />';
1574 if( defined('WCEX_MOBILE') and isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url_mbl']) )
1575 $mes .= '※本番URL(携帯)を�
1576 �力して下さい<br />';
1577
1578 if( '' == $mes ) {
1579 $this->action_status = 'success';
1580 $this->action_message = __('options are updated','usces');
1581 $options['acting_settings']['mizuho']['activate'] = 'on';
1582 $options['acting_settings']['mizuho']['send_url_test'] = "https://210.161.141.207/mltbank/MBWebFrontPayment";
1583 if( defined('WCEX_MOBILE') ) $options['acting_settings']['mizuho']['send_url_mbl_test'] = "https://210.161.141.207/mltbank/iMBWebFrontPayment";
1584 if( 'on' == $options['acting_settings']['mizuho']['card_activate'] ) {
1585 $this->payment_structure['acting_mizuho_card'] = 'カード決済(みずほファクター)';
1586 } else {
1587 unset($this->payment_structure['acting_mizuho_card']);
1588 }
1589 if( 'on' == $options['acting_settings']['mizuho']['conv1_activate'] ) {
1590 $this->payment_structure['acting_mizuho_conv1'] = 'コンビニ・ウェルネット決済(みずほファクター)';
1591 } else {
1592 unset($this->payment_structure['acting_mizuho_conv1']);
1593 }
1594 if( 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) {
1595 $this->payment_structure['acting_mizuho_conv2'] = 'コンビニ・セブンイレブン決済(みずほファクター)';
1596 } else {
1597 unset($this->payment_structure['acting_mizuho_conv2']);
1598 }
1599 update_option('usces', $options);
1600 } else {
1601 $this->action_status = 'error';
1602 $this->action_message = __('Data have deficiency.','usces');
1603 $options['acting_settings']['mizuho']['activate'] = 'off';
1604 unset($this->payment_structure['acting_mizuho_card']);
1605 unset($this->payment_structure['acting_mizuho_conv1']);
1606 unset($this->payment_structure['acting_mizuho_conv2']);
1607 }
1608 ksort($this->payment_structure);
1609 update_option('usces_payment_structure', $this->payment_structure);
1610 break;
1611 //20130225ysk end
1612 }
1613
1614 }
1615
1616 $this->options = get_option('usces');
1617
1618 require_once(USCES_PLUGIN_DIR . '/includes/admin_settlement.php');
1619 }
1620
1621 /********************************************************************************/
1622 function selected( $selected, $current) {
1623 if ( $selected == $current)
1624 echo ' selected="selected"';
1625 }
1626 /********************************************************************************/
1627
1628 function usces_session_start() {
1629 $options = get_option('usces');
1630 if( !isset($options['usces_key']) || empty($options['usces_key']) ){
1631 $options['usces_key'] = uniqid('uk');
1632 update_option('usces', $options);
1633 }
1634
1635 if(defined( 'USCES_KEY' )){
1636 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1637 session_name( 'adm'.USCES_KEY );
1638 }else{
1639 session_name( USCES_KEY );
1640 }
1641 }else{
1642 if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){
1643 session_name( 'adm'.$options['usces_key'] );
1644 }else{
1645 session_name( $options['usces_key'] );
1646 }
1647 }
1648 if(isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid'])) {
1649 $sessid = $_GET['uscesid'];
1650 $sessid = $this->uscesdc($sessid);
1651 session_id($sessid);
1652 }
1653
1654 @session_start();
1655
1656 //20111222ysk start 0000367
1657 //if ( !isset($_SESSION['usces_member']) ){
1658 if ( !isset($_SESSION['usces_member']) || $options['membersystem_state'] != 'activate' ){
1659 //20111222ysk end
1660 $_SESSION['usces_member'] = array();
1661 }
1662
1663 if(!isset($_SESSION['usces_checked_business_days']))
1664 $this->update_business_days();
1665 }
1666
1667 function usces_cookie() {
1668 if(is_admin()) return;
1669
1670 $actionflag = false;
1671 $sess = NULL;
1672 $addr = NULL;
1673 $rckid = NULL;
1674 $none = NULL;
1675 $cookie = $this->get_cookie();
1676
1677 if( isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid']) ){
1678 $sessid = base64_decode(urldecode($_GET['uscesid']));
1679 list($sess, $addr, $rckid, $none) = explode('_', $sessid, 4);
1680 }
1681 if('acting' == $addr) return;
1682
1683 if( apply_filters( 'usces_filter_cookie', false) ) return;
1684
1685 //There is a need to consider.
1686 return;
1687
1688 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
1689
1690 $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
1691 $sslid = isset($cookie['sslid']) ? $cookie['sslid'] : NULL;
1692 $option = get_option('usces');
1693 $parsed = parse_url(get_option('home'));
1694 $home = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1695 $parsed = parse_url($option['ssl_url']);
1696 $sslhome = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : '');
1697
1698 //usces_log('refer : '.$refer, 'acting_transaction.log');
1699 // usces_log('sslid : '.$sslid, 'acting_transaction.log');
1700 // usces_log('rckid : '.$rckid, 'acting_transaction.log');
1701 // usces_log('usces_cookieid : '.$_SESSION['usces_cookieid'], 'acting_transaction.log');
1702 // usces_log('request : '.print_r($_SERVER['REQUEST_URI'],true), 'acting_transaction.log');
1703
1704 if( empty($refer) || (false === strpos($refer, $home) && false === strpos($refer, $sslhome)) ){
1705 if( !empty($sslid) && !empty($rckid) && $sslid === $rckid ){
1706 $actionflag = true;
1707 }else{
1708 $actionflag = false;
1709 }
1710 }else{
1711 if( !empty($sslid) && $sslid !== $rckid ){
1712 $actionflag = false;
1713 }else{
1714 $actionflag = true;
1715 }
1716 }
1717
1718
1719 if( $actionflag ){
1720 $values = array(
1721 'id' => $rckid,
1722 'sslid' => $rckid,
1723 'name' => '',
1724 'rme' => ''
1725 );
1726 if( 'acting' !== $rckid ){
1727 $this->set_cookie($values);
1728 }
1729 }else{
1730 if( 'acting' !== $rckid ){
1731 unset($_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] );
1732 wp_redirect( 'http://'.$home );
1733 }
1734 }
1735 }else{
1736 if( !isset($cookie['id']) || WCUtils::is_blank($cookie['id']) ) {
1737 $values = array(
1738 'id' => md5(uniqid(rand(), true)),
1739 'name' => '',
1740 'rme' => ''
1741 );
1742 $this->set_cookie($values);
1743 $_SESSION['usces_cookieid'] = $values['id'];
1744 } else {
1745 if( !isset($_SESSION['usces_cookieid']) || $_SESSION['usces_cookieid'] != $cookie['id'])
1746 $_SESSION['usces_cookieid'] = $cookie['id'];
1747 }
1748
1749 $actionflag = true;
1750 }
1751
1752 }
1753
1754 function set_cookie($values){
1755 $value = serialize($values);
1756 $timeout = time()+7*86400;
1757 $domain = $_SERVER['SERVER_NAME'];
1758 $res = setcookie('usces_cookie', $value, $timeout, USCES_COOKIEPATH, $domain);
1759 }
1760
1761 function get_cookie() {
1762 $values = isset($_COOKIE['usces_cookie']) ? unserialize(stripslashes($_COOKIE['usces_cookie'])) : NULL;
1763 return $values;
1764 }
1765
1766 function get_access( $key, $type, $date ) {
1767 global $wpdb;
1768 $table_name = $wpdb->prefix . "usces_access";
1769
1770 $query = $wpdb->prepare("SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date);
1771 $value = $wpdb->get_var( $query );
1772 if( !$value ){
1773 $res = NULL;
1774 }else{
1775 $res = unserialize($value);
1776 }
1777
1778 return $res;
1779 }
1780
1781 function get_access_piriod( $key, $type, $startday, $endday ) {
1782 global $wpdb;
1783 $table_name = $wpdb->prefix . "usces_access";
1784 //$wpdb->show_errors();
1785 $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);
1786 $res = $wpdb->get_results( $query, ARRAY_A );
1787
1788 return $res;
1789 }
1790
1791 function update_access( $array ) {
1792 global $wpdb;
1793 $table_name = $wpdb->prefix . "usces_access";
1794
1795 $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']);
1796 $res = $wpdb->get_var( $query );
1797 //$wpdb->show_errors();
1798 if(empty($res)){
1799 $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']);
1800 $wpdb->query( $query );
1801 }else{
1802 $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']);
1803 $wpdb->query( $query );
1804 }
1805 }
1806
1807 function get_uscesid( $flag = true) {
1808
1809 $sessname = session_name();
1810 $sessid = session_id();
1811 $sessid = $this->uscescv($sessid, $flag);
1812 return $sessid;
1813 }
1814
1815 function shop_head() {
1816 global $post;
1817 $this->item = $post;
1818 $no_cart_css = isset($this->options['system']['no_cart_css']) ? $this->options['system']['no_cart_css'] : 0;
1819
1820 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1821 $css_url = USCES_FRONT_PLUGIN_URL . '/css/usces_cart.css';
1822 }else{
1823 $css_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/css/usces_cart.css';
1824 }
1825 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) ){
1826 echo " <meta name='robots' content='noindex,nofollow' />\n";
1827 wp_print_scripts( array( 'sack' ));
1828 }
1829 if( !$no_cart_css ){
1830 echo '<link href="' . $css_url . '" rel="stylesheet" type="text/css" />';
1831 }
1832 if( file_exists(get_stylesheet_directory() . '/usces_cart.css') ){
1833 echo '<link href="' . get_stylesheet_directory_uri() . '/usces_cart.css" rel="stylesheet" type="text/css" />';
1834 }
1835 }
1836
1837 function shop_foot() {
1838 global $current_user;
1839 $item = $this->item;
1840 if( empty($item) ){
1841 $item->ID = 0;
1842 $item->post_mime_type = '';
1843 }
1844 get_currentuserinfo();
1845 if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
1846 $javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js';
1847 }else{
1848 $javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js';
1849 }
1850 // $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')) : '';
1851 $this->previous_url = isset($_SESSION['usces_previous_url']) ? $_SESSION['usces_previous_url'] : get_home_url();
1852
1853 // usces_log('post_type : '.$item->post_mime_type, 'test.log');
1854 // usces_log('is_single : '.(is_single() ? 'true' : 'false'), 'test.log');
1855
1856 if( $this->use_js && empty($this->item) && !is_admin() ) :
1857 ?>
1858 <script type='text/javascript'>
1859 /* <![CDATA[ */
1860 uscesL10n = {
1861 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
1862 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>"
1863 }
1864 /* ]]> */
1865 </script>
1866 <?php elseif( $this->use_js && !empty($this->item) ) :
1867
1868 $ioptkeys = $this->get_itemOptionKey( $item->ID );
1869 $mes_opts_str = "";
1870 $key_opts_str = "";
1871 $opt_means = "";
1872 $opt_esse = "";
1873 if($ioptkeys){
1874 foreach($ioptkeys as $key => $value){
1875 $optValues = $this->get_itemOptions( $value, $item->ID );
1876 if($optValues['means'] < 2){
1877 $mes_opts_str .= "'" . sprintf(__("Chose the %s", 'usces'), esc_js($value)) . "',";
1878 }else{
1879 $mes_opts_str .= "'" . sprintf(__("Input the %s", 'usces'), esc_js($value)) . "',";
1880 }
1881 $key_opts_str .= "'" . urlencode(esc_js($value)) . "',";
1882 $opt_means .= "'" . esc_js($optValues['means']) . "',";
1883 $opt_esse .= "'" . esc_js($optValues['essential']) . "',";
1884 }
1885 $mes_opts_str = rtrim($mes_opts_str, ',');
1886 $key_opts_str = rtrim($key_opts_str, ',');
1887 $opt_means = rtrim($opt_means, ',');
1888 $opt_esse = rtrim($opt_esse, ',');
1889 }
1890 //$itemRestriction = get_post_custom_values('_itemRestriction', $item->ID);
1891 $itemRestriction = get_post_meta($item->ID, '_itemRestriction', true);
1892
1893 ?>
1894 <script type='text/javascript'>
1895 /* <![CDATA[ */
1896 uscesL10n = {
1897 <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?>
1898 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>",
1899 'post_id': "<?php echo $item->ID; ?>",
1900 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
1901 'is_cart_row': <?php echo ( (0 < $this->cart->num_row()) ? 'true' : 'false'); ?>,
1902 'opt_esse': new Array( <?php echo $opt_esse; ?> ),
1903 'opt_means': new Array( <?php echo $opt_means; ?> ),
1904 'mes_opts': new Array( <?php echo $mes_opts_str; ?> ),
1905 'key_opts': new Array( <?php echo $key_opts_str; ?> ),
1906 'previous_url': "<?php echo $this->previous_url; ?>",
1907 'itemRestriction': "<?php echo $itemRestriction; ?>"
1908 }
1909 /* ]]> */
1910 </script>
1911 <script type='text/javascript' src='<?php echo $javascript_url; ?>'></script>
1912 <?php endif; ?>
1913 <?php //if( !is_home() && !is_front_page() && $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || ('item' == $item->post_mime_type)) ) : ?>
1914 <?php if( $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || (is_singular() && 'item' == $item->post_mime_type)) ) : ?>
1915 <script type='text/javascript'>
1916 (function($) {
1917 uscesCart = {
1918 intoCart : function (post_id, sku) {
1919
1920 var zaikonum = document.getElementById("zaikonum["+post_id+"]["+sku+"]").value;
1921 var zaiko = document.getElementById("zaiko["+post_id+"]["+sku+"]").value;
1922 if( (zaiko != '0' && zaiko != '1') || parseInt(zaikonum) == 0 ){
1923 alert('<?php _e('temporaly out of stock now', 'usces'); ?>');
1924 return false;
1925 }
1926
1927 var mes = '';
1928 if(document.getElementById("quant["+post_id+"]["+sku+"]")){
1929 var quant = document.getElementById("quant["+post_id+"]["+sku+"]").value;
1930 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
1931 mes += "<?php _e('enter the correct amount', 'usces'); ?>\n";
1932 }
1933 var checknum = '';
1934 var checkmode = '';
1935 if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
1936 checknum = uscesL10n.itemRestriction;
1937 checkmode ='rest';
1938 } else if( parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
1939 checknum = zaikonum;
1940 checkmode ='zaiko';
1941 } else if( (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) {
1942 checknum = zaikonum;
1943 checkmode ='zaiko';
1944 } else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum == '' ) {
1945 checknum = uscesL10n.itemRestriction;
1946 checkmode ='rest';
1947 }
1948
1949
1950 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
1951 if(checkmode == 'rest'){
1952 mes += <?php _e("'This article is limited by '+checknum+' at a time.'", 'usces'); ?>+"\n";
1953 }else{
1954 mes += <?php _e("'Stock is remainder '+checknum+'.'", 'usces'); ?>+"\n";
1955 }
1956 }
1957 }
1958 for(i=0; i<uscesL10n.key_opts.length; i++){
1959 var skuob = document.getElementById("itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]");
1960 if( uscesL10n.opt_esse[i] == '1' ){
1961
1962 if( uscesL10n.opt_means[i] < 2 && skuob.value == '#NONE#' ){
1963 mes += uscesL10n.mes_opts[i]+"\n";
1964 }else if( uscesL10n.opt_means[i] >= 2 && skuob.value == '' ){
1965 mes += uscesL10n.mes_opts[i]+"\n";
1966 }
1967 }
1968 }
1969
1970 <?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); //Unavailable ?>
1971 <?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?>
1972
1973 if( mes != '' ){
1974 alert( mes );
1975 return false;
1976 }else{
1977 <?php echo apply_filters('usces_filter_js_intoCart', "return true;\n", $item->ID, NULL); ?>
1978 }
1979 },
1980
1981 upCart : function () {
1982
1983 var zaikoob = $("input[name*='zaikonum']");
1984 var quantob = $("input[name*='quant']");
1985 var postidob = $("input[name*='itempostid']");
1986 var skuob = $("input[name*='itemsku']");
1987
1988 var zaikonum = '';
1989 var zaiko = '';
1990 var quant = '';
1991 var mes = '';
1992 var checknum = '';
1993 var post_id = '';
1994 var sku = '';
1995 var itemRestriction = '';
1996
1997 var ct = zaikoob.length;
1998 for(var i=0; i< ct; i++){
1999 post_id = postidob[i].value;
2000 sku = skuob[i].value;
2001 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2002 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2003
2004 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2005 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2006 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2007 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2008 }
2009 var checknum = '';
2010 var checkmode = '';
2011 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2012 checknum = itemRestriction;
2013 checkmode ='rest';
2014 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2015 checknum = zaikonum;
2016 checkmode ='zaiko';
2017 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2018 checknum = zaikonum;
2019 checkmode ='zaiko';
2020 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2021 checknum = itemRestriction;
2022 checkmode ='rest';
2023 }
2024 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2025 if(checkmode == 'rest'){
2026 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2027 }else{
2028 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2029 }
2030 }
2031 }
2032 }
2033
2034 <?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); //Unavailable ?>
2035 <?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?>
2036
2037 if( mes != '' ){
2038 alert( mes );
2039 return false;
2040 }else{
2041 <?php echo apply_filters('usces_filter_js_upCart', "return true;\n", $item->ID, NULL); ?>
2042 }
2043 },
2044
2045 cartNext : function () {
2046
2047 var zaikoob = $("input[name*='zaikonum']");
2048 var quantob = $("input[name*='quant']");
2049 var postidob = $("input[name*='itempostid']");
2050 var skuob = $("input[name*='itemsku']");
2051
2052 var zaikonum = '';
2053 var zaiko = '';
2054 var quant = '';
2055 var mes = '';
2056 var checknum = '';
2057 var post_id = '';
2058 var sku = '';
2059 var itemRestriction = '';
2060
2061 var ct = zaikoob.length;
2062 for(var i=0; i< ct; i++){
2063 post_id = postidob[i].value;
2064 sku = skuob[i].value;
2065 itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
2066 zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2067
2068 quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
2069 if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){
2070 if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
2071 mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n";
2072 }
2073 var checknum = '';
2074 var checkmode = '';
2075 if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2076 checknum = itemRestriction;
2077 checkmode ='rest';
2078 } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
2079 checknum = zaikonum;
2080 checkmode ='zaiko';
2081 } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
2082 checknum = zaikonum;
2083 checkmode ='zaiko';
2084 } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) {
2085 checknum = itemRestriction;
2086 checkmode ='rest';
2087 }
2088
2089 if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
2090 if(checkmode == 'rest'){
2091 mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n";
2092 }else{
2093 mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n";
2094 }
2095 }
2096 }
2097 }
2098 if( mes != '' ){
2099 alert( mes );
2100 return false;
2101 }else{
2102 return true;
2103 }
2104 },
2105
2106 previousCart : function () {
2107 location.href = uscesL10n.previous_url;
2108 },
2109
2110 settings: {
2111 url: uscesL10n.ajaxurl,
2112 type: 'POST',
2113 cache: false,
2114 success: function(data, dataType){
2115 //$("tbody#item-opt-list").html( data );
2116 },
2117 error: function(msg){
2118 //$("#ajax-response").html(msg);
2119 }
2120 },
2121
2122 changeStates : function( country ) {
2123 var s = this.settings;
2124 s.data = "action=change_states_ajax&country=" + country;
2125 s.success = function(data, dataType){
2126 if( 'error' == data ){
2127 alert('error');
2128 }else{
2129 $("select#pref").html( data );
2130 }
2131 };
2132 s.error = function(msg){
2133 alert("error");
2134 };
2135 $.ajax( s );
2136 return false;
2137 },
2138
2139 isNum : function (num) {
2140 if (num.match(/[^0-9]/g)) {
2141 return false;
2142 }
2143 return true;
2144 },
2145 purchase : 0
2146 };
2147 $("#country").change(function () {
2148 var country = $("#country option:selected").val();
2149 $("#newcharging_type option:selected").val()
2150 uscesCart.changeStates( country );
2151 });
2152 $("#purchase_form").submit(function () {
2153 if( 0 == uscesCart.purchase ){
2154 uscesCart.purchase = 1;
2155 return true;
2156 }else{
2157 $("#purchase_button").attr("disabled", "disabled");
2158 $("#back_button").attr("disabled", "disabled");
2159 return false;
2160 }
2161 });
2162
2163 })(jQuery);
2164 </script>
2165 <?php endif; ?>
2166 <?php
2167 usces_states_form_js();
2168 }
2169
2170 function admin_head() {
2171 global $wp_version;
2172 $payments_str = '';
2173 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
2174 foreach ( (array)$payments as $id => $array ) {
2175 $payments_str .= "'" . esc_js($array['name']) . "': '" . esc_js($array['settlement']) . "', ";
2176 }
2177 $payments_str .= "'" . __('Transfer (prepayment)', 'usces') . "': 'transferAdvance', ";
2178 $payments_str .= "'" . __('Transfer (postpay)', 'usces') . "': 'transferDeferred', ";
2179 $payments_str .= "'" . __('COD', 'usces') . "': 'COD', ";
2180 $payments_str = rtrim($payments_str, ', ');
2181 $wcex_str = '';
2182 $wcex = usces_get_wcex();
2183 foreach ( (array)$wcex as $key => $values ) {
2184 $wcex_str .= "'" . esc_js($key) . "-" . esc_js($values['version']) . "', ";
2185 }
2186 $wcex_str = rtrim($wcex_str, ', ');
2187 if ( version_compare($wp_version, '3.4', '>=') ){
2188 $theme_ob = wp_get_theme();
2189 $theme['Name'] = esc_js($theme_ob->get('Name'));
2190 $theme['Version'] = esc_js($theme_ob->get('Version'));
2191 }else{
2192 $theme = get_theme_data( get_stylesheet_directory().'/style.css' );//20120618ysk
2193 }
2194 ?>
2195
2196 <link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" />
2197 <script type='text/javascript'>
2198 /* <![CDATA[ */
2199 uscesL10n = {
2200 'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php",
2201 'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>",
2202 'version': "<?php echo USCES_VERSION; ?>",
2203 'wcid': "<?php echo get_option('usces_wcid'); ?>",
2204 'locale': '<?php echo get_locale(); ?>',
2205 'cart_number': "<?php echo get_option('usces_cart_number'); ?>",
2206 'purchase_limit': "<?php echo $this->options['purchase_limit']; ?>",
2207 'point_rate': "<?php echo $this->options['point_rate']; ?>",
2208 'shipping_rule': "<?php echo $this->options['shipping_rule']; ?>",
2209 'theme': "<?php echo $theme['Name'] . '-' . $theme['Version']; ?>",
2210 'wcex': new Array( <?php echo $wcex_str; ?> ),
2211 'now_loading': "<?php _e('now loading', 'usces'); ?>"
2212 };
2213 uscesPayments = {<?php echo $payments_str; ?>};
2214 /* ]]> */
2215 </script>
2216 <script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js'></script>
2217 <?php
2218 if($this->action_status == 'edit' || $this->action_status == 'editpost'){
2219 ?>
2220 <link rel='stylesheet' href='<?php echo site_url(); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' />
2221 <?php
2222 }
2223 if( isset($_REQUEST['page']) ){
2224 switch( $_REQUEST['page'] ){
2225 case 'usces_initial':
2226 ?>
2227 <script type='text/javascript'>
2228 /* <![CDATA[ */
2229 usces_ini = {
2230 'cod_type': "<?php if( 'change' == $this->options['cod_type'] ) {echo 'change';}else{echo 'fix';} ?>",
2231 'cod_type_fix': "<?php echo esc_js(__('Fixation C.O.D.', 'usces')); ?>",
2232 'cod_type_change': "<?php echo esc_js(__('Variable C.O.D.', 'usces')); ?>",
2233 'cod_unit': "<?php echo esc_js(__('dollars', 'usces')); ?>",
2234 'cod_failure': "<?php echo esc_js(__('failure in update', 'usces')); ?>",
2235 'cod_updated': "<?php echo esc_js(__('options are updated', 'usces')); ?>",
2236 'cod_limit': "<?php echo esc_js(__('A value of the amount of upper limit is dirty.', 'usces')); ?>"
2237 };
2238 /* ]]> */
2239 </script>
2240 <?php
2241 break;
2242 case 'usces_itemnew':
2243 case 'usces_itemedit':
2244 ?>
2245 <style type="text/css">
2246 <!--
2247 #usces_mess {
2248 color: #FF0000;
2249 font-weight: bold;
2250 }
2251 -->
2252 </style>
2253 <?php
2254 break;
2255 }
2256 }
2257 ?>
2258 <?php
2259 if( is_admin() && ( (isset($_GET['order_action']) && 'newpost' == $_GET['order_action'])
2260 || (isset($_GET['page']) && 'usces_ordernew' == $_GET['page'])
2261 || (isset($_GET['order_action']) && 'edit' == $_GET['order_action'])
2262 || (isset($_GET['order_action']) && 'editpost' == $_GET['order_action'])
2263 || (isset($_GET['member_action']) && 'edit' == $_GET['member_action'])
2264 || (isset($_GET['member_action']) && 'editpost' == $_GET['member_action'])) ) :
2265 switch( $_GET['page'] ){
2266 case 'usces_ordernew':
2267 case 'usces_orderlist':
2268 $admin_page = 'order';
2269 break;
2270 case 'usces_memberlist':
2271 $admin_page = 'member';
2272 break;
2273 }
2274 ?>
2275 <script type='text/javascript'>
2276 jQuery(function($) {
2277 uscesForm = {
2278 settings: {
2279 url: uscesL10n.requestFile,
2280 type: 'POST',
2281 cache: false,
2282 success: function(data, dataType){
2283 //$("tbody#item-opt-list").html( data );
2284 },
2285 error: function(msg){
2286 //$("#ajax-response").html(msg);
2287 }
2288 },
2289
2290 changeStates : function( country, type ) {
2291 var s = this.settings;
2292 s.data = "action=change_states_ajax&country=" + country;
2293 s.success = function(data, dataType){
2294 if( 'error' == data ){
2295 alert('error');
2296 }else{
2297 $("select#" + type + "_pref").html( data );
2298 if( customercountry == country && 'customer' == type ){
2299 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2300 }else if( deliverycountry == country && 'delivery' == type ){
2301 $("#" + type + "_pref").attr({selectedIndex:deliverystate});
2302 }else if( customercountry == country && 'member' == type ){
2303 $("#" + type + "_pref").attr({selectedIndex:customerstate});
2304 }
2305 }
2306 };
2307 s.error = function(msg){
2308 alert("error");
2309 };
2310 $.ajax( s );
2311 return false;
2312 },
2313
2314 isNum : function (num) {
2315 if (num.match(/[^0-9]/g)) {
2316 return false;
2317 }
2318 return true;
2319 }
2320 };
2321 <?php
2322 if( 'order' == $admin_page ){
2323 ?>
2324 if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) {
2325 var customerstate = $("#customer_pref").get(0).selectedIndex;
2326 var customercountry = $("#customer_country").val();
2327 var deliverystate = $("#delivery_pref").get(0).selectedIndex;
2328 var deliverycountry = $("#delivery_country").val();
2329
2330 $("#customer_country").change(function () {
2331 var country = $("#customer_country option:selected").val();
2332 uscesForm.changeStates( country, 'customer' );
2333 });
2334 $("#delivery_country").change(function () {
2335 var country = $("#delivery_country option:selected").val();
2336 uscesForm.changeStates( country, 'delivery' );
2337 });
2338 }
2339 <?php
2340 }else if( 'member' == $admin_page ){
2341 ?>
2342 if( undefined != $("#member_pref").get(0) ) {
2343 var customerstate = $("#member_pref").get(0).selectedIndex;
2344 var customercountry = $("#member_country").val();
2345 var deliverystate = '';
2346 var deliverycountry = '';
2347
2348 $("#member_country").change(function () {
2349 var country = $("#member_country option:selected").val();
2350 uscesForm.changeStates( country, 'member' );
2351 });
2352 }
2353 <?php
2354 }
2355 ?>
2356 });
2357 </script>
2358 <?php
2359 endif;
2360 }
2361
2362 function main() {
2363 global $wpdb, $wp_locale, $wp_version, $post_ID;
2364 global $wp_query, $usces_action, $post, $action, $editing;
2365
2366 update_option('usces_shipping_rule', apply_filters('usces_filter_shipping_rule', get_option('usces_shipping_rule')));
2367 $this->shipping_rule = get_option('usces_shipping_rule');
2368
2369 // $_wp_http_referer = isset($_POST['_wp_http_referer']) ? $_POST['_wp_http_referer'] : 'a';
2370 // if( isset($_POST) && 1 !== preg_match('/(?:plugin|theme)-editor\.php/', $_wp_http_referer) ){
2371 // $_POST = $this->stripslashes_deep_post($_POST);
2372 // }
2373
2374 if( !is_admin() ){
2375 $this->usces_cookie();
2376 }
2377 $this->make_url();
2378
2379 //usces_log('HTTP_REFERER : '.$_SERVER['HTTP_REFERER'], 'acting_transaction.log');
2380 //usces_log('REQUEST_URI : '.$_SERVER['REQUEST_URI'], 'acting_transaction.log');
2381
2382 do_action('usces_main');
2383 $this->update_table();
2384
2385
2386 // if( 'customer' == $this->page ){
2387 // header("Pragma: private");
2388 // header("Cache-Control: private");
2389 // }else{
2390 // header("Pragma: no-cache");
2391 // header("Cache-Control: no-cache");
2392 // }
2393
2394
2395 //var_dump($_REQUEST);
2396 require_once(USCES_PLUGIN_DIR . '/classes/cart.class.php');
2397 $this->cart = new usces_cart();
2398
2399 do_action('usces_after_cart_instant');
2400
2401 if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate' ){
2402 $post_id = (int)$_GET['post'];
2403 $new_id = usces_item_dupricate($post_id);
2404 $ref = isset($_REQUEST['usces_referer']) ? urlencode($_REQUEST['usces_referer']) : '';
2405 $url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref;
2406 wp_redirect($url);
2407 exit;
2408 }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'itemcsv' ){
2409 $filename = usces_item_uploadcsv();
2410 $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&regfile='.$filename;
2411 wp_redirect($url);
2412 exit;
2413 }
2414 //20110208ysk start
2415 if('on' == $this->options['acting_settings']['paypal']['ec_activate']) {
2416 require_once(USCES_PLUGIN_DIR . '/classes/paymentPaypal.class.php');
2417 $this->paypal = new usces_paypal();
2418 }
2419 //20110208ysk end
2420
2421 $this->ad_controller();
2422 //$this->controller();
2423
2424
2425
2426 if( isset($_GET['page']) && $_GET['page'] == 'usces_itemnew'){
2427 $itemnew = 'new';
2428 }else{
2429 $itemnew = '';
2430 }
2431
2432 wp_enqueue_script('jquery');
2433
2434 if( is_admin() && isset($_REQUEST['page']) && ((isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') || $itemnew == 'new' || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'editpost'))) {
2435
2436 if(isset($_REQUEST['action']) && $_REQUEST['action'] != 'editpost' && $itemnew == 'new'){
2437 if ( version_compare($wp_version, '3.0-beta', '>') ){
2438 if ( !isset($_GET['post_type']) )
2439 $post_type = 'post';
2440 elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
2441 $post_type = $_GET['post_type'];
2442 else
2443 wp_die( __('Invalid post type') );
2444 $post_type_object = get_post_type_object($post_type);
2445 $editing = true;
2446 // if ( current_user_can($post_type_object->edit_type_cap) ) {
2447 $post = $this->get_default_post_to_edit30( $post_type, true );
2448 $post_ID = $post->ID;
2449 // }
2450
2451 }else{
2452 $post = $this->get_default_post_to_edit();
2453 }
2454 }else{
2455 if ( version_compare($wp_version, '3.0-beta', '>') ){
2456 if ( isset($_GET['post']) )
2457 $post_id = (int) $_GET['post'];
2458 elseif ( isset($_POST['post_ID']) )
2459 $post_id = (int) $_POST['post_ID'];
2460 else
2461 $post_id = 0;
2462 $post_ID = $post_id;
2463 $post = null;
2464 $post_type_object = null;
2465 $post_type = null;
2466 if ( $post_id ) {
2467 $post = get_post($post_id);
2468 if ( $post ) {
2469 $post_type_object = get_post_type_object($post->post_type);
2470 if ( $post_type_object ) {
2471 $post_type = $post->post_type;
2472 $current_screen->post_type = $post->post_type;
2473 $current_screen->id = $current_screen->post_type;
2474 }
2475 }
2476 } elseif ( isset($_POST['post_type']) ) {
2477 $post_type_object = get_post_type_object($_POST['post_type']);
2478 if ( $post_type_object ) {
2479 $post_type = $post_type_object->name;
2480 $current_screen->post_type = $post_type;
2481 $current_screen->id = $current_screen->post_type;
2482 }
2483 }
2484
2485
2486 // $post = get_post( $post_id, OBJECT, 'edit' );
2487 // if ( $post->post_type == 'page' )
2488 // $post->page_template = get_post_meta( $id, '_wp_page_template', true );
2489
2490 }else{
2491 if(isset($_GET['post'])){
2492 $post_ID = (int) $_GET['post'];
2493 $post = get_post($post_ID);
2494 }else{
2495 $post_ID = isset($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : 0;
2496 if(!empty($post_ID))
2497 $post = get_post($post_ID);
2498 }
2499 }
2500 // global $wp_query, $usces_action, $post;
2501
2502 }
2503 $editing = true;
2504 wp_enqueue_script('autosave');
2505 wp_enqueue_script('post');
2506 //if ( user_can_richedit() )
2507 //wp_enqueue_script('editor');
2508 add_thickbox();
2509 wp_enqueue_script('media-upload');
2510 wp_enqueue_script('word-count');
2511 wp_enqueue_script( 'admin-comments' );
2512
2513 if ( version_compare($wp_version, '3.3', '<') )
2514 add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
2515 wp_enqueue_script('quicktags');
2516
2517 }
2518
2519
2520 if( is_admin() && isset($_REQUEST['page']) ){
2521
2522 wp_enqueue_script('jquery-color');
2523
2524 switch( $_REQUEST['page'] ){
2525
2526 case 'usces_initial':
2527 $js = USCES_FRONT_PLUGIN_URL.'/js/usces_initial.js';
2528 wp_enqueue_script('usces_initial.js', $js, array('jquery-ui-dialog', 'jquery-ui-sortable'));
2529 //wp_enqueue_script('jquery-ui-sortable');
2530 break;
2531
2532 case 'usces_settlement':
2533 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2534 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2535 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0' );
2536 // $item_list_layoutUrl = USCES_FRONT_PLUGIN_URL.'/js/usces_dumy.js';
2537 // wp_enqueue_script('usces_dumy', $item_list_layoutUrl, array('jquery-ui-tabs'), '1.0' );
2538 break;
2539 //20100809ysk start
2540 case 'usces_cart':
2541 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2542 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2543 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2544 break;
2545 //20100809ysk end
2546 //20100818ysk start
2547 case 'usces_member':
2548 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2549 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2550 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2551 break;
2552 //20100818ysk end
2553 //20100908ysk start
2554 case 'usces_orderlist':
2555 case 'usces_ordernew':
2556 wp_enqueue_script('jquery-ui-dialog');
2557 break;
2558 case 'usces_memberlist':
2559 wp_enqueue_script('jquery-ui-dialog');
2560 break;
2561 //20100908ysk end
2562 //20101111ysk start
2563 case 'usces_itemnew':
2564 wp_enqueue_script('jquery-ui-sortable');
2565 break;
2566 case 'usces_itemedit':
2567 if( isset($_REQUEST['action']) && 'upload_register' == $_REQUEST['action'] ){
2568 @ob_end_clean();
2569 ob_start();
2570 }else{
2571 wp_enqueue_script('jquery-ui-sortable');
2572 wp_enqueue_script('jquery-ui-dialog');
2573 }
2574 break;
2575 //20101111ysk end
2576 //20101208ysk start
2577 case 'usces_delivery':
2578 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2579 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2580 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2581 break;
2582 //20101208ysk end
2583 //20110331ysk start
2584 case 'usces_system':
2585 wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core'));
2586 $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js';
2587 wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0');
2588 break;
2589 //20110331ysk end
2590 }
2591 }
2592
2593 if( isset($_REQUEST['order_action']) && $_REQUEST['order_action'] == 'pdfout' ){
2594 $this->get_current_member();
2595 $mid = $this->current_member['id'];
2596 $oid = $_GET['order_id'];
2597 if( !is_user_logged_in() && !$this->is_order($mid, $oid) )
2598 die('No permission');
2599 require_once( apply_filters('usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php') );
2600 }
2601
2602 do_action( 'usces_after_main' );
2603 }
2604
2605 function stripslashes_deep_post( $array ){
2606 $res = array();
2607 foreach( $array as $key => $value ){
2608 $key = stripslashes($key);
2609 if( is_array($value) ){
2610 $value = $this->stripslashes_deep_post( $value );
2611 }else{
2612 $value = stripslashes($value);
2613 }
2614 $res[$key] = $value;
2615 }
2616 return $res;
2617 }
2618
2619 function make_url(){
2620
2621 $permalink_structure = get_option('permalink_structure');
2622 //usces_log('use_ssl : '.$this->use_ssl, 'acting_transaction.log');
2623 if($this->use_ssl) {
2624 if( $permalink_structure ){
2625 $this->delim = '&';
2626 $home_perse = parse_url(get_option('home'));
2627 $home_perse_path = isset($home_perse['path']) ? $home_perse['path'] : '';
2628 $home_path = $home_perse['host'].$home_perse_path;
2629 $ssl_perse = parse_url($this->options['ssl_url']);
2630 $ssl_perse_path = isset($ssl_perse['path']) ? $ssl_perse['path'] : '';
2631 $ssl_path = $ssl_perse['host'].$ssl_perse_path;
2632 if( $home_perse_path != $ssl_perse_path ){
2633 if( ! defined('USCES_CUSTOMER_URL') )
2634 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2635 if( ! defined('USCES_CART_URL') )
2636 define('USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2637 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2638 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2639 if( ! defined('USCES_NEWMEMBER_URL') )
2640 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2641 if( ! defined('USCES_LOGIN_URL') )
2642 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2643 if( ! defined('USCES_LOGOUT_URL') )
2644 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2645 if( ! defined('USCES_MEMBER_URL') )
2646 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2647 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2648 if( ! defined('USCES_INQUIRY_URL') )
2649 define('USCES_INQUIRY_URL', $inquiry_url);
2650 if( ! defined('USCES_CART_NONSESSION_URL') )
2651 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER);
2652 //20110208ysk start
2653 //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));
2654 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2655 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2656 //20110208ysk end
2657 }else{
2658 $ssl_plink_cart = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_CART_NUMBER) ));
2659 $ssl_plink_member = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_MEMBER_NUMBER) ));
2660 if( ! defined('USCES_CUSTOMER_URL') )
2661 define('USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1');
2662 if( ! defined('USCES_CART_URL') )
2663 define('USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid());
2664 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2665 define('USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2666 if( ! defined('USCES_NEWMEMBER_URL') )
2667 define('USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid(). '&page=newmember');
2668 if( ! defined('USCES_LOGIN_URL') )
2669 define('USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=login');
2670 if( ! defined('USCES_LOGOUT_URL') )
2671 define('USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=logout');
2672 if( ! defined('USCES_MEMBER_URL') )
2673 define('USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid());
2674 if( !isset($this->options['inquiry_id']) || !( (int)$this->options['inquiry_id'] ) ){
2675 $inquiry_url = get_home_url();
2676 }else{
2677 $ssl_plink_inquiry = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link($this->options['inquiry_id']) ));
2678 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid();
2679 }
2680 if( ! defined('USCES_INQUIRY_URL') )
2681 define('USCES_INQUIRY_URL', $inquiry_url);
2682 if( ! defined('USCES_CART_NONSESSION_URL') )
2683 define('USCES_CART_NONSESSION_URL', $ssl_plink_cart);
2684 //20110208ysk start
2685 //define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2686 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2687 define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2688 //20110208ysk end
2689 }
2690 }else{
2691 $this->delim = '&';
2692 if( ! defined('USCES_CUSTOMER_URL') )
2693 define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid());
2694 if( ! defined('USCES_CART_URL') )
2695 define('USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid());
2696 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2697 define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword');
2698 if( ! defined('USCES_NEWMEMBER_URL') )
2699 define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember');
2700 if( ! defined('USCES_LOGIN_URL') )
2701 define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login');
2702 if( ! defined('USCES_LOGOUT_URL') )
2703 define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout');
2704 if( ! defined('USCES_MEMBER_URL') )
2705 define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid());
2706 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
2707 if( ! defined('USCES_INQUIRY_URL') )
2708 define('USCES_INQUIRY_URL', $inquiry_url);
2709 if( ! defined('USCES_CART_NONSESSION_URL') )
2710 define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER);
2711 //20110208ysk start
2712 //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2713 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2714 define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2715 //20110208ysk end
2716 }
2717 if( !is_admin() ){
2718 add_filter('home_url', array($this, 'usces_ssl_page_link'));
2719 add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link'));
2720 add_filter('icon_dir_uri', array($this, 'usces_ssl_icon_dir_uri'));
2721 add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link'));
2722 add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link'));
2723 add_filter('script_loader_src', array($this, 'usces_ssl_script_link'));
2724 add_filter('style_loader_src', array($this, 'usces_ssl_script_link'));
2725 }
2726 } else {
2727 if( $permalink_structure ){
2728 $this->delim = '?';
2729 if( ! defined('USCES_CUSTOMER_URL') )
2730 define('USCES_CUSTOMER_URL', get_page_link(USCES_CART_NUMBER) . '?customerinfo=1');
2731 if( ! defined('USCES_CART_URL') )
2732 define('USCES_CART_URL', get_page_link(USCES_CART_NUMBER));
2733 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2734 define('USCES_LOSTMEMBERPASSWORD_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=lostmemberpassword');
2735 if( ! defined('USCES_NEWMEMBER_URL') )
2736 define('USCES_NEWMEMBER_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=newmember');
2737 if( ! defined('USCES_LOGIN_URL') )
2738 define('USCES_LOGIN_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=login');
2739 if( ! defined('USCES_LOGOUT_URL') )
2740 define('USCES_LOGOUT_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=logout');
2741 if( ! defined('USCES_MEMBER_URL') )
2742 define('USCES_MEMBER_URL', get_page_link(USCES_MEMBER_NUMBER));
2743 $inquiry_url = ( !isset( $this->options['inquiry_id'] ) || !( (int)$this->options['inquiry_id'] )) ? get_home_url() : get_page_link($this->options['inquiry_id']);
2744 if( ! defined('USCES_INQUIRY_URL') )
2745 define('USCES_INQUIRY_URL', $inquiry_url);
2746 if( ! defined('USCES_CART_NONSESSION_URL') )
2747 define('USCES_CART_NONSESSION_URL', get_page_link(USCES_CART_NUMBER));
2748 //20110208ysk start
2749 //define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2750 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2751 define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2752 //20110208ysk end
2753 }else{
2754 $this->delim = '&';
2755 if( ! defined('USCES_CUSTOMER_URL') )
2756 define('USCES_CUSTOMER_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1');
2757 if( ! defined('USCES_CART_URL') )
2758 define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2759 if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') )
2760 define('USCES_LOSTMEMBERPASSWORD_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=lostmemberpassword');
2761 if( ! defined('USCES_NEWMEMBER_URL') )
2762 define('USCES_NEWMEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=newmember');
2763 if( ! defined('USCES_LOGIN_URL') )
2764 define('USCES_LOGIN_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=login');
2765 if( ! defined('USCES_LOGOUT_URL') )
2766 define('USCES_LOGOUT_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2767 if( ! defined('USCES_CART_NONSESSION_URL') )
2768 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout');
2769 if( ! defined('USCES_MEMBER_URL') )
2770 define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER);
2771 $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option('home') . '/?page_id=' . $this->options['inquiry_id'];
2772 if( ! defined('USCES_INQUIRY_URL') )
2773 define('USCES_INQUIRY_URL', $inquiry_url);
2774 if( ! defined('USCES_CART_NONSESSION_URL') )
2775 define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER);
2776 //20110208ysk start
2777 //define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2778 if( ! defined('USCES_PAYPAL_NOTIFY_URL') )
2779 define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false));
2780 //20110208ysk end
2781 }
2782 }
2783 }
2784
2785 function regist_action(){
2786 usces_register_action('inCart', 'post', 'inCart', NULL, 'inCart');
2787 usces_register_action('upButton', 'post', 'upButton', NULL, 'upButton');
2788 usces_register_action('delButton', 'post', 'delButton', NULL, 'delButton');
2789 usces_register_action('backCart', 'post', 'backCart', NULL, 'backCart');
2790 usces_register_action('customerinfo', 'request', 'customerinfo', NULL, 'customerinfo');
2791 usces_register_action('backCustomer', 'post', 'backCustomer', NULL, 'backCustomer');
2792 usces_register_action('customerlogin', 'post', 'customerlogin', NULL, 'customerlogin');
2793 usces_register_action('reganddeliveryinfo', 'post', 'reganddeliveryinfo', NULL, 'reganddeliveryinfo');
2794 usces_register_action('deliveryinfo', 'post', 'deliveryinfo', NULL, 'deliveryinfo');
2795 usces_register_action('backDelivery', 'post', 'backDelivery', NULL, 'backDelivery');
2796 usces_register_action('confirm', 'request', 'confirm', NULL, 'confirm');
2797 usces_register_action('use_point', 'post', 'use_point', NULL, 'use_point');
2798 usces_register_action('backConfirm', 'post', 'backConfirm', NULL, 'backConfirm');
2799 usces_register_action('purchase', 'request', 'purchase', NULL, 'purchase');
2800 usces_register_action('acting_return', 'request', 'acting_return', NULL, 'acting_return');
2801 usces_register_action('settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon');
2802 usces_register_action('inquiry_button', 'post', 'inquiry_button', NULL, 'inquiry_button');
2803 usces_register_action('member_login', 'request', 'member_login', NULL, 'member_login_page');
2804 usces_register_action('regmember', 'request', 'regmember', NULL, 'regmember');
2805 usces_register_action('editmember', 'request', 'editmember', NULL, 'editmember');
2806 usces_register_action('deletemember', 'request', 'deletemember', NULL, 'deletemember');
2807 usces_register_action('page_login', 'get', 'page', 'login', 'member_login_page');
2808 usces_register_action('page_logout', 'get', 'page', 'logout', 'page_logout');
2809 usces_register_action('page_lostmemberpassword', 'get', 'page', 'lostmemberpassword', 'page_lostmemberpassword');
2810 usces_register_action('lostpassword', 'request', 'lostpassword', NULL, 'lostpassword');
2811 usces_register_action('uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword');
2812 usces_register_action('changepassword', 'request', 'changepassword', NULL, 'changepassword_page');
2813 usces_register_action('page_newmember', 'get', 'page', 'newmember', 'page_newmember');
2814 usces_register_action('usces_export', 'post', 'usces_export', NULL, 'usces_export');
2815 usces_register_action('usces_import', 'post', 'usces_import', NULL, 'usces_import');
2816 usces_register_action('page_search_item', 'get', 'page', 'search_item', 'page_search_item');
2817 usces_register_action('front_ajax', 'post', 'usces_ajax_action', NULL, 'front_ajax');
2818 }
2819
2820 function ad_controller(){
2821 global $usces_action;
2822 ksort($usces_action);
2823 //if($this->is_maintenance()){
2824 if($this->is_maintenance() and !is_user_logged_in()){//0000651
2825 $this->maintenance();
2826 }else{
2827 $action_array = array('inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer',
2828 'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point',
2829 'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login',
2830 'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword',
2831 'uscesmode_changepassword', 'changepassword', 'page_newmember', 'usces_export', 'usces_import',
2832 'page_search_item', 'front_ajax');
2833 $flg = 0;
2834 $res = true;
2835 foreach( $usces_action as $handle => $action ){
2836 extract($action);
2837 switch($type){
2838 case 'post':
2839 if( empty($value) ){
2840 if( isset($_POST[$key]) ){
2841 if(in_array($handle, $action_array)){
2842 $res = call_user_func(array($this, $function));
2843 }else{
2844 $res = call_user_func($function);
2845 }
2846 $flg = 1;
2847 }
2848 }else{
2849 if( isset($_POST[$key]) && $_POST[$key] == $value ){
2850 if(in_array($handle, $action_array)){
2851 $res = call_user_func(array($this, $function));
2852 }else{
2853 $res = call_user_func($function);
2854 }
2855 $flg = 1;
2856 }
2857 }
2858 break;
2859 case 'get':
2860 if( empty($value) ){
2861 if( isset($_GET[$key]) ){
2862 if(in_array($handle, $action_array)){
2863 $res = call_user_func(array($this, $function));
2864 }else{
2865 $res = call_user_func($function);
2866 }
2867 $flg = 1;
2868 }
2869 }else{
2870 if( isset($_GET[$key]) && $_GET[$key] == $value ){
2871 if(in_array($handle, $action_array)){
2872 $res = call_user_func(array($this, $function));
2873 }else{
2874 $res = call_user_func($function);
2875 }
2876 $flg = 1;
2877 }
2878 }
2879 break;
2880 case 'request':
2881 if( empty($value) ){
2882 if( isset($_REQUEST[$key]) ){
2883 if(in_array($handle, $action_array)){
2884 $res = call_user_func(array($this, $function));
2885 }else{
2886 $res = call_user_func($function);
2887 }
2888 $flg = 1;
2889 }
2890 }else{
2891 if( isset($_REQUEST[$key]) && $_REQUEST[$key] == $value ){
2892 if(in_array($handle, $action_array)){
2893 $res = call_user_func(array($this, $function));
2894 }else{
2895 $res = call_user_func($function);
2896 }
2897 $flg = 1;
2898 }
2899 }
2900 break;
2901 }
2902 if( ! $res ) break;
2903 }
2904 if( !$flg ) $this->default_page();
2905 }
2906 }
2907
2908 //action function------------------------------------------------------------
2909 function front_ajax(){
2910 switch ($_POST['usces_ajax_action']){
2911 case 'change_states':
2912 change_states_ajax();
2913 break;
2914 }
2915 do_action('usces_front_ajax');
2916 }
2917
2918 function maintenance(){
2919 $this->page = 'maintenance';
2920 add_action('the_post', array($this, 'action_cartFilter'));
2921 }
2922
2923 function inCart(){
2924 global $wp_query;
2925 $this->page = 'cart';
2926 $this->incart_check();
2927 $this->cart->inCart();
2928 add_action('the_post', array($this, 'action_cartFilter'));
2929 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2930 add_action('template_redirect', array($this, 'template_redirect'));
2931 }
2932
2933 function upButton(){
2934 global $wp_query;
2935 $this->page = 'cart';
2936 $this->cart->upCart();
2937 $this->error_message = $this->zaiko_check();
2938 add_action('the_post', array($this, 'action_cartFilter'));
2939 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2940 add_action('template_redirect', array($this, 'template_redirect'));
2941 }
2942
2943 function delButton(){
2944 global $wp_query;
2945 $this->page = 'cart';
2946 $this->cart->del_row();
2947 add_action('the_post', array($this, 'action_cartFilter'));
2948 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2949 add_action('template_redirect', array($this, 'template_redirect'));
2950 }
2951
2952 function backCart(){
2953 global $wp_query;
2954 $this->page = 'cart';
2955 add_action('the_post', array($this, 'action_cartFilter'));
2956 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2957 add_action('template_redirect', array($this, 'template_redirect'));
2958 }
2959
2960 function customerinfo(){
2961 global $wp_query;
2962 if( false === $this->cart->num_row() ){
2963 header('location: ' . get_option('home'));
2964 exit;
2965 }
2966 do_action( 'usces_action_customerinfo' );
2967 $this->cart->entry();
2968 $this->error_message = $this->zaiko_check();
2969 $this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message );
2970 if( WCUtils::is_blank($this->error_message) ){
2971 if($this->is_member_logged_in()){
2972 //20100818ysk start
2973 //$this->page = 'delivery';
2974 $this->error_message = has_custom_customer_field_essential();
2975 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'delivery' : 'customer';
2976 //20100818ysk end
2977 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
2978 }else{
2979 $this->page = 'customer';
2980 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
2981 }
2982 }else{
2983 $this->page = 'cart';
2984 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
2985 }
2986 if ( !$this->cart->is_order_condition() ) {
2987 $order_conditions = $this->get_condition();
2988 $this->cart->set_order_condition($order_conditions);
2989 }
2990 add_action('the_post', array($this, 'action_cartFilter'));
2991 add_action('template_redirect', array($this, 'template_redirect'));
2992 }
2993
2994 function backCustomer(){
2995 global $wp_query;
2996 if( false === $this->cart->num_row() ){
2997 header('location: ' . get_option('home'));
2998 exit;
2999 }
3000 $this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' );
3001 add_action('the_post', array($this, 'action_cartFilter'));
3002 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3003 add_action('template_redirect', array($this, 'template_redirect'));
3004 // $this->cart->entry();
3005 // $this->error_message = $this->delivery_check();
3006 // $this->page = ($this->error_message == '') ? 'customer' : 'delivery';
3007 }
3008
3009 function customerlogin(){
3010 global $wp_query;
3011 if( false === $this->cart->num_row() ){
3012 header('location: ' . get_option('home'));
3013 exit;
3014 }
3015 //20100818ysk start
3016 //$this->cart->entry();
3017 //$this->page = ($this->member_login() == 'member') ? 'delivery' : 'customer';
3018 if($this->member_login() == 'member') {
3019 $this->cart->entry();
3020 $this->error_message = has_custom_customer_field_essential();
3021 if( WCUtils::is_blank($this->error_message) ){
3022 $this->page = 'delivery';
3023 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3024 }else{
3025 $this->page = 'customer';
3026 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3027 }
3028 } else {
3029 $this->cart->entry();
3030 $this->page = 'customer';
3031 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3032 }
3033 //20100818ysk end
3034 add_action('the_post', array($this, 'action_cartFilter'));
3035 add_action('template_redirect', array($this, 'template_redirect'));
3036 }
3037
3038 function reganddeliveryinfo(){
3039 global $wp_query;
3040 if( false === $this->cart->num_row() ){
3041 header('location: ' . get_option('home'));
3042 exit;
3043 }
3044 $this->cart->entry();
3045 //20110715ysk start 0000203
3046 //$_POST['member_regmode'] = 'newmemberfromcart';
3047 if(empty($_POST['member_regmode']) or $_POST['member_regmode'] != 'editmemberfromcart') $_POST['member_regmode'] = 'newmemberfromcart';
3048 //20110715ysk end
3049
3050 if( $this->regist_member() == 'newcompletion' ){
3051 $this->page = 'delivery';
3052 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3053 }else{
3054 $this->page = 'customer';
3055 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3056 }
3057 add_action('the_post', array($this, 'action_cartFilter'));
3058 add_action('template_redirect', array($this, 'template_redirect'));
3059 }
3060
3061 function deliveryinfo(){
3062 global $wp_query;
3063 if( false === $this->cart->num_row() ){
3064 header('location: ' . get_option('home'));
3065 exit;
3066 }
3067 $this->cart->entry();
3068 $this->error_message = $this->customer_check();
3069
3070 if( WCUtils::is_blank($this->error_message) ){
3071 $this->page = 'delivery';
3072 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3073 }else{
3074 $this->page = 'customer';
3075 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer');
3076 }
3077 add_action('the_post', array($this, 'action_cartFilter'));
3078 add_action('template_redirect', array($this, 'template_redirect'));
3079 }
3080
3081 function backDelivery(){
3082 global $wp_query;
3083 if( false === $this->cart->num_row() ){
3084 header('location: ' . get_option('home'));
3085 exit;
3086 }
3087 $this->page = 'delivery';
3088 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3089 add_action('the_post', array($this, 'action_cartFilter'));
3090 add_action('template_redirect', array($this, 'template_redirect'));
3091 }
3092
3093 function confirm(){
3094 global $wpdb, $wp_query;
3095 if( false === $this->cart->num_row() ){
3096 header('location: ' . get_option('home'));
3097 exit;
3098 }
3099
3100 $this->cart->entry();
3101 $this->error_message = $this->zaiko_check();
3102 if( $this->error_message != '' ){
3103 $this->page = 'cart';
3104 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3105 add_action('the_post', array($this, 'action_cartFilter'));
3106 add_action('template_redirect', array($this, 'template_redirect'));
3107 return;
3108 }
3109
3110 $this->set_reserve_pre_order_id();
3111 if(isset($_POST['confirm'])){
3112 $this->error_message = $this->delivery_check();
3113 }
3114 $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'confirm' : 'delivery';
3115 if( WCUtils::is_blank($this->error_message) ){
3116 //20120919ysk start 0000573
3117 if( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) {
3118 unset( $_SESSION['usces_entry']['order']['usedpoint'] );//20120914ysk 0000566
3119 $member_table = $wpdb->prefix."usces_member";
3120 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID']);
3121 $mem_point = $wpdb->get_var( $query );
3122 $_SESSION['usces_member']['point'] = $mem_point;
3123 }
3124 //20120919ysk end
3125 $this->page = 'confirm';
3126 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3127 }else{
3128 $this->page = 'delivery';
3129 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery');
3130 }
3131 add_action('the_post', array($this, 'action_cartFilter'));
3132 add_action('template_redirect', array($this, 'template_redirect'));
3133 }
3134
3135 function use_point(){
3136 global $wp_query;
3137 $this->cart->entry();
3138 $this->error_message = $this->point_check( $this->cart->get_entry() );
3139 $this->page = 'confirm';
3140 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3141 add_action('the_post', array($this, 'action_cartFilter'));
3142 add_action('template_redirect', array($this, 'template_redirect'));
3143 }
3144
3145 function backConfirm(){
3146 global $wp_query;
3147 if( false === $this->cart->num_row() ){
3148 header('location: ' . get_option('home'));
3149 exit;
3150 }
3151 $this->page = 'confirm';
3152 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm');
3153 add_action('the_post', array($this, 'action_cartFilter'));
3154 add_action('template_redirect', array($this, 'template_redirect'));
3155 }
3156
3157 function purchase(){
3158 global $wp_query;
3159 if( false === $this->cart->num_row() ){
3160 header('location: ' . get_option('home'));
3161 exit;
3162 }
3163
3164 if( !apply_filters('usces_purchase_check', true) ) return;
3165
3166 do_action('usces_purchase_validate');
3167 $entry = $this->cart->get_entry();
3168 $this->error_message = $this->zaiko_check();
3169 if( WCUtils::is_blank($this->error_message) && 0 < $this->cart->num_row()){
3170 $actinc_status = '';
3171 $payments = $this->getPayments( $entry['order']['payment_name'] );
3172 if( substr($payments['settlement'], 0, 6) == 'acting' && $entry['order']['total_full_price'] > 0 ){
3173 $acting_flg = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3174 $query = '';
3175 foreach($_POST as $key => $value){
3176 if($key != 'purchase')
3177 $query .= '&' . $key . '=' . urlencode(maybe_serialize($value));
3178 }
3179 $actinc_status = $this->acting_processing($acting_flg, $query);
3180 }
3181
3182 if($actinc_status == 'error'){
3183 $this->page = 'error';
3184 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3185 }else{
3186 $res = $this->order_processing();
3187 if( 'ordercompletion' == $res ){
3188 $this->page = 'ordercompletion';
3189 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3190 }else{
3191 $this->page = 'error';
3192 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3193 }
3194 }
3195 }else{
3196 $this->page = 'cart';
3197 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart');
3198 }
3199 add_action('the_post', array($this, 'action_cartFilter'));
3200 add_action('template_redirect', array($this, 'template_redirect'));
3201 }
3202
3203 function acting_return(){
3204 global $wp_query;
3205 $entry = $this->cart->get_entry();
3206
3207 //20110208ysk start
3208 /* if( 'paypal_ipn' == $_REQUEST['acting_return'] ){
3209 usces_log('paypal_ipn in ', 'acting_transaction.log');
3210 require_once($this->options['settlement_path'] . 'paypal.php');
3211 $ipn_res = paypal_ipn_check($usces_paypal_url);
3212 if( $ipn_res[0] === true ){
3213 $res = $this->order_processing( $ipn_res );
3214 if( 'ordercompletion' == $res ){
3215 $this->cart->crear_cart();
3216 }else{
3217 usces_log('paypal_ipn regorder error (acting_return) : '.print_r($entry, true), 'acting_transaction.log');
3218 }
3219 }
3220 exit;
3221 }*/
3222 //20110208ysk end
3223 if( false === $this->cart->num_row() && ('paypal' != $_GET['acting'] && 1 !== (int)$_GET['acting_return']) ){
3224 header('location: ' . get_option('home'));
3225 exit;
3226 }
3227
3228 $this->payment_results = usces_check_acting_return();
3229
3230 if( isset($this->payment_results[0]) && $this->payment_results[0] === 'duplicate' ){
3231
3232 header('location: ' . get_option('home'));
3233 exit;
3234
3235 }else if( isset($this->payment_results[0]) && $this->payment_results[0] ){//result OK
3236
3237 if( ! $this->payment_results['reg_order'] ){//without Registration Order
3238 $this->page = 'ordercompletion';
3239 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3240
3241 }else{
3242 $res = $this->order_processing( $this->payment_results );
3243
3244 if( 'ordercompletion' == $res ){
3245 if( isset($_REQUEST['wctid']) ){
3246 usces_ordered_acting_data($_REQUEST['wctid']);
3247 }
3248 $this->page = 'ordercompletion';
3249 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
3250 }else{
3251 $this->page = 'error';
3252 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3253 }
3254 }
3255
3256 }else{//result NG
3257 $this->page = 'error';
3258 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
3259 }
3260
3261 add_action('the_post', array($this, 'action_cartFilter'));
3262 add_action('template_redirect', array($this, 'template_redirect'));
3263 }
3264
3265 function settlement_epsilon(){
3266 global $wp_query;
3267 require_once($this->options['settlement_path'] . 'epsilon.php');
3268 }
3269
3270 function inquiry_button(){
3271 if( isset($_POST['inq_name']) && !WCUtils::is_blank($_POST['inq_name']) && isset($_POST['inq_mailaddress']) && is_email( trim($_POST['inq_mailaddress']) ) && !WCUtils::is_blank($_POST['inq_contents']) ){
3272 $res = $this->inquiry_processing();
3273 }else{
3274 $res = 'deficiency';
3275 }
3276
3277 $this->page = $res;
3278 }
3279
3280 function member_login_page(){
3281 global $wp_query;
3282 $res = $this->member_login();
3283 if( 'member' == $res ){
3284 $this->page = 'member';
3285 do_action('usces_action_member_logined');
3286 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_member');
3287 }elseif( 'login' == $res ){
3288 $this->page = 'login';
3289 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_login');
3290 }
3291 add_action('the_post', array($this, 'action_memberFilter'));
3292 add_action('template_redirect', array($this, 'template_redirect'));
3293 }
3294
3295 function regmember(){
3296 global $wp_query;
3297 $res = $this->regist_member();
3298 if( 'editmemberform' == $res ){
3299 $this->page = 'editmemberform';
3300 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3301 }elseif( 'newcompletion' == $res ){
3302 $this->page = 'newcompletion';
3303 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3304 }else{
3305 $this->page = $res;
3306 }
3307 add_action('the_post', array($this, 'action_memberFilter'));
3308 add_action('template_redirect', array($this, 'template_redirect'));
3309 }
3310
3311 function editmember(){
3312 global $wp_query;
3313 $res = $this->regist_member();
3314 if( 'editmemberform' == $res ){
3315 $this->page = 'editmemberform';
3316 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform');
3317 }elseif( 'newcompletion' == $res ){
3318 $this->page = 'newcompletion';
3319 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion');
3320 }else{
3321 $this->page = $res;
3322 }
3323 add_action('the_post', array($this, 'action_memberFilter'));
3324 add_action('template_redirect', array($this, 'template_redirect'));
3325 }
3326
3327 function deletemember(){
3328 $res = $this->delete_member();
3329 if( $res ){
3330 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember');
3331 $this->member_logout();
3332 }else{
3333 $this->page = 'editmemberform';
3334 add_action('the_post', array($this, 'action_memberFilter'));
3335 }
3336 add_action('template_redirect', array($this, 'template_redirect'));
3337 }
3338
3339 function page_logout(){
3340 global $wp_query;
3341 $this->member_logout();
3342 add_action('the_post', array($this, 'action_memberFilter'));
3343 add_action('template_redirect', array($this, 'template_redirect'));
3344 }
3345
3346 function page_lostmemberpassword(){
3347 global $wp_query;
3348 $this->page = 'lostmemberpassword';
3349 add_action('the_post', array($this, 'action_memberFilter'));
3350 add_action('template_redirect', array($this, 'template_redirect'));
3351 }
3352
3353 function lostpassword(){
3354 global $wp_query;
3355 $this->error_message = $this->lostpass_mailaddcheck();
3356 if ( $this->error_message != '' ) {
3357 $this->page = 'lostmemberpassword';
3358 } else {
3359 $res = $this->lostmail();
3360 $this->page = $res;//'lostcompletion';
3361 }
3362 add_action('the_post', array($this, 'action_memberFilter'));
3363 add_action('template_redirect', array($this, 'template_redirect'));
3364 }
3365
3366 function uscesmode_changepassword(){
3367 global $wp_query;
3368 $this->page = 'changepassword';
3369 add_action('the_post', array($this, 'action_memberFilter'));
3370 add_action('template_redirect', array($this, 'template_redirect'));
3371 }
3372
3373 function changepassword_page(){
3374 global $wp_query;
3375 $this->error_message = $this->changepass_check();
3376 if ( $this->error_message != '' ) {
3377 $this->page = 'changepassword';
3378 } else {
3379 $res = $this->changepassword();
3380 $this->page = $res;//'changepasscompletion';
3381 }
3382 add_action('the_post', array($this, 'action_memberFilter'));
3383 add_action('template_redirect', array($this, 'template_redirect'));
3384 }
3385
3386 function page_newmember(){
3387
3388 global $wp_query;
3389 $this->page = 'newmemberform';
3390 add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform');
3391 add_action('the_post', array($this, 'action_memberFilter'));
3392 add_action('template_redirect', array($this, 'template_redirect'));
3393 }
3394
3395 function usces_export(){
3396 $this->export();
3397 }
3398
3399 function usces_import(){
3400 $this->import();
3401 }
3402
3403 function page_search_item(){
3404 global $wp_query;
3405 $this->page = 'search_item';
3406 //add_action('template_redirect', array($this, 'action_search_item'));
3407 add_action('the_post', array($this, 'action_cartFilter'));
3408 add_action('template_redirect', array($this, 'template_redirect'));
3409 }
3410
3411 function default_page(){
3412 global $wp_query;
3413 add_action('the_post', array($this, 'goDefaultPage'));
3414 add_action('template_redirect', array($this, 'template_redirect'));
3415 }
3416 //--------------------------------------------------------------------------------------
3417
3418
3419 function goDefaultPage(){
3420 global $post;
3421
3422 if( $post->ID == USCES_CART_NUMBER ) {
3423
3424 $this->page = 'cart';
3425 add_filter('the_content', array($this, 'filter_cartContent'),20);
3426
3427 }else if( $post->ID == USCES_MEMBER_NUMBER ) {
3428
3429 $this->page = 'member';
3430 add_filter('the_content', array($this, 'filter_memberContent'),20);
3431
3432 }else if( !is_singular() ) {
3433 $this->page = 'wp_search';
3434 add_filter('the_excerpt', array($this, 'filter_cartContent'),20);
3435 add_filter('the_content', array($this, 'filter_cartContent'),20);
3436
3437 }else{
3438 add_filter('the_content', array(&$this, 'filter_itemPage'));
3439
3440 }
3441 }
3442
3443 function template_redirect () {
3444 global $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode;
3445
3446 if( apply_filters('usces_action_template_redirect', false) ) return;//Deprecated
3447 if( apply_filters('usces_filter_template_redirect', false) ) return;
3448
3449 if( is_single() && 'item' == $post->post_mime_type ) {
3450 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_item_single.php') ){
3451 if( !post_password_required($post) ){
3452 include(get_stylesheet_directory() . '/wc_templates/wc_item_single.php');
3453 exit;
3454 }
3455 }
3456 }elseif( isset($_REQUEST['page']) && ('search_item' == $_REQUEST['page'] || 'usces_search' == $_REQUEST['page']) && $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3457 if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_search_page.php') ){
3458 include(get_stylesheet_directory() . '/wc_templates/wc_search_page.php');
3459 exit;
3460 }
3461
3462 }else if( $this->is_cart_page($_SERVER['REQUEST_URI']) ){
3463 switch( $this->page ){
3464 case 'customer':
3465 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php') ){
3466 usces_get_entries();
3467 usces_get_member_regmode();
3468 include(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php');
3469 exit;
3470 }
3471 break;
3472 case 'delivery':
3473 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php') ){
3474 usces_get_entries();
3475 usces_get_carts();
3476 include(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php');
3477 exit;
3478 }
3479 break;
3480 case 'confirm':
3481 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php') ){
3482 usces_get_entries();
3483 usces_get_carts();
3484 usces_get_members();
3485 include(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php');
3486 exit;
3487 }
3488 break;
3489 case 'ordercompletion':
3490 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php') ){
3491 usces_get_entries();
3492 usces_get_carts();
3493 include(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php');
3494 exit;
3495 }
3496 break;
3497 case 'error':
3498 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php') ){
3499 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php');
3500 exit;
3501 }
3502 break;
3503 case 'cart':
3504 default:
3505 if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php') ){
3506 include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php');
3507 exit;
3508 }
3509
3510 }
3511 }else if($this->is_inquiry_page($_SERVER['REQUEST_URI']) ){
3512
3513 }else if( $this->is_member_page($_SERVER['REQUEST_URI']) ){
3514 if($this->options['membersystem_state'] != 'activate') return;
3515
3516 if( $this->is_member_logged_in() ) {
3517 $member_regmode = 'editmemberform';
3518 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php') ){
3519 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php');
3520 exit;
3521 }
3522
3523 } else {
3524
3525 switch( $this->page ){
3526 case 'login':
3527 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3528 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3529 exit;
3530 }
3531 break;
3532 case 'newmemberform':
3533 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php') ){
3534 $member_regmode = 'newmemberform';
3535 include(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php');
3536 exit;
3537 }
3538 break;
3539 case 'lostmemberpassword':
3540 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php') ){
3541 include(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php');
3542 exit;
3543 }
3544 break;
3545 case 'changepassword':
3546 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php') ){
3547 include(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php');
3548 exit;
3549 }
3550 break;
3551 case 'newcompletion':
3552 case 'editcompletion':
3553 case 'lostcompletion':
3554 case 'changepasscompletion':
3555 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php') ){
3556 include(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php');
3557 exit;
3558 }
3559 break;
3560 default:
3561 if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){
3562 include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php');
3563 exit;
3564 }
3565 }
3566 }
3567
3568 }else{
3569 // remove_action('the_post', array(&$this, 'goDefaultPage'));
3570 }
3571 }
3572
3573 function import() {
3574 $res = usces_import_xml();
3575 if ( $res === false ) :
3576 $this->action_status = 'error';
3577 //$this->action_message = __('Import was not completed.', 'usces');
3578 else :
3579 $this->action_status = 'success';
3580 $this->action_message = __('Import is cmpleted', 'usces');
3581 endif;
3582
3583 // require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php');
3584 }
3585
3586 function export() {
3587 $filename = 'usces.' . substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10) . '.xml';
3588
3589 header('Content-Description: File Transfer');
3590 header("Content-Disposition: attachment; filename=$filename");
3591 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
3592
3593 usces_export_xml();
3594 die();
3595
3596 }
3597
3598
3599 function changepassword() {
3600 global $wpdb;
3601
3602 if ( !isset($_SESSION['usces_lostmail']) ) :
3603 $this->error_message = __('Failed in update due to time-out', 'usces');
3604 return 'login';
3605 else :
3606
3607 $member_table = $wpdb->prefix . "usces_member";
3608
3609 $query = $wpdb->prepare("UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s",
3610 md5(trim($_POST['loginpass1'])), $_SESSION['usces_lostmail']);
3611 $res = $wpdb->query( $query );
3612 //$res = $wpdb->last_results;
3613
3614 if ( $res === false ) :
3615 $this->error_message = __('Error: failure in updating password', 'usces');
3616 return 'login';
3617 else :
3618 return 'changepasscompletion';
3619 endif;
3620
3621 endif;
3622 }
3623
3624 function lostmail() {
3625 $delim = apply_filters( 'usces_filter_delim', $this->delim );
3626
3627 $_SESSION['usces_lostmail'] = trim($_POST['loginmail']);
3628 $id = session_id();
3629 $uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword';
3630 $res = usces_lostmail($uri);
3631 return $res;
3632
3633 }
3634
3635 function regist_member() {
3636 global $wpdb;
3637 $_POST = $this->stripslashes_deep_post($_POST);
3638
3639 $member = $this->get_member();
3640 $mode = $_POST['member_regmode'];
3641 $member_table = $wpdb->prefix . "usces_member";
3642 $member_meta_table = $wpdb->prefix . "usces_member_meta";
3643
3644 //20110715ysk start 0000203
3645 //$error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3646 $error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' or $_POST['member_regmode'] == 'editmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check();
3647 //20110715ysk end
3648
3649 if ( $error_mes != '' ) {
3650
3651 $this->error_message = $error_mes;
3652 return $mode;
3653
3654 } elseif ( $_POST['member_regmode'] == 'editmemberform' ) {
3655
3656 $this->get_current_member();
3657 $mem_id = $this->current_member['id'];
3658 do_action('usces_action_pre_edit_memberdata', $_POST['member'], $mem_id);
3659
3660 //20130802ysk start 0000741
3661 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3662 $id = $wpdb->get_var( $query );
3663 if ( !empty($id) and $id != $mem_id ) {
3664 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3665 return $mode;
3666 }
3667 //20130802ysk end
3668
3669 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3670 $pass = $wpdb->get_var( $query );
3671
3672 $password = ( !empty($_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? md5(trim($_POST['member']['password1'])) : $pass;
3673 $query = $wpdb->prepare("UPDATE $member_table SET
3674 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3675 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3676 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3677 $password,
3678 trim($_POST['member']['name1']),
3679 trim($_POST['member']['name2']),
3680 trim($_POST['member']['name3']),
3681 trim($_POST['member']['name4']),
3682 trim($_POST['member']['zipcode']),
3683 trim($_POST['member']['pref']),
3684 trim($_POST['member']['address1']),
3685 trim($_POST['member']['address2']),
3686 trim($_POST['member']['address3']),
3687 trim($_POST['member']['tel']),
3688 trim($_POST['member']['fax']),
3689 trim($_POST['member']['mailaddress1']),
3690 $mem_id
3691 );
3692 $res = $wpdb->query( $query );
3693
3694 if( $res !== false ){
3695 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $mem_id);
3696 //20100818ysk start
3697 $res = $this->reg_custom_member($mem_id);
3698 //20100818ysk end
3699 do_action('usces_action_edit_memberdata', $_POST['member'], $mem_id);
3700 //$meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" );
3701 $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'remise_pcid', 'digitalcheck_ip_user_id'" );
3702 $query = $wpdb->prepare("DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )",
3703 $mem_id
3704 );
3705 $res = $wpdb->query( $query );
3706
3707 $this->get_current_member();
3708 return 'editmemberform';
3709
3710 } else {
3711 $this->error_message = __('Error:failure in update', 'usces');
3712 return $mode;
3713 }
3714
3715 } elseif ( $_POST['member_regmode'] == 'newmemberform' ) {
3716
3717 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
3718 $id = $wpdb->get_var( $query );
3719 if ( !empty($id) ) {
3720 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3721 return $mode;
3722 } else {
3723
3724 $point = $this->options['start_point'];
3725 $pass = md5(trim($_POST['member']['password1']));
3726 $query = $wpdb->prepare("INSERT INTO $member_table
3727 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3728 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3729 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3730 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3731 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3732 trim($_POST['member']['mailaddress1']),
3733 $pass,
3734 0,
3735 "",
3736 $point,
3737 trim($_POST['member']['name1']),
3738 trim($_POST['member']['name2']),
3739 trim($_POST['member']['name3']),
3740 trim($_POST['member']['name4']),
3741 trim($_POST['member']['zipcode']),
3742 trim($_POST['member']['pref']),
3743 trim($_POST['member']['address1']),
3744 trim($_POST['member']['address2']),
3745 trim($_POST['member']['address3']),
3746 trim($_POST['member']['tel']),
3747 trim($_POST['member']['fax']),
3748 '',
3749 '',
3750 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3751 '');
3752 $res = $wpdb->query( $query );
3753
3754 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3755 //$this->get_current_member();
3756 if($res !== false) {
3757 $user = $_POST['member'];
3758 $user['ID'] = $wpdb->insert_id;
3759 $this->set_member_meta_value('customer_country', $_POST['member']['country'], $user['ID']);
3760 //20110714ysk start 0000207
3761 //20100818ysk start
3762 //$res = $this->reg_custom_member($wpdb->insert_id);
3763 $res = $this->reg_custom_member($user['ID']);
3764 //20100818ysk end
3765 //20110714ysk end
3766 $mser = usces_send_regmembermail($user);
3767
3768 do_action('usces_action_member_registered', $_POST['member'], $user['ID']);
3769
3770 return 'newcompletion';
3771
3772 } else {
3773 $this->error_message = __('Error:failure in update', 'usces');
3774 return $mode;
3775 }
3776 }
3777
3778 } elseif ( $_POST['member_regmode'] == 'newmemberfromcart' ) {
3779
3780 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1']));
3781 $id = $wpdb->get_var( $query );
3782 if ( !empty($id) ) {
3783 $this->error_message = __('This e-mail address has been already registered.', 'usces');
3784 return $mode;
3785 } else {
3786
3787 $point = $this->options['start_point'];
3788 $pass = md5(trim($_POST['customer']['password1']));
3789 $query = $wpdb->prepare("INSERT INTO $member_table
3790 (mem_email, mem_pass, mem_status, mem_cookie, mem_point,
3791 mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
3792 mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
3793 mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
3794 VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
3795 trim($_POST['customer']['mailaddress1']),
3796 $pass,
3797 0,
3798 "",
3799 $point,
3800 trim($_POST['customer']['name1']),
3801 trim($_POST['customer']['name2']),
3802 trim($_POST['customer']['name3']),
3803 trim($_POST['customer']['name4']),
3804 trim($_POST['customer']['zipcode']),
3805 trim($_POST['customer']['pref']),
3806 trim($_POST['customer']['address1']),
3807 trim($_POST['customer']['address2']),
3808 trim($_POST['customer']['address3']),
3809 trim($_POST['customer']['tel']),
3810 trim($_POST['customer']['fax']),
3811 '',
3812 '',
3813 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
3814 '');
3815 $res = $wpdb->query( $query );
3816
3817 //$_SESSION['usces_member']['ID'] = $wpdb->insert_id;
3818 //$this->get_current_member();
3819 if($res !== false) {
3820 //20110714ysk start 0000207
3821 $member_id = $wpdb->insert_id;
3822 //$this->set_member_meta_value('customer_country', $_POST['member']['country'], $wpdb->insert_id);
3823 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $member_id);
3824 //20100818ysk start
3825 //$res = $this->reg_custom_member($wpdb->insert_id);
3826 $res = $this->reg_custom_member($member_id);
3827 //20100818ysk end
3828 //20110714ysk end
3829 //usces_send_regmembermail();
3830 do_action('usces_action_member_registered', $_POST['customer'], $member_id);
3831 $user = $_POST['customer'];
3832 $user['ID'] = $member_id;
3833 $mser = usces_send_regmembermail($user);
3834 $_POST['loginmail'] = trim($_POST['customer']['mailaddress1']);
3835 $_POST['loginpass'] = trim($_POST['customer']['password1']);
3836 if( $this->member_login() == 'member' ){
3837 $_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart';
3838 return 'newcompletion';
3839 }
3840
3841 } else {
3842 $this->error_message = __('Error:failure in update', 'usces');
3843 return $mode;
3844 }
3845 }
3846
3847 //20110715ysk start 0000203
3848 } elseif ( $_POST['member_regmode'] == 'editmemberfromcart' ) {
3849
3850 $this->get_current_member();
3851 $mem_id = $this->current_member['id'];
3852 do_action('usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id);
3853
3854 $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id);
3855 $pass = $wpdb->get_var( $query );
3856
3857 $password = ( !empty($_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? md5(trim($_POST['customer']['password1'])) : $pass;
3858 $query = $wpdb->prepare("UPDATE $member_table SET
3859 mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
3860 mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
3861 mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
3862 $password,
3863 trim($_POST['customer']['name1']),
3864 trim($_POST['customer']['name2']),
3865 trim($_POST['customer']['name3']),
3866 trim($_POST['customer']['name4']),
3867 trim($_POST['customer']['zipcode']),
3868 trim($_POST['customer']['pref']),
3869 trim($_POST['customer']['address1']),
3870 trim($_POST['customer']['address2']),
3871 trim($_POST['customer']['address3']),
3872 trim($_POST['customer']['tel']),
3873 trim($_POST['customer']['fax']),
3874 trim($_POST['customer']['mailaddress1']),
3875 $mem_id
3876 );
3877 $res = $wpdb->query( $query );
3878 if( $res !== false ){
3879 $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $mem_id);
3880 $res = $this->reg_custom_member($mem_id);
3881 do_action('usces_action_edit_memberdata', $_POST['customer'], $mem_id);
3882 unset($_SESSION['usces_member']);
3883 $this->member_just_login(trim($_POST['customer']['mailaddress1']), trim($_POST['customer']['password1']));
3884 return 'newcompletion';
3885
3886 } else {
3887 $this->error_message = __('Error:failure in update', 'usces');
3888 return $mode;
3889 }
3890 //20110715ysk end
3891 }
3892 }
3893
3894 function delete_member() {
3895 if( ! $this->is_member_logged_in() )
3896 return false;
3897 $mem = $this->get_member();
3898 if( ! $mem['ID'] )
3899 return false;
3900
3901 $res = usces_delete_memberdata( $mem['ID'] );
3902 if( $res ) {
3903 usces_send_delmembermail( $mem );
3904 }
3905
3906 return $res;
3907 }
3908
3909 function is_member_logged_in( $id = false ) {
3910 if( $id === false ){
3911 if( !empty($_SESSION['usces_member']['ID']) )
3912 return true;
3913 else
3914 return false;
3915 }else{
3916 if( !empty($_SESSION['usces_member']['ID']) && $_SESSION['usces_member']['ID'] == $id )
3917 return true;
3918 else
3919 return false;
3920 }
3921 }
3922
3923 function is_member($email) {
3924 global $wpdb;
3925
3926 $member_table = $wpdb->prefix . "usces_member";
3927 $query = $wpdb->prepare("SELECT mem_email FROM $member_table WHERE mem_email = %s", $email);
3928 $member = $wpdb->get_row( $query, ARRAY_A );
3929 if ( empty($member) ) {
3930 return false;
3931 }else{
3932 return true;
3933 }
3934 }
3935
3936 function member_login() {
3937 global $wpdb;
3938 $_POST = $this->stripslashes_deep_post($_POST);
3939
3940 $cookie = $this->get_cookie();
3941
3942
3943 if ( isset($cookie['rme']) && $cookie['rme'] == 'forever' && !isset($_POST['rememberme']) && !isset($_POST['loginmail'])) {
3944 $email = $cookie['name'];
3945 $member_table = $wpdb->prefix . "usces_member";
3946
3947 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
3948 $id = $wpdb->get_var( $query );
3949
3950 if ( !$id ) {
3951 $this->current_member['email'] = htmlspecialchars($email);
3952 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
3953 return 'login';
3954 } else {
3955 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s", $email);
3956 $member = $wpdb->get_row( $query, ARRAY_A );
3957 if ( empty($member) ) {
3958 $this->current_member['email'] = htmlspecialchars($email);
3959 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
3960 return 'login';
3961 } else {
3962 $_SESSION['usces_member']['ID'] = $member['ID'];
3963 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
3964 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
3965 $_SESSION['usces_member']['point'] = $member['mem_point'];
3966 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
3967 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
3968 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
3969 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
3970 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
3971 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
3972 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
3973 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
3974 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
3975 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
3976 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
3977 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
3978 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
3979 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
3980 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
3981 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
3982 $_SESSION['usces_member']['status'] = $member['mem_status'];
3983 //20100818ysk start
3984 $this->set_session_custom_member($member['ID']);
3985 //20100818ysk end
3986 $this->get_current_member();
3987
3988 do_action( 'usces_action_after_login' );
3989 return apply_filters( 'usces_filter_member_login', 'member', $member );
3990 }
3991 }
3992 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginmail']) && isset($_POST['loginpass']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
3993 return 'login';
3994 } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) {
3995 $this->current_member['email'] = trim($_POST['loginmail']);
3996 $this->error_message = __('<b>Error:</b> Enter the password.', 'usces');
3997 return 'login';
3998 } else if ( !isset($_POST['loginmail']) ){
3999 return 'login';
4000 } else {
4001 $email = isset($_POST['loginmail']) ? trim($_POST['loginmail']) : '';
4002 $pass = isset($_POST['loginpass']) ? md5(trim($_POST['loginpass'])) : '';
4003 $member_table = $wpdb->prefix . "usces_member";
4004
4005 $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
4006 $id = $wpdb->get_var( $query );
4007
4008 if ( !$id ) {
4009 $this->current_member['email'] = htmlspecialchars($email);
4010 $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces');
4011 return 'login';
4012 } else {
4013 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4014 $member = $wpdb->get_row( $query, ARRAY_A );
4015 if ( empty($member) ) {
4016 $this->current_member['email'] = htmlspecialchars($email);
4017 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4018 return 'login';
4019 } else {
4020 $_SESSION['usces_member']['ID'] = $member['ID'];
4021 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4022 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4023 $_SESSION['usces_member']['point'] = $member['mem_point'];
4024 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4025 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4026 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4027 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4028 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4029 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4030 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4031 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4032 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4033 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4034 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4035 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4036 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4037 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4038 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4039 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4040 $_SESSION['usces_member']['status'] = $member['mem_status'];
4041 //20100818ysk start
4042 $this->set_session_custom_member($member['ID']);
4043 //20100818ysk end
4044 $this->get_current_member();
4045
4046 if( isset($_POST['rememberme']) ){
4047 $cookie['name'] = $email;
4048 $cookie['rme'] = 'forever';
4049 $this->set_cookie($cookie);
4050 }else{
4051 $cookie['name'] = '';
4052 $cookie['rme'] = '';
4053 $this->set_cookie($cookie);
4054 }
4055
4056 do_action( 'usces_action_after_login' );
4057 return apply_filters( 'usces_filter_member_login', 'member', $member );
4058 }
4059 }
4060 }
4061 }
4062
4063 function member_just_login($email, $pass) {
4064 global $wpdb;
4065 $pass = md5($pass);
4066 $member_table = $wpdb->prefix . "usces_member";
4067
4068 $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass);
4069 $member = $wpdb->get_row( $query, ARRAY_A );
4070 if ( empty($member) ) {
4071 $this->current_member['email'] = htmlspecialchars($email);
4072 $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces');
4073 return 'login';
4074 } else {
4075 $_SESSION['usces_member']['ID'] = $member['ID'];
4076 $_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
4077 $_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
4078 $_SESSION['usces_member']['point'] = $member['mem_point'];
4079 $_SESSION['usces_member']['name1'] = $member['mem_name1'];
4080 $_SESSION['usces_member']['name2'] = $member['mem_name2'];
4081 $_SESSION['usces_member']['name3'] = $member['mem_name3'];
4082 $_SESSION['usces_member']['name4'] = $member['mem_name4'];
4083 $_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
4084 $_SESSION['usces_member']['pref'] = $member['mem_pref'];
4085 $_SESSION['usces_member']['address1'] = $member['mem_address1'];
4086 $_SESSION['usces_member']['address2'] = $member['mem_address2'];
4087 $_SESSION['usces_member']['address3'] = $member['mem_address3'];
4088 $_SESSION['usces_member']['tel'] = $member['mem_tel'];
4089 $_SESSION['usces_member']['fax'] = $member['mem_fax'];
4090 $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
4091 $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : '';
4092 $_SESSION['usces_member']['registered'] = $member['mem_registered'];
4093 $_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
4094 $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']);
4095 $_SESSION['usces_member']['status'] = $member['mem_status'];
4096 //20100818ysk start
4097 $this->set_session_custom_member($member['ID']);
4098 //20100818ysk end
4099 $this->get_current_member();
4100
4101 // $cookie = $this->get_cookie();
4102 // if(isset($_POST['rememberme']) && $cookie){
4103 // $cookie['name'] = $email;
4104 // $cookie['pass'] = trim($_POST['loginpass']);
4105 // $this->set_cookie($cookie);
4106 // }else{
4107 // $cookie['name'] = '';
4108 // $cookie['pass'] = '';
4109 // $this->set_cookie($cookie);
4110 // }
4111
4112 do_action( 'usces_action_after_login' );
4113 return apply_filters( 'usces_filter_member_login', 'member', $member );
4114 }
4115 }
4116
4117 function member_logout() {
4118 unset($_SESSION['usces_member'], $_SESSION['usces_entry']);
4119 do_action('usces_action_member_logout');
4120 wp_redirect(get_option('home'));
4121 exit;
4122 }
4123
4124 function get_current_member() {
4125
4126 if ( isset($_SESSION['usces_member']['ID']) ) {
4127 $this->current_member['id'] = $_SESSION['usces_member']['ID'];
4128 $this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return');
4129 } else {
4130 $this->current_member['id'] = 0;
4131 $this->current_member['name'] = __('guest', 'usces');
4132 }
4133 }
4134
4135 function get_member() {
4136 $res = array(
4137 'ID' => '',
4138 'registered' => '',
4139 'mailaddress1' => '',
4140 'mailaddress2' => '',
4141 'password1' => '',
4142 'password2' => '',
4143 'point' => '',
4144 'name1' => '',
4145 'name2' => '',
4146 'name3' => '',
4147 'name4' => '',
4148 'zipcode' => '',
4149 'address1' => '',
4150 'address2' => '',
4151 'address3' => '',
4152 'tel' => '',
4153 'fax' => '',
4154 'country' => '',
4155 'pref' => '',
4156 'status' => ''
4157 );
4158 if(!empty($_SESSION['usces_member'])) {
4159 foreach ( $_SESSION['usces_member'] as $key => $value ) {
4160 //20100818ysk start
4161 if(is_array($_SESSION['usces_member'][$key]))
4162 $res[$key] = stripslashes_deep($value);
4163 else
4164 //20100818ysk end
4165 $res[$key] = stripslashes($value);
4166 }
4167 }
4168 return $res;
4169 }
4170
4171 function get_member_info( $mid ) {
4172 global $wpdb;
4173 $infos = array();
4174
4175 //if( !current_user_can('activate_plugins') ) return array();
4176
4177 $table = $wpdb->prefix . "usces_member";
4178 $query = $wpdb->prepare("SELECT * FROM $table WHERE ID = %d", $mid);
4179 $datas = $wpdb->get_results( $query, ARRAY_A );
4180 if( $datas ) {
4181 $infos = $datas[0];
4182
4183 $table = $wpdb->prefix . "usces_member_meta";
4184 $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid);
4185 $metas = $wpdb->get_results( $query, ARRAY_A );
4186
4187 foreach( $metas as $meta ){
4188 $infos[$meta['meta_key']] = maybe_unserialize($meta['meta_value']);
4189 }
4190 }
4191 return $infos;
4192 }
4193
4194 function set_member_info( $data=array(), $mid ) {
4195 global $wpdb;
4196
4197 $table = $wpdb->prefix . "usces_member";
4198 $res = $wpdb->update( $table, $data, array('ID'=>$mid), NULL, array('%d'));
4199 return $res;
4200 }
4201
4202 function is_order($mid, $oid) {
4203 global $wpdb;
4204
4205 $table = $wpdb->prefix . "usces_order";
4206 $query = $wpdb->prepare("SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid);
4207 $mem_id = $wpdb->get_var( $query );
4208 if ( empty($mem_id) ) {
4209 return false;
4210 }else{
4211 return true;
4212 }
4213 }
4214
4215 function is_purchased_item($mid, $post_id, $sku = NULL) {
4216 global $wpdb;
4217 $res = false;
4218
4219 $history = $this->get_member_history($mid);
4220 foreach ( $history as $umhs ) {
4221 $cart = $umhs['cart'];
4222 $status = $umhs['order_status'];
4223 for($i=0; $i<count($cart); $i++) {
4224 $cart_row = $cart[$i];
4225 $sku_code = urldecode($cart_row['sku']);
4226 if( empty($sku) ){
4227 if( $cart_row['post_id'] == $post_id && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4228 $res = true;
4229 break 2;
4230 }elseif( $cart_row['post_id'] == $post_id && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4231 $res = 'noreceipt';
4232 break 2;
4233 }
4234 }else{
4235 if( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){
4236 $res = true;
4237 break 2;
4238 }elseif( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){
4239 $res = 'noreceipt';
4240 break 2;
4241 }
4242 }
4243 }
4244
4245 }
4246 return $res;
4247 }
4248
4249 function get_order_data($order_id, $mode = '' ) {
4250 global $wpdb, $usces;
4251 $order_table = $wpdb->prefix . "usces_order";
4252
4253 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $order_id);
4254
4255 if( 'direct' == $mode ){
4256 $value = $wpdb->get_row( $query, ARRAY_A );
4257 return $value;
4258 }
4259
4260 $value = $wpdb->get_row( $query );
4261
4262 if( $value == NULL ) {
4263 return false;
4264 }else{
4265 $res =array();
4266 }
4267 if(strpos($value->order_status, 'cancel') !== false || strpos($value->order_status, 'estimate') !== false){
4268 return false;
4269 }
4270
4271 $res = array(
4272 'ID' => $value->ID,
4273 'mem_id' => $value->mem_id,
4274 'cart' => unserialize($value->order_cart),
4275 'condition' => unserialize($value->order_condition),
4276 'getpoint' => $value->order_getpoint,
4277 'usedpoint' => $value->order_usedpoint,
4278 'discount' => $value->order_discount,
4279 'payment_name' => $value->order_payment_name,
4280 'shipping_charge' => $value->order_shipping_charge,
4281 'cod_fee' => $value->order_cod_fee,
4282 'tax' => $value->order_tax,
4283 'end_price' => $value->order_item_total_price - $value->order_usedpoint + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax,
4284 'status' => $value->order_status,
4285 'date' => mysql2date(__('Y/m/d'), $value->order_date),
4286 'modified' => mysql2date(__('Y/m/d'), $value->order_modified)
4287 );
4288
4289 return $res;
4290 }
4291
4292 function get_orderIDs_by_postID($mem_id, $post_id) {
4293 global $wpdb;
4294 $order_table = $wpdb->prefix . "usces_order";
4295
4296 $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);
4297 $rows = $wpdb->get_query( $query, ARRAY_A );
4298
4299 if( $value == NULL ) {
4300 return false;
4301 }else{
4302 foreach($rows as $row){
4303 if(strpos($row['order_status'], 'cancel') !== false || strpos($row['order_status'], 'estimate') !== false){
4304 continue;
4305 }else{
4306 $carts = unserialize($row['order_cart']);
4307 foreach($carts as $cart){
4308 if( $post_id == $cart['post_id'] ){
4309 $res[] = $row['ID'];
4310 break;
4311 }
4312 }
4313 }
4314 }
4315 }
4316 return $res;
4317 }
4318
4319 function incart_check() {
4320 //$_POST = $this->stripslashes_deep_post($_POST);
4321 $mes = array();
4322
4323 $ids = array_keys($_POST['inCart']);
4324 $post_id = $ids[0];
4325 $skus = array_keys($_POST['inCart'][$post_id]);
4326 $sku = $skus[0];
4327 $quant = isset($_POST['quant'][$post_id][$sku]) ? (int)$_POST['quant'][$post_id][$sku] : 1;
4328 $stock = $this->getItemZaikoNum($post_id, $sku);
4329 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku);
4330 $itemRestriction = get_post_meta($post_id, '_itemRestriction',true );
4331
4332 if( 1 > $quant ){
4333 $mes[$post_id][$sku] = __('enter the correct amount', 'usces') . "<br />";
4334 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4335 $mes[$post_id][$sku] = sprintf(__("This article is limited by %d at a time.", 'usces'), $itemRestriction) . "<br />";
4336 }else if( $quant > (int)$stock && !WCUtils::is_blank($stock) ){
4337 $mes[$post_id][$sku] = __('Sorry, stock is insufficient.', 'usces') . ' ' . __('Current stock', 'usces') . $stock . "<br />";
4338 }else if( 1 < $zaiko_id ){
4339 $mes[$post_id][$sku] = __('Sorry, this item is sold out.', 'usces') . "<br />";
4340 }
4341
4342 $ioptkeys = $this->get_itemOptionKey( $post_id, true );
4343 if($ioptkeys){
4344 foreach($ioptkeys as $key => $value){
4345 $optValues = $this->get_itemOptions( urldecode($value), $post_id );
4346 if( 0 == $optValues['means'] ){ //case of select
4347 if( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][$post_id][$sku][$value] ){
4348 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4349 }
4350 }elseif( 1 == $optValues['means'] ){ //case of multiselect
4351 if( $optValues['essential'] ){
4352 $mselect = 0;
4353 foreach((array)$_POST['itemOption'][$post_id][$sku][$value] as $mvalue){
4354 if(!empty($mvalue) and '#NONE#' != $mvalue) $mselect++;
4355 }
4356 if( $mselect == 0 ){
4357 $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />";
4358 }
4359 }
4360 }else{ //case of text
4361 if( $optValues['essential'] && WCUtils::is_blank($_POST['itemOption'][$post_id][$sku][$value]) ){
4362 $mes[$post_id][$sku] .= sprintf(__("Input the %s", 'usces'), urldecode($value)) . "<br />";
4363 }
4364 }
4365 }
4366 }
4367
4368 $mes = apply_filters('usces_filter_incart_check', $mes, $post_id, $sku);
4369
4370 if( isset($mes[$post_id]) && is_array($mes[$post_id]) ){
4371 foreach( $mes[$post_id] as $skukey => $skuvalue ){
4372 $mes[$post_id][$skukey] = rtrim($skuvalue, "<br />");
4373 }
4374 }
4375
4376 if( !empty($mes) ){
4377 $_SESSION['usces_singleitem']['itemOption'] = $_POST['itemOption'];
4378 $_SESSION['usces_singleitem']['quant'] = $_POST['quant'];
4379 $_SESSION['usces_singleitem']['error_message'] = $mes;
4380 if( false === strpos($_POST['usces_referer'], 'http') ){
4381 $parse_url = parse_url(get_home_url());
4382 header('location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $_POST['usces_referer'] . '#cart_button');
4383 }else{
4384 header('location: ' . $_POST['usces_referer'] . '#cart_button');
4385 }
4386 exit;
4387 }
4388
4389 do_action('usces_action_incart_checked', $mes, $post_id, $sku);
4390 }
4391
4392 function zaiko_check() {
4393 $mes = '';
4394 $cart = $this->cart->get_cart();
4395 $stocks = array();
4396
4397 for($i=0; $i<count($cart); $i++) {
4398 $cart_row = $cart[$i];
4399 $post_id = $cart_row['post_id'];
4400 $sku = $cart_row['sku'];
4401 $sku_code = urldecode($cart_row['sku']);
4402
4403 $quant = ( isset($_POST['quant']) ) ? trim($_POST['quant'][$i][$post_id][$sku]) : $cart_row['quantity'];
4404 //$zaiko_status = $this->getItemZaiko($post_id, $sku);
4405 $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku_code);
4406 $stock = $this->getItemZaikoNum($post_id, $sku_code);
4407 if( !isset($stocks[$post_id][$sku]) ){
4408 if( !WCUtils::is_blank($stock) ){
4409 $stocks[$post_id][$sku] = $stock;
4410 }else{
4411 $stocks[$post_id][$sku] = NULL;
4412 }
4413 }
4414 $checkstock = $stocks[$post_id][$sku];
4415 $stocks[$post_id][$sku] = $stocks[$post_id][$sku] - $quant;
4416 $itemRestriction = get_post_meta($post_id, '_itemRestriction', true);
4417
4418 //$red = (in_array($zaiko_status, array(__('Sold Out', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'red' : '';
4419
4420 if( 1 > (int)$quant ){
4421 $mes .= sprintf(__("Enter the correct amount for the No.%d item.", 'usces'), ($i+1)) . "<br />";
4422 }else if( 1 < $zaiko_id || WCUtils::is_zero($stock) ){
4423 $mes .= sprintf(__('Sorry, No.%d item is sold out.', 'usces'), ($i+1)) . "<br />";
4424 }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
4425 $mes .= sprintf(__('This article is limited by %1$d at a time for the No.%2$d item.', 'usces'), $itemRestriction, ($i+1)) . "<br />";
4426 }else if( 0 > $stocks[$post_id][$sku] && !WCUtils::is_blank($stock) ){
4427 $mes .= sprintf(__('Stock of No.%1$d item is remainder %2$d.', 'usces'), ($i+1), $checkstock) . "<br />";
4428 }
4429 }
4430 $mes = apply_filters('usces_filter_zaiko_check', $mes, $cart);
4431 return $mes;
4432 }
4433
4434 function member_check() {
4435 $mes = '';
4436 foreach ( $_POST['member'] as $key => $vlue ) {
4437 $_SESSION['usces_member'][$key] = trim($vlue);
4438 }
4439 if ( $_POST['member_regmode'] == 'editmemberform' ) {
4440 if ( (!WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ) && trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4441 $mes .= __('Password is not correct.', 'usces') . "<br />";
4442 if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) )
4443 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4444
4445 } else {
4446 if ( WCUtils::is_blank($_POST['member']['password1']) || WCUtils::is_blank($_POST['member']['password2']) || trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
4447 $mes .= __('Password is not correct.', 'usces') . "<br />";
4448 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']) )
4449 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4450
4451 }
4452 if ( WCUtils::is_blank($_POST["member"]["name1"]) )
4453 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4454 // if ( trim($_POST["member"]["name3"]) == "" && USCES_JP )
4455 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4456 if ( WCUtils::is_blank($_POST["member"]["zipcode"]) )
4457 $mes .= __('postal code is not correct', 'usces') . "<br />";
4458 if ( $_POST["member"]["pref"] == __('-- Select --', 'usces') )
4459 $mes .= __('enter the prefecture', 'usces') . "<br />";
4460 if ( WCUtils::is_blank($_POST["member"]["address1"]) )
4461 $mes .= __('enter the city name', 'usces') . "<br />";
4462 if ( WCUtils::is_blank($_POST["member"]["address2"]) )
4463 $mes .= __('enter house numbers', 'usces') . "<br />";
4464 if ( WCUtils::is_blank($_POST["member"]["tel"]) )
4465 $mes .= __('enter phone numbers', 'usces') . "<br />";
4466 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4467 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4468
4469 $mes = apply_filters('usces_filter_member_check', $mes);
4470
4471 return $mes;
4472 }
4473
4474 function member_check_fromcart() {
4475 $mes = '';
4476 if ( WCUtils::is_blank($_POST['customer']['password1']) || WCUtils::is_blank($_POST['customer']['password2']) || trim($_POST['customer']['password1']) != trim($_POST['customer']['password2']) )
4477 $mes .= __('Password is not correct.', 'usces') . "<br />";
4478 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']) )
4479 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4480 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4481 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4482 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4483 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4484 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4485 $mes .= __('postal code is not correct', 'usces') . "<br />";
4486 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4487 $mes .= __('enter the prefecture', 'usces') . "<br />";
4488 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4489 $mes .= __('enter the city name', 'usces') . "<br />";
4490 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4491 $mes .= __('enter house numbers', 'usces') . "<br />";
4492 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4493 $mes .= __('enter phone numbers', 'usces') . "<br />";
4494 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4495 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4496
4497 $mes = apply_filters('usces_filter_member_check_fromcart', $mes);
4498
4499 return $mes;
4500 }
4501
4502 function admin_member_check() {
4503 global $wpdb;
4504 $mes = '';
4505 if ( !is_email( trim($_POST['member']["email"]) ) ){
4506 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4507 }else{
4508 $member_table = $wpdb->prefix . "usces_member";
4509 $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
4510 if( trim($_POST['member']["email"]) != $mem_email ){
4511 $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
4512 if( !empty($mem_ID) )
4513 $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />";
4514 }
4515 }
4516 if ( WCUtils::is_blank($_POST['member']["name1"]) )
4517 $mes .= __('Name is not correct', 'usces') . "<br />";
4518 // if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
4519 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4520 // if ( trim($_POST['member']["zipcode"]) == "" )
4521 // $mes .= __('postal code is not correct', 'usces') . "<br />";
4522 // if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
4523 // $mes .= __('enter the prefecture', 'usces') . "<br />";
4524 // if ( trim($_POST['member']["address1"]) == "" )
4525 // $mes .= __('enter the city name', 'usces') . "<br />";
4526 // if ( trim($_POST['member']["address2"]) == "" )
4527 // $mes .= __('enter house numbers', 'usces') . "<br />";
4528 // if ( trim($_POST['member']["tel"]) == "" )
4529 // $mes .= __('enter phone numbers', 'usces') . "<br />";
4530 if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
4531 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4532
4533 $mes = apply_filters('usces_filter_admin_member_check', $mes);
4534
4535 return $mes;
4536 }
4537
4538 function customer_check() {
4539 $mes = '';
4540 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']) )
4541 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4542 if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
4543 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4544 // if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
4545 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4546 if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
4547 $mes .= __('postal code is not correct', 'usces') . "<br />";
4548 if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
4549 $mes .= __('enter the prefecture', 'usces') . "<br />";
4550 if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
4551 $mes .= __('enter the city name', 'usces') . "<br />";
4552 if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
4553 $mes .= __('enter house numbers', 'usces') . "<br />";
4554 if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
4555 $mes .= __('enter phone numbers', 'usces') . "<br />";
4556 if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
4557 $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
4558
4559 $mes = apply_filters('usces_filter_customer_check', $mes);
4560
4561 return $mes;
4562 }
4563
4564 function delivery_check() {
4565 $mes = '';
4566 if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
4567 if ( WCUtils::is_blank($_POST["delivery"]["name1"]) )
4568 $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299
4569 // if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP )
4570 // $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />";
4571 if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) )
4572 $mes .= __('postal code is not correct', 'usces') . "<br />";
4573 if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') )
4574 $mes .= __('enter the prefecture', 'usces') . "<br />";
4575 if ( WCUtils::is_blank($_POST["delivery"]["address1"]) )
4576 $mes .= __('enter the city name', 'usces') . "<br />";
4577 if ( WCUtils::is_blank($_POST["delivery"]["address2"]) )
4578 $mes .= __('enter house numbers', 'usces') . "<br />";
4579 if ( WCUtils::is_blank($_POST["delivery"]["tel"]) )
4580 $mes .= __('enter phone numbers', 'usces') . "<br />";
4581 }
4582 if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) )
4583 $mes .= __('chose one from delivery method.', 'usces') . "<br />";
4584 if ( !isset($_POST['offer']['payment_name']) ){
4585 $mes .= __('chose one from payment options.', 'usces') . "<br />";
4586 }else{
4587 $payments = $this->getPayments($_POST['offer']['payment_name']);
4588 if('COD' == $payments['settlement']){
4589 $total_items_price = $this->get_total_price();
4590 $tax = $this->getTax( $total_items_price );
4591 $total_items_price = $total_items_price + $tax;
4592 $cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
4593 if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount )
4594 $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 />";
4595 }
4596
4597 }
4598 //20101119ysk start
4599 if(isset($_POST['offer']['delivery_method']) and isset($_POST['offer']['payment_name'])) {
4600 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4601 if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) {
4602 $payments = $this->getPayments($_POST['offer']['payment_name']);
4603 if('COD' == $payments['settlement'])
4604 $mes .= __('COD is not available.', 'usces') . "<br />";
4605 }
4606 }
4607 //20101119ysk end
4608 //20110317ysk start
4609 if(isset($_POST['offer']['delivery_method'])) {
4610 $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
4611 $country = $_SESSION['usces_entry']["delivery"]["country"];
4612 $local_country = usces_get_base_country();
4613 if($country == $local_country) {
4614 if($this->options['delivery_method'][$d_method_index]['intl'] == 1) {
4615 $mes .= __('Delivery method is incorrect. Can not specify an international flight.', 'usces') . "<br />";
4616 }
4617 } else {
4618 if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) {
4619 $mes .= __('Delivery method is incorrect. Specify the international flights.', 'usces') . "<br />";
4620 }
4621 }
4622 }
4623 //20110317ysk end
4624
4625 $mes = apply_filters('usces_filter_delivery_check', $mes);
4626
4627 return $mes;
4628 }
4629
4630 function point_check( $entries ) {
4631 $member = $this->get_member();
4632 $this->set_cart_fees( $member, $entries );
4633 $mes = '';
4634 if( isset($_POST['offer']["usedpoint"]) ) {
4635 if ( WCUtils::is_blank($_POST['offer']["usedpoint"]) || !preg_match("/^[0-9]+$/", $_POST['offer']["usedpoint"]) || (int)$_POST['offer']["usedpoint"] < 0 ) {
4636 $mes .= __('Invalid value. Please enter in the numbers.', 'usces') . "<br />";
4637 } else {
4638 /* if ( trim($_POST['offer']["usedpoint"]) > $member['point'] ){
4639 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".$member['point']."pt<br />";
4640 $_POST['offer']["usedpoint"] = 0;
4641 $array = array(
4642 'usedpoint' => 0
4643 );
4644 $this->cart->set_order_entry( $array );
4645 }elseif($this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'])){
4646 $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 />";
4647 $_POST['offer']["usedpoint"] = 0;
4648 $array = array(
4649 'usedpoint' => 0
4650 );
4651 $this->cart->set_order_entry( $array );
4652 }elseif(!$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'])){
4653 $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4654 $_POST['offer']["usedpoint"] = 0;
4655 $array = array(
4656 'usedpoint' => 0
4657 );
4658 $this->cart->set_order_entry( $array );
4659 }
4660 */ if( trim($_POST['offer']["usedpoint"]) > $member['point'] ) {
4661 $mes .= __('You have exceeded the maximum available.', 'usces')."max".$member['point']."pt<br />";
4662 } 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']) ) {
4663 $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 />";
4664 } elseif( !$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount']) ) {
4665 $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />";
4666 }
4667 $mes = apply_filters( 'usces_filter_point_check', $mes );
4668 if( '' != $mes ) {
4669 $_POST['offer']["usedpoint"] = 0;
4670 $array = array(
4671 'usedpoint' => 0
4672 );
4673 $this->cart->set_order_entry( $array );
4674 }
4675 }
4676 }
4677 $mes = apply_filters('usces_filter_point_check', $mes);
4678 return $mes;
4679 }
4680
4681 function lostpass_mailaddcheck() {
4682 $mes = '';
4683 if ( !is_email($_POST['loginmail']) || WCUtils::is_blank($_POST['loginmail']) ) {
4684 $mes .= __('e-mail address is not correct', 'usces') . "<br />";
4685 }elseif( !$this->is_member($_POST['loginmail']) ){
4686 $mes .= __('It is the e-mail address that there is not.', 'usces') . "<br />";
4687 }
4688
4689 return $mes;
4690 }
4691
4692 function changepass_check() {
4693 $mes = '';
4694 if ( WCUtils::is_blank($_POST['loginpass1']) || WCUtils::is_blank($_POST['loginpass2']) || (trim($_POST['loginpass1']) != trim($_POST['loginpass2'])))
4695 $mes .= __('Password is not correct.', 'usces') . "<br />";
4696
4697 return $mes;
4698 }
4699
4700 function get_page() {
4701 return $this->page;
4702 }
4703
4704 function check_display_mode() {
4705 $options = get_option('usces');
4706 if( isset($options['display_mode']) && $options['display_mode'] == 'Maintenancemode' ) return;
4707
4708 $start['hour'] = empty($options['campaign_schedule']['start']['hour']) ? 0 : $options['campaign_schedule']['start']['hour'];
4709 $start['min'] = empty($options['campaign_schedule']['start']['min']) ? 0 : $options['campaign_schedule']['start']['min'];
4710 $start['month'] = empty($options['campaign_schedule']['start']['month']) ? 0 : $options['campaign_schedule']['start']['month'];
4711 $start['day'] = empty($options['campaign_schedule']['start']['day']) ? 0 : $options['campaign_schedule']['start']['day'];
4712 $start['year'] = empty($options['campaign_schedule']['start']['year']) ? 0 : $options['campaign_schedule']['start']['year'];
4713 $end['hour'] = empty($options['campaign_schedule']['end']['hour']) ? 0 : $options['campaign_schedule']['end']['hour'];
4714 $end['min'] = empty($options['campaign_schedule']['end']['min']) ? 0 : $options['campaign_schedule']['end']['min'];
4715 $end['month'] = empty($options['campaign_schedule']['end']['month']) ? 0 : $options['campaign_schedule']['end']['month'];
4716 $end['day'] = empty($options['campaign_schedule']['end']['day']) ? 0 : $options['campaign_schedule']['end']['day'];
4717 $end['year'] = empty($options['campaign_schedule']['end']['year']) ? 0 : $options['campaign_schedule']['end']['year'];
4718 $starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']);
4719 $endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']);
4720 $current_time = current_time('timestamp');
4721
4722 if( ($current_time >= $starttime) && ($current_time <= $endtime) )
4723 $options['display_mode'] = 'Promotionsale';
4724 else
4725 $options['display_mode'] = 'Usualsale';
4726
4727 update_option('usces', $options);
4728
4729 }
4730
4731 function update_business_days() {
4732 $options = get_option('usces');
4733 $datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
4734 $dhour = (int)substr($datetimestr, 11, 2);
4735 $dminute = (int)substr($datetimestr, 14, 2);
4736 $dsecond = (int)substr($datetimestr, 17, 2);
4737 $dmonth = (int)substr($datetimestr, 5, 2);
4738 $dday = (int)substr($datetimestr, 8, 2);
4739 $dyear = (int)substr($datetimestr, 0, 4);
4740 $dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear);
4741 $datenow = getdate($dtimestamp);
4742 //list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1);
4743 list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], 1, 1);
4744
4745 if(isset($options['business_days'][$year][$mon][1]))
4746 unset($options['business_days'][$year][$mon]);
4747
4748 for($i=0; $i<3; $i++){
4749 //list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i);
4750 list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], 1, $i);
4751 $last = getLastDay($year, $mon);
4752 for($j=1; $j<=$last; $j++){
4753 if(!isset($options['business_days'][$year][$mon][$j]))
4754 $options['business_days'][$year][$mon][$j] = 1;
4755 }
4756 }
4757
4758 update_option('usces', $options);
4759
4760 $_SESSION['usces_checked_business_days'] = '';
4761 }
4762
4763 function display_cart() {
4764 if($this->cart->num_row() > 0) {
4765 include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
4766 } else {
4767 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4768 }
4769 }
4770
4771 function display_cart_confirm() {
4772 if($this->cart->num_row() > 0) {
4773 include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php');
4774 } else {
4775 echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n";
4776 }
4777 }
4778
4779 function set_initial() {
4780
4781 usces_log('set_initial : OK', 'database_error.log');
4782 $rets07 = usces_upgrade_07();
4783 $rets11 = usces_upgrade_11();
4784 usces_log('rets11 : ' . print_r($rets11,true), 'database_error.log');
4785 $this->set_default_theme();
4786 $this->set_default_page();
4787 $this->set_default_categories();
4788 $this->create_table();
4789 $this->update_table();
4790 $this->update_options();//20120710ysk 0000472
4791 }
4792
4793 function create_table() {
4794 global $wpdb;
4795
4796 if ( ! empty($wpdb->charset) )
4797 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
4798 if ( ! empty($wpdb->collate) )
4799 $charset_collate .= " COLLATE $wpdb->collate";
4800
4801 $access_table = $wpdb->prefix . "usces_access";
4802 $member_table = $wpdb->prefix . "usces_member";
4803 $member_meta_table = $wpdb->prefix . "usces_member_meta";
4804 $order_table = $wpdb->prefix . "usces_order";
4805 $order_meta_table = $wpdb->prefix . "usces_order_meta";
4806
4807 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4808
4809 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
4810
4811 $sql = "CREATE TABLE " . $access_table . " (
4812 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4813 acc_key VARCHAR( 50 ) NOT NULL ,
4814 acc_type VARCHAR( 50 ) NULL ,
4815 acc_value LONGTEXT NULL ,
4816 acc_date DATE NOT NULL DEFAULT '0000-00-00',
4817 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
4818 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
4819 acc_str1 VARCHAR( 200 ) NULL ,
4820 acc_str2 VARCHAR( 200 ) NULL ,
4821 KEY acc_key ( acc_key ),
4822 KEY acc_type ( acc_type ),
4823 KEY acc_date ( acc_date ),
4824 KEY acc_num1 ( acc_num1 ),
4825 KEY acc_num2 ( acc_num2 )
4826 ) ENGINE = MYISAM AUTO_INCREMENT=0 $charset_collate;";
4827
4828 dbDelta($sql);
4829 add_option("usces_db_access", USCES_DB_ACCESS);
4830 }
4831 if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
4832
4833 $sql = "CREATE TABLE " . $member_table . " (
4834 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4835 mem_email VARCHAR( 100 ) NOT NULL ,
4836 mem_pass VARCHAR( 64 ) NOT NULL ,
4837 mem_status INT( 11 ) NOT NULL DEFAULT '0',
4838 mem_cookie VARCHAR( 13 ) NULL ,
4839 mem_point INT( 11 ) NOT NULL DEFAULT '0',
4840 mem_name1 VARCHAR( 100 ) NOT NULL ,
4841 mem_name2 VARCHAR( 100 ) NULL ,
4842 mem_name3 VARCHAR( 100 ) NULL ,
4843 mem_name4 VARCHAR( 100 ) NULL ,
4844 mem_zip VARCHAR( 50 ) NULL ,
4845 mem_pref VARCHAR( 100 ) NOT NULL ,
4846 mem_address1 VARCHAR( 100 ) NOT NULL ,
4847 mem_address2 VARCHAR( 100 ) NULL ,
4848 mem_address3 VARCHAR( 100 ) NULL ,
4849 mem_tel VARCHAR( 100 ) NOT NULL ,
4850 mem_fax VARCHAR( 100 ) NULL ,
4851 mem_delivery_flag TINYINT ( 1 ) NULL ,
4852 mem_delivery LONGTEXT,
4853 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
4854 mem_nicename VARCHAR( 50 ) NULL ,
4855 KEY mem_email ( mem_email ) ,
4856 KEY mem_pass ( mem_pass )
4857 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
4858
4859 dbDelta($sql);
4860 add_option("usces_db_member", USCES_DB_MEMBER);
4861 }
4862 if($wpdb->get_var("show tables like '$member_meta_table'") != $member_meta_table) {
4863
4864 $sql = "CREATE TABLE " . $member_meta_table . " (
4865 mmeta_id bigint(20) NOT NULL auto_increment,
4866 member_id bigint(20) NOT NULL default '0',
4867 meta_key varchar(255) default NULL,
4868 meta_value longtext,
4869 PRIMARY KEY (mmeta_id),
4870 KEY order_id (member_id),
4871 KEY meta_key (meta_key)
4872 ) ENGINE = MYISAM $charset_collate;";
4873
4874 dbDelta($sql);
4875 add_option("usces_db_member_meta", USCES_DB_MEMBER_META);
4876 }
4877 if($wpdb->get_var("show tables like '$order_table'") != $order_table) {
4878
4879 $sql = "CREATE TABLE " . $order_table . " (
4880 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4881 mem_id BIGINT( 20 ) UNSIGNED NULL ,
4882 order_email VARCHAR( 100 ) NOT NULL ,
4883 order_name1 VARCHAR( 100 ) NOT NULL ,
4884 order_name2 VARCHAR( 100 ) NULL ,
4885 order_name3 VARCHAR( 100 ) NULL ,
4886 order_name4 VARCHAR( 100 ) NULL ,
4887 order_zip VARCHAR( 50 ) NULL ,
4888 order_pref VARCHAR( 100 ) NOT NULL ,
4889 order_address1 VARCHAR( 100 ) NOT NULL ,
4890 order_address2 VARCHAR( 100 ) NULL ,
4891 order_address3 VARCHAR( 100 ) NULL ,
4892 order_tel VARCHAR( 100 ) NOT NULL ,
4893 order_fax VARCHAR( 100 ) NULL ,
4894 order_delivery LONGTEXT,
4895 order_cart LONGTEXT,
4896 order_note TEXT,
4897 order_delivery_time VARCHAR( 100 ) NOT NULL ,
4898 order_payment_name VARCHAR( 100 ) NOT NULL ,
4899 order_condition TEXT,
4900 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4901 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
4902 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
4903 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4904 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4905 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4906 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
4907 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
4908 order_modified VARCHAR( 20 ) NULL ,
4909 order_status VARCHAR( 255 ) NULL ,
4910 order_check VARCHAR( 255 ) NULL ,
4911 order_delidue_date VARCHAR( 30 ) NULL ,
4912 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
4913 order_delivery_date VARCHAR( 100 ) NULL,
4914 KEY order_email ( order_email ) ,
4915 KEY order_name1 ( order_name1 ) ,
4916 KEY order_name2 ( order_name2 ) ,
4917 KEY order_pref ( order_pref ) ,
4918 KEY order_address1 ( order_address1 ) ,
4919 KEY order_tel ( order_tel ) ,
4920 KEY order_date ( order_date )
4921 ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
4922
4923 dbDelta($sql);
4924 add_option("usces_db_order", USCES_DB_ORDER);
4925 }
4926 if($wpdb->get_var("show tables like '$order_meta_table'") != $order_meta_table) {
4927
4928 $sql = "CREATE TABLE " . $order_meta_table . " (
4929 ometa_id bigint(20) NOT NULL auto_increment,
4930 order_id bigint(20) NOT NULL default '0',
4931 meta_key varchar(255) default NULL,
4932 meta_value longtext,
4933 PRIMARY KEY (ometa_id),
4934 KEY order_id (order_id),
4935 KEY meta_key (meta_key)
4936 ) ENGINE = MYISAM $charset_collate;";
4937
4938 dbDelta($sql);
4939 add_option("usces_db_order_meta", USCES_DB_ORDER_META);
4940 }
4941
4942 }
4943
4944 function update_table()
4945 {
4946 global $wpdb;
4947 $access_table = $wpdb->prefix . "usces_access";
4948 $member_table = $wpdb->prefix . "usces_member";
4949 $member_meta_table = $wpdb->prefix . "usces_member_meta";
4950 $order_table = $wpdb->prefix . "usces_order";
4951 $order_meta_table = $wpdb->prefix . "usces_order_meta";
4952
4953 $access_ver = get_option( "usces_db_access" );
4954 $member_ver = get_option( "usces_db_member" );
4955 $member_meta_ver = get_option( "usces_db_member_meta" );
4956 $order_ver = get_option( "usces_db_order" );
4957 $order_meta_ver = get_option( "usces_db_order_meta" );
4958
4959 if( $access_ver != USCES_DB_ACCESS ) {
4960 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4961 $sql = "CREATE TABLE " . $access_table . " (
4962 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4963 acc_key VARCHAR( 50 ) NOT NULL ,
4964 acc_type VARCHAR( 50 ) NULL ,
4965 acc_value LONGTEXT NULL ,
4966 acc_date DATE NOT NULL DEFAULT '0000-00-00',
4967 acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
4968 acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
4969 acc_str1 VARCHAR( 200 ) NULL ,
4970 acc_str2 VARCHAR( 200 ) NULL ,
4971 KEY acc_key ( acc_key ),
4972 KEY acc_type ( acc_type ),
4973 KEY acc_date ( acc_date ),
4974 KEY acc_num1 ( acc_num1 ),
4975 KEY acc_num2 ( acc_num2 )
4976 ) ENGINE = MYISAM;";
4977
4978 dbDelta($sql);
4979 update_option( "usces_db_access", USCES_DB_ACCESS );
4980 }
4981 if( $member_ver != USCES_DB_MEMBER ) {
4982 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
4983 $sql = "CREATE TABLE " . $member_table . " (
4984 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4985 mem_email VARCHAR( 100 ) NOT NULL ,
4986 mem_pass VARCHAR( 64 ) NOT NULL ,
4987 mem_status INT( 11 ) NOT NULL DEFAULT '0',
4988 mem_cookie VARCHAR( 13 ) NULL ,
4989 mem_point INT( 11 ) NOT NULL DEFAULT '0',
4990 mem_name1 VARCHAR( 100 ) NOT NULL ,
4991 mem_name2 VARCHAR( 100 ) NULL ,
4992 mem_name3 VARCHAR( 100 ) NULL ,
4993 mem_name4 VARCHAR( 100 ) NULL ,
4994 mem_zip VARCHAR( 50 ) NULL ,
4995 mem_pref VARCHAR( 100 ) NOT NULL ,
4996 mem_address1 VARCHAR( 100 ) NOT NULL ,
4997 mem_address2 VARCHAR( 100 ) NULL ,
4998 mem_address3 VARCHAR( 100 ) NULL ,
4999 mem_tel VARCHAR( 100 ) NOT NULL ,
5000 mem_fax VARCHAR( 100 ) NULL ,
5001 mem_delivery_flag TINYINT ( 1 ) NULL ,
5002 mem_delivery LONGTEXT,
5003 mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5004 mem_nicename VARCHAR( 50 ) NULL ,
5005 KEY mem_email ( mem_email ) ,
5006 KEY mem_pass ( mem_pass )
5007 ) ENGINE = MYISAM;";
5008
5009 dbDelta($sql);
5010 update_option( "usces_db_member", USCES_DB_MEMBER );
5011 }
5012 if( $member_meta_ver != USCES_DB_MEMBER_META ) {
5013 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5014 $sql = "CREATE TABLE " . $member_meta_table . " (
5015 mmeta_id bigint(20) NOT NULL auto_increment,
5016 member_id bigint(20) NOT NULL default '0',
5017 meta_key varchar(255) default NULL,
5018 meta_value longtext,
5019 PRIMARY KEY (mmeta_id),
5020 KEY order_id (member_id),
5021 KEY meta_key (meta_key)
5022 ) ENGINE = MYISAM;";
5023
5024 dbDelta($sql);
5025 update_option("usces_db_member_meta", USCES_DB_MEMBER_META);
5026 }
5027 if( $order_ver != USCES_DB_ORDER ) {
5028 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5029 $sql = "CREATE TABLE " . $order_table . " (
5030 ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
5031 mem_id BIGINT( 20 ) UNSIGNED NULL ,
5032 order_email VARCHAR( 100 ) NOT NULL ,
5033 order_name1 VARCHAR( 100 ) NOT NULL ,
5034 order_name2 VARCHAR( 100 ) NULL ,
5035 order_name3 VARCHAR( 100 ) NULL ,
5036 order_name4 VARCHAR( 100 ) NULL ,
5037 order_zip VARCHAR( 50 ) NULL ,
5038 order_pref VARCHAR( 100 ) NOT NULL ,
5039 order_address1 VARCHAR( 100 ) NOT NULL ,
5040 order_address2 VARCHAR( 100 ) NULL ,
5041 order_address3 VARCHAR( 100 ) NULL ,
5042 order_tel VARCHAR( 100 ) NOT NULL ,
5043 order_fax VARCHAR( 100 ) NULL ,
5044 order_delivery LONGTEXT,
5045 order_cart LONGTEXT,
5046 order_note TEXT,
5047 order_delivery_time VARCHAR( 100 ) NOT NULL ,
5048 order_payment_name VARCHAR( 100 ) NOT NULL ,
5049 order_condition TEXT,
5050 order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5051 order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
5052 order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
5053 order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5054 order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5055 order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5056 order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
5057 order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
5058 order_modified VARCHAR( 20 ) NULL ,
5059 order_status VARCHAR( 255 ) NULL ,
5060 order_check VARCHAR( 255 ) NULL ,
5061 order_delidue_date VARCHAR( 30 ) NULL ,
5062 order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
5063 order_delivery_date VARCHAR( 100 ) NULL,
5064 KEY order_email ( order_email ) ,
5065 KEY order_name1 ( order_name1 ) ,
5066 KEY order_name2 ( order_name2 ) ,
5067 KEY order_pref ( order_pref ) ,
5068 KEY order_address1 ( order_address1 ) ,
5069 KEY order_tel ( order_tel ) ,
5070 KEY order_date ( order_date )
5071 ) ENGINE = MYISAM;";
5072
5073 dbDelta($sql);
5074 update_option("usces_db_order", USCES_DB_ORDER);
5075 }
5076 if( $order_meta_ver != USCES_DB_ORDER_META ) {
5077 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
5078 $sql = "CREATE TABLE " . $order_meta_table . " (
5079 ometa_id bigint(20) NOT NULL auto_increment,
5080 order_id bigint(20) NOT NULL default '0',
5081 meta_key varchar(255) default NULL,
5082 meta_value longtext,
5083 PRIMARY KEY (ometa_id),
5084 KEY order_id (order_id),
5085 KEY meta_key (meta_key)
5086 ) ENGINE = MYISAM;";
5087
5088 dbDelta($sql);
5089 update_option("usces_db_order_meta", USCES_DB_ORDER_META);
5090 }
5091 }
5092
5093 function set_default_theme()
5094 {
5095 $themepath = USCES_WP_CONTENT_DIR.'/themes/welcart_default';
5096 $resourcepath = USCES_WP_CONTENT_DIR.'/plugins/usc-e-shop/theme/welcart_default';
5097 if( file_exists($themepath) ) return false;
5098 if(!file_exists($resourcepath) ) return false;
5099
5100 mkdir($themepath, 0775);
5101 $this->dir_copy($resourcepath, $themepath);
5102
5103 }
5104
5105 function dir_copy($source, $dest){
5106 if ($res = opendir($source)) {
5107 while (($file = readdir($res)) !== false) {
5108 $sorce_path = $source . '/' . $file;
5109 $dest_path = $dest . '/' . $file;
5110 $filetype = @filetype($sorce_path);
5111 if( $filetype == 'file' ) {
5112 copy($sorce_path, $dest_path);
5113 }elseif( $filetype == 'dir' && $file != '..' && $file != '.' ){
5114 mkdir($dest_path);
5115 $this->dir_copy($sorce_path, $dest_path);
5116 }
5117 }
5118 closedir($res);
5119 }
5120 }
5121
5122 function set_default_page()
5123 {
5124 global $wpdb;
5125 $datetime = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
5126 $datetime_gmt = gmdate('Y-m-d H:i:s', time());
5127
5128 //cart_page
5129 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER);
5130 $cart_number = $wpdb->get_var( $query );
5131 if( $cart_number === NULL ) {
5132 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5133 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5134 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5135 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5136 VALUES (%d, %s, %s, %s, %s, %s, %s,
5137 %s, %s, %s, %s, %s, %s, %s, %s,
5138 %s, %d, %s, %d, %s, %s, %d)",
5139 1, $datetime, $datetime_gmt, '', __('Cart', 'usces'), '', 'publish',
5140 'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt,
5141 '', 0, '', 0, 'page', '', 0);
5142 $wpdb->query($query);
5143 $cart_number = $wpdb->insert_id;
5144 if( $cart_number !== NULL ) {
5145 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5146 $cart_number, '_wp_page_template', 'uscescart.php');
5147 $wpdb->query($query);
5148 }
5149 }
5150 update_option('usces_cart_number', $cart_number);
5151
5152 //member_page
5153 $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER);
5154 $member_number = $wpdb->get_var( $query );
5155 if( $member_number === NULL ) {
5156 $query = $wpdb->prepare("INSERT INTO $wpdb->posts
5157 (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
5158 comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
5159 post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
5160 VALUES (%d, %s, %s, %s, %s, %s, %s,
5161 %s, %s, %s, %s, %s, %s, %s, %s,
5162 %s, %d, %s, %d, %s, %s, %d)",
5163 1, $datetime, $datetime_gmt, '', __('Membership', 'usces'), '', 'publish',
5164 'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt,
5165 '', 0, '', 0, 'page', '', 0);
5166 $wpdb->query($query);
5167 $member_number = $wpdb->insert_id;
5168 if( $member_number !== NULL ) {
5169 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
5170 $member_number, '_wp_page_template', 'uscesmember.php');
5171 $wpdb->query($query);
5172 }
5173 }
5174 update_option('usces_member_number', $member_number);
5175
5176 }
5177
5178 function set_default_categories()
5179 {
5180 global $wpdb;
5181
5182 $idObj = get_category_by_slug('item');
5183 if( empty($idObj) ) {
5184 $item_cat = array('cat_name' => __('Items', 'usces'), 'category_description' => '', 'category_nicename' => 'item', 'category_parent' => 0);
5185 $item_cat_id = wp_insert_category($item_cat);
5186 update_option('usces_item_cat_parent_id', $item_cat_id);
5187 }
5188
5189 $idObj = get_category_by_slug('itemreco');
5190 if( empty($idObj) && isset($item_cat_id) ) {
5191 $itemreco_cat = array('cat_name' => __('Items recommended', 'usces'), 'category_description' => '', 'category_nicename' => 'itemreco', 'category_parent' => $item_cat_id);
5192 $itemreco_cat_id = wp_insert_category($itemreco_cat);
5193 }
5194
5195 $idObj = get_category_by_slug('itemnew');
5196 if( empty($idObj) && isset($item_cat_id) ) {
5197 $itemnew_cat = array('cat_name' => __('New items', 'usces'), 'category_description' => '', 'category_nicename' => 'itemnew', 'category_parent' => $item_cat_id);
5198 $itemnew_cat_id = wp_insert_category($itemnew_cat);
5199 }
5200
5201 $idObj = get_category_by_slug('itemgenre');
5202 if( empty($idObj) && isset($item_cat_id) ) {
5203 $itemgenre_cat = array('cat_name' => __('Item genre', 'usces'), 'category_description' => '', 'category_nicename' => 'itemgenre', 'category_parent' => $item_cat_id);
5204 $itemgenre_cat_id = wp_insert_category($itemgenre_cat);
5205 }
5206 }
5207 //20120710ysk start 0000472
5208 function update_options() {
5209 $target_market = $this->options['system']['target_market'];
5210
5211 $update_shipping_charge = false;
5212 $shipping_charge = isset($this->options['shipping_charge']) ? $this->options['shipping_charge'] : array();
5213 foreach( (array)$target_market as $tm ) {
5214 for( $i = 0; $i < count($shipping_charge); $i++ ) {
5215 if( isset($shipping_charge[$i]['country']) and $shipping_charge[$i]['country'] == $tm ) {
5216 foreach( $shipping_charge[$i]['value'] as $pref => $value ) {
5217 $shipping_charge[$i][$tm][$pref] = $value;
5218 }
5219 unset($shipping_charge[$i]['country']);
5220 unset($shipping_charge[$i]['value']);
5221 $update_shipping_charge = true;
5222 }
5223 }
5224 }
5225 if( $update_shipping_charge ) $this->options['shipping_charge'] = $shipping_charge;
5226
5227 $update_delivery_days = false;
5228 $delivery_days = isset($this->options['delivery_days']) ? $this->options['delivery_days'] : array();
5229 foreach( (array)$target_market as $tm ) {
5230 for( $i = 0; $i < count($delivery_days); $i++ ) {
5231 if( isset($delivery_days[$i]['country']) and $delivery_days[$i]['country'] == $tm ) {
5232 foreach( $delivery_days[$i]['value'] as $pref => $value ) {
5233 $delivery_days[$i][$tm][$pref] = $value;
5234 }
5235 unset($delivery_days[$i]['country']);
5236 unset($delivery_days[$i]['value']);
5237 $update_delivery_days = true;
5238 }
5239 }
5240 }
5241 if( $update_delivery_days ) $this->options['delivery_days'] = $delivery_days;
5242
5243 if( $update_shipping_charge or $update_delivery_days )
5244 update_option('usces', $this->options);
5245 }
5246 //20120710ysk end
5247 function get_item_cat_ids(){
5248 $args = array('child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0, 'hierarchical' => 0);
5249 $categories = get_categories( $args );
5250 foreach($categories as $category){
5251 $ids[] = $category->term_id;
5252 }
5253 return $ids;
5254 }
5255
5256 function get_item_post_ids(){
5257 global $wpdb;
5258 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5259 $ids = $wpdb->get_col( $query );
5260
5261 return $ids;
5262 }
5263
5264 function get_item_cat_genre_ids( $post_id ){
5265 $ids = array();
5266 $all_ids = array();
5267 $genre = get_category_by_slug( 'itemgenre' );
5268 $genre_id = $genre->term_id;
5269 $args = array('child_of' => $genre_id, 'hide_empty' => 0, 'hierarchical' => 0);
5270 $categories = get_categories( $args );
5271 foreach($categories as $category){
5272 $ids[] = $category->term_id;
5273 }
5274 $allcats = get_the_category( $post_id );
5275 foreach($allcats as $cat){
5276 $all_ids[] = $cat->term_id;
5277 }
5278 //$all_ids =
5279 $results = array_intersect($ids, $all_ids);
5280
5281 return $results;
5282 }
5283
5284 function set_item_mime($post_id, $str)
5285 {
5286 global $wpdb;
5287 if( WCUtils::is_blank($str) ) return;
5288
5289 $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id);
5290 $results = $wpdb->query( $query );
5291 return $results;
5292 }
5293
5294 function isAdnminSSL()
5295 {
5296 $plugins = get_option('active_plugins');
5297 foreach($plugins as $plugin) {
5298 if( false !== strpos($plugin, USCES_ADMIN_SSL_BASE_NAME) )
5299 return true;
5300 }
5301 return false;
5302 }
5303
5304 function getGuidTax() {
5305 $tax_rate = (int)$this->options['tax_rate'];
5306 if ( 0 < $tax_rate )
5307 $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>';
5308 else
5309 $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>';
5310
5311 return apply_filters('usces_filter_tax_guid', $str, $tax_rate);
5312 }
5313
5314 function getItemCode($post_id) {
5315 $str = get_post_meta($post_id, '_itemCode', true);
5316 return $str;
5317 }
5318
5319 function getItemName($post_id) {
5320 $str = get_post_meta($post_id, '_itemName', true);
5321 return $str;
5322 }
5323
5324 function getItemRestriction($post_id) {
5325 $str = get_post_meta($post_id, '_itemRestriction', true);
5326 return $str;
5327 }
5328
5329 function getItemPointrate($post_id) {
5330 $str = get_post_meta($post_id, '_itemPointrate', true);
5331 return $str;
5332 }
5333
5334 function getItemShipping($post_id) {
5335 $str = get_post_meta($post_id, '_itemShipping', true);
5336 return $str;
5337 }
5338
5339 function getItemShippingCharge($post_id) {
5340 $str = get_post_meta($post_id, '_itemShippingCharge', true);
5341 return (float)$str;
5342 }
5343
5344 function getItemDeliveryMethod($post_id) {
5345 $str = get_post_meta($post_id, '_itemDeliveryMethod', true);
5346 if( empty($str) )
5347 return array();
5348 else
5349 return $str;
5350 }
5351
5352 function getItemIndividualSCharge($post_id) {
5353 $str = get_post_meta($post_id, '_itemIndividualSCharge', true);
5354 return $str;
5355 }
5356
5357 function getItemGpNum1($post_id) {
5358 $str = get_post_meta($post_id, '_itemGpNum1', true);
5359 return $str;
5360 }
5361
5362 function getItemGpNum2($post_id) {
5363 $str = get_post_meta($post_id, '_itemGpNum2', true);
5364 return $str;
5365 }
5366
5367 function getItemGpNum3($post_id) {
5368 $str = get_post_meta($post_id, '_itemGpNum3', true);
5369 return $str;
5370 }
5371
5372 function getItemGpDis1($post_id) {
5373 $str = get_post_meta($post_id, '_itemGpDis1', true);
5374 return $str;
5375 }
5376
5377 function getItemGpDis2($post_id) {
5378 $str = get_post_meta($post_id, '_itemGpDis2', true);
5379 return $str;
5380 }
5381
5382 function getItemGpDis3($post_id) {
5383 $str = get_post_meta($post_id, '_itemGpDis3', true);
5384 return $str;
5385 }
5386
5387 function getItemSku($post_id, $index = '') {
5388 $array = array();
5389 $skus = $this->get_skus($post_id, 'sort');
5390 foreach((array)$skus as $sku){
5391 $array[] = $sku['code'];
5392 }
5393 if(!$array) return false;
5394 if($index == ''){
5395 return $array;
5396 }else if(isset($array[$index])){
5397 return $array[$index];
5398 }else{
5399 return false;
5400 }
5401 }
5402
5403 function getItemPrice($post_id, $skukey = '') {
5404 $array = array();
5405 $skus = $this->get_skus($post_id, 'code');
5406 foreach((array)$skus as $key => $sku){
5407 $array[$key] = (float)str_replace('.', '', $sku['price']);
5408 }
5409 if(!$array) return false;
5410 if($skukey == ''){
5411 return $array;
5412 }else if(isset($array[$skukey])){
5413 return $array[$skukey];
5414 }else{
5415 return false;
5416 }
5417 }
5418
5419 function getItemDiscount($post_id, $skukey = '') {
5420 $display_mode = $this->options['display_mode'];
5421 $array = array();
5422 $skus = $this->get_skus($post_id, 'code');
5423 foreach((array)$skus as $key => $sku){
5424 $price = (float)str_replace(',', '', $sku['price']);
5425 if ( $display_mode == 'Promotionsale' ) {
5426 if ( $this->options['campaign_privilege'] == 'discount' ){
5427 if( 0 === (int)$this->options['campaign_category'] || in_category((int)$this->options['campaign_category'], $post_id) ){
5428 $discount = $price * $this->options['privilege_discount'] / 100;
5429 }else{
5430 $discount = 0;
5431 }
5432 }else if ( $this->options['campaign_privilege'] == 'point' ){
5433 $discount = 0;
5434 }
5435 }
5436
5437 $discount = ceil($discount);
5438 $array[$key] = $discount;
5439 }
5440 if(!$array) return false;
5441 if($skukey == ''){
5442 return $array;
5443 }else if(isset($array[$skukey])){
5444 return $array[$skukey];
5445 }else{
5446 return false;
5447 }
5448 }
5449
5450 function getItemZaiko($post_id, $skukey = '') {
5451 $array = array();
5452 $skus = $this->get_skus($post_id, 'code');
5453 foreach((array)$skus as $key => $sku){
5454 $num = $sku['stock'];
5455 $array[$key] = $this->zaiko_status[$num];
5456 }
5457 if(!$array) return false;
5458 if($skukey == ''){
5459 return $array;
5460 }else if(isset($array[$skukey])){
5461 return $array[$skukey];
5462 }else{
5463 return false;
5464 }
5465 }
5466
5467 function getItemZaikoStatusId($post_id, $skukey = '') {
5468 $array = array();
5469 $skus = $this->get_skus($post_id, 'code');
5470 foreach((array)$skus as $key => $sku){
5471 $num = $sku['stock'];
5472 $array[$key] = $num;
5473 }
5474 if(!$array) return false;
5475 if($skukey == ''){
5476 return $array;
5477 }else if(isset($array[$skukey])){
5478 return $array[$skukey];
5479 }else{
5480 return false;
5481 }
5482 }
5483
5484 function updateItemZaiko($post_id, $skucode, $value) {
5485 $res = usces_update_sku( $post_id, $skucode, 'stock', $value );
5486 if( !$res ){
5487 return false;
5488 }else{
5489 return true;
5490 }
5491 }
5492
5493 function getItemZaikoNum($post_id, $skukey = '') {
5494 $array = array();
5495 $skus = $this->get_skus($post_id, 'code');
5496 foreach((array)$skus as $key => $sku){
5497 $array[$key] = $sku['stocknum'];
5498 }
5499 if(!$array) return false;
5500 if($skukey == ''){
5501 return $array;
5502 }else if(isset($array[$skukey])){
5503 return $array[$skukey];
5504 }else{
5505 return false;
5506 }
5507 }
5508
5509 function updateItemZaikoNum($post_id, $skucode, $value) {
5510 $res = usces_update_sku( $post_id, $skucode, 'stocknum', $value );
5511 if( !$res ){
5512 return false;
5513 }else{
5514 return true;
5515 }
5516 }
5517 //20120629ysk start 0000520
5518 function getItemDivision( $post_id ){
5519 if( usces_is_item($post_id) ){
5520 $item_division = get_post_meta($post_id, '_item_division', true);
5521 $division = empty($item_division) ? 'shipped' : $item_division;
5522 }else{
5523 $division = NULL;
5524 }
5525 return $division;
5526 }
5527 //20120629ysk end
5528 function getItemChargingType( $post_id, $cart = array() ){
5529 if( usces_is_item($post_id) ){
5530 $charging = get_post_meta($post_id, '_item_charging_type', true);
5531 //if( !defined('WCEX_DLSELLER') )
5532 if( !defined('WCEX_DLSELLER') and !defined('WCEX_AUTO_DELIVERY') )
5533 $charging = NULL;
5534 }else{
5535 $charging = NULL;
5536 }
5537 switch( $charging ){
5538 case 0:
5539 $type = 'once';
5540 break;
5541 case 1:
5542 $type = 'continue';
5543 break;
5544 case 2:
5545 $type = 'regular';
5546 if( !empty($cart) ) {
5547 if( empty($cart['advance']) ) {
5548 $type = 'once';
5549 } else {
5550 $advance = $this->cart->wc_unserialize( $cart['advance'] );
5551 $sku = urldecode( $cart['sku'] );
5552 $regular = $advance[$post_id][$sku]['regular'];
5553 $unit = isset( $regular['unit'] ) ? $regular['unit'] : '';
5554 $interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0;
5555 if( empty($unit) or 1 > $interval ) //通常課金扱い
5556 $type = 'once';
5557 }
5558 }
5559 break;
5560 default:
5561 $type = NULL;
5562 }
5563 return $type;
5564 }
5565
5566 function getItemFrequency( $post_id ){
5567 $frequency = get_post_meta($post_id, '_item_frequency',true );
5568 return $frequency;
5569 }
5570
5571 function getItemChargingDay( $post_id ){
5572 $array = get_post_meta($post_id, '_item_chargingday',true );
5573 $day = (int)$array;
5574 $chargingday = empty($day) ? 1 : $day;
5575 return $chargingday;
5576 }
5577
5578 function getItemSkuDisp($post_id, $skukey = '') {
5579 $array = array();
5580 $skus = $this->get_skus($post_id, 'code');
5581 foreach((array)$skus as $key => $sku){
5582 $array[$key] = $sku['name'];
5583 }
5584 if(!$array) return false;
5585 if($skukey == ''){
5586 return $array;
5587 }else if(isset($array[$skukey])){
5588 return $array[$skukey];
5589 }else{
5590 return false;
5591 }
5592 }
5593
5594 // function getItemSkuChargingType($post_id, $skukey = '') {
5595 // $fields = get_post_custom($post_id);
5596 // $skus = array();
5597 // foreach((array)$fields as $key => $value){
5598 // if( preg_match('/^_isku_/', $key, $match) ){
5599 // $key = substr($key, 6);
5600 // $values = maybe_unserialize($value[0]);
5601 // if( isset($values['charging_type']) && "undefined" != $values['charging_type'] && !empty($values['charging_type']) ){
5602 // $skus[$key] = $values['charging_type'];
5603 // }else{
5604 // continue;
5605 // }
5606 // }
5607 // }
5608 // if( empty($skus) ) return false;
5609 // if($skukey == ''){
5610 // return $skus;
5611 // }elseif( isset($skus[$skukey]) ){
5612 // return $skus[$skukey];
5613 // }else{
5614 // return false;
5615 // }
5616 // }
5617
5618 function getItemSkuUnit($post_id, $skukey = '') {
5619 $array = array();
5620 $skus = $this->get_skus($post_id, 'code');
5621 foreach((array)$skus as $key => $sku){
5622 $array[$key] = $sku['unit'];
5623 }
5624 if(!$array) return false;
5625 if($skukey == ''){
5626 return $array;
5627 }else if(isset($array[$skukey])){
5628 return $array[$skukey];
5629 }else{
5630 return false;
5631 }
5632 }
5633
5634 function get_item( $post_id ) {
5635 $usces_item['post_id'] = $post_id;
5636 $usces_item['itemCode'] = $this->getItemCode($post_id);
5637 $usces_item['itemName'] = $this->getItemName($post_id);
5638
5639 $skus = $this->get_skus($post_id, 'code');
5640 foreach((array)$skus as $key => $sku){
5641 $usces_item['skuCodes'][] = $key;
5642 $usces_item['skuValues'][] = $sku;
5643 }
5644
5645 $usces_item = apply_filters('usces_filter_get_item', $usces_item, $post_id);
5646
5647 return $usces_item;
5648 }
5649
5650 function get_itemOptionKey( $post_id, $enc = false ) {
5651 $opts = usces_get_opts( $post_id );
5652 if(empty($opts)) return;
5653
5654 $res = array();
5655 foreach ( (array)$opts as $opt ) {
5656 if( $enc )
5657 $res[] = urlencode($opt['name']);
5658 else
5659 $res[] = $opt['name'];
5660 }
5661 return $res;
5662 }
5663
5664 function get_itemOptions( $key, $post_id ) {
5665 $opts = usces_get_opts( $post_id, 'name' );
5666 if(empty($opts[$key]))
5667 return;
5668 else
5669 return $opts[$key];
5670 }
5671
5672 function get_postIDbyCode( $itemcode ) {
5673 global $wpdb;
5674
5675 $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_itemCode', $itemcode);
5676 $res = $wpdb->get_var( $query );
5677 return $res;
5678 }
5679
5680 function get_pictids($item_code) {
5681 global $wpdb, $usces;
5682
5683 if( empty($item_code) )
5684 return false;
5685
5686 if( !$usces->options['system']['subimage_rule'] ){
5687 $codestr = $item_code.'%';
5688 $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);
5689 }else{
5690 $codestr = $item_code.'--%';
5691 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr);
5692 }
5693 $results = $wpdb->get_col( $query );
5694 return $results;
5695 }
5696
5697 function get_mainpictid($item_code) {
5698 global $wpdb;
5699 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $item_code);
5700 $id = $wpdb->get_var( $query );
5701 $id = apply_filters( 'usces_filter_get_mainpictid', $id, $item_code );
5702 return $id;
5703 }
5704
5705 function get_skus( $post_id, $keyflag = 'sort' ) {
5706 if( !$post_id )
5707 return array();
5708
5709 $skus = array();
5710 $metas = usces_get_post_meta($post_id, '_isku_');
5711 if( empty($metas) ) return $skus;
5712
5713 foreach( $metas as $rows ){
5714 $values = unserialize($rows['meta_value']);
5715 $key = isset($values[$keyflag]) ? $values[$keyflag] : $values['sort'];
5716 $skus[$key] = array(
5717 'meta_id' => $rows['meta_id'],
5718 'code' => $values['code'],
5719 'name' => $values['name'],
5720 'cprice' => $values['cprice'],
5721 'price' => $values['price'],
5722 'unit' => $values['unit'],
5723 'stocknum' => $values['stocknum'],
5724 'stock' => $values['stock'],
5725 'gp' => $values['gp'],
5726 'sort' => $values['sort'],
5727 'advance' => isset($values['advance']) ? $values['advance'] : ''
5728 );
5729 }
5730 $skus = apply_filters( 'usces_filter_get_skus', $skus, $post_id, $keyflag );
5731 ksort($skus);
5732
5733 return $skus;
5734 }
5735
5736 function is_item( $post ) {
5737
5738 if( $post->post_mime_type == 'item' )
5739 return true;
5740 else
5741 return false;
5742 }
5743
5744 function getItemIds( $end_type ) {
5745 global $wpdb;
5746 if( 'front' == $end_type )
5747 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item');
5748 if( 'back' == $end_type )
5749 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
5750 $ids = $wpdb->get_col( $query );
5751 if( empty($ids) ) $ids = array();
5752 return $ids;
5753 }
5754
5755 function getNotItemIds() {
5756 global $wpdb;
5757 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item');
5758 $ids = $wpdb->get_col( $query );
5759 if( empty($ids) ) $ids = array();
5760 return $ids;
5761 }
5762
5763 function getPaymentMethod( $name ) {
5764 $res = array();
5765 $payments = $this->options['payment_method'];
5766 foreach ( (array)$payments as $payment ) {
5767 if($name = $payment['name']) {
5768 $res = $payment;
5769 break;
5770 }
5771 }
5772 return $res;
5773 }
5774
5775 function order_processing( $results = array() ) {
5776 do_action('usces_pre_reg_orderdata');
5777 //db(function.php)
5778 //20110203ysk start
5779 $res = usces_check_acting_return_duplicate( $results );
5780 if($res != NULL) {
5781 usces_log('order processing duplicate : acting='.$_REQUEST['acting'].', order_id='.$res, 'acting_transaction.log');
5782 return 'ordercompletion';
5783 }
5784 if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) {
5785 usces_log($_REQUEST['acting'].' transaction : '.$_REQUEST['gid'], 'acting_transaction.log');//OK
5786 }
5787 //20110203ysk end
5788 //20110621ysk start 0000184
5789 if(isset($_REQUEST['acting']) && ('paypal_ec' == $_REQUEST['acting'])) {
5790 if( !usces_paypal_doecp( $results ) )
5791 return 'error';
5792 }
5793 //20110621ysk end
5794 $order_id = usces_reg_orderdata( $results );
5795 do_action('usces_post_reg_orderdata', $order_id, $results);
5796
5797 if ( $order_id ) {
5798 //mail(function.php)
5799 $mail_res = usces_send_ordermail( $order_id );
5800 return 'ordercompletion';
5801
5802 } else {
5803 return 'error';
5804 }
5805
5806 }
5807
5808 function acting_processing($acting_flg, $query) {
5809 global $wpdb;
5810 $entry = $this->cart->get_entry();
5811 $delim = apply_filters( 'usces_filter_delim', $this->delim );
5812 $acting_flg = trim($acting_flg);
5813 //$usces_entries = $this->cart->get_entry();
5814
5815 if( empty($acting_flg) ) return 'error';
5816
5817
5818 //include(USCES_PLUGIN_DIR . '/settlement/' . $acting_flg);
5819 if($acting_flg == 'paypal.php'){
5820 // if( !file_exists($this->options['settlement_path'] . $acting_flg) )
5821 // return 'error';
5822 //
5823 // require_once($this->options['settlement_path'] . "paypal.php");
5824 // paypal_submit();
5825
5826 }else if($acting_flg == 'epsilon.php'){
5827 if( !file_exists($this->options['settlement_path'] . $acting_flg) )
5828 return 'error';
5829
5830 if ( $this->use_ssl ) {
5831 $redirect = str_replace('http://', 'https://', USCES_CART_URL);
5832 }else{
5833 $redirect = USCES_CART_URL;
5834 }
5835 usces_log('epsilon card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5836 $query .= '&settlement=epsilon&redirect_url=' . urlencode($redirect);
5837 $query = $delim . ltrim($query, '&');
5838 header("location: " . $redirect . $query);
5839 exit;
5840
5841 }else if($acting_flg == 'acting_zeus_card' && 2 == $this->options['acting_settings']['zeus']['connection'] ){
5842 if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] ){
5843 if( !isset($_REQUEST['PaRes'])){
5844
5845 usces_log('zeus card 3dsecure entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5846 usces_zeus_3dsecure_enrol();
5847
5848 }else{
5849
5850 usces_log('zeus card 3dsecure : auth', 'acting_transaction.log');
5851 usces_zeus_3dsecure_auth();
5852 }
5853 }else{
5854 usces_log('zeus card no3d entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5855 $res = usces_zeus_secure_payreq();
5856 return $res;
5857 }
5858 }else if($acting_flg == 'acting_zeus_card' && 1 == $this->options['acting_settings']['zeus']['connection'] ){
5859
5860 $acting_opts = $this->options['acting_settings']['zeus'];
5861 $interface = parse_url($acting_opts['card_url']);
5862
5863 usces_log('zeus card securelink entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5864
5865 $vars = 'send=mall';
5866 $vars .= '&clientip=' . $acting_opts['clientip'];
5867 $vars .= '&cardnumber=' . $_POST['cardnumber'];
5868 if( 1 == $this->options['acting_settings']['zeus']['security'] ){
5869 $vars .= '&seccode=' . $_POST['securecode'];
5870 }
5871 $vars .= '&expyy=' . substr($_POST['expyy'], 2);
5872 $vars .= '&expmm=' . $_POST['expmm'];
5873 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
5874 $vars .= '&email=' . $_POST['email'];
5875 $vars .= '&sendid=' . $_POST['sendid'];
5876 $vars .= '&username=' . $_POST['username'];
5877 $vars .= '&money=' . $_POST['money'];
5878 $vars .= '&sendpoint=' . $_POST['sendpoint'];
5879 $vars .= '&printord=' . $_POST['printord'];
5880 $vars .= '&return_value=yes';
5881 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
5882 $vars .= '&div=' . $_POST['div'];
5883 }
5884
5885 //usces_log('zeus card *****vars : '.print_r($vars, true), 'acting_transaction.log');
5886
5887 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
5888 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
5889 //$header .= "Host: usctest.securesites.com\r\n";
5890 $header .= "User-Agent: PHP Script\r\n";
5891 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
5892 $header .= "Content-Length: " . strlen($vars) . "\r\n";
5893 $header .= "Connection: close\r\n\r\n";
5894 $header .= $vars;
5895 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
5896
5897 if ($fp){
5898 fwrite($fp, $header);
5899 while ( !feof($fp) ) {
5900 $scr = fgets($fp, 1024);
5901 $page .= $scr;
5902 }
5903 fclose($fp);
5904
5905 //usces_log('zeus card *****2 : '.print_r($page, true), 'acting_transaction.log');
5906 if( false !== strpos( $page, 'Success_order') ){
5907 usces_auth_order_acting_data($_POST['sendpoint']);
5908 usces_log('zeus card : Success_order ', 'acting_transaction.log');
5909 $ordd = usces_get_order_number( $page );
5910 //20120904ysk start 0000541
5911 if ( !isset($_POST['cbrand']) || (isset($_POST['howpay']) && 1 == $_POST['howpay']) ) {
5912 $args = '';
5913 } else {
5914 $div = 'div_'.$_POST['cbrand'];
5915 $args = '&cbrand='.$_POST['cbrand'].'&howpay='.$_POST['howpay'].'&'.$div.'='.$_POST[$div];
5916 }
5917 $args .= '&order_number='.$ordd.'&wctid='.$_POST['sendpoint'];
5918 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=1'.$args);
5919 //20120904ysk end
5920 exit;
5921 }else{
5922 $err_code = usces_get_err_code( $page );
5923 usces_log('zeus card : Certification Error : '.$err_code, 'acting_transaction.log');
5924 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0&err_code='.substr( $err_code, -3 ) );
5925 exit;
5926 }
5927 }else{
5928 usces_log('zeus card : Socket Error', 'acting_transaction.log');
5929 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
5930 }
5931 exit;
5932
5933 }else if($acting_flg == 'acting_zeus_conv'){
5934
5935 $acting_opts = $this->options['acting_settings']['zeus'];
5936 $interface = parse_url($acting_opts['conv_url']);
5937
5938
5939 $vars .= 'clientip=' . $acting_opts['clientip_conv'];
5940 $vars .= '&act=' . $_POST['act'];
5941 $vars .= '&money=' . $_POST['money'];
5942 $vars .= '&username=' . mb_convert_encoding($_POST['username'], 'SJIS', 'UTF-8');
5943 $vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
5944 $vars .= '&email=' . $_POST['email'];
5945 $vars .= '&pay_cvs=' . $_POST['pay_cvs'];
5946 $vars .= '&sendid=' . $_POST['sendid'];
5947 $vars .= '&sendpoint=' . $_POST['sendpoint'];
5948 if( !WCUtils::is_blank($acting_opts['testid_conv']) ){
5949 $vars .= '&testid=' . $acting_opts['testid_conv'];
5950 $vars .= '&test_type=' . $acting_opts['test_type_conv'];
5951 }
5952
5953
5954 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
5955 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
5956 $header .= "User-Agent: PHP Script\r\n";
5957 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
5958 $header .= "Content-Length: " . strlen($vars) . "\r\n";
5959 $header .= "Connection: close\r\n\r\n";
5960 $header .= $vars;
5961 //usces_log('zeus conv header : '.print_r($header, true), 'acting_transaction.log');
5962 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
5963
5964 if ($fp){
5965 fwrite($fp, $header);
5966 while ( !feof($fp) ) {
5967 $scr = fgets($fp, 1024);
5968 $page .= $scr;
5969 if( false !== strpos( $scr, 'order_no') )
5970 $qstr .= trim($scr) . '&';
5971 if( false !== strpos( $scr, 'pay_no1') )
5972 $qstr .= trim($scr) . '&';
5973 if( false !== strpos( $scr, 'pay_no2') )
5974 $qstr .= trim($scr) . '&';
5975 if( false !== strpos( $scr, 'pay_limit') )
5976 $qstr .= trim($scr) . '&';
5977 if( false !== strpos( $scr, 'pay_url') )
5978 $qstr .= trim($scr) . '&';
5979 if( false !== strpos( $scr, 'error_code') )
5980 $qstr .= trim($scr) . '&';
5981 if( false !== strpos( $scr, 'sendpoint') )
5982 $qstr .= trim($scr) . '&';
5983 }
5984 $qstr .= 'pay_cvs=' . $_POST['pay_cvs'].'&wctid='.$_POST['sendpoint'];
5985 fclose($fp);
5986 //usces_log('zeus page : '.$page, 'acting_transaction.log');
5987
5988 if( false !== strpos( $page, 'Success_order') ){
5989 usces_log('zeus conv entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
5990 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=1&' . $qstr);
5991 exit;
5992 }else{
5993 usces_log('zeus data NG : '.$page, 'acting_transaction.log');
5994 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
5995 exit;
5996 }
5997 }else{
5998 usces_log('zeus : sockopen NG', 'acting_transaction.log');
5999 header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
6000 }
6001 exit;
6002
6003 //20110208ysk start
6004 }else if($acting_flg == 'acting_paypal_ec') {
6005 $acting_opts = $this->options['acting_settings']['paypal'];
6006
6007 $nvpstr = $query;
6008 $nvpstr .= '&CURRENCYCODE='.$this->get_currency_code();
6009 //$nvpstr .= '&ADDROVERRIDE=1';
6010 $nvpstr .= '&PAYMENTACTION=' . apply_filters('usces_filter_paypal_ec_paymentaction', 'Sale');
6011
6012 //The returnURL is the location where buyers return to when a payment has been succesfully authorized.
6013 $nvpstr .= '&RETURNURL='.urlencode(USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=1');
6014
6015 //The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow
6016 $nvpstr .= '&CANCELURL='.urlencode(USCES_CART_URL.$delim.'confirm=1');
6017
6018 $nvpstr .= '&NOTIFYURL='.urlencode(USCES_PAYPAL_NOTIFY_URL);
6019
6020 $this->paypal->setMethod('SetExpressCheckout');
6021 $this->paypal->setData($nvpstr);
6022 $res = $this->paypal->doExpressCheckout();
6023 $resArray = $this->paypal->getResponse();
6024 $ack = strtoupper($resArray["ACK"]);
6025 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
6026 $token = urldecode($resArray["TOKEN"]);
6027 $payPalURL = $acting_opts['paypal_url'].'?cmd=_express-checkout&token='.$token.'&useraction=commit';
6028 header("Location: ".$payPalURL);
6029
6030 } else {
6031 //Display a user friendly Error on the page using any of the following error information returned by PayPal
6032 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
6033 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
6034 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
6035 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
6036 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');
6037 header("Location: ".USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=0');
6038 }
6039 exit;
6040 //20110208ysk end
6041 //20121030ysk start
6042 } elseif( $acting_flg == 'acting_telecom_edy' ) {
6043 $table_meta_name = $wpdb->prefix."usces_order_meta";
6044 $value = array();
6045 $value['usces_cart'] = $_SESSION['usces_cart'];
6046 $value['usces_entry'] = $_SESSION['usces_entry'];
6047 $value['usces_member'] = $_SESSION['usces_member'];
6048 $mvalue = serialize( $value );
6049 $mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue );
6050 $res = $wpdb->query( $mquery );
6051
6052 unset( $_SESSION['usces_cart'] );
6053 unset( $_SESSION['usces_entry'] );
6054
6055 $acting_opts = $this->options['acting_settings']['telecom'];
6056 header( "location: ".$acting_opts['send_url_edy'].'?acting=telecom_edy'.$query );
6057 exit;
6058 //20121030ysk end
6059 //20121206ysk start
6060 } else if( $acting_flg == 'acting_digitalcheck_card' ) {
6061 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6062 $interface = parse_url($acting_opts['send_url_user_id']);
6063 $kakutei = ( empty($acting_opts['card_kakutei']) ) ? '0' : $acting_opts['card_kakutei'];
6064
6065 $vars = 'IP='.$acting_opts['card_ip'];
6066 $vars .= '&PASS='.$acting_opts['card_pass'];
6067 $vars .= '&IP_USER_ID='.$_POST['IP_USER_ID'];
6068 $vars .= '&SID='.$_POST['SID'];
6069 $vars .= '&STORE=51';
6070 $vars .= '&N1='.$_POST['N1'];
6071 $vars .= '&K1='.$_POST['K1'];
6072 $vars .= '&KAKUTEI='.$kakutei;
6073 $vars .= '&FUKA='.$acting_flg;
6074
6075 $header = "POST ".$interface['path']." HTTP/1.1\r\n";
6076 $header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
6077 $header .= "User-Agent: PHP Script\r\n";
6078 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
6079 $header .= "Content-Length: ".strlen($vars)."\r\n";
6080 $header .= "Connection: close\r\n\r\n";
6081 $header .= $vars;
6082 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
6083
6084 if( $fp ) {
6085 fwrite( $fp, $header );
6086 $page = '';
6087 while( !feof($fp) ) {
6088 $line = fgets( $fp, 1024 );
6089 if( strcmp($line, "\r\n") == 0 ) {
6090 $headerdone = true;
6091 } elseif( $headerdone ) {
6092 $page .= $line;
6093 }
6094 }
6095 fclose($fp);
6096 $lines = explode("\n", $page);
6097 if( false !== strpos( $lines[0], 'OK') ) {
6098 usces_log('digitalcheck card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
6099 //$args = '&SID='.$lines[1];
6100 $args = '&SID='.$_POST['SID'].'&FUKA='.$acting_flg;
6101 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=1'.$args );
6102 } else {
6103 usces_log('digitalcheck card : Certification Error : '.$page, 'acting_transaction.log');
6104 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6105 }
6106 } else {
6107 usces_log('digitalcheck card : Socket Error', 'acting_transaction.log');
6108 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
6109 }
6110 exit;
6111 } else if( $acting_flg == 'acting_digitalcheck_conv' ) {
6112 if( isset($_REQUEST['STORE']) and '99' != $_REQUEST['STORE'] ) {
6113 $res = $this->order_processing();
6114 if( 'ordercompletion' == $res ) {
6115 $table_meta_name = $wpdb->prefix."usces_order_meta";
6116 $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] );
6117 $order_id = $wpdb->get_var($mquery);
6118 if( $order_id ) {
6119 $data = array( "settltment_status" => __("Failure",'usces'), "settltment_errmsg" => __("Settlement was not completed.",'usces') );
6120 $this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
6121 }
6122 $this->cart->crear_cart();
6123 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6124 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6125 exit;
6126 } else {
6127 usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
6128 header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=0' );
6129 }
6130 } else {
6131 $acting_opts = $this->options['acting_settings']['digitalcheck'];
6132 header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
6133 exit;
6134 }
6135 //20121206ysk end
6136 }
6137 do_action('usces_action_acting_processing', $acting_flg, $query);
6138 }
6139
6140 function inquiry_processing() {
6141
6142 $mail_res = usces_send_inquirymail();
6143
6144 if ( $mail_res )
6145 return 'inquiry_comp';
6146 else
6147 return 'inquiry_error';
6148 }
6149
6150 function lastprocessing() {
6151
6152 if ( $this->page == 'ordercompletion' )
6153 $this->cart->crear_cart();
6154
6155 unset($_SESSION['usces_singleitem']);
6156
6157 }
6158
6159 function is_item_zaiko( $post_id, $sku ){
6160 $status_num = (int)$this->getItemZaikoStatusId($post_id, $sku);
6161 $zaiko_num = $this->getItemZaikoNum($post_id, $sku);
6162
6163 if( false !== $zaiko_num
6164 && ( 0 < (int)$zaiko_num || WCUtils::is_blank($zaiko_num) )
6165 && false !== $status_num
6166 && 2 > $status_num
6167 ){
6168 return true;
6169 }else{
6170 return false;
6171 }
6172 }
6173
6174 // function for the cart ***********************************************************
6175 function get_total_price( $cart = array() ) {
6176 if( empty($cart) )
6177 $cart = $this->cart->get_cart();
6178
6179 $total_price = 0;
6180
6181 if( !empty($cart) ) {
6182 for($i=0; $i<count($cart); $i++) {
6183 $quantity = $cart[$i]['quantity'];
6184 $skuPrice = $cart[$i]['price'];
6185
6186 $total_price += ($skuPrice * $quantity);
6187 }
6188 }
6189 return apply_filters( 'usces_filter_get_total_price', $total_price, $cart);
6190 }
6191
6192 function get_total_quantity( $cart = array() ) {
6193 if( empty($cart) )
6194 $cart = $this->cart->get_cart();
6195
6196 $total_quantity = 0;
6197
6198 if( !empty($cart) ) {
6199 for($i=0; $i<count($cart); $i++) {
6200 $total_quantity += $cart[$i]['quantity'];
6201 }
6202 }
6203 return $total_quantity;
6204 }
6205
6206 function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) {
6207 if( $mem_id == '' || $this->options['membersystem_state'] == 'deactivate' || $this->options['membersystem_point'] == 'deactivate') return 0;
6208
6209 if ( empty($cart) )
6210 $cart = $this->cart->get_cart();
6211
6212 if ( empty($display_mode) )
6213 $display_mode = $this->options['display_mode'];
6214
6215 $point = 0;
6216 $total = $this->get_total_price( $cart );
6217 if ( $display_mode == 'Promotionsale' ) {
6218 if ( $this->options['campaign_privilege'] == 'discount' ) {
6219 foreach ( $cart as $rows ) {
6220 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6221 if ( !in_array($this->options['campaign_category'], $cats) ){
6222 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6223 $price = $rows['price'] * $rows['quantity'];
6224 $point += $price * $rate / 100;
6225 }
6226 }
6227 } elseif ( $this->options['campaign_privilege'] == 'point' ) {
6228 foreach ( $cart as $rows ) {
6229 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6230 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6231 $price = $rows['price'] * $rows['quantity'];
6232 $cats = $this->get_post_term_ids($rows['post_id'], 'category');
6233 if ( in_array($this->options['campaign_category'], $cats) )
6234 $point += $price * $rate / 100 * $this->options['privilege_point'];
6235 else
6236 $point += $price * $rate / 100;
6237 }
6238 }
6239 } else {
6240 foreach ( $cart as $rows ) {
6241 $rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
6242 //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
6243 $price = $rows['price'] * $rows['quantity'];
6244 $point += $price * $rate / 100;
6245 }
6246 }
6247
6248 //20130425ysk start 0000699
6249 if( 0 < $point ) $point = ceil( $point );
6250
6251 $entry = $this->cart->get_entry();
6252 $use_point = isset( $entry['order']['usedpoint'] ) ? (int)$entry['order']['usedpoint'] : 0;
6253 if( 0 < $use_point ) {
6254 $point = ceil( $point - ( $point * $use_point / $total ) );
6255 if( 0 > $point )
6256 $point = 0;
6257 }
6258
6259 return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart );
6260 //20130425ysk end
6261 }
6262
6263 function get_order_discount( $display_mode = '', $cart = array() ) {
6264 if ( empty($cart) )
6265 $cart = $this->cart->get_cart();
6266
6267 if ( empty($display_mode) )
6268 $display_mode = $this->options['display_mode'];
6269
6270 $discount = 0;
6271 $total = $this->get_total_price( $cart );
6272 if ( $display_mode == 'Promotionsale' ) {
6273 if ( $this->options['campaign_privilege'] == 'discount' ){
6274 if( 0 === (int)$this->options['campaign_category'] ){
6275 $discount = $total * $this->options['privilege_discount'] / 100;
6276 }else{
6277 foreach($cart as $cart_row){
6278 if( in_category((int)$this->options['campaign_category'], $cart_row['post_id']) ){
6279 $discount += $cart_row['price'] * $cart_row['quantity'] * $this->options['privilege_discount'] / 100;
6280 }
6281 }
6282 }
6283 }else if ( $this->options['campaign_privilege'] == 'point' ){
6284 $discount = 0;
6285 }
6286 }
6287
6288 $discount = ceil($discount * -1);
6289 $discount = apply_filters('usces_order_discount', $discount, $cart);
6290 return $discount;
6291 }
6292
6293 function getShippingCharge( $pref, $cart = array(), $entry = array() ) {
6294 if( empty($cart) )
6295 $cart = $this->cart->get_cart();
6296 if( empty($entry) )
6297 $entry = $this->cart->get_entry();
6298
6299 //�
6300 �送方法ID
6301 $d_method_id = $entry['order']['delivery_method'];
6302 //�
6303 �送方法index
6304 $d_method_index = $this->get_delivery_method_index($d_method_id);
6305 //送料ID
6306 $fixed_charge_id = ( isset($this->options['delivery_method'][$d_method_index]['charge']) ) ? $this->options['delivery_method'][$d_method_index]['charge'] : -1;
6307 $individual_quant = 0;
6308 $total_quant = 0;
6309 $charges = array();
6310 $individual_charges = array();
6311 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
6312
6313 foreach ( $cart as $rows ) {
6314
6315 if( -1 == $fixed_charge_id ){
6316 //商品送料ID
6317 $s_charge_id = $this->getItemShippingCharge($rows['post_id']);
6318 //商品送料index
6319 $s_charge_index = $this->get_shipping_charge_index($s_charge_id);
6320 //20120710ysk start 0000472
6321 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6322 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6323 //20120710ysk end
6324 }else{
6325
6326 $s_charge_index = $this->get_shipping_charge_index($fixed_charge_id);
6327 //20120710ysk start 0000472
6328 //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
6329 $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
6330 //20120710ysk end
6331 }
6332
6333 if($this->getItemIndividualSCharge($rows['post_id'])){
6334 $individual_quant += $rows['quantity'];
6335 $individual_charges[] = $rows['quantity'] * $charge;
6336 }else{
6337 $charges[] = $charge;
6338 }
6339 $total_quant += $rows['quantity'];
6340 }
6341
6342 if( count($charges) > 0 ){
6343 rsort($charges);
6344 $max_charge = $charges[0];
6345 $charge = $max_charge + array_sum($individual_charges);
6346 }else{
6347 $charge = array_sum($individual_charges);
6348 }
6349
6350 $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
6351
6352 return $charge;
6353 }
6354
6355 function getCODFee($payment_name, $amount_by_cod) {
6356 $payments = $this->getPayments($payment_name);
6357 if( 'COD' != $payments['settlement'] ){
6358 $fee = 0;
6359
6360 }else if( 'change' != $this->options['cod_type'] ){
6361 //$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : '';
6362 $fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : 0;
6363
6364 }else{
6365 $price = $amount_by_cod + $this->getTax( $amount_by_cod );
6366 if( $price <= $this->options['cod_first_amount'] ){
6367 $fee = $this->options['cod_first_fee'];
6368
6369 }else if( isset($this->options['cod_amounts']) ){
6370 $last = count( $this->options['cod_amounts'] ) - 1;
6371 if( $price > $this->options['cod_amounts'][$last] ){
6372 $fee = $this->options['cod_end_fee'];
6373
6374 }else{
6375 $fee = 0;
6376 foreach( $this->options['cod_amounts'] as $key => $value ){
6377 if( $price <= $value ){
6378 $fee = $this->options['cod_fees'][$key];
6379 break;
6380 }
6381 }
6382 }
6383 }else{
6384 $fee = $this->options['cod_end_fee'];
6385 }
6386 }
6387 $fee = apply_filters('usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod);
6388 return $fee;
6389 }
6390
6391 function getTax( $total ) {
6392 if( empty($this->options['tax_rate']) )
6393 return 0;
6394
6395 if( $this->options['tax_method'] == 'cutting' )
6396 $tax = floor($total * $this->options['tax_rate'] / 100);
6397 elseif($this->options['tax_method'] == 'bring')
6398 $tax = ceil($total * $this->options['tax_rate'] / 100);
6399 elseif($this->options['tax_method'] == 'rounding')
6400 $tax = round($total * $this->options['tax_rate'] / 100);
6401
6402 return $tax;
6403 }
6404
6405 function set_cart_fees( $member, &$entries ) {
6406 $carts = $this->cart->get_cart();
6407 $total_items_price = $this->get_total_price();
6408 if ( empty($this->options['postage_privilege']) || $total_items_price < $this->options['postage_privilege'] ) {
6409 $shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'] );
6410 } else {
6411 $shipping_charge = 0;
6412 }
6413 $shipping_charge = apply_filters('usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries);
6414 $payments = $this->getPayments( $entries['order']['payment_name'] );
6415 $discount = $this->get_order_discount();
6416 $use_point = $entries['order']['usedpoint'];
6417 $amount_by_cod = $total_items_price - $use_point + $discount + $shipping_charge;
6418 $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);
6419 $cod_fee = $this->getCODFee($entries['order']['payment_name'], $amount_by_cod);
6420 $cod_fee = apply_filters('usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge);
6421 $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
6422 $total_price = apply_filters('usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee);
6423 $tax = $this->getTax( $total_price );
6424 $total_full_price = $total_price + $tax;
6425 $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);
6426 $get_point = $this->get_order_point( $member['ID'] );
6427 //20130425ysk start 0000699
6428 //if(0 < (int)$use_point){
6429 // $get_point = ceil( $get_point - ($get_point * $use_point / $total_items_price) );
6430 // if(0 > $get_point)
6431 // $get_point = 0;
6432 //}
6433 //20130425ysk end
6434
6435 $array = array(
6436 'total_items_price' => $total_items_price,
6437 'total_price' => $total_price,
6438 'total_full_price' => $total_full_price,
6439 'getpoint' => $get_point,
6440 'usedpoint' => $use_point,
6441 'discount' => $discount,
6442 'shipping_charge' => $shipping_charge,
6443 'cod_fee' => $cod_fee,
6444 'tax' => $tax
6445 );
6446 $this->cart->set_order_entry( $array );
6447 //$entries = $this->cart->get_entry();
6448 //var_dump($entries);
6449 }
6450
6451 function getPayments( $payment_name ) {
6452 if( '#none#' == $payment_name )
6453 return NULL;
6454
6455 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
6456 if( isset($payments[$payment_name]) )
6457 return $payments[$payment_name];
6458 return NULL;
6459 }
6460
6461 function is_maintenance() {
6462 if ( $this->options['display_mode'] == 'Maintenancemode' )
6463 return true;
6464 else
6465 return false;
6466 }
6467
6468 // function maintenance_mode() {
6469 // if ( $this->is_maintenance() && !is_user_logged_in() && (!strstr($_SERVER['REQUEST_URI'], 'wp-admin') || !strstr($_SERVER['REQUEST_URI'], 'wp-login') ) ) {
6470 // include ( TEMPLATEPATH . '/maintenance.php ');
6471 // exit;
6472 // } elseif ( isset($_GET['uscesmode']) && $_GET['uscesmode'] == 'lostpassword' ) {
6473 // $error = isset($_GET['error']) ? '?error='.$_GET['error'] : '';
6474 // include ( TEMPLATEPATH . '/member/changepassword.php ');
6475 // exit;
6476 // }
6477 // }
6478
6479 function get_member_history($mem_id) {
6480 global $wpdb;
6481 $order_table = $wpdb->prefix . "usces_order";
6482
6483 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
6484 $query = apply_filters( 'usces_filter_member_history_query', $query, $mem_id );
6485 // $query = $wpdb->prepare("SELECT ID, order_cart, order_condition, order_date, order_usedpoint, order_getpoint,
6486 // order_discount, order_shipping_charge, order_cod_fee, order_tax, order_status
6487 // FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
6488 $results = $wpdb->get_results( $query );
6489
6490 $i=0;
6491 $res = array();
6492 foreach ( $results as $value ) {
6493 if(strpos($value->order_status, 'cancel') === false && strpos($value->order_status, 'estimate') === false){
6494
6495 $res[] = array(
6496 'ID' => $value->ID,
6497 'cart' => unserialize($value->order_cart),
6498 'condition' => unserialize($value->order_condition),
6499 'getpoint' => $value->order_getpoint,
6500 'usedpoint' => $value->order_usedpoint,
6501 'discount' => $value->order_discount,
6502 'shipping_charge' => $value->order_shipping_charge,
6503 'payment_name' => $value->order_payment_name,
6504 'cod_fee' => $value->order_cod_fee,
6505 'tax' => $value->order_tax,
6506 'order_status' => $value->order_status,
6507 'date' => mysql2date(__('Y/m/d'), $value->order_date),
6508 'order_date' => $value->order_date
6509 );
6510 $i++;
6511
6512 }
6513 }
6514
6515 return $res;
6516
6517 }
6518
6519 function get_post_term_ids( $post_id, $taxonomy ){
6520 global $wpdb;
6521 $query = $wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_relationships AS tr
6522 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
6523 WHERE tt.taxonomy = %s AND tr.object_id = %d", $taxonomy, $post_id);
6524 $ids = $wpdb->get_col( $query );
6525
6526 return $ids;
6527
6528 }
6529
6530 function get_tag_names($post_id) {
6531 global $wpdb;
6532 $tag = 'post_tag';
6533 $query = $wpdb->prepare("SELECT t.name FROM $wpdb->term_relationships AS tr
6534 INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
6535 INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id
6536 WHERE tt.taxonomy = %s AND tr.object_id = %d", $tag, $post_id);
6537 $names = $wpdb->get_col( $query );
6538
6539 return apply_filters('usces_filter_get_tag_names', $names, $post_id);
6540
6541 }
6542
6543 function get_ID_byItemName($itemname, $status = 'publish') {
6544 global $wpdb;
6545 $meta_key = '_itemCode';
6546 $query = $wpdb->prepare("SELECT p.ID FROM $wpdb->posts AS p
6547 INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id
6548 WHERE p.post_status = %s AND pm.meta_key = %s AND meta_value = %s ", $status, $meta_key, $itemname);
6549 $id = $wpdb->get_var( $query );
6550
6551 // $wpdb->show_errors();
6552 // $wpdb->print_error();
6553
6554 return $id;
6555
6556 }
6557
6558 function uscescv( $sessid, $flag ) {
6559
6560 $chars = '';
6561 $i=0;
6562 $h=0;
6563 $usces_cookie = $this->get_cookie();
6564 if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
6565 $cid = $usces_cookie['id'];
6566 }elseif( isset($_SESSION['usces_cookieid']) && !empty($_SESSION['usces_cookieid']) ){
6567 $cid = $_SESSION['usces_cookieid'];
6568 }else{
6569 $cid = 0;
6570 }
6571 while($h<strlen($sessid)){
6572 if(0 == $i % 3){
6573 $chars .= substr($i, -1);
6574 }else{
6575 $chars .= substr($sessid, $h, 1);
6576 $h++;
6577 }
6578 $i++;
6579 }
6580 if( $flag ){
6581 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
6582 $postfix = apply_filters('usces_sessid_force', $postfix);
6583 $sessid = $chars . '_' . $postfix . '_' . $cid . '_A';
6584 }else{
6585 $sessid = $chars . '_' . apply_filters('usces_sessid_flag', 'acting') . '_' . $cid . '_A';
6586 }
6587 $sessid = urlencode(base64_encode($sessid));
6588 //usces_log('sessid2 : '.$sessid, 'acting_transaction.log');
6589
6590 return $sessid;
6591 }
6592
6593 function uscesdc( $sessid ) {
6594 // $usces_cookie = $this->get_cookie();
6595 // if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
6596 // if( isset($usces_cookie['sslid']) && !empty($usces_cookie['sslid']) ){
6597 // $cid = $usces_cookie['sslid'];
6598 // }else{
6599 // $cid = 0;
6600 // }
6601 // }else{
6602 // if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
6603 // $cid = $usces_cookie['id'];
6604 // }else{
6605 // $cid = 0;
6606 // }
6607 // }
6608 $sessid = base64_decode(urldecode($sessid));
6609 list($sess, $addr, $cookieid, $none) = explode('_', $sessid, 4);
6610 $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
6611 $postfix = apply_filters('usces_sessid_force', $postfix);
6612 //usces_log('cid : '.$cid, 'acting_transaction.log');
6613 //usces_log('cookieid : '.$cookieid, 'acting_transaction.log');
6614 //usces_log('postfix : '.$postfix, 'acting_transaction.log');
6615 //usces_log('addr : '.$addr, 'acting_transaction.log');
6616 if( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) {
6617 $sessid = '';
6618 return NULL;
6619 }
6620 $chars = '';
6621 $h=0;
6622 while($h<strlen($sess)){
6623 if(0 != $h % 3){
6624 $chars .= substr($sess, $h, 1);
6625 }
6626 $h++;
6627 }
6628 $sessid = $chars;
6629
6630 return $sessid;
6631
6632 }
6633
6634 function get_visiter( $period ) {
6635 global $wpdb;
6636 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6637 $yearstr = substr($datestr, 0, 4);
6638 $monthstr = substr($datestr, 5, 2);
6639 $daystr = substr($datestr, 8, 2);
6640 if($period == 'today') {
6641 $date = $datestr;
6642 $today = $datestr;
6643 }else if($period == 'thismonth') {
6644 $date = date('Y-m-01');
6645 $today = $datestr;
6646 }else if($period == 'lastyear') {
6647 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6648 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
6649 }
6650 $table_name = $wpdb->prefix . 'usces_access';
6651
6652 $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);
6653 $res = $wpdb->get_row($query, ARRAY_A);
6654
6655 if( $res == NULL )
6656 return 0;
6657 else
6658 return $res['ct1']+$res['ct2'];
6659 }
6660
6661 function get_fvisiter( $period ) {
6662 global $wpdb;
6663 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6664 $yearstr = substr($datestr, 0, 4);
6665 $monthstr = substr($datestr, 5, 2);
6666 $daystr = substr($datestr, 8, 2);
6667 if($period == 'today') {
6668 $date = $datestr;
6669 $today = $datestr;
6670 }else if($period == 'thismonth') {
6671 $date = date('Y-m-01');
6672 $today = $datestr;
6673 }else if($period == 'lastyear') {
6674 $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6675 $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
6676 }
6677 $table_name = $wpdb->prefix . 'usces_access';
6678
6679 $query = $wpdb->prepare("SELECT SUM(acc_num2) AS ct FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today);
6680 $res = $wpdb->get_var($query);
6681
6682 if( $res == NULL )
6683 return 0;
6684 else
6685 return $res;
6686 }
6687
6688 function get_order_num( $period ) {
6689 global $wpdb;
6690 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6691 $yearstr = substr($datestr, 0, 4);
6692 $monthstr = substr($datestr, 5, 2);
6693 $daystr = substr($datestr, 8, 2);
6694 if($period == 'today') {
6695 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
6696 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6697 }else if($period == 'thismonth') {
6698 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
6699 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6700 }else if($period == 'lastyear') {
6701 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6702 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
6703 }
6704 $table_name = $wpdb->prefix . 'usces_order';
6705
6706 $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');
6707 $res = $wpdb->get_var($query);
6708
6709 if( $res == NULL )
6710 return 0;
6711 else
6712 return $res;
6713 }
6714
6715 function get_order_amount( $period ) {
6716 global $wpdb;
6717 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6718 $yearstr = substr($datestr, 0, 4);
6719 $monthstr = substr($datestr, 5, 2);
6720 $daystr = substr($datestr, 8, 2);
6721 if($period == 'today') {
6722 $date = date('Y-m-d 00:00:00', current_time('timestamp'));
6723 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6724 }else if($period == 'thismonth') {
6725 $date = date('Y-m-01 00:00:00', current_time('timestamp'));
6726 $today = date('Y-m-d 23:59:59', current_time('timestamp'));
6727 }else if($period == 'lastyear') {
6728 $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
6729 $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
6730 }
6731 $table_name = $wpdb->prefix . 'usces_order';
6732
6733 $query = $wpdb->prepare("SELECT
6734 SUM(order_item_total_price) AS price,
6735 SUM(order_usedpoint) AS point,
6736 SUM(order_discount) AS discount,
6737 SUM(order_shipping_charge) AS shipping,
6738 SUM(order_cod_fee) AS cod,
6739 SUM(order_tax) AS tax
6740 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');
6741 $res = $wpdb->get_row($query, ARRAY_A);
6742
6743 if( $res == NULL )
6744 return 0;
6745 else
6746 return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax'];
6747 }
6748
6749 function is_status($need, $str){
6750 $array = explode(',', $str);
6751 return in_array($need, $array);
6752 }
6753
6754 function make_status( $taio='', $receipt='', $admin='' ){
6755 $str = '';
6756 if($taio != '' && $taio != '#none#')
6757 $str .= $taio . ',';
6758 if($receipt != '' && $receipt != '#none#')
6759 $str .= $receipt . ',';
6760 if($admin != '' && $admin != '#none#')
6761 $str .= $admin . ',';
6762 return $str;
6763 }
6764
6765 function get_memberid_by_email($email){
6766 global $wpdb;
6767 $table_name = $wpdb->prefix . "usces_member";
6768 $query = $wpdb->prepare("SELECT ID FROM $table_name WHERE mem_email = %s", $email);
6769 $res = $wpdb->get_var($query);
6770 return $res;
6771 }
6772
6773 function get_condition(){
6774 //20120807ysk start 0000544
6775 $order_conditions = array(
6776 'display_mode' => $this->options['display_mode'],
6777 'campaign_privilege' => $this->options['campaign_privilege'],
6778 'campaign_category' => $this->options['campaign_category'],
6779 'privilege_point' => $this->options['privilege_point'],
6780 'privilege_discount' => $this->options['privilege_discount']);
6781 return $order_conditions;
6782 //20120807ysk end
6783 }
6784
6785 function get_bestseller_ids( $days = "" ){
6786 global $wpdb;
6787 $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
6788 $yearstr = substr($datestr, 0, 4);
6789 $monthstr = substr($datestr, 5, 2);
6790 $daystr = substr($datestr, 8, 2);
6791 $res = array();
6792 $order_table_name = $wpdb->prefix . "usces_order";
6793 $where = "";
6794 if( empty($days) ){
6795 $days = 30;
6796 }
6797 $order_date = date('Y-m-d H:i:s', mktime(0, 0, 0, (int)$monthstr, ((int)$daystr-$days), (int)$yearstr));
6798 $where = " WHERE order_date >= '{$order_date}'";
6799 $query = "SELECT order_cart FROM {$order_table_name}" . $where;
6800 $dbres = $wpdb->get_col($query);
6801 if(!$dbres) return false;
6802
6803 foreach((array)$dbres as $carts){
6804 $rows = unserialize($carts);
6805 foreach((array)$rows as $carts){
6806 if( 'publish' != get_post_status($carts['post_id']) )
6807 continue;
6808
6809 $id = $carts['post_id'];
6810 $qu = $carts['quantity'];
6811 if(array_key_exists($id, $res)){
6812 $res[$id] = $res[$id] + $qu;
6813 }else{
6814 $res[$id] = $qu;
6815 }
6816 }
6817 }
6818 arsort($res);
6819 $results = array_keys($res);
6820 return $results;
6821 }
6822
6823 function get_items_num(){
6824 global $wpdb;
6825 $query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM {$wpdb->posts}
6826 WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
6827 'item', 'post', 'trush');
6828 $res = $wpdb->get_var($query);
6829
6830 return $res;
6831 }
6832
6833 function is_gptekiyo( $post_id, $sku, $quant ) {
6834 $skus = $this->get_skus( $post_id, 'code' );
6835 if( !isset($skus[$sku]['gp']) || !$skus[$sku]['gp'] ) return false;
6836
6837 $GpN1 = $this->getItemGpNum1($post_id);
6838 $GpN2 = $this->getItemGpNum2($post_id);
6839 $GpN3 = $this->getItemGpNum3($post_id);
6840
6841 if( empty($GpN1) ) {
6842
6843 return false;
6844
6845 }else if( !empty($GpN1) && empty($GpN2) ) {
6846
6847 if( $quant >= $GpN1 ) {
6848 return true;
6849 }else{
6850 return false;
6851 }
6852
6853 }else if( !empty($GpN1) && !empty($GpN2) && empty($GpN3) ) {
6854
6855 if( $quant >= $GpN2 ) {
6856 return true;
6857 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
6858 return true;
6859 }else{
6860 return false;
6861 }
6862
6863 }else if( !empty($GpN1) && !empty($GpN2) && !empty($GpN3) ) {
6864
6865 if( $quant >= $GpN3 ) {
6866 return true;
6867 }else if( $quant >= $GpN2 && $quant < $GpN3 ) {
6868 return true;
6869 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
6870 return true;
6871 }else{
6872 return false;
6873 }
6874 }
6875 }
6876
6877 function get_available_delivery_method() {
6878 if($this->cart->num_row() > 0) {
6879 $cart = $this->cart->get_cart();
6880 $before_deli = array();
6881 $intersect = array();
6882 $integration = array();
6883 $temp = array();
6884 $in = 0;
6885 foreach($cart as $key => $row){
6886 $deli = $this->getItemDeliveryMethod($row['post_id']);
6887 //usces_p($deli);
6888 if( empty($deli))
6889 continue;
6890
6891 //usces_log('deli : '.print_r($deli, true), 'acting_transaction.log');
6892 if( 0 === $in ){
6893 $intersect = $deli;
6894 }
6895 $intersect = array_intersect($deli, $intersect);
6896 $before_deli = $deli;
6897 foreach($deli as $value){
6898 $integration[] = $value;
6899 }
6900 $in++;
6901 }
6902 $integration = array_unique($integration);
6903 foreach($integration as $id){
6904 $index = $this->get_delivery_method_index($id);
6905 $temp[$index] = $id;
6906 }
6907 ksort($temp);
6908 //20120820ysk start 0000546
6909 //$force = array($temp[0]);
6910 $force = array(array_shift($temp));
6911 //20120820ysk end
6912
6913 if( empty($intersect) ){
6914 return $force;
6915 }else{
6916 return $intersect;
6917 }
6918 }
6919 return array();
6920 }
6921
6922 function get_delivery_method_index($id) {
6923 $index = false;
6924 for($i=0; $i<count($this->options['delivery_method']); $i++){
6925 if( $this->options['delivery_method'][$i]['id'] === (int)$id ){
6926 $index = $i;
6927 }
6928 }
6929 if($index === false)
6930 return -1;
6931 else
6932 return $index;
6933 }
6934
6935 function get_shipping_charge_index($id) {
6936 $index = false;
6937 for($i=0; $i<count($this->options['shipping_charge']); $i++){
6938 //20120710ysk start 0000472
6939 //if( $this->options['shipping_charge'][$i]['id'] === $id ){
6940 if( (int)$this->options['shipping_charge'][$i]['id'] == (int)$id ){
6941 //20120710ysk end
6942 $index = $i;
6943 }
6944 }
6945 if($index === false)
6946 return -1;
6947 else
6948 return $index;
6949 }
6950
6951 function get_initial_data($xml){
6952 $buf = file_get_contents($xml);
6953 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);
6954 return $match;
6955 }
6956
6957 function getCurrencySymbol(){
6958 global $usces_settings;
6959 $cr = $this->options['system']['currency'];
6960 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
6961 return $symbol;
6962 }
6963
6964 function getCartItemName($post_id, $sku){
6965 $name_arr = array();
6966 $name_str = '';
6967
6968 foreach($this->options['indi_item_name'] as $key => $value){
6969 if($value){
6970 $pos = (int)$this->options['pos_item_name'][$key];
6971 $ind = ($pos === 0) ? 'A' : $pos;
6972 switch($key){
6973 case 'item_name':
6974 $name_arr[$ind][$key] = $this->getItemName($post_id);
6975 break;
6976 case 'item_code':
6977 $name_arr[$ind][$key] = $this->getItemCode($post_id);
6978 break;
6979 case 'sku_name':
6980 $name_arr[$ind][$key] = $this->getItemSkuDisp($post_id, $sku);
6981 break;
6982 case 'sku_code':
6983 $name_arr[$ind][$key] = $sku;
6984 break;
6985 }
6986 }
6987
6988 }
6989 ksort($name_arr);
6990 foreach($name_arr as $vals){
6991 foreach($vals as $key => $value){
6992
6993 $name_str .= $value . ' ';
6994 }
6995 }
6996
6997 $name_str = apply_filters('usces_admin_order_item_name_filter', $name_str, $post_id, $sku);
6998
6999 return trim($name_str);
7000 }
7001
7002 function set_reserve_pre_order_id(){
7003 $entry = $this->cart->get_entry();
7004 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : uniqid('');
7005 $this->cart->set_pre_order_id($id);
7006 }
7007
7008 function get_current_pre_order_id(){
7009 $entry = $this->cart->get_entry();
7010 $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : NULL;
7011 return $id;
7012 }
7013
7014 function get_reserve($order_id, $key){
7015 global $wpdb;
7016 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7017 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7018 $order_id, $key);
7019 $res = $wpdb->get_var($query);
7020 return $res;
7021 }
7022
7023 //20100818ysk start
7024 //20100816ysk start
7025 //function get_order_meta($order_id, $key) {
7026 function get_order_meta_value($key, $order_id) {
7027 global $wpdb;
7028 $order_meta_table_name = $wpdb->prefix . "usces_order_meta";
7029 $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
7030 $order_id, $key);
7031 $res = $wpdb->get_var($query);
7032 return $res;
7033 }
7034 //20100816ysk end
7035 function set_order_meta_value($key, $meta_value, $order_id) {
7036 global $wpdb;
7037
7038 //if( empty($meta_value) ) return;
7039 if( empty($order_id) ) return;
7040
7041 $table_name = $wpdb->prefix . "usces_order_meta";
7042 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s",
7043 $order_id, $key);
7044 $res = $wpdb->get_var($query);
7045 if(0 < $res) {
7046 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s",
7047 $meta_value,
7048 $order_id,
7049 $key
7050 );
7051 $res2 = $wpdb->query($query);
7052 } else {
7053 $query = $wpdb->prepare("INSERT INTO $table_name (order_id, meta_key, meta_value)
7054 VALUES(%d, %s, %s)",
7055 $order_id,
7056 $key,
7057 $meta_value
7058 );
7059 $res2 = $wpdb->query($query);
7060 }
7061 return $res2;
7062 }
7063 //20130524ysk start
7064 function del_order_meta( $key, $order_id ) {
7065 global $wpdb;
7066 $table_name = $wpdb->prefix."usces_order_meta";
7067 $query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
7068 $res = $wpdb->query( $query );
7069 return $res;
7070 }
7071 //20130524ysk end
7072 function set_session_custom_member($member_id) {
7073 unset($_SESSION['usces_member']['custom_member']);
7074 $meta = usces_has_custom_field_meta('member');
7075 if(is_array($meta)) {
7076 $keys = array_keys($meta);
7077 foreach($keys as $key) {
7078 $csmb_key = 'csmb_'.$key;
7079 $_SESSION['usces_member']['custom_member'][$key] = maybe_unserialize($this->get_member_meta_value($csmb_key, $member_id));
7080 }
7081 }
7082 }
7083
7084 function reg_custom_member($member_id) {
7085 //20130524ysk start 0000712
7086 $csmb_meta = usces_has_custom_field_meta( 'member' );
7087 if( is_array($csmb_meta) ) {
7088 foreach( $csmb_meta as $key => $entry ) {
7089 if( '4' == $entry['means'] ) {
7090 $this->del_member_meta( 'csmb_'.$key, $member_id );
7091 }
7092 }
7093 }
7094 //20130524ysk end
7095 if( !empty($_POST['custom_member']) ) {
7096 foreach( $_POST['custom_member'] as $key => $value ) {
7097 $csmb_key = 'csmb_'.$key;
7098 if( is_array($value) )
7099 $value = serialize($value);
7100 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7101 if(false === $res)
7102 return false;
7103 }
7104 }elseif( isset($_POST['custom_customer']) ){
7105 foreach( $_POST['custom_customer'] as $key => $value ) {
7106 $csmb_key = 'csmb_'.$key;
7107 if( is_array($value) )
7108 $value = serialize($value);
7109 $res = $this->set_member_meta_value($csmb_key, $value, $member_id);
7110 if(false === $res)
7111 return false;
7112 }
7113 }
7114 }
7115 //20100818ysk end
7116
7117 function save_order_acting_data($rand){
7118 global $wpdb;
7119 $data = serialize(array( 'cart' => $this->cart->get_cart(), 'entry' => $this->cart->get_entry() ));
7120 $table_name = $wpdb->prefix . "usces_access";
7121 $query = $wpdb->prepare("INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value)
7122 VALUES(%s, %s, now(), %s, %s)",
7123 'acting_data',
7124 $this->get_uscesid(false),
7125 $rand,
7126 $data
7127 );
7128 $res = $wpdb->query($query);
7129 return $res;
7130 }
7131
7132 //20100818ysk start
7133 function set_member_meta_value($key, $meta_value, $member_id = ''){
7134 global $wpdb;
7135
7136 //if( empty($meta_value) ) return;
7137 if( WCUtils::is_blank($member_id) ) {
7138 if( !$this->is_member_logged_in() ) return;
7139 $member = $this->get_member();
7140 $member_id = $member['ID'];
7141 }
7142
7143 $table_name = $wpdb->prefix . "usces_member_meta";
7144 //$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7145 $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s",
7146 $member_id, $key);
7147 $res = $wpdb->get_var($query);
7148 //if($res != NULL){
7149 if(0 < $res){
7150 $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s",
7151 $meta_value,
7152 $member_id,
7153 $key
7154 );
7155 $res2 = $wpdb->query($query);
7156 }else{
7157 $query = $wpdb->prepare("INSERT INTO $table_name (member_id, meta_key, meta_value)
7158 VALUES(%d, %s, %s)",
7159 $member_id,
7160 $key,
7161 $meta_value
7162 );
7163 $res2 = $wpdb->query($query);
7164 }
7165 return $res2;
7166 }
7167 //20100818ysk end
7168
7169 function get_member_meta_value($key, $member_id){
7170 global $wpdb;
7171 $table_name = $wpdb->prefix . "usces_member_meta";
7172 $query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
7173 $member_id, $key);
7174 $res = $wpdb->get_var($query);
7175 return $res;
7176 }
7177
7178 function del_member_meta($key, $member_id){
7179 global $wpdb;
7180 $table_name = $wpdb->prefix . "usces_member_meta";
7181 $query = $wpdb->prepare("DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s",
7182 $member_id, $key);
7183 $res = $wpdb->query($query);
7184 return $res;
7185 }
7186
7187 function get_member_meta($member_id){
7188 global $wpdb;
7189 $table_name = $wpdb->prefix . "usces_member_meta";
7190 $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_%');
7191 $res = $wpdb->get_results($query, ARRAY_A);
7192 return $res;
7193 }
7194
7195 function get_settle_info_field( $order_id ){
7196 global $wpdb;
7197 $fields = array();
7198 $table_name = $wpdb->prefix . "usces_order_meta";
7199 $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)",
7200 $order_id, 'acting_%', 'settlement_id', 'order_number', 'res_tracking_id', 'SID');
7201 $res = $wpdb->get_results($query, ARRAY_A);
7202 if( !$res )
7203 return $fields;
7204
7205 foreach( $res as $value ){
7206 if( 'settlement_id' == $value['meta_key'] ){
7207 $meta_values = maybe_unserialize($value['meta_value']);
7208 if( is_array($meta_values) ){
7209 foreach( $meta_values as $key => $meta_value ){
7210 $fields[$key] = $meta_value;
7211 }
7212 }else{
7213 $fields['settlement_id'] = $meta_values;
7214 }
7215 }elseif( 'order_number' == $value['meta_key'] ){
7216 $fields['order_number'] = $value['meta_value'];
7217 }elseif( 'res_tracking_id' == $value['meta_key'] ){
7218 $fields['res_tracking_id'] = $value['meta_value'];
7219 }elseif( 'SID' == $value['meta_key'] ){
7220 $fields['SID'] = $value['meta_value'];
7221 }elseif( 'acting_' == substr($value['meta_key'], 0, 7) ){
7222 $meta_values = unserialize($value['meta_value']);
7223 if(is_array($meta_values)){
7224 foreach( $meta_values as $key => $meta_value ){
7225 $fields[$key] = $meta_value;
7226 }
7227 }
7228 }
7229 }
7230 return $fields;
7231 }
7232
7233 function get_post_custom($post_id, $orderby='meta_id', $order='ASC'){
7234 global $wpdb;
7235 $table = $wpdb->prefix . "postmeta";
7236 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7237 $post_id), ARRAY_A );
7238
7239 if ( !empty($meta_list) ) {
7240 foreach ( $meta_list as $metarow) {
7241 $mkey = $metarow['meta_key'];
7242 $mval = $metarow['meta_value'];
7243 $res[$mkey][] = $mval;
7244 }
7245 }
7246 return $res;
7247 }
7248
7249 function get_post_user_custom($post_id, $orderby='meta_id', $order='ASC'){
7250 global $wpdb;
7251 $res = array();
7252 $table = $wpdb->prefix . "postmeta";
7253 $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order",
7254 $post_id), ARRAY_A );
7255
7256 if ( !empty($meta_list) ) {
7257 foreach ( $meta_list as $metarow) {
7258 if( 0 === strpos($metarow['meta_key'], '_') )
7259 continue;
7260
7261 $mkey = $metarow['meta_key'];
7262 $mval = $metarow['meta_value'];
7263 if( array_key_exists($mkey, $res) ){
7264 $cval = $res[$mkey];
7265 $cval = (array)$cval;
7266 $cval[] = $mval;
7267 $res[$mkey] = $cval;
7268 }else{
7269 $res[$mkey] = $mval;
7270 }
7271 }
7272 }
7273 return $res;
7274 }
7275
7276 function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ){
7277 global $usces_settings;
7278 $cr = $this->options['system']['currency'];
7279 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7280 if( !$seperator_flag ){
7281 $seperator = '';
7282 }
7283 $price = number_format((double)$amount, $decimal, $point, $seperator);//0000652
7284
7285 if( $symbol_pre )
7286 $price = ( usces_is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol ) . $price;
7287
7288 if( $symbol_post )
7289 $price = $price . __($code, 'usces');
7290
7291 return $price;
7292 }
7293
7294 function get_currency_code(){
7295 global $usces_settings;
7296 $cr = $this->options['system']['currency'];
7297 list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
7298 return $code;
7299 }
7300
7301 //shortcode-----------------------------------------------------------------------------
7302 function sc_company_name() {
7303 return htmlspecialchars($this->options['company_name']);
7304 }
7305 function sc_zip_code() {
7306 return htmlspecialchars($this->options['zip_code']);
7307 }
7308 function sc_address1() {
7309 return htmlspecialchars($this->options['address1']);
7310 }
7311 function sc_address2() {
7312 return htmlspecialchars($this->options['address2']);
7313 }
7314 function sc_tel_number() {
7315 return htmlspecialchars($this->options['tel_number']);
7316 }
7317 function sc_fax_number() {
7318 return htmlspecialchars($this->options['fax_number']);
7319 }
7320 function sc_inquiry_mail() {
7321 return htmlspecialchars($this->options['inquiry_mail']);
7322 }
7323 function sc_payment() {
7324 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
7325 $htm = "<ul>\n";
7326 foreach ( (array)$payments as $payment ) {
7327 $htm .= "<li>" . htmlspecialchars($payment['name']) . "<br />\n";
7328 $htm .= nl2br(htmlspecialchars($payment['explanation'])) . "</li>\n";
7329 }
7330 $htm .= "</ul>\n";
7331 return $htm;
7332 }
7333 function sc_payment_title() {
7334 $payments = $this->options['payment_method'];
7335 $htm = "<ul>\n";
7336 foreach ( (array)$payments as $payment ) {
7337 $htm .= "<li>" . esc_html($payment['name']) . "</li>\n";
7338 }
7339 $htm .= "</ul>\n";
7340 return $htm;
7341 }
7342 function sc_cod_fee() {
7343 return number_format($this->options['cod_fee']);
7344 }
7345 function sc_start_point() {
7346 return number_format($this->options['start_point']);
7347 }
7348 function sc_postage_privilege() {
7349 if(empty($this->options['postage_privilege']))
7350 return;
7351 return number_format($this->options['postage_privilege']);
7352 }
7353 function sc_shipping_charge() {
7354 //20120710ysk start 0000472
7355 $entry = $this->cart->get_entry();
7356 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
7357 //20120710ysk end
7358 $arr = array();
7359 foreach ( (array)$this->options['shipping_charge'] as $charges ) {
7360 //20120710ysk start 0000472
7361 //foreach ( (array)$charges['value'] as $value ) {
7362 foreach ( (array)$charges[$country] as $value ) {
7363 //20120710ysk end
7364 $arr[] = $value;
7365 }
7366 }
7367 sort($arr);
7368 $min = $arr[0];
7369 rsort($arr);
7370 $max = $arr[0];
7371 if($min == $max){
7372 $res = number_format($min);
7373 }else{
7374 $res = number_format($min) . __(' - ', 'usces') . number_format($max);
7375 }
7376 return $res;
7377 }
7378 function sc_site_url() {
7379 return get_option('home');
7380 }
7381 function sc_button_to_cart($atts) {
7382 extract(shortcode_atts(array(
7383 'item' => '',
7384 'sku' => '',
7385 'value' => __('to the cart', 'usces'),
7386 'force' => 0,
7387 'quant' => 0,
7388 'opt' => 1,
7389 ), $atts));
7390
7391 $post_id = $this->get_ID_byItemName($item);
7392 $datas = $this->get_skus( $post_id, 'code' );
7393 $zaikonum = $datas[$sku]['stocknum'];
7394 $zaiko = $datas[$sku]['stock'];
7395 $gptekiyo = $datas[$sku]['gp'];
7396 $skuPrice = $datas[$sku]['price'];
7397 $sku_enc = urlencode($sku);
7398 $mats = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc');
7399 if( ! $this->is_item_zaiko( $post_id, $sku ) ){
7400 return '<div class="button_status">' . esc_html($this->zaiko_status[$zaiko]) . '</div>';
7401 }
7402
7403 $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n";
7404 $html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"{$zaikonum}\" />\n";
7405 $html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"{$zaiko}\" />\n";
7406 $html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"{$gptekiyo}\" />\n";
7407 $html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"{$skuPrice}\" />\n";
7408 if( 1 == $opt ){
7409 $html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' );
7410 }elseif( 2 == $opt ){
7411 $html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' );
7412 }
7413 if( $quant ){
7414 $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;}\" />";
7415 $html .= apply_filters('usces_filter_sc_itemQuant', $quant_field, $mats);
7416 }
7417 $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) . " />";
7418 $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
7419 if( $force )
7420 $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
7421 $html = apply_filters('usces_filter_single_item_inform', $html);
7422 $html .= "</form>";
7423 $html .= '<div class="error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";
7424
7425 return $html;
7426 }
7427
7428 function filter_itemPage($content){
7429 global $post;
7430 $html = '';
7431
7432 if( ($post->post_mime_type != 'item' || !is_single()) ) return $content;
7433 if( post_password_required($post) ) return $content;
7434
7435 $temp_path = apply_filters('usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php');
7436 include( $temp_path );
7437
7438 $content = apply_filters('usces_filter_itemPage', $html, $post->ID);
7439
7440 return $content;
7441 }
7442
7443 function filter_cartContent($content) {
7444 global $post;
7445 $html = '';
7446
7447 switch($this->page){
7448 case 'cart':
7449 $temp_path = apply_filters('usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php');
7450 include( $temp_path );
7451 break;
7452 case 'customer':
7453 $temp_path = apply_filters('usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php');
7454 include( $temp_path );
7455 break;
7456 case 'delivery':
7457 $temp_path = apply_filters('usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php');
7458 include( $temp_path );
7459 break;
7460 case 'confirm':
7461 $temp_path = apply_filters('usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php');
7462 include( $temp_path );
7463 break;
7464 case 'ordercompletion':
7465 $temp_path = apply_filters('usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php');
7466 include( $temp_path );
7467 break;
7468 case 'error':
7469 $temp_path = apply_filters('usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php');
7470 include( $temp_path );
7471 break;
7472 case 'maintenance':
7473 $temp_path = apply_filters('usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php');
7474 include( $temp_path );
7475 break;
7476 case 'search_item':
7477 $temp_path = apply_filters('usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php');
7478 include( $temp_path );
7479 break;
7480 case 'wp_search':
7481 if($post->post_mime_type == 'item'){
7482 $temp_path = apply_filters('usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php');
7483 include( $temp_path );
7484 }else{
7485 $html = $content;
7486 }
7487 break;
7488 default:
7489 $html = $content;
7490 }
7491
7492 if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) )
7493 $html = str_replace('src="'.site_url(), 'src="'.USCES_SSL_URL_ADMIN, $html);
7494
7495 $html = apply_filters('usces_filter_cartContent', $html);
7496
7497 $content = $html;
7498
7499 remove_filter('the_title', array($this, 'filter_cartTitle'));
7500
7501 return $content;
7502 }
7503
7504 function filter_cartTitle($title) {
7505
7506 if( $title == 'Cart' || $title == __('Cart', 'usces') ){
7507 switch($this->page){
7508 case 'cart':
7509 $newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces'));
7510 break;
7511 case 'customer':
7512 $newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces'));
7513 break;
7514 case 'delivery':
7515 $newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces'));
7516 break;
7517 case 'confirm':
7518 $newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces'));
7519 break;
7520 case 'ordercompletion':
7521 $newtitle = apply_filters('usces_filter_title_ordercompletion', __('Completion', 'usces'));
7522 break;
7523 case 'error':
7524 $newtitle = apply_filters('usces_filter_title_carterror', __('Error', 'usces'));
7525 break;
7526 case 'search_item':
7527 $newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces'));
7528 break;
7529 case 'maintenance':
7530 $newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces'));
7531 break;
7532 case 'login':
7533 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
7534 break;
7535 default:
7536 $newtitle = apply_filters('usces_filter_title_cart_default', $title);
7537 }
7538 }else{
7539 $newtitle = $title;
7540 }
7541
7542 $newtitle = apply_filters('usces_filter_cartTitle', $newtitle);
7543 return $newtitle;
7544 }
7545
7546 function action_cartFilter(){
7547 add_filter('the_title', array($this, 'filter_cartTitle'),20);
7548 add_filter('the_content', array($this, 'filter_cartContent'),20);
7549 }
7550
7551 function action_search_item(){
7552 include(TEMPLATEPATH . '/page.php');
7553 exit;
7554 }
7555
7556 function filter_memberContent($content) {
7557 global $post;
7558 $html = '';
7559
7560 if($this->options['membersystem_state'] == 'activate'){
7561
7562 if( $this->is_member_logged_in() ) {
7563
7564 $member_regmode = 'editmemberform';
7565 $temp_path = apply_filters('usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php');
7566 include( $temp_path );
7567
7568 } else {
7569
7570 switch($this->page){
7571 case 'login':
7572 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
7573 include( $temp_path );
7574 break;
7575 case 'lostmemberpassword':
7576 $temp_path = apply_filters('usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php');
7577 include( $temp_path );
7578 break;
7579 case 'changepassword':
7580 $temp_path = apply_filters('usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php');
7581 include( $temp_path );
7582 break;
7583 case 'newcompletion':
7584 case 'editcompletion':
7585 case 'lostcompletion':
7586 case 'changepasscompletion':
7587 $temp_path = apply_filters('usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php');
7588 include( $temp_path );
7589 break;
7590 case 'newmemberform':
7591 $member_form_title = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
7592 $member_regmode = 'newmemberform';
7593 $temp_path = apply_filters('usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php');
7594 include( $temp_path );
7595 break;
7596 default:
7597 $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
7598 include( $temp_path );
7599 }
7600
7601 }
7602 }else{
7603 $html .= "<p>".__('Member Services is not running currently.','usces')."</p>";
7604 }
7605
7606 $content = $html;
7607
7608 remove_filter('the_title', array($this, 'filter_memberTitle'));
7609
7610 return $content;
7611 }
7612
7613 function filter_memberTitle($title) {
7614
7615 if( $this->options['membersystem_state'] == 'activate' && ($title == 'Member' || $title == __('Membership', 'usces')) ){
7616 switch($this->page){
7617 case 'login':
7618 $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
7619 break;
7620 case 'newmemberform':
7621 $newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
7622 break;
7623 case 'lostmemberpassword':
7624 $newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces'));
7625 break;
7626 case 'changepassword':
7627 $newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces'));
7628 break;
7629 case 'newcompletion':
7630 case 'editcompletion':
7631 case 'lostcompletion':
7632 case 'changepasscompletion':
7633 $newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Completion', 'usces'));
7634 break;
7635 case 'error':
7636 $newtitle = apply_filters('usces_filter_title_membererror', __('Error', 'usces'));
7637 break;
7638 default:
7639 $newtitle = apply_filters('usces_filter_title_member_default', $title);
7640 }
7641 }else{
7642 $newtitle = $title;
7643 }
7644
7645 $newtitle = apply_filters('usces_filter_memberTitle', $newtitle);
7646 return $newtitle;
7647 }
7648
7649 function action_memberFilter(){
7650 add_filter('the_title', array($this, 'filter_memberTitle'),20);
7651 add_filter('the_content', array($this, 'filter_memberContent'),20);
7652 }
7653
7654 function filter_usces_cart_css(){
7655 $path = get_stylesheet_directory_uri() . '/usces_cart.css';
7656 return $path;
7657 }
7658
7659 function filter_divide_item(){
7660 global $wp_query;
7661
7662
7663 if( ($this->options['divide_item'] && !is_category() && !is_search() && !is_singular() && !is_admin()) ){
7664 $ids = $this->getItemIds( 'front' );
7665 $wp_query->query_vars['post__not_in'] = $ids;
7666
7667 }
7668 if( is_admin() ){
7669 $ids = $this->getItemIds( 'back' );
7670 //$wp_query->query_vars['category__not_in'] = array(USCES_ITEM_CAT_PARENT_ID);
7671 $wp_query->query_vars['post__not_in'] = $ids;
7672 }
7673 do_action( 'usces_action_divide_item');
7674 }
7675
7676 function load_upload_template(){
7677 $post_id = $_POST['post_id'];
7678 $file = 'upload_template01.php';
7679 include(TEMPLATEPATH . '/' . $file);
7680 exit;
7681 }
7682
7683 function filter_itemimg_anchor_rel($html){
7684
7685 if( is_single() ){
7686 $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"';
7687 }else{
7688 $str = '';
7689 }
7690 return $html . $str;
7691 }
7692
7693 function filter_permalink( $link ) {
7694
7695 if(false !== strpos('?page_id=4', $link) || false !== strpos('?page_id=3', $link) || false !== strpos('usces-cart', $link) || false !== strpos('usces-member', $link) )
7696 $link = str_replace('http://', 'https://', $link);
7697
7698 return $link;
7699 }
7700
7701 function filter_cart_page_header($html){
7702 if( !empty($this->options['cart_page_data']['header']['cart']) ){
7703 $html = $this->options['cart_page_data']['header']['cart'];
7704 }
7705 return do_shortcode( stripslashes(nl2br($html)) );
7706 }
7707
7708 function filter_cart_page_footer($html){
7709 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
7710 $html = $this->options['cart_page_data']['footer']['cart'];
7711 }
7712 return do_shortcode( stripslashes(nl2br($html)) );
7713 }
7714
7715 function filter_customer_page_header($html){
7716 if( !empty($this->options['cart_page_data']['header']['customer']) ){
7717 $html = $this->options['cart_page_data']['header']['customer'];
7718 }
7719 return do_shortcode( stripslashes(nl2br($html)) );
7720 }
7721
7722 function filter_customer_page_footer($html){
7723 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
7724 $html = $this->options['cart_page_data']['footer']['customer'];
7725 }
7726 return do_shortcode( stripslashes(nl2br($html)) );
7727 }
7728
7729 function filter_delivery_page_header($html){
7730 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
7731 $html = $this->options['cart_page_data']['header']['delivery'];
7732 }
7733 return do_shortcode( stripslashes(nl2br($html)) );
7734 }
7735
7736 function filter_delivery_page_footer($html){
7737 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
7738 $html = $this->options['cart_page_data']['footer']['delivery'];
7739 }
7740 return do_shortcode( stripslashes(nl2br($html)) );
7741 }
7742
7743 function filter_confirm_page_header($html){
7744 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
7745 $html = $this->options['cart_page_data']['header']['confirm'];
7746 }
7747 return do_shortcode( stripslashes(nl2br($html)) );
7748 }
7749
7750 function filter_confirm_page_footer($html){
7751 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
7752 $html = $this->options['cart_page_data']['footer']['confirm'];
7753 }
7754 return do_shortcode( stripslashes(nl2br($html)) );
7755 }
7756
7757 function filter_cartcompletion_page_header($html){
7758 if( !empty($this->options['cart_page_data']['header']['completion']) ){
7759 $html = $this->options['cart_page_data']['header']['completion'];
7760 }
7761 return do_shortcode( stripslashes(nl2br($html)) );
7762 }
7763
7764 function filter_cartcompletion_page_footer($html){
7765 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
7766 $html = $this->options['cart_page_data']['footer']['completion'];
7767 }
7768 return do_shortcode( stripslashes(nl2br($html)) );
7769 }
7770
7771 function filter_login_page_header($html){
7772 if( !empty($this->options['member_page_data']['header']['login']) ){
7773 $html = $this->options['member_page_data']['header']['login'];
7774 }
7775 return do_shortcode( stripslashes(nl2br($html)) );
7776 }
7777
7778 function filter_login_page_footer($html){
7779 if( !empty($this->options['member_page_data']['footer']['login']) ){
7780 $html = $this->options['member_page_data']['footer']['login'];
7781 }
7782 return do_shortcode( stripslashes(nl2br($html)) );
7783 }
7784
7785 function filter_newmember_page_header($html){
7786 if( !empty($this->options['member_page_data']['header']['newmember']) ){
7787 $html = $this->options['member_page_data']['header']['newmember'];
7788 }
7789 return do_shortcode( stripslashes(nl2br($html)) );
7790 }
7791
7792 function filter_newmember_page_footer($html){
7793 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
7794 $html = $this->options['member_page_data']['footer']['newmember'];
7795 }
7796 return do_shortcode( stripslashes(nl2br($html)) );
7797 }
7798
7799 function filter_newpass_page_header($html){
7800 if( !empty($this->options['member_page_data']['header']['newpass']) ){
7801 $html = $this->options['member_page_data']['header']['newpass'];
7802 }
7803 return do_shortcode( stripslashes(nl2br($html)) );
7804 }
7805
7806 function filter_newpass_page_footer($html){
7807 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
7808 $html = $this->options['member_page_data']['footer']['newpass'];
7809 }
7810 return do_shortcode( stripslashes(nl2br($html)) );
7811 }
7812
7813 function filter_changepass_page_header($html){
7814 if( !empty($this->options['member_page_data']['header']['changepass']) ){
7815 $html = $this->options['member_page_data']['header']['changepass'];
7816 }
7817 return do_shortcode( stripslashes(nl2br($html)) );
7818 }
7819
7820 function filter_changepass_page_footer($html){
7821 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
7822 $html = $this->options['member_page_data']['footer']['changepass'];
7823 }
7824 return do_shortcode( stripslashes(nl2br($html)) );
7825 }
7826
7827 function filter_memberinfo_page_header($html){
7828 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
7829 $html = $this->options['member_page_data']['header']['memberinfo'];
7830 }
7831 return do_shortcode( stripslashes(nl2br($html)) );
7832 }
7833
7834 function filter_memberinfo_page_footer($html){
7835 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
7836 $html = $this->options['member_page_data']['footer']['memberinfo'];
7837 }
7838 return do_shortcode( stripslashes(nl2br($html)) );
7839 }
7840
7841 function filter_membercompletion_page_header($html){
7842 if( !empty($this->options['member_page_data']['header']['completion']) ){
7843 $html = $this->options['member_page_data']['header']['completion'];
7844 }
7845 return do_shortcode( stripslashes(nl2br($html)) );
7846 }
7847
7848 function filter_membercompletion_page_footer($html){
7849 if( !empty($this->options['member_page_data']['footer']['completion']) ){
7850 $html = $this->options['member_page_data']['footer']['completion'];
7851 }
7852 return do_shortcode( stripslashes(nl2br($html)) );
7853 }
7854
7855 function action_cart_page_header(){
7856 if( !empty($this->options['cart_page_data']['header']['cart']) ){
7857 $html = $this->options['cart_page_data']['header']['cart'];
7858 echo do_shortcode( stripslashes(nl2br($html)) );
7859 }
7860 }
7861
7862 function action_cart_page_footer(){
7863 if( !empty($this->options['cart_page_data']['footer']['cart']) ){
7864 $html = $this->options['cart_page_data']['footer']['cart'];
7865 echo do_shortcode( stripslashes(nl2br($html)) );
7866 }
7867 }
7868
7869 function action_customer_page_header(){
7870 if( !empty($this->options['cart_page_data']['header']['customer']) ){
7871 $html = $this->options['cart_page_data']['header']['customer'];
7872 echo do_shortcode( stripslashes(nl2br($html)) );
7873 }
7874 }
7875
7876 function action_customer_page_footer(){
7877 if( !empty($this->options['cart_page_data']['footer']['customer']) ){
7878 $html = $this->options['cart_page_data']['footer']['customer'];
7879 echo do_shortcode( stripslashes(nl2br($html)) );
7880 }
7881 }
7882
7883 function action_delivery_page_header(){
7884 if( !empty($this->options['cart_page_data']['header']['delivery']) ){
7885 $html = $this->options['cart_page_data']['header']['delivery'];
7886 echo do_shortcode( stripslashes(nl2br($html)) );
7887 }
7888 }
7889
7890 function action_delivery_page_footer(){
7891 if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
7892 $html = $this->options['cart_page_data']['footer']['delivery'];
7893 echo do_shortcode( stripslashes(nl2br($html)) );
7894 }
7895 }
7896
7897 function action_confirm_page_header(){
7898 if( !empty($this->options['cart_page_data']['header']['confirm']) ){
7899 $html = $this->options['cart_page_data']['header']['confirm'];
7900 echo do_shortcode( stripslashes(nl2br($html)) );
7901 }
7902 }
7903
7904 function action_confirm_page_footer(){
7905 if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
7906 $html = $this->options['cart_page_data']['footer']['confirm'];
7907 echo do_shortcode( stripslashes(nl2br($html)) );
7908 }
7909 }
7910
7911 function action_cartcompletion_page_header(){
7912 if( !empty($this->options['cart_page_data']['header']['completion']) ){
7913 $html = $this->options['cart_page_data']['header']['completion'];
7914 echo do_shortcode( stripslashes(nl2br($html)) );
7915 }
7916 }
7917
7918 function action_cartcompletion_page_footer(){
7919 if( !empty($this->options['cart_page_data']['footer']['completion']) ){
7920 $html = $this->options['cart_page_data']['footer']['completion'];
7921 echo do_shortcode( stripslashes(nl2br($html)) );
7922 }
7923 }
7924
7925 function action_login_page_header(){
7926 if( !empty($this->options['member_page_data']['header']['login']) ){
7927 $html = $this->options['member_page_data']['header']['login'];
7928 echo do_shortcode( stripslashes(nl2br($html)) );
7929 }
7930 }
7931
7932 function action_login_page_footer(){
7933 if( !empty($this->options['member_page_data']['footer']['login']) ){
7934 $html = $this->options['member_page_data']['footer']['login'];
7935 echo do_shortcode( stripslashes(nl2br($html)) );
7936 }
7937 }
7938
7939 function action_newmember_page_header(){
7940 if( !empty($this->options['member_page_data']['header']['newmember']) ){
7941 $html = $this->options['member_page_data']['header']['newmember'];
7942 echo do_shortcode( stripslashes(nl2br($html)) );
7943 }
7944 }
7945
7946 function action_newmember_page_footer(){
7947 if( !empty($this->options['member_page_data']['footer']['newmember']) ){
7948 $html = $this->options['member_page_data']['footer']['newmember'];
7949 echo do_shortcode( stripslashes(nl2br($html)) );
7950 }
7951 }
7952
7953 function action_newpass_page_header(){
7954 if( !empty($this->options['member_page_data']['header']['newpass']) ){
7955 $html = $this->options['member_page_data']['header']['newpass'];
7956 echo do_shortcode( stripslashes(nl2br($html)) );
7957 }
7958 }
7959
7960 function action_newpass_page_footer(){
7961 if( !empty($this->options['member_page_data']['footer']['newpass']) ){
7962 $html = $this->options['member_page_data']['footer']['newpass'];
7963 echo do_shortcode( stripslashes(nl2br($html)) );
7964 }
7965 }
7966
7967 function action_changepass_page_header(){
7968 if( !empty($this->options['member_page_data']['header']['changepass']) ){
7969 $html = $this->options['member_page_data']['header']['changepass'];
7970 echo do_shortcode( stripslashes(nl2br($html)) );
7971 }
7972 }
7973
7974 function action_changepass_page_footer(){
7975 if( !empty($this->options['member_page_data']['footer']['changepass']) ){
7976 $html = $this->options['member_page_data']['footer']['changepass'];
7977 echo do_shortcode( stripslashes(nl2br($html)) );
7978 }
7979 }
7980
7981 function action_memberinfo_page_header(){
7982 if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
7983 $html = $this->options['member_page_data']['header']['memberinfo'];
7984 echo do_shortcode( stripslashes(nl2br($html)) );
7985 }
7986 }
7987
7988 function action_memberinfo_page_footer(){
7989 if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
7990 $html = $this->options['member_page_data']['footer']['memberinfo'];
7991 echo do_shortcode( stripslashes(nl2br($html)) );
7992 }
7993 }
7994
7995 function action_membercompletion_page_header(){
7996 if( !empty($this->options['member_page_data']['header']['completion']) ){
7997 $html = $this->options['member_page_data']['header']['completion'];
7998 echo do_shortcode( stripslashes(nl2br($html)) );
7999 }
8000 }
8001
8002 function action_membercompletion_page_footer(){
8003 if( !empty($this->options['member_page_data']['footer']['completion']) ){
8004 $html = $this->options['member_page_data']['footer']['completion'];
8005 echo do_shortcode( stripslashes(nl2br($html)) );
8006 }
8007 }
8008
8009 }
8010 ?>
8011