清除Discuz!云平台功能,QQ互联独立

This commit is contained in:
Comsenz 2017-07-08 15:55:56 +08:00
parent 33f3ec0c4a
commit d2555bd8c5
144 changed files with 1755 additions and 15878 deletions

View File

@ -36,6 +36,7 @@ if(!$_G['setting']['connect']['allow']) {
define('CURMODULE', $mod);
runhooks();
$connectService = Cloud::loadClass('Service_Connect');
require_once DISCUZ_ROOT.'/source/plugin/qqconnect/lib/Connect.php';
$connectService = new Cloud_Service_Connect();
require_once libfile('connect/'.$mod, 'plugin/qqconnect');
?>

View File

@ -77,7 +77,6 @@ $discuz->cachelist = $cachelist;
switch ($mod) {
case 'secqaa':
case 'manyou':
case 'userstatus':
case 'seccode':
$discuz->init_cron = false;

View File

@ -14,7 +14,7 @@ require './source/class/class_core.php';
$discuz = C::app();
$modarray = array('my', 'user', 'curforum', 'newthread');
$modarray = array('user', 'curforum', 'newthread');
$cachelist = $slist = array();
$mod = '';

View File

@ -238,7 +238,7 @@ EOT;
require libfile("cloud/$operation", 'admincp');
} elseif(in_array($operation, array('manyou', 'connect', 'security', 'stats', 'search', 'smilies', 'qqgroup', 'union', 'storage'))) {
if($cloudstatus != 'cloud') {
/* if($cloudstatus != 'cloud') {
cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'", 3000);</script>');
}
@ -251,7 +251,7 @@ EOT;
cpmsg('cloud_application_disable', 'action=plugins', 'error');
}
}
*/
require libfile("cloud/$operation", 'admincp');
} else {

View File

@ -236,7 +236,6 @@ $menu['tools'] = array(
$isfounder ? array('menu_tools_fileperms', 'tools_fileperms') : null,
$isfounder ? array('menu_tools_filecheck', 'checktools_filecheck') : null,
$isfounder ? array('menu_tools_hookcheck', 'checktools_hookcheck') : null,
$isfounder ? array('menu_cloud_doctor', 'cloud_doctor') : null,
);
if($isfounder) {
$topmenu['founder'] = '';

View File

@ -1,145 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_connect.php 33756 2013-08-10 06:32:48Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$utilService = Cloud::loadClass('Service_Util');
$connectService = Cloud::loadClass('Service_Connect');
$op = $_GET['op'];
$signUrl = $utilService->generateSiteSignUrl();
$_GET['anchor'] = in_array($_GET['anchor'], array('setting', 'service')) ? $_GET['anchor'] : 'setting';
$current = array($_GET['anchor'] => 1);
$connectnav = array();
$connectnav[0] = array('connect_menu_setting', 'cloud&operation=connect&anchor=setting', $current['setting']);
$connectnav[1] = array('connect_menu_service', 'cloud&operation=connect&anchor=service', $current['service']);
if (!$_G['inajax']) {
cpheader();
}
if($_GET['anchor'] == 'service') {
$utilService->redirect($cloudDomain.'/connect/service/?' . $signUrl);
} elseif ($_GET['anchor'] == 'setting') {
$setting = C::t('common_setting')->fetch_all(array('extcredits', 'connect', 'connectsiteid', 'connectsitekey', 'regconnect'));
$setting['connect'] = (array)dunserialize($setting['connect']);
if(!submitcheck('connectsubmit')) {
shownav('navcloud', 'menu_setting_qqconnect');
include_once libfile('function/forumlist');
$forumselect = array();
$forumselect['t'] = '<select name="connectnew[t][fids][]" multiple="multiple" size="10">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
if($setting['connect']['t']['fids']) {
foreach($setting['connect']['t']['fids'] as $v) {
$forumselect['t'] = str_replace('<option value="'.$v.'">', '<option value="'.$v.'" selected>', $forumselect['t']);
}
}
$connectrewardcredits = $connectgroup = $connectguestgroup = '';
$setting['extcredits'] = dunserialize($setting['extcredits']);
for($i = 0; $i <= 8; $i++) {
if($setting['extcredits'][$i]['available']) {
$extcredit = 'extcredits'.$i.' ('.$setting['extcredits'][$i]['title'].')';
$connectrewardcredits .= '<option value="'.$i.'" '.($i == intval($setting['connect']['register_rewardcredit']) ? 'selected' : '').'>'.($i ? $extcredit : $lang['none']).'</option>';
}
}
$groups = C::t('common_usergroup')->fetch_all_by_type('special');
foreach($groups as $group) {
$connectgroup .= "<option value=\"$group[groupid]\" ".($group['groupid'] == $setting['connect']['register_groupid'] ? 'selected' : '').">$group[grouptitle]</option>\n";
$connectguestgroup .= "<option value=\"$group[groupid]\" ".($group['groupid'] == $setting['connect']['guest_groupid'] ? 'selected' : '').">$group[grouptitle]</option>\n";
}
showformheader('cloud&operation=connect');
showtableheader();
showsetting('connect_setting_allow', 'connectnew[allow]', $setting['connect']['allow'], 'radio', 0, 1);
showsetting('setting_access_guest_connect_group', '', '', '<select name="connectnew[guest_groupid]"><option value="0">'.$lang['usergroups_system_0'].'</option>'.$connectguestgroup.'</select>');
showsetting('setting_access_register_connect_birthday', 'connectnew[register_birthday]', $setting['connect']['register_birthday'], 'radio');
showsetting('setting_access_register_connect_gender', 'connectnew[register_gender]', $setting['connect']['register_gender'], 'radio');
showsetting('setting_access_register_connect_uinlimit', 'connectnew[register_uinlimit]', $setting['connect']['register_uinlimit'], 'text');
showsetting('setting_access_register_connect_credit', '', '', '<select name="connectnew[register_rewardcredit]">'.$connectrewardcredits.'</select>');
showsetting('setting_access_register_connect_addcredit', 'connectnew[register_addcredit]', $setting['connect']['register_addcredit'], 'text');
showsetting('setting_access_register_connect_group', '', '', '<select name="connectnew[register_groupid]"><option value="0">'.$lang['usergroups_system_0'].'</option>'.$connectgroup.'</select>');
showsetting('setting_access_register_connect_regverify', 'connectnew[register_regverify]', $setting['connect']['register_regverify'], 'radio');
showsetting('setting_access_register_connect_invite', 'connectnew[register_invite]', $setting['connect']['register_invite'], 'radio');
showsetting('setting_access_register_connect_newbiespan', 'connectnew[newbiespan]', $setting['connect']['newbiespan'], 'text');
showtagfooter('tbody');
showsubmenu('menu_cloud_connect', $connectnav);
showsetting('connect_setting_t_allow', 'connectnew[t][allow]', $setting['connect']['t']['allow'], 'radio', 0, 1);
showsetting('connect_setting_t_fids', '', '', $forumselect['t']);
showsetting('connect_setting_t_group', 'connectnew[t][group]', $setting['connect']['t']['group'], 'radio');
showsetting('connect_setting_t_reply', 'connectnew[t][reply]', $setting['connect']['t']['reply'], 'radio');
showsetting('connect_setting_t_reply_showauthor', 'connectnew[t][reply_showauthor]', $setting['connect']['t']['reply_showauthor'], 'radio');
showtagfooter('tbody');
showsetting('connect_setting_like_allow', 'connectnew[like_allow]', $setting['connect']['like_allow'], 'radio', 0, 1);
showsetting('connect_setting_like_url', 'connectnew[like_qq]', $setting['connect']['like_qq'], 'text');
showtagfooter('tbody');
showsetting('connect_setting_turl_allow', 'connectnew[turl_allow]', $setting['connect']['turl_allow'], 'radio', 0, 1);
showsetting('connect_setting_turl_qq', 'connectnew[turl_qq]', $setting['connect']['turl_qq'], 'text');
showtagfooter('tbody');
showsetting('connect_setting_qshare_allow', 'connectnew[qshare_allow]', $setting['connect']['qshare_allow'], 'radio', 0, 1);
showtagfooter('tbody');
showsetting('connect_setting_weibo_appkey', 'connectnew[qshare_appkey]', $setting['connect']['qshare_appkey'], 'text');
showtagfooter('tbody');
showsubmit('connectsubmit');
showtablefooter();
showformfooter();
} else {
if($_GET['connectnew']['turl_qq'] && !is_numeric($_GET['connectnew']['turl_qq'])) {
cpmsg('connect_setting_turl_qq_failed', '', 'error');
}
if($_GET['connectnew']['like_url']) {
$url = parse_url($_GET['connectnew']['like_url']);
if(!preg_match('/\.qq\.com$/i', $url['host'])) {
cpmsg('connect_like_url_error', '', 'error');
}
}
if($_GET['connectnew']['like_allow'] && $_GET['connectnew']['like_url'] === '') {
cpmsg('connect_like_url_miss', '', 'error');
}
$_GET['connectnew'] = array_merge($setting['connect'], $_GET['connectnew']);
$_GET['connectnew']['like_url'] = $_GET['connectnew']['like_qq'] ? 'http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'.$_GET['connectnew']['like_qq'].'&width=100&height=21&type=button_num' : '';
$_GET['connectnew']['turl_code'] = '';
$connectnew = serialize($_GET['connectnew']);
$regconnectnew = !$setting['connect']['allow'] && $_GET['connectnew']['allow'] ? 1 : $setting['regconnect'];
C::t('common_setting')->update_batch(array('regconnect' => $regconnectnew, 'connect' => $connectnew));
$connectClient = Cloud::loadClass('Service_Client_Connect');
try {
$res = $connectClient->sync($_GET['connectnew']['like_qq'], $_GET['connectnew']['turl_qq']);
} catch (Cloud_Service_Client_RestfulException $e) {
$res = array('status' => false, 'msg' => cplang('qqgroup_msg_remote_exception', array('errmsg' => $e->getMessage(), 'errno' => $e->getCode())));
}
if(!is_array($res)) {
$res = array('status' => false, 'msg' => 'qqgroup_msg_remote_error');
}
if($res['mblogCode']) {
$_GET['connectnew']['turl_code'] = $res['mblogCode'];
$connectnew = serialize($_GET['connectnew']);
C::t('common_setting')->update('connect', $connectnew);
}
updatecache(array('setting', 'fields_register', 'fields_connect_register'));
cpmsg('connect_update_succeed', 'action=cloud&operation=connect', 'succeed');
}
}

View File

@ -1,250 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_doctor.php 36329 2016-12-26 08:47:27Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
@set_time_limit(0);
$op = trim($_GET['op']);
if(submitcheck('setidkeysubmit')) {
if (!isfounder()) {
cpmsg('action_noaccess', '', 'error');
}
$siteId = intval(trim($_GET['my_siteid']));
if($siteId && strcmp($_GET['my_siteid'], $siteId) !== 0) {
cpmsg('cloud_idkeysetting_siteid_failure', '', 'error');
}
$_GET['my_sitekey'] = trim($_GET['my_sitekey']);
if(empty($_GET['my_sitekey'])) {
$siteKey = '';
} elseif(strpos($_GET['my_sitekey'], '***')) {
$siteKey = false;
} elseif(preg_match('/^[0-9a-f]{32}$/', $_GET['my_sitekey'])) {
$siteKey = $_GET['my_sitekey'];
} else {
cpmsg('cloud_idkeysetting_sitekey_failure', '', 'error');
}
$settings = array();
if($siteKey !== false) {
$settings['my_sitekey'] = $siteKey;
}
if($_G['setting']['my_siteid'] != $siteId) {
$settings['my_siteid'] = $siteId;
}
if($_G['setting']['cloud_status'] != $_GET['cloud_status']) {
$settings['cloud_status'] = intval(trim($_GET['cloud_status']));;
}
if($settings) {
C::t('common_setting')->update_batch($settings);
updatecache('setting');
}
$locationUrl = ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor';
cpmsg('cloud_idkeysetting_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.$locationUrl.'\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.$locationUrl.'\'", 3000);</script>');
} elseif($op == 'apitest') {
$doctorService =Cloud::loadClass('Service_Doctor');
$APIType = intval($_GET['api_type']);
$APIIP = trim($_GET['api_ip']);
$startTime = microtime(true);
$testStatus = $doctorService->testAPI($APIType, $APIIP, $_G['setting']);
$endTime = microtime(true);
$otherTips = '';
if($APIIP) {
if ($_GET['api_description']) {
$otherTips = diconv(trim($_GET['api_description']), 'UTF-8');
}
} else {
if($APIType == 1) {
$otherTips = '<a href="javascript:;" onClick="display(\'cloud_tbody_api_test\')">'.$lang['cloud_doctor_api_test_other'].'</a>';
} elseif($APIType == 2) {
$otherTips = '<a href="javascript:;" onClick="display(\'cloud_tbody_manyou_test\')">'.$lang['cloud_doctor_manyou_test_other'].'</a>';
} elseif($APIType == 3) {
$otherTips = '<a href="javascript:;" onClick="display(\'cloud_tbody_qzone_test\')">'.$lang['cloud_doctor_qzone_test_other'].'</a>';
}
}
ajaxshowheader();
if($testStatus) {
printf($lang['cloud_doctor_api_test_success'], $lang['cloud_doctor_result_success'], $APIIP, $endTime - $startTime, $otherTips);
} else {
printf($lang['cloud_doctor_api_test_failure'], $lang['cloud_doctor_result_failure'], $APIIP, $otherTips);
}
ajaxshowfooter();
} elseif($op == 'setidkey') {
ajaxshowheader();
echo '
<h3 class="flb" id="fctrl_showblock" style="cursor: move;">
<em id="return_showblock" fwin="showblock">'.$lang['cloud_doctor_setidkey'].'</em>
<span><a title="'.$lang['close'].'" onclick="hideWindow(\'cloudApiIpWin\');return false;" class="flbc" href="javascript:;">'.$lang['close'].'</a></span>
</h3>
';
echo '<div style="margin: 0 10px; width: 700px;">';
showtips('cloud_doctor_setidkey_tips');
showformheader('cloud');
showhiddenfields(array('operation' => $operation));
showhiddenfields(array('op' => $op));
showtableheader();
showsetting('cloud_site_id', 'my_siteid', $_G['setting']['my_siteid'], 'text');
showsetting('cloud_site_key', 'my_sitekey', preg_replace('/(\w{2})\w*(\w{2})/', '\\1****\\2', $_G['setting']['my_sitekey']), 'text');
showsetting('cloud_site_status', array('cloud_status', array(array('0', $lang['cloud_doctor_status_0']), array('1', $lang['cloud_doctor_status_1']), array('2', $lang['cloud_doctor_status_2']))), $_G['setting']['cloud_status'], 'select');
showsubmit('setidkeysubmit');
showtablefooter();
showformfooter();
echo '</div>';
ajaxshowfooter();
} else {
$appService = Cloud::loadClass('Service_App');
$doctorService = Cloud::loadClass('Service_Doctor');
require_once DISCUZ_ROOT.'./source/discuz_version.php';
shownav('tools', 'menu_cloud_doctor');
showsubmenu('menu_cloud_doctor');
showtips('cloud_doctor_tips');
echo '<script type="text/javascript">var disallowfloat = "";</script>';
showtableheader();
showformheader('cloud');
showhiddenfields(array('operation' => 'siteinfo'));
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_status');
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_url').'</strong>',
$_G['siteurl'].
(isfounder() ? ' &nbsp; <input type="submit" class="btn" id="submit_syncsubmit" name="syncsubmit" value="'.$lang['cloud_sync'].'" />&nbsp; ' : '')
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_id').'</strong>',
$_G['setting']['my_siteid']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_key').'</strong>',
preg_replace('/(\w{2})\w*(\w{2})/', '\\1****\\2', $_G['setting']['my_sitekey']).' '.$lang['cloud_site_key_safetips']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_status').'</strong>',
(isfounder() ? $doctorService->showCloudStatus($_G['setting']['cloud_status']).' <a href="javascript:;" onClick="showWindow(\'cloudApiIpWin\', \''.ADMINSCRIPT.'?action=cloud&operation=doctor&op=setidkey\'); return false;">'.$lang['cloud_doctor_modify_siteidkey'].'</a>' : $doctorService->showCloudStatus($_G['setting']['cloud_status'])).
(isfounder() ? ' &nbsp; <input type="submit" class="btn" id="submit_resetsubmit" name="resetsubmit" value="'.$lang['cloud_resetkey'].'" />' : '')
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('setting_basic_bbclosed').'</strong>',
$_G['setting']['bbclosed'] ? $lang['cloud_doctor_close_yes'] : $lang['no']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_version').'</strong>',
DISCUZ_VERSION.' '.DISCUZ_RELEASE
));
if(isfounder()) {
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_change_info').'</strong>',
'<a href="'.$doctorService->changeQQUrl().'" target="_blank">'.cplang('cloud_change_qq').'</a>',
));
}
showtagfooter('tbody');
showformfooter();
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_result');
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_timecheck').'</strong>',
'<span id="cloud_time_check">' . cplang('cloud_doctor_time_check', array('imgdir' => $_G['style']['imgdir'])) .'</span>',
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_gethostbyname_function').'</strong>',
function_exists('gethostbyname') ? $lang['cloud_doctor_result_success'].' '.$lang['available'] : $lang['cloud_doctor_result_failure'].$lang['cloud_doctor_function_disable']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_api').'</strong>',
$doctorService->checkDNSResult(1, $_G['setting'])
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_api_test').'</strong>',
$doctorService->showTestJS(1)
));
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_api_test', false);
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_manyou_test', false);
showtagfooter('tbody');
showtagheader('tbody', '', true);
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_qzone').'</strong>',
$doctorService->checkDNSResult(3, $_G['setting'])
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_qzone_test').'</strong>',
$doctorService->showTestJS(3)
));
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_qzone_test', false);
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_site_test', true);
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_site_test').'</strong>',
cplang('cloud_doctor_site_test_result', array('imgdir' => $_G['style']['imgdir']))
));
showtagfooter('tbody');
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_plugin');
$doctorService->showPlugins();
showtagfooter('tbody');
if($appService->getCloudAppStatus('connect')) {
if ($op == 'fixGuest') {
$doctorService->fixGuestGroup(cplang('connect_guest_group_name'));
}
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_connect');
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_connect_app_id').'</strong>',
!empty($_G['setting']['connectappid']) ? $_G['setting']['connectappid'] : $lang['cloud_doctor_connect_reopen']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_connect_app_key').'</strong>',
!empty($_G['setting']['connectappkey']) ? preg_replace('/(\w{2})\w*(\w{2})/', '\\1****\\2', $_G['setting']['connectappkey']).' '.$lang['cloud_site_key_safetips'] : $lang['cloud_doctor_connect_reopen']
));
$guestGroupStr = cplang('cloud_doctor_result_success') .' '. cplang('cloud_doctor_normal');
if (!$doctorService->checkGuestGroup()) {
$guestGroupStr = cplang('cloud_doctor_result_failure') . ' ' . cplang('cloud_doctor_connect_fix');
}
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_connect_guestgroup').'</strong>',
$guestGroupStr,
));
showtagfooter('tbody');
}
showtablefooter();
$doctorService->showCloudDoctorJS();
}

View File

@ -1,157 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_manyou.php 29273 2012-03-31 07:58:50Z yexinhao $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!submitcheck('settingsubmit')) {
shownav('navcloud', 'setting_manyou');
$_GET['anchor'] = in_array($_GET['anchor'], array('base', 'manage')) ? $_GET['anchor'] : 'manage';
$current = array($_GET['anchor'] => 1);
$manyounav = array();
if($_G['setting']['my_app_status']) {
$manyounav[0] = array('setting_manyou_manage', 'cloud&operation=manyou&anchor=manage', $current['manage']);
}
$manyounav[1] = array('setting_manyou_base', 'cloud&operation=manyou&anchor=base', $current['base']);
showsubmenu('setting_manyou', $manyounav);
showformheader('cloud&edit=yes');
showhiddenfields(array('operation' => $operation));
if($_GET['anchor'] == 'base') {
showtips('setting_manyou_tips');
showtableheader('', 'nobottom', 'id="base"');
$actives = $checkarr = array();
$actives[$_G['setting']['my_app_status']] = ' class="checked"';
$checkarr[$_G['setting']['my_app_status']] = ' checked';
$str = <<<EOF
<ul onmouseover="altStyle(this);">
<li$actives[1]><input type="radio" onclick="hiddenShareInfo(0, 1);$('hidden_setting_manyou_base_status').style.display = '';" $checkarr[1] value="1" name="settingnew[my_app_status]" class="radio">&nbsp;$lang[yes]</li>
<li$actives[0]><input type="radio" onclick="hiddenShareInfo(0, 0);$('hidden_setting_manyou_base_status').style.display = 'none';" $checkarr[0] value="0" name="settingnew[my_app_status]" class="radio">&nbsp;$lang[no]</li>
</ul>
EOF;
showsetting('setting_manyou_base_status', 'settingnew[my_app_status]', $_G['setting']['my_app_status'], $str, '', 1);
showsetting('setting_manyou_base_close_prompt', 'settingnew[my_closecheckupdate]', $_G['setting']['my_closecheckupdate'], 'radio');
showsetting('setting_manyou_base_open_app_prompt', 'settingnew[my_openappprompt]', $_G['setting']['my_openappprompt'], 'radio');
showtagfooter('tbody');
$appstate = !empty($_G['setting']['my_app_status']) ? 1 : 0;
$actives = $checkarr = array();
echo <<<EOF
<script type="text/javascript">
var appState = $appstate;
function hiddenShareInfo(type, state) {
appState = state ? 1 : 0;
$('shareinfo').style.display = appState ? '' : 'none';
}
</script>
EOF;
showtagheader('tbody', 'shareinfo', $_G['setting']['my_app_status']);
showsetting('setting_manyou_base_ip', 'settingnew[my_ip]', $_G['setting']['my_ip'], 'text');
showtagfooter('tbody');
showtablefooter();
} elseif($_G['setting']['my_app_status']) {
$uchUrl = $_G['siteurl'].'/'.ADMINSCRIPT.'?action=cloud&operation=manyou&anchor=' . $_GET['anchor'];
if(empty($_GET['my_suffix'])) {
$_GET['my_suffix'] = '/appadmin/list';
}
$my_prefix = 'http://uchome.manyou.com';
$my_suffix = urlencode($_GET['my_suffix']);
$tmp_suffix = $_GET['my_suffix']?urldecode($_GET['my_suffix']):'/appadmin/list';
$myUrl = $my_prefix.$tmp_suffix;
$timestamp = time();
$hash = md5($_G['setting']['my_siteid'].'|'.$_G['uid'].'|'.$_G['setting']['my_sitekey'].'|'.$timestamp);
$delimiter = strrpos($myUrl, '?') ? '&' : '?';
$url = $myUrl.$delimiter.'s_id='.$_G['setting']['my_siteid'].'&uch_id='.$_G['uid'].'&uch_url='.urlencode($uchUrl).'&my_suffix='.$my_suffix.'&timestamp='.$timestamp.'&my_sign='.$hash;
print <<<EOF
<script type="text/javascript" src="http://static.manyou.com/scripts/my_iframe.js"></script>
<script language="javascript">
var prefixURL = "$my_prefix";
var suffixURL = "$my_suffix";
var queryString = '';
var url = "{$url}";
var oldHash = null;
var timer = null;
var server = new MyXD.Server("ifm0");
server.registHandler('iframeHasLoaded');
server.registHandler('setTitle');
server.start();
function iframeHasLoaded(ifm_id) {
MyXD.Util.showIframe(ifm_id);
document.getElementById('loading').style.display = 'none';
}
function setTitle(x) {
document.title = x;
}
</script>
<div id="loading" style="display:block; padding:100px 0 100px 0;text-align:center;color:#999999;font-size:12px;">
<img src="static/image/common/loading.gif" alt="loading..." align="absmiddle" /> {$lang['loading']}...
</div>
<div style="margin-top:8px;">
<iframe id="ifm0" frameborder="0" width="810px" scrolling="no" height="810px" style="position:absolute; top:-5000px; left:-5000px;" src="{$url}"></iframe>
</div>
</body></html>
EOF;
exit();
} else {
cpmsg('my_app_status_off', 'action=cloud&operation=manyou&anchor=base', 'error');
}
showsubmit('settingsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$settingnew = $_GET['settingnew'];
$settings = array();
foreach($settingnew as $key => $val) {
if($_G['setting'][$key] != $val) {
$$key = $val;
$settings[$key] = $val;
}
}
if($settings) {
C::t('common_setting')->update_batch($settings);
}
$appName = 'manyou';
$status = $settingnew['my_app_status'] ? 'normal' : 'pause';
$appService = Cloud::loadClass('Service_App');
$appService->setCloudAppStatus($appName, $status);
cpmsg('setting_update_succeed', 'action=cloud&operation='.$operation.(!empty($_GET['anchor']) ? '&anchor='.$_GET['anchor'] : ''), 'succeed');
}

View File

@ -1,743 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_qqgroup.php 31974 2012-10-29 06:02:39Z songlixin $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$op = trim($_GET['op']);
$utilService = Cloud::loadClass('Service_Util');
$signUrl = $utilService->generateSiteSignUrl(array('v' => 2));
$_GET['anchor'] = in_array($_GET['anchor'], array('block', 'list', 'info', 'setting')) ? $_GET['anchor'] : 'block';
if ($_GET['first']) {
$_GET['anchor'] = 'list';
}
$current = array($_GET['anchor'] => 1);
$qqgroupnav = array();
$qqgroupnav[0] = array('qqgroup_menu_block', 'cloud&operation=qqgroup&anchor=block', $current['block']);
$qqgroupnav[1] = array('qqgroup_menu_list', 'cloud&operation=qqgroup&anchor=list', $current['list']);
$qqgroupnav[2] = array('qqgroup_menu_manager', 'cloud&operation=qqgroup&anchor=info', $current['info']);
$qqgroupnav[3] = array('qqgroup_menu_setting', 'cloud&operation=qqgroup&anchor=setting', $current['setting']);
if (!$_G['inajax']) {
cpheader();
}
if($_GET['anchor'] == 'list') {
$utilService->redirect($cloudDomain.'/qun/list/?' . $signUrl);
} elseif($_GET['anchor'] == 'info') {
$utilService->redirect($cloudDomain.'/qun/siteInfo/?' . $signUrl);
} elseif($_GET['anchor'] == 'setting') {
if(submitcheck('settingsubmit')) {
$usergroups = $_POST['groupid'];
$updateData = array(
'qqgroup_usergroup_feed_list' => serialize($usergroups),
);
C::t('common_setting')->update_batch($updateData);
updatecache('setting');
cpmsg('setting_update_succeed', 'action=cloud&operation=qqgroup&anchor='.$_GET['anchor'], 'succeed');
} else {
$usergroupsfeedlist = unserialize($_G['setting']['qqgroup_usergroup_feed_list']);
$groupselect = array();
foreach (C::t('common_usergroup')->fetch_all_by_radminid(0) as $group) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
$groupselect[$group['type']] .= "<option value=\"$group[groupid]\" ".(in_array($group['groupid'], $usergroupsfeedlist) ? 'selected' : '').">$group[grouptitle]</option>\n";
}
$groupselect = ($groupselect['special'] ? '<optgroup label="'.$lang['usergroups_special'].'">'.$groupselect['special'].'</optgroup>' : '').
($groupselect['specialadmin'] ? '<optgroup label="'.$lang['usergroups_specialadmin'].'">'.$groupselect['specialadmin'].'</optgroup>' : '').
'<optgroup label="'.$lang['usergroups_system'].'">'.$groupselect['system'].'</optgroup>';
shownav('navcloud', 'menu_cloud_qqgroup');
showsubmenu('menu_cloud_qqgroup', $qqgroupnav);
showtips('qqgroup_setting_tips');
showformheader('cloud&operation=qqgroup&anchor=setting');
showtableheader('qqgroup_feed_setting', '', '', 2);
showsetting('qqgroup_usergroup_feed_list', '', '', '<select name="groupid[]" multiple="multiple" size="10">'.$groupselect.'</select>');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
}
} elseif($_GET['anchor'] == 'block') {
$perpage = 10;
$maxPage = 10;
$page = intval($_GET['page']);
$page = MAX($page, 1);
$page = MIN($page, $maxPage);
$prevPage = MAX($page - 1, 1);
$nextPage = MIN($page + 1, $maxPage);
if(submitcheck('setMiniportalThreadsSubmit')) {
$topic = $_GET['topic'];
$topic = processMiniportalTopicThread($topic);
if(!$topic) {
cpmsg('qqgroup_msg_deficiency', '', 'error');
}
$normal = $_GET['normal'];
$normal = processMiniportalNormalThreads($normal);
if(!$normal) {
cpmsg('qqgroup_msg_deficiency', '', 'error');
}
$serverResult = sentMiniportalThreadsRemote($topic, $normal);
$threads = array('topic' => $topic, 'normal' => $normal);
if($serverResult['status']) {
storeMiniportalThreads($threads);
cpmsg('qqgroup_msg_save_succeed', 'action=cloud&operation=qqgroup&anchor=block', 'succeed');
} else {
$info = array('threads' => $threads, 'errorIds' => $serverResult['errorIds']);
QQGroupMessage($serverResult['msg'], 'action=cloud&operation=qqgroup&anchor=block&sentResult=1', $info);
}
} elseif($op == 'getTopicThread') {
getTopicThread();
} elseif($op == 'getNormalThread') {
getNormalThread();
} elseif($op == 'uploadImage') {
$tid = intval($_GET['tid']);
if (submitcheck('uploadImageSubmit')) {
ajaxshowheader();
if($uploadImage = QQGroupUpload($tid)) {
echo '<div id="upload_msg_success">'.cplang('qqgroup_msg_upload_succeed').'</div><div id="upload_msg_imgpath" style="display:none;">'.$uploadImage['thumbTarget'].'</div><div id="upload_msg_imgurl" style="display:none;">'.$_G['setting']['attachurl'].$uploadImage['thumbTarget'].'</div>';
} else {
echo '<div id="upload_msg_failure">'.cplang('qqgroup_msg_upload_failure').'</div>';
}
ajaxshowfooter();
} else {
showUploadImageForm($tid);
}
} elseif($op == 'searchForm') {
showSearchThreads();
} else {
shownav('navcloud', 'menu_cloud_qqgroup');
showsubmenu('menu_cloud_qqgroup', $qqgroupnav);
echo '<div id="ajaxwaitid"></div>';
showQQGroupCSS();
showSearchDiv();
showMiniportalPreview();
showQQGroupScript();
}
}
function showSearchForm() {
require_once libfile('function/forumlist');
showformheader('cloud&operation=qqgroup&anchor=block&op=searchForm', 'onSubmit="ajaxGetSearchResultThreads(); return false;"', 'search_form');
showtableheader();
$orderoptions = array('views', 'replies', 'heats', 'dateline', 'lastpost', 'recommends');
$orderoption = '';
foreach($orderoptions as $value) {
$orderoption .= '<option value="'.$value.'" '.($value == 'dateline' ? 'selected="selected"' : '').'>'.cplang('qqgroup_search_order_'.$value).'</option>';
}
$datelineoptions = array(1, 2, 3, 4);
$datelineoption = '';
foreach($datelineoptions as $value) {
$datelineoption .= '<option value="'.$value.'" '.($value == 4 ? 'selected="selected"' : '').'>'.cplang(sprintf('qqgroup_search_dateline_%s', $value)).'</option>';
}
echo '
<tr>
<td><select id="srchorder" name="srchorder" onchange="ajaxChangeSearch();">'.$orderoption.'</select></td>
<td><select id="srchdateline" name="srchdateline" onChange="ajaxChangeSearch();">'.$datelineoption.'</select></td>
<td><label for="srchtid">'.cplang('qqgroup_search_tid').'</label></td>
<td><input type="text" value="" id="srchtid" name="srchtid" style="width:80px;" /></td>
<td><input type="submit" value="'.cplang('qqgroup_search_button').'" id="search_submit" name="search_submit" class="btn" /></td>
</tr>
';
showtablefooter();
showformfooter();
}
function showSearchThreads() {
global $_G, $page, $perpage;;
$threads = array();
$starttime = 0;
$srchtid = intval($_GET['srchtid']);
$srchorder = in_array($_GET['srchorder'], array('views', 'replies', 'heats', 'dateline', 'lastpost')) ? $_GET['srchorder'] : 'dateline';
$datelinearray = array(1 => 3600, 2 => 86400, 3 => 86400 * 7, 4 => 86400 * 30);
$srchdateline = array_key_exists($_GET['srchdateline'], $datelinearray) ? $datelinearray[$_GET['srchdateline']] : 86400 * 30;
$start = ($page - 1) * $perpage;
if($srchtid) {
$threads = C::t('forum_thread')->fetch_all_by_tid_displayorder($srchtid, 0);
} else {
$starttime = TIMESTAMP - $srchdateline;
$threads = C::t('forum_thread')->fetch_all_by_dateline($starttime, $start, $perpage, $srchorder);
}
$mpurl = ADMINSCRIPT.'?action=cloud&operation=qqgroup&anchor=block&op=searchForm'
.'&srchtid='.$srchtid.'&srchorder='.$srchorder.'&srchdateline='.intval($_GET['srchdateline']);
return showSearchResultThreads($threads, $mpurl);
}
function showSearchResultThreads($threads, $mpurl) {
global $_G;
$threadsOutput = '';
loadcache('forums');
if(empty($threads)) {
$threadsOutput = '
<tr><td colspan="3">'.cplang('qqgroup_search_nothreads').'</td></tr>
';
} else {
foreach($threads as $thread) {
$thread['subject'] = strip_tags($thread['subject']);
$threadsOutput .= '
<tr id="thread_'.$thread['tid'].'">
<td class="title"><a href="forum.php?mod=viewthread&tid='.$thread['tid'].'" title="'.$thread['subject'].'" target="_blank">'.cutstr($thread['subject'], 45).($thread['attachment'] == 2 ? '&nbsp;<img align="absmiddle" src="static/image/admincp/cloud/image_s.gif" alt="attach_img" title="'.cplang('attach_img').'" />' : '').'</a></td>
<td title="'.dhtmlspecialchars(strip_tags($_G['cache']['forums'][$thread['fid']]['name'])).'">'.cutstr(dhtmlspecialchars(strip_tags($_G['cache']['forums'][$thread['fid']]['name'])), 14, '').'</td>
<td class="qqqun_op"><a id="thread_addtop_'.$thread['tid'].'" href="javascript:;" onClick="addMiniportalTop('.$thread['tid'].')" class="qqqun_op_top" title="'.cplang('qqgroup_ctrl_add_miniportal_topic').'">top</a><a id="thread_addlist_'.$thread['tid'].'" href="javascript:;" onClick="addMiniportalList('.$thread['tid'].')" class="qqqun_op_list" title="'.cplang('qqgroup_ctrl_add_miniportal_normal').'">list</a></td>
</tr>';
}
}
ajaxshowheader();
echo $threadsOutput;
showSearchResultPageLinks(count($threads), $mpurl);
ajaxshowfooter();
}
function showSearchResultPageLinks($num = 0, $mpurl) {
global $_G, $page, $perpage, $maxPage;
$needNext = $page < $maxPage && $num == $perpage ? true : false;
if ($pageLink = QQGroupSearchSimplePage($needNext, $page, $mpurl)) {
echo '<tr><td colspan="3" class="qqqun_pg">'.$pageLink.'</td></tr>';
}
}
function QQGroupSearchSimplePage($needNext, $curpage, $mpurl) {
global $prevPage, $nextPage;
$return = '';
$lang['next'] = lang('core', 'nextpage');
$lang['prev'] = lang('core', 'prevpage');
$searchThreadsRule = 'ajaxGetPageResultThreads(\'%s\', \'%s\');';
$prevClickFunc = addcslashes(sprintf($searchThreadsRule, $prevPage, dhtmlspecialchars($mpurl)), '"');
$nextClickFunc = addcslashes(sprintf($searchThreadsRule, $nextPage, dhtmlspecialchars($mpurl)), '"');
$prev = $curpage > 1 ? '<a href="javascript:;" onClick="'.$prevClickFunc.'" >'.$lang['prev'].'</a>' : '';
$next = $needNext ? '<a href="javascript:;" onClick="'.$nextClickFunc.'" >'.$lang['next'].'</a>' : '';
if($next || $prev) {
$return = $prev.$next;
}
return $return;
}
function getTopicThread() {
global $_G;
$tid = intval($_GET['tid']);
if(empty($tid)) {
ajaxshowheader();
echo showTopicTemplate(0);
ajaxshowfooter();
return false;
}
require_once libfile('function/forum');
require_once libfile('function/discuzcode');
loadforum();
$posttable = $_G['thread']['posttable'];
if(empty($posttable)) {
ajaxshowheader();
echo showTopicTemplate(0);
ajaxshowfooter();
return false;
}
$imagePath = $imageUrl = '';
$subject = strip_tags($_G['thread']['subject']);
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($tid);
$pid = intval($post['pid']);
$message = cutstr(strip_tags(discuzcode($post['message'], 1, 0, 1)), 200);
$message = preg_replace('/\[attach\](\d+)\[\/attach\]/is', '', $message);
$imageDir = 'qqgroup';
$imageName = 'miniportal_tid_'.$tid.'.jpg';
$thumbTarget = $imageDir.'/'.$imageName;
if(file_exists($_G['setting']['attachdir'].'./'.$thumbTarget)) {
$imagePath = $thumbTarget;
$imageUrl = $_G['setting']['attachurl'].$imagePath;
} else {
$attachments = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'pid', $pid, '', array('-1', '1'), false, 0, 1);
if($attachments && $attachment = reset($attachments)) {
$imagePath = 'forum/'.$attachment['attachment'];
$imageUrl = $_G['setting']['attachurl'].$imagePath;
}
}
ajaxshowheader();
echo showTopicTemplate($tid, $subject, $message, $imagePath, $imageUrl);
ajaxshowfooter();
}
function showTopicTemplate($tid, $subject = '', $message = '', $imagePath = '', $imageUrl = '') {
$html = '';
if ($tid) {
$html .= '
<div class="qqqun_editor">
<ul>
<li class="e_edit"><a href="javascript:;" title="'.cplang('qqgroup_ctrl_edit').'" onClick="clickTopicEditor(\'title\')">edit</a></li>
<li class="e_pic"><a onclick="showWindow(\'uploadImgWin\', this.href); return false;" href="'.ADMINSCRIPT.'?action=cloud&operation=qqgroup&anchor=block&op=uploadImage&tid='.$tid.'" title="'.cplang('qqgroup_ctrl_upload_image').'">pic</a></li>
<li class="e_del"><a href="javascript:;" title="'.cplang('qqgroup_ctrl_remove').'" onClick="removeTopicThread('.$tid.')">del</a></li>
</ul>
</div>
<dl>
<input type="hidden" name="topic[id]" value="'.$tid.'" />
<input type="hidden" name="topic[displayorder]" value="0" />
<input type="hidden" id="topic_image_value" name="topic[extra][image]" value="'.$imagePath.'" />
<dt class="title"><input id="topic-editor-input-title" type="text" class="px tpx" name="topic[title]" value="'.str_replace(array('\\', '"'), array('&#92;', '&#34;'), $subject).'" onblur="blurTopic(this);" onClick="clickTopicEditor(\'title\');" /></dt>
<dd class="thumb"><a onclick="clickTopicEditor(\'image\'); showWindow(\'uploadImgWin\', this.href); return false;" href="'.ADMINSCRIPT.'?action=cloud&operation=qqgroup&anchor=block&op=uploadImage&tid='.$tid.'" title="'.cplang('qqgroup_ctrl_upload_image').'"><img id="topic_editor_thumb" src="'.($imageUrl ? $imageUrl.'?'.rand() : 'static/image/admincp/cloud/thumb.png').'" alt="'.cplang('qqgroup_ctrl_upload_image').'" /></a></dd>
<dd class="info">
<textarea id="topic-editor-textarea-content" class="pt ipt" onblur="blurTopic(this);" onClick="clickTopicEditor(\'content\');" name="topic[extra][content]">'.$message.'</textarea>
</dd>
</dl>
';
} else {
$html = '
<dl>
<div class="tips">'.cplang('qqgroup_preview_tips_topic').'</div>
</dl>
';
}
return $html;
}
function getNormalThread() {
global $_G;
$tid = intval($_GET['tid']);
if(empty($tid)) {
return false;
}
require_once libfile('function/forum');
require_once libfile('function/discuzcode');
loadforum();
$subject = strip_tags($_G['thread']['subject']);
$hasImage = $_G['thread']['attachment'] ? true : false;
ajaxshowheader();
echo showNormalTemplateLi($tid, $subject, $hasImage, true);
ajaxshowfooter();
}
function showNormalTemplateLi($tid, $subject = '', $hasImage = false) {
if ($tid) {
$html = '
<input type="hidden" class="normal_thread_tid" name="normal['.$tid.'][id]" value="'.$tid.'" />
<input type="hidden" name="normal['.$tid.'][hasImage]" value="'.$hasImage.'" />
<input class="preview_displayorder" type="hidden" name="normal['.$tid.'][displayorder]" value="" />
<textarea class="pt" name="normal['.$tid.'][title]" onClick="clickNormalEditor(this);" onblur="blurNormalTextarea(this)">'.$subject.'</textarea>
';
} else {
$html = '
<div class="tips">'.cplang('qqgroup_preview_tips_normal').'</div>
';
}
return $html;
}
function getMiniportalThreads() {
$threads = array();
$threads = C::t('common_setting')->fetch('cloud_qqgroup_miniportal_threads', true);
$normalThreads = array();
if($threads['normal']) {
$i = 1;
foreach($threads['normal'] as $tid => $normal) {
$normal['displayorder'] = $i;
$normalThreads[$i] = $normal;
$i++;
}
}
$threads['normalThreads'] = $normalThreads;
return $threads;
}
function getResultThreads() {
global $_G;
$info = $_GET['info'];
$info = dunserialize(base64_decode(trim($info)));
if(!$info) {
return false;
}
$threads = $info['threads'];
if (!$threads) {
return false;
}
$errorIds = $info['errorIds'];
if (!$errorIds) {
$errorIds = array();
}
if($threads['topic']['id'] && in_array($threads['topic']['id'], $errorIds)) {
$threads['topic'] = array();
}
$normalThreads = array();
if($threads['normal']) {
$i = 1;
foreach($threads['normal'] as $tid => $normal) {
if (in_array($tid, $errorIds)) {
unset($theads['normal'][$tid]);
continue;
} else {
$normal['displayorder'] = $i;
$normalThreads[$i] = $normal;
$i++;
}
}
}
$threads['normalThreads'] = $normalThreads;
return $threads;
}
function showSearchDiv() {
echo '<div class="qqqun_bblist">';
showSearchForm();
showSearchResultDiv();
echo '</div>';
}
function showSearchResultDiv() {
echo '
<table class="qqqun_tl">
<tr>
<th>'.cplang('qqgroup_search_threadslist').'</th>
<th width="100">'.cplang('qqgroup_search_inforum').'</th>
<th>'.cplang('qqgroup_search_operation').'</th>
</tr>';
echo '<tbody id="search_result"><tr><td colspan="3">'.cplang('qqgroup_search_loading').'</td></tr></tbody>';
echo '</table>';
}
function showMiniportalPreview() {
global $_G;
if($_GET['sentResult'] && $_GET['info']) {
$mcThreads = getResultThreads();
} else {
$mcThreads = getMiniportalThreads();
}
echo '<div id="qqqun">';
echo '
<div class="qqqun_title">
<em><a href="#">'.cplang('qqgroup_preview_more').'</a></em>
'.cplang('qqgroup_preview_shortname').'
</div>
';
showformheader('cloud&operation=qqgroup&anchor=block', '', 'previewForm');
$topic = $mcThreads['topic'];
$topicId = intval($topic['id']);
echo '<div class="qqqun_top" id="topicDiv">'.showTopicTemplate($topicId, $topic['title'], $topic['extra']['content'], $topic['extra']['image'], $topic['extra']['image'] ? $_G['setting']['attachurl'].$topic['extra']['image'] : '').'</div>';
echo '<div class="qqqun_list">';
echo '
<div class="qqqun_editor">
<ul>
<li class="e_up"><a href="javascript:;" onClick="moveNormalThread(true);" title="'.cplang('qqgroup_ctrl_up').'">up</a></li>
<li class="e_down"><a href="javascript:;" onClick="moveNormalThread(false);" title="'.cplang('qqgroup_ctrl_down').'">down</a></li>
<li class="e_edit"><a href="javascript:;" onClick="editNormalThread();" title="'.cplang('qqgroup_ctrl_edit').'">edit</a></li>
<li class="e_del"><a href="javascript:;" onClick="removeNormalThread();" title="'.cplang('qqgroup_ctrl_remove').'">del</a></li>
</ul>
</div>
';
echo '<ul class="qqqun_xl">';
$normalIds = array();
$normalThreads = $mcThreads['normalThreads'];
for($i=1; $i<=5; $i++) {
$normal = $normalThreads[$i];
if($normal) {
$normalIds[] = $normalThreads[$i]['id'];
echo '<li id="normal_thread_'.$i.'" displayorder="'.$i.'">'.showNormalTemplateLi($normalThreads[$i]['id'], $normalThreads[$i]['title'], $normalThreads[$i]['extra']['hasImage']).'</li>';
} else {
if($i == 1) {
echo '<li id="normal_thread_'.$i.'" displayorder="'.$i.'"><div class="tips">'.cplang('qqgroup_preview_tips_normal').'</div></li>';
} else {
echo '<li id="normal_thread_'.$i.'" displayorder="'.$i.'" style="display:none;"></li>';
}
}
}
echo '</ul>';
echo '</div>';
echo '
<div class="qqqun_btn">
<button id="previewFormSubmit" type="submit" class="btn"><span>'.cplang('qqgroup_preview_button').'</span></button>
</div>
';
echo '<input type="hidden" name="setMiniportalThreadsSubmit" value="1" />';
showformfooter();
echo '</div>';
echo '
<script type="text/javascript">
var selectedTopicId = '.$topicId.';
var selectedNormalIds = ['.implode(', ', $normalIds).'];
</script>
';
}
function processMiniportalTopicThread($topic) {
if(empty($topic)) {
return false;
}
$id = intval($topic['id']);
if(empty($id)) {
return false;
}
$title = trim($topic['title']);
if(!$title) {
return false;
}
$displayorder = 0;
$content = trim($topic['extra']['content']);
if(!$content) {
return false;
}
$extra = array('image' => strip_tags(trim($topic['extra']['image'])), 'content' => $content);
$newTopic = array('id' => $id, 'idtype' => 1, 'miniportaltype' => 2, 'title' => $title, 'extra' => $extra, 'displayorder' => $displayorder, 'dateline' => TIMESTAMP);
return $newTopic;
}
function processMiniportalNormalThreads($normal) {
$newNormal = array();
$i = 0;
foreach($normal as $thread) {
$thread = processlNormalThread($thread);
if($thread && $thread['id']) {
$i ++;
$thread['displayorder'] = $i;
$newNormal[$thread['id']] = $thread;
}
}
return $newNormal;
}
function processlNormalThread($thread) {
if(empty($thread)) {
return false;
}
$id = intval($thread['id']);
if(empty($id)) {
return false;
}
$title = trim($thread['title']);
if(!$title) {
return false;
}
$displayorder = intval($thread['displayorder']);
$hasImage = $thread['extra']['hasImage'] ? true : false;
$extra = array('hasImage' => $hasImage);
$newThread = array('id' => $id, 'idtype' => 1, 'miniportaltype' => 1, 'title' => $title, 'extra' => $extra, 'displayorder' => $displayorder, 'dateline' => TIMESTAMP);
return $newThread;
}
function storeMiniportalThreads($threads) {
return C::t('common_setting')->update('cloud_qqgroup_miniportal_threads', $threads);
}
function sentMiniportalThreadsRemote($topic, $normal, $gIds = array()) {
global $_G;
if($topic['extra']['image'] && $topic['extra']['image'] = @file_get_contents($_G['setting']['attachdir'].'./'.$topic['extra']['image'])) {
$topic['extra']['image'] = base64_encode($topic['extra']['image']);
}
$groupClient = Cloud::loadClass('Service_Client_QQGroup');
try {
$res = $groupClient->miniportal($topic, $normal, $gIds);
} catch (Cloud_Service_Client_RestfulException $e) {
if ($e->getCode() == 1) {
$res = array('status' => false, 'msg' => cplang('qqgroup_msg_unknown_dns'));
} else {
$res = array('status' => false, 'msg' => cplang('qqgroup_msg_remote_exception', array('errmsg' => $e->getMessage(), 'errno' => $e->getCode())));
}
}
if(!is_array($res)) {
$res = array('status' => false, 'msg' => cplang('qqgroup_msg_remote_error'));
}
return $res;
}
function showUploadImageForm($tid) {
ajaxshowheader();
echo '
<ul class="fwin-menu">
<li class="a"><a>'.cplang('qqgroup_ctrl_upload_image').'</a></li>
<li style="float:right;"><a class="flbc" href="javascript:;" onClick="hideWindow(\'uploadImgWin\')" title="'.cplang('qqgroup_ctrl_close').'">'.cplang('qqgroup_ctrl_close').'</a></li>
</ul>
';
echo '<div class="c">';
showformheader('cloud&operation=qqgroup&anchor=block&op=uploadImage', 'enctype="multipart/form-data"', 'uploadImage');
echo '<input type="hidden" name="tid" value="'.$tid.'" />';
echo '<input type="hidden" name="uploadImageSubmit" value="1" />';
echo '
<table class="tb">
<tr style="display:none;">
<td id="uploadImageResult" colspan="2" align="center"></td>
</tr>
<tr>
<td width="70" align="right">'.cplang('qqgroup_ctrl_choose_image').'</td>
<td align="left"><input type="file" name="imageFile" size="30" /></td>
</tr>
<tr>
<td align="right"></td>
<td align="left">
<p>'.cplang('qqgroup_ctrl_choose_image_tips').'</p>
</td>
</tr>
</table>
';
showformfooter();
echo '</div>';
echo '
<div class="o pns"><button class="pn pnc" onClick="ajaxUploadQQGroupImage();"><span>'.cplang('qqgroup_ctrl_upload_image').'</span></button></div>
';
ajaxshowfooter();
}
function QQGroupUpload($tid) {
global $_G;
$imageDir = 'qqgroup';
$imageName = 'miniportal_tid_'.$tid.'.jpg';
$fieldName = 'imageFile';
$_FILES[$fieldName]['name'] = addslashes(urldecode($_FILES[$fieldName]['name']));
$_FILES[$fieldName]['type'] = addslashes(urldecode($_FILES[$fieldName]['type']));
$upload = new discuz_upload();
$upload->init($_FILES[$fieldName]);
$attach = & $upload->attach;
if (!$attach['isimage']) {
return false;
}
if ($attach['size'] > 5000000) {
return false;
}
$upload->save();
list($imgwidth, $imgheight) = $attach['imageinfo'];
if($imgwidth < 75 || $imgheight < 75) {
@unlink($attach['target']);
return false;
}
require_once libfile('class/image');
$image = new image;
$image->param['thumbquality'] = 100;
$thumbTarget = $imageDir.'/'.$imageName;
@unlink($_G['setting']['attachdir'].'./'.$thumbTarget);
$thumb = $image->Thumb($attach['target'], $thumbTarget, 75, 75) ? 1 : 0;
if(!$thumb && !@copy($attach['target'], $_G['setting']['attachdir'].'./'.$thumbTarget)) {
@unlink($attach['target']);
return false;
}
@unlink($attach['target']);
$res = $attach;
$res['thumbTarget'] = $thumbTarget;
return $res;
}
function showQQGroupScript() {
global $adminscript;
echo
<<<EOF
<script type="text/javascript" src="static/image/admincp/cloud/jquery.min.js"></script>
<script type="text/javascript">
var adminscript = '$adminscript';
</script>
<script type="text/javascript" src="static/image/admincp/cloud/qqgroup.js?v=20121101"></script>
EOF;
}
function showQQGroupCSS() {
echo
<<<EOF
<link href="static/image/admincp/cloud/qqgroup.css" rel="stylesheet" type="text/css" />
EOF;
}
function QQGroupMessage($message, $url = '', $info = '') {
if($url) {
$url = addcslashes(substr($url, 0, 5) == 'http:' ? $url : ADMINSCRIPT . '?' . $url, '\'');
}
if($info) {
$info = base64_encode(serialize($info));
}
$message = "<h4 class=\"infotitle3\">$message</h4>";
$message .= '<form id="qqgroup_message_form" action="'.$url.'" method="POST" style="display:none;">';
$message .= '<textarea name="info" style="display:none;">'.$info.'</textarea>';
$message .= '</form>';
$message .= '<p class="marginbot"><a href="javascript:;" onClick="$(\'qqgroup_message_form\').submit();" class="lightlink">'.cplang('message_return').'</a></p>';
echo '<h3>'.cplang('discuz_message').'</h3><div class="infobox">'.$message.'</div>';
exit();
}

