PluginProbe
Welcart e-Commerce / 1.3.4
Welcart e-Commerce v1.3.4
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.4, at functions/admin_func.php

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