Beispiel #1
0
function make_downloadurl($sha1, $filesize, $filename)
{
    global $_G;
    $filename = trim($filename, ' "');
    // Discuz! 默认的filename两侧会加上 双引号
    $filename = diconv($filename, CHARSET, 'UTF-8');
    $filename = str2hex($filename);
    $filename = strtolower($filename[1]);
    $post = 'http://dz.xf.qq.com/ftn.php?v=1&&';
    $k = _hash_hmac('sha1', sprintf('%s|%s|%s', $sha1, $_G['timestamp'], $_G['setting']['ftn_site_id']), $_G['setting']['xf_storage_enc_key']);
    $parm = array('site_id' => $_G['setting']['ftn_site_id'], 't' => $_G['timestamp'], 'sha1' => $sha1, 'filesize' => $filesize, 'filename' => $filename, 'k' => $k, 'ip' => $_G['clientip']);
    return $post . cloud_http_build_query($parm, '', '&&');
}
 function _viewthread_share_method_output()
 {
     global $_G;
     require_once libfile('function/connect');
     if ($GLOBALS['page'] == 1 && $_G['forum_firstpid'] && $GLOBALS['postlist'][$_G['forum_firstpid']]['invisible'] == 0) {
         $_G['connect']['feed_js'] = $_G['connect']['t_js'] = false;
         if (!getstatus($_G['forum_thread']['status'], 7) && $_G['forum_thread']['displayorder'] >= 0) {
             $feedlogstatus = false;
             $_G['connect']['feed_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_feedlog') . " WHERE tid='{$_G['tid']}'");
             if ($_G['connect']['feed_log']) {
                 $_G['connect']['feed_interval'] = 300;
                 $_G['connect']['feed_publish_max'] = 1000;
                 if ($_G['connect']['feed_log'] && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) {
                     if ($_G['connect']['feed_log']['status'] == 1 || $_G['connect']['feed_log']['status'] == 2 && TIMESTAMP - $_G['connect']['feed_log']['lastpublished'] > $_G['connect']['feed_interval'] && $_G['connect']['feed_log']['publishtimes'] < $_G['connect']['feed_publish_max']) {
                         DB::query("UPDATE " . DB::table('connect_feedlog') . " SET status='2', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}' AND status!=4");
                         $_G['connect']['feed_js'] = $feedlogstatus = true;
                     }
                 }
             } else {
                 $feedlogstatus = true;
             }
         }
         if (!getstatus($_G['forum_thread']['status'], 8) && $_G['forum_thread']['displayorder'] >= 0) {
             $_G['connect']['t_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_tlog') . " WHERE tid='{$_G['tid']}'");
             if ($_G['connect']['t_log']) {
                 $_G['connect']['t_interval'] = 300;
                 $_G['connect']['t_publish_max'] = 1000;
                 if ($_G['connect']['t_log'] && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) {
                     if ($_G['connect']['t_log']['status'] == 1 || $_G['connect']['t_log']['status'] == 2 && TIMESTAMP - $_G['connect']['t_log']['lastpublished'] > $_G['connect']['t_interval'] && $_G['connect']['t_log']['publishtimes'] < $_G['connect']['t_publish_max']) {
                         DB::query("UPDATE " . DB::table('connect_tlog') . " SET status='2', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}' AND status!=4");
                         $_G['connect']['t_js'] = $tlogstatus = true;
                     }
                 }
             } else {
                 $tlogstatus = true;
             }
         }
         if ($feedlogstatus || $tlogstatus) {
             $newstatus = $_G['forum_thread']['status'];
             $newstatus = $feedlogstatus ? setstatus(7, 1, $newstatus) : $newstatus;
             $newstatus = $tlogstatus ? setstatus(8, 1, $newstatus) : $newstatus;
             DB::query("UPDATE " . DB::table('forum_thread') . " SET status='{$newstatus}' WHERE tid='{$_G['tid']}'");
         }
         $_G['connect']['thread_url'] = $_G['siteurl'] . $GLOBALS['canonical'];
         $_G['connect']['qzone_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=1&thread_id=' . $_G['tid'];
         $_G['connect']['weibo_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=2&thread_id=' . $_G['tid'];
         $_G['connect']['pengyou_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=3&thread_id=' . $_G['tid'];
         $_G['connect']['qzone_share_api'] = $_G['connect']['qzone_public_share_url'] . '?url=' . urlencode($_G['connect']['thread_url']);
         $_G['connect']['pengyou_share_api'] = $_G['connect']['qzone_public_share_url'] . '?to=pengyou&url=' . urlencode($_G['connect']['thread_url']);
         $params = array('oauth_consumer_key' => $_G['setting']['connectappid'], 'title' => $GLOBALS['postlist'][$_G['forum_firstpid']]['subject'], 'url' => $_G['connect']['thread_url']);
         $params['sig'] = connect_get_sig($params, connect_get_sig_key());
         $_G['connect']['t_share_api'] = $_G['connect']['url'] . '/mblog/redirect?' . cloud_http_build_query($params, '', '&');
         $_G['connect']['first_post'] = daddslashes($GLOBALS['postlist'][$_G['forum_firstpid']]);
         $_G['gp_connect_autoshare'] = !empty($_G['gp_connect_autoshare']) ? 1 : 0;
         $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey'];
         if ($this->allow && $_G['setting']['connect']['mblog_app_key']) {
             $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['mblog_app_key'];
         }
         $extrajs = '';
         if ($_G['connect']['feed_js'] || $_G['connect']['t_js']) {
             $params = array();
             $params['thread_id'] = $_G['tid'];
             $params['ts'] = TIMESTAMP;
             $params['type'] = bindec(($_G['connect']['t_js'] ? '1' : '0') . ($_G['connect']['feed_js'] ? '1' : '0'));
             $params['sig'] = connect_get_sig($params, connect_get_sig_key());
             $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . cloud_http_build_query($params, '', '&');
             $extrajs = connect_output_javascript($jsurl);
         }
         if (!$_G['member']['conisbind'] && $_G['group']['allowgetimage'] && $_G['thread']['price'] == 0) {
             if ($_G['connect']['first_post']['message']) {
                 require_once libfile('function/connect');
                 $post['html_content'] = connect_parse_bbcode($_G['connect']['first_post']['message'], $_G['connect']['first_post']['fid'], $_G['connect']['first_post']['pid'], $_G['connect']['first_post']['htmlon'], $attach_images);
                 if ($attach_images && is_array($attach_images)) {
                     $attach_images = array_slice($attach_images, 0, 3);
                     $share_images = array();
                     foreach ($attach_images as $attach_image) {
                         $share_images[] = urlencode($attach_image['big']);
                     }
                     $_G['connect']['share_images'] = implode('|', $share_images);
                     unset($share_images);
                 }
             }
         }
         connect_merge_member();
         return tpl_viewthread_share_method() . $extrajs;
     }
 }
Beispiel #3
0
function cloud_http_build_query($data, $numeric_prefix = '', $arg_separator = '', $prefix = '')
{
    $render = array();
    if (empty($arg_separator)) {
        $arg_separator = @ini_get('arg_separator.output');
        empty($arg_separator) && ($arg_separator = '&');
    }
    foreach ((array) $data as $key => $val) {
        if (is_array($val) || is_object($val)) {
            $_key = empty($prefix) ? "{$key}[%s]" : sprintf($prefix, $key) . "[%s]";
            $_render = cloud_http_build_query($val, '', $arg_separator, $_key);
            if (!empty($_render)) {
                $render[] = $_render;
            }
        } else {
            if (is_numeric($key) && empty($prefix)) {
                $render[] = urlencode("{$numeric_prefix}{$key}") . "=" . urlencode($val);
            } else {
                if (!empty($prefix)) {
                    $_key = sprintf($prefix, $key);
                    $render[] = urlencode($_key) . "=" . urlencode($val);
                } else {
                    $render[] = urlencode($key) . "=" . urlencode($val);
                }
            }
        }
    }
    $render = implode($arg_separator, $render);
    if (empty($render)) {
        $render = '';
    }
    return $render;
}
Beispiel #4
0
 $sig_params['oauth_signature'] = connect_get_oauth_signature($api_url, $sig_params, 'POST', $oauth_token_secret);
 $params['sh_type'] = $sh_type;
 $params['subject'] = $_G['gp_subject'];
 $params['share_subject'] = $_G['gp_share_subject'];
 $params['thread_id'] = $_G['gp_thread_id'];
 $params['author'] = $_G['gp_author'];
 $params['author_id'] = $_G['gp_author_id'];
 $params['forum_id'] = $_G['gp_forum_id'];
 $params['p_id'] = $_G['gp_post_id'];
 $parmas['u_id'] = $_G['uid'];
 $params['reason'] = $_G['gp_reason'];
 $params['content'] = $_G['gp_html_content'];
 $params['client_ip'] = $_G['clientip'];
 $params['attach_images'] = $_G['gp_attach_image'];
 $params = array_merge($sig_params, $params);
 $response = connect_output_php($api_url . '?', cloud_http_build_query($params, '', '&'));
 if (!isset($response['status'])) {
     $code = 100;
     connect_errlog($code, lang('connect', 'connect_errlog_server_no_response'));
     $message = lang('connect', 'server_busy');
 } else {
     if ($response['status'] == 0) {
         $code = $response['status'];
         if ($sh_type == 2) {
             $message = lang('connect', 'broadcast_success');
         } else {
             $message = lang('connect', 'share_success');
         }
     } else {
         $message = lang('connect', 'server_busy');
         $code = $response['status'];
Beispiel #5
0
function connect_get_oauth_signature($url, $params, $method = 'POST', $oauth_token_secret = '')
{
    global $_G;
    $method = strtoupper($method);
    if (!in_array($method, array('GET', 'POST'))) {
        return FALSE;
    }
    $url = urlencode($url);
    $param_str = urlencode(cloud_http_build_query($params, '', '&'));
    $base_string = $method . '&' . $url . '&' . $param_str;
    $key = $_G['setting']['connectappkey'] . '&' . $oauth_token_secret;
    if (function_exists('hash_hmac')) {
        $signature = hash_hmac('sha1', $base_string, $key);
    } else {
        $signature = connect_custom_hmac('sha1', $base_string, $key);
    }
    return $signature;
}
Beispiel #6
0
        showmessage('qqconnect:connect_config_unbind_success', 'member.php?mod=logging&action=login');
    }
} else {
    if ($_G[inajax] && $op == 'synconfig') {
        DB::query("UPDATE " . DB::table('common_member_connect') . " SET conispublishfeed='0', conispublisht='0' WHERE uid='{$_G['uid']}'");
        dsetcookie('connect_synpost_tip');
    } elseif ($op == 'weibosign') {
        require_once libfile('function/connect');
        connect_merge_member();
        if ($_G['member']['conuin'] && $_G['member']['conuinsecret']) {
            $arr = array();
            $arr['oauth_consumer_key'] = $_G['setting']['connectappid'];
            $arr['oauth_nonce'] = mt_rand();
            $arr['oauth_timestamp'] = TIMESTAMP;
            $arr['oauth_signature_method'] = 'HMAC_SHA1';
            $arr['oauth_token'] = $_G['member']['conuin'];
            ksort($arr);
            $arr['oauth_signature'] = connect_get_oauth_signature('http://api.discuz.qq.com/connect/getSignature', $arr, 'GET', $_G['member']['conuinsecret']);
            $result = connect_output_php('http://api.discuz.qq.com/connect/getSignature?' . cloud_http_build_query($arr, '', '&'));
            if ($result['status'] == 0) {
                connect_ajax_ouput_message('[wb=' . $result['result']['username'] . ']' . $result['result']['signature_url'] . '[/wb]', 0);
            } else {
                connect_ajax_ouput_message('connect_wbsign_no_account', $result['status']);
            }
        } else {
            connect_ajax_ouput_message('connect_wbsign_no_bind', -1);
        }
    } else {
        dheader('location: home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp');
    }
}
        }
    }
} elseif ($op == 'change') {
    dsetcookie('con_request_token');
    dsetcookie('con_request_token_secret');
    $response = connect_get_request_token();
    if (!isset($response['status']) || $response['status'] !== 0) {
        connect_errlog($response['status'], $response['result']);
        showmessage('qqconnect:connect_get_request_token_failed', $referer);
    }
    $request_token = $response['result']['oauth_token'];
    $request_token_secret = $response['result']['oauth_token_secret'];
    dsetcookie('con_request_token', $request_token);
    dsetcookie('con_request_token_secret', $request_token_secret);
    $params = array('oauth_token' => $request_token, 'oauth_consumer_key' => $_G['setting']['connectappid']);
    $redirect = $_G['connect']['url'] . '/discuz/login?' . cloud_http_build_query($params, '', '&');
    dheader('Location:' . $redirect);
}
function connect_login($connect_member)
{
    global $_G;
    $member = DB::fetch_first("SELECT * FROM " . DB::table('common_member') . " WHERE uid='{$connect_member['uid']}'");
    if (!$member) {
        return false;
    }
    require_once libfile('function/member');
    $cookietime = 1296000;
    setloginstatus($member, $cookietime);
    dsetcookie('connect_login', 1, $cookietime);
    dsetcookie('connect_is_bind', '1', 31536000);
    dsetcookie('connect_uin', $connect_member['conopenid'], 31536000);
Beispiel #8
0
 function benchMarkLog($startTime, $id, $data, $type)
 {
     return true;
     $endTime = microtime(true);
     include_once libfile('function/cloud');
     $dataSize = strlen(cloud_http_build_query($data));
     $content = array(date('Y-m-d H:i:s', $startTime), $endTime - $startTime, $type, $id, $dataSize);
     $content = join(',', $content) . "\n";
 }
Beispiel #9
0
 function _viewthread_share_method_output()
 {
     global $_G, $postlist;
     require_once libfile('function/connect');
     $extrajs = '';
     if ($GLOBALS['page'] == 1 && $_G['forum_firstpid'] && $GLOBALS['postlist'][$_G['forum_firstpid']]['invisible'] == 0 && TIMESTAMP - $_G['forum_thread']['dateline'] < 43200) {
         $_G['connect']['feed_js'] = $_G['connect']['t_js'] = $feedlogstatus = $tlogstatus = false;
         if ((!getstatus($_G['forum_thread']['status'], 7) || !getstatus($_G['forum_thread']['status'], 8)) && $_G['forum_thread']['displayorder'] >= 0 && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) {
             $_G['connect']['feed_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_feedlog') . " WHERE tid='{$_G['tid']}'");
             if ($_G['connect']['feed_log']) {
                 $_G['connect']['feed_interval'] = 300;
                 $_G['connect']['feed_publish_max'] = 1000;
                 if (getstatus($_G['connect']['feed_log']['status'], 1) || getstatus($_G['connect']['feed_log']['status'], 2) && TIMESTAMP - $_G['connect']['feed_log']['lastpublished'] > $_G['connect']['feed_interval'] && $_G['connect']['feed_log']['publishtimes'] < $_G['connect']['feed_publish_max']) {
                     $_G['connect']['feed_js'] = $feedlogstatus = true;
                 }
                 if (getstatus($_G['connect']['feed_log']['status'], 3) || getstatus($_G['connect']['feed_log']['status'], 4) && TIMESTAMP - $_G['connect']['feed_log']['lastpublished'] > $_G['connect']['feed_interval'] && $_G['connect']['feed_log']['publishtimes'] < $_G['connect']['feed_publish_max']) {
                     $_G['connect']['t_js'] = $tlogstatus = true;
                 }
                 if ($feedlogstatus || $tlogstatus) {
                     $status = $feedlogstatus ? setstatus(2, 1, $status) : $status;
                     $status = $tlogstatus ? setstatus(4, 1, $status) : $status;
                     DB::query("UPDATE " . DB::table('connect_feedlog') . " SET status='{$status}', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}'");
                 }
             }
         }
         if ($feedlogstatus || $tlogstatus) {
             $newstatus = $_G['forum_thread']['status'];
             $newstatus = $feedlogstatus ? setstatus(7, 1, $newstatus) : $newstatus;
             $newstatus = $tlogstatus ? setstatus(8, 1, $newstatus) : $newstatus;
             DB::query("UPDATE " . DB::table('forum_thread') . " SET status='{$newstatus}' WHERE tid='{$_G['tid']}'");
         }
         if ($_G['connect']['feed_js'] || $_G['connect']['t_js']) {
             $params = array();
             $params['thread_id'] = $_G['tid'];
             $params['ts'] = TIMESTAMP;
             $params['type'] = bindec(($_G['connect']['t_js'] ? '1' : '0') . ($_G['connect']['feed_js'] ? '1' : '0'));
             $params['sig'] = connect_get_sig($params, connect_get_sig_key());
             $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . cloud_http_build_query($params, '', '&');
             $extrajs = connect_output_javascript($jsurl);
         }
     }
     $_G['connect']['thread_url'] = $_G['siteurl'] . $GLOBALS['canonical'];
     $_G['connect']['qzone_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=1&thread_id=' . $_G['tid'];
     $_G['connect']['weibo_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=2&thread_id=' . $_G['tid'];
     $_G['connect']['pengyou_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=3&thread_id=' . $_G['tid'];
     $_G['connect']['qzone_share_api'] = $_G['connect']['qzone_public_share_url'] . '?url=' . urlencode($_G['connect']['thread_url']);
     $_G['connect']['pengyou_share_api'] = $_G['connect']['qzone_public_share_url'] . '?to=pengyou&url=' . urlencode($_G['connect']['thread_url']);
     $params = array('oauth_consumer_key' => $_G['setting']['connectappid'], 'title' => $GLOBALS['postlist'][$_G['forum_firstpid']]['subject'], 'url' => $_G['connect']['thread_url']);
     $params['sig'] = connect_get_sig($params, connect_get_sig_key());
     $_G['connect']['t_share_api'] = $_G['connect']['url'] . '/mblog/redirect?' . cloud_http_build_query($params, '', '&');
     $_G['connect']['first_post'] = daddslashes($GLOBALS['postlist'][$_G['forum_firstpid']]);
     if ($_G['connect']['first_post']['anonymous']) {
         $_G['connect']['first_post']['authorid'] = 0;
         $_G['connect']['first_post']['author'] = '';
     }
     $_G['gp_connect_autoshare'] = !empty($_G['gp_connect_autoshare']) ? 1 : 0;
     $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey'];
     if ($this->allow && $_G['setting']['connect']['mblog_app_key']) {
         $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['mblog_app_key'];
     }
     if (trim($_G['forum']['viewperm'])) {
         $allowViewPermGroupIds = explode("\t", trim($_G['forum']['viewperm']));
     }
     if (trim($_G['forum']['getattachperm'])) {
         $allowViewAttachGroupIds = explode("\t", trim($_G['forum']['getattachperm']));
     }
     $bigWidth = '400';
     $bigHeight = '400';
     $share_images = array();
     foreach ($postlist[$_G['connect']['first_post']['pid']]['attachments'] as $attachment) {
         if ($attachment['isimage'] == 0 || $attachment['price'] > 0 || $attachment['readperm'] > $_G['group']['readaccess'] || $allowViewPermGroupIds && !in_array($_G['groupid'], $allowViewPermGroupIds) || $allowViewAttachGroupIds && !in_array($_G['groupid'], $allowViewAttachGroupIds)) {
             continue;
         }
         $key = md5($attachment['aid'] . '|' . $bigWidth . '|' . $bigHeight);
         $bigImageURL = $_G['siteurl'] . 'forum.php?mod=image&aid=' . $attachment['aid'] . '&size=' . $bigWidth . 'x' . $bigHeight . '&key=' . rawurlencode($key) . '&type=fixnone&nocache=1';
         $share_images[] = urlencode($bigImageURL);
     }
     $_G['connect']['share_images'] = implode('|', $share_images);
     connect_merge_member();
     return tpl_viewthread_share_method() . $extrajs;
 }