View File

@ -1,61 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_search.php 33387 2013-06-05 03:21:26Z jeffjzhang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$op = $_GET['op'];
$anchor = isset($_GET['anchor']) ? $_GET['anchor'] : 'setting';
$current = array($anchor => 1);
if (!$_G['inajax']) {
cpheader();
shownav('navcloud', 'menu_cloud_search');
showsubmenu('menu_cloud_search', array(
array(array('menu' => 'search_menu_settingsearch', 'submenu' => array(
array('search_menu_basicsetting', 'cloud&operation=search&anchor=setting', $current['setting']),
array('search_menu_modulesetting', 'cloud&operation=search&anchor=modulesetting', $current['modulesetting']),
)), in_array($anchor, array('setting', 'modulesetting'))),
array('Iwenwen', 'cloud&operation=search&anchor=iwenwen', $current['iwenwen']),
));
}
if($anchor == 'modulesetting') {
if(!submitcheck('modulesetting')) {
showtips('search_modulesetting_tips');
showformheader('cloud&operation=search&anchor=modulesetting');
showtableheader();
showsetting('search_setting_allow_thread_related', 'cloudsearch_relatedthread', isset($_G['setting']['my_search_data']['allow_thread_related']) ? $_G['setting']['my_search_data']['allow_thread_related'] : 1, 'radio');
showsetting('search_setting_allow_recommend_related', 'cloudsearch_relatedrecommend', isset($_G['setting']['my_search_data']['allow_recommend_related']) ? $_G['setting']['my_search_data']['allow_recommend_related'] : 1, 'radio');
showsubmit('modulesetting');
showtablefooter();
showformfooter();
} else {
$_G['setting']['my_search_data']['allow_thread_related'] = dintval($_POST['cloudsearch_relatedthread']);
$_G['setting']['my_search_data']['allow_recommend_related'] = dintval($_POST['cloudsearch_relatedrecommend']);
$updateData = array(
'my_search_data' => $_G['setting']['my_search_data']
);
C::t('common_setting')->update_batch($updateData);
updatecache('setting');
cpmsg('setting_update_succeed', 'action=cloud&operation=search&anchor='.$anchor, 'succeed');
}
} elseif(preg_match('/^[a-z|A-Z|\d]+$/', $anchor)) {
$utilService = Cloud::loadClass('Service_Util');
$cp_version = $_G['setting']['my_search_data']['cp_version'];
$params = array('link_url' => ADMINSCRIPT . '?action=cloud&operation=search', 'cp_version' => $cp_version, 'anchor' => $anchor, 'm_setting' => 1);
$signUrl = $utilService->generateSiteSignUrl($params);
$utilService->redirect($cloudDomain . '/search/' . $anchor . '/?' . $signUrl);
}

View File

@ -1,471 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_security.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$op = trim($_GET['op']);
$_GET['anchor'] = in_array($_GET['anchor'], array('index', 'setting', 'thread', 'post', 'member', 'reportOperation', 'reopen')) ? $_GET['anchor'] : 'index';
$pt = in_array($_GET['anchor'], array('thread', 'post')) ? $_GET['anchor'] : 'thread';
$current = array($_GET['anchor'] => 1);
$operateresultmap = array(
'0' => 1,
'-1' => 0,
'-5' => 0
);
$securitynav = array();
$securitynav[0] = array('security_index', 'cloud&operation=security&anchor=index', $current['index']);
$securitynav[1] = array('security_blanklist', 'cloud&operation=security&anchor=setting', $current['setting']);
$securitynav[2] = array('security_thread_list', 'cloud&operation=security&anchor=thread', $current['thread']);
$securitynav[3] = array('security_post_list', 'cloud&operation=security&anchor=post', $current['post']);
$securitynav[4] = array('security_member_list', 'cloud&operation=security&anchor=member', $current['member']);
if (!$_G['inajax']) {
cpheader();
shownav('safe', 'menu_cloud_security', 'security_'.$_GET['anchor'].'_list');
showsubmenu('menu_cloud_security', $securitynav);
}
$tpp = !empty($_GET['tpp']) ? $_GET['tpp'] : '20';
$start_limit = ($page - 1) * $tpp;
require_once libfile('function/discuzcode');
require_once libfile('function/core');
$datas = $data = $eviluids = $evilPids = $evilTids = $members = $thread = $post = '';
if($_GET['anchor'] != 'reopen') {
$apps = $appService->getCloudApps();
if(empty($apps) || empty($apps[$operation]) || $apps[$operation]['status'] == 'close') {
cpmsg('security_reopen', '', 'succeed');
}
}
if ($_GET['anchor'] == 'index') {
$utilService = Cloud::loadClass('Service_Util');
$signUrl = $utilService->generateSiteSignUrl(array('v' => 2));
$utilService->redirect($cloudDomain.'/security/stats/list/?' . $signUrl);
} elseif ($_GET['anchor'] == 'setting') {
if (!submitcheck('settingsubmit')) {
loadcache('setting');
$evilthreads = C::t('common_setting')->fetch('cloud_security_stats_thread');
$evilposts = C::t('common_setting')->fetch('cloud_security_stats_post');
$evilmembers = C::t('common_setting')->fetch('cloud_security_stats_member');
$usergroupswhitelist = $_G['setting']['security_usergroups_white_list'];
$groupselect = array();
foreach (C::t('common_usergroup')->fetch_all_not(array('6','7')) as $group) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
$groupselect[$group['type']] .= "<option value=\"$group[groupid]\" ".(in_array($group['groupid'], $usergroupswhitelist) ? 'selected' : '').">$group[grouptitle]</option>\n";
}
$groupselect = '<optgroup label="'.$lang['usergroups_member'].'">'.$groupselect['member'].'</optgroup>'.
($groupselect['special'] ? '<optgroup label="'.$lang['usergroups_special'].'">'.$groupselect['special'].'</optgroup>' : '').
($groupselect['specialadmin'] ? '<optgroup label="'.$lang['usergroups_specialadmin'].'">'.$groupselect['specialadmin'].'</optgroup>' : '').
'<optgroup label="'.$lang['usergroups_system'].'">'.$groupselect['system'].'</optgroup>';
$forumswhitelist = $_G['setting']['security_forums_white_list'];
require_once libfile('function/forumlist');
loadcache('forums');
$forumselect = str_replace('%', '%%', forumselect(FALSE, 0, $forumswhitelist, TRUE));
showformheader('cloud&operation=security&anchor=setting');
showtableheader('security_white_list_setting', '', '', 2);
showsetting('security_usergroup_white_list', '', '', '<select name="groupid[]" multiple="multiple" size="10">'.$groupselect.'</select>');
showsetting('security_forum_white_list', '', '', '<select name="fid[]" multiple="multiple" size="10">'.$forumselect.'</select>');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
} else {
$usergroups = $_POST['groupid'];
$forums = $_POST['fid'];
$updateData = array(
'security_usergroups_white_list' => serialize($usergroups),
'security_forums_white_list' => serialize($forums)
);
C::t('common_setting')->update_batch($updateData);
updatecache('setting');
cpmsg('setting_update_succeed', 'action=cloud&operation=security&anchor='.$_GET['anchor'], 'succeed');
}
} elseif ($_GET['anchor'] == 'thread') {
$count = C::t('#security#security_evilpost')->count_by_type('1');
$multipage = multi($count, $tpp, $page, ADMINSCRIPT.'?action=cloud&operation=security&anchor=thread');
list($datas, $evilTids) = getEvilList('thread', $start_limit, $tpp);
echo "<p><a href='###' onclick='$(\"recyclebinform\").submit();'>{$lang['security_recyclebin_thread']}</a></p>";
showformheader('recyclebin&operation=search', 'style="display: none;"', 'recyclebinform');
showhiddenfields(array('security' => 1, 'searchsubmit' => 1));
showformfooter();
showtableheader('', '', 'id = "security_list"');
showsubtitle(array('security_subject', 'security_forum', 'security_author', 'security_thread_status'));
foreach($datas as $key => $value) {
if(!$value['message']) {
$subjectstyle = 'class = "threadopt"';
} else {
$subjectstyle = '';
}
$value['message'] = convertMessage($value);
$modthreadkey = modauthkey($value['tid']);
$viewlink = $value['message'] ? '<a href="forum.php?mod=redirect&goto=findpost&ptid='.$value['tid'].'&pid='.$value['pid'].'&modthreadkey='.$modthreadkey.'" target="_blank" title="'.$lang['security_view_thread'].'">'.$value['subject'].'</a>' : '';
$thread = array(convertSubjectandIP($value, $viewlink), getNamebyFid($value['fid']), convertAuthorAndDate($value), //convertIdtoStr($value['eviltype']),
convertIdtoStr($value['invisible'], 'adminoperate'));
showtagheader('tbody', '', true, 'hover');
showtablerow($subjectstyle, array('width = "400px"'), $thread);
$value['message'] ? showtablerow('class="threadopt" style = "display: none;" id = "mod_'.$value['tid'].'_row_'.$key.'"', 'colspan = "6"', $value['message']) : '';
showtagfooter('tbody');
}
if ($multipage) {
showtablerow('', 'colspan = "6"', $multipage);
}
showtablefooter();
} elseif($_GET['anchor'] == 'post') {
$count = C::t('#security#security_evilpost')->count_by_type('0');
$multipage = multi($count, $tpp, $page, ADMINSCRIPT.'?action=cloud&operation=security&anchor=post');
list($datas, $evilPids) = getEvilList('post', $start_limit, $tpp);
echo "<p><a href='###' onclick='$(\"recyclebinpostform\").submit();'>{$lang['security_recyclebin_post']}</a></p>";
showformheader('recyclebinpost&operation=search', 'style="display: none;"', 'recyclebinpostform');
showhiddenfields(array('security' => 1, 'searchsubmit' => 1));
showformfooter();
showtableheader('', '', 'id = "security_list"');
showsubtitle(array('security_subject', 'security_forum', 'security_author', 'security_post_status'));
foreach($datas as $key => $value) {
if(!$value['message']) {
$subjectstyle = 'class = "threadopt"';
} else {
$subjectstyle = '';
}
$value['message'] = convertMessage($value);
$modthreadkey = modauthkey($value['tid']);
$thread = array(convertSubjectandIP($value), getNamebyFid($value['fid']), convertAuthorAndDate($value), //convertIdtoStr($value['eviltype']),
convertIdtoStr($value['invisible'], 'adminoperate'), $viewlink);
showtagheader('tbody', '', true, 'hover');
showtablerow($subjectstyle,array('width = "400px"'), $thread);
$value['message'] ? showtablerow('class="threadopt" style="display: none;" id = "mod_'.$value['tid'].'_row_'.$key.'"', 'colspan = "6"', $value['message']) : '';
showtagfooter('tbody');
}
if ($multipage) {
showtablerow('', 'colspan = "6"', $multipage);
}
showtablefooter();
} elseif($_GET['anchor'] == 'member') {
showtips('security_member_tips');
if($_GET['ignoreuid']) {
C::t('#security#security_eviluser')->delete(intval($_GET['ignoreuid']));
}
$memberperpage = $_G['setting']['memberperpage'];
$start_limit = ($page - 1) * $memberperpage;
$count = C::t('#security#security_eviluser')->count();
$multipage = multi($count, $memberperpage, $page, ADMINSCRIPT.'?action=cloud&operation=security&anchor=member');
list($datas, $eviluids) = getEvilList('user', $start_limit, $memberperpage);
showformheader('recyclebinpost&operation=search', 'style="display: none;"', 'recyclebinmember');
showhiddenfields(array('security' => 1, 'searchsubmit' => 1));
echo "\n<input type=\"hidden\" name=\"authors\" id=\"authors\" value=\"\">";
showformfooter();
showformheader("members&operation=clean", '');
showtableheader();
showsubtitle(array('','security_members_name', 'members_edit_info', 'security_thread_member_group', 'security_createtime', '', '', ''));
foreach($datas as $value) {
if ($value['username']) {
$username = '<a href="home.php?mod=space&uid='.$value['uid'].'&do=profile" target="_blank" title="'.$title.'">'.$value['username'].'</a>';
} else {
$username = $lang['security_userdeleted']."(uid:{$value['uid']})";
}
$del = '<input type="checkbox" name="uidarray[]" value="'.$value['uid'].'"'.($value['adminid'] == 1 ? 'disabled' : '').' class="checkbox">';
$optmember = '<a href="'.ADMINSCRIPT.'?action=members&operation=ban&uid='.$value['uid'].'" target="_blank">'.cplang('members_ban').'</a>';
$ignorethis = '<a href="'.ADMINSCRIPT.'?action=cloud&operation=security&anchor=member&ignoreuid='.$value['uid'].'&page='.$page.'">'.cplang('security_member_ignore_this').'</a>';
$createtime = date('Y-m-d', $value['createtime']);
$evilthreads = '<a href="javascript:void(0);" onclick="searchevilpost_member(\''.$value['username'].'\', 1);return false;">'.cplang('security_thread_list').'</a>';
$evilposts = '<a href="javascript:void(0);" onclick="searchevilpost_member(\''.$value['username'].'\', 2);return false;">'.cplang('security_post_list').'</a>';
$member = array($del, $username, convertMemberInfo($value), $value['grouptitle'], $createtime, $evilthreads, $evilposts, $optmember, $ignorethis);
showtablerow('',array('class="td25"'),$member);
}
showsubmit('deletesubmit', cplang('delete'), '', '', $multipage);
showtablefooter();
showformfooter();
} elseif($_GET['anchor'] == 'reopen') {
Cloud::loadFile('Service_Client_Cloud');
$Cloud_Service_Client_Cloud = new Cloud_Service_Client_Cloud;
$return = $Cloud_Service_Client_Cloud->appOpenWithRegister('security');
if($return['errCode']) {
cpmsg($return['errMessage'], 'action=cloud&operation=security&anchor=index', 'error');
} else {
dheader('location: '.ADMINSCRIPT.'?action=cloud&operation=security&anchor=index');
}
}
echo "
<script type='text/javascript'>
function searchevilpost_member(username, type) {
$('recyclebinmember').action= '".ADMINSCRIPT."?'+(type == 1 ? 'action=recyclebin&operation=search' : 'action=recyclebinpost&operation=search');
$('authors').value=username;
$('recyclebinmember').submit();
return false;
}
</script>";
$jsScript = <<<EOF
<script type='text/javascript'>
function toggle_mod(id) {
if($(id).style.display == 'none') {
$(id).style.display = '';
} else {
$(id).style.display = 'none';
}
return false;
}
function security_foldall() {
var trs = $('security_list').getElementsByTagName('TR');
for(var i in trs) {
if(trs[i].id && trs[i].id.match(/mod_(\d+)_row_(\d+)/) != null) {
trs[i].style.display = "none";
}
}
}
function security_exfoldall() {
var trs = $('security_list').getElementsByTagName('TR');
for(var i in trs) {
if(trs[i].id && trs[i].id.match(/mod_(\d+)_row_(\d+)/) != null) {
trs[i].style.display = "";
}
}
}
</script>
EOF;
echo $jsScript;
function convertIdtoStr($id, $type = 'security_type', $subtype = 'thread') {
global $lang;
if ($type == 'security_type') {
$id = min(6, $id);
$result = $lang['security_type_'.$id];
} elseif($type == 'checkreported') {
$result = $id ? $lang['security_isreported_yes'] : $lang['security_isreported_no'];
} elseif($type == 'adminoperate') {
if ($id === null) {
return $lang['security_opreateresult_2'];
}
if (in_array($subtype, array('thread', 'post'))) {
global $operateresultmap;
$result = $lang['security_opreateresult_'.$operateresultmap[$id]];
} elseif ($subtype == 'member') {
global $nooperategroup;
if (in_array($id, $nooperategroup)) {
$result = $lang['security_opreateresult_0'];
} else {
$result = $lang['security_opreateresult_1'];
}
}
}
return $result;
}
function convertMemberInfo($value) {
global $lang;
$result = '';
if ($value['username']) {
$result = $lang['members_edit_regdate'] . ': ' . dgmdate($value['regdate']) . '<br/>';
$result .= $lang['members_edit_regip'] . ': ' . $value['regip'] . ' ' . convertip($value['regip']) . '<br/>';
$result .= 'Email: ' . $value['email'];
} else {
$result = '<p style="margin:14px 0;">' . $lang['security_userdeleted'] . '</p>';
}
return $result;
}
function convertOperate($id = 0) {
$ids = array('1' => 'delete',
'2' => 'restore');
if (!$ids[$id]) {
return false;
}
return $ids[$id];
}
function getEvilList($type, $start, $ppp) {
$datas = $data = array();
$evilids = array();
if ($type == 'member') {
$type = 'user';
}
if ($type == 'user') {
$query = C::t('#security#security_eviluser')->fetch_range($start, $ppp);
$idtype = 'uid';
} elseif($type == 'thread') {
$query = C::t('#security#security_evilpost')->fetch_range_by_type('1', $start, $ppp);
$idtype = 'pid';
} elseif($type == 'post') {
$query = C::t('#security#security_evilpost')->fetch_range_by_type('0', $start, $ppp);
$idtype = 'pid';
}
foreach ($query as $data) {
$datas[$data[$idtype]] = $data;
$evilids[] = $data[$idtype];
if ($data['tid']) {
$evilTids[] = $data['tid'];
$threadPid[$data['tid']][] = $data['pid'];
}
}
if (is_array($evilTids)) {
$evilTids = array_unique($evilTids);
}
if (!$evilids) {
return false;
}
if ($type == 'user') {
$usergroups = array();
foreach (C::t('common_usergroup')->range() as $group) {
$usergroups[$group['groupid']] = $group['grouptitle'];
}
$regips = C::t('common_member_status')->fetch_all($evilids);
$query = C::t('common_member')->fetch_all($evilids);
foreach ($query as $key => $user) {
if(!empty($user) && !in_array($user['groupid'], array(4,5,6))) {
$query[$key]['regip'] = $regips[$key]['regip'];
}
}
if(count($evilids) != count($query)) {
$deleviluids = array();
foreach($evilids as $key => $eviluid) {
if(empty($query[$eviluid])) {
$deleviluids[] = $eviluid;
unset($evilids[$key]);
}
}
C::t('#security#security_eviluser')->delete($deleviluids);
}
} elseif($type == 'thread' || $type == 'post') {
$query = C::t('forum_thread')->fetch_all_by_tid($evilTids);
}
foreach ($query as $data) {
if ($type == 'thread' || $type == 'post') {
foreach($threadPid[$data['tid']] as $pid) {
$isFirst = ($type == 'thread') ? 1 : 0;
$postData = C::t('forum_post')->fetch($data['posttableid'], $pid);
if ($postData['pid']) {
$datas[$postData['pid']] = array_merge($datas[$postData['pid']], $postData);
if ($type == 'post') {
$datas[$postData['pid']]['subject'] = $data['subject'];
}
}
}
} else {
$data['grouptitle'] = $usergroups[$data['groupid']];
$datas[$data[$idtype]] = array_merge($datas[$data[$idtype]], $data);
}
}
return array($datas, $evilids);
}
function getNamebyFid($fid) {
global $_G;
if (!$fid) {
return false;
}
$forumInfo = C::t('forum_forum')->fetch_all_name_by_fid($fid);
$name = $forumInfo[$fid]['name'];
$name = "<a href='forum.php?mod=forumdisplay&fid=$fid' target='_blank'>".$name."</a>";
return $name;
}
function convertSubjectandIP($value, $viewlink = '') {
global $lang;
if ($viewlink) {
$result = '<h3>'.$viewlink.'</h3>';
} else {
$result = '<h3><a title="'.$lang['security_clicktotoggle'].'" href="javascript:;" onclick="return toggle_mod(\'mod_'.$value['tid'].'_row_'.$value['pid'].'\');" target="_blank">'.$value['subject'].'</a></h3>';
}
$result .= '<p>'.$value['useip'].' '.convertip($value['useip']).' ( pid : '.$value['pid'].' ) </p>';
if (!$value['message']) {
return $lang['security_postdeleted']."(tid:{$value['tid']} pid:{$value['pid']})";
}
return $result;
}
function convertMessage($value) {
global $lang;
if (!$value['message']) {
return false;
}
$value['message'] = discuzcode($value['message'], 0, 0, sprintf('%00b', $value['htmlon']), 1, 1, 1, 0);
$value['message'] = '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:100px; word-break: break-all;">'.$value['message'].'</div>';
return $value['message'];
}
function convertAuthorAndDate($value) {
if (!$value['author']) {
return false;
}
$result = "<a href='home.php?mod=space&uid={$value[authorid]}&do=profile' target='_blank'>" . $value['author'] . "</a>" . '<p>';
$result .= dgmdate($value['dateline']);
$result .= '</a>';
return $result;
}
function getDataToReport($operateType, $datatosync, $datas) {
$datatoreport = array();
foreach($datatosync as $operateresult => $ids) {
foreach($ids as $id) {
if(!$datas[$id]['isreported']) {
$data = array(
'operateType' => $operateType,
'operate' => $operateresult == 'validate' ? 'restore' : 'delete',
'operateId' => $id,
'uid' => $datas[$id]['authorid'] ? $datas[$id]['authorid'] : $datas[$id]['uid'],
);
$data['openId'] = getOpenId($data['uid']);
$data['clientIp'] = $datas[$id]['userip'] ? $datas[$id]['userip'] : getMemberIp($data['uid']);
if ($operateType != 'member') {
$data['tid'] = $datas[$id]['tid'];
$data['pid'] = $datas[$id]['pid'];
$data['fid'] = $datas[$id]['fid'];
}
array_push($datatoreport, $data);
}
}
}
return $datatoreport;
}

