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

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

716 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 usces_auth_order_acting_data($_POST['sendpoint']);
191
192 $data = array();
193 $data['xid'] = $EnrolRes['response']['xid'];//$_REQUEST['MD'];
194 $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
195 $PayReq .= '<request service="secure_link_3d" action="payment">';
196 $PayReq .= usces_assoc2xml($data);
197 $PayReq .= '</request>';
198
199 //usces_log('zeus : PayReq1'.print_r($PayReq, true), 'acting_transaction.log');
200 $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
201 //usces_log('zeus : PayReq2'.print_r($xml, true), 'acting_transaction.log');
202 if ( empty($xml) ){
203 usces_log('zeus : PayRes Error', 'acting_transaction.log');
204 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayRes&code=0');
205 exit;
206 }
207
208
209 $PayRes = usces_xml2assoc($xml);
210 //usces_log('usces_zeus_3dsecure_enrol : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
211 if( 'success' != $PayRes['response']['result']['status'] ){
212 usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
213 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
214 exit;
215 }else{
216 //usces_log('zeus : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
217 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']);
218 exit;
219 }
220 exit;
221
222 }elseif( 'success' != $EnrolRes['response']['result']['status'] ){
223 usces_log('zeus bad status : status=' . $EnrolRes['response']['result']['status'] . ' code=' . $EnrolRes['response']['result']['code'], 'acting_transaction.log');
224 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $EnrolRes['response']['result']['status'] . '&code=' . $EnrolRes['response']['result']['code']);
225 exit;
226 }
227
228 usces_auth_order_acting_data($_POST['sendpoint']);
229
230 $data = array();
231 $data['MD'] = $EnrolRes['response']['xid'];
232 $data['PaReq'] = $EnrolRes['response']['redirection']['PaReq'];
233 $data['TermUrl'] = USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1';
234 $PaReq = http_build_query($data);
235 $PaReq = 'MD='.$EnrolRes['response']['xid'].'&PaReq='.$EnrolRes['response']['redirection']['PaReq'].'&TermUrl='.USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1';
236 /* $PaReq = '<?xml version="1.0" encoding="utf-8" ?>';
237 $PaReq .= '<request service="secure_link_3d" action="enroll">';
238 $PaReq .= usces_assoc2xml($data);
239 $PaReq .= '</request>';
240 */
241 // usces_log('TermUrl : ' . USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1&sendpoint=' . $_POST['sendpoint'], 'acting_transaction.log');
242 ?>
243 <form name="zeus" action="<?php echo $EnrolRes['response']['redirection']['acs_url']; ?>" method="post">
244 <input name="MD" type="hidden" value="<?php echo $EnrolRes['response']['xid']; ?>" />
245 <input name="PaReq" type="hidden" value="<?php echo $EnrolRes['response']['redirection']['PaReq']; ?>" />
246 <input name="TermUrl" type="hidden" value="<?php echo USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1&sendpoint=' . $_POST['sendpoint']; ?>" />
247 </form>
248 <script type="text/javascript">document.zeus.submit();</script>
249 <?php
250 /* $xml = usces_get_xml($EnrolRes['response']['redirection']['acs_url'], $PaReq);
251 if ( empty($xml) ){
252 usces_log('zeus : PaRes Error', 'acting_transaction.log');
253 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PaRes&code=0');
254 exit;
255 }
256 print($xml);
257 */// $PaRes = usces_xml2assoc($xml);
258 // if( 'success' != $PaRes['response']['result']['status'] ){
259 // usces_log('zeus bad status : status=' . $PaRes['response']['result']['status'] . ' code=' . $PaRes['response']['result']['code'], 'acting_transaction.log');
260 // header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PaRes['response']['result']['status'] . '&code=' . $PaRes['response']['result']['code']);
261 // exit;
262 // }
263 exit;
264 }
265
266 function usces_zeus_3dsecure_auth(){
267 global $usces;
268
269 $acting_opts = $usces->options['acting_settings']['zeus'];
270
271 $data = array();
272 $data['xid'] = $_REQUEST['MD'];
273 $data['PaRes'] = $_REQUEST['PaRes'];
274 $AuthReq = '<?xml version="1.0" encoding="utf-8" ?>';
275 $AuthReq .= '<request service="secure_link_3d" action="authentication">';
276 $AuthReq .= usces_assoc2xml($data);
277 $AuthReq .= '</request>';
278
279 $xml = usces_get_xml($acting_opts['card_secureurl'], $AuthReq);
280 if ( strpos($xml, 'Invalid') ){
281 usces_log('zeus : AuthReq Error'.print_r($xml, true), 'acting_transaction.log');
282 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=AuthReq&code=0');
283 exit;
284 }
285 //usces_log('xml : '.print_r($xml, true), 'acting_transaction.log');
286
287 $AuthRes = usces_xml2assoc($xml);
288 //usces_log('AuthRes : '.print_r($AuthRes, true), 'acting_transaction.log');
289 if( 'success' != $AuthRes['response']['result']['status'] ){
290 usces_log('zeus bad status : status=' . $AuthRes['response']['result']['status'] . ' code=' . $AuthRes['response']['result']['code'], 'acting_transaction.log');
291 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $AuthRes['response']['result']['status'] . '&code=' . $AuthRes['response']['result']['code']);
292 exit;
293 }
294
295
296 $data = array();
297 $data['xid'] = $_REQUEST['MD'];
298 $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
299 $PayReq .= '<request service="secure_link_3d" action="payment">';
300 $PayReq .= usces_assoc2xml($data);
301 $PayReq .= '</request>';
302
303 //usces_log('zeus : PayReq1'.print_r($PayReq, true), 'acting_transaction.log');
304 $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
305 //usces_log('zeus : PayReq2'.print_r($xml, true), 'acting_transaction.log');
306 if ( empty($xml) ){
307 usces_log('zeus : PayRes Error', 'acting_transaction.log');
308 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayRes&code=0');
309 exit;
310 }
311
312 $PayRes = usces_xml2assoc($xml);
313 //usces_log('usces_zeus_3dsecure_auth : PayReq'.print_r($PayReq, true), 'acting_transaction.log');
314 if( 'success' != $PayRes['response']['result']['status'] ){
315 usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
316 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
317 exit;
318 }else{
319 usces_log('zeus : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
320 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']);
321 exit;
322 }
323 exit;
324 }
325
326 function usces_zeus_secure_payreq(){
327 global $usces;
328
329 $acting_opts = $usces->options['acting_settings']['zeus'];
330
331 $member = $usces->get_member();
332 $pcid = $usces->get_member_meta_value('zeus_pcid', $member['ID']);
333
334 $data = array();
335
336 if( 2 == $acting_opts['security'] && 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
337 $data['authentication']['clientip'] = $acting_opts['clientip'];
338 $data['authentication']['key'] = $acting_opts['authkey'];
339 $data['card']['history_action_send_email']['key'] = $_POST['sendid'];
340 $data['payment']['amount'] = $_POST['money'];
341 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
342 $data['payment']['count'] = $_POST['div'];
343 }else{
344 $data['payment']['count'] = '01';
345 }
346 $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
347 $data['user']['email'] = $_POST['email'];
348 $data['uniq_key']['sendid'] = $_POST['sendid'];
349 $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
350
351 }else{
352 $data['authentication']['clientip'] = $acting_opts['clientip'];
353 $data['authentication']['key'] = $acting_opts['authkey'];
354 $data['card']['number'] = $_POST['cardnumber'];
355 $data['card']['expires']['year'] = (int)$_POST['expyy'];
356 $data['card']['expires']['month'] = (int)$_POST['expmm'];
357 if( 1 == $acting_opts['security'] ){
358 $data['card']['cvv'] = $_POST['securecode'];
359 }
360 $data['card']['name'] = $_POST['username'];
361 $data['payment']['amount'] = $_POST['money'];
362 if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
363 $data['payment']['count'] = $_POST['div'];
364 }else{
365 $data['payment']['count'] = '01';
366 }
367 $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
368 $data['user']['email'] = $_POST['email'];
369 $data['uniq_key']['sendid'] = $_POST['sendid'];
370 $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
371 }
372
373 $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
374 $PayReq .= '<request service="secure_link" action="payment">';
375 $PayReq .= usces_assoc2xml($data);
376 $PayReq .= '</request>';
377 //usces_log('zeus data: ' . print_r($data,true), 'acting_transaction.log');
378 //usces_log('zeus PayReq: ' . print_r($PayReq,true), 'acting_transaction.log');
379
380 $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
381 if ( empty($xml) ){
382 usces_log('zeus : PayReq Error', 'acting_transaction.log');
383 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayReq&code=0');
384 exit;
385 }
386
387 usces_auth_order_acting_data($_POST['sendpoint']);
388
389 $PayRes = usces_xml2assoc($xml);
390 //usces_log('usces_zeus_secure_payreq : PayReq'.print_r($PayReq, true), 'acting_transaction.log');
391 if( 'success' == $PayRes['response']['result']['status'] ){
392 usces_log('zeus : PayRes'.print_r($PayRes, true), 'acting_transaction.log');
393 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']);
394 exit;
395 }else{
396 usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
397 header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
398 exit;
399 }
400 }
401
402 function usces_xml2assoc($xml) {
403 $arr = array();
404 if (!preg_match_all('|\<\s*?(\w+).*?\>(.*)\<\/\s*\\1.*?\>|s', $xml, $m)) return $xml;
405 if (is_array($m[1]))
406 for ($i = 0;$i < sizeof($m[1]); $i++) $arr[$m[1][$i]] = usces_xml2assoc($m[2][$i]);
407 else $arr[$m[1]] = usces_xml2assoc($m[2]);
408
409 return $arr;
410 }
411 function usces_assoc2xml($prm_array){
412 $xml = '';
413 if(is_array($prm_array)){
414 $i=0;
415 foreach ($prm_array as $index => $element){
416 if(is_array($element)){
417 $acts = explode('_', $index, 3);
418 if( 2 < count($acts) && 'history' == $acts[0] && 'action' == $acts[1] ){
419 $xml .= '<history action="' . $acts[2] . '">';
420 $xml .= usces_assoc2xml($element);
421 $xml .= '</history>';
422 }else{
423 $xml .= '<' . $index . '>';
424 $xml .= usces_assoc2xml($element);
425 $xml .= '</' . $index . '>';
426 }
427 }else{
428 $xml .= '<' . $index . '>' . $element . '</' . $index . '>';
429 }
430 if($i>500) break;
431 }
432 }
433 return $xml;
434 }
435 function usces_get_xml($url, $paras){
436 $interface = parse_url($url);
437 $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
438 $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
439 $header .= "User-Agent: PHP Script\r\n";
440 $header .= "Content-Type: text/xml\r\n";
441 $header .= "Content-Length: " . strlen($paras) . "\r\n";
442 $header .= "Connection: close\r\n\r\n";
443 $header .= $paras;
444 $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
445 //usces_log('header : '.print_r($header, true), 'acting_transaction.log');
446
447 $xml = '';
448 if ($fp){
449 fwrite($fp, $header);
450 while ( !feof($fp) ) {
451 $xml .= fgets($fp, 1024);
452 }
453 fclose($fp);
454 }
455 //usces_log('get_return : '.print_r($xml, true), 'acting_transaction.log');
456
457 return $xml;
458 }
459
460 //function admin_prodauct_meta_box(){
461 // $wp_version = get_bloginfo('version');
462 // if (version_compare($wp_version, '3.4-beta3', '<'))
463 // return;
464 //
465 // if ( 'usces_itemedit' == $_GET['page'] && !isset($_GET['action']))
466 // return;
467 //
468 //
469 //}
470
471 function admin_prodauct_current_screen(){
472 global $current_screen, $post;
473
474
475
476 $wp_version = get_bloginfo('version');
477 if (version_compare($wp_version, '3.4-beta3', '<'))
478 return;
479
480 if ( !(isset($_GET['page']) && (('usces_itemedit' == $_GET['page'] && isset($_GET['action'])) || 'usces_itemnew' == $_GET['page'])) )
481 return;
482
483 if ( isset( $_GET['post'] ) )
484 $post_id = $post_ID = (int) $_GET['post'];
485 elseif ( isset( $_POST['post_ID'] ) )
486 $post_id = $post_ID = (int) $_POST['post_ID'];
487 else
488 $post_id = $post_ID = 0;
489
490 $post_type = 'post';
491 $post_type_object = get_post_type_object( $post_type );
492
493 if ( $post_id ){
494 $post = get_post( $post_id );
495 }else{
496 $post = get_default_post_to_edit( $post_type, true );
497 $post_ID = $post->ID;
498 }
499
500 require_once(USCES_PLUGIN_DIR.'/includes/meta-boxes.php');
501
502 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');
503
504 // all taxonomies
505 foreach ( get_object_taxonomies($post_type) as $tax_name ) {
506 $taxonomy = get_taxonomy($tax_name);
507 if ( ! $taxonomy->show_ui )
508 continue;
509
510 $label = $taxonomy->labels->name;
511
512 if ( !is_taxonomy_hierarchical($tax_name) )
513 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core');
514 else
515 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 ));
516 }
517
518 if ( post_type_supports($post_type, 'page-attributes') )
519 add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
520
521 if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'thumbnail') )
522 add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
523
524 if ( post_type_supports($post_type, 'excerpt') )
525 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
526
527 if ( post_type_supports($post_type, 'trackbacks') )
528 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core');
529
530 if ( post_type_supports($post_type, 'custom-fields') )
531 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core');
532
533 //do_action('dbx_post_advanced');
534 if ( post_type_supports($post_type, 'comments') )
535 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core');
536
537 if ( (isset($post->post_status) && ('publish' == $post->post_status || 'private' == $post->post_status) ) && post_type_supports($post_type, 'comments') )
538 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
539
540 if ( !( (isset( $post->post_status ) && 'pending' == $post->post_status) && !current_user_can( $post_type_object->cap->publish_posts ) ) )
541 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
542
543 if ( post_type_supports($post_type, 'author') ) {
544 if ( version_compare($wp_version, '3.1', '>=') ){
545 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
546 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
547 }else{
548 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
549 if ( isset($post->post_author) && $post->post_author && !in_array($post->post_author, $authors) )
550 $authors[] = $post->post_author;
551 if ( ( $authors && count( $authors ) > 1 ) || is_super_admin() )
552 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
553 }
554 }
555
556 if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
557 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
558
559 //add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );
560
561
562 $current_screen->base = $post_type;
563 $current_screen->id = $post_type;
564 $current_screen->post_type = $post_type;
565 //usces_p($current_screen);
566
567 }
568
569 function admin_prodauct_header(){
570
571 $wp_version = get_bloginfo('version');
572 if (version_compare($wp_version, '3.4-beta3', '<'))
573 return;
574
575 if ( isset($_REQUEST['action'])){
576
577 $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>';
578
579 get_current_screen()->add_help_tab( array(
580 'id' => 'suport-display',
581 'title' => 'Documents',
582 'content' => $suport_display,
583 ) );
584 //
585 // $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>';
586 // $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>';
587 //
588 // get_current_screen()->add_help_tab( array(
589 // 'id' => 'title-post-editor',
590 // 'title' => __('Title and Post Editor'),
591 // 'content' => $title_and_editor,
592 // ) );
593 //
594 // $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>';
595 //
596 // if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
597 // $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>';
598 // }
599 //
600 // if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
601 // $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>';
602 // }
603 //
604 // get_current_screen()->add_help_tab( array(
605 // 'id' => 'publish-box',
606 // 'title' => __('Publish Box'),
607 // 'content' => $publish_box,
608 // ) );
609 //
610 // $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>';
611 // $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>';
612 //
613 // get_current_screen()->add_help_tab( array(
614 // 'id' => 'discussion-settings',
615 // 'title' => __('Discussion Settings'),
616 // 'content' => $discussion_settings,
617 // ) );
618 //
619 // get_current_screen()->set_help_sidebar(
620 // '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
621 // '<p><strong>' . __('For more information:') . '</strong></p>' .
622 // '<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
623 // '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
624 // );
625 }else{
626
627 }
628 }
629
630 function admin_new_prodauct_header(){
631
632 $wp_version = get_bloginfo('version');
633 if (version_compare($wp_version, '3.4-beta3', '<'))
634 return;
635
636 $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>';
637
638 get_current_screen()->add_help_tab( array(
639 'id' => 'customize-display',
640 'title' => __('Customizing This Display'),
641 'content' => $customize_display,
642 ) );
643 //
644 // $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>';
645 // $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>';
646 //
647 // get_current_screen()->add_help_tab( array(
648 // 'id' => 'title-post-editor',
649 // 'title' => __('Title and Post Editor'),
650 // 'content' => $title_and_editor,
651 // ) );
652 //
653 // $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>';
654 //
655 // if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
656 // $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>';
657 // }
658 //
659 // if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
660 // $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>';
661 // }
662 //
663 // get_current_screen()->add_help_tab( array(
664 // 'id' => 'publish-box',
665 // 'title' => __('Publish Box'),
666 // 'content' => $publish_box,
667 // ) );
668 //
669 // $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>';
670 // $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>';
671 //
672 // get_current_screen()->add_help_tab( array(
673 // 'id' => 'discussion-settings',
674 // 'title' => __('Discussion Settings'),
675 // 'content' => $discussion_settings,
676 // ) );
677 //
678 // get_current_screen()->set_help_sidebar(
679 // '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
680 // '<p><strong>' . __('For more information:') . '</strong></p>' .
681 // '<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
682 // '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
683 // );
684 }
685
686 function usces_clear_quickcharge(){
687 global $wpdb;
688 $table_name = $wpdb->prefix . 'usces_member_meta';
689 $wpdb->show_errors();
690 $query = $wpdb->prepare("DELETE FROM $table_name WHERE meta_key = %s", 'zeus_pcid');
691 $res = $wpdb->query( $query );
692
693 return $res;
694 }
695
696 function usces_get_order_number( $page ) {
697 if( empty($page) ) return '';
698
699 $log = explode( "\r\n", $page );
700 $ordd = '';
701 //$flg = false;
702 foreach( (array)$log as $line ) {
703 //usces_log('line='.$line, 'wcad.log');
704 //if( $flg ) {
705 // $ordd = $line;
706 // $flg = false;
707 //}
708 //if( 'Success_order' == $line ) $flg = true;
709 if( false !== strpos( $line, 'Success_order') ) {
710 list( $status, $ordd ) = explode( "\n", $line );
711 }
712 }
713 //usces_log('ordd='.$ordd, 'wcad.log');
714 return $ordd;
715 }
716 ?>