Example #1
0
    $cloudClient = new Discuz_Cloud_Client();
    if ($_G['setting']['my_app_status']) {
        manyouSync();
    }
    $res = $cloudClient->sync();
    if (!$res) {
        cpmsg('cloud_sync_failure', '', 'error', array('errCode' => $cloudClient->errno, 'errMessage' => $cloudClient->errmsg));
    } else {
        cpmsg('cloud_sync_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=siteinfo\'" class="lightlink">' . cplang('message_redirect') . '</a></p><script type="text/JavaScript">setTimeout("top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=siteinfo\'", 3000);</script>');
    }
} elseif (submitcheck('resetsubmit')) {
    if ($cloudstatus != 'cloud') {
        cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=open\'" class="lightlink">' . cplang('message_redirect') . '</a></p><script type="text/JavaScript">setTimeout("top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=open\'", 3000);</script>');
    }
    require_once DISCUZ_ROOT . '/api/manyou/Manyou.php';
    $cloudClient = new Discuz_Cloud_Client();
    $res = $cloudClient->resetKey();
    if (!$res) {
        cpmsg($cloudClient->errmsg, '', 'error');
    } else {
        $sId = $res['sId'];
        $sKey = $res['sKey'];
        DB::query("REPLACE INTO " . DB::table('common_setting') . " (`skey`, `svalue`)\r\n\t\t\t\t\tVALUES ('my_siteid', '{$sId}'), ('my_sitekey', '{$sKey}'), ('cloud_status', '1')");
        updatecache('setting');
        cpmsg('cloud_reset_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=siteinfo\'" class="lightlink">' . cplang('message_redirect') . '</a></p><script type="text/JavaScript">setTimeout("top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=siteinfo\'", 3000);</script>');
    }
} elseif (submitcheck('ipsubmit')) {
    $_G['gp_cloud_api_ip'] = trim($_G['gp_cloud_api_ip']);
    $_G['gp_my_ip'] = trim($_G['gp_my_ip']);
    if ($_G['setting']['cloud_api_ip'] != $_G['gp_cloud_api_ip'] || $_G['setting']['my_ip'] != $_G['gp_my_ip']) {
        DB::query("REPLACE INTO " . DB::table('common_setting') . " (`skey`, `svalue`)\r\n\t\t\t\t\tVALUES ('cloud_api_ip', '{$_G['gp_cloud_api_ip']}'), ('my_ip', '{$_G['gp_my_ip']}')");
Example #2
0
function upgrademanyou($cloudApiIp = '')
{
    global $_G;
    require_once DISCUZ_ROOT . '/api/manyou/Manyou.php';
    $cloudClient = new Discuz_Cloud_Client();
    $returnData = $cloudClient->sync();
    if ($cloudClient->errno == 1 && $cloudApiIp) {
        $cloudClient->setCloudIp($cloudApiIp);
        $returnData = $cloudClient->sync();
        if (!$cloudClient->errno) {
            DB::query("REPLACE INTO " . DB::table('common_setting') . " (`skey`, `svalue`)\r\n\t\t\t\t\t\tVALUES ('cloud_api_ip', '{$cloudApiIp}')");
        }
    }
    if ($cloudClient->errno) {
        $result = array('errCode' => $cloudClient->errno, 'errMessage' => $cloudClient->errmsg);
    } else {
        $result = array('errCode' => 0);
    }
    return $result;
}
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: cloud_siteinfo.php 23271 2011-06-29 04:33:39Z yexinhao $
 */
if (!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
    exit('Access Denied');
}
require_once DISCUZ_ROOT . '/api/manyou/Manyou.php';
$cloudClient = new Discuz_Cloud_Client();
if (submitcheck('syncsubmit')) {
    if ($cloudstatus != 'cloud') {
        cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=open\'" class="lightlink">' . cplang('message_redirect') . '</a></p><script type="text/JavaScript">setTimeout("top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=open\'", 3000);</script>');
    }
    if ($_G['setting']['my_app_status']) {
        manyouSync();
    }
    $res = $cloudClient->sync();
    if (!$res) {
        cpmsg('cloud_sync_failure', '', 'error', array('errCode' => $cloudClient->errno, 'errMessage' => $cloudClient->errmsg));
    } else {
        cpmsg('cloud_sync_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=siteinfo\'" class="lightlink">' . cplang('message_redirect') . '</a></p><script type="text/JavaScript">setTimeout("top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=siteinfo\'", 3000);</script>');
    }
} elseif (submitcheck('resetsubmit')) {
    if ($cloudstatus != 'cloud') {
        cpmsg('cloud_open_first', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=open\'" class="lightlink">' . cplang('message_redirect') . '</a></p><script type="text/JavaScript">setTimeout("top.location = \'' . ADMINSCRIPT . '?frames=yes&action=cloud&operation=open\'", 3000);</script>');
    }
    $res = $cloudClient->resetKey();
     $url = parse_url($_G['gp_connectnew']['like_url']);
     if (!preg_match('/\\.qq\\.com$/i', $url['host'])) {
         cpmsg('connect_like_url_error', '', 'error');
     }
 }
 if ($_G['gp_connectnew']['like_allow'] && $_G['gp_connectnew']['like_url'] === '') {
     cpmsg('connect_like_url_miss', '', 'error');
 }
 $_G['gp_connectnew'] = array_merge($setting['connect'], $_G['gp_connectnew']);
 $_G['gp_connectnew']['like_url'] = $_G['gp_connectnew']['like_qq'] ? 'http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F' . $_G['gp_connectnew']['like_qq'] . '&width=100&height=21&type=button_num' : '';
 $_G['gp_connectnew']['turl_code'] = '';
 $connectnew = addslashes(serialize(dstripslashes($_G['gp_connectnew'])));
 $regconnectnew = !$setting['connect']['allow'] && $_G['gp_connectnew']['allow'] ? 1 : $setting['regconnect'];
 DB::query("REPLACE INTO " . DB::table('common_setting') . " (`skey`, `svalue`) VALUES\r\n\t\t\t('regconnect', '{$regconnectnew}'),\r\n\t\t\t('connect', '{$connectnew}')");
 require_once DISCUZ_ROOT . './api/manyou/Manyou.php';
 $client = new Discuz_Cloud_Client();
 $res = $client->connectSync($_G['gp_connectnew']['like_qq'], $_G['gp_connectnew']['turl_qq']);
 if ($client->errno) {
     $res = array('status' => false, 'msg' => cplang('qqgroup_msg_remote_exception', array('errmsg' => $client->errmsg, 'errno' => $client->errno)));
 } elseif (!is_array($res)) {
     $res = array('status' => false, 'msg' => 'qqgroup_msg_remote_error');
 }
 if ($res['msg']) {
     cpmsg($res['msg'], '', 'error');
 }
 if ($res['mblogCode']) {
     $_G['gp_connectnew']['turl_code'] = $res['mblogCode'];
     $connectnew = addslashes(serialize(dstripslashes($_G['gp_connectnew'])));
     DB::query("REPLACE INTO " . DB::table('common_setting') . " (`skey`, `svalue`) VALUES ('connect', '{$connectnew}')");
 }
 updatecache(array('setting', 'fields_register', 'fields_connect_register'));
Example #5
0
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']);
    }
    require_once DISCUZ_ROOT . './api/manyou/Manyou.php';
    $client = new Discuz_Cloud_Client();
    $res = $client->QQGroupMiniportal($topic, $normal, $gIds);
    if ($client->errno) {
        if ($client->errno == 1) {
            $res = array('status' => false, 'msg' => cplang('qqgroup_msg_unknown_dns'));
        } else {
            $res = array('status' => false, 'msg' => cplang('qqgroup_msg_remote_exception', array('errmsg' => $client->errmsg, 'errno' => $client->errno)));
        }
    } elseif (!is_array($res)) {
        $res = array('status' => false, 'msg' => cplang('qqgroup_msg_remote_error'));
    }
    return $res;
}