View File

@ -1,123 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_siteinfo.php 33808 2013-08-15 11:22:45Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(submitcheck('syncsubmit')) {
if($cloudstatus != 'cloud') {
cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'", 3000);</script>');
}
try {
$cloudClient = & Cloud::loadClass('Service_Client_Cloud', array(true));
if ($_G['setting']['my_app_status']) {
$manyouClient = Cloud::loadClass('Service_Client_Manyou');
$manyouClient->sync();
}
$res = $cloudClient->sync();
} catch (Cloud_Service_Client_RestfulException $e) {
cpmsg('cloud_sync_failure', '', 'error', array('errorCode' => $e->getCode(), 'errorMessage' => $e->getMessage()));
}
cpmsg('cloud_sync_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'", 3000);</script>');
} elseif(submitcheck('resetsubmit')) {
if (!isfounder()) {
cpmsg('action_noaccess', '', 'error');
}
if($cloudstatus != 'cloud') {
cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=plugins\'", 3000);</script>');
}
try {
$cloudClient = Cloud::loadClass('Service_Client_Cloud');
$res = $cloudClient->resetKey();
} catch (Cloud_Service_Client_RestfulException $e) {
cpmsg($e->getMessage(), '', 'error');
}
$sId = intval($res['sId']);
$sKey = trim($res['sKey']);
C::t('common_setting')->update_batch(array('my_siteid' => $sId, 'my_sitekey' => $sKey));
updatecache('setting');
cpmsg('cloud_reset_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor\'", 3000);</script>');
} elseif(submitcheck('ipsubmit')) {
$_POST['cloud_api_ip'] = trim($_POST['cloud_api_ip']);
$_POST['my_ip'] = trim($_POST['my_ip']);
$_POST['connect_api_ip'] = trim($_POST['connect_api_ip']);
if($_G['setting']['cloud_api_ip'] != $_POST['cloud_api_ip'] || $_G['setting']['my_ip'] != $_POST['my_ip'] || $_G['setting']['connect_api_ip'] != $_POST['connect_api_ip']) {
C::t('common_setting')->update_batch(array('cloud_api_ip' => $_POST['cloud_api_ip'], 'my_ip' => $_POST['my_ip'], 'connect_api_ip' => $_POST['connect_api_ip']));
updatecache('setting');
}
$locationUrl = ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor';
cpmsg('cloud_ipsetting_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.$locationUrl.'\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.$locationUrl.'\'", 3000);</script>');
} elseif ($_GET['anchor'] == 'cloud_ip') {
ajaxshowheader();
echo '
<h3 class="flb" id="fctrl_showblock" style="cursor: move;">
<em id="return_showblock" fwin="showblock">'.$lang['cloud_api_ip_btn'].'</em>
<span><a title="'.$lang['close'].'" onclick="hideWindow(\'cloudApiIpWin\');return false;" class="flbc" href="javascript:;">'.$lang['close'].'</a></span>
</h3>
';
echo '<div style="margin: 0 10px; width: 700px;">';
showformheader('cloud');
showhiddenfields(array('operation' => $operation));
if($_GET['callback']) {
showhiddenfields(array('callback' => $_GET['callback']));
}
showtableheader();
showsetting('cloud_api_ip', 'cloud_api_ip', $_G['setting']['cloud_api_ip'], 'text');
showsetting('cloud_manyou_ip', 'my_ip', $_G['setting']['my_ip'], 'text');
showsetting('cloud_connect_api_ip', 'connect_api_ip', $_G['setting']['connect_api_ip'], 'text');
showsubmit('ipsubmit');
showtablefooter();
showformfooter();
echo '</div>';
ajaxshowfooter();
} else {
shownav('navcloud', 'menu_cloud_siteinfo');
showsubmenu('menu_cloud_siteinfo');
showtips('cloud_siteinfo_tips');
echo '<script type="text/javascript">var disallowfloat = "";</script>';
showformheader('cloud');
showhiddenfields(array('operation' => $operation));
showtableheader();
showtitle('menu_cloud_siteinfo');
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_name').'</strong>',
$_G['setting']['bbname']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_url').'</strong>',
$_G['siteurl']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_id').'</strong>',
$_G['setting']['my_siteid']
));
$resetSubmitButton = isfounder() ? '<input type="submit" class="btn" id="submit_resetsubmit" name="resetsubmit" value="'.$lang['cloud_resetkey'].'" />&nbsp; ' : '';
showsubmit('syncsubmit', 'cloud_sync', '',$resetSubmitButton.'<input type="button" class="btn" onClick="showWindow(\'cloudApiIpWin\', \''.ADMINSCRIPT.'?action=cloud&operation=siteinfo&anchor=cloud_ip\'); return false;" value="'.$lang['cloud_api_ip_btn'].'" />');
showtablefooter();
showformfooter();
}

View File

@ -1,20 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_smilies.php 25510 2011-11-14 02:22:26Z yexinhao $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$_GET['anchor'] = in_array($_GET['anchor'], array('base')) ? $_GET['anchor'] : 'base';
shownav('navcloud', 'cloud_smilies');
showsubmenu('cloud_smilies');
showtips('cloud_smilies_tips');

View File

