383
个编辑
更改
创建页面,内容为“<?php →* * Created by PhpStorm. * User: yzg * Date: 2016/1/19 * Time: 11:37: if (!defined('IN_DISCUZ')) { exit('Access Denied'); } //ini_set('display_er...”
<?php
/**
* Created by PhpStorm.
* User: yzg
* Date: 2016/1/19
* Time: 11:37
*/
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
//ini_set('display_errors', 1);
//error_reporting(E_ALL ^ E_NOTICE);
class plugin_xigua_re{
function common(){
global $_G;
if($_G['basescript'] =='group'){
$config = $_G['cache']['plugin']['xigua_re'];
if($config['needgroup']){
$_G['basescript'] = 'forum';
}
}
}
}
class plugin_xigua_re_portal extends plugin_xigua_re
{
function view_article_content_output(){
global $article,$postlist;
$authorinfo = getuserbyuid($article['uid']);
$postlist[0]['authorid'] = $article['uid'];
$postlist[0]['first'] = 1;
$postlist[0]['groupid'] = $authorinfo['groupid'];
$postlist[0]['subject'] = $article['title'];
$postlist[0]['pid'] = 'a_'.$article['aid'];
$_G['fid'] = 0;
global $ispc;
$ispc = 1;
$ret = mobileplugin_xigua_re_forum::viewthread_postbottom_mobile_output();
return $ret[0];
}
}
class mobileplugin_xigua_re_portal extends plugin_xigua_re_portal
{
function view_article_content_output(){
global $article,$postlist;
$authorinfo = getuserbyuid($article['uid']);
$postlist[0]['authorid'] = $article['uid'];
$postlist[0]['first'] = 1;
$postlist[0]['groupid'] = $authorinfo['groupid'];
$postlist[0]['subject'] = $article['title'];
$postlist[0]['pid'] = 'a_'.$article['aid'];
$_G['fid'] = 0;
global $ispc;
$ispc = 0;
$ret = mobileplugin_xigua_re_forum::viewthread_postbottom_mobile_output();
return $ret[0];
}
}
class plugin_xigua_re_forum extends plugin_xigua_re
{
public static function viewthread_postbottom_output(){
global $ispc;
$ispc = 1;
$ret = mobileplugin_xigua_re_forum::viewthread_postbottom_mobile_output();
return $ret;
}
}
class mobileplugin_xigua_re_forum extends plugin_xigua_re
{
public static function getstyle($ispc, $color)
{
$reword = $ispc ? 'text-align: center; font-size: 18px;color: #666;line-height: 36px;clear:both;' : 'font-size:16px;text-align:center;padding-top:10px;color:#909090;clear:both;width:100%;';
$relistli = $ispc ? 'margin:0 6px 6px 0;float:left' : 'display:inline-block;margin:0 6px 6px 0;vertical-align:top';
$html = '';
include_once template('xigua_re:style');
$style = $html;
return $style;
}
public static function viewthread_postbottom_mobile_output(){
include_once DISCUZ_ROOT.'./source/plugin/xigua_re/common.php';
global $_G,$postlist,$ispc;
$config = $_G['cache']['plugin']['xigua_re'];
$color = $config['linkcolor'] ? $config['linkcolor'] : '#D75847';
$hasstyle = 0;
$data = array();
$style = self::getstyle($ispc, $color);
$yuan = lang('plugin/xigua_re', 'yuan');
$ren = lang('plugin/xigua_re', 'ren');
$wuhui = lang('plugin/xigua_re', 'wuhui');
$lijida = lang('plugin/xigua_re', 'lijida');
$guanbi = lang('plugin/xigua_re', 'guanbi');
$qing = lang('plugin/xigua_re', 'qing');
$pcjs = '';
include_once template('xigua_re:pcjs');
$authors = array();
foreach (array_values($postlist) as $item) {
$authors[] = $item['authorid'];
}
$users = C::t('#xigua_re#xgre_user')->fetch_by_uids($authors);
foreach (array_values($postlist) as $index => $item) {
/*
$mem = C::t('common_member')->fetch($item['authorid']);
foreach(explode("\t", $mem['extgroupids']) as $extgroupid) {
if($extgroupid = intval(trim($extgroupid))) {
$groupidarray[] = $extgroupid;
}
}
if(!in_array($item['groupid'], unserialize($config['opengroups'])) && !array_intersect(unserialize($config['opengroups']), $groupidarray)){
$data[$index] = '';
continue;
}
*/
if(!in_array($item['groupid'], unserialize($config['opengroups']))){
$data[$index] = '';
continue;
}
if($_G['fid'] && in_array($_G['fid'], unserialize($config['closefids']))){
$data[$index] = '';
continue;
}
if($config['first'] && !$item['first']){
$data[$index] = '';
continue;
}
$user = $users[$item['authorid']];
if(!$user['openid']){
if($config['needopenid']){
$data[$index] = '';
continue;
}
}
if(!$user['word']){
$user['word'] = $config['preword'];
}
$postid = 'pid_'.$item['pid'];
$tid = $item['tid'];
$url = urlencode(re_current_url());
$subject = $item['subject'];
$subject = urlencode($subject);
$imgs = $reilist = '';
$dlist = array();
$count = C::t('#xigua_re#xgre_order')->fetch_usercount_by_postid($postid);
if($count){
$dlist = $list = C::t('#xigua_re#xgre_order')->fetch_user_by_postid($postid);
}
if($hasstyle){
$style = '';
$pcjs = '';
}
$paybtn = '';
include template('xigua_re:paybtn');
$data[$index] = $paybtn;
$hasstyle = 1;
}
if($data[0]){
$data[''] = $data[0];
}
return $data;
}
}[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# ^C
[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# dir
api.class.php cache help.inc.php lang.inc.php notify_wx.php order.inc.php.bak order.inc.php.new setting.inc.php template
app.inc.php check.inc.php hook.class.php lib order.inc.php order.inc.php.bak2 pay.inc.php static tixian.inc.php
bind.inc.php common.php index.inc.php list.inc.php order.inc.php-4 order.inc.php.c rank.inc.php table uninstall.php
[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# ^C
[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# cat index.inc.php
<?php
/**
* Created by PhpStorm.
* User: yzg
* Date: 2016/1/28
* Time: 16:24
*/
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
//ini_set('display_errors', 1);
//error_reporting(E_ALL ^ E_NOTICE);
include_once DISCUZ_ROOT.'./source/plugin/xigua_re/common.php';
$cookie = substr(md5('rewechatopenid'.$_G['siteurl'].WX_APPID.WX_MCHID.WX_APPSECRET), 0, 8);
$config['jin'] = explode(',', trim($config['jin']));
foreach ($config['jin'] as $item) {
if ($item > 0) {
$configary[] = $item;
}
}
$touid = intval($_GET['uid']);
$touser = getuserbyuid($touid);
$toavatar = avatar($touid, 'big', true);
$navtitle = $config['linkword'] . $touser['username'];
$user = C::t('#xigua_re#xgre_user')->fetch_user($touid);
$toopenid = $user['openid'];
if(!$toopenid){
if($config['needopenid']) {
dheader('Location:'.dreferer());
exit;
}
}
if($_GET['tid']){
$_GET['subject'] = DB::result_first('select subject from %t where tid=%d', array('forum_thread', $_GET['tid']));
}
if($_GET['url']){
$_SERVER['HTTP_REFERER'] = $_GET['url'];
}
$color = $config['linkcolor'] ? $config['linkcolor'] : '#D75847';
$tools = new JsApiPay();
if($_GET['ac'] =='pc' && !IN_WECHAT){
$price = round($_GET['price'], 2);
if(!$price){
$subject = $_GET['subject'];
$postid = $_GET['postid'];
$url = $_GET['url'];
include_once template('xigua_re:pay3');
}
$order_id = C::t('#xigua_re#xgre_order')->get_order_id(
$fromopenid, $_G['uid'], $touid, $toopenid,
$price*100,
$_GET['subject'], $_GET['url'],$_GET['postid'], $_G['cookie']['rewxnickname'], $_G['cookie']['rewxheadimgurl']
);
if(!$order_id){
exit('order_id empty!');
}
$body = diconv($navtitle, CHARSET, 'UTF-8');
$notify = new NativePay();
$input = new WxPayUnifiedOrder();
$input->SetBody($body);
$input->SetAttach($body);
$input->SetOut_trade_no($order_id);
$input->SetTotal_fee($price*100);
$input->SetTime_start(date("YmdHis"));
// $input->SetTime_expire(date("YmdHis", time() + 3600));
$input->SetGoods_tag($body);
$input->SetNotify_url($_G['siteurl']. 'source/plugin/xigua_re/notify_wx.php');
$input->SetTrade_type("NATIVE");
$input->SetProduct_id($order_id);
$result = $notify->GetPayUrl($input);
$url2 = $result["code_url"];
if(!$url2){
$img = diconv($result['return_msg'],'UTF-8',CHARSET );
}else{
if(class_exists('QRcode')){
$qrfile = 'source/plugin/xigua_re/cache/o'.$order_id.'.png';
QRcode::png($url2, DISCUZ_ROOT.$qrfile, QR_ECLEVEL_L, 3);
$src = $_G['siteurl'].$qrfile;
}else{
$src= 'http://qr.liantu.com/api.php?&w=240&bg=ffffff&fg=333333&text='.urlencode($url2);
}
$errorsrc= 'http://qr.liantu.com/api.php?&w=240&bg=ffffff&fg=333333&text='.urlencode($url2);
$img = "<img src='$src' onerror=\"this.error=null;this.src='$errorsrc'\" class=\"payqrcode\" /><p class=\"xg1\" style='margin:10px auto!important;'>".lang('plugin/xigua_re', 'sao')."</p>";
}
include_once template('xigua_re:pay2');
exit;
}
elseif($_GET['ac'] == 'jsApi'){
if(isset($_GET['index']) && isset($configary[$_GET['index']])){
$price = $configary[$_GET['index']];
}else{
$price = round($_GET['price'], 2);
}
$fromopenid = $openid = $_G['cookie'][$cookie] ? authcode($_G['cookie'][$cookie], 'DECODE', $authkey) : '';
if(!$openid && IN_WECHAT){
exit(json_encode(array('error' => 'openid empty!')));
}
$_GET['url'] = str_replace('&mobile=2', '', $_GET['url']);
$order_id = C::t('#xigua_re#xgre_order')->get_order_id(
$fromopenid, $_G['uid'], $touid, $toopenid,
$price*100,
$_GET['subject'], $_GET['url'],$_GET['postid'], $_G['cookie']['rewxnickname'], $_G['cookie']['rewxheadimgurl']
);
if(!$order_id){
exit(json_encode(array('error' => 'order_id empty!')));
}
$body = diconv($navtitle, CHARSET, 'UTF-8');
$input = new WxPayUnifiedOrder();
$input->SetBody($body);
$input->SetAttach($body);
$input->SetOut_trade_no($order_id);
$input->SetTotal_fee($price*100);
$input->SetTime_start(date("YmdHis"));
// $input->SetTime_expire(date("YmdHis", time() + 3600));
$input->SetGoods_tag($body);
$input->SetNotify_url($_G['siteurl']. 'source/plugin/xigua_re/notify_wx.php');
if(IN_WECHAT){
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openid);
$order = WxPayApi::unifiedOrder($input);
$jsApiParameters = $tools->GetJsApiParameters($order);
echo $jsApiParameters;
}else{
$input->SetTrade_type("MWEB");
$input->SetProduct_id($order_id);
$input->values['spbill_create_ip'] = re_clientip();
$result = WxPayApi::unifiedOrder($input);
$data = array('error' => 0,);
if($result['return_code'] =='SUCCESS' && $result['result_code'] == 'SUCCESS'){
$data['mweb_url'] = $result['mweb_url'].'&redirect_url='.urlencode($_SERVER['HTTP_REFERER']);
}else{
$data['error'] = $result['return_msg']."({$result['return_code']})";
}
echo json_encode($data);
}
exit;
}
else{
if(!$_G['uid']){
$openid = $_G['cookie'][$cookie] ? authcode($_G['cookie'][$cookie], 'DECODE', $authkey) : '';
if(!$openid){
$opendata = $tools->GetOpenid();
if($openid = $opendata['openid']){
dsetcookie($cookie, authcode($openid, 'ENCODE', $authkey), 7100);
dsetcookie('reaccesstoken', authcode($opendata['access_token'], 'ENCODE', $authkey), 7200);
}
}
$wxuser = $tools->getUserInfoById(authcode($_G['cookie']['reaccesstoken'], 'DECODE', $authkey), $openid);
}else{
$openid = $_G['cookie'][$cookie] ? authcode($_G['cookie'][$cookie], 'DECODE', $authkey) : '';
if(!$openid && IN_WECHAT){
$opendata = $tools->GetOnlyOpenid();
if($openid = $opendata['openid']){
dsetcookie($cookie, authcode($openid, 'ENCODE', $authkey), 7100);
}
}
$wxuser = array(
'nickname' => diconv($_G['username'], CHARSET,'UTF-8'),
'headimgurl' => avatar($_G['uid'], 'middle', true),
);
}
if($_GET['tid']){
$_SERVER['HTTP_REFERER'] = $_G['siteurl'].'forum.php?mod=viewthread&tid='.$_GET['tid'];
}
$nickname = diconv($wxuser['nickname'],'UTF-8', CHARSET);
$nickname && dsetcookie('rewxnickname', $nickname, 86400);
$wxuser['headimgurl'] && dsetcookie('rewxheadimgurl', $wxuser['headimgurl'], 86400);
$apple = 0;
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPod')){
$apple = 1;
}
if($config['tpl']==1){
include_once template('xigua_re:choose');
}else{
include_once template('xigua_re:choose2');
}
}
/**
* Created by PhpStorm.
* User: yzg
* Date: 2016/1/19
* Time: 11:37
*/
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
//ini_set('display_errors', 1);
//error_reporting(E_ALL ^ E_NOTICE);
class plugin_xigua_re{
function common(){
global $_G;
if($_G['basescript'] =='group'){
$config = $_G['cache']['plugin']['xigua_re'];
if($config['needgroup']){
$_G['basescript'] = 'forum';
}
}
}
}
class plugin_xigua_re_portal extends plugin_xigua_re
{
function view_article_content_output(){
global $article,$postlist;
$authorinfo = getuserbyuid($article['uid']);
$postlist[0]['authorid'] = $article['uid'];
$postlist[0]['first'] = 1;
$postlist[0]['groupid'] = $authorinfo['groupid'];
$postlist[0]['subject'] = $article['title'];
$postlist[0]['pid'] = 'a_'.$article['aid'];
$_G['fid'] = 0;
global $ispc;
$ispc = 1;
$ret = mobileplugin_xigua_re_forum::viewthread_postbottom_mobile_output();
return $ret[0];
}
}
class mobileplugin_xigua_re_portal extends plugin_xigua_re_portal
{
function view_article_content_output(){
global $article,$postlist;
$authorinfo = getuserbyuid($article['uid']);
$postlist[0]['authorid'] = $article['uid'];
$postlist[0]['first'] = 1;
$postlist[0]['groupid'] = $authorinfo['groupid'];
$postlist[0]['subject'] = $article['title'];
$postlist[0]['pid'] = 'a_'.$article['aid'];
$_G['fid'] = 0;
global $ispc;
$ispc = 0;
$ret = mobileplugin_xigua_re_forum::viewthread_postbottom_mobile_output();
return $ret[0];
}
}
class plugin_xigua_re_forum extends plugin_xigua_re
{
public static function viewthread_postbottom_output(){
global $ispc;
$ispc = 1;
$ret = mobileplugin_xigua_re_forum::viewthread_postbottom_mobile_output();
return $ret;
}
}
class mobileplugin_xigua_re_forum extends plugin_xigua_re
{
public static function getstyle($ispc, $color)
{
$reword = $ispc ? 'text-align: center; font-size: 18px;color: #666;line-height: 36px;clear:both;' : 'font-size:16px;text-align:center;padding-top:10px;color:#909090;clear:both;width:100%;';
$relistli = $ispc ? 'margin:0 6px 6px 0;float:left' : 'display:inline-block;margin:0 6px 6px 0;vertical-align:top';
$html = '';
include_once template('xigua_re:style');
$style = $html;
return $style;
}
public static function viewthread_postbottom_mobile_output(){
include_once DISCUZ_ROOT.'./source/plugin/xigua_re/common.php';
global $_G,$postlist,$ispc;
$config = $_G['cache']['plugin']['xigua_re'];
$color = $config['linkcolor'] ? $config['linkcolor'] : '#D75847';
$hasstyle = 0;
$data = array();
$style = self::getstyle($ispc, $color);
$yuan = lang('plugin/xigua_re', 'yuan');
$ren = lang('plugin/xigua_re', 'ren');
$wuhui = lang('plugin/xigua_re', 'wuhui');
$lijida = lang('plugin/xigua_re', 'lijida');
$guanbi = lang('plugin/xigua_re', 'guanbi');
$qing = lang('plugin/xigua_re', 'qing');
$pcjs = '';
include_once template('xigua_re:pcjs');
$authors = array();
foreach (array_values($postlist) as $item) {
$authors[] = $item['authorid'];
}
$users = C::t('#xigua_re#xgre_user')->fetch_by_uids($authors);
foreach (array_values($postlist) as $index => $item) {
/*
$mem = C::t('common_member')->fetch($item['authorid']);
foreach(explode("\t", $mem['extgroupids']) as $extgroupid) {
if($extgroupid = intval(trim($extgroupid))) {
$groupidarray[] = $extgroupid;
}
}
if(!in_array($item['groupid'], unserialize($config['opengroups'])) && !array_intersect(unserialize($config['opengroups']), $groupidarray)){
$data[$index] = '';
continue;
}
*/
if(!in_array($item['groupid'], unserialize($config['opengroups']))){
$data[$index] = '';
continue;
}
if($_G['fid'] && in_array($_G['fid'], unserialize($config['closefids']))){
$data[$index] = '';
continue;
}
if($config['first'] && !$item['first']){
$data[$index] = '';
continue;
}
$user = $users[$item['authorid']];
if(!$user['openid']){
if($config['needopenid']){
$data[$index] = '';
continue;
}
}
if(!$user['word']){
$user['word'] = $config['preword'];
}
$postid = 'pid_'.$item['pid'];
$tid = $item['tid'];
$url = urlencode(re_current_url());
$subject = $item['subject'];
$subject = urlencode($subject);
$imgs = $reilist = '';
$dlist = array();
$count = C::t('#xigua_re#xgre_order')->fetch_usercount_by_postid($postid);
if($count){
$dlist = $list = C::t('#xigua_re#xgre_order')->fetch_user_by_postid($postid);
}
if($hasstyle){
$style = '';
$pcjs = '';
}
$paybtn = '';
include template('xigua_re:paybtn');
$data[$index] = $paybtn;
$hasstyle = 1;
}
if($data[0]){
$data[''] = $data[0];
}
return $data;
}
}[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# ^C
[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# dir
api.class.php cache help.inc.php lang.inc.php notify_wx.php order.inc.php.bak order.inc.php.new setting.inc.php template
app.inc.php check.inc.php hook.class.php lib order.inc.php order.inc.php.bak2 pay.inc.php static tixian.inc.php
bind.inc.php common.php index.inc.php list.inc.php order.inc.php-4 order.inc.php.c rank.inc.php table uninstall.php
[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# ^C
[root@iZ8vbiqtysky2rwjzode27Z xigua_re]# cat index.inc.php
<?php
/**
* Created by PhpStorm.
* User: yzg
* Date: 2016/1/28
* Time: 16:24
*/
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
//ini_set('display_errors', 1);
//error_reporting(E_ALL ^ E_NOTICE);
include_once DISCUZ_ROOT.'./source/plugin/xigua_re/common.php';
$cookie = substr(md5('rewechatopenid'.$_G['siteurl'].WX_APPID.WX_MCHID.WX_APPSECRET), 0, 8);
$config['jin'] = explode(',', trim($config['jin']));
foreach ($config['jin'] as $item) {
if ($item > 0) {
$configary[] = $item;
}
}
$touid = intval($_GET['uid']);
$touser = getuserbyuid($touid);
$toavatar = avatar($touid, 'big', true);
$navtitle = $config['linkword'] . $touser['username'];
$user = C::t('#xigua_re#xgre_user')->fetch_user($touid);
$toopenid = $user['openid'];
if(!$toopenid){
if($config['needopenid']) {
dheader('Location:'.dreferer());
exit;
}
}
if($_GET['tid']){
$_GET['subject'] = DB::result_first('select subject from %t where tid=%d', array('forum_thread', $_GET['tid']));
}
if($_GET['url']){
$_SERVER['HTTP_REFERER'] = $_GET['url'];
}
$color = $config['linkcolor'] ? $config['linkcolor'] : '#D75847';
$tools = new JsApiPay();
if($_GET['ac'] =='pc' && !IN_WECHAT){
$price = round($_GET['price'], 2);
if(!$price){
$subject = $_GET['subject'];
$postid = $_GET['postid'];
$url = $_GET['url'];
include_once template('xigua_re:pay3');
}
$order_id = C::t('#xigua_re#xgre_order')->get_order_id(
$fromopenid, $_G['uid'], $touid, $toopenid,
$price*100,
$_GET['subject'], $_GET['url'],$_GET['postid'], $_G['cookie']['rewxnickname'], $_G['cookie']['rewxheadimgurl']
);
if(!$order_id){
exit('order_id empty!');
}
$body = diconv($navtitle, CHARSET, 'UTF-8');
$notify = new NativePay();
$input = new WxPayUnifiedOrder();
$input->SetBody($body);
$input->SetAttach($body);
$input->SetOut_trade_no($order_id);
$input->SetTotal_fee($price*100);
$input->SetTime_start(date("YmdHis"));
// $input->SetTime_expire(date("YmdHis", time() + 3600));
$input->SetGoods_tag($body);
$input->SetNotify_url($_G['siteurl']. 'source/plugin/xigua_re/notify_wx.php');
$input->SetTrade_type("NATIVE");
$input->SetProduct_id($order_id);
$result = $notify->GetPayUrl($input);
$url2 = $result["code_url"];
if(!$url2){
$img = diconv($result['return_msg'],'UTF-8',CHARSET );
}else{
if(class_exists('QRcode')){
$qrfile = 'source/plugin/xigua_re/cache/o'.$order_id.'.png';
QRcode::png($url2, DISCUZ_ROOT.$qrfile, QR_ECLEVEL_L, 3);
$src = $_G['siteurl'].$qrfile;
}else{
$src= 'http://qr.liantu.com/api.php?&w=240&bg=ffffff&fg=333333&text='.urlencode($url2);
}
$errorsrc= 'http://qr.liantu.com/api.php?&w=240&bg=ffffff&fg=333333&text='.urlencode($url2);
$img = "<img src='$src' onerror=\"this.error=null;this.src='$errorsrc'\" class=\"payqrcode\" /><p class=\"xg1\" style='margin:10px auto!important;'>".lang('plugin/xigua_re', 'sao')."</p>";
}
include_once template('xigua_re:pay2');
exit;
}
elseif($_GET['ac'] == 'jsApi'){
if(isset($_GET['index']) && isset($configary[$_GET['index']])){
$price = $configary[$_GET['index']];
}else{
$price = round($_GET['price'], 2);
}
$fromopenid = $openid = $_G['cookie'][$cookie] ? authcode($_G['cookie'][$cookie], 'DECODE', $authkey) : '';
if(!$openid && IN_WECHAT){
exit(json_encode(array('error' => 'openid empty!')));
}
$_GET['url'] = str_replace('&mobile=2', '', $_GET['url']);
$order_id = C::t('#xigua_re#xgre_order')->get_order_id(
$fromopenid, $_G['uid'], $touid, $toopenid,
$price*100,
$_GET['subject'], $_GET['url'],$_GET['postid'], $_G['cookie']['rewxnickname'], $_G['cookie']['rewxheadimgurl']
);
if(!$order_id){
exit(json_encode(array('error' => 'order_id empty!')));
}
$body = diconv($navtitle, CHARSET, 'UTF-8');
$input = new WxPayUnifiedOrder();
$input->SetBody($body);
$input->SetAttach($body);
$input->SetOut_trade_no($order_id);
$input->SetTotal_fee($price*100);
$input->SetTime_start(date("YmdHis"));
// $input->SetTime_expire(date("YmdHis", time() + 3600));
$input->SetGoods_tag($body);
$input->SetNotify_url($_G['siteurl']. 'source/plugin/xigua_re/notify_wx.php');
if(IN_WECHAT){
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openid);
$order = WxPayApi::unifiedOrder($input);
$jsApiParameters = $tools->GetJsApiParameters($order);
echo $jsApiParameters;
}else{
$input->SetTrade_type("MWEB");
$input->SetProduct_id($order_id);
$input->values['spbill_create_ip'] = re_clientip();
$result = WxPayApi::unifiedOrder($input);
$data = array('error' => 0,);
if($result['return_code'] =='SUCCESS' && $result['result_code'] == 'SUCCESS'){
$data['mweb_url'] = $result['mweb_url'].'&redirect_url='.urlencode($_SERVER['HTTP_REFERER']);
}else{
$data['error'] = $result['return_msg']."({$result['return_code']})";
}
echo json_encode($data);
}
exit;
}
else{
if(!$_G['uid']){
$openid = $_G['cookie'][$cookie] ? authcode($_G['cookie'][$cookie], 'DECODE', $authkey) : '';
if(!$openid){
$opendata = $tools->GetOpenid();
if($openid = $opendata['openid']){
dsetcookie($cookie, authcode($openid, 'ENCODE', $authkey), 7100);
dsetcookie('reaccesstoken', authcode($opendata['access_token'], 'ENCODE', $authkey), 7200);
}
}
$wxuser = $tools->getUserInfoById(authcode($_G['cookie']['reaccesstoken'], 'DECODE', $authkey), $openid);
}else{
$openid = $_G['cookie'][$cookie] ? authcode($_G['cookie'][$cookie], 'DECODE', $authkey) : '';
if(!$openid && IN_WECHAT){
$opendata = $tools->GetOnlyOpenid();
if($openid = $opendata['openid']){
dsetcookie($cookie, authcode($openid, 'ENCODE', $authkey), 7100);
}
}
$wxuser = array(
'nickname' => diconv($_G['username'], CHARSET,'UTF-8'),
'headimgurl' => avatar($_G['uid'], 'middle', true),
);
}
if($_GET['tid']){
$_SERVER['HTTP_REFERER'] = $_G['siteurl'].'forum.php?mod=viewthread&tid='.$_GET['tid'];
}
$nickname = diconv($wxuser['nickname'],'UTF-8', CHARSET);
$nickname && dsetcookie('rewxnickname', $nickname, 86400);
$wxuser['headimgurl'] && dsetcookie('rewxheadimgurl', $wxuser['headimgurl'], 86400);
$apple = 0;
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPod')){
$apple = 1;
}
if($config['tpl']==1){
include_once template('xigua_re:choose');
}else{
include_once template('xigua_re:choose2');
}
}