PluginProbe
Welcart e-Commerce / 1.3.6
Welcart e-Commerce v1.3.6
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 / functions / admin_func.php

admin_func.php in Welcart e-Commerce 1.3.6, at functions/admin_func.php

714 lines 33.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function usces_states_form_js(){
3 global $usces;
4
5 $js = '';
6 if( $usces->use_js
7 && (( (is_page(USCES_MEMBER_NUMBER) || $usces->is_member_page($_SERVER['REQUEST_URI'])) && ((true === $usces->is_member_logged_in() && WCUtils::is_blank($usces->page)) || 'member' == $usces->page || 'editmemberform' == $usces->page || 'newmemberform' == $usces->page) )
8 || ( (is_page(USCES_CART_NUMBER) || $usces->is_cart_page($_SERVER['REQUEST_URI'])) && ('customer' == $usces->page || 'delivery' == $usces->page) )
9 )) {
10
11 $js .= '<script type="text/javascript">
12 (function($) {
13 uscesForm = {
14 settings: {
15 url: uscesL10n.ajaxurl,
16 type: "POST",
17 cache: false,
18 success: function(data, dataType){
19 //$("tbody#item-opt-list").html( data );
20 },
21 error: function(msg){
22 //$("#ajax-response").html(msg);
23 }
24 },
25
26 changeStates : function( country, type ) {
27
28 var s = this.settings;
29 s.url = "' . USCES_SSL_URL . '/";
30 s.data = "usces_ajax_action=change_states&country=" + country;
31 s.success = function(data, dataType){
32 if( "error" == data ){
33 alert("error");
34 }else{
35 $("select#" + type + "_pref").html( data );
36 if( customercountry == country && "customer" == type ){
37 $("#" + type + "_pref").attr({selectedIndex:customerstate});
38 }else if( deliverycountry == country && "delivery" == type ){
39 $("#" + type + "_pref").attr({selectedIndex:deliverystate});
40 }else if( customercountry == country && "member" == type ){
41 $("#" + type + "_pref").attr({selectedIndex:customerstate});
42 }
43 }
44 };
45 s.error = function(msg){
46 alert("error");
47 };
48 $.ajax( s );
49 return false;
50 }
51 };';
52
53 if( 'customer' == $usces->page ){
54
55 $js .= 'var customerstate = $("#customer_pref").get(0).selectedIndex;
56 var customercountry = $("#customer_country").val();
57 var deliverystate = "";
58 var deliverycountry = "";
59 var memberstate = "";
60 var membercountry = "";
61 $("#customer_country").change(function () {
62 var country = $("#customer_country option:selected").val();
63 uscesForm.changeStates( country, "customer" );
64 });';
65
66 }elseif( 'delivery' == $usces->page ){
67
68 $js .= 'var customerstate = "";
69 var customercountry = "";
70 var deliverystate = $("#delivery_pref").get(0).selectedIndex;
71 var deliverycountry = $("#delivery_country").val();
72 var memberstate = "";
73 var membercountry = "";
74 $("#delivery_country").change(function () {
75 var country = $("#delivery_country option:selected").val();
76 uscesForm.changeStates( country, "delivery" );
77 });';
78
79 }elseif( (true === $usces->is_member_logged_in() && WCUtils::is_blank($usces->page)) || (true === $usces->is_member_logged_in() && 'member' == $usces->page) || 'editmemberform' == $usces->page || 'newmemberform' == $usces->page ){
80
81 $js .= 'var customerstate = "";
82 var customercountry = "";
83 var deliverystate = "";
84 var deliverycountry = "";
85 var memberstate = $("#member_pref").get(0).selectedIndex;
86 var membercountry = $("#member_country").val();
87 $("#member_country").change(function () {
88 var country = $("#member_country option:selected").val();
89 uscesForm.changeStates( country, "member" );
90 });';
91 }
92 $js .= '})(jQuery);
93 </script>';
94 }
95
96 echo apply_filters('usces_filter_states_form_js', $js);
97 }
98
99 function usces_get_pointreduction($currency){
100 global $usces, $usces_settings;
101
102 $form = $usces_settings['currency'][$currency];
103 if( 2 == $form[1] ){
104 $reduction = 0.01;
105 }else{
106 $reduction = 1;
107 }
108 $reduction = apply_filters('usces_filter_pointreduction', $reduction);
109 return $reduction;
110 }
111
112 function usces_zeus_3dsecure_enrol(){
113 global $usces;
114
115 $acting_opts = $usces->options['acting_settings']['zeus'];
116
117 $member = $usces->get_member();
118 $pcid = $usces->get_member_meta_value('zeus_pcid', $member['ID']);
119
120 $data = array();
121
122 //if( 2 == $acting_opts['security'] && 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
123 if( 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
124 $data['authentication']['clientip'] = $acting_opts['clientip'];
125 $data['authentication']['key'] = $acting_opts['authkey'];
126 $data['card']['history']['key'] = 'sendid';
127 $data['card']['history']['action'] = 'send_email';
128 $data['card']['cvv'] = $_POST['securecode'];
129 $data['payment']['amount'] = $_POST['money'];
130 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
131 $data['payment']['count'] = $_POST['div'];
132 }else{
133 $data['payment']['count'] = '01';
134 }
135 $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
136 $data['user']['email'] = $_POST['email'];
137 $data['uniq_key']['sendid'] = $_POST['sendid'];
138 $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
139
140 }else{
141 $data['authentication']['clientip'] = $acting_opts['clientip'];
142 $data['authentication']['key'] = $acting_opts['authkey'];
143 $data['card']['number'] = $_POST['cardnumber'];
144 $data['card']['expires']['year'] = (int)$_POST['expyy'];
145 $data['card']['expires']['month'] = (int)$_POST['expmm'];
146 if( 1 == $acting_opts['security'] ){
147 $data['card']['cvv'] = $_POST['securecode'];
148 }
149 $data['card']['name'] = $_POST['username'];
150 $data['payment']['amount'] = $_POST['money'];
151 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
152 $data['payment']['count'] = $_POST['div'];
153 }else{
154 $data['payment']['count'] = '01';
155 }
156 $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
157 $data['user']['email'] = $_POST['email'];
158 $data['uniq_key']['sendid'] = $_POST['sendid'];
159 $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
160 }
161
162 $EnrolReq = '<?xml version="1.0" encoding="utf-8"?>';
163 $EnrolReq .= '<request service="secure_link_3d" action="enroll">';
164 $EnrolReq .= usces_assoc2xml($data);
165 $EnrolReq .= '</request>';
166
167 //$assoc = usces_xml2assoc($EnrolReq);
168 //echo '<pre>';
169 //print_r($assoc);
170 //echo '</pre>';
171 //
172 //
173 //$xml = usces_assoc2xml($assoc);
174 //echo '<pre>';
175 //print_r($xml);
176 //echo '</pre>';
177
178 $xml = usces_get_xml($acting_opts['card_secureurl'], $EnrolReq);
179 if ( empty($xml) ){
180 usces_log('zeus : EnrolRes Error', 'acting_transaction.log');
181 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=EnrolReq&code=0');
182 exit;
183 }
184 //usces_log('data : ' . print_r($data, true), 'acting_transaction.log');
185
186 $EnrolRes = usces_xml2assoc($xml);
187 //usces_log('EnrolRes : ' . print_r($EnrolRes, true), 'acting_transaction.log');
188 if( 'outside' == $EnrolRes['response']['result']['status'] ){
189
190 $data = array();
191 $data['xid'] = $EnrolRes['response']['xid'];//$_REQUEST['MD'];
192 $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
193 $PayReq .= '<request service="secure_link_3d" action="payment">';
194 $PayReq .= usces_assoc2xml($data);
195 $PayReq .= '</request>';
196
197 //usces_log('zeus : PayReq1'.print_r($PayReq, true), 'acting_transaction.log');
198 $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
199 //usces_log('zeus : PayReq2'.print_r($xml, true), 'acting_transaction.log');
200 if ( empty($xml) ){
201 usces_log('zeus : PayRes Error', 'acting_transaction.log');
202 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayRes&code=0');
203 exit;
204 }
205
206
207 $PayRes = usces_xml2assoc($xml);
208 //usces_log('usces_zeus_3dsecure_enrol : PayReq'.print_r($PayReq, true), 'acting_transaction.log');
209 if( 'success' != $PayRes['response']['result']['status'] ){
210 usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
211 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
212 exit;
213 }else{
214 //usces_log('zeus : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
215 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=1&zeussuffix=' . $PayRes['response']['card']['number']['suffix'] . '&zeusyear=' . $PayRes['response']['card']['expires']['year'] . '&zeusmonth=' . $PayRes['response']['card']['expires']['month'] . '&zeusordd=' . $PayRes['response']['order_number'] . '&wctid=' . $_POST['sendpoint']);
216 exit;
217 }
218 exit;
219
220 }elseif( 'success' != $EnrolRes['response']['result']['status'] ){
221 usces_log('zeus bad status : status=' . $EnrolRes['response']['result']['status'] . ' code=' . $EnrolRes['response']['result']['code'], 'acting_transaction.log');
222 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $EnrolRes['response']['result']['status'] . '&code=' . $EnrolRes['response']['result']['code']);
223 exit;
224 }
225
226 usces_auth_order_acting_data($_POST['sendpoint']);
227
228 $data = array();
229 $data['MD'] = $EnrolRes['response']['xid'];
230 $data['PaReq'] = $EnrolRes['response']['redirection']['PaReq'];
231 $data['TermUrl'] = USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1';
232 $PaReq = http_build_query($data);
233 $PaReq = 'MD='.$EnrolRes['response']['xid'].'&PaReq='.$EnrolRes['response']['redirection']['PaReq'].'&TermUrl='.USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1';
234 /* $PaReq = '<?xml version="1.0" encoding="utf-8" ?>';
235 $PaReq .= '<request service="secure_link_3d" action="enroll">';
236 $PaReq .= usces_assoc2xml($data);
237 $PaReq .= '</request>';
238 */
239 // usces_log('TermUrl : ' . USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1&sendpoint=' . $_POST['sendpoint'], 'acting_transaction.log');
240 ?>
241 <form name="zeus" action="<?php echo $EnrolRes['response']['redirection']['acs_url']; ?>" method="post">
242 <input name="MD" type="hidden" value="<?php echo $EnrolRes['response']['xid']; ?>" />
243 <input name="PaReq" type="hidden" value="<?php echo $EnrolRes['response']['redirection']['PaReq']; ?>" />
244 <input name="TermUrl" type="hidden" value="<?php echo USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1&sendpoint=' . $_POST['sendpoint']; ?>" />
245 </form>
246 <script type="text/javascript">document.zeus.submit();</script>
247 <?php
248 /* $xml = usces_get_xml($EnrolRes['response']['redirection']['acs_url'], $PaReq);
249 if ( empty($xml) ){
250 usces_log('zeus : PaRes Error', 'acting_transaction.log');
251 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PaRes&code=0');
252 exit;
253 }
254 print($xml);
255 */// $PaRes = usces_xml2assoc($xml);
256 // if( 'success' != $PaRes['response']['result']['status'] ){
257 // usces_log('zeus bad status : status=' . $PaRes['response']['result']['status'] . ' code=' . $PaRes['response']['result']['code'], 'acting_transaction.log');
258 // header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PaRes['response']['result']['status'] . '&code=' . $PaRes['response']['result']['code']);
259 // exit;
260 // }
261 exit;
262 }
263
264 function usces_zeus_3dsecure_auth(){
265 global $usces;
266
267 $acting_opts = $usces->options['acting_settings']['zeus'];
268
269 $data = array();
270 $data['xid'] = $_REQUEST['MD'];
271 $data['PaRes'] = $_REQUEST['PaRes'];
272 $AuthReq = '<?xml version="1.0" encoding="utf-8" ?>';
273 $AuthReq .= '<request service="secure_link_3d" action="authentication">';
274 $AuthReq .= usces_assoc2xml($data);
275 $AuthReq .= '</request>';
276
277 $xml = usces_get_xml($acting_opts['card_secureurl'], $AuthReq);
278 if ( strpos($xml, 'Invalid') ){
279 usces_log('zeus : AuthReq Error'.print_r($xml, true), 'acting_transaction.log');
280 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=AuthReq&code=0');
281 exit;
282 }
283 //usces_log('xml : '.print_r($xml, true), 'acting_transaction.log');
284
285 $AuthRes = usces_xml2assoc($xml);
286 //usces_log('AuthRes : '.print_r($AuthRes, true), 'acting_transaction.log');
287 if( 'success' != $AuthRes['response']['result']['status'] ){
288 usces_log('zeus bad status : status=' . $AuthRes['response']['result']['status'] . ' code=' . $AuthRes['response']['result']['code'], 'acting_transaction.log');
289 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $AuthRes['response']['result']['status'] . '&code=' . $AuthRes['response']['result']['code']);
290 exit;
291 }
292
293
294 $data = array();
295 $data['xid'] = $_REQUEST['MD'];
296 $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
297 $PayReq .= '<request service="secure_link_3d" action="payment">';
298 $PayReq .= usces_assoc2xml($data);
299 $PayReq .= '</request>';
300
301 //usces_log('zeus : PayReq1'.print_r($PayReq, true), 'acting_transaction.log');
302 $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
303 //usces_log('zeus : PayReq2'.print_r($xml, true), 'acting_transaction.log');
304 if ( empty($xml) ){
305 usces_log('zeus : PayRes Error', 'acting_transaction.log');
306 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayRes&code=0');
307 exit;
308 }
309
310 $PayRes = usces_xml2assoc($xml);
311 //usces_log('usces_zeus_3dsecure_auth : PayReq'.print_r($PayReq, true), 'acting_transaction.log');
312 if( 'success' != $PayRes['response']['result']['status'] ){
313 usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
314 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
315 exit;
316 }else{
317 usces_log('zeus : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
318 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=1&zeussuffix=' . $PayRes['response']['card']['number']['suffix'] . '&zeusyear=' . $PayRes['response']['card']['expires']['year'] . '&zeusmonth=' . $PayRes['response']['card']['expires']['month'] . '&zeusordd=' . $PayRes['response']['order_number'] . '&wctid=' . $_REQUEST['sendpoint']);
319 exit;
320 }
321 exit;
322 }
323
324 function usces_zeus_secure_payreq(){
325 global $usces;
326
327 $acting_opts = $usces->options['acting_settings']['zeus'];
328
329 $member = $usces->get_member();
330 $pcid = $usces->get_member_meta_value('zeus_pcid', $member['ID']);
331
332 $data = array();
333
334 if( 2 == $acting_opts['security'] && 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
335 $data['authentication']['clientip'] = $acting_opts['clientip'];
336 $data['authentication']['key'] = $acting_opts['authkey'];
337 $data['card']['history_action_send_email']['key'] = $_POST['sendid'];
338 $data['payment']['amount'] = $_POST['money'];
339 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
340 $data['payment']['count'] = $_POST['div'];
341 }else{
342 $data['payment']['count'] = '01';
343 }
344 $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
345 $data['user']['email'] = $_POST['email'];
346 $data['uniq_key']['sendid'] = $_POST['sendid'];
347 $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
348
349 }else{
350 $data['authentication']['clientip'] = $acting_opts['clientip'];
351 $data['authentication']['key'] = $acting_opts['authkey'];
352 $data['card']['number'] = $_POST['cardnumber'];
353 $data['card']['expires']['year'] = (int)$_POST['expyy'];
354 $data['card']['expires']['month'] = (int)$_POST['expmm'];
355 if( 1 == $acting_opts['security'] ){
356 $data['card']['cvv'] = $_POST['securecode'];
357 }
358 $data['card']['name'] = $_POST['username'];
359 $data['payment']['amount'] = $_POST['money'];
360 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
361 $data['payment']['count'] = $_POST['div'];
362 }else{
363 $data['payment']['count'] = '01';
364 }
365 $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
366 $data['user']['email'] = $_POST['email'];
367 $data['uniq_key']['sendid'] = $_POST['sendid'];
368 $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
369 }
370
371 $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
372 $PayReq .= '<request service="secure_link" action="payment">';
373 $PayReq .= usces_assoc2xml($data);
374 $PayReq .= '</request>';
375 //usces_log('zeus data: ' . print_r($data,true), 'acting_transaction.log');
376 //usces_log('zeus PayReq: ' . print_r($PayReq,true), 'acting_transaction.log');
377
378 $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
379 if ( empty($xml) ){
380 usces_log('zeus : PayReq Error', 'acting_transaction.log');
381 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayReq&code=0');
382 exit;
383 }
384
385 usces_auth_order_acting_data($_POST['sendpoint']);
386
387 $PayRes = usces_xml2assoc($xml);
388 //usces_log('usces_zeus_secure_payreq : PayReq'.print_r($PayReq, true), 'acting_transaction.log');
389 if( 'success' == $PayRes['response']['result']['status'] ){
390 usces_log('zeus : PayRes'.print_r($PayRes, true), 'acting_transaction.log');
391 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=1&zeussuffix=' . $PayRes['response']['card']['number']['suffix'] . '&zeusyear=' . $PayRes['response']['card']['expires']['year'] . '&zeusmonth=' . $PayRes['response']['card']['expires']['month'] . '&zeusordd=' . $PayRes['response']['order_number'] . '&wctid=' . $_POST['sendpoint']);
392 exit;
393 }else{
394 usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
395 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
396 exit;
397 }
398 }
399
400 function usces_xml2assoc($xml) {
401 $arr = array();
402 if (!preg_match_all('|\<\s*?(\w+).*?\>(.*)\<\/\s*\\1.*?\>|s', $xml, $m)) return $xml;
403 if (is_array($m[1]))
404 for ($i = 0;$i < sizeof($m[1]); $i++) $arr[$m[1][$i]] = usces_xml2assoc($m[2][$i]);
405 else $arr[$m[1]] = usces_xml2assoc($m[2]);
406
407 return $arr;
408 }
409 function usces_assoc2xml($prm_array){
410 $xml = '';
411 if(is_array($prm_array)){
412 $i=0;
413 foreach ($prm_array as $index => $element){
414 if(is_array($element)){
415 $acts = explode('_', $index, 3);
416 if( 2 < count($acts) && 'history' == $acts[0] && 'action' == $acts[1] ){
417 $xml .= '<history action="' . $acts[2] . '">';
418 $xml .= usces_assoc2xml($element);
419 $xml .= '</history>';
420 }else{
421 $xml .= '<' . $index . '>';
422 $xml .= usces_assoc2xml($element);
423 $xml .= '</' . $index . '>';
424 }
425 }else{
426 $xml .= '<' . $index . '>' . $element . '</' . $index . '>';
427 }
428 if($i>500) break;
429 }
430 }
431 return $xml;
432 }
433 function usces_get_xml($url, $paras){
434 $interface = parse_url($url);
435 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
436 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
437 $header .= "User-Agent: PHP Script\r\n";
438 $header .= "Content-Type: text/xml\r\n";
439 $header .= "Content-Length: " . strlen($paras) . "\r\n";
440 $header .= "Connection: close\r\n\r\n";
441 $header .= $paras;
442 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
443 //usces_log('header : '.print_r($header, true), 'acting_transaction.log');
444
445 $xml = '';
446 if ($fp){
447 fwrite($fp, $header);
448 while ( !feof($fp) ) {
449 $xml .= fgets($fp, 1024);
450 }
451 fclose($fp);
452 }
453 //usces_log('get_return : '.print_r($xml, true), 'acting_transaction.log');
454
455 return $xml;
456 }
457
458 //function admin_prodauct_meta_box(){
459 // $wp_version = get_bloginfo('version');
460 // if (version_compare($wp_version, '3.4-beta3', '<'))
461 // return;
462 //
463 // if ( 'usces_itemedit' == $_GET['page'] && !isset($_GET['action']))
464 // return;
465 //
466 //
467 //}
468
469 function admin_prodauct_current_screen(){
470 global $current_screen, $post;
471
472
473
474 $wp_version = get_bloginfo('version');
475 if (version_compare($wp_version, '3.4-beta3', '<'))
476 return;
477
478 if ( !(isset($_GET['page']) && (('usces_itemedit' == $_GET['page'] && isset($_GET['action'])) || 'usces_itemnew' == $_GET['page'])) )
479 return;
480
481 if ( isset( $_GET['post'] ) )
482 $post_id = $post_ID = (int) $_GET['post'];
483 elseif ( isset( $_POST['post_ID'] ) )
484 $post_id = $post_ID = (int) $_POST['post_ID'];
485 else
486 $post_id = $post_ID = 0;
487
488 $post_type = 'post';
489 $post_type_object = get_post_type_object( $post_type );
490
491 if ( $post_id ){
492 $post = get_post( $post_id );
493 }else{
494 $post = get_default_post_to_edit( $post_type, true );
495 $post_ID = $post->ID;
496 }
497
498 require_once(USCES_PLUGIN_DIR.'/includes/meta-boxes.php');
499
500 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');
501
502 // all taxonomies
503 foreach ( get_object_taxonomies($post_type) as $tax_name ) {
504 $taxonomy = get_taxonomy($tax_name);
505 if ( ! $taxonomy->show_ui )
506 continue;
507
508 $label = $taxonomy->labels->name;
509
510 if ( !is_taxonomy_hierarchical($tax_name) )
511 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core');
512 else
513 add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', $post_type, 'side', 'core', array( 'taxonomy' => $tax_name, 'descendants_and_self' => USCES_ITEM_CAT_PARENT_ID ));
514 }
515
516 if ( post_type_supports($post_type, 'page-attributes') )
517 add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
518
519 if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'thumbnail') )
520 add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
521
522 if ( post_type_supports($post_type, 'excerpt') )
523 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
524
525 if ( post_type_supports($post_type, 'trackbacks') )
526 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core');
527
528 if ( post_type_supports($post_type, 'custom-fields') )
529 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core');
530
531 //do_action('dbx_post_advanced');
532 if ( post_type_supports($post_type, 'comments') )
533 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core');
534
535 if ( (isset($post->post_status) && ('publish' == $post->post_status || 'private' == $post->post_status) ) && post_type_supports($post_type, 'comments') )
536 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
537
538 if ( !( (isset( $post->post_status ) && 'pending' == $post->post_status) && !current_user_can( $post_type_object->cap->publish_posts ) ) )
539 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
540
541 if ( post_type_supports($post_type, 'author') ) {
542 if ( version_compare($wp_version, '3.1', '>=') ){
543 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
544 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
545 }else{
546 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
547 if ( isset($post->post_author) && $post->post_author && !in_array($post->post_author, $authors) )
548 $authors[] = $post->post_author;
549 if ( ( $authors && count( $authors ) > 1 ) || is_super_admin() )
550 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
551 }
552 }
553
554 if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
555 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
556
557 //add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );
558
559
560 $current_screen->base = $post_type;
561 $current_screen->id = $post_type;
562 $current_screen->post_type = $post_type;
563 //usces_p($current_screen);
564
565 }
566
567 function admin_prodauct_header(){
568
569 $wp_version = get_bloginfo('version');
570 if (version_compare($wp_version, '3.4-beta3', '<'))
571 return;
572
573 if ( isset($_REQUEST['action'])){
574
575 $suport_display = '<p>商品登録関連ドキュメント<br /><a href="http://www.welcart.com/documents/manual-2/%E6%96%B0%E8%A6%8F%E5%95%86%E5%93%81%E8%BF%BD%E5%8A%A0" target="_new">商品編集画面</a></p>';
576
577 get_current_screen()->add_help_tab( array(
578 'id' => 'suport-display',
579 'title' => 'Documents',
580 'content' => $suport_display,
581 ) );
582 //
583 // $title_and_editor = '<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>';
584 // $title_and_editor .= '<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular post editor.') . '</p>';
585 //
586 // get_current_screen()->add_help_tab( array(
587 // 'id' => 'title-post-editor',
588 // 'title' => __('Title and Post Editor'),
589 // 'content' => $title_and_editor,
590 // ) );
591 //
592 // $publish_box = '<p>' . __('<strong>Publish</strong> - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '</p>';
593 //
594 // if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
595 // $publish_box .= '<p>' . __( '<strong>Post Format</strong> - This designates how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="http://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</p>';
596 // }
597 //
598 // if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
599 // $publish_box .= '<p>' . __('<strong>Featured Image</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '</p>';
600 // }
601 //
602 // get_current_screen()->add_help_tab( array(
603 // 'id' => 'publish-box',
604 // 'title' => __('Publish Box'),
605 // 'content' => $publish_box,
606 // ) );
607 //
608 // $discussion_settings = '<p>' . __('<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>';
609 // $discussion_settings .= '<p>' . __('<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>';
610 //
611 // get_current_screen()->add_help_tab( array(
612 // 'id' => 'discussion-settings',
613 // 'title' => __('Discussion Settings'),
614 // 'content' => $discussion_settings,
615 // ) );
616 //
617 // get_current_screen()->set_help_sidebar(
618 // '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
619 // '<p><strong>' . __('For more information:') . '</strong></p>' .
620 // '<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
621 // '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
622 // );
623 }else{
624
625 }
626 }
627
628 function admin_new_prodauct_header(){
629
630 $wp_version = get_bloginfo('version');
631 if (version_compare($wp_version, '3.4-beta3', '<'))
632 return;
633
634 $customize_display = '<p>' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '</p>';
635
636 get_current_screen()->add_help_tab( array(
637 'id' => 'customize-display',
638 'title' => __('Customizing This Display'),
639 'content' => $customize_display,
640 ) );
641 //
642 // $title_and_editor = '<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>';
643 // $title_and_editor .= '<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular post editor.') . '</p>';
644 //
645 // get_current_screen()->add_help_tab( array(
646 // 'id' => 'title-post-editor',
647 // 'title' => __('Title and Post Editor'),
648 // 'content' => $title_and_editor,
649 // ) );
650 //
651 // $publish_box = '<p>' . __('<strong>Publish</strong> - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '</p>';
652 //
653 // if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
654 // $publish_box .= '<p>' . __( '<strong>Post Format</strong> - This designates how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="http://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</p>';
655 // }
656 //
657 // if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
658 // $publish_box .= '<p>' . __('<strong>Featured Image</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '</p>';
659 // }
660 //
661 // get_current_screen()->add_help_tab( array(
662 // 'id' => 'publish-box',
663 // 'title' => __('Publish Box'),
664 // 'content' => $publish_box,
665 // ) );
666 //
667 // $discussion_settings = '<p>' . __('<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>';
668 // $discussion_settings .= '<p>' . __('<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>';
669 //
670 // get_current_screen()->add_help_tab( array(
671 // 'id' => 'discussion-settings',
672 // 'title' => __('Discussion Settings'),
673 // 'content' => $discussion_settings,
674 // ) );
675 //
676 // get_current_screen()->set_help_sidebar(
677 // '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
678 // '<p><strong>' . __('For more information:') . '</strong></p>' .
679 // '<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
680 // '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
681 // );
682 }
683
684 function usces_clear_quickcharge(){
685 global $wpdb;
686 $table_name = $wpdb->prefix . 'usces_member_meta';
687 $wpdb->show_errors();
688 $query = $wpdb->prepare("DELETE FROM $table_name WHERE meta_key = %s", 'zeus_pcid');
689 $res = $wpdb->query( $query );
690
691 return $res;
692 }
693
694 function usces_get_order_number( $page ) {
695 if( empty($page) ) return '';
696
697 $log = explode( "\r\n", $page );
698 $ordd = '';
699 //$flg = false;
700 foreach( (array)$log as $line ) {
701 //usces_log('line='.$line, 'wcad.log');
702 //if( $flg ) {
703 // $ordd = $line;
704 // $flg = false;
705 //}
706 //if( 'Success_order' == $line ) $flg = true;
707 if( false !== strpos( $line, 'Success_order') ) {
708 list( $status, $ordd ) = explode( "\n", $line );
709 }
710 }
711 //usces_log('ordd='.$ordd, 'wcad.log');
712 return $ordd;
713 }
714 ?>