@ -1,85 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_stats.php 29282 2012-03-31 09:26:14Z zhouxiaobo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$_GET['anchor'] = in_array($_GET['anchor'], array('base', 'summary')) ? $_GET['anchor'] : 'summary';
$current = array($_GET['anchor'] => 1);
$statsnav = array();
$statsnav[0] = array('cloud_stats_summary', 'cloud&operation=stats&anchor=summary', $current['summary']);
$statsnav[1] = array('cloud_stats_setting', 'cloud&operation=stats&anchor=base', $current['base']);
if(!$_G['inajax']) {
cpheader();
}
if($_GET['anchor'] == 'base') {
if(!submitcheck('settingsubmit')) {
shownav('navcloud', 'cloud_stats');
showsubmenu('cloud_stats', $statsnav);
showtips('cloud_stats_tips');
showformheader('cloud&edit=yes');
showhiddenfields(array('operation' => $operation));
showtableheader();
$myicon = C::t('common_setting')->fetch('cloud_staticon');
if ($myicon === false || in_array($myicon, array(5, 6, 7, 8))) {
$myicon = 1;
}
$checkicon[$myicon] = ' checked';
$icons = '<table style="margin-bottom: 3px; margin-top:3px; width:350px;"><tr><td>';
for($i=1;$i<=11;$i++) {
if ($i < 5) {
$icons .= '<input class="radio" type="radio" id="stat_icon_'.$i.'" name="settingnew[cloud_staticon]" value="'.$i.'"'.$checkicon[$i].' /><label for="stat_icon_'.$i.'">&nbsp;<img src="http://tcss.qq.com/icon/toss_1'.$i.'.gif" /></label>&nbsp;&nbsp;';
if ($i % 4 == 0) {
$icons .= '</td></tr><tr><td>';
}
} elseif ($i < 9) {
continue;
} elseif ($i < 11) {
$icons .= '<input class="radio" type="radio" id="stat_icon_'.$i.'" name="settingnew[cloud_staticon]" value="'.$i.'"'.$checkicon[$i].' /><label for="stat_icon_'.$i.'">&nbsp;'.$lang['cloud_stats_icon_word'.$i].'</label>&nbsp;&nbsp;';
} else {
$icons .= '</td></tr><tr><td><input class="radio" type="radio" id="stat_icon_'.$i.'" name="settingnew[cloud_staticon]" value="0"'.$checkicon[0].' /><label for="stat_icon_'.$i.'">&nbsp;'.$lang['cloud_stats_icon_none'].'</label></td></tr>';
}
}
$icons .= '</table>';
showsetting('cloud_stats_icon_set', '', '', $icons);
showsubmit('settingsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$settingnew = $_GET['settingnew'];
$settingnew['cloud_staticon'] = intval($settingnew['cloud_staticon']);
C::t('common_setting')->update('cloud_staticon', $settingnew['cloud_staticon']);
updatecache('setting');
cpmsg('setting_update_succeed', 'action=cloud&operation='.$operation.(!empty($_GET['anchor']) ? '&anchor='.$_GET['anchor'] : ''), 'succeed');
}
} elseif($_GET['anchor'] == 'summary') {
shownav('navcloud', 'cloud_stats');
showsubmenu('cloud_stats', $statsnav);
$statsDomain = 'http://ta.qq.com';
$utilService = Cloud::loadClass('Service_Util');
$signUrl = $utilService->generateSiteSignUrl(array('v' => 2));
$utilService->redirect($statsDomain . '/statsSummary/?' . $signUrl);
}

View File

@ -1,20 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_smilies.php 25510 2011-11-14 02:22:26Z yexinhao $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$_GET['anchor'] = in_array($_GET['anchor'], array('base')) ? $_GET['anchor'] : 'base';
shownav('navcloud', 'cloud_storage');
showsubmenu('cloud_storage');
showtips('cloud_storage_tips');

View File

@ -1,22 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_union.php 29273 2012-03-31 07:58:50Z yexinhao $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(!$_G['inajax']) {
cpheader();
shownav('navcloud', 'cloud_stats');
}
$unionDomain = 'http://union.discuz.qq.com';
$utilService = Cloud::loadClass('Service_Util');
$signUrl = $utilService->generateSiteSignUrl();
$utilService->redirect($unionDomain . '/site/application/?' . $signUrl);

View File

@ -1 +0,0 @@

View File

@ -1 +0,0 @@

View File

@ -1,48 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: menu_cloud.php 25593 2011-11-15 10:56:04Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$appService = Cloud::loadClass('Service_App');
$topmenu['cloud'] = '';
try {
$cloudStatus = $appService->checkCloudStatus();
} catch (Cloud_Service_AppException $e) {
}
if ($cloudStatus == 'cloud') {
$menu['cloud'] = array(
array('menu_cloud_applist', 'cloud_applist'),
array('menu_cloud_siteinfo', 'cloud_siteinfo'),
array('menu_cloud_doctor', 'cloud_doctor')
);
$apps = $appService->getCloudApps();
if(is_array($apps) && $apps) {
foreach($apps as $app) {
if($app['status'] != 'close') {
array_push($menu['cloud'], array("menu_cloud_{$app['name']}", "cloud_{$app['name']}"));
}
}
}
} else {
if ($cloudStatus == 'upgrade') {
$menuitem = 'menu_cloud_upgrade';
} else {
$menuitem = 'menu_cloud_open';
}
$menu['cloud'] = array(
array($menuitem, 'cloud_open'),
array('menu_cloud_doctor', 'cloud_doctor')
);
}

View File

@ -1,68 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: class_cloud.php 34000 2013-09-17 08:52:48Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud {
static private $_loaded = array();
public static function loadClass($className, $params = null) {
if (strpos($className, 'Cloud_') !== 0) {
$className = 'Cloud_' . $className;
}
self::loadFile($className);
$instance = call_user_func_array(array($className, 'getInstance'), (array)$params);
return $instance;
}
public static function loadFile($className) {
$items = explode('_', $className);
if ($items[0] == 'Cloud') {
unset($items[0]);
}
$loadKey = implode('_', $items);
if (isset(self::$_loaded[$loadKey])) {
return true;
}
$file = DISCUZ_ROOT . '/source/plugin/manyou/' . implode('/', $items) . '.php';
if (!is_file($file)) {
throw new Cloud_Exception('Cloud file not exists!', 50001);
}
include $file;
self::$_loaded[$loadKey] = true;
return true;
}
}
class Cloud_Exception extends Exception {
public function __construct($message, $code = 0) {
if ($message instanceof Exception) {
parent::__construct($message->getMessage(), intval($message->getCode()));
} else {
parent::__construct($message, intval($code));
}
}
}
?>

View File

@ -1,132 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: class_cloudregister.php 33799 2013-08-15 02:29:22Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Cloud');
class Cloud_Register extends Cloud_Service_Client_Cloud {
public $appIdentifier;
public $pluginid;
protected $lang;
public function __construct($appIdentifier, $pluginid, $startStep, $debug = false) {
global $_G;
parent::__construct($debug);
$this->appIdentifier = $appIdentifier;
$this->pluginid = $pluginid;
$step = !empty($_GET['step']) ? authcode($_GET['step'], 'DECODE', $_G['config']['security']['authkey']) : $startStep;
$method = 'step_'.$step;
$this->lang = lang('cloud_register');
if(!empty($_GET['skip'])) {
return false;
}
if(method_exists($this, $method)) {
return $this->$method();
} else {
return false;
}
}
private function _step($v) {
global $_G;
return rawurlencode(authcode($v, 'ENCODE', $_G['config']['security']['authkey'], 3600));
}
private function _msg($message, $extra = '') {
if(defined('ADMINSCRIPT')) {
cpmsg($message, '', 'succeed', array(), ($extra ? $extra.'<br />' : '').'<br /><a href="'.ADMINSCRIPT.'?action=plugins">'.$this->lang['back'].'</a>');
} else {
showmessage($message.'<br />'.$extra, $url, $values, array('alert' => 'info'));
}
}
private function step_appOpenFormView() {
global $_G;
$submiturl = $_G['siteurl'].ADMINSCRIPT.'?action=plugins&operation=enable&pluginid='.$this->pluginid.'&formhash='.FORMHASH.'&step='.$this->_step('appOpenWithRegister');
$fromurl = $_G['siteurl'].ADMINSCRIPT.'?action=plugins';
$data = $this->appOpenFormView($this->appIdentifier, $submiturl, $fromurl);
if($data) {
echo $data;
exit;
}
$this->step_appOpenWithRegister();
}
private function step_appOpenWithRegister() {
global $_G;
$return = $this->appOpenWithRegister($this->appIdentifier, $_GET['extra']);
if($return['errCode']) {
if($return['errCode'] == '1000') {
$this->step_bindQQ();
} else {
$this->_msg($return['errMessage']);
}
}
if($return['result']) {
if($return['result']['sId'] && $return['result']['sKey']) {
C::t('common_setting')->update_batch(array('my_siteid' => $return['result']['sId'], 'my_sitekey' => $return['result']['sKey']));
updatecache('setting');
}
if($return['result']['needBindQQ']) {
$this->step_bindQQ();
}
}
$this->step_over();
}
private function step_bindQQ() {
global $_G;
$fromurl = $_G['siteurl'].ADMINSCRIPT.'?frame=no&action=plugins&operation=enable&pluginid='.$this->pluginid.'&formhash='.FORMHASH.'&step='.$this->_step('bindQQBack');
$url = $this->bindQQ($this->appIdentifier, $fromurl, $_GET['extra']);
$script = '<script type="text/javascript">function BindQQ() {var url = \''.$url.'\';var left = (window.screen.width - 700) / 2;var top = (window.screen.height - 460) / 2;var A=window.open(url, \'TencentLogin\', \'left=\'+left+\',top=\'+top+\',width=700,height=460,menubar=0,scrollbars=1,resizable=1,status=1,titlebar=0,toolbar=0,scrollbars=0,location=1\');}</script>';
$this->_msg($this->lang['bindqq'], $script.$this->lang['bindqq_link']);
}
private function step_bindQQBack() {
$stepurl = $_G['siteurl'].ADMINSCRIPT.'?action=plugins&operation=enable&pluginid='.$this->pluginid.'&formhash='.FORMHASH.'&step='.$this->_step('appOpenWithRegister');
if($_GET['extra']) {
$utilService = Cloud::loadClass('Service_Util');
$stepurl .= '&'.$utilService->httpBuildQuery(array('extra' => $_GET['extra']), '', '&');
}
echo '<script type="text/javascript">if(window.opener) {window.opener.location.href=\''.$stepurl.'\';};window.close();</script>';
exit;
}
private function step_over() {
return true;
}
private function step_appCloseReasonsView() {
$submiturl = $_G['siteurl'].ADMINSCRIPT.'?action=plugins&operation=disable&pluginid='.$this->pluginid.'&formhash='.FORMHASH.'&step='.$this->_step('appClose');
$fromurl = $_G['siteurl'].ADMINSCRIPT.'?action=plugins';
$data = $this->appCloseReasonsView($this->appIdentifier, $submiturl, $fromurl);
if($data) {
echo $data;
exit;
}
$this->step_over();
}
private function step_appClose() {
$return = $this->appClose($this->appIdentifier);
if($return['errCode']) {
$this->_msg($return['errMessage']);
}
$this->step_over();
}
}
?>

View File

@ -112,16 +112,6 @@ class helper_notification {
$pkId = C::t('home_notification')->insert($setarr, true);
}
$banType = array('task');
if($_G['setting']['cloud_status'] && !in_array($type, $banType)) {
$noticeService = Cloud::loadClass('Service_Client_Notification');
if($oldnote['id']) {
$noticeService->update($touid, $pkId, $setarr['from_num'], $setarr['dateline'], $note);
} else {
$extra = $type == 'post' ? array('pId' => $notevars['pid']) : array();
$extra['notekey'] = $note;
$noticeService->add($touid, $pkId, $type, $setarr['authorid'], $setarr['author'], $setarr['from_id'], $setarr['from_idtype'], $setarr['note'], $setarr['from_num'], $setarr['dateline'], $extra);
}
}
if(empty($oldnote['new'])) {
C::t('common_member')->increase($touid, array('newprompt' => 1));

View File

@ -39,22 +39,6 @@ class helper_pm {
loaducenter();
$return = uc_pm_send($fromid, $toid, addslashes($subject), addslashes($message), 1, $replypmid, $isusername, $type);
if($return > 0 && $fromid) {
if($_G['setting']['cloud_status']) {
$msgService = Cloud::loadClass('Cloud_Service_Client_Message');
if(is_numeric($toid)) {
$msgService->add($toid, $fromid, $author, $_G['timestamp']);
} else {
$senduids = array();
foreach(C::t('common_member')->fetch_all_by_username(explode(',', $toid)) as $touser) {
$senduids[$touser['uid']] = $touser['uid'];
}
if($senduids) {
$msgService->add($senduids, $fromid, $author, $_G['timestamp']);
}
}
}
foreach(explode(',', $fromid) as $v) {
useractionlog($fromid, 'pmid');
}

View File

@ -1,43 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: optimizer_cloudsecurity.php 33488 2013-06-24 01:48:20Z jeffjzhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class optimizer_cloudsecurity {
public function __construct() {
}
public function check() {
$apps = C::t('common_setting')->fetch('cloud_apps', true);
$security = $apps['security'];
if(!isset($security['status']) || $security['status'] == 'close') {
$return = array('status' => 1, 'type' =>'header', 'lang' => lang('optimizer', 'optimizer_cloudsecurity_need'));
} else {
$securitysetting = C::t('common_setting')->fetch('security_usergroups_white_list');
$securitysafelogin = C::t('common_setting')->fetch('security_safelogin');
if($securitysetting != serialize(array(1, 2, 3)) || $securitysafelogin != 1) {
$return = array('status' => 1, 'type' =>'header', 'lang' => lang('optimizer', 'optimizer_cloudsecurity_setting_need'));
} else {
$return = array('status' => 0, 'type' =>'none', 'lang' => lang('optimizer', 'optimizer_cloudsecurity_no_need'));
}
}
return $return;
}
public function optimizer() {
$adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
dheader('Location: '.$_G['siteurl'].$adminfile.'?action=cloud&operation=applist');
}
}
?>

View File

@ -1,36 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: optimizer_eviluser.php 33867 2013-08-23 06:12:21Z jeffjzhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class optimizer_eviluser {
public function __construct() {
}
public function check() {
$eviluser = C::t('#security#security_eviluser')->fetch_range(0, 1);
if($eviluser) {
$return = array('status' => 1, 'type' =>'header', 'lang' => lang('optimizer', 'optimizer_eviluser_need'));
} else {
$return = array('status' => 0, 'type' =>'none', 'lang' => lang('optimizer', 'optimizer_eviluser_no_need'));
}
return $return;
}
public function optimizer() {
$adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
dheader('Location: '.$_G['siteurl'].$adminfile.'?action=cloud&operation=security&anchor=member');
}
}
?>

View File

@ -1,36 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: optimizer_white_list.php 33867 2013-08-23 06:12:21Z jeffjzhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class optimizer_white_list {
public function __construct() {
}
public function check() {
$white_list = C::t('common_setting')->fetch_all(array('security_usergroups_white_list', 'security_forums_white_list'), true);
if($white_list) {
$return = array('status' => 2, 'type' =>'header', 'lang' => lang('optimizer', 'optimizer_white_list_need'));
} else {
$return = array('status' => 0, 'type' =>'none', 'lang' => lang('optimizer', 'optimizer_white_list_no_need'));
}
return $return;
}
public function optimizer() {
$adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
dheader('Location: '.$_G['siteurl'].$adminfile.'?action=cloud&operation=security&anchor=setting');
}
}
?>

View File

@ -1038,10 +1038,6 @@ function output() {
if(defined('IN_MOBILE')) {
mobileoutput();
}
if(!defined('IN_MOBILE') && !defined('IN_ARCHIVER')) {
$tipsService = Cloud::loadClass('Service_DiscuzTips');
$tipsService->show();
}
$havedomain = implode('', $_G['setting']['domain']['app']);
if($_G['setting']['rewritestatus'] || !empty($havedomain)) {
$content = ob_get_contents();

View File

@ -1000,24 +1000,6 @@ function set_atlist_cookie($uids) {
dsetcookie('atlist', implode(',', $uids).($tmp ? ','.implode(',', $tmp) : ''), 86400 * 360);
}
function cloud_referer_related() {
global $_G;
$my_search_data = $_G['setting']['my_search_data'];
if (viewthread_is_search_referer() && $my_search_data['status']) {
$appService = Cloud::loadClass('Service_App');
if($appService->getCloudAppStatus('search')) {
$_params = array('s_site_gid' => $_G['groupid'],
'response_type' => 'js',
'referer' => $_SERVER['HTTP_REFERER'],
);
$utilService = Cloud::loadClass('Service_Util');
$signUrl = $utilService->generateSiteSignUrl($_params);
$my_search_se_url = 'http://search.discuz.qq.com/api/site/se?' . $signUrl . "";
}
}
return $my_search_se_url;
}
function viewthread_is_search_referer() {
$regex = "((http|https)\:\/\/)?";
$regex .= "([a-z]*.)?(ask.com|yahoo.com|cn.yahoo.com|bing.com|baidu.com|soso.com|google.com|google.cn)(.[a-z]{2,3})?\/";

View File

@ -50,8 +50,7 @@ if($_G['collection']['ratenum']) {
if(!$op || $op == 'related') {
$isteamworkers = in_array($_G['uid'], array_keys($collectionteamworker));
$cloud_apps = (array)unserialize($_G['setting']['cloud_apps']);
$search_status = $cloud_apps['search']['status'] == 'normal' ? TRUE : FALSE;
$search_status = FALSE;
if(!$op && $op != 'related') {
if($_G['collection']['uid'] == $_G['uid']) {

View File

@ -127,10 +127,6 @@ if($view == 'userapp') {
if($newnotify) {
C::t('home_notification')->ignore($_G['uid'], $type, $category, true, true);
if($_G['setting']['cloud_status']) {
$noticeService = Cloud::loadClass('Service_Client_Notification');
$noticeService->setNoticeFlag($_G['uid'], TIMESTAMP);
}
}
helper_notification::update_newprompt($_G['uid'], ($type ? $type : $category));
if($_G['setting']['my_app_status']) {

View File

@ -171,10 +171,6 @@ if($_GET['subop'] == 'view') {
}
$newpmcount = $newpm + $announcepm;
if($_G['member']['newpm']) {
if($newpm && $_G['setting']['cloud_status']) {
$msgService = Cloud::loadClass('Cloud_Service_Client_Message');
$msgService->setMsgFlag($_G['uid'], $_G['timestamp']);
}
C::t('common_member')->update($_G['uid'], array('newpm' => 0));
uc_pm_ignore($_G['uid']);
}

View File

@ -30,10 +30,6 @@ if($_GET['op'] == 'delete') {
C::t('forum_forum')->update_forum_counter($deletecounter['fids'], 0, 0, 0, 0, -1);
}
C::t('home_favorite')->delete($_GET['favorite'], false, $_G['uid']);
if($_G['setting']['cloud_status']) {
$favoriteService = Cloud::loadClass('Service_Client_Favorite');
$favoriteService->remove($_G['uid'], $_GET['favorite'], TIMESTAMP);
}
}
showmessage('favorite_delete_succeed', 'home.php?mod=space&uid='.$_G['uid'].'&do=favorite&view=me&type='.$_GET['type'].'&quickforward=1');
} else {
@ -52,10 +48,6 @@ if($_GET['op'] == 'delete') {
break;
}
C::t('home_favorite')->delete($favid);
if($_G['setting']['cloud_status']) {
$favoriteService = Cloud::loadClass('Service_Client_Favorite');
$favoriteService->remove($_G['uid'], $favid, TIMESTAMP);
}
showmessage('do_success', 'home.php?mod=space&uid='.$_G['uid'].'&do=favorite&view=me&type='.$_GET['type'].'&quickforward=1', array('favid' => $favid, 'id' => $thevalue['id']), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true, 'locationtime' => 3));
}
}
@ -141,10 +133,7 @@ if($_GET['op'] == 'delete') {
'dateline' => TIMESTAMP
);
$favid = C::t('home_favorite')->insert($arr, true);
if($_G['setting']['cloud_status']) {
$favoriteService = Cloud::loadClass('Service_Client_Favorite');
$favoriteService->add($arr['uid'], $favid, $arr['id'], $arr['idtype'], $arr['title'], $arr['description'], TIMESTAMP);
}
switch($type) {
case 'thread':
C::t('forum_thread')->increase($id, array('favtimes'=>1));

View File

@ -28,7 +28,7 @@ if(empty($_POST)) {
showmessage('qqconnect:connect_login_first', $referer);
}
$_G['qc']['connect_is_feed'] = true;
$_G['qc']['connect_is_feed'] = false;
$_G['qc']['connect_app_id'] = $_G['setting']['connectappid'];
$_G['qc']['connect_openid'] = $conopenid;
@ -65,14 +65,8 @@ if(empty($_POST)) {
dsetcookie('client_created', TIMESTAMP, $cookie_expires);
dsetcookie('client_token', 1, $cookie_expires);
if(!$_G['setting']['connect']['oauth2']) {
if (!$conuin || !$conuinsecret || !$conopenid) {
showmessage('qqconnect:connect_get_request_token_failed');
}
} else {
if (!$conuintoken || !$conopenid) {
showmessage('qqconnect:connect_get_request_token_failed');
}
if (!$conuintoken || !$conopenid) {
showmessage('qqconnect:connect_get_request_token_failed');
}
if(C::t('#qqconnect#common_member_connect')->fetch_fields_by_openid($conopenid, 'uid')) {

View File

@ -29,31 +29,10 @@ if($_G['config']['output']['tplrefresh']) {
cleartemplatecache();
}
$plugins = array('qqconnect', 'cloudstat', 'soso_smilies', 'security', 'mobile', 'pcmgr_url_safeguard', 'manyou', 'cloudcaptcha', 'wechat');
$opens = array('mobile', 'pcmgr_url_safeguard', 'security', 'cloudcaptcha');
$plugins = array('mobile', 'wechat');
$opens = array('mobile');
$checkcloses = array('cloudcaptcha');
$cloudapps = array('qqconnect' => 'connect', 'cloudstat' => 'stats', 'soso_smilies' => 'smilies', 'security' => 'security', 'manyou' => 'manyou', 'cloudcaptcha' => 'captcha');
$apps = C::t('common_setting')->fetch('cloud_apps', true);
if (!$apps) {
$apps = array();
}
if (!is_array($apps)) {
$apps = dunserialize($apps);
}
unset($apps[0]);
if($apps) {
foreach($cloudapps as $key => $appname) {
if($apps[$appname]['status'] == 'normal') {
$opens[] = $key;
}
}
}
require_once libfile('function/plugin');
require_once libfile('function/admincp');
@ -105,28 +84,4 @@ foreach($plugins as $pluginid) {
}
}
if(!array_key_exists('security', $apps)) {
Cloud::loadFile('Service_Client_Cloud');
$Cloud_Service_Client_Cloud = new Cloud_Service_Client_Cloud;
$return = $Cloud_Service_Client_Cloud->appOpenWithRegister('security');
if($return['errCode']) {
$plugin = C::t('common_plugin')->fetch_by_identifier('security');
C::t('common_plugin')->update($plugin['pluginid'], array('available' => 0));
}
if($return['result']) {
if($return['result']['sId'] && $return['result']['sKey']) {
C::t('common_setting')->update_batch(array('my_siteid' => $return['result']['sId'], 'my_sitekey' => $return['result']['sKey']));
updatecache('setting');
}
}
}
loadcache('setting', 1);
if(!$_G['setting']['my_siteid']) {
foreach($checkcloses as $pluginid) {
$plugin = C::t('common_plugin')->fetch_by_identifier($pluginid);
C::t('common_plugin')->update($plugin['pluginid'], array('available' => 0));
}
}
?>

View File

@ -1,71 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_manyou.php 33253 2013-05-10 01:29:32Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($_GET['action'] == 'inviteCode') {
$my_register_url = 'http://api.manyou.com/uchome.php';
$response = dfsockopen($my_register_url, 0, 'action=inviteCode&app=search');
showmessage($response, '', array(), array('msgtype' => 3, 'handle' => false));
}elseif($_GET['action'] == 'menu') {
$list = array();
$menu = C::t('common_setting')->fetch('appmenu');
$renew = false;
if($menu) {
$list = unserialize($menu);
}
$today = strtotime(dgmdate(TIMESTAMP, 'Y-m-d'));
if(!isset($list['dateline']) || $list['dateline'] < $today) {
$userApp = Cloud::loadClass('Service_Client_Manyou');
$list = $userApp->getMenuApps();
}
$usedList = array();
if(!empty($_G['cookie']['usedapp']) && $_G['uid']) {
$usedInfo = explode('|', $_G['cookie']['usedapp']);
if($usedInfo[0] == $_G['uid']) {
$appids = explode(',', $usedInfo[1]);
if($appids) {
$usedList = C::t('home_userapp')->fetch_all_by_uid_appid($_G['uid'], $appids);
$usedAppId = array();
foreach($usedList as $key => $app) {
if(isset($list[1][$app['appid']])) {
unset($usedList[$key]);
continue;
}
$usedAppId[$app['appid']] = $app['appid'];
$app['pic'] = 'http://appicon.manyou.com/logos/'.$app['appid'];
$app['url'] = 'userapp.php?mod=app&id='.$app['appid'];
$app['name'] = $app['appname'];
$usedList[$key] = $app;
}
$usedNum = count($usedAppId);
if($usedNum < 6 && isset($list[2]) && $list[2]) {
$addNum = 6 - $usedNum;
foreach($list[2] as $app) {
if(!$addNum) {
break;
}elseif(!isset($usedAppId[$app['appid']])) {
$usedList[] = $app;
$addNum--;
}
}
}
}
}
}
if(empty($usedList) && isset($list[2]) && $list[2]) {
foreach($list[2] as $app) {
if(count($usedList) >= 6) {
break;
}
$usedList[] = $app;
}
}
include template("userapp/userapp_misc");
}

View File

@ -63,62 +63,6 @@ if(!empty($srchfid) && !is_numeric($srchfid)) {
$forumselect = str_replace('<option value="'.$srchfid.'">', '<option value="'.$srchfid.'" selected="selected">', $forumselect);
}
$mySearchData = $_G['setting']['my_search_data'];
if($mySearchData['status'] && !$srchfrom && !$searchid) {
if (!$_G['setting']['my_siteid']) {
dheader('Location: index.php');
}
$appService = Cloud::loadClass('Service_App');
if($appService->getCloudAppStatus('search') && $searchparams) {
$source = 'discuz';
$cloudSource = array('collectionsearch', 'hotsearch');
if(!empty($_GET['srhlocality'])) {
$sourcetype = explode('::', $_GET['srhlocality']);
if($sourcetype[0] == 'forum') {
$source = $sourcetype[1] == 'index' ? 'forum' : ($sourcetype[1] == 'forumdisplay' ? 'forum_forum' : 'forum_thread');
} elseif($sourcetype[0] == 'portal') {
$source = $sourcetype[1] == 'view' ? 'article' : ($sourcetype[1] == 'list' ? 'portal_list': 'portal');
} elseif($sourcetype[0] == 'group') {
$source = $sourcetype[1] == 'viewthread' ? 'group_thread' : ($sourcetype[1] == 'group' ? 'group_forum' : 'group');
} elseif($sourcetype[0] == 'home') {
$source = 'home'.(empty($sourcetype[1]) ? '' : '_'.$sourcetype[1]);
} elseif($sourcetype[0] == 'misc' && $sourcetype[1] == 'ranklist') {
$source = 'toplist';
}
} elseif(in_array($_GET['source'], $cloudSource)) {
$source = $_GET['source'];
}
$params = array();
$params['source'] = $source;
$params['q'] = $keyword;
$params['module'] = 'forum';
if($srhfid) {
$params['fId'] = $srhfid;
}
if($_GET['adv']) {
$params['isAdv'] = 1;
}
if(!empty($_GET['author'])) {
$params['author']=$_GET['author'];
}
if(!empty($_GET['scope'])) {
$params['scope']=$_GET['scope'];
}
if(!empty($_GET['orderField'])) {
$params['orderField']=$_GET['orderField'];
}
$searchparams['params'] = array_merge($searchparams['params'], $params);
$utilService = Cloud::loadClass('Service_Util');
$url = $searchparams['url'] . '?' . $utilService->httpBuildQuery($searchparams['params'], '', '&');
$utilService->redirect($url);
die;
}
}
if(!submitcheck('searchsubmit', 1)) {
if($_GET['adv']) {

View File

@ -1,86 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_my.php 31728 2012-09-25 09:03:42Z zhouxiaobo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
if (!$_G['setting']['my_siteid'] || !$_G['setting']['my_search_status']) {
dheader('Location: index.php');
}
$appService = Cloud::loadClass('Service_App');
if ($appService->getCloudAppStatus('connect')) {
$connectService = Cloud::loadClass('Cloud_Service_Connect');
$connectService->connectMergeMember();
}
$searchHelper = Cloud::loadClass('Cloud_Service_SearchHelper');
$myForums = $searchHelper->getForums();
$myExtGroupIds = array();
$_extGroupIds = explode("\t", $_G['member']['extgroupids']);
foreach($_extGroupIds as $v) {
if ($v) {
$myExtGroupIds[] = $v;
}
}
$myExtGroupIdsStr = implode(',', $myExtGroupIds);
$params = array(
'cuName' => $_G['username'],
'gId' => $_G['groupid'],
'agId' => $_G['adminid'],
'egIds' => $myExtGroupIdsStr,
'fmSign' => substr($myForums['sign'], -4),
);
$groupIds = explode(',', $_G['groupid']);
if ($_G['adminid']) {
$groupIds[] = $_G['adminid'];
}
if ($myExtGroupIds) {
$groupIds = array_merge($groupIds, $myExtGroupIds);
}
$groupIds = array_unique($groupIds);
$userGroups = $searchHelper->getUserGroupPermissions($groupIds);
foreach($groupIds as $k => $v) {
$value = substr($userGroups[$v]['sign'], -4);
if ($value) {
$params['ugSign' . $v] = $value;
}
}
$params['charset'] = $_G['charset'];
if ($_G['member']['conopenid']) {
$params['openid'] = $_G['member']['conopenid'];
}
$extra = array('q', 'fId', 'author', 'scope', 'source', 'module', 'isAdv');
foreach($extra as $v) {
if ($_GET[$v]) {
$params[$v] = $_GET[$v];
}
}
$mySearchData = $_G['setting']['my_search_data'];
if ($mySearchData['domain']) {
$domain = $mySearchData['domain'];
} else {
$domain = 'search.discuz.qq.com';
}
$utilService = Cloud::loadClass('Cloud_Service_Util');
$url = 'http://' . $domain . '/f/discuz?' . $utilService->generateSiteSignUrl($params, true);
dheader('Location: ' . $url);
?>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<item id="Title"><![CDATA[Discuz! Plugin]]></item>
<item id="Data">
<item id="plugin">
<item id="available"><![CDATA[1]]></item>
<item id="adminid"><![CDATA[1]]></item>
<item id="name"><![CDATA[云验证码]]></item>
<item id="identifier"><![CDATA[cloudcaptcha]]></item>
<item id="description"><![CDATA[]]></item>
<item id="datatables"><![CDATA[]]></item>
<item id="directory"><![CDATA[cloudcaptcha/]]></item>
<item id="copyright"><![CDATA[Comsenz Inc.]]></item>
<item id="version"><![CDATA[1.0]]></item>
</item>
<item id="version"><![CDATA[X3.2]]></item>
<item id="language">
<item id="scriptlang">
<item id="cloudcaptcha_name"><![CDATA[云验证码]]></item>
<item id="switch_error"><![CDATA[您需要先开启其他云平台插件,才能使用本插件]]></item>
</item>
</item>
<item id="enablefile"><![CDATA[switch.php]]></item>
</item>
</root>

View File

@ -1,22 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: get.inc.php 33997 2013-09-17 06:46:37Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$data = captcha::get($_GET['refresh'], $_GET['modid']);
preg_match('/verifysession=(\w+);/', $GLOBALS['filesockheader'], $r);
dsetcookie('dcaptchasig', $r[1]);
dheader('Content-Disposition: inline');
dheader('Content-Type: image/pjpeg');
echo $data;
?>

View File

@ -1,58 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: seccode_cloudcaptcha.php 34041 2013-09-24 09:48:15Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class seccode_cloudcaptcha {
var $version = '1.0';
var $name = 'cloudcaptcha_name';
var $description = '';
var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
function check($value, $idhash, $seccheck, $fromjs, $modid) {
global $_G;
if(!$_G['setting']['my_siteid']) {
return false;
}
$sig = $_G['cookie']['dcaptchasig'];
$data = captcha::validate($value, $sig, $fromjs, $modid);
return $data == '{"errCode":0}';
}
function make($idhash, $modid) {
global $_G;
if(!$_G['setting']['my_siteid']) {
return;
}
$rand = random(10);
$src = 'plugin.php?id=cloudcaptcha:get&rand='.$rand.'&modid='.$modid;
$tips = lang('core', 'seccode_image_tips');
echo '<span id="seccode_js'.$idhash.'"></span><script type="text/javascript" src="http://discuz.gtimg.cn/cloud/scripts/captcha.js?version='.CLOUDCAPTCHA_VER.'"></script>'.
'<script type="text/javascript" reload="1">'.
'var refresh = $(\'seccode_'.$idhash.'\').innerHTML ? 1 : 0;'.
'var cloudCaptchaTimer = setInterval(function(){if(typeof cloudCaptcha != "undefined"){'.
'clearInterval(cloudCaptchaTimer);'.
'cloudCaptcha.run("'.$src.'&refresh=" + refresh, "'.$idhash.'", "'.$tips.'");}}, 50);</script>';
}
function image($idhash, $modid) {
global $_G;
if(!$_G['setting']['my_siteid']) {
return;
}
$rand = random(10);
return $_G['siteurl'].'plugin.php?id=cloudcaptcha:get&rand='.$rand.'&modid='.$modid;
}
}
?>

View File

@ -1,16 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: switch.php 33953 2013-09-05 03:17:10Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['my_siteid'] || !$_G['setting']['my_sitekey']) {
cpmsg('cloudcaptcha:switch_error', '', 'error');
}

View File

@ -1,16 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_setting.inc.php 33704 2013-08-06 06:45:48Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
dheader('location: '.ADMINSCRIPT.'?action=cloud&operation=stats&anchor='.$_GET['ac']);
?>

View File

@ -1,314 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloudstat.class.php 33237 2013-05-08 06:16:23Z jeffjzhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_cloudstat {
var $discuzParams = array();
var $extraParams = array();
function common() {
global $_G;
if($_G['inajax']) {
return;
}
$_G['setting']['statcode'] = $this->_makejs() . $_G['setting']['statcode'];
}
function global_cpnav_extra1() {
$js = '<script type="text/javascript">var _speedMark = new Date();</script>';
return $js;
}
function _makejs() {
global $_G;
$dzjs = $this->_makedzjs();
$return = '';
if(!$_G['inajax']) {
$return = '&nbsp;&nbsp;<span id="tcss"></span><script type="text/javascript" src="http://tcss.qq.com/ping.js?v=1'.VERHASH.'" charset="utf-8"></script>';
}
$return .= '<script type="text/javascript" reload="1">pgvMain('.$dzjs.');</script>';
return $return;
}
function _makedzjs() {
global $_G, $mod;
$this->discuzParams['r2'] = $_G['setting']['my_siteid'];
$this->discuzParams['ui'] = $_G['uid'] ? $_G['uid'] : 0;
if($_G['uid'] && ($_G['member']['regdate'] < ($_G['timestamp'] - $_G['timestamp'] % 86400))) {
$this->discuzParams['ty'] = 2;
}
$this->discuzParams['rt'] = $_G['basescript'];
if($mod) {
$this->discuzParams['md'] = $mod;
}
if($_G['fid']) {
$this->discuzParams['fi'] = $_G['fid'];
}
if($_G['tid']) {
$this->discuzParams['ti'] = $_G['tid'];
}
if($_G['page']) {
$this->discuzParams['pn'] = $_G['page'];
} else {
$this->discuzParams['pn'] = 1;
}
$qq = intval(getcookie('stats_qc_reg'));
dsetcookie('stats_qc_reg');
$qq .= $_G['uid']?'1':'0';
$qclogin = intval(getcookie('stats_qc_login'));
if(($_G['uid'] && $_G['member']['conisbind']) || $qclogin == 4) {
$qq .= $qclogin?$qclogin:1;
dsetcookie('stats_qc_login');
} else {
$qq .= '0';
}
$this->discuzParams['qq'] = $qq;
$cloudstatpost = getcookie('cloudstatpost');
dsetcookie('cloudstatpost');
$cloudstatpost = explode('D', $cloudstatpost);
if($cloudstatpost[0] == 'thread') {
$this->discuzParams['nt'] = 1;
$this->discuzParams['ui'] = $cloudstatpost[1];
$this->discuzParams['fi'] = $cloudstatpost[2];
$this->discuzParams['ti'] = $cloudstatpost[3];
$subject = $_G['forum_thread']['subject'];
$charset = $_G['charset'];
if(empty($charset)) {
foreach ($_G['config']['db'] as $key => $cfg) {
if ($cfg['dbcharset']) {
$charset = $cfg['dbcharset'];
break;
}
}
}
if('GBK' != strtoupper($charset) && !empty($charset)) {
$subject = diconv($subject, $charset, 'GBK');
}
$this->extraParams[] = "tn=" . urlencode($subject);
} elseif($cloudstatpost[0] == 'post') {
$this->discuzParams['nt'] = 2;
$this->discuzParams['ui'] = $cloudstatpost[1];
$this->discuzParams['fi'] = $cloudstatpost[2];
$this->discuzParams['ti'] = $cloudstatpost[3];
$this->discuzParams['pi'] = $cloudstatpost[4];
}
$cloudstaticon = isset($_G['setting']['cloud_staticon']) ? intval($_G['setting']['cloud_staticon']) : 1;
if ($cloudstaticon && !$_G['inajax']) {
if ($cloudstaticon > 4 && $cloudstaticon < 9) {
$cloudstaticon = 1;
} elseif ($cloudstaticon < 5) {
$cloudstaticon += 10;
}
$this->discuzParams['logo'] = $cloudstaticon;
}
return $this->_response_format(array(
'discuzParams' => $this->discuzParams,
'extraParams' => implode(';', $this->extraParams)
));
}
function _response_format($result) {
if(function_exists('json_encode')) {
$json = json_encode($result);
} else {
$json = $this->_array2json($result);
}
return $json;
}
function _array2json($array) {
$piece = array();
foreach ($array as $k => $v) {
$piece[] = $k . ':' . $this->_php2json($v);
}
if ($piece) {
$json = '{' . implode(',', $piece) . '}';
} else {
$json = '[]';
}
return $json;
}
function _php2json($value) {
if (is_array($value)) {
return $this->_array2json($value);
}
if (is_string($value)) {
$value = str_replace(array("\n", "\t"), array(), $value);
$value = addslashes($value);
return '"'.$value.'"';
}
if (is_bool($value)) {
return $value ? 'true' : 'false';
}
if (is_null($value)) {
return 'null';
}
return $value;
}
function _post_cloudstat_message($param) {
global $_G;
$param = $param['param'];
if(in_array($param[0], array('post_newthread_succeed', 'post_newthread_mod_succeed'))) {
dsetcookie('cloudstatpost', 'threadD'.$_G['uid'].'D'.$param[2]['fid'].'D'.$param[2]['tid'], 86400);
} elseif(in_array($param[0], array('post_reply_succeed', 'post_reply_mod_succeed'))) {
dsetcookie('cloudstatpost', 'postD'.$_G['uid'].'D'.$param[2]['fid'].'D'.$param[2]['tid'].'D'.$param[2]['pid'], 86400);
}
}
function _viewthread_postbottom_output() {
global $_G;
$cloudstatjs = array();
if($_G['inajax'] && !empty($_GET['viewpid'])) {
$cloudstatjs[] = $this->_makejs();
}
return $cloudstatjs;
}
}
class plugin_cloudstat_forum extends plugin_cloudstat {
function post_cloudstat_message($param) {
return $this->_post_cloudstat_message($param);
}
function viewthread_postbottom_output() {
return $this->_viewthread_postbottom_output();
}
}
class plugin_cloudstat_group extends plugin_cloudstat {
function post_cloudstat_message($param) {
return $this->_post_cloudstat_message($param);
}
function viewthread_postbottom_output() {
return $this->_viewthread_postbottom_output();
}
}
class mobileplugin_cloudstat_forum extends plugin_cloudstat {
function post_cloudstat_message($param) {
return $this->_post_cloudstat_message($param);
}
}
class mobileplugin_cloudstat extends plugin_cloudstat {
function global_footer_mobile() {
return $this->_noscript();
}
function _noscript() {
global $_G;
$this->_makedzjs();
$uri = $_SERVER['REQUEST_URI'];
if ($uri) {
$urlInfo = parse_url($uri);
$this->discuzParams['url'] = $urlInfo['path'];
$this->discuzParams['arg'] = urlencode($urlInfo['query']);
} else {
$this->discuzParams['url'] = '/';
$this->discuzParams['arg'] = '-';
}
$this->discuzParams['tz'] = sprintf('%0d', -($_G['timenow']['offset']));
$siteUrl = parse_url($_G['siteurl']);
$this->discuzParams['dm'] = $siteUrl['host'];
$pvi = getcookie('pvi');
if (!$pvi) {
$pvi = mt_rand(1, 0x7fffffff) % 10000000000;
dsetcookie('pvi', $pvi, 2145888000);
}
$this->discuzParams['pvi'] = $pvi;
$si = getcookie('si');
if (!$si) {
$si = 's' . (mt_rand(1, 0x7fffffff) % 10000000000);
dsetcookie('si', $si);
}
$this->discuzParams['si'] = $si;
$cloudstatpost = getcookie('cloudstatpost');
dsetcookie('cloudstatpost');
$cloudstatpost = explode('D', $cloudstatpost);
if($cloudstatpost[0] == 'thread') {
$this->discuzParams['nt'] = 1;
$this->discuzParams['ui'] = $cloudstatpost[1];
$this->discuzParams['fi'] = $cloudstatpost[2];
$this->discuzParams['ti'] = $cloudstatpost[3];
$subject = $_G['forum_thread']['subject'];
$charset = $_G['charset'];
if(empty($charset)) {
foreach ($_G['config']['db'] as $key => $cfg) {
if ($cfg['dbcharset']) {
$charset = $cfg['dbcharset'];
break;
}
}
}
if('GBK' != strtoupper($charset) && !empty($charset)) {
$subject = diconv($subject, $charset, 'GBK');
}
$this->extraParams[] = "tn=" . urlencode($subject);
} elseif($cloudstatpost[0] == 'post') {
$this->discuzParams['nt'] = 2;
$this->discuzParams['ui'] = $cloudstatpost[1];
$this->discuzParams['fi'] = $cloudstatpost[2];
$this->discuzParams['ti'] = $cloudstatpost[3];
$this->discuzParams['pi'] = $cloudstatpost[4];
}
$ref = $_SERVER['HTTP_REFERER'];
if ($ref) {
$refInfo = parse_url($ref);
$this->discuzParams['rdm'] = $refInfo['host'];
$this->discuzParams['rarg'] = urlencode($refInfo['query']);
$this->discuzParams['rurl'] = $refInfo['path'];
}
$this->extraParams[] = 'mt=0';
$this->discuzParams['rnd'] = mt_rand(1, 0x7fffffff);
$query = '';
foreach ($this->discuzParams as $key => $val) {
$query .= "$key=$val&";
}
$pingd = 'http://pingtcss.qq.com/pingd?' . $query . 'ext=' . implode(';', $this->extraParams);
return '<img src="' . $pingd . '" height="1" width="1" style="float:right" noerror="true" />';
}
}

View File

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<item id="Title"><![CDATA[Discuz! Plugin]]></item>
<item id="Data">
<item id="plugin">
<item id="available"><![CDATA[1]]></item>
<item id="adminid"><![CDATA[1]]></item>
<item id="name"><![CDATA[腾讯分析]]></item>
<item id="identifier"><![CDATA[cloudstat]]></item>
<item id="description"><![CDATA[]]></item>
<item id="datatables"><![CDATA[]]></item>
<item id="directory"><![CDATA[cloudstat/]]></item>
<item id="copyright"><![CDATA[Comsenz Inc.]]></item>
<item id="version"><![CDATA[1.06.1]]></item>
<item id="__modules">
<item id="0">
<item id="name"><![CDATA[cloudstat]]></item>
<item id="param"><![CDATA[]]></item>
<item id="menu"><![CDATA[]]></item>
<item id="url"><![CDATA[]]></item>
<item id="type"><![CDATA[28]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="displayorder"><![CDATA[0]]></item>
<item id="navtitle"><![CDATA[]]></item>
<item id="navicon"><![CDATA[]]></item>
<item id="navsubname"><![CDATA[]]></item>
<item id="navsuburl"><![CDATA[]]></item>
</item>
<item id="1">
<item id="name"><![CDATA[cloudstat]]></item>
<item id="param"><![CDATA[]]></item>
<item id="menu"><![CDATA[]]></item>
<item id="url"><![CDATA[]]></item>
<item id="type"><![CDATA[11]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="displayorder"><![CDATA[0]]></item>
<item id="navtitle"><![CDATA[]]></item>
<item id="navicon"><![CDATA[]]></item>
<item id="navsubname"><![CDATA[]]></item>
<item id="navsuburl"><![CDATA[]]></item>
</item>
<item id="2">
<item id="name"><![CDATA[admincp]]></item>
<item id="param"><![CDATA[ac=summary]]></item>
<item id="menu"><![CDATA[网站概况]]></item>
<item id="url"><![CDATA[]]></item>
<item id="type"><![CDATA[3]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="displayorder"><![CDATA[0]]></item>
<item id="navtitle"><![CDATA[]]></item>
<item id="navicon"><![CDATA[]]></item>
<item id="navsubname"><![CDATA[]]></item>
<item id="navsuburl"><![CDATA[]]></item>
</item>
<item id="3">
<item id="name"><![CDATA[admincp]]></item>
<item id="param"><![CDATA[ac=base]]></item>
<item id="menu"><![CDATA[设置图标]]></item>
<item id="url"><![CDATA[]]></item>
<item id="type"><![CDATA[3]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="displayorder"><![CDATA[1]]></item>
<item id="navtitle"><![CDATA[]]></item>
<item id="navicon"><![CDATA[]]></item>
<item id="navsubname"><![CDATA[]]></item>
<item id="navsuburl"><![CDATA[]]></item>
</item>
</item>
</item>
<item id="version"><![CDATA[X3.2]]></item>
<item id="enablefile"><![CDATA[switch.php]]></item>
<item id="disablefile"><![CDATA[switch.php]]></item>
</item>
</root>

View File

@ -1 +0,0 @@

View File

@ -1,27 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: switch.php 33950 2013-09-05 02:17:27Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$appIdentifier = 'stats';
$pluginid = intval($_GET['pluginid']);
require_once libfile('class/cloudregister');
if($operation == 'enable') {
new Cloud_Register($appIdentifier, $pluginid, 'appOpenFormView');
} elseif($operation == 'disable') {
new Cloud_Register($appIdentifier, $pluginid, 'appCloseReasonsView');
}

View File

@ -1,260 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: App.php 34007 2013-09-18 06:43:17Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_AppException');
class Cloud_Service_App {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
}
public function checkCloudStatus() {
global $_G;
$res = false;
$cloudStatus = $_G['setting']['cloud_status'];
$sId = $_G['setting']['my_siteid'];
$sKey = $_G['setting']['my_sitekey'];
if($sId && $sKey) {
switch($cloudStatus) {
case 1:
$res = 'cloud';
break;
case 2:
$res = 'unconfirmed';
break;
default:
$res = 'upgrade';
}
} elseif(!$cloudStatus && !$sId && !$sKey) {
$res = 'register';
} else {
throw new Cloud_Service_AppException('Cloud status error!', 52101);
}
return $res;
}
public function getCloudApps($cache = true) {
$apps = array();
if($cache) {
global $_G;
$apps = $_G['setting']['cloud_apps'];
} else {
$apps = C::t('common_setting')->fetch('cloud_apps', true);
}
if (!$apps) {
$apps = array();
}
if (!is_array($apps)) {
$apps = dunserialize($apps);
}
unset($apps[0]);
return $apps;
}
public function getCloudAppStatus($appName, $cache = true) {
$res = false;
$apps = $this->getCloudApps($cache);
if ($apps && $apps[$appName]) {
$res = ($apps[$appName]['status'] == 'normal');
}
return $res;
}
public function setCloudAppStatus($appName, $status, $cache = true, $updateCache = true) {
$method = '_' . strtolower($appName) . 'StatusCallback';
if(!method_exists($this, $method)) {
throw new Cloud_Service_AppException('Cloud callback: ' . $method . ' not exists!', 51001);
}
try {
$callbackRes = $this->$method($appName, $status);
} catch (Exception $e) {
throw new Cloud_Service_AppException($e);
}
if (!$callbackRes) {
throw new Cloud_Service_AppException('Cloud callback: ' . $method . ' error!', 51003);
}
$apps = $this->getCloudApps($cache);
$app = array('name' => $appName, 'status' => $status);
$apps[$appName] = $app;
C::t('common_setting')->update('cloud_apps', $apps);
if ($updateCache) {
require_once libfile('function/cache');
updatecache(array('plugin', 'setting', 'styles'));
cleartemplatecache();
}
return true;
}
private function _manyouStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
return C::t('common_setting')->update('my_app_status', $available);
}
private function _connectStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
$setting = C::t('common_setting')->fetch('connect', true);
if(!$setting) {
$setting = array();
}
$setting['allow'] = $available;
C::t('common_setting')->update('connect', $setting);
$this->setPluginAvailable('qqconnect', $available);
return true;
}
private function _securityStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
$this->setPluginAvailable('security', $available);
return true;
}
private function _storageStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
$this->setPluginAvailable('xf_storage', $available);
return true;
}
private function _statsStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
$this->setPluginAvailable('cloudstat', $available);
return true;
}
private function _searchStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
C::t('common_setting')->update('my_search_status', $available);
if($available) {
Cloud::loadFile('Service_SearchHelper');
Cloud_Service_SearchHelper::allowSearchForum();
}
$this->setPluginAvailable('cloudsearch', $available);
return true;
}
private function _smiliesStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
$this->setPluginAvailable('soso_smilies', $available);
return true;
}
private function _qqgroupStatusCallback($appName, $status) {
$available = 0;
if($status == 'normal') {
$available = 1;
}
$this->setPluginAvailable('qqgroup', $available);
return true;
}
private function _unionStatusCallback($appName, $status) {
return true;
}
private function _mobileOemStatusCallback($appName, $status) {
return true;
}
function setPluginAvailable($identifier, $available) {
$available = intval($available);
$plugin = C::t('common_plugin')->fetch_by_identifier($identifier);
if(!$plugin || !$plugin['pluginid']) {
throw new Cloud_Service_AppException('Cloud plugin: ' . $identifier . ' not exists!', 51108);
}
C::t('common_plugin')->update($plugin['pluginid'], array('available' => $available));
return true;
}
}

View File

@ -1,24 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: AppException.php 28702 2012-03-08 06:43:58Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_AppException extends Exception {
public function __construct($message, $code = 0) {
if ($message instanceof Exception) {
parent::__construct($message->getMessage(), intval($message->getCode()));
} else {
parent::__construct($message, intval($code));
}
}
}

View File

@ -1,237 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Cloud.php 33755 2013-08-10 03:21:02Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_Cloud extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function appOpen() {
return $this->_callMethod('site.appOpen', array('sId' => $this->_sId, 'appIdentifier' => 'search'));
}
public function appOpenWithRegister($appIdentifier, $extra = array()) {
$this->reloadId();
return $this->_callMethod('site.appOpen', array(
'sId' => $this->_sId,
'appIdentifier' => $appIdentifier,
'sName' => $this->siteName,
'sSiteKey' => $this->uniqueId,
'sUrl' => $this->siteUrl,
'sCharset' => $this->charset,
'sTimeZone' => $this->timeZone,
'sUCenterUrl' => $this->UCenterUrl,
'sLanguage' => $this->language,
'sProductType' => $this->productType,
'sProductVersion' => $this->productVersion,
'sTimestamp' => $this->_ts,
'sApiVersion' => $this->apiVersion,
'sSiteUid' => $this->siteUid,
'sProductRelease' => $this->productRelease,
'extra' => $extra,
), false, true);
}
public function appOpenFormView($appIdentifier, $submitUrl, $fromUrl) {
return $this->_callMethod('site.getAppOpenFormView', array(
'sId' => $this->_sId,
'sCharset' => $this->charset,
'appIdentifier' => $appIdentifier,
'submitUrl' => $submitUrl,
'fromUrl' => $fromUrl,
'type' => 'open',
));
}
public function appClose($appIdentifier) {
return $this->_callMethod('site.appClose', array(
'sId' => $this->_sId,
'appIdentifier' => $appIdentifier,
'sSiteUid' => $this->siteUid,
), false, true);
}
public function appCloseReasonsView($appIdentifier, $submitUrl, $fromUrl) {
return $this->_callMethod('site.getAppCloseReasonsView', array(
'sId' => $this->_sId,
'appIdentifier' => $appIdentifier,
'submitUrl' => $submitUrl,
'fromUrl' => $fromUrl,
));
}
private function reloadId() {
global $_G;
loadcache('setting', 1);
$this->_sId = !empty($_G['setting']['my_siteid']) ? $_G['setting']['my_siteid'] : '';
$this->_sKey = !empty($_G['setting']['my_sitekey']) ? $_G['setting']['my_sitekey'] : '';
}
public function bindQQ($appIdentifier, $fromUrl, $extra = array()) {
$this->reloadId();
$utilService = Cloud::loadClass('Service_Util');
$fromUrl .= $extra ? '&'.$utilService->httpBuildQuery(array('extra' => $extra), '', '&') : '';
$params = array(
's_id' => $this->_sId,
'app_identifier' => $appIdentifier,
's_site_uid' => $this->siteUid,
'from_url' => $fromUrl,
'ADTAG' => 'CP.CLOUD.BIND.INDEX',
);
ksort($params);
$str = $utilService->httpBuildQuery($params, '', '&');
$params['sig'] = md5(sprintf('%s|%s|%s', $str, $this->_sKey, $this->_ts));
$params['ts'] = $this->_ts;
return 'http://cp.discuz.qq.com/addon_bind/index?'.$utilService->httpBuildQuery($params, '', '&');
}
public function register() {
return $this->_callMethod('site.register', array(
'sName' => $this->siteName,
'sSiteKey' => $this->uniqueId,
'sUrl' => $this->siteUrl,
'sCharset' => $this->charset,
'sTimeZone' => $this->timeZone,
'sUCenterUrl' => $this->UCenterUrl,
'sLanguage' => $this->language,
'sProductType' => $this->productType,
'sProductVersion' => $this->productVersion,
'sTimestamp' => $this->_ts,
'sApiVersion' => $this->apiVersion,
'sSiteUid' => $this->siteUid,
'sProductRelease' => $this->productRelease,
)
);
}
public function sync() {
return $this->_callMethod('site.sync', array(
'sId' => $this->_sId,
'sName' => $this->siteName,
'sSiteKey' => $this->uniqueId,
'sUrl' => $this->siteUrl,
'sCharset' => $this->charset,
'sTimeZone' => $this->timeZone,
'sUCenterUrl' => $this->UCenterUrl,
'sLanguage' => $this->language,
'sProductType' => $this->productType,
'sProductVersion' => $this->productVersion,
'sTimestamp' => $this->_ts,
'sApiVersion' => $this->apiVersion,
'sSiteUid' => $this->siteUid,
'sProductRelease' => $this->productRelease
)
);
}
public function resetKey() {
return $this->_callMethod('site.resetKey', array('sId' => $this->_sId));
}
public function resume() {
return $this->_callMethod('site.resume', array(
'sUrl' => $this->siteUrl,
'sCharset' => 'UTF-8',
'sProductType' => $this->productType,
'sProductVersion' => $this->productVersion
)
);
}
public function registerCloud($cloudApiIp = '') {
try {
$returnData = $this->register();
} catch (Cloud_Service_Client_RestfulException $e) {
if ($e->getCode() == 1 && $cloudApiIp) {
$this->setCloudApiIp($cloudApiIp);
try {
$returnData = $this->register();
C::t('common_setting')->update('cloud_api_ip', $cloudApiIp);
} catch (Cloud_Service_Client_RestfulException $e) {
throw new Cloud_Service_Client_RestfulException($e);
}
} else {
throw new Cloud_Service_Client_RestfulException($e);
}
}
$sId = intval($returnData['sId']);
$sKey = trim($returnData['sKey']);
if ($sId && $sKey) {
C::t('common_setting')->update_batch(array('my_siteid' => $sId, 'my_sitekey' =>$sKey ,'cloud_status' => '2'));
updatecache('setting');
} else {
throw new Cloud_Service_Client_RestfulException('Error Response.', 2);
}
return true;
}
public function upgradeManyou($cloudApiIp = '') {
try {
$returnData = $this->sync();
} catch (Cloud_Service_Client_RestfulException $e) {
if ($e->getCode() == 1 && $cloudApiIp) {
$this->setCloudApiIp($cloudApiIp);
try {
$returnData = $this->sync();
C::t('common_setting')->update('cloud_api_ip', $cloudApiIp);
} catch (Cloud_Service_Client_RestfulException $e) {
throw new Cloud_Service_Client_RestfulException($e);
}
}
}
return true;
}
}

View File

@ -1,39 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Connect.php 25946 2011-11-28 01:34:23Z zhouxiaobo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_Connect extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function sync($qzoneLikeQQ, $mblogQQ) {
return $this->_callMethod('connect.sync', array('qzoneLikeQQ' => $qzoneLikeQQ, 'mblogFollowQQ' => $mblogQQ));
}
}

View File

@ -1,38 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Disk.php 29011 2012-03-22 08:45:06Z songlixin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_Disk extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function sendTask($cloudData) {
return $this->_callMethod('connect.disk', $cloudData);
}
}

View File

@ -1,65 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Favorite.php 29721 2012-04-26 07:01:08Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_Favorite extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function add($siteUid, $pkId, $id, $idType, $title, $description, $dateline) {
$_params = array(
'openid' => $this->getUserOpenId($siteUid),
'sSiteUid' => $siteUid,
'pkId' => $pkId,
'fromId' => $id,
'fromIdType' => $idType,
'title' => $title,
'description' => $description,
'dateline' => $dateline,
'deviceToken' => $this->getUserDeviceToken($siteUid)
);
return $this->_callMethod('connect.discuz.favorite.add', $_params);
}
public function remove($siteUid, $pkIds, $dateline) {
$_params = array(
'openid' => $this->getUserOpenId($siteUid),
'sSiteUid' => $siteUid,
'pkIds' => $pkIds,
'dateline' => $dateline
);
return $this->_callMethod('connect.discuz.favorite.remove', $_params);
}
protected function _callMethod($method, $args) {
try {
return parent::_callMethod($method, $args);
} catch (Exception $e) {
}
}
}

View File

@ -1,101 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Manyou.php 33053 2013-04-12 10:09:51Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_RestfulException');
class Cloud_Service_Client_Manyou {
private $_myurl = 'http://api.manyou.com/uchome.php';
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
}
public function sync() {
global $_G;
$this->getResponse('siteRefresh');
return true;
}
public function getMenuApps() {
$result = $this->getResponse('getMenuApps');
if($result) {
$result['dateline'] = TIMESTAMP;
C::t('common_setting')->update('appmenu', $result['result']);
}
return $result['errCode'] ? false : $result['result'];
}
private function getResponse($action) {
global $_G;
$response = @dfsockopen($this->_myurl, 0, $this->getGlobalPostString($action), '', false, $_G['setting']['my_ip']);
$result = unserialize($response);
if(!$response) {
throw new Cloud_Service_Client_RestfulException('Empty Response', 111);
} elseif(!$result) {
throw new Cloud_Service_Client_RestfulException('Error Response: ' . $response, 110);
}
if($result['errCode']) {
throw new Cloud_Service_Client_RestfulException($result['errMessage'], $result['errCode']);
}
return $result;
}
private function getGlobalPostString($action) {
global $_G;
$setting = $_G['setting'];
$mySiteId = empty($_G['setting']['my_siteid'])?'':$_G['setting']['my_siteid'];
$siteName = $_G['setting']['bbname'];
$siteUrl = $_G['siteurl'];
$ucUrl = rtrim($_G['setting']['ucenterurl'], '/').'/';
$siteCharset = $_G['charset'];
$siteTimeZone = $_G['setting']['timeoffset'];
$mySiteKey = empty($_G['setting']['my_sitekey']) ? '' : $_G['setting']['my_sitekey'];
$siteKey = C::t('common_setting')->fetch('siteuniqueid');
$siteLanguage = $_G['config']['output']['language'];
$siteVersion = $_G['setting']['version'];
$utilService = Cloud::loadClass('Service_Util');
$myVersion = $utilService->getApiVersion();
$productType = 'DISCUZX';
$siteRealNameEnable = '';
$siteRealAvatarEnable = '';
$siteEnableApp = intval($setting['my_app_status']);
$key = $mySiteId . $siteName . $siteUrl . $ucUrl . $siteCharset . $siteTimeZone . $siteRealNameEnable . $mySiteKey . $siteKey;
$key = md5($key);
$siteTimeZone = urlencode($siteTimeZone);
$siteName = urlencode($siteName);
$register = false;
return sprintf('action=%s&productType=%s&key=%s&mySiteId=%d&siteName=%s&siteUrl=%s&ucUrl=%s&siteCharset=%s&siteTimeZone=%s&siteEnableRealName=%s&siteEnableRealAvatar=%s&siteKey=%s&siteLanguage=%s&siteVersion=%s&myVersion=%s&siteEnableApp=%s&from=cloud', $action, $productType, $key, $mySiteId, $siteName, $siteUrl, $ucUrl, $siteCharset, $siteTimeZone, $siteRealNameEnable, $siteRealAvatarEnable, $siteKey, $siteLanguage, $siteVersion, $myVersion, $siteEnableApp);
}
}

View File

@ -1,79 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Message.php 31448 2012-08-28 09:04:57Z songlixin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_Message extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function add($siteUids, $authorId, $author, $dateline) {
$toUids = array();
if($siteUids) {
$users = C::t('#qqconnect#common_member')->fetch_all((array)$siteUids);
$connectUsers = C::t('#qqconnect#common_member_connect')->fetch_all((array)$siteUids);
$i = 1;
foreach ($users as $uid => $user) {
$conopenid = $connectUsers[$uid]['conopenid'];
if (!$conopenid) {
$conopenid = 'n' . $i ++;
}
$toUids[$conopenid] = $user['uid'];
}
$_params = array(
'openidData' => $toUids,
'authorId' => $authorId,
'author' => $author,
'dateline' => $dateline,
'deviceToken' => $this->getUserDeviceToken($siteUids),
'extra' => array(
'isAdminGroup' => getglobal('adminid'),
'groupId' => getglobal('groupid'),
'groupName' => getglobal('group/grouptitle')
)
);
return $this->_callMethod('connect.discuz.message.add', $_params);
}
return false;
}
public function setMsgFlag($siteUid, $dateline) {
$_params = array(
'openid' => $this->getUserOpenId($siteUid),
'sSiteUid' => $siteUid,
'dateline' => $dateline
);
return $this->_callMethod('connect.discuz.message.read', $_params);
}
protected function _callMethod($method, $args) {
try {
return parent::_callMethod($method, $args);
} catch (Exception $e) {
}
}
}

View File

@ -1,119 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Notification.php 34003 2013-09-18 04:31:14Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_Notification extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function add($siteUid, $pkId, $type, $authorId, $author, $fromId, $fromIdType, $note, $fromNum, $dateline, $extra = array()) {
$_params = array(
'openid' => $this->getUserOpenId($siteUid),
'sSiteUid' => $siteUid,
'pkId' => $pkId,
'type' => $type,
'authorId' => $authorId,
'author' => $author,
'fromId' => $fromId,
'fromIdType' => $fromIdType,
'fromNum' => $fromNum,
'content' => $note,
'dateline' => $dateline,
'deviceToken' => $this->getUserDeviceToken($siteUid),
'extra' => array(
'isAdminGroup' => getglobal('adminid'),
'groupId' => getglobal('groupid'),
'groupName' => getglobal('group/grouptitle')
)
);
if($extra) {
foreach($extra as $key => $value) {
$_params['extra'][$key] = $value;
}
}
return $this->_callMethod('connect.discuz.notification.add', $_params);
}
public function update($siteUid, $pkId, $fromNum, $dateline, $notekey) {
$_params = array(
'openid' => $this->getUserOpenId($siteUid),
'sSiteUid' => $siteUid,
'pkId' => $pkId,
'fromNum' => $fromNum,
'dateline' => $dateline,
'notekey' => $notekey,
);
return $this->_callMethod('connect.discuz.notification.update', $_params);
}
public function setNoticeFlag($siteUid, $dateline) {
$_params = array(
'openid' => $this->getUserOpenId($siteUid),
'sSiteUid' => $siteUid,
'dateline' => $dateline
);
return $this->_callMethod('connect.discuz.notification.read', $_params);
}
public function addSiteMasterUserNotify($siteUids, $subject, $content, $authorId, $author, $fromType, $dateline) {
$toUids = array();
if($siteUids) {
$users = C::t('#qqconnect#common_member')->fetch_all((array)$siteUids);
$connectUsers = C::t('#qqconnect#common_member_connect')->fetch_all((array)$siteUids);
$i = 1;
foreach ($users as $uid => $user) {
$conopenid = $connectUsers[$uid]['conopenid'];
if (!$conopenid) {
$conopenid = 'n' . $i ++;
}
$toUids[$conopenid] = $user['uid'];
}
$_params = array(
'openidData' => $toUids,
'subject' => $subject,
'content' => $content,
'authorId' => $authorId,
'author' => $author,
'fromType' => $fromType == 1 ? 1 : 2,
'dateline' => $dateline,
'deviceToken' => $this->getUserDeviceToken($siteUids)
);
return parent::_callMethod('connect.discuz.notification.addSiteMasterUserNotify', $_params);
}
return false;
}
protected function _callMethod($method, $args) {
try {
return parent::_callMethod($method, $args);
} catch (Exception $e) {
}
}
}

View File

@ -1,67 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: OEM.php 33992 2013-09-17 01:01:52Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_OEM extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function checkApp() {
if(!$this->_sId) {
return array();
}
global $_G;
if($_G['uid']) {
$connectUser = C::t('#qqconnect#common_member_connect')->fetch($_G['uid']);
$openid = $connectUser['conopenid'];
} else {
$openid = '';
}
return $this->_callMethod('oem.checkApp', array('sId' => $this->_sId, 'uId' => $_G['uid'], 'openId' => $openid));
}
public function getDownloadUrl() {
if(!$this->_sId) {
return '';
}
global $_G;
loadcache('mobileoem_data');
if(!$_G['cache']['mobileoem_data']['downloadPath']) {
return '';
}
if($_G['uid']) {
$connectUser = C::t('#qqconnect#common_member_connect')->fetch($_G['uid']);
$openid = $connectUser['conopenid'];
} else {
$openid = '';
}
$utilService = Cloud::loadClass('Service_Util');
return $_G['cache']['mobileoem_data']['downloadPath'].'?'.$utilService->generateSiteSignUrl(array('sId' => $this->_sId, 'uId' => $_G['uid'], 'openId' => $openid));
}
}

View File

@ -1,44 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: QQGroup.php 26146 2011-12-03 08:53:31Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_QQGroup extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
public function miniportal($topic, $normal, $gIds = array()) {
return $this->_callMethod('qqgroup.miniportal', array('topic' => $topic, 'normal' => $normal, 'gIds' => $gIds));
}
public function feed($thread, $gIds = array()) {
return $this->_callMethod('qqgroup.feed', array('thread' => $thread, 'gIds' => $gIds));
}
}

View File

@ -1,290 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Restful.php 33750 2013-08-09 09:56:01Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_RestfulException');
abstract class Cloud_Service_Client_Restful {
protected $_cloudApiIp = '';
protected $_sId = 0;
protected $_sKey = '';
protected $_url = 'http://api.discuz.qq.com/site.php';
protected $_format = 'PHP';
protected $_ts = 0;
protected $_debug = false;
protected $_batchParams = array();
public $errorCode = 0;
public $errorMessage = '';
public $my_status = false;
public $cloud_status = false;
public $siteName = '';
public $uniqueId = '';
public $siteUrl = '';
public $charset = '';
public $timeZone = 0;
public $UCenterUrl = '';
public $language = '';
public $productType = '';
public $productVersion = '';
public $productRelease = '';
public $apiVersion = '';
public $siteUid = 0;
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
$this->_debug = $debug;
$this->_initSiteEnv();
}
protected function _initSiteEnv() {
global $_G;
require_once DISCUZ_ROOT.'./source/discuz_version.php';
$this->my_status = !empty($_G['setting']['my_app_status']) ? $_G['setting']['my_app_status'] : '';
$this->cloud_status = !empty($_G['setting']['cloud_status']) ? $_G['setting']['cloud_status'] : '';
$this->_sId = !empty($_G['setting']['my_siteid']) ? $_G['setting']['my_siteid'] : '';
$this->_sKey = !empty($_G['setting']['my_sitekey']) ? $_G['setting']['my_sitekey'] : '';
$this->_ts = TIMESTAMP;
$this->siteName = !empty($_G['setting']['bbname']) ? $_G['setting']['bbname'] : '';
$this->uniqueId = $_G['setting']['siteuniqueid'];
$this->siteUrl = $_G['siteurl'];
$this->charset = CHARSET;
$this->timeZone = !empty($_G['setting']['timeoffset']) ? $_G['setting']['timeoffset'] : '';
$this->UCenterUrl = !empty($_G['setting']['ucenterurl']) ? $_G['setting']['ucenterurl'] : '';
$this->language = $_G['config']['output']['language'] ? $_G['config']['output']['language'] : 'zh_CN';
$this->productType = 'DISCUZX';
$this->productVersion = defined('DISCUZ_VERSION') ? DISCUZ_VERSION : '';
$this->productRelease = defined('DISCUZ_RELEASE') ? DISCUZ_RELEASE : '';
$utilService = Cloud::loadClass('Service_Util');
$this->apiVersion = $utilService->getApiVersion();
$this->siteUid = $_G['uid'];
if ($_G['setting']['cloud_api_ip']) {
$this->setCloudApiIp($_G['setting']['cloud_api_ip']);
}
}
protected function _callMethod($method, $args, $isBatch = false, $return = false) {
$this->errorCode = 0;
$this->errorMessage = '';
$url = $this->_url;
$avgDomain = explode('.', $method);
switch ($avgDomain[0]) {
case 'site':
$url = 'http://api.discuz.qq.com/site_cloud.php';
break;
case 'qqgroup':
$url = 'http://api.discuz.qq.com/site_qqgroup.php';
break;
case 'connect':
$url = 'http://api.discuz.qq.com/site_connect.php';
break;
case 'security':
$url = 'http://api.discuz.qq.com/site_security.php';
break;
default:
$url = $this->_url;
}
$params = array();
$params['sId'] = $this->_sId;
$params['method'] = $method;
$params['format'] = strtoupper($this->_format);
$params['sig'] = $this->_generateSig($params, $method, $args);
$params['ts'] = $this->_ts;
$postData = $this->_createPostData($params, $args);
if ($isBatch) {
$this->_batchParams[] = $postData;
return true;
} else {
$utilService = Cloud::loadClass('Service_Util');
$postString = $utilService->httpBuildQuery($postData, '', '&');
$result = $this->_postRequest($url, $postString);
if ($this->_debug) {
$this->_message('receive data ' . dhtmlspecialchars($result) . "\n\n");
}
if(!$return) {
return $this->_parseResponse($result, false, $return);
} else {
$response = @dunserialize($result);
if(!is_array($response)) {
return $result;
} else {
return $response;
}
}
}
}
protected function _parseResponse($response, $isBatch = false) {
if (!$response) {
$this->_unknowErrorMessage();
}
$response = @dunserialize($response);
if (!is_array($response)) {
$this->_unknowErrorMessage();
}
if ($response['errCode']) {
$this->errorCode = $response['errCode'];
$this->errorMessage = $response['errMessage'];
throw new Cloud_Service_Client_RestfulException($response['errMessage'], $response['errCode']);
}
if (!isset($response['result']) && !isset($response['batchResult'])) {
$this->_unknowErrorMessage();
}
if ($isBatch) {
return $response['batchResult'];
} else {
return $response['result'];
}
}
public function runBatchMethod() {
if (!$this->_batchParams) {
return false;
}
$postData = array('batchParams' => $this->_batchParams);
$utilService = Cloud::loadClass('Service_Util');
$postString = $utilService->httpBuildQuery($postData, '', '&');
$result = $this->_postRequest($this->_url, $postString);
if ($this->_debug) {
$this->_message('receive data ' . dhtmlspecialchars($result) . "\n\n");
}
return $this->_parseResponse($result, true);
}
protected function _unknowErrorMessage() {
$this->errorCode = 1;
$this->errorMessage = 'An unknown error occurred. May be DNS Error. ';
throw new Cloud_Service_Client_RestfulException($this->errorMessage, $this->errorCode);
}
protected function _generateSig($params, $method, $args) {
$postData = $this->_createPostData($params, $args);
$utilService = Cloud::loadClass('Service_Util');
$postString = $utilService->httpBuildQuery($postData, '', '&');
if ($this->_debug) {
$this->_message('sig string: ' . $postString . '|' . $this->_sKey . '|' . $this->_ts . "\n\n");
}
return md5(sprintf('%s|%s|%s', $postString, $this->_sKey, $this->_ts));
}
protected function _createPostData($params, $args) {
ksort($params);
ksort($args);
$params['args'] = $args;
return $params;
}
protected function _postRequest($url, $data, $ip = '') {
if ($this->_debug) {
$this->_message('post params: ' . $data. "\n\n");
}
$ip = $this->_cloudApiIp;
$result = $this->_fsockopen($url, 0, $data, '', false, $ip, 5);
return $result;
}
function _fsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = false, $ip = '', $timeout = 15, $block = true) {
return dfsockopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block);
}
protected function _message($msg) {
echo $msg;
}
public function setCloudApiIp($ip) {
$this->_cloudApiIp = $ip;
return true;
}
protected function getUserOpenId($uid) {
$openId = '';
try {
$connectInfo = C::t('#qqconnect#common_member_connect')->fetch($uid);
if($connectInfo) {
$openId = $connectInfo['conopenid'];
}
} catch (Exception $e) {}
return $openId;
}
protected function getUserDeviceToken($uids) {
$uids = (array)$uids;
$deviceToken = array();
try {
$query = DB::query('SELECT * FROM '.DB::table('common_devicetoken').' WHERE uid IN('.dimplode($uids).')', array(), true);
while($value = DB::fetch($query)) {
$deviceToken[$value['uid']][] = $value['token'];
}
} catch (Exception $e) {}
return $deviceToken;
}
}

View File

@ -1,24 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: RestfulException.php 28702 2012-03-08 06:43:58Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Client_RestfulException extends Exception {
public function __construct($message, $code = 0) {
if ($message instanceof Exception) {
parent::__construct($message->getMessage(), intval($message->getCode()));
} else {
parent::__construct($message, intval($code));
}
}
}

View File

@ -1,72 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Security.php 29263 2012-03-31 05:45:08Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Client_Restful');
class Cloud_Service_Client_Security extends Cloud_Service_Client_Restful {
protected static $_instance;
public static function getInstance($debug = false) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($debug);
}
return self::$_instance;
}
public function __construct($debug = false) {
return parent::__construct($debug);
}
function securityReportUserRegister($batchData) {
return $this->_callMethod('security.user.register', array('sId' => $this->_sId, 'data' => $batchData));
}
function securityReportUserLogin($batchData) {
return $this->_callMethod('security.user.login', array('sId' => $this->_sId, 'data' => $batchData));
}
function securityReportBanUser($batchData) {
return $this->_callMethod('security.user.ban', array('sId' => $this->_sId, 'data' => $batchData));
}
function securityReportPost($batchData) {
return $this->_callMethod('security.post.handlePost', array('sId' => $this->_sId, 'data' => $batchData));
}
function securityReportDelPost($batchData) {
return $this->_callMethod('security.post.del', array('sId' => $this->_sId, 'data' => $batchData));
}
function securityReportOperation($operateType, $results, $operateTime = TIMESTAMP, $extra = array()) {
$data = array(
'sId' => $this->_sId,
'sSiteUid' => $this->siteUid,
'operateType' => $operateType,
'operateTime' => $operateTime,
'results' => $results,
'extra' => $extra
);
return $this->_callMethod('security.sitemaster.handleOperation', $data);
}
}

View File

@ -1,82 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: DiscuzTips.php 36311 2016-12-19 01:47:34Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_DiscuzTips {
protected static $_instance;
public static function getInstance() {
global $_G;
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function show() {
global $_G;
if($_G['inajax']) {
return '';
}
if($_G['isHTTPS']) {
return '';
}
$clientVersion = '2';
$util = Cloud::loadclass('Service_Util');
include_once DISCUZ_ROOT . '/source/discuz_version.php';
$release = DISCUZ_RELEASE;
$fix = DISCUZ_FIXBUG;
$cloudApi = $util->getApiVersion();
$isfounder = $util->isfounder($_G['member']);
$sId = $_G['setting']['my_siteid'];
$version = $_G['setting']['version'];
$ts = TIMESTAMP;
$sig = '';
$adminId = $_G['adminid'];
$openId = $_G['member']['conopenid'];
$uid = $_G['uid'];
$groupId = $_G['groupid'];
if ($sId) {
$params = array(
's_id' => $sId,
'product_version' => $version,
'product_release' => '',
'fix_bug' => '',
'is_founder' => $isfounder,
's_url' => $_G['siteurl'],
'admin_id' => $adminId,
'open_id' => $openId,
'uid' => $uid,
'group_id' => $groupId,
'last_send_time' => $_COOKIE['dctips'],
);
ksort($params);
$str = $util->httpBuildQuery($params, '', '&');
$sig = md5(sprintf('%s|%s|%s', $str, $_G['setting']['my_sitekey'], $ts));
}
$jsCode = <<<EOF
<div id="discuz_tips" style="display:none;"></div>
<script type="text/javascript">
var tipsinfo = '$sId|$version|$cloudApi|$isfounder|$adminId|$openId|$uid|$groupId|$ts|$sig|$clientVersion';
</script>
<script src="http://discuz.gtimg.cn/cloud/scripts/discuz_tips.js?v=1" type="text/javascript" charset="UTF-8"></script>
EOF;
echo $jsCode;
}
}

View File

@ -1,244 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Disk.php 30715 2012-06-14 03:02:00Z songlixin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Disk {
protected $_util;
protected $_client;
protected $_baseUrl;
protected static $_instance;
public static function getInstance() {
global $_G;
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
global $_G;
$this->_util = Cloud::loadClass('Service_Util');
$this->_client = Cloud::loadClass('Service_Client_Disk');
$this->_baseUrl = $_G['siteurl'] . 'apptest.php?';
}
public function saveTask($attach, $openId) {
global $_G;
if (!$_G['uid']) {
throw new Cloud_Exception('noLogin', '30001');
}
if (!$openId) {
throw new Cloud_Exception('noopenId', '30002');
}
$verifyCode = md5($openId . $attach['aid'] . $_G['timestamp'] . $_G['uid']);
$taskData = array(
'aid' => $attach['aid'],
'uid' => $_G['uid'],
'openId' => $openId,
'filename' => $attach['filename'],
'verifycode' => $verifyCode,
'status' => 0,
'dateline' => $_G['timestamp'],
);
$taskId = C::t('#qqconnect#connect_disktask')->insert($taskData, true);
$downParams = array(
'taskid' => $taskId,
'verifycode' => $verifyCode,
);
$downloadUrl = $this->_baseUrl . $this->_util->generateSiteSignUrl($downParams);
$filePath = self::_getFullPath($attach['attachment']);
if ($attach['filesize'] <= 10000000 && file_exists($filePath)) {
$md5 = md5_file($filePath);
$hash = hash_file('sha1', $filePath);
}
$cloudData = array(
'sId' => $_G['setting']['my_siteid'],
'openId' => $openId,
'batchTasks' => array(
array(
'aId' => $attach['aid'],
'fileName' => $attach['filename'],
'downloadUrl' => $downloadUrl,
'size' => filesize($filePath),
'md5' => $md5,
'hash' => $hash,
),
),
'clientIp' => $_G['clientip'],
);
return $this->_client->sendTask($cloudData);
}
public function getAttachment() {
global $_G;
try {
$taskData = $this->checkTask();
} catch (Exception $e) {
throw new Cloud_Exception($e);
}
$task = $taskData['task'];
$attach = $taskData['attach'];
$taskId = $task['taskid'];
C::t('#qqconnect#connect_disktask')->update($taskId, array(
'status' => 1,
'downloadtime' => $_G['timestamp'],
));
$db = DB::object();
$db->close();
ob_end_clean();
$attach['filename'] = '"'.(strtolower(CHARSET) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['filename']) : $attach['filename']).'"';
dheader('Content-Type: application/octet-stream');
dheader('Content-Length: ' . $attach['filesize']);
dheader('Content-Disposition: attachment; filename='.$attach['filename']);
self::_checkXSendFile($attach['attachment']);
if ($attach['remote']) {
self::_getRemoteFile($attach['attachment']);
} else {
self::_getLocalFile($attach['attachment']);
}
exit;
}
public function checkTask() {
global $_G;
$sId = $_G['setting']['my_siteid'];
$ts = $_GET['ts'];
$taskId = $_GET['taskid'];
$verifyCode = $_GET['verifycode'];
if ($sId != $_GET['s_id']) {
throw new Cloud_Exception('sIdError', '30004');
}
if ($_G['timestamp'] - $ts > 86400) {
throw new Cloud_Exception('downloadTimeOut', '30005');
}
$params = array(
'taskid' => $taskId,
'verifycode' => $verifyCode,
's_id' => $_GET['s_id'],
's_site_uid' => $_GET['s_site_uid'],
);
$sig = $_GET['sig'];
$sKey = $_G['setting']['my_sitekey'];
ksort($params);
$str = $this->_util->httpBuildQuery($params, '', '&');
if ($sig != md5(sprintf('%s|%s|%s', $str, $sKey, $ts))) {
throw new Cloud_Exception('sigError', '30003');
}
$task = C::t('#qqconnect#connect_disktask')->fetch($taskId);
if (!$task) {
throw new Cloud_Exception('noTask', '30006');
}
if ($verifyCode != $task['verifycode']) {
throw new Cloud_Exception('verifyError', '30009');
}
$attach = C::t('forum_attachment_n')->fetch('aid:' . $task['aid'], $task['aid']);
if (!$attach) {
throw new Cloud_Exception('noAttachment', '30007');
}
$return = array(
'task' => $task,
'attach' => $attach,
);
return $return;
}
public function clearDirtyData() {
return C::t('#qqconnect#connect_disktask')->delete_by_status(1);
}
private static function _getFullPath($attachment) {
global $_G;
return $_G['setting']['attachdir'] . 'forum/' . $attachment;
}
private static function _getLocalFile($file) {
$filename = self::_getFullPath($file);
$readmod = getglobal('config/download/readmod');
$readmod = $readmod > 0 && $readmod < 5 ? $readmod : 2;
if($readmod == 1 || $readmod == 3 || $readmod == 4) {
if($fp = @fopen($filename, 'rb')) {
if(function_exists('fpassthru') && ($readmod == 3 || $readmod == 4)) {
@fpassthru($fp);
} else {
echo @fread($fp, filesize($filename));
}
}
@fclose($fp);
} else {
@readfile($filename);
}
@flush(); @ob_flush();
}
private static function _getRemoteFile($file) {
global $_G;
@set_time_limit(0);
if(!@readfile($_G['setting']['ftp']['attachurl'] . 'forum/' . $file)) {
$ftp = ftpcmd('object');
$tmpfile = @tempnam($_G['setting']['attachdir'], '');
if($ftp->ftp_get($tmpfile, 'forum/'.$file, FTP_BINARY)) {
@readfile($tmpfile);
@unlink($tmpfile);
} else {
@unlink($tmpfile);
return FALSE;
}
}
return TRUE;
}
private static function _checkXSendFile($file) {
$filename = self::_getFullPath($file);
$xsendfile = getglobal('config/download/xsendfile');
if(!empty($xsendfile)) {
$type = intval($xsendfile['type']);
$cmd = '';
switch ($type) {
case 1:
$cmd = 'X-Accel-Redirect';
$url = $xsendfile['dir'] . $file;
break;
case 2:
$cmd = $_SERVER['SERVER_SOFTWARE'] <'lighttpd/1.5' ? 'X-LIGHTTPD-send-file' : 'X-Sendfile';
$url = $filename;
break;
case 3:
$cmd = 'X-Sendfile';
$url = $filename;
break;
}
if($cmd) {
dheader("$cmd: $url");
exit();
}
}
}
}

View File

@ -1,227 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Doctor.php 33991 2013-09-16 07:25:00Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Doctor {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
}
public function checkDNS($url) {
if (empty($url)) {
return false;
}
$matches = parse_url($url);
$host = !empty($matches['host']) ? $matches['host'] : $matches['path'];
if (!$host) {
return false;
}
$ip = gethostbyname($host);
if ($ip == $host) {
return false;
} else {
return $ip;
}
}
public function checkDNSResult($type = 1, $setting = array()) {
switch ($type) {
case 1:
$setIP = $setting['cloud_api_ip'] ? cplang('cloud_doctor_setting_ip') . $setting['cloud_api_ip'] : '';
$host = 'api.discuz.qq.com';
break;
case 2:
$setIP = $setting['my_ip'] ? cplang('cloud_doctor_setting_ip') . $setting['my_ip'] : '';
$host = 'api.manyou.com';
break;
case 3:
$setIP = $setting['connect_api_ip'] ? cplang('cloud_doctor_setting_ip') . $setting['connect_api_ip'] : '';
$host = 'openapi.qzone.qq.com';
break;
}
$ip = $this->checkDNS($host);
if ($ip) {
return sprintf(cplang('cloud_doctor_dns_success'), $host, $ip, $setIP, ADMINSCRIPT);
} else {
return sprintf(cplang('cloud_doctor_dns_failure'), $host, $setIP, ADMINSCRIPT);
}
}
public function showPlugins() {
global $_G;
$plugins = array();
$identifiers = array('qqconnect', 'cloudstat', 'soso_smilies', 'security', 'cloudcaptcha', 'manyou');
$plugins = C::t('common_plugin')->fetch_all_by_identifier($identifiers);
if ($plugins && count($plugins) == count($identifiers)) {
$systemPluginStatus = cplang('cloud_doctor_result_success').' '.cplang('available');
} else {
$initsysFormHash = substr(md5(substr($_G['timestamp'], 0, -7).$_G['username'].$_G['uid'].$_G['authkey']), 8, 8);
$systemPluginStatus = cplang('cloud_doctor_result_failure') . cplang('cloud_doctor_system_plugin_status_false', array('formhash' => $initsysFormHash));
}
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_system_plugin_status').'</strong>',
$systemPluginStatus
));
foreach($plugins as $plugin) {
$moduleStatus = cplang('cloud_doctor_plugin_module_error');
$plugin['modules'] = @dunserialize($plugin['modules']);
if(is_array($plugin['modules']) && $plugin['modules']) {
$moduleStatus = '';
}
showtablerow('', array('class="td24"'), array(
'<strong>'.$plugin['name'].'</strong>',
cplang('version').' '.$plugin['version'].' '.$moduleStatus
));
}
}
public function showCloudStatus($cloudStatus) {
$cloudStatus = intval($cloudStatus);
return cplang('cloud_doctor_status_' . $cloudStatus);
}
public function testAPI($type = 1, $ip = '', $setting = array()) {
switch ($type) {
case 1:
$url = 'http://api.discuz.qq.com/site.php';
$result = dfsockopen($url, 0, '', '', false, $ip ? $ip : $setting['cloud_api_ip'], 5);
break;
case 2:
$url = 'http://api.manyou.com/uchome.php';
$result = dfsockopen($url, 0, 'action=siteRefresh', '', false, $ip ? $ip : $setting['my_ip'], 5);
break;
case 3:
$url = 'http://openapi.qzone.qq.com/oauth/qzoneoauth_request_token';
$result = dfsockopen($url, 0, '', '', false, $ip ? $ip : $setting['connect_api_ip'], 5);
if($result) {
return true;
}
break;
}
$result = trim($result);
if(!$result) {
return false;
}
$result = @dunserialize($result);
if(!$result) {
return false;
}
return true;
}
public function showTestJS($type = 1, $ip = '') {
$html = sprintf('<div id="_doctor_apitest_%1$s_%2$s"></div><script type="text/javascript">ajaxget("%3$s?action=cloud&operation=doctor&op=apitest&api_type=%1$s&api_ip=%2$s", "_doctor_apitest_%1$s_%2$s");</script>', $type, $ip, ADMINSCRIPT);
return $html;
}
public function showAPIJS() {
echo '<script type="text/javascript" src="static/image/admincp/cloud/cloud.js"></script> <script type="text/javascript" src="http://cp.discuz.qq.com/cloud/apiIp" charset="utf-8"></script>';
}
public function showSiteTestAPIJS($position = 'doctor') {
global $_G;
require_once DISCUZ_ROOT.'./source/discuz_version.php';
echo '<script type="text/javascript" src="http://cp.discuz.qq.com/cloud/siteTest?s_url=' . urlencode($_G['siteurl']) . '&charset=' . CHARSET . '&productVersion=' . DISCUZ_VERSION . '&position=' . $position . '" charset="utf-8"></script>';
}
public function showCloudDoctorJS($position = 'doctor') {
global $_G;
require_once DISCUZ_ROOT.'./source/discuz_version.php';
$url = $_G['siteurl'];
$charset = CHARSET;
$version = DISCUZ_VERSION;
$rand = rand();
$time = time();
$output = <<<EOF
<script type="text/javascript">
var discuzUrl = '$url';
var discuzCharset = '$charset';
var productVersion = '$version';
var checkPosition = '$position';
var discuzTime = '$time';
</script>
<script type="text/javascript" src="//discuz.gtimg.cn/cloud/scripts/doctor.js?v=$rand" charset="utf-8"></script>
EOF;
echo $output;
}
public function fixGuestGroup($name) {
$connect = C::t('common_setting')->fetch('connect', true);
$guestGroupId = $connect['guest_groupid'];
$group = C::t('common_usergroup')->fetch($guestGroupId);
if ($group) {
return true;
}
$userGroupData = array(
'type' => 'special',
'grouptitle' => $name,
'allowvisit' => 1,
'color' => '',
'stars' => '',
);
$newGroupId = C::t('common_usergroup')->insert($userGroupData, true);
$dataField = array(
'groupid' => $newGroupId,
'allowsearch' => 2,
'readaccess' => 1,
'allowgetattach' => 1,
'allowgetimage' => 1,
);
C::t('common_usergroup_field')->insert($dataField);
$connect['guest_groupid'] = $newGroupId;
C::t('common_setting')->update('connect', serialize($connect));
updatecache('usergroups');
}
public function checkGuestGroup() {
$connect = C::t('common_setting')->fetch('connect', true);
$guestGroupId = $connect['guest_groupid'];
$group = C::t('common_usergroup')->fetch($guestGroupId);
if ($group) {
return true;
}
return false;
}
public function changeQQUrl() {
global $_G;
return 'http://cp.discuz.qq.com/platform/changeQQ?s_id='.$_G['setting']['my_siteid'].'&s_site_uid='.$_G['uid'];
}
}

View File

@ -1,109 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: ManyouHelper.php 25512 2011-11-14 02:31:42Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_ManyouHelper {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
}
public function getMethodCode($module, $method) {
$methods = array(
'Search.getUserGroupPermissions' => 10,
'Search.getUpdatedPosts' => 11,
'Search.removePostLogs' => 12,
'Search.getPosts' => 13,
'Search.getNewPosts' => 14,
'Search.getAllPosts' => 15,
'Search.removePosts' => 16,
'Search.getUpdatedThreads' => 17,
'Search.removeThreadLogs' => 18,
'Search.getThreads' => '1a',
'Search.getNewThreads' => '1b',
'Search.getAllThreads' => '1c',
'Search.getForums' => '1d',
'Search.recycleThreads' => '1e',
'Search.recycleThreads' => '1f',
'Search.setConfig' => '20',
'Search.getConfig' => '21',
'Search.setHotWords' => '22',
'Cloud.getApps' => '30',
'Cloud.setApp' => '31',
'Cloud.openCloud' => '32',
'Cloud.getStatus' => '33',
'Connect.setConfig' => '34',
'Union.addAdvs' => '35',
'Common.setConfig' => '40',
'Common.getNav' => '41',
'Site.getUpdatedUsers' => '42',
'Site.getUpdatedFriends' => '43',
'Site.getAllUsers' => '44',
'Site.getStat' => '45',
'Users.getInfo' => '50',
'Users.getFriendInfo' => '51',
'Users.getExtraInfo' => '52',
'Friends.get' => '53',
'Friends.areFriends' => '54',
'Application.update' => '55',
'Application.remove' => '56',
'Application.setFlag' => '57',
'UserApplication.add' => '58',
'UserApplication.remove' => '5a',
'UserApplication.update' => '5b',
'UserApplication.getInstalled' => '5c',
'UserApplication.get' => '5d',
'Feed.publishTemplatizedAction' => '5e',
'Notifications.send' => '5f',
'Notifications.get' => '60',
'Profile.setMYML' => '61',
'Profile.setActionLink' => '62',
'Request.send' => '63',
'NewsFeed.get' => '64',
'VideoAuth.setAuthStatus' => '65',
'VideoAuth.auth' => '66',
'Users.getFormHash' => '67',
'Credit.get' => '70',
'Credit.update' => '71',
'MiniBlog.post' => '72',
'MiniBlog.get' => '73',
'Photo.createAlbum' => '74',
'Photo.updateAlbum' => '75',
'Photo.removeAlbum' => '76',
'Photo.getAlbums' => '77',
'Photo.upload' => '78',
'Photo.get' => '7a',
'Photo.update' => '7b',
'Photo.remove' => '7c',
'ImbotMsn.setBindStatus' => '7d',
);
return $methods[$module . '.' . $method];
}
}

View File

@ -1,54 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: QQGroup.php 28558 2012-03-05 02:59:09Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_QQGroup {
protected $_util;
protected static $_instance;
public static function getInstance() {
global $_G;
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
$this->_util = Cloud::loadClass('Service_Util');
}
public function iframeUrl($tid, $title, $content) {
global $_G;
if (!$_G['adminid']) {
return false;
}
$url = 'http://qun.discuz.qq.com/feed/push?';
$params = array(
't_id' => $tid,
's_url' => $_G['siteurl'],
'title' => $title,
'content' => $content
);
$signUrl = $this->_util->generateSiteSignUrl($params);
return $url . $signUrl;
}
}

View File

@ -1,862 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: SearchHelper.php 33013 2013-04-08 03:31:33Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_SearchHelper {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
}
public function getTables($table) {
if(!in_array($table, array('post', 'thread'))) {
return false;
}
$infos = getglobal($table.'table_info');
if ($infos) {
$tables = array();
foreach($infos as $id => $row) {
$tables[$id] = $id;
}
} else {
$tables = array(0);
}
return $tables;
}
private function _convertForum($row) {
$result = array();
$map = array(
'fid' => 'fId',
'fup' => 'pId',
'name' => 'fName',
'type' => 'type',
'displayorder' => 'displayOrder',
);
foreach($row as $k => $v) {
if (array_key_exists($k, $map)) {
$result[$map[$k]] = $v;
continue;
}
if ($k == 'status') {
$isGroup = false;
switch ($v) {
case '0' :
$displayStatus = 'hidden';
break;
case '1' :
$displayStatus = 'normal';
break;
case '2' :
$displayStatus = 'some';
break;
case '3' :
$displayStatus = 'normal';
$isGroup = true;
break;
default :
$displayStatus = 'unknown';
}
$result['displayStatus'] = $displayStatus;
$result['isGroup'] = $isGroup;
}
}
$formula = dunserialize($row['formulaperm']);
$result['isFormula'] = $formula[1] ? TRUE : FALSE;
$result['sign'] = md5(serialize($result));
return $result;
}
public function getForums($fIds = array()) {
if($fIds) {
$forums = C::t('forum_forum')->fetch_all_info_by_fids($fIds);
} else {
$forums = C::t('forum_forum')->fetch_all_info_by_fids(0, 0, 0, 0, 0, 0, 1);
}
$result = array();
$result['totalNum'] = count($forums);
foreach($forums as $forum) {
$result['data'][$forum['fid']] = self::_convertForum($forum);
}
if (!$fIds) {
$result['sign'] = md5(serialize($result['data']));
}
return $result;
}
public function getUserGroupPermissions($userGroupIds) {
global $_G;
$userGroups = array();
if ($_G['setting']['verify']['enabled']) {
foreach ($userGroupIds as $groupId) {
if (dintval($groupId) > 65500) {
$vGid = $groupId - 65500;
if ($_G['setting']['verify'][$vGid]['available']) {
$key = array_search($groupId, $userGroupIds);
unset($userGroupIds[$key]);
$userGroups['v' . $vGid] = array();
}
}
}
}
$fields = array(
'groupid' => 'userGroupId',
'grouptitle' => 'userGroupName',
'readaccess' => 'readPermission',
'allowvisit' => 'allowVisit',
'allowsearch' => 'searchLevel',
);
$userGroup= C::t('common_usergroup')->fetch_all((array)$userGroupIds);
$userGroupField = C::t('common_usergroup_field')->fetch_all_fields((array)$userGroupIds, array('readaccess', 'allowsearch'));
foreach(array_merge($userGroup, $userGroupField) as $row) {
foreach($row as $k => $v) {
if (array_key_exists($k, $fields)) {
if ($k == 'allowsearch') {
$userGroups[$row['groupid']]['allowSearchAlbum'] = ($v & 8) ? true : false;
$userGroups[$row['groupid']]['allowSearchBlog'] = ($v & 4) ? true : false;
$userGroups[$row['groupid']]['allowSearchForum'] = ($v & 2) ? true : false;
$userGroups[$row['groupid']]['allowSearchPortal'] = ($v & 1) ? true : false;
$userGroups[$row['groupid']]['allowFulltextSearch'] = ($v & 32) ? true : false;
} else {
$userGroups[$row['groupid']][$fields[$k]] = $v;
}
}
$userGroups[$row['groupid']]['forbidForumIds'] = array();
$userGroups[$row['groupid']]['allowForumIds'] = array();
$userGroups[$row['groupid']]['specifyAllowForumIds'] = array();
}
}
$fIds = array();
foreach(C::t('forum_forum')->fetch_all_by_status('1') as $row) {
$fIds[$row['fid']] = $row['fid'];
}
$fieldForums = array();
foreach(C::t('forum_forumfield')->fetch_all_by_fid($fIds) as $row) {
$fieldForums[$row['fid']] = $row;
}
foreach($fIds as $fId) {
$row = $fieldForums[$fId];
$allowViewGroupIds = array();
if ($row['viewperm']) {
$allowViewGroupIds = explode("\t", $row['viewperm']);
}
foreach($userGroups as $gid => $_v) {
if ($row['password']) {
$userGroups[$gid]['forbidForumIds'][] = $fId;
continue;
}
$perm = dunserialize($row['formulaperm']);
if(is_array($perm)) {
$spviewperm = explode("\t", $row['spviewperm']);
if (in_array($gid, $spviewperm)) {
$userGroups[$gid]['allowForumIds'][] = $fId;
$userGroups[$gid]['specifyAllowForumIds'][] = $fId;
continue;
}
if ($perm[0] || $perm[1] || $perm['users']) {
$userGroups[$gid]['forbidForumIds'][] = $fId;
continue;
}
}
if (!$allowViewGroupIds) {
$userGroups[$gid]['allowForumIds'][] = $fId;
} elseif (!in_array($gid, $allowViewGroupIds)) {
$userGroups[$gid]['forbidForumIds'][] = $fId;
} elseif (in_array($gid, $allowViewGroupIds)) {
$userGroups[$gid]['allowForumIds'][] = $fId;
$userGroups[$gid]['specifyAllowForumIds'][] = $fId;
}
}
}
foreach ($userGroups as $groupId => $v) {
if (substr($groupId, 0, 1) == 'v') {
$verifyKey = 65500 + dintval(substr($groupId, 1));
$v['userGroupId'] = $verifyKey;
$userGroups[$verifyKey] = $v;
unset($userGroups[$groupId]);
}
}
foreach($userGroups as $k => $v) {
ksort($v);
$userGroups[$k]['sign'] = md5(serialize($v));
}
return $userGroups;
}
public function getGuestPerm($gfIds = array()) {
$perm = self::getUserGroupPermissions(array(7));
$guestPerm = $perm[7];
if ($gfIds) {
foreach(C::t('forum_forumfield')->fetch_all_by_fid($gfIds) as $row) {
if ($row['gviewperm'] == 1) {
$guestPerm['allowForumIds'][] = $row['fid'];
} else {
$guestPerm['forbidForumIds'][] = $row['fid'];
}
}
}
return $guestPerm;
}
public function convertThread($row) {
$result = array();
$map = array(
'tid' => 'tId',
'fid' => 'fId',
'authorid' => 'authorId',
'author' => 'authorName',
'special' => 'specialType',
'price' => 'price',
'subject' => 'subject',
'readperm' => 'readPermission',
'lastposter' => 'lastPoster',
'views' => 'viewNum',
'replies' => 'replyNum',
'displayorder' => 'stickLevel',
'highlight' => 'isHighlight',
'digest' => 'digestLevel',
'rate' => 'rate',
'attachment' => 'isAttached',
'moderated' => 'isModerated',
'closed' => 'isClosed',
'supe_pushstatus' => 'supeSitePushStatus',
'recommends' => 'recommendTimes',
'recommend_add' => 'recommendSupportTimes',
'recommend_sub' => 'recommendOpposeTimes',
'heats' => 'heats',
'pid' => 'pId',
'isgroup' => 'isGroup',
'posttableid' => 'postTableId',
'favtimes' => 'favoriteTimes',
'sharetimes'=> 'shareTimes',
'icon' => 'icon',
);
$map2 = array(
'dateline' => 'createdTime',
'lastpost' => 'lastPostedTime',
);
foreach($row as $k => $v) {
if (array_key_exists($k, $map)) {
if ($k == 'special') {
switch($v) {
case 1:
$v = 'poll';
break;
case 2:
$v = 'trade';
break;
case 3:
$v = 'reward';
break;
case 4:
$v = 'activity';
break;
case 5:
$v = 'debate';
break;
case 127:
$v = 'plugin';
break;
default:
$v = 'normal';
}
}
if ($k == 'displayorder') {
if ($v >= 0) {
$result['displayStatus'] = 'normal';
} elseif ($v == -1) {
$result['displayStatus'] = 'recycled';
} elseif ($v == -2) {
$result['displayStatus'] = 'unapproved';
} elseif ($v == -3) {
$result['displayStatus'] = 'ignored';
} elseif ($v == -4) {
$result['displayStatus'] = 'draft';
} else {
$result['displayStatus'] = 'unknown';
}
switch($v) {
case 1:
$v = 'board';
break;
case 2:
$v = 'group';
break;
case 3:
$v = 'global';
break;
case 0:
default:
$v = 'none';
}
}
if (in_array($k, array('highlight', 'moderated', 'closed', 'isgroup'))) {
$v = $v ? true : false;
}
$result[$map[$k]] = $v;
} elseif (array_key_exists($k, $map2)) {
$result[$map2[$k]] = dgmdate($v, 'Y-m-d H:i:s', 8);
}
}
return $result;
}
public function preGetThreads($tableid, $tIds) {
$result = array();
if($tIds) {
foreach(C::t('forum_thread')->fetch_all_by_tid($tIds, 0, 0, $tableid) as $thread) {
$result[$thread['tid']] = self::convertThread($thread);
}
}
return $result;
}
public function getThreadPosts($tIds) {
$result = array();
foreach($tIds as $postTableId => $_tIds) {
foreach(C::t('forum_post')->fetch_all_by_tid($postTableId, $_tIds, true, '', 0, 0, 1) as $post) {
$result[$post['tid']] = self::convertPost($post);
}
}
return $result;
}
public function getThreads($tIds, $isReturnPostId = true) {
global $_G;
$tables = array();
$infos = $_G['setting']['threadtable_info'];
if ($infos) {
foreach($infos as $id => $row) {
$tables[] = $id;
}
} else {
$tables = array('forum_thread');
}
$tableNum = count($tables);
$res = $data = $_tableInfo = array();
for($i = 0; $i < $tableNum; $i++) {
$_threads = self::preGetThreads($tables[$i], $tIds);
if ($_threads) {
if (!$data) {
$data = $_threads;
} else {
$data = $data + $_threads;
}
if (count($data) == count($tIds)) {
break;
}
}
}
if ($isReturnPostId) {
$threadIds = array();
foreach($data as $tId => $thread) {
$postTableId = $thread['postTableId'];
$threadIds[$postTableId][] = $tId;
}
$threadPosts = self::getThreadPosts($threadIds);
foreach($data as $tId => $thread) {
$data[$tId]['pId'] = $threadPosts[$tId]['pId'];
}
}
return $data;
}
public function convertPost($row) {
$result = array();
$map = array('pid' => 'pId',
'tid' => 'tId',
'fid' => 'fId',
'authorid' => 'authorId',
'author' => 'authorName',
'useip' => 'authorIp',
'anonymous' => 'isAnonymous',
'subject' => 'subject',
'message' => 'content',
'invisible' => 'displayStatus',
'htmlon' => 'isHtml',
'attachment' => 'isAttached',
'rate' => 'rate',
'ratetimes' => 'rateTimes',
'dateline' => 'createdTime',
'first' => 'isThread',
);
$map2 = array(
'bbcodeoff' => 'isBbcode',
'smileyoff' => 'isSmiley',
'parseurloff' => 'isParseUrl',
);
foreach($row as $k => $v) {
if (array_key_exists($k, $map)) {
if ($k == 'invisible') {
switch($v) {
case 0:
$v = 'normal';
break;
case -1:
$v = 'recycled';
break;
case -2:
$v = 'unapproved';
break;
case -3:
$v = 'ignored';
break;
case -4:
$v = 'draft';
break;
default:
$v = 'unkonwn';
}
}
if ($k == 'dateline') {
$result[$map[$k]] = dgmdate($v, 'Y-m-d H:i:s', 8);
continue;
}
if (in_array($k, array('htmlon', 'attachment', 'first', 'anonymous'))) {
$v = $v ? true : false;
}
$result[$map[$k]] = $v;
} elseif (array_key_exists($k, $map2)) {
$result[$map2[$k]] = $v ? false : true;
}
}
$result['isWarned'] = $result['isBanned'] = false;
if ($row['status'] & 1) {
$result['isBanned'] = true;
}
if ($row['status'] & 2) {
$result['isWarned'] = true;
}
$attachInfo = array();
if ($result['isAttached']) {
$attachIndex = C::t('forum_attachment')->fetch_all_by_id('pid', $row['pid']);
$attachment = C::t('forum_attachment_n')->fetch_all_by_id('pid:'.$row['pid'], 'pid', $row['pid'], 'aid');
$attachMap = array(
'aid' => 'aId',
'tid' => 'tId',
'pid' => 'pId',
'uid' => 'uId',
'dateline' => 'uploadedTime',
'filename' => 'fileName',
'filesize' => 'fileSize',
'attachment' => 'filePath',
'remote' => 'isRemote',
'description' => 'description',
'readperm' => 'readPerm',
'price' => 'price',
'isimage' => 'isImage',
'width' => 'width',
'thumb' => 'isThumb',
'picid' => 'picId',
);
foreach ($attachment as $k => $v) {
$attachTemp = array();
foreach ($v as $key => $val) {
if ($key == 'dateline') {
$attachTemp[$attachMap[$key]] = dgmdate($val, 'Y-m-d H:i:s', 8);
continue;
}
$attachTemp[$attachMap[$key]] = $val;
}
$attachInfo[$k] = $attachTemp;
$attachInfo[$k]['downloadTimes'] = $attachIndex[$k]['downloads'];
}
}
$result['attachInfo'] = $attachInfo;
return $result;
}
public function convertNav($row) {
$map = array( 'id' => 'id',
'name' => 'name',
'title' => 'title',
'url' => 'url',
'type' => 'provider',
'navtype' => 'navType',
'available' => 'available',
'displayorder' => 'displayOrder',
'target' => 'linkTarget',
'highlight' => 'highlight',
'level' => 'userGroupLevel',
'subtype' => 'subLayout',
'subcols' => 'subColNum',
'subname' => 'subName',
'suburl' => 'subUrl',
);
foreach($row as $k => $v) {
if (array_key_exists($k, $map)) {
if (in_array($k, array('available'))) {
$v = $v > 0 ? true : false;
}
if ($k == 'subtype') {
if ($v == 1) {
$v = 'parallel';
} else {
$v = 'menu';
}
}
if ($k == 'type') {
switch($v) {
case '1':
$v = 'user';
break;
case '0':
default:
$v = 'system';
break;
}
}
if ($k == 'navtype') {
switch($v) {
case 1:
$v = 'footer';
break;
case 2:
$v = 'space';
break;
case 3:
$v = 'my';
break;
case 0:
$v = 'header';
break;
}
}
$result[$map[$k]] = $v;
}
}
return $result;
}
public function convertPoll($row) {
$map = array('polloptionid' => 'id',
'tid' => null,
'votes' => 'votes',
'displayorder' => 'displayOrder',
'polloption' => 'label',
'voterids' => 'voterIds',
);
$result = array();
foreach($row as $k => $v) {
$field = $map[$k];
if ($field !== null) {
$result[$field] = $v;
}
}
return $result;
}
public function getPollInfo($tIds) {
$result = array();
foreach(C::t('forum_polloption')->fetch_all_by_tid($tIds) as $row) {
$result[$row['tid']][$row['polloptionid']] = self::convertPoll($row);
}
return $result;
}
public function getThreadSort($tIds) {
global $_G;
$optionvar = array();
foreach(C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tIds) as $row) {
if(!isset($_G['cache']['threadsort_option_'.$row['sortid']])) {
loadcache(array('threadsort_option_'.$row['sortid']));
}
$title = $_G['cache']['threadsort_option_'.$row['sortid']][$row['optionid']]['title'];
$type = $_G['cache']['threadsort_option_'.$row['sortid']][$row['optionid']]['type'];
if($title && !in_array($type, array('image'))) {
$optionvar[$row['tid']][$title] = $row['value'];
}
}
return $optionvar;
}
public function allowSearchForum() {
C::t('common_usergroup_field')->update_allowsearch();
require_once libfile('function/cache');
updatecache('usergroups');
}
public function myThreadLog($opt, $data) {
global $_G;
$cloudAppService = Cloud::loadClass('Service_App');
if(!$cloudAppService->getCloudAppStatus('search')) return;
$data['action'] = $opt;
$data['dateline'] = time();
C::t('forum_threadlog')->insert($data, false, true);
}
public function myPostLog($opt, $data) {
global $_G;
$cloudAppService = Cloud::loadClass('Service_App');
if(!$cloudAppService->getCloudAppStatus('search')) return;
$data['action'] = $opt;
$data['dateline'] = time();
C::t('forum_postlog')->insert($data, false, true);
}
public function getRelatedThreadsTao($keyword, $page, $tpp, $excludeForumIds = '', $cache = false) {
global $_G;
$sId = $_G['setting']['my_siteid'];
$result = array();
if($sId) {
if($cache === true) {
$kname = 'search_recommend_thread_'.$keyword.'_'.$page.'_'.$excludeForumIds;
loadcache($kname);
}
if(isset($_G['cache'][$kname]['ts']) && (TIMESTAMP - $_G['cache'][$kname]['ts'] <= 21600)) {
$result = $_G['cache'][$kname]['result'];
} else {
$apiUrl = 'http://api.discuz.qq.com/search/discuz/tao?';
$params = array(
'sId' => $sId,
'q' => $keyword,
'tpp' => $tpp,
'excludeForumIds' => $excludeForumIds,
'page' => $page ? $page : 1,
'clientIp' => $_G['clientip']
);
$utilService = Cloud::loadClass('Service_Util');
$response = dfsockopen($apiUrl.$utilService->generateSiteSignUrl($params), 0, '', '', false, $_G['setting']['cloud_api_ip']);
require_once libfile('class/xml');
$result = (array) xml2array($response);
if($cache === true && isset($result['status']) && $result['status'] == 0) {
save_syscache($kname, array('ts' => TIMESTAMP, 'result' => $result));
}
if($result['status'] != 0) {
$result = null;
}
}
}
return $result;
}
public function getRelatedThreads($fId, $cache = false) {
global $_G;
$sId = $_G['setting']['my_siteid'];
$result = array();
if($sId) {
if($cache === true) {
$kname = 'search_recommend_fidthread_'.$fId;
loadcache($kname);
}
if(isset($_G['cache'][$kname]['ts']) && (TIMESTAMP - $_G['cache'][$kname]['ts'] <= 21600)) {
$result = $_G['cache'][$kname]['result'];
} else {
$apiUrl = 'http://api.discuz.qq.com/search/discuz/forumRelated?';
$params = array(
'sId' => $sId,
'fId' => $fId,
'clientIp' => $_G['clientip']
);
$utilService = Cloud::loadClass('Service_Util');
$response = dfsockopen($apiUrl.$utilService->generateSiteSignUrl($params), 0, '', '', false, $_G['setting']['cloud_api_ip']);
require_once libfile('class/xml');
$result = (array) xml2array($response);
if($cache === true && isset($result['status']) && $result['status'] == 0) {
save_syscache($kname, array('ts' => TIMESTAMP, 'result' => $result));
}
if($result['status'] != 0) {
$result = null;
}
}
}
return $result;
}
public function getRecWords($needNum = 14, $format = 'num', $fid = 0) {
global $_G;
$sId = $_G['setting']['my_siteid'];
$data = array();
if($sId) {
$fid = $fid ? $fid : 0;
$kname = 'search_recommend_words_' . $fid;
loadcache($kname);
$cacheLife = isset($_G['setting']['my_search_data']['recwords_lifetime']) ? intval($_G['setting']['my_search_data']['recwords_lifetime']) : 21600;
$cloudSettingTime = isset($_G['setting']['my_search_data']['set_forbidden_recwords_time']) ? intval($_G['setting']['my_search_data']['set_forbidden_recwords_time']) : 0;
$cacheSettingTime = isset($_G['cache'][$kname]['setting_ts']) ? intval($_G['cache'][$kname]['setting_ts']) : 0;
if((!$cloudSettingTime || $cloudSettingTime == $cacheSettingTime) && isset($_G['cache'][$kname]['ts']) && (TIMESTAMP - $_G['cache'][$kname]['ts'] <= $cacheLife)) {
$data = $_G['cache'][$kname]['result'];
} else {
$apiUrl = 'http://api.discuz.qq.com/search/recwords/get';
$params = array(
's_id' => $sId,
'f_id' => $fid,
'need_random' => false,
'need_num' => $needNum,
'version' => $format == 'num' ? 1 : 2, // 1返回数字下标的结果集、2返回关联数组形式的结果集
'close' => 1,
);
$utilService = Cloud::loadClass('Service_Util');
$response = dfsockopen($apiUrl, 0, $utilService->generateSiteSignUrl($params), '', false, $_G['setting']['cloud_api_ip']);
$result = (array) unserialize($response);
if(isset($result['status']) && $result['status'] === 0) {
$data = $result['result'];
if($cloudSettingTime) {
save_syscache($kname, array('ts' => TIMESTAMP, 'setting_ts' => $cloudSettingTime, 'result' => $data));
} else {
save_syscache($kname, array('ts' => TIMESTAMP, 'result' => $data));
}
}
}
}
return $data;
}
public function makeSearchSignUrl() {
global $_G;
$url = '';
$params = array();
$mySearchData = $_G['setting']['my_search_data'];
$mySiteId = $_G['setting']['my_siteid'];
$mySiteKey = $_G['setting']['my_sitekey'];
$cloudAppService = Cloud::loadClass('Service_App');
if($mySearchData['status'] && $cloudAppService->getCloudAppStatus('search') && $mySiteId) {
$myExtGroupIds = array();
$_extGroupIds = explode("\t", $_G['member']['extgroupids']);
foreach($_extGroupIds as $v) {
if($v) {
$myExtGroupIds[] = $v;
}
}
$myExtGroupIdsStr = implode(',', $myExtGroupIds);
$params = array(
'sId' => $mySiteId,
'ts' => time(),
'cuId' => $_G['uid'],
'cuName' => $_G['username'],
'gId' => intval($_G['groupid']),
'agId' => intval($_G['adminid']),
'egIds' => $myExtGroupIdsStr,
'fmSign' => '',
);
$groupIds = array($params['gId']);
if($params['agId']) {
$groupIds[] = $params['agId'];
}
if($myExtGroupIds) {
$groupIds = array_merge($groupIds, $myExtGroupIds);
}
$groupIds = array_unique($groupIds);
foreach($groupIds as $v) {
$key = 'ugSign' . $v;
$params[$key] = '';
}
$extraParams = array();
if (isset($_G['setting']['verify']['enabled']) && $_G['setting']['verify']['enabled']) {
$verifyGroups = C::t('common_member_verify')->fetch($_G['uid']);
$extraParams['ext_vgIds'] = 0;
foreach ($verifyGroups as $k => $v) {
if ($k != 'uid') {
$position = dintval(substr($k, strlen('verify')));
$extraParams['ext_vgIds'] = setstatus($position, dintval($v), $extraParams['ext_vgIds']);
}
}
}
if ($_G['cookie']['ffids' . $_G['uid']]) {
$ext_ffids = str_replace('D', ',', authcode($_G['cookie']['ffids' . $_G['uid']], 'DECODE'));
$extraParams['ext_ffids'] = $ext_ffids;
}
if (!empty($extraParams)) {
ksort($extraParams);
$params = array_merge($params, $extraParams);
}
$params['sign'] = md5(implode('|', $params) . '|' . $mySiteKey);
if ($cloudAppService->getCloudAppStatus('connect') && $_G['member']['conopenid']) {
$connectService = Cloud::loadClass('Service_Connect');
$connectService->connectMergeMember();
$params['openid'] = $_G['member']['conopenid'];
}
$params['charset'] = $_G['charset'];
if($mySearchData['domain']) {
$domain = $mySearchData['domain'];
} else {
$domain = 'search.discuz.qq.com';
}
$url = 'http://' . $domain . '/f/discuz';
}
return !empty($url) ? array('url' => $url, 'params' => $params) : array();
}
}

View File

@ -1,935 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Security.php 30564 2012-06-04 05:38:45Z songlixin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Security {
protected static $debug = 0;
protected static $_secClient;
protected static $_secStatus;
protected static $postAction = array('newThread', 'newPost', 'editPost', 'editThread');
protected static $userAction = array('register', 'login');
protected static $delPostAction = array('delThread', 'delPost');
protected static $delUserAction = array('banUser');
protected static $retryLimit = 8;
protected static $specialType = array('1' => 'poll', '2' => 'trade', '3' => 'reward', '4' => 'activity', '5' => 'debate');
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
$cloudAppService = Cloud::loadClass('Service_App');
self::$_secStatus = $cloudAppService->getCloudAppStatus('security');
self::$_instance->_setClient();
}
return self::$_instance;
}
private function _getUA() {
return $_SERVER['HTTP_USER_AGENT'];
}
private function _setClient() {
if (!self::$_secStatus) {
return false;
}
self::$_secClient = Cloud::loadClass('Service_Client_Security');
}
public function reportRegister($uid) {
global $_G;
if (!self::$_secStatus) {
return false;
}
$startTime = microtime(true);
$uid = dintval($uid);
$member = C::t('common_member')->fetch($uid);
if (!is_array($member)) {
return true;
}
$openId = $this->_getOpenId($uid);
$secReportCodeStatus = ($_G['setting']['seccodestatus'] & 1) ? 1 : 2;
$batchData = array();
$batchData[] = array(
'siteUid' => $member['uid'],
'username' => $member['username'],
'email' => $member['email'],
'openId' => $openId,
'registerTime' => $_G['timestamp'],
'clientIp' => $_G['clientip'],
'remoteIp' => $_SERVER['REMOTE_ADDR'],
'hasVerifyCode' => $secReportCodeStatus,
'regResult' => 1,
'userAgent' => $this->_getUA(),
'extra' => $extra
);
$result = false;
try {
$result = self::$_secClient->securityReportUserRegister($batchData);
} catch (Cloud_Service_Client_RestfulException $e) {
$ids = array($uid);
$this->logFailed('register', $ids);
} catch (Exception $e) {
}
$this->benchMarkLog($startTime, $member['uid'], $batchData, 'register');
return $result;
}
public function reportLogin($uid) {
global $_G;
if (!self::$_secStatus) {
return false;
}
$startTime = microtime(true);
$uid = dintval($uid);
$member = C::t('common_member')->fetch($uid, 0 ,1);
if (!is_array($member)) {
return true;
}
$memberField = C::t('common_member_field_forum')->fetch($uid, 0, 1);
$memberStatus = C::t('common_member_status')->fetch($uid, 0, 1);
$memberCount = C::t('common_member_count')->fetch($uid, 0, 1);
$memberVerify = C::t('common_member_verify')->fetch($uid);
$openId = $this->_getOpenId($uid);
$userBitMap['isAdmin'] = $member['adminid'] ? 1 : 2;
$userBitMap['hasMedal'] = $memberField['medals'] ? 1 : 2;
$userBitMap['hasAvatar'] = $member['avatarstatus'] ? 1 : 2;
$userBitMap['hasVerify'] = (count($memberVerify)) ? 1 : 2;
$username = $member['username'];
$email = $member['email'];
$emailStatus = $member['emailstatus'];
$sUrl = $_G['siteurl'];
$credits = $member['credits'];
$regIp = $memberStatus['regip'];
$regDate = $member['regdate'];
$friends = $memberCount['friends'];
$onlineTime = $memberCount['oltime']*3600;
$threads = $memberCount['threads'];
$posts = $memberCount['posts'];
$signature = $memberField['sightml'];
if (!$regIp) {
$regIp = 'N/A';
}
if ($_G['clientip'] == NULL) {
$_G['clientip'] = 'N/A';
}
$batchData = array();
$batchData[] = array(
'siteUid' => $uid,
'openId' => $openId,
'loginTime' => TIMESTAMP,
'clientIp' => $_G['clientip'],
'remoteIp' => $_SERVER['REMOTE_ADDR'],
'username' => $username,
'email' => $email,
'emailStatus' => $emailStatus,
'sUrl' => $sUrl,
'credits' => $credits,
'registerIp' => $regIp,
'registerTime' => $regDate,
'friends' => $friends,
'onlineTime' => $onlineTime,
'threads' => $threads,
'posts' => $posts,
'signature' => $signature,
'userBitMap' => $userBitMap,
'userAgent' => $this->_getUA(),
'extra' => $extra
);
$result = false;
try {
$result = self::$_secClient->securityReportUserLogin($batchData);
} catch (Cloud_Service_Client_RestfulException $e) {
$ids = array($uid);
$this->logFailed('login', $ids);
} catch (Exception $e) {
}
$this->benchMarkLog($startTime, $uid, $batchData, 'login');
return $result;
}
public function reportPost($type, $tid, $pid, $extra = NULL, $isFollow = 0) {
global $_G;
$utilService = Cloud::loadClass('Service_Util');
if (!self::$_secStatus) {
return false;
}
$startTime = microtime(true);
$tid = dintval($tid);
$pid = dintval($pid);
$url = $_G['siteurl'] . "forum.php?mod=redirect&goto=findpost&ptid=$tid&pid=$pid";
include_once libfile('function/forum');
$thread = get_thread_by_tid($tid);
if (!is_array($thread)) {
return true;
}
$post = get_post_by_pid($pid);
$member = C::t('common_member')->fetch($post['authorid'], 0, 1);
$memberField = C::t('common_member_field_forum')->fetch($post['authorid'], 0, 1);
$memberStatus = C::t('common_member_status')->fetch($post['authorid'], 0, 1);
$memberVerify = C::t('common_member_verify')->fetch($post['authorid']);
if ($post['first'] == 1) {
$type = $type . 'Thread';
} else {
$type = $type . 'Post';
}
$id = 'pid:' . $pid;
$aids = C::t('forum_attachment')->fetch_all_by_id('pid', $pid);
$aids = array_keys($aids);
$postAttachs = C::t('forum_attachment_n')->fetch_all($id, $aids);
if (!$post['first']) {
$firstPost = C::t('forum_post')->fetch_all_by_tid($thread['posttableid'], $tid, 1, '', 0, 0, 1);
$firstPost = array_pop($firstPost);
$id = 'pid:' . $firstPost['pid'];
$aids = C::t('forum_attachment')->fetch_all_by_id('pid', $firstPost['pid']);
$aids = array_keys($aids);
$threadAttachs = C::t('forum_attachment_n')->fetch_all($id, $aids);
} else {
$firstPost = $post;
$firstPostAttachs = $postAttachs;
}
$views = dintval($thread['views']);
$replies = dintval($thread['replies']);
$favourites = dintval($thread['favtimes']);
$supports = dintval($thread['recommend_add']);
$opposes = dintval($thread['recommend_sub']);
$shares = dintval($thread['sharetimes']);
$openId = $this->_getOpenId($_G['uid']);
if (!$thread || !$post) {
return true;
}
$fid = $thread["fid"];
if ($post['first']) {
$threadShield = ($post['status'] & 1) ? 1 : 2;
$threadWarning = ($post['status'] & 2) ? 1 : 2;
} else {
$threadShield = ($firstPost['status'] & 1) ? 1 : 2;
$threadWarning = ($firstPost['status'] & 2) ? 1 : 2;
}
$contentBitMap = array(
'onTop' => $thread['displayorder'] ? 1:2,
'hide' => (strpos($post['message'], '[hide')) ? 1:2,
'digest' => $thread['digest'] ? 1 : 2,
'highLight' => $thread['highlight'] ? 1:2,
'special' => $thread['special'] ? 1:2,
'threadAttach' => 2,
'threadAttachFlash' => 2,
'threadAttachPic' => 2,
'threadAttachVideo' => 2,
'threadAttachAudio' => 2,
'threadShield' => $threadShield,
'threadWarning' => $threadWarning,
'postAttach' => 2,
'postAttachFlash' => 2,
'postAttachPic' => 2,
'postAttachVideo' => 2,
'postAttachAudio' => 2,
'postShield' => ($post['status'] & 1) ? 1 : 2,
'postWarning' => ($post['status'] & 2) ? 1 : 2,
'isAdmin' => $member['adminid'] ? 1 : 2,
'isRush' => getstatus($thread['status'], 3) ? 1 : 2,
'hasReadPerm' => $thread['readperm'] ? 1 : 2,
'hasStamp' => ($thread['stamp'] >= 0) ? 1 : 2,
'hasIcon' => ($thread['icon'] >= 0) ? 1 : 2,
'isPushed' => $thread['pushedaid'] ? 1 : 2,
'hasCover' => $thread['cover'] ? 1 : 2,
'hasReward' => $thread['replycredit'] ? 1 : 2,
'isFollow' => $isFollow ? 1 : 2,
'threadStatus' => $thread['status'],
'postStatus' => $post['status'],
);
if ($post['first']) {
$contentBitMap['isMobile'] = $utilService->isMobile($thread['status']) ? 1 : 2;
if ($contentBitMap['isMobile'] == 1) {
$contentBitMap['isMobileSound'] = $utilService->mobileHasSound($thread['status']) ? 1 : 2;
$contentBitMap['isMobilePhoto'] = $utilService->mobileHasPhoto($thread['status']) ? 1 : 2;
$contentBitMap['isMobileGPS'] = $utilService->mobileHasGPS($thread['status']) ? 1 : 2;
}
} else {
$contentBitMap['isMobile'] = getstatus($post['status'], 4) ? 1 : 2;
}
$userBitMap['isAdmin'] = $member['adminid'] ? 1 : 2;
$userBitMap['hasMedal'] = $memberField['medals'] ? 1 : 2;
$userBitMap['hasAvatar'] = $member['avatarstatus'] ? 1 : 2;
$userBitMap['hasVerify'] = (count($memberVerify)) ? 1 : 2;
$videoExt = array('.rm', '.flv', '.mkv', '.rmvb', '.avi', '.wmv', '.mp4', '.mpeg', '.mpg');
$audioExt = array('.wav', '.mid', '.mp3', '.m3u', '.wma', '.asf', '.asx');
if ($firstPostAttachs) {
foreach($firstPostAttachs as $attach) {
$fileExt = substr($attach['filename'], strrpos($attach['filename'], '.'));
if ($fileExt == '.bmp' || $fileExt == '.jpg' || $fileExt == '.jpeg' || $fileExt == '.gif' || $fileExt == '.png') {
$contentBitMap['threadAttachPic'] = 1;
}
if ($fileExt == '.swf' || $fileExt == '.fla') {
$contentBitMap['threadAttachFlash'] = 1;
}
if (in_array($fileExt, $videoExt)) {
$contentBitMap['threadAttachVideo'] = 1;
}
if (in_array($fileExt, $audioExt)) {
$contentBitMap['threadAttachAudio'] = 1;
}
}
$contentBitMap['threadAttach'] = 1;
}
if ($postAttachs) {
foreach($postAttachs as $attach) {
$fileExt = substr($attach['filename'], strrpos($attach['filename'], '.'));
if ($fileExt == '.bmp' || $fileExt == '.jpg' || $fileExt == '.jpeg' || $fileExt == '.gif' || $fileExt == '.png') {
$contentBitMap['postAttachPic'] = 1;
}
if ($fileExt == '.swf' || $fileExt == '.fla') {
$contentBitMap['postAttachFlash'] = 1;
}
if (in_array($fileExt, $videoExt)) {
$contentBitMap['postAttachVideo'] = 1;
}
if (in_array($fileExt, $audioExt)) {
$contentBitMap['postAttachAudio'] = 1;
}
}
$contentBitMap['postAttach'] = 1;
}
if ($thread['authorid'] == $_G['uid']) {
$threadEmail = $_G['member']['email'];
} else {
$threadMember = C::t('common_member')->fetch($thread['authorid'], 0, 1);
$threadEmail = $threadMember['email'];
}
if ($post['authorid'] == $_G['uid']) {
$postEmail = $_G['member']['email'];
} else {
$postEmail = $member['email'];
}
if ($thread['special']) {
if (array_key_exists($thread['special'], $this->specialType)) {
$threadSpecial = self::$specialType[$thread['special']];
} else {
$threadSpecial = 'other';
}
}
$threadSort = 2;
if ($thread['sortid']) {
$threadSort = 1;
if ($post['first']) {
$sortMessage = $this->_convertSortInfo($thread['sortid'], $thread['tid']);
}
}
$contentBitMap['threadSort'] = $threadSort;
if ($_GET['action'] == 'newtrade') {
$type = 'newThread';
$pid = $firstPost['pid'];
}
$batchData[] = array(
'tId' => $tid,
'pId' => $pid,
'threadUid' => dintval($thread['authorid']),
'threadUsername' => $thread['author'],
'threadEmail' => $threadEmail,
'postUid' => dintval($post['authorid']),
'postUsername' => $post['author'],
'postEmail' => $postEmail,
'openId' => $openId,
'fId' => dintval($fid),
'threadUrl' => $url,
'operateTime' => $_G['timestamp'],
'clientIp' => $_G['clientip'],
'remoteIp' => $_SERVER['REMOTE_ADDR'],
'views' => $views,
'replies' => $replies,
'favourites' => $favourites,
'supports' => $supports,
'opposes' => $opposes,
'shares' => $shares,
'title' => $post['subject'],
'content' => $post['message'],
'sortMessage' => $sortMessage,
'attachList' => $postAttachs,
'reportType' => $type,
'contentBitMap' => $contentBitMap,
'userBitMap' => $userBitMap,
'extra' => $extra,
'specialType' => $threadSpecial,
'signature' => $memberField['sightml'],
'userAgent' => $this->_getUA(),
);
$result = false;
try {
$result = self::$_secClient->securityReportPost($batchData);
} catch (Cloud_Service_Client_RestfulException $e) {
$ids = array($tid, $pid);
$this->logFailed($type, $ids);
} catch (Exception $e) {
}
$this->benchMarkLog($startTime, $pid, $batchData, $type);
return $result;
}
private function _convertSortInfo($sortId, $tid) {
global $_G;
$returnStr = array();
require_once libfile('function/threadsort');
$sortInfo = threadsortshow($sortId, $tid);
foreach ($sortInfo['optionlist'] as $value) {
if ($value['type'] != 'select') {
$returnStr[] = $value['title'] . ':' . $value['value'];
}
}
if (count($returnStr)) {
return implode('<br/>', $returnStr);
}
return false;
}
public function reportDelPost($logId) {
if (!self::$_secStatus) {
return false;
}
if (!$logId) {
return true;
}
$log = C::t('#security#security_failedlog')->fetch($logId);
if ($log['pid'] == 0) {
return true;
}
$extraData = dunserialize($log['extra2']);
$batchData[] = array(
'tid' => $log['tid'],
'pid' => $log['pid'],
'uid' => $log['uid'],
'delType' => $log['reporttype'],
'findEvilTime' => $log['createtime'],
'postTime' => $log['posttime'],
'reason' => $log['delreason'],
'fid' => $extraData['fid'],
'clientIp' => $extraData['clientIp'],
'openId' => $extraData['openId'],
);
$result = false;
try {
$result = self::$_secClient->securityReportDelPost($batchData);
} catch (Cloud_Service_Client_RestfulException $e) {
$ids = array($log['tid'], $log['pid']);
$this->logFailed('delPost', $ids);
} catch (Exception $e) {
}
return $result;
}
public function reportBanUser($logId) {
if (!self::$_secStatus) {
return false;
}
if (!$logId) {
return true;
}
$log = C::t('#security#security_failedlog')->fetch($logId);
if ($log['uid'] == 0) {
return true;
}
$extraData = dunserialize($log['extra2']);
$batchData[] = array(
'uid' => $log['uid'],
'findEvilTime' => $log['createtime'],
'postTime' => $log['posttime'],
'reason' => $log['delreason'],
'clientIp' => $extraData['clientIp'],
'openId' => $extraData['openId'],
);
$result = false;
try {
$result = self::$_secClient->securityReportBanUser($batchData);
} catch (Cloud_Service_Client_RestfulException $e) {
$ids = array($log['uid']);
$this->logFailed('banUser', $ids);
} catch (Exception $e) {
}
return $result;
}
public function retryReportData($num = 1) {
global $_G;
if (!self::$_secStatus) {
return false;
}
C::t('#security#security_failedlog')->deleteDirtyLog();
$num = dintval($num) ? dintval($num) : 1;
$result = 0;
$clearIds = array();
$retryData = C::t('#security#security_failedlog')->range(0, $num, 'ASC');
foreach ($retryData as $data) {
if (!$data['uid'] && !$data['tid'] && !$data['pid']) {
continue;
}
if ($data['scheduletime'] > $_G['timestamp']) {
continue;
}
$reportType = $data['reporttype'];
$uid = $data['uid'];
$tid = $data['tid'];
$pid = $data['pid'];
$failcount = $data['failcount'];
if ($failcount >= self::$retryLimit) {
$clearIds[] = $data['id'];
} else {
switch ($reportType) {
case 'newThread':
case 'newPost':
$result = $this->reportPost('new', $tid, $pid);
break;
case 'editPost':
case 'editThread':
$result = $this->reportPost('edit', $tid, $pid);
break;
case 'register':
$result = $this->reportRegister($uid);
break;
case 'login':
$result = $this->reportLogin($uid);
break;
case 'delThread':
case 'delPost':
$result = $this->reportDelPost($data['id']);
break;
case 'banUser':
$result = $this->reportBanUser($data['id']);
break;
default:break;
}
if ($result) {
$clearIds[] = $data['id'];
}
}
}
$this->_clearFailed($clearIds);
}
private function _clearFailed($ids) {
if (!is_array($ids)) {
$ids = array($ids);
}
if (count($ids) < 1) {
return false;
}
C::t('#security#security_failedlog')->delete($ids);
}
public function writeLog($id, $type) {
if (!self::$debug) {
return false;
}
return true;
}
function logFailed($reportType, $ids, $reason = '') {
global $_G;
if (!self::$_secStatus) {
return false;
}
$this->_checkAndClearFailNum();
if (!is_array($ids)) {
$ids = array($ids);
}
$postTime = 0;
if (in_array($reportType, self::$postAction) || in_array($reportType, self::$delPostAction)) {
$tid = dintval($ids[0]) ? dintval($ids[0]) : dintval($ids['tid']);
$pid = dintval($ids[1]) ? dintval($ids[1]) : dintval($ids['pid']);
$uid = dintval($ids['uid']);
if ($pid == 0) {
return false;
}
if (in_array($reportType, self::$delPostAction)) {
require_once libfile('function/forum');
$postInfo = get_post_by_pid($pid);
$postTime = $postInfo['dateline'];
$fid = $postInfo['fid'];
$uid = $postInfo['authorid'];
$clientIp = $postInfo['useip'];
$openId = $this->_getOpenId($uid);
}
$oldData = C::t('#security#security_failedlog')->fetch_by_pid($pid);
} elseif (in_array($reportType, self::$userAction) || in_array($reportType, self::$delUserAction)) {
$tid = 0;
$pid = 0;
$uid = dintval($ids[0]) ? dintval($ids[0]) : dintval($ids['uid']);
if ($uid == 0) {
return false;
}
if (in_array($reportType, self::$delUserAction)) {
$memberStatus = C::t('common_member_status')->fetch($uid, 0, 1);
$postTime = $memberStatus['lastpost'];
$clientIp = $this->_getMemberIp($uid);
$openId = $this->_getOpenId($uid);
}
$oldData = C::t('#security#security_failedlog')->fetch_by_uid($uid);
} else {
return false;
}
$extraData = array(
'fid' => $fid,
'clientIp' => $clientIp,
'openId' => $openId,
);
if (is_array($oldData) && $oldData['id']) {
$data = $oldData;
$data['reporttype'] = $reportType;
$data['lastfailtime'] = $_G['timestamp'];
$data['scheduletime'] = $_G['timestamp'] + 300;
$data['failcount']++;
} else {
$data = array(
'reporttype' => $reportType,
'tid' => $tid,
'pid' => $pid,
'uid' => $uid,
'failcount' => 1,
'createtime' => $_G['timestamp'],
'posttime' => $postTime,
'delreason' => $reason,
'scheduletime' => $_G['timestamp'] + 60,
'lastfailtime' => $_G['timestamp'],
);
}
if ($extraData['fid'] || $extraData['clientIp'] || $extraData['openId']) {
$data['extra2'] = serialize($extraData);
}
if (!$data['uid'] && !$data['tid'] && !$data['pid']) {
return false;
}
C::t('#security#security_failedlog')->insert($data, 0, 1);
}
private function _getOpenId($uid) {
$member = C::t('common_member')->fetch($uid, 0, 1);
if ($member['conisbind']) {
$connectInfo = C::t('#qqconnect#common_member_connect')->fetch($uid);
$openId = $connectInfo['conopenid'];
} else {
$openId = '';
}
return $openId;
}
private function _getMemberIp($uid) {
if (empty($uid)) {
return false;
}
$member = C::t('common_member_status')->fetch($uid, 0, 1);
if ($member['lastip']) {
return $member['lastip'];
} else {
return $member['regip'];
}
}
private function _checkAndClearFailNum($maxNum = '50000') {
$num = C::t('#security#security_failedlog')->count();
if ($num >= $maxNum) {
C::t('#security#security_failedlog')->truncate();
}
return true;
}
public function logDeletePost($pids, $reason = 'Admin Delete') {
if (!is_array($pids)) {
$pids = array($pids);
}
$logData = array();
require_once libfile('function/forum');
foreach ($pids as $pid) {
$postInfo = get_post_by_pid($pid);
if ($postInfo['invisible'] != '-5') {
$logData[] = array(
'tid' => $postInfo['tid'],
'pid' => $postInfo['pid'],
'fid' => $postInfo['fid'],
'uid' => $postInfo['authorid'],
'clientIp' => $postInfo['useip'],
'openId' => $this->_getOpenId($postInfo['authorid']),
);
}
}
if (count($logData)) {
foreach ($logData as $data) {
$this->logFailed('delPost', $data, $reason);
}
}
}
public function logBannedMember($username, $reason = 'Admin Banned') {
if (!$username || !self::$_secStatus) {
return false;
}
$uid = C::t('common_member')->fetch_uid_by_username($username);
if ($uid) {
$data = array(
'uid' => $uid,
'openId' => $this->_getOpenId($uid),
'clientIp' => $this->_getMemberIp($uid),
);
$this->logFailed('banUser', $data, $reason);
}
}
public function logDeleteThread($tids, $reason = 'Admin Delete') {
global $_G;
if (!is_array($tids)) {
$tids = array($tids);
}
$postids = array();
$logData = array();
loadcache(array('threadtableids', 'posttableids'));
$threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
$posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array();
$threadtableids = array_unique(array_merge(array('0'), $threadtableids));
$posttableids = array_unique(array_merge(array('0'), $threadtableids));
foreach($threadtableids as $tableid) {
$threads = C::t('forum_thread')->fetch_all_by_tid($tids, 0, 0, $tableid);
if (count($threads)) {
foreach ($threads as $tid => $thread) {
if ($thread['displayorder'] == '-1') {
unset($threads[$tid]);
}
}
$postids[$tableid] = array_keys($threads);
}
}
foreach ($posttableids as $postTableId) {
if (count($postids[$postTableId])) {
$posts = C::t('forum_post')->fetch_all_by_tid($postTableId, $tids, 1, '', 0, 0, 1);
foreach ($posts as $data) {
$logData[] = array(
'tid' => $data['tid'],
'pid' => $data['pid'],
'fid' => $data['fid'],
'uid' => $data['authorid'],
'clientIp' => $data['useip'],
'openId' => $this->_getOpenId($data['authorid']),
);
}
}
}
if (count($logData)) {
foreach ($logData as $data) {
$this->logFailed('delThread', $data, $reason);
}
}
}
public function getOperateData($type, $limit = 20) {
if (!self::$_secStatus) {
return false;
}
$allowType = array('post', 'user', 'member');
$operateData = array();
$operateResultData = array();
if ($type == 'member') {
$type = 'user';
}
if (!in_array($type, $allowType)) {
return false;
}
$tableName = '#security#security_evil' . $type;
$operateData = C::t($tableName)->fetch_all_report($limit);
foreach($operateData as $tempData) {
$operateResult = $tempData['operateresult'] == 1 ? 'recover' : 'delete';
if ($type == 'post') {
require_once libfile('function/forum');
$detailData = get_post_by_pid($tempData['pid']);
$detailData['pid'] = $tempData['pid'];
$detailData['tid'] = $tempData['tid'];
$detailData['uid'] = $id = $tempData['pid'];
} elseif ($type == 'user') {
$detailData = C::t('common_member')->fetch($tempData['uid'], 0, 1);
$detailData['uid'] = $id = $tempData['uid'];
}
if ($type == 'post') {
$operateType = $detailData['first'] ? 'thread' : 'post';
} elseif ($type == 'user') {
$operateType = 'member';
}
$data = array(
'tid' => $detailData['tid'] ? $detailData['tid'] : 0,
'pid' => $detailData['pid'] ? $detailData['pid'] : 0,
'fid' => $detailData['fid'] ? $detailData['fid'] : 0,
'operateType' => $operateType,
'operate' => $operateResult,
'operateId' => $id,
'uid' => $detailData['authorid'] ? $detailData['authorid'] : $detailData['uid'],
);
$data['openId'] = $this->_getOpenId($data['uid']);
$data['clientIp'] = $detailData['useip'] ? $detailData['useip'] : $this->_getMemberIp($data['uid']);
$operateResultData[] = $data;
}
return $operateResultData;
}
public function markasreported($operateType, $operateData) {
if (!self::$_secStatus) {
return false;
}
foreach ($operateData as $data) {
$operateId[] = $data['operateId'];
}
if (!is_array($operateId) || !count($operateId)) {
return false;
}
if ($operateType == 'member') {
C::t('#security#security_eviluser')->update($operateId, array('isreported' => 1));
} elseif(in_array($operateType, array('thread', 'post'))) {
C::t('#security#security_evilpost')->update($operateId, array('isreported' => 1));
}
return true;
}
public function updatePostOperate($ids, $operate) {
if (!self::$_secStatus) {
return false;
}
$result = $this->_getOperateResult($operate);
C::t('#security#security_evilpost')->update($ids, array('operateresult' => $result));
return true;
}
public function updateThreadOperate($ids, $operate) {
if (!self::$_secStatus) {
return false;
}
$result = $this->_getOperateResult($operate);
C::t('#security#security_evilpost')->update_by_tid($ids, array('operateresult' => $result));
return true;
}
public function updateMemberOperate($ids, $operate) {
if (!self::$_secStatus) {
return false;
}
$result = $this->_getOperateResult($operate);
C::t('#security#security_eviluser')->update($ids, array('operateresult' => $result));
return true;
}
public function updateMemberRecover($username) {
if (!$username || !self::$_secStatus) {
return false;
}
$uid = C::t('common_member')->fetch_uid_by_username($username);
$this->updateMemberOperate(array($uid), 'recover');
return true;
}
private function _getOperateResult($str) {
$mapArray = array(
'recover' => 1,
'delete' => 2,
);
return $mapArray[$str];
}
private function benchMarkLog($startTime, $id, $data, $type) {
return true;
$util = Cloud::loadClass('Service_Util');
$endTime = microtime(true);
$dataSize = strlen($util->httpBuildQuery($data));
$content = array(
date('Y-m-d H:i:s', $startTime),
$endTime - $startTime,
$type,
$id,
$dataSize,
);
$content = join(',', $content) . "\n";
}
}

View File

@ -1,85 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Application.php 25813 2011-11-22 10:07:48Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Application extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onApplicationUpdate($appId, $appName, $version, $displayMethod, $displayOrder = null, $userPanelArea = null, $canvasTitle = null, $isFullscreen = null, $displayUserPanel = null, $additionalStatus = null) {
$row = C::t('common_myapp')->fetch($appId);
$result = true;
if ($row['appname'] != $appName) {
$fields = array('appname' => $appName);
$result = C::t('home_userapp')->update_by_uid_appid(0, $appId, $fields);
require_once libfile('function/cache');
updatecache('userapp');
}
$displayMethod = ($displayMethod == 'iframe') ? 1 : 0;
$this->refreshApplication($appId, $appName, $version, $userPanelArea, $canvasTitle, $isFullscreen, $displayUserPanel, $displayMethod, null, null, $displayOrder, $additionalStatus);
return $result;
}
public function onApplicationRemove($appIds) {
$result = C::t('home_userapp')->delete_by_uid_appid(0, $appIds);
C::t('home_userappfield')->delete_by_uid_appid(0, $appIds);
C::t('common_myapp')->delete($appIds);
require_once libfile('function/cache');
updatecache(array('userapp', 'myapp'));
return $result;
}
public function onApplicationSetFlag($applications, $flag) {
$flag = ($flag == 'disabled') ? -1 : ($flag == 'default' ? 1 : 0);
$appIds = array();
if ($applications && is_array($applications)) {
foreach($applications as $application) {
$this->refreshApplication($application['appId'], $application['appName'], null, null, null, null, null, null, null, $flag, null, null);
$appIds[] = $application['appId'];
}
}
if ($flag == -1) {
C::t('home_feed')->delete_by_icon($appIds);
C::t('home_userapp')->delete_by_uid_appid(0, $appIds);
C::t('home_userappfield')->delete_by_uid_appid(0, $appIds);
C::t('common_myinvite')->delete_by_appid($appIds);
C::t('home_notification')->delete_by_type($appIds);
}
require_once libfile('function/cache');
updatecache('userapp');
$result = true;
return $result;
}
}

View File

@ -1,167 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Cloud.php 29177 2012-03-28 05:56:17Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Cloud extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onCloudGetApps($appName = '') {
$appService = Cloud::loadClass('Service_App');
$utilService = Cloud::loadClass('Service_Util');
$apps = $appService->getCloudApps(false);
if ($appName) {
$apps = array($appName => $apps[$appName]);
}
$apps['apiVersion'] = $utilService->getApiVersion();
$apps['siteInfo'] = $this->_getBaseInfo();
return $apps;
}
public function onCloudSetApps($apps) {
if (!is_array($apps)) {
return false;
}
$appService = Cloud::loadClass('Service_App');
$utilService = Cloud::loadClass('Service_Util');
$res = array();
$res['apiVersion'] = $utilService->getApiVersion();
foreach ($apps as $appName => $status) {
$res[$appName] = $appService->setCloudAppStatus($appName, $status, false, false);
}
try {
require_once libfile('function/cache');
updatecache(array('plugin', 'setting', 'styles'));
cleartemplatecache();
} catch (Exception $e) {
}
$res['siteInfo'] = $this->_getBaseInfo();
return $res;
}
public function onCloudOpenCloud() {
$appService = Cloud::loadClass('Service_App');
$utilService = Cloud::loadClass('Service_Util');
$this->_openCloud();
$res = array();
$res['status'] = true;
$res['siteInfo'] = $this->_getBaseInfo();
return $res;
}
protected function _openCloud() {
require_once libfile('function/cache');
$result = C::t('common_setting')->update('cloud_status', 1);
try {
C::t('common_setting')->delete(array('connectsiteid', 'connectsitekey', 'my_siteid_old', 'my_sitekey_sign_old'));
} catch (Exception $e) {
}
updatecache('setting');
return true;
}
protected function _getBaseInfo() {
global $_G;
$info = array();
loadcache(array('userstats', 'historyposts'));
$indexData = memory('get', 'forum_index_page_1');
if(is_array($indexData) && $indexData) {
$indexData = array();
$info['threads'] = $indexData['threads'] ? $indexData['threads'] : 0;
$info['todayPosts'] = $indexData['todayposts'] ? $indexData['todayposts'] : 0;
$info['allPosts'] = $indexData['posts'] ? $indexData['posts'] : 0;
} else {
$threads = $posts = $todayposts = 0;
$query = C::t('forum_forum')->fetch_all_by_status(1, 0);
foreach($query as $forum) {
if($forum['type'] != 'group') {
$threads += $forum['threads'];
$posts += $forum['posts'];
$todayposts += $forum['todayposts'];
}
}
$info['threads'] = $threads ? $threads : 0;
$info['allPosts'] = $posts ? $posts : 0;
$info['todayPosts'] = $todayposts ? $todayposts : 0;
}
$info['members'] = $_G['cache']['userstats']['totalmembers'] ? intval($_G['cache']['userstats']['totalmembers']) : 0;
$postdata = $_G['cache']['historyposts'] ? explode("\t", $_G['cache']['historyposts']) : array(0,0);
$info['yesterdayPosts'] = intval($postdata[0]);
return $info;
}
public function onCloudGetStats() {
global $_G;
$info = array();
$tableprelen = strlen(C::t('common_setting')->get_tablepre());
$table = array(
'forum_thread' => 'threads',
'forum_post' => 'allPosts',
'common_member' => 'members'
);
foreach(C::t('common_setting')->fetch_all_table_status() as $row) {
$tablename = substr($row['Name'], $tableprelen);
if(!isset($table[$tablename])) {
continue;
}
$info[$table[$tablename]] = $row['Rows'];
}
loadcache(array('historyposts'));
$postdata = $_G['cache']['historyposts'] ? explode("\t", $_G['cache']['historyposts']) : array(0,0);
$info['yesterdayPosts'] = intval($postdata[0]);
$postnum = 0;
$postrow = 0;
$avg_posts = C::t('common_stat')->fetch_post_avg();
$info['avgPosts'] = intval($avg_posts);
$info['statsCode'] = $_G['setting']['statcode'];
return $info;
}
}

View File

@ -1,120 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Common.php 25828 2011-11-23 10:50:40Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Common extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onCommonSetConfig($data) {
$settings = array();
if (is_array($data) && $data) {
foreach($data as $key => $val) {
if (substr($key, 0, 3) != 'my_') {
continue;
}
$settings[$key] = $val;
}
if ($settings) {
C::t('common_setting')->update_batch($settings);
require_once DISCUZ_ROOT . './source/function/function_cache.php';
updatecache('setting');
return true;
}
}
return false;
}
public function onCommonGetConfig($keys) {
global $_G;
$confs = array();
foreach ($keys as $key) {
if ($key && $_G['setting']) {
$setting = $_G['setting'];
if ($key == 'search' && is_array($setting['search'])) {
$conf = array();
foreach ($setting['search'] as $app => $v) {
$conf[$app] = array(
'status' => $v['status'] ? true : false,
'interval' => $v['searchctrl'],
'frequence' => $v['maxspm'],
'maxResults' => $v['maxsearchresults']
);
}
$confs[$key] = $conf;
continue;
}
if ($key == 'rewrite') {
$conf = array();
if ($setting['rewritestatus'] && $setting['rewriterule']) {
$conf['compatible'] = $setting['rewritecompatible'] ? true : false;
foreach($setting['rewriterule'] as $mod => $rule) {
$conf['modules'][$mod]['rule'] = $rule;
if (in_array($mod, $setting['rewritestatus'])) {
$conf['modules'][$mod]['status'] = true;
} else {
$conf['modules'][$mod]['status'] = false;
}
}
}
$confs[$key] = $conf;
continue;
}
}
}
return $confs;
}
public function onCommonGetNavs($type = '') {
Cloud::loadFile('Service_SearchHelper');
$navtype = null;
switch($type) {
case 'footer':
$navtype = 1;
break;
case 'space':
$navtype = 2;
break;
case 'my':
$navtype = 3;
break;
case 'header':
$navtype = 0;
break;
}
$navs = $subNavs = array();
foreach(C::t('common_nav')->fetch_all_by_navtype($navtype) as $nav) {
if (!$nav['parentid']) {
$navs[$nav['id']] = Cloud_Service_SearchHelper::convertNav($nav);
} else {
$subNavs[$nav['id']] = $nav;
}
}
foreach($subNavs as $k => $v) {
$navs[$v['parentid']]['navs'][$v['id']] = Cloud_Service_SearchHelper::convertNav($v);
}
return $navs;
}
}

View File

@ -1,61 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Connect.php 28957 2012-03-20 12:32:24Z houdelei $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Connect extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onConnectSetConfig($data) {
global $_G;
$settingFields = array('connectappid', 'connectappkey');
if (!$data) {
return false;
}
$setting = C::t('common_setting')->fetch_all(array('connect'));
$connectData = (array)dunserialize($setting['connect']);
if (!is_array($connectData)) {
$connectData = array();
}
$settings = array();
foreach($data as $k => $v) {
if (in_array($k, $settingFields)) {
$settings[$k] = $v;
} else {
$connectData[$k] = $v;
}
}
if ($connectData) {
$settings['connect'] = $connectData;
}
if ($settings) {
C::t('common_setting')->update_batch($settings);
return true;
}
return false;
}
}

View File

@ -1,54 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Credit.php 34004 2013-09-18 05:06:47Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Credit extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onCreditGet($uId) {
global $_G;
$_G['setting']['myapp_credit'] = '';
if($_G['setting']['creditstransextra'][7]) {
$_G['setting']['myapp_credit'] = 'extcredits'.intval($_G['setting']['creditstransextra'][7]);
} elseif ($_G['setting']['creditstrans']) {
$_G['setting']['myapp_credit'] = 'extcredits'.intval($_G['setting']['creditstrans']);
}
if(empty($_G['setting']['myapp_credit'])) {
return 0;
}
$row = C::t('common_member_count')->fetch($uId);
return $row[$_G['setting']['myapp_credit']];
}
public function onCreditSign($uId) {
global $_G;
if($uId) {
return updatecreditbyaction('mobileoemdaylogin', $uId) ? 1 : 0;
}
return 0;
}
}

View File

@ -1,36 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: ErrorResponse.php 25510 2011-11-14 02:22:26Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_ErrorResponse {
public $errorCode = 0;
public $errorMessage = '';
public function __construct($errorCode, $errorMessage) {
$this->errorCode = $errorCode;
$this->errorMessage = $errorMessage;
}
function getCode() {
return $this->errorCode;
}
function getMessage() {
return $this->errorMessage;
}
function getResult() {
return null;
}
}

View File

@ -1,44 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Feed.php 25512 2011-11-14 02:31:42Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Feed extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onFeedPublishTemplatizedAction($uId, $appId, $titleTemplate, $titleData, $bodyTemplate, $bodyData, $bodyGeneral = '', $image1 = '', $image1Link = '', $image2 = '', $image2Link = '', $image3 = '', $image3Link = '', $image4 = '', $image4Link = '', $targetIds = '', $privacy = '', $hashTemplate = '', $hashData = '', $specialAppid=0) {
$res = $this->getUserSpace($uId);
if (!$res) {
return new Cloud_Service_Server_ErrorResponse('1', "User($uId) Not Exists");
}
$friend = ($privacy == 'public') ? 0 : ($privacy == 'friends' ? 1 : 2);
$images = array($image1, $image2, $image3, $image4);
$image_links = array($image1Link, $image2Link, $image3Link, $image4Link);
require_once libfile('function/feed');
$result = feed_add($appId, $titleTemplate, $titleData, $bodyTemplate, $bodyData, $bodyGeneral, $images, $image_links, $targetIds, $friend, $specialAppid, 1);
return $result;
}
}

View File

@ -1,47 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Friends.php 25693 2011-11-18 02:21:03Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Friends extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onFriendsGet($uIds, $friendNum = MY_FRIEND_NUM_LIMIT) {
$result = array();
if ($uIds) {
foreach($uIds as $uId) {
$result[$uId] = $this->_getFriends($uId, $friendNum);
}
}
return $result;
}
public function onFriendsAreFriends($uId1, $uId2) {
$friend = C::t('home_friend')->fetch_all_by_uid_fuid($uId1, $uId2);
$result = false;
if($friend = $friend[0]) {
$result = true;
}
return $result;
}
}

View File

@ -1,73 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Mobile.php 34063 2013-09-26 05:37:52Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Server_Restful');
class Cloud_Service_Server_Mobile extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onMobileLoginToken($deviceToken, $uid) {
return C::t("#mobile#common_devicetoken")->loginToken($deviceToken, $uid);
}
public function onMobileLogoutToken($deviceToken, $uid) {
return C::t("#mobile#common_devicetoken")->logoutToken($deviceToken);
}
public function onMobileClearToken($deviceToken) {
return C::t("#mobile#common_devicetoken")->clearToken($deviceToken);
}
public function onMobileModule() {
global $_G;
if(!$_G['setting']['plugins']['available']) {
return '';
}
require_once libfile('function/admincp');
loadcache('pluginlanguage_script', 1);
$return = array();
foreach($_G['setting']['plugins']['available'] as $pluginid) {
$row = array();
$modulefile = DISCUZ_ROOT.'./source/plugin/'.$pluginid.'/discuz_mobile_'.$pluginid.'.xml';
if(file_exists($modulefile)) {
$_GET['importtxt'] = @implode('', file($modulefile));
$pluginarray = getimportdata('Discuz! Mobile', 0, 1);
if($pluginarray) {
foreach($pluginarray as $name => $value) {
$row[] = array(
'name' => isset($_G['cache']['pluginlanguage_script'][$pluginid][$name]) ? $_G['cache']['pluginlanguage_script'][$pluginid][$name] : $name,
'logo' => $value['logo'],
'url' => preg_match('/^http:\/\//', $value['url']) ? $value['url'] : $_G['siteurl'].$value['url'],
);
}
}
}
$return[$pluginid] = $row;
}
return $return;
}
}

View File

@ -1,186 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: My.php 34000 2013-09-17 08:52:48Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Server_Restful');
class Cloud_Service_Server_My extends Cloud_Service_Server_Restful {
public $siteId;
public $siteKey;
public $timezone;
public $version;
public $charset;
public $language;
public $myAppStatus;
public $mySearchStatus;
protected static $_instance;
public static function getInstance($siteId, $siteKey, $timezone, $version, $charset, $language, $myAppStatus, $mySearchStatus) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($siteId, $siteKey, $timezone, $version, $charset, $language, $myAppStatus, $mySearchStatus);
}
return self::$_instance;
}
public function __construct($siteId, $siteKey, $timezone, $version, $charset, $language, $myAppStatus, $mySearchStatus) {
global $_G;
$this->siteId = $siteId;
$this->siteKey = $siteKey ? $siteKey : $_G['setting']['siteuniqueid'];
$this->timezone = $timezone;
$this->version = $version;
$this->charset = $charset;
$this->language = $language;
$this->myAppStatus = $myAppStatus;
$this->mySearchStatus = $mySearchStatus;
}
public function run() {
try {
$this->_checkRequest();
$response = $this->_processServerRequest();
} catch (Exception $e) {
$response = new Cloud_Service_Server_ErrorResponse($e->getCode(), $e->getMessage());
}
@ob_end_clean();
if(function_exists('ob_gzhandler')) {
@ob_start('ob_gzhandler');
} else {
@ob_start();
}
echo serialize($this->_formatLocalResponse($response));
exit;
}
protected function _checkRequest() {
global $_G;
if (empty($_G['setting']['siteuniqueid'])) {
throw new Cloud_Service_Server_RestfulException('Client SiteKey NOT Exists', 11);
} elseif (empty($this->siteKey)) {
throw new Cloud_Service_Server_RestfulException('My SiteKey NOT Exists', 12);
}
}
protected function _processServerRequest() {
$request = $_POST;
$module = $request['module'];
$method = $request['method'];
$params = $request['params'];
if (!$module || !$method) {
throw new Cloud_Service_Server_RestfulException('Invalid Method: ' . $method, 1);
}
$siteKey = $this->siteKey;
if ($request['ptnId']) {
$siteKey = md5($this->siteId . $this->siteKey . $request['ptnId'] . $request['ptnMethods']);
}
$sign = $this->_generateSign($module, $method, $params, $siteKey);
if ($sign != $request['sign']) {
throw new Cloud_Service_Server_RestfulException('Error Sign', 10);
}
if ($request['ptnId']) {
if ($allowMethods = explode(',', $request['ptnMethods'])) {
$manyouHelper = Cloud::loadClass('Service_ManyouHelper');
if (!in_array($manyouHelper->getMethodCode($module, $method), $allowMethods)) {
throw new Cloud_Service_Server_RestfulException('Method Not Allowed', 13);
}
}
}
$params = dunserialize($params);
return $this->_callLocalMethod($module, $method, $params);
}
protected function _generateSign($module, $method, $params, $siteKey) {
return md5($module . '|' . $method . '|' . $params . '|' . $siteKey);
}
protected function _callLocalMethod($module, $method, $params) {
if ($module == 'Batch' && $method == 'run') {
$response = array();
foreach($params as $param) {
try {
$response[] = $this->_callLocalMethod($param['module'], $param['method'], $param['params']);
} catch (Exception $e) {
$response[] = new Cloud_Service_Server_ErrorResponse($e->getCode, $e->getMessage());
}
}
return new Cloud_Service_Server_Response($response, 'Batch');
} else {
$methodName = $this->_getMethodName($module, $method);
$className = sprintf('Cloud_Service_Server_%s', ucfirst($module));
try {
$class = Cloud::loadClass($className);
} catch (Exception $e) {
throw new Cloud_Service_Server_RestfulException('Class not implemented: ' . $className, 2);
}
if (method_exists($class, $methodName)) {
$result = call_user_func_array(array(&$class, $methodName), (array)$params);
if ($result instanceof Cloud_Service_Server_ErrorResponse) {
return $result;
}
return new Cloud_Service_Server_Response($result);
} else {
throw new Cloud_Service_Server_RestfulException('Method not implemented: ' . $methodName, 2);
}
}
}
protected function _getMethodName($module, $method) {
return 'on' . ucfirst($module) . ucfirst($method);
}
protected function _formatLocalResponse($data) {
$utilService = Cloud::loadClass('Service_Util');
$res = array(
'my_version' => $utilService->getApiVersion(),
'timezone' => $this->timezone,
'version' => $this->version,
'charset' => $this->charset,
'language' => $this->language
);
if ($data instanceof Cloud_Service_Server_Response) {
if (is_array($data->result) && $data->getMode() == 'Batch') {
foreach($data->result as $result) {
if ($result instanceof Cloud_Service_Server_Response) {
$res['result'][] = $result->getResult();
} else {
$res['result'][] = array(
'errno' => $result->getCode(),
'errmsg' => $result->getMessage()
);
}
}
} else {
$res['result'] = $data->getResult();
}
} else {
$res['errCode'] = $data->getCode();
$res['errMessage'] = $data->getMessage();
}
return $res;
}
}

View File

@ -1,89 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Notifications.php 25828 2011-11-23 10:50:40Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Notifications extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onNotificationsSend($uId, $recipientIds, $appId, $notification) {
$this->getUserSpace($uId);
$result = array();
foreach($recipientIds as $recipientId) {
$val = intval($recipientId);
if($val) {
if ($uId) {
$result[$val] = notification_add($val, $appId, $notification) === null;
} else {
$result[$val] = notification_add($val, $appId, $notification, array(), 1) === null;
}
} else {
$result[$recipientId] = null;
}
}
return $result;
}
public function onNotificationsGet($uId) {
$notify = $result = array();
$result = array(
'message' => array(
'unread' => 0,
'mostRecent' => 0
),
'notification' => array(
'unread' => 0 ,
'mostRecent' => 0
),
'friendRequest' => array(
'uIds' => array()
)
);
$i = 0;
foreach(C::t('home_notification')->fetch_all_by_uid($uId, 1) as $value) {
$i++;
if(!$result['notification']['mostRecent']) $result['notification']['mostRecent'] = $value['dateline'];
}
$result['notification']['unread'] = $i;
loaducenter();
$pmarr = uc_pm_list($uId, 1, 1, 'newbox', 'newpm');
if($pmarr['count']) {
$result['message']['unread'] = $pmarr['count'];
$result['message']['mostRecent'] = $pmarr['data'][0]['dateline'];
}
$fIds = array();
foreach(C::t('home_friend_request')->fetch_all_by_uid($uId) as $value) {
if(!$result['friendRequest']['mostRecent']) {
$result['friendRequest']['mostRecent'] = $value['dateline'];
}
$fIds[] = $value['uid'];
}
$result['friendRequest']['uIds'] = $fIds;
return $result;
}
}

View File

@ -1,55 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Request.php 25522 2011-11-14 03:32:59Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Request extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onRequestSend($uId, $recipientIds, $appId, $requestName, $myml, $type) {
$now = time();
$result = array();
$type = ($type == 'request') ? 1 : 0;
$fields = array('typename' => $requestName,
'appid' => $appId,
'type' => $type,
'fromuid' => $uId,
'dateline' => $now
);
foreach($recipientIds as $key => $val) {
$hash = crc32($appId . $val . $now . rand(0, 1000));
$hash = sprintf('%u', $hash);
$fields['touid'] = intval($val);
$fields['hash'] = $hash;
$fields['myml'] = str_replace('{{MyReqHash}}', $hash, $myml);
$result[] = C::t('common_myinvite')->insert($fields, true);
$note = array(
'from_id' => $fields['touid'],
'from_idtype' => 'myappquery'
);
notification_add($fields['touid'], 'myapp', 'myinvite_request', $note);
}
return $result;
}
}

View File

@ -1,32 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Response.php 25510 2011-11-14 02:22:26Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Response {
public $result;
public $mode;
public function __construct($res, $mode = null) {
$this->result = $res;
$this->mode = $mode;
}
public function getResult() {
return $this->result;
}
public function getMode() {
return $this->mode;
}
}

View File

@ -1,569 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Restful.php 29263 2012-03-31 05:45:08Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('MY_FRIEND_NUM_LIMIT', 2000);
Cloud::loadFile('Service_Server_RestfulException');
Cloud::loadFile('Service_Server_Response');
Cloud::loadFile('Service_Server_ErrorResponse');
abstract class Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
protected function _myAddslashes($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = $this->_myAddslashes($val);
}
} else {
$string = ($string === null) ? null : addslashes($string);
}
return $string;
}
protected function _myStripslashes($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = $this->_myStripslashes($val);
}
} else {
$string = ($string === null) ? null : stripslashes($string);
}
return $string;
}
public function onUsersGetInfo($uIds, $fields = array(), $isExtra = false) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUsersGetFriendInfo($uId, $num = MY_FRIEND_NUM_LIMIT, $isExtra = false) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUsersGetExtraInfo($uIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUsersGetFormHash($uId, $userAgent) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onFriendsGet($uIds, $friendNum = MY_FRIEND_NUM_LIMIT) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onFriendsAreFriends($uId1, $uId2) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUserApplicationAdd($uId, $appId, $appName, $privacy, $allowSideNav, $allowFeed, $allowProfileLink, $defaultBoxType, $defaultMYML, $defaultProfileLink, $version, $displayMethod, $displayOrder = null, $userPanelArea = null, $canvasTitle = null, $isFullscreen = null , $displayUserPanel = null, $additionalStatus = null) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUserApplicationRemove($uId, $appIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUserApplicationUpdate($uId, $appIds, $appName, $privacy, $allowSideNav, $allowFeed, $allowProfileLink, $version, $displayMethod, $displayOrder = null, $userPanelArea = null, $canvasTitle = null, $isFullscreen = null, $displayUserPanel = null) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUserApplicationGetInstalled($uId) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUserApplicationGet($uId, $appIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSiteGetUpdatedUsers($num) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSiteGetUpdatedFriends($num) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSiteGetAllUsers($from, $num, $friendNum = MY_FRIEND_NUM_LIMIT) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSiteGetStat($beginDate = null, $num = null, $orderType = 'ASC') {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onFeedPublishTemplatizedAction($uId, $appId, $titleTemplate, $titleData, $bodyTemplate, $bodyData, $bodyGeneral = '', $image1 = '', $image1Link = '', $image2 = '', $image2Link = '', $image3 = '', $image3Link = '', $image4 = '', $image4Link = '', $targetIds = '', $privacy = '', $hashTemplate = '', $hashData = '', $specialAppid=0) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onNotificationsSend($uId, $recipientIds, $appId, $notification) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onNotificationsGet($uId) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onApplicationUpdate($appId, $appName, $version, $displayMethod, $displayOrder = null, $userPanelArea = null, $canvasTitle = null, $isFullscreen = null, $displayUserPanel = null, $additionalStatus = null) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onApplicationRemove($appIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onApplicationSetFlag($applications, $flag) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onCreditGet($uId) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onRequestSend($uId, $recipientIds, $appId, $requestName, $myml, $type) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onVideoAuthSetAuthStatus($uId, $status) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onVideoAuthAuth($uId, $picData, $picExt = 'jpg', $isReward = false) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetUserGroupPermissions($userGroupIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetUpdatedPosts($num, $lastPostIds = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchRemovePostLogs($pIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetPosts($pIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetNewPosts($num, $fromPostId = 0) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetAllPosts($num, $pId = 0, $orderType = 'ASC') {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchRecyclePosts($pIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetUpdatedThreads($num, $lastThreadIds = array(), $lastForumIds = array(), $lastUserIds = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchRemoveThreadLogs($lastThreadIds = array(), $lastForumIds = array(), $lastUserIds = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetThreads($tIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchRecycleThreads($tIds) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetNewThreads($num, $tId = 0) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetAllThreads($num, $tId = 0, $orderType = 'ASC') {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetForums($fIds = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchSetConfig($data = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchGetConfig($data = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onSearchSetHotWords($hotWords = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onCommonGetNav($type = '') {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onCloudGetApps($appName = '') {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onCloudSetApp($app) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onCloudOpenCloud() {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onCloudGetStats() {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onConnectSetConfig($data = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
public function onUnionAddAdvs($advs = array()) {
return new Cloud_Service_Server_ErrorResponse('2', 'Method not implemented.');
}
protected function _convertPrivacy($privacy, $u2m = false) {
$privacys = array(0=>'public', 1=>'friends', 2=>'someFriends', 3=>'me', 4=>'passwd');
$privacys = ($u2m) ? $privacys : array_flip($privacys);
return $privacys[$privacy];
}
protected function _spaceInfo2Extra($rows) {
$privacy = dunserialize($rows['privacy']);
$profilePrivacy = $privacy['profile'];
$res = array();
$map = array(
'graduateschool' => array('edu', 'school', true),
'company' => array('work', 'company', true),
'lookingfor' => array('trainwith', 'value'),
'interest' => array('interest', 'value'),
'bio' => array('intro', 'value')
);
foreach ($map as $dzKey => $myKeys) {
if ($rows[$dzKey]) {
$data = array('privacy' => $this->_convertPrivacy($profilePrivacy[$dzKey], true), $myKeys[1] => $rows[$dzKey]);
if ($myKeys[2]) {
$res[$myKeys[0]][] = $data;
} else {
$res[$myKeys[0]] = $data;
}
}
}
return $res;
}
protected function _friends2friends($friends , $num, $isOnlyReturnId = false, $isFriendIdKey = false) {
$i = 1;
$res = array();
foreach($friends as $friend) {
if($num && $i > $num) {
break;
}
if ($isOnlyReturnId) {
$row = $friend['fuid'];
} else {
$row = array('uId' => $friend['fuid'],
'handle' => $friend['fusername']
);
}
if ($isFriendIdKey) {
$res[$friend['fuid']] = $row;
} else {
$res[] = $row;
}
$i++;
}
return $res;
}
protected function _space2user($space) {
global $_G;
if(!$space) {
return array();
}
$founders = empty($_G['config']['admincp']['founder'])?array():explode(',', $_G['config']['admincp']['founder']);
$adminLevel = 'none';
if($space['groupid'] == 1 && $space['adminid'] == 1) {
$adminLevel = 'manager';
if($founders
&& (in_array($space['uid'], $founders)
|| (!is_numeric($space['username']) && in_array($space['username'], $founders)))) {
$adminLevel = 'founder';
}
}
$privacy = dunserialize($space['privacy']);
if (!$privacy) {
$privacy = array();
}
$profilePrivacy = array();
$map = array('affectivestatus' => 'relationshipStatus',
'birthday' => 'birthday',
'bloodtype' => 'bloodType',
'birthcity' => 'birthPlace',
'residecity' => 'residePlace',
'mobile' => 'mobile',
'qq' => 'qq',
'msn' => 'msn');
$privacys = dunserialize($space['privacy']);
foreach ($map as $dzKey => $myKey) {
$profilePrivacy[$myKey] = $this->_convertPrivacy($privacys['profile'][$dzKey], true);
}
$user = array(
'uId' => $space['uid'],
'handle' => $space['username'],
'action' => $space['action'],
'realName' => $space['realname'],
'realNameChecked' => $space['realname'] ? true : false,
'gender' => $space['gender'] == 1 ? 'male' : ($space['gender'] == 2 ? 'female' : 'unknown'),
'email' => $space['email'],
'qq' => $space['qq'],
'msn' => $space['msn'],
'birthday' => sprintf('%04d-%02d-%02d', $space['birthyear'], $space['birthmonth'], $space['birthday']),
'bloodType' => empty($space['bloodtype']) ? 'unknown' : $space['bloodtype'],
'relationshipStatus' => $space['affectivestatus'],
'birthProvince' => $space['birthprovince'],
'birthCity' => $space['birthcity'],
'resideProvince' => $space['resideprovince'],
'resideCity' => $space['residecity'],
'viewNum' => $space['views'],
'friendNum' => $space['friends'],
'feedfriend' => $space['feedfriend'],
'myStatus' => $space['spacenote'],
'lastActivity' => $space['lastactivity'],
'created' => $space['regdate'],
'credit' => $space['credits'],
'isUploadAvatar' => $space['avatarstatus'] ? true : false,
'adminLevel' => $adminLevel,
'homepagePrivacy' => $this->_convertPrivacy($privacy['view']['index'], true),
'profilePrivacyList' => $profilePrivacy,
'friendListPrivacy' => $this->_convertPrivacy($privacy['view']['friend'], true)
);
return $user;
}
protected function _getFriends($uId, $num = null) {
global $_G;
$fquery = C::t('home_friend')->fetch_all_by_uid($uId, 0, $num);
$friends = array();
foreach($fquery as $friend) {
$friends[] = $friend['fuid'];
}
return $friends;
}
public function refreshApplication($appId, $appName, $version, $userPanelArea, $canvasTitle, $isFullscreen, $displayUserPanel, $displayMethod, $narrow, $flag, $displayOrder, $additionalStatus) {
global $_G;
$fields = array();
if ($appName !== null && strlen($appName)>1) {
$fields['appname'] = $appName;
}
if ($version !== null) {
$fields['version'] = $version;
$fields['iconstatus'] = 0;
$fields['icondowntime'] = 0;
}
if ($displayMethod !== null) {
$fields['displaymethod'] = $displayMethod;
}
if ($narrow !== null) {
$fields['narrow'] = $narrow;
}
if ($flag !== null) {
$fields['flag'] = $flag;
}
if ($displayOrder !== null) {
$fields['displayorder'] = $displayOrder;
}
if ($userPanelArea !== null) {
$fields['userpanelarea'] = $userPanelArea;
}
if ($canvasTitle !== null) {
$fields['canvastitle'] = $canvasTitle;
}
if ($isFullscreen !== null) {
$fields['fullscreen'] = $isFullscreen;
}
if ($displayUserPanel !== null) {
$fields['displayuserpanel'] = $displayUserPanel;
}
if ($additionalStatus !== null) {
$fields['appstatus'] = $additionalStatus == 'new' ? 1 : ($additionalStatus == 'none' ? 0 : 2);
}
$result = false;
if($application = C::t('common_myapp')->fetch($appId)) {
$needUpdate = false;
foreach ($fields as $key => $value) {
if ($value != $application[$key]) {
$needUpdate = true;
break;
}
}
if ($needUpdate) {
C::t('common_myapp')->update($appId, $fields);
}
$result = true;
} else {
$fields['appid'] = $appId;
$result = C::t('common_myapp')->insert($fields, true);
$result = true;
}
require_once libfile('function/cache');
updatecache(array('myapp', 'userapp'));
return $result;
}
public function getUsers($uIds, $spaces = array(), $isReturnSpaceField = true, $isExtra = true, $isReturnFriends = false, $friendNum = 500, $isOnlyReturnFriendId = false, $isFriendIdKey = false) {
if (!$uIds) {
return array();
}
if (!is_array($uIds)) {
$uIds = (array)$uIds;
}
if (!$spaces) {
$spaces = C::t('common_member')->fetch_all($uIds);
}
$totalFriendsNum = 0;
foreach(C::t('common_member_count')->fetch_all($uIds) as $uid => $row) {
$spaces[$uid] = array_merge($spaces[$uid], $row);
$totalFriendsNum += $row['friends'];
}
foreach(C::t('common_member_status')->fetch_all($uIds) as $uid => $row) {
$spaces[$uid] = array_merge($spaces[$uid], $row);
}
$spaceFields = array();
if ($isReturnSpaceField) {
$spaceFields = C::t('common_member_profile')->fetch_all($uIds);
}
foreach(C::t('common_member_field_home')->fetch_all($uIds) as $uid => $row) {
$spaces[$uid] = array_merge($spaces[$uid], $row);
$spaceFields[$uid] = array_merge($spaceFields[$uid], $row);
}
$friends = array();
if ($isReturnFriends) {
if ($totalFriendsNum <= 10000) {
$query = C::t('home_friend')->fetch_all_by_uid($uIds);
foreach($query as $row) {
$friends[$row['uid']][] = $row;
}
} else {
foreach ($uIds as $uId) {
$query = C::t('home_friend')->fetch_all_by_uid($uId, 0 , $friendNum);
foreach($query as $row) {
$friends[$uId][] = $row;
}
}
}
}
$users = array();
foreach($uIds as $uId) {
$space = $spaces[$uId];
if ($isReturnSpaceField) {
$space = array_merge($spaceFields[$uId], $space);
}
$user = $this->_space2user($space);
if (!$user) {
continue;
}
if ($isExtra) {
$user['extra'] = $this->_spaceInfo2Extra($spaceFields[$uId]);
}
if ($isReturnFriends) {
$user['friends'] = $this->_friends2friends($friends[$uId], $friendNum, $isOnlyReturnFriendId, $isFriendIdKey);
}
$users[] = $user;
}
return $users;
}
public function getExtraByUsers($uIds) {
if (!$uIds) {
return array();
}
if (!is_array($uIds)) {
$uIds = (array)$uIds;
}
$spaceFields = array();
$spaceFields = C::t('common_member_profile')->fetch_all($uIds);
foreach(C::t('common_member_field_home')->fetch_all($uIds) as $uid => $row) {
$spaceFields[$uid] = array_merge($spaceFields[$uid], $row);
}
$users = array();
foreach($uIds as $uId) {
$user = array('uId' => $uId,
'extra' => $this->_spaceInfo2Extra($spaceFields[$uId]));
$users[] = $user;
}
return $users;
}
function getUserSpace($uId) {
global $_G;
$space = getuserbyuid($uId);
if (!$space['uid']) {
return false;
}
$_G['uid'] = $space['uid'];
$_G['username'] = $space['username'];
return true;
}
}

View File

@ -1,24 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: RestfulException.php 28702 2012-03-08 06:43:58Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_RestfulException extends Exception {
public function __construct($message, $code = 0) {
if ($message instanceof Exception) {
parent::__construct($message->getMessage(), intval($message->getCode()));
} else {
parent::__construct($message, intval($code));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,246 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Security.php 33923 2013-09-03 02:59:43Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Cloud::loadFile('Service_Server_Restful');
class Cloud_Service_Server_Security extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onSecuritySetEvilPost($data) {
$results = array();
foreach ($data as $evilPost) {
$results[] = $this->_handleEvilPost($evilPost['tid'], $evilPost['pid'], $evilPost['evilType'], $evilPost['evilLevel']);
}
return $results;
}
public function onSecuritySetEvilUser($data, $days = 1) {
$results = array();
foreach ($data as $evilUser) {
$results[] = $this->_handleEvilUser($evilUser['uid'], $evilUser['evilType'], $evilUser['evilLevel'], $days);
}
return $results;
}
protected function _handleEvilPost($tid, $pid, $evilType, $evilLevel = 1) {
include_once DISCUZ_ROOT.'./source/language/lang_admincp_cloud.php';
$securityService = Cloud::loadClass('Service_Security');
$securityService->writeLog($pid, 'pid');
$evilPost = C::t('#security#security_evilpost')->fetch($pid);
if (count($evilPost)) {
return true;
} else {
require_once libfile('function/delete');
require_once libfile('function/forum');
require_once libfile('function/post');
$data = array('pid' => $pid, 'tid' => $tid, 'evilcount' => 1, 'eviltype' => $evilType, 'createtime' => TIMESTAMP);
$post = get_post_by_pid($pid);
if (is_array($post) && count($post) > 0) {
if ($tid != $post['tid']) {
return false;
}
$thread = get_thread_by_tid($tid);
if ($post['first']) {
$data['type'] = 1;
if ($this->_checkThreadIgnore($tid)) {
return false;
}
C::t('#security#security_evilpost')->insert($data, false, true);
$this->_updateEvilCount('thread');
deletethread(array($tid), true, true, true);
updatemodlog($tid, 'DEL', 0, 1, $extend_lang['security_modreason']);
} else {
$data['type'] = 0;
if ($this->_checkPostIgnore($pid, $post)) {
return false;
}
C::t('#security#security_evilpost')->insert($data, false, true);
$this->_updateEvilCount('post');
deletepost(array($pid), 'pid', true, false, true);
}
if(!empty($post['authorid'])) {
$data = array('uid' => $post['authorid'], 'createtime' => TIMESTAMP);
C::t('#security#security_eviluser')->insert($data, false, true);
}
} else {
$data['operateresult'] = 2;
C::t('#security#security_evilpost')->insert($data, false, true);
}
if($evilLevel >= 5) {
$user = C::t('common_member')->fetch($post['authorid'], 0, 1);
$this->_handleBandUser($user, 1);
}
}
return true;
}
protected function _handleBandUser($user, $days = 1) {
$uid = $user['uid'];
if($this->_checkUserIgnore($uid)) {
return false;
}
require_once libfile('function/forum');
$setarr = array('groupid' => 4);
if($days) {
$days = !empty($days) ? TIMESTAMP + $days * 86400 : 0;
$days = $days > TIMESTAMP ? $days : 0;
if($days) {
$user['groupterms']['main'] = array('time' => $days, 'adminid' => $user['adminid'], 'groupid' => $user['groupid']);
$user['groupterms']['ext'][4] = $days;
C::t('common_member_field_forum')->update($uid, array('groupterms' => serialize($user['groupterms'])));
$setarr['groupexpiry'] = groupexpiry($user['groupterms']);
} else {
$setarr['groupexpiry'] = 0;
}
}
require_once libfile('function/misc');
return C::t('common_member')->update($uid, $setarr);
}
protected function _handleEvilUser($uid, $evilType, $evilLevel = 1, $days = 1) {
global $_G;
include_once DISCUZ_ROOT.'./source/language/lang_admincp_cloud.php';
$securityService = Cloud::loadClass('Service_Security');
$securityService->writeLog($uid, 'uid');
if($this->_checkUserIgnore($uid)) {
return false;
}
$user = C::t('common_member')->fetch($uid, 0, 1);
if(is_array($user)) {
$update = $this->_handleBandUser($user, $days);
if ($update) {
$_G['member']['username'] = 'SYSTEM';
savebanlog($user['username'], $user['groupid'], 4, 0, $extend_lang['security_modreason']);
}
}
$evilUser = C::t('#security#security_eviluser')->fetch($uid);
if (count($evilUser)) {
return true;
} else {
$data = array('uid' => $uid, 'evilcount' => 1, 'eviltype' => $evilType, 'createtime' => TIMESTAMP);
C::t('#security#security_eviluser')->insert($data, false, true);
$this->_updateEvilCount('member');
}
return true;
}
protected function _checkThreadIgnore($tid) {
if (!intval($tid)) {
return true;
}
require_once libfile('function/forum');
$checkFiled = array('highlight', 'displayorder', 'digest');
$thread = get_thread_by_tid($tid);
$checkResult = false;
$checkResult = $this->_checkBoardIgnore($thread['fid']);
$checkResult = $checkResult ? true : $this->_checkUserIgnore($thread['authorid']);
foreach ($checkFiled as $field) {
if ($thread[$field] > 0) {
$checkResult = true;
};
}
return $checkResult;
}
protected function _updateEvilCount($type) {
if (empty($type)) {
return false;
}
$settingKey = 'cloud_security_stats_' . $type;
$count = intval(C::t('common_setting')->fetch($settingKey));
C::t('common_setting')->update($settingKey, $count + 1);
}
protected function _checkPostIgnore($pid, $post) {
if (!intval($pid)) {
return true;
}
$checkResult = false;
$checkResult = $this->_checkBoardIgnore($post['fid']);
$checkResult = $checkResult ? true : $this->_checkUserIgnore($post['authorid']);
$postStick = C::t('forum_poststick')->count_by_pid($pid);
if ($checkResult || $postStick) {
$checkResult = true;
}
return $checkResult;
}
protected function _checkBoardIgnore($fid) {
global $_G;
$checkResult = false;
$whiteList = $_G['setting']['security_forums_white_list'];
$whiteList = is_array($whiteList) ? $whiteList : array();
if (in_array($fid, $whiteList)) {
$checkResult = true;
}
return $checkResult;
}
protected function _checkUserIgnore($uid) {
global $_G;
if (!intval($uid)) {
return true;
}
$whiteList = $_G['setting']['security_usergroups_white_list'];
$whiteList = is_array($whiteList) ? $whiteList : array();
$memberInfo = C::t('common_member')->fetch($uid, 0, 1);
$checkResult = false;
if (in_array($memberInfo['groupid'], $whiteList)) {
$checkResult = true;
}
return $checkResult;
}
}

View File

@ -1,133 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Site.php 29263 2012-03-31 05:45:08Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Site extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onSiteGetAllUsers($from, $userNum, $friendNum = 500, $isExtra) {
$result = array();
if ($userNum <= 0) {
$totalNum = C::t('common_member')->count();
$maxUId = C::t('common_member')->max_uid();
$result['totalNum'] = $totalNum;
$result['maxUId'] = $maxUId;
} else {
$spaces = C::t('common_member')->range_by_uid($from, $userNum);
$uIds = array_keys($spaces);
$users = $this->getUsers($uIds, $spaces, true, $isExtra, true, $friendNum, true);
$result['users'] = $users;
}
return $result;
}
public function onSiteGetUpdatedUsers($num) {
$totalNum = C::t('common_member_log')->count();
$users = array();
if ($totalNum) {
$deletedUsers = $userLogs = $uIds = array();
$undeletedUserIds = array();
foreach(C::t('common_member_log')->fetch_all_range($num) as $row) {
$uIds[] = $row['uid'];
if ($row['action'] == 'delete') {
$deletedUsers[] = array('uId' => $row['uid'],
'action' => $row['action'],
);
} else {
$undeletedUserIds[] = $row['uid'];
}
$userLogs[$row['uid']] = $row;
}
$updatedUsers = $this->getUsers($undeletedUserIds, false, true, true, false);
foreach($updatedUsers as $k => $v) {
$updatedUsers[$k]['action'] = $userLogs[$v['uId']]['action'];
$updatedUsers[$k]['updateType'] = 'all';
}
$users = array_merge($updatedUsers, $deletedUsers);
if ($uIds) {
C::t('common_member_log')->delete($uIds);
}
}
$result = array('totalNum' => $totalNum, 'users' => $users);
return $result;
}
public function onSiteGetUpdatedFriends($num) {
$friends = array();
$totalNum = C::t('home_friendlog')->count();
if ($totalNum) {
foreach(C::t('home_friendlog')->fetch_all_order_by_dateline(0, $num) as $friend) {
$friends[] = array('uId' => $friend['uid'],
'uId2' => $friend['fuid'],
'action' => $friend['action']
);
C::t('home_friendlog')->delete_by_uid_fuid($friend['uid'], $friend['fuid']);
}
}
return array('totalNum' => $totalNum, 'friends' => $friends);
}
public function onSiteGetStat($beginDate = null, $num = null, $orderType = 'ASC') {
$result = array();
$fields = array('login' => 'loginUserNum',
'doing' => 'doingNum',
'blog' => 'blogNum',
'pic' => 'photoNum',
'poll' => 'pollNum',
'event' => 'eventNum',
'share' => 'shareNum',
'thread' => 'threadNum',
'docomment' => 'doingCommentNum',
'blogcomment' => 'blogCommentNum',
'piccomment' => 'photoCommentNum',
'pollcomment' => 'pollCommentNum',
'eventcomment' => 'eventCommentNum',
'sharecomment' => 'shareCommentNum',
'pollvote' => 'pollUserNum',
'eventjoin' => 'eventUserNum',
'post' => 'postNum',
'wall' => 'wallNum',
'poke' => 'pokeNum',
'click' => 'clickNum',
);
foreach(C::t('common_stat')->fetch_all_by_daytime($beginDate, 0, $num, $orderType) as $row) {
$stat = array('date' => $row['daytime']);
foreach($row as $k => $v) {
if (array_key_exists($k, $fields)) {
$stat[$fields[$k]] = $v;
}
}
$result[] = $stat;
}
return $result;
}
}

View File

@ -1,38 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Storage.php 29263 2012-03-31 05:45:08Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Storage extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onStorageSetConfig($data) {
if ($data['xf_storage_enc_key']) {
$insert = array(
'skey' => 'xf_storage_enc_key',
'svalue' => $data['xf_storage_enc_key'],
);
C::t('common_setting')->insert($insert, 0, 1);
return true;
}
return false;
}
}

View File

@ -1,134 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Union.php 25702 2011-11-18 04:28:41Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Union extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onUnionAddAdvs($advs) {
$result = array();
if (is_array($advs)) {
foreach($advs as $advid => $adv) {
$data = $this->_addAdv($adv);
if($data === true) {
$result['succeed'][$advid] = $advid;
} else {
$result['failed'][$advid] = $data;
}
}
require_once libfile('function/cache');
updatecache('advs');
updatecache('setting');
} else {
$result['error'] = 'no adv';
}
return $result;
}
protected function _addAdv($adv) {
global $_G;
foreach($adv as $k => $v) {
$_GET[''.$k] = $v;
}
$type = $_GET['type'];
$advlibfile = libfile('adv/'.$type, 'class');
if (file_exists($advlibfile)) {
require_once $advlibfile;
} else {
return 'err_1';
}
$advclass = 'adv_'.$type;
$advclass = new $advclass;
$advnew = $_GET['advnew'];
$parameters = !empty($_GET['parameters']) ? $_GET['parameters'] : array();
if(@in_array('custom', $advnew['targets'])) {
$targetcustom = explode(',', $advnew['targetcustom']);
$advnew['targets'] = array_merge($advnew['targets'], $targetcustom);
}
$advclass->setsetting($advnew, $parameters);
$advnew['starttime'] = $advnew['starttime'] ? strtotime($advnew['starttime']) : 0;
$advnew['endtime'] = $advnew['endtime'] ? strtotime($advnew['endtime']) : 0;
if(!$advnew['title']) {
return 'err_2';
} elseif(strlen($advnew['title']) > 50) {
return 'err_3';
} elseif(!$advnew['style']) {
return 'err_4';
} elseif(!$advnew['targets']) {
return 'err_5';
} elseif($advnew['endtime'] && ($advnew['endtime'] <= TIMESTAMP || $advnew['endtime'] <= $advnew['starttime'])) {
return 'err_6';
} elseif(($advnew['style'] == 'code' && !$advnew['code']['html'])
|| ($advnew['style'] == 'text' && (!$advnew['text']['title'] || !$advnew['text']['link']))
|| ($advnew['style'] == 'image' && (!$_FILES['advnewimage'] && !$_GET['advnewimage'] || !$advnew['image']['link']))
|| ($advnew['style'] == 'flash' && (!$_FILES['advnewflash'] && !$_GET['advnewflash'] || !$advnew['flash']['width'] || !$advnew['flash']['height']))) {
return 'err_7';
}
$advid = C::t('common_advertisement')->insert(array('available' => 1, 'type' => $type), true);
if($advnew['style'] == 'image' || $advnew['style'] == 'flash') {
$advnew[$advnew['style']]['url'] = $_GET['advnew'.$advnew['style']];
}
$advnew['displayorder'] = isset($advnew['displayorder']) ? implode("\t", $advnew['displayorder']) : '';
$advnew['code'] = $this->_encodeAdvCode($advnew);
$advnew['parameters'] = serialize(array_merge(is_array($parameters) ? $parameters : array(), array('style' => $advnew['style']), $advnew['style'] == 'code' ? array() : $advnew[$advnew['style']], array('html' => $advnew['code']), array('displayorder' => $advnew['displayorder'])));
C::t('common_advertisement')->update($advid, array(
'title' => $advnew['title'],
'targets' => $advnew['targets'],
'parameters' => $advnew['parameters'],
'code' => $advnew['code'],
'starttime' => $advnew['starttime'],
'endtime' => $advnew['endtime']
));
return true;
}
protected function _encodeAdvCode($advnew) {
switch($advnew['style']) {
case 'code':
$advnew['code'] = $advnew['code']['html'];
break;
case 'text':
$advnew['code'] = '<a href="'.$advnew['text']['link'].'" target="_blank" '.($advnew['text']['size'] ? 'style="font-size: '.$advnew['text']['size'].'"' : '').'>'.$advnew['text']['title'].'</a>';
break;
case 'image':
$advnew['code'] = '<a href="'.$advnew['image']['link'].'" target="_blank"><img src="'.$advnew['image']['url'].'"'.($advnew['image']['height'] ? ' height="'.$advnew['image']['height'].'"' : '').($advnew['image']['width'] ? ' width="'.$advnew['image']['width'].'"' : '').($advnew['image']['alt'] ? ' alt="'.$advnew['image']['alt'].'"' : '').' border="0"></a>';
break;
case 'flash':
$advnew['code'] = '<embed width="'.$advnew['flash']['width'].'" height="'.$advnew['flash']['height'].'" src="'.$advnew['flash']['url'].'" type="application/x-shockwave-flash" wmode="transparent"></embed>';
break;
}
return $advnew['code'];
}
}

View File

@ -1,195 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: UserApplication.php 33052 2013-04-12 09:39:49Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_UserApplication extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onUserApplicationAdd($uId, $appId, $appName, $privacy, $allowSideNav, $allowFeed, $allowProfileLink, $defaultBoxType, $defaultMYML, $defaultProfileLink, $version, $displayMethod, $displayOrder = null, $userPanelArea = null, $canvasTitle = null, $isFullscreen = null , $displayUserPanel = null, $additionalStatus = null) {
global $_G;
$res = $this->getUserSpace($uId);
if (!$res) {
return new Cloud_Service_Server_ErrorResponse('1', "User($uId) Not Exists");
}
$row = C::t('home_userapp')->fetch_by_uid_appid($uId, $appId);
if ($row['appid']) {
$errCode = '170';
$errMessage = 'Application has been already added';
return new Cloud_Service_Server_ErrorResponse($errCode, $errMessage);
}
switch($privacy) {
case 'public':
$privacy = 0;
break;
case 'friends':
$privacy = 1;
break;
case 'me':
$privacy = 3;
break;
case 'none':
$privacy = 5;
break;
default:
$privacy = 0;
}
$narrow = ($defaultBoxType == 'narrow') ? 1 : 0;
$setarr = array('uid' => $uId,
'appid' => $appId,
'appname' => $appName,
'privacy' => $privacy,
'allowsidenav' => $allowSideNav,
'allowfeed' => $allowFeed,
'allowprofilelink' => $allowProfileLink,
'narrow' => $narrow
);
if ($displayOrder !== null) {
$setarr['displayorder'] = $displayOrder;
}
$maxMenuOrder = C::t('home_userapp')->fetch_max_menuorder_by_uid($uId);
$setarr['menuorder'] = ++$maxMenuOrder;
C::t('home_userapp')->insert($setarr);
$fields = array('uid' => $uId,
'appid' => $appId,
'profilelink' => $defaultProfileLink,
'myml' => $defaultMYML
);
$result = C::t('home_userappfield')->insert($fields, true);
updatecreditbyaction('installapp', $uId, array(), $appId);
require_once libfile('function/cache');
updatecache('userapp');
C::t('common_member_status')->update($uId, array('lastactivity' => TIMESTAMP), 'UNBUFFERED');
$displayMethod = ($displayMethod == 'iframe') ? 1 : 0;
$this->refreshApplication($appId, $appName, $version, $userPanelArea, $canvasTitle, $isFullscreen, $displayUserPanel, $displayMethod, $narrow, null, null, $additionalStatus);
return 1;
}
public function onUserApplicationRemove($uId, $appIds) {
$result = C::t('home_userapp')->delete_by_uid_appid($uId, $appIds);
C::t('home_userappfield')->delete_by_uid_appid($uId, $appIds);
updatecreditbyaction('installapp', $uId, array(), $appId, -1);
require_once libfile('function/cache');
updatecache('userapp');
return $result;
}
public function onUserApplicationUpdate($uId, $appIds, $appName, $privacy, $allowSideNav, $allowFeed, $allowProfileLink, $version, $displayMethod, $displayOrder = null, $userPanelArea = null, $canvasTitle = null, $isFullscreen = null, $displayUserPanel = null) {
switch($privacy) {
case 'public':
$privacy = 0;
break;
case 'friends':
$privacy = 1;
break;
case 'me':
$privacy = 3;
break;
case 'none':
$privacy = 5;
break;
default:
$privacy = 0;
}
$setarr = array(
'appname' => $appName,
'privacy' => $privacy,
'allowsidenav' => $allowSideNav,
'allowfeed' => $allowFeed,
'allowprofilelink' => $allowProfileLink
);
if ($displayOrder !== null) {
$setarr['displayorder'] = $displayOrder;
$setarr['menuorder'] = $displayOrder;
}
$result = C::t('home_userapp')->update_by_uid_appid($uId, $appIds, $setarr);
$displayMethod = ($displayMethod == 'iframe') ? 1 : 0;
if (is_array($appIds)) {
foreach($appIds as $appId) {
$this->refreshApplication($appId, $appName, $version, $userPanelArea, $canvasTitle, $isFullscreen, $displayUserPanel, $displayMethod, null, null, null, null);
}
}
return $result;
}
public function onUserApplicationGetInstalled($uId) {
$result = array();
foreach(C::t('home_userapp')->fetch_all_by_uid_appid($uId) as $userApp) {
$result[] = $userApp['appid'];
}
return $result;
}
public function onUserApplicationGet($uId, $appIds) {
$result = array();
foreach(C::t('home_userapp')->fetch_all_by_uid_appid($uId, $appIds) as $userApp) {
switch($userApp['privacy']) {
case 0:
$privacy = 'public';
break;
case 1:
$privacy = 'friends';
break;
case 3:
$privacy = 'me';
break;
case 5:
$privacy = 'none';
break;
default:
$privacy = 'public';
}
$result[] = array(
'appId' => $userApp['appid'],
'privacy' => $privacy,
'allowSideNav' => $userApp['allowsidenav'],
'allowFeed' => $userApp['allowfeed'],
'allowProfileLink' => $userApp['allowprofilelink'],
'displayOrder' => $userApp['displayorder']
);
}
return $result;
}
}

View File

@ -1,81 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Users.php 25756 2011-11-22 02:47:45Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_Users extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onUsersGetInfo($uIds, $fields = array(), $isExtra = false) {
$users = $this->getUsers($uIds, false, true, $isExtra, false);
$result = array();
if ($users) {
if ($fields) {
foreach($users as $key => $user) {
foreach($user as $k => $v) {
if (in_array($k, $fields)) {
$result[$key][$k] = $v;
}
}
}
}
}
if (!$result) {
$result = $users;
}
return $result;
}
public function onUsersGetFriendInfo($uId, $num = MY_FRIEND_NUM_LIMIT, $isExtra = false) {
$users = $this->getUsers(array($uId), false, true, $isExtra, true, $num, false, true);
$totalNum = C::t('home_friend')->count_by_uid($uId);
$friends = $users[0]['friends'];
unset($users[0]['friends']);
$result = array('totalNum' => $totalNum,
'friends' => $friends,
'me' => $users[0],
);
return $result;
}
public function onUsersGetExtraInfo($uIds) {
$result = $this->getExtraByUsers($uIds);
return $result;
}
public function onUsersGetFormHash($uId, $userAgent) {
global $_G;
$uId = intval($uId);
if (!$uId) {
return false;
}
$member = getuserbyuid($uId, 1);
$_G['username'] = $member['username'];
$_G['uid'] = $member['uid'];
$_G['authkey'] = md5($_G['config']['security']['authkey'] . $userAgent);
return formhash();
}
}

View File

@ -1,117 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: VideoAuth.php 28833 2012-03-14 08:42:59Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Server_VideoAuth extends Cloud_Service_Server_Restful {
protected static $_instance;
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function onVideoAuthSetAuthStatus($uId, $status) {
if ($status == 'approved') {
$status = 1;
updatecreditbyaction('videophoto', $uId);
} else if($status == 'refused') {
$status = 0;
} else {
$errCode = '200';
$errMessage = 'Error arguments';
return new Cloud_Service_Server_ErrorResponse($errCode, $errMessage);
}
$result = C::t('common_member')->update($uId, array('videophotostatus' => $status));
$memberVerify = C::t('common_member_verify')->fetch($uId);
if(!$memberVerify) {
C::t('common_member_verify')->insert(array('uid' => $uId, 'verify7' => $status));
} else {
C::t('common_member_verify')->update($uId, array('verify7' => $status));
}
return $result;
}
public function onVideoAuthAuth($uId, $picData, $picExt = 'jpg', $isReward = false) {
global $_G;
$res = $this->getUserSpace($uId);
if (!$res) {
return new Cloud_Service_Server_ErrorResponse('1', "User($uId) Not Exists");
}
$allowPicType = array('jpg','jpeg','gif','png');
if(in_array($picExt, $allowPicType)) {
$pic = base64_decode($picData);
if (!$pic || strlen($pic) == strlen($picData)) {
$errCode = '200';
$errMessage = 'Error argument';
return new Cloud_Service_Server_ErrorResponse($errCode, $errMessage);
}
$secret = md5($_G['timestamp']."\t".$_G['uid']);
$picDir = DISCUZ_ROOT . './data/avatar/' . substr($secret, 0, 1);
if (!is_dir($picDir)) {
if (!mkdir($picDir, 0777)) {
$errCode = '300';
$errMessage = 'Cannot create directory';
return new Cloud_Service_Server_ErrorResponse($errCode, $errMessage);
}
}
$picDir .= '/' . substr($secret, 1, 1);
if (!is_dir($picDir)) {
if (!@mkdir($picDir, 0777)) {
$errCode = '300';
$errMessage = 'Cannot create directory';
return new Cloud_Service_Server_ErrorResponse($errCode, $errMessage);
}
}
$picPath = $picDir . '/' . $secret . '.' . $picExt;
$fp = @fopen($picPath, 'wb');
if ($fp) {
if (fwrite($fp, $pic) !== FALSE) {
fclose($fp);
$upload = new discuz_upload();
if(!$upload->get_image_info($picPath)) {
@unlink($picPath);
} else {
C::t('common_member')->update($uId, array('videophotostatus' => 1));
$memberVerify = C::t('common_member_verify')->fetch($uId);
if(!$memberVerify) {
C::t('common_member_verify')->insert(array('uid' => $uId, 'verify7' => 1));
} else {
C::t('common_member_verify')->update($uId, array('verify7' => 1));
}
$fields = array('videophoto' => $secret);
$result = C::t('common_member_field_home')->update($uId, $fields);
if ($isReward) {
updatecreditbyaction('videophoto', $uId);
}
return $result;
}
}
fclose($fp);
}
}
$errCode = '300';
$errMessage = 'Video Auth Error';
return new Cloud_Service_Server_ErrorResponse($errCode, $errMessage);
}
}

View File

@ -1,171 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: Storage.php 29263 2012-03-31 05:45:08Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud_Service_Storage {
protected static $debug = 0;
protected static $_appStatus;
protected static $_siteId;
protected static $_encKey;
protected static $_util;
protected static $_instance;
public static function getInstance() {
global $_G;
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
$cloudAppService = Cloud::loadClass('Service_App');
self::$_appStatus = $cloudAppService->getCloudAppStatus('storage');
self::$_siteId = $_G['setting']['my_siteid'];
self::$_encKey = $_G['setting']['xf_storage_enc_key'];
self::$_util = Cloud::loadClass('Service_Util');
}
return self::$_instance;
}
public function ftnFormhash($specialadd = '') {
global $_G;
return substr(md5(substr($_G['timestamp'], 0, -4) . $_G['username'] . $_G['uid'] . $_G['authkey'] . self::$_encKey . $specialadd), 8, 8);
}
public function makeFtnSig($formhash) {
global $_G;
$openId = $this->getOpenId($_G['uid']);
$signGetx = array(
's_id' => self::$_siteId,
's_site_uid' => $_G['uid'],
'ts' => $_G['timestamp'],
'discuz_form_hash' => $formhash,
'site_url' => $_G['siteurl'],
'discuz_openid' => $openId,
);
ksort($signGetx);
return self::$_util->hashHmac('sha1', self::$_util->httpBuildQuery($signGetx, '', '&'), self::$_encKey);
}
public function makeIframeUrl($formhash) {
global $_G;
$openId = $this->getOpenId($_G['uid']);
$ftnGetx = array(
's_id' => self::$_siteId,
's_site_uid' => $_G['uid'],
'ts' => $_G['timestamp'],
'discuz_form_hash' => $formhash,
'site_url' => $_G['siteurl'],
'discuz_openid' => $openId,
);
$url = "http://cp.discuz.qq.com/storage/FTN?" . self::$_util->httpBuildQuery($ftnGetx, '', '&');
$url = $url.'&sign=' . $this->makeFtnSig($formhash);
return $url;
}
public function makeQQdlUrl($sha, $filename) {
global $_G;
$filename = trim($filename);
$filename = urlencode(diconv($filename,CHARSET,'UTF-8'));
$url = $_G['siteurl'] . $filename . '?&&txf_fid=' . $sha . '&siteid=' . self::$_siteId;
return 'qqdl://'.base64_encode($url);
}
public function makeDownloadurl($sha1, $filesize, $filename) {
global $_G;
$filename = trim($filename,' "'); // Discuz! 默认的filename两侧会加上 双引号
$filename = diconv($filename,CHARSET,'UTF-8');
$filename = $this->str2hex($filename);
$filename = strtolower($filename[1]);
$post = 'http://dz.xf.qq.com/ftn.php?v=1&&';
$k = self::$_util->hashHmac('sha1', sprintf('%s|%s|%s', $sha1, $_G['timestamp'], self::$_siteId), self::$_encKey);
$parm = array(
'site_id' => self::$_siteId,
't' => $_G['timestamp'],
'sha1' => $sha1,
'filesize' => $filesize,
'filename' => $filename,
'k' => $k,
'ip' => $_G['clientip']
);
return $post . self::$_util->httpBuildQuery($parm, '', '&&');
}
private function _joinParm($parm = array(),$joiner = '&'){
$andflag = '';
$return = '';
foreach($parm as $key => $value){
$value = urlencode($value);
$return .= $andflag.$key.'='.$value;
$andflag = $joiner;
}
return $return;
}
public function str2hex($str){
$length = strlen($str)*2;
return unpack('H' . $length, $str);
}
public function getOpenId($uid) {
$member = C::t('common_member')->fetch($uid);
if ($member['conisbind']) {
$connectInfo = C::t('#qqconnect#common_member_connect')->fetch($uid);
$openId = $connectInfo['conopenid'];
} else {
$openId = '';
}
return $openId;
}
public function checkAttachment($attach, $redirect = true) {
if (strpos($attach['attachment'], 'storage:') !== false) {
C::t('forum_attachment')->update_download($attach['aid']);
$sha1 = substr($attach['attachment'], -40);
$downloadUrl = $this->makeDownloadurl($sha1, $attach['filesize'], $attach['filename']);
if ($redirect) {
dheader('location:' . $downloadUrl);
exit;
} else {
return $downloadUrl;
}
}
}
public function getAttachmentByPids($pids) {
global $_G;
if (!is_array($pids)) {
$pids = explode(',', $pids);
}
include_once libfile('function/post');
$attachment = array();
foreach ($pids as $pid) {
$data = getattach($pid);
$attachment[] = $data['used'];
}
return $attachment;
}
}

View File

@ -1,16 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_setting.inc.php 33704 2013-08-06 06:45:48Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
dheader('location: '.ADMINSCRIPT.'?action=cloud&operation=manyou&anchor='.$_GET['ac']);
?>

View File

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<item id="Title"><![CDATA[Discuz! Plugin]]></item>
<item id="Data">
<item id="plugin">
<item id="available"><![CDATA[1]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="name"><![CDATA[漫游应用]]></item>
<item id="identifier"><![CDATA[manyou]]></item>
<item id="description"><![CDATA[]]></item>
<item id="datatables"><![CDATA[]]></item>
<item id="directory"><![CDATA[manyou/]]></item>
<item id="copyright"><![CDATA[Comsenz Inc.]]></item>
<item id="version"><![CDATA[1.0]]></item>
<item id="__modules">
<item id="0">
<item id="name"><![CDATA[admincp]]></item>
<item id="param"><![CDATA[ac=manage]]></item>
<item id="menu"><![CDATA[漫游应用管理]]></item>
<item id="url"><![CDATA[]]></item>
<item id="type"><![CDATA[3]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="displayorder"><![CDATA[0]]></item>
<item id="navtitle"><![CDATA[]]></item>
<item id="navicon"><![CDATA[]]></item>
<item id="navsubname"><![CDATA[]]></item>
<item id="navsuburl"><![CDATA[]]></item>
</item>
<item id="1">
<item id="name"><![CDATA[admincp]]></item>
<item id="param"><![CDATA[ac=base]]></item>
<item id="menu"><![CDATA[基本设置]]></item>
<item id="url"><![CDATA[]]></item>
<item id="type"><![CDATA[3]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="displayorder"><![CDATA[1]]></item>
<item id="navtitle"><![CDATA[]]></item>
<item id="navicon"><![CDATA[]]></item>
<item id="navsubname"><![CDATA[]]></item>
<item id="navsuburl"><![CDATA[]]></item>
</item>
</item>
</item>
<item id="version"><![CDATA[X3.2]]></item>
<item id="enablefile"><![CDATA[switch.php]]></item>
<item id="disablefile"><![CDATA[switch.php]]></item>
</item>
</root>

View File

@ -1,27 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: switch.php 33950 2013-09-05 02:17:27Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$appIdentifier = 'manyou';
$pluginid = intval($_GET['pluginid']);
require_once libfile('class/cloudregister');
if($operation == 'enable') {
new Cloud_Register($appIdentifier, $pluginid, 'appOpenFormView');
} elseif($operation == 'disable') {
new Cloud_Register($appIdentifier, $pluginid, 'appCloseReasonsView');
}

View File

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<item id="Title"><![CDATA[Discuz! Plugin]]></item>
<item id="Data">
<item id="plugin">
<item id="available"><![CDATA[1]]></item>
<item id="adminid"><![CDATA[1]]></item>
<item id="name"><![CDATA[漫游应用帖内展示]]></item>
<item id="identifier"><![CDATA[myapp]]></item>
<item id="description"><![CDATA[显示楼主最近安装过的应用。]]></item>
<item id="datatables"><![CDATA[]]></item>
<item id="directory"><![CDATA[myapp/]]></item>
<item id="copyright"><![CDATA[Comsenz Inc.]]></item>
<item id="version"><![CDATA[1.0]]></item>
<item id="__modules">
<item id="0">
<item id="name"><![CDATA[myapp]]></item>
<item id="menu"><![CDATA[]]></item>
<item id="url"><![CDATA[]]></item>
<item id="type"><![CDATA[11]]></item>
<item id="adminid"><![CDATA[0]]></item>
<item id="displayorder"><![CDATA[0]]></item>
<item id="navtitle"><![CDATA[]]></item>
<item id="navicon"><![CDATA[]]></item>
<item id="navsubname"><![CDATA[]]></item>
<item id="navsuburl"><![CDATA[]]></item>
</item>
</item>
</item>
<item id="version"><![CDATA[X3.2]]></item>
<item id="installfile"><![CDATA[install.php]]></item>
<item id="uninstallfile"><![CDATA[uninstall.php]]></item>
<item id="var">
<item id="0">
<item id="displayorder"><![CDATA[1]]></item>
<item id="title"><![CDATA[显示的数量]]></item>
<item id="description"><![CDATA[]]></item>
<item id="variable"><![CDATA[shownum]]></item>
<item id="type"><![CDATA[number]]></item>
<item id="value"><![CDATA[3]]></item>
<item id="extra"><![CDATA[]]></item>
</item>
<item id="1">
<item id="displayorder"><![CDATA[0]]></item>
<item id="title"><![CDATA[显示的标题]]></item>
<item id="description"><![CDATA[]]></item>
<item id="variable"><![CDATA[showtitle]]></item>
<item id="type"><![CDATA[text]]></item>
<item id="value"><![CDATA[<font style="font-weight:700">我玩的应用:</font><br/>]]></item>
<item id="extra"><![CDATA[]]></item>
</item>
<item id="2">
<item id="displayorder"><![CDATA[2]]></item>
<item id="title"><![CDATA[显示用户漫游动态]]></item>
<item id="description"><![CDATA[开启后帖子下方显示本用户的漫游动态]]></item>
<item id="variable"><![CDATA[showmyapp]]></item>
<item id="type"><![CDATA[radio]]></item>
<item id="value"><![CDATA[1]]></item>
<item id="extra"><![CDATA[]]></item>
</item>
</item>
</item>
</root>

View File

@ -1 +0,0 @@

View File

@ -1,27 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: install.php 25889 2011-11-24 09:52:20Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$sql = <<<EOF
DROP TABLE IF EXISTS pre_home_userapp_plying;
CREATE TABLE pre_home_userapp_plying (
`uid` mediumint(8) unsigned NOT NULL default '0',
`appid` text NOT NULL,
PRIMARY KEY (`uid`)
)ENGINE=MyISAM;
EOF;
runquery($sql);
$finish = TRUE;
?>

Some files were not shown because too many files have changed in this diff Show More