예제 #1
0
 public static function build_http_query_multi($params)
 {
     if (!$params) {
         return '';
     }
     uksort($params, 'strcmp');
     $pairs = array();
     self::$boundary = $boundary = uniqid('------------------');
     $MPboundary = '--' . $boundary;
     $endMPboundary = $MPboundary . '--';
     $multipartbody = '';
     foreach ($params as $parameter => $value) {
         if (in_array($parameter, array('pic', 'image')) && $value[0] == '@') {
             $url = ltrim($value, '@');
             $content = file_get_contents($url);
             $array = explode('?', basename($url));
             $filename = $array[0];
             $multipartbody .= $MPboundary . "\r\n";
             $multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
             $multipartbody .= "Content-Type: image/unknown\r\n\r\n";
             $multipartbody .= $content . "\r\n";
         } else {
             $multipartbody .= $MPboundary . "\r\n";
             $multipartbody .= 'content-disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
             $multipartbody .= $value . "\r\n";
         }
     }
     $multipartbody .= $endMPboundary;
     return $multipartbody;
 }
                if ($result['rs_code'] == '2100') {
                    $new_hd_token = $client->oauth->getAccessToken('token', $hd_token);
                    require_once libfile('function/cache');
                    writetocache('dzapp_haodai_setting', getcachevars(array('hd_token' => $new_hd_token)));
                    showtablerow('', array('class="td24"'), array($lang['callback_status'], '<font color="green">' . $lang['valid'] . '</font>'));
                } else {
                    $auth_url = $client->oauth->getAuthorizeURL(HD_CALLBACK_URL);
                    showtablerow('', array('class="td24"'), array($lang['callback_status'], '<font color="red">' . $lang['callback_expired'] . '</font> <a href="' . $auth_url . '"><img src="source/plugin/dzapp_haodai/images/haodai_login.png" class="vmiddle"></a>'));
                }
            } else {
                showtablerow('', array('class="td24"'), array($lang['callback_status'], '<font color="green">' . $lang['valid'] . '</font>'));
            }
        } elseif (isset($hd_token['expires']) && TIMESTAMP < $hd_token['expires'] - 3600) {
            showtablerow('', array('class="td24"'), array($lang['callback_status'], '<font color="green">' . $lang['valid'] . '</font>'));
        } else {
            $oauth = new HaoDaiOAuth(HD_AKEY, HD_SKEY);
            $auth_url = $oauth->getAuthorizeURL(HD_CALLBACK_URL);
            showtablerow('', array('class="td24"'), array($lang['callback_status'], '<font color="red">' . $lang['callback_expired'] . '</font> <a href="' . $auth_url . '"><img src="source/plugin/dzapp_haodai/images/haodai_login.png" class="vmiddle"></a>'));
        }
    }
    showtablefooter();
} elseif ($_GET['want'] == 'import') {
    if (!submitcheck('ok')) {
        showformheader('plugins&operation=config&identifier=dzapp_haodai&pmod=admincp_callback&want=import');
        showtableheader('import_callback');
        showsetting($lang['appkey'], 'AKEY', defined('HD_AKEY') ? HD_AKEY : '', 'text');
        showsetting($lang['appsecret'], 'SKEY', defined('HD_SKEY') ? HD_SKEY : '', 'text');
        showsetting($lang['ref'], 'REF', defined('HD_REF') ? HD_REF : '', 'text');
        showsetting($lang['callback_url'], 'CALLBACK_URL', defined('HD_CALLBACK_URL') ? HD_CALLBACK_URL : $_G['siteurl'] . 'plugin.php?id=dzapp_haodai:callback', 'text');
        showsetting($lang['host_url'], 'API_HOST', defined('HD_API_HOST') ? HD_API_HOST : 'http://api.haodai.com/', 'text');
        showsubmit('ok', "ok");
예제 #3
0
파일: callback.inc.php 프로젝트: cwcw/cms
<?php

/**
 * DZAPP Haodai Callback Interface
 *
 * @copyright (c) 2013 DZAPP. (http://www.dzapp.cn)
 * @author BranchZero <*****@*****.**>
 */
include_once DISCUZ_ROOT . './data/dzapp_haodai_config.php';
require_once DISCUZ_ROOT . './source/plugin/dzapp_haodai/haodai.api.class.php';
$o = new HaoDaiOAuth(HD_AKEY, HD_SKEY);
!defined('IN_DISCUZ') && exit('Access Denied');
if (isset($_REQUEST['code'])) {
    $keys = array();
    $keys['code'] = $_REQUEST['code'];
    $keys['redirect_uri'] = HD_CALLBACK_URL;
    $hd_token = $o->getAccessToken('code', $keys);
    require_once libfile('function/cache');
    writetocache('dzapp_haodai_setting', getcachevars(array('hd_token' => $hd_token)));
    dheader('Location: ' . $_G['siteurl'] . 'admin.php?action=plugins&operation=config&identifier=dzapp_haodai&pmod=admincp_callback');
}