function insenz_respond($data, $status = 1, $force = 0)
{
    global $insenz, $timestamp;
    @(include_once DISCUZ_ROOT . './discuz_version.php');
    $authkey = !empty($insenz['authkey']) && !$force ? $insenz['authkey'] : 'Discuz!INSENZ';
    $t_hex = sprintf("%08x", $timestamp);
    $postdata = '<?xml version="1.0" encoding="UTF' . '-8"?>' . '<response insenz_version="' . INSENZ_VERSION . '" discuz_version="' . DISCUZ_VERSION . ' - ' . DISCUZ_RELEASE . '">' . ($status ? "<status>1</status><reason>{$data}</reason>" : $data) . '</response>';
    echo insenz_authcode($t_hex . md5($authkey . $postdata . $t_hex) . $postdata, 'ENCODE', $authkey);
    exit;
}
示例#2
0
$feedpostnum = $thread['replies'] > $ppp ? $ppp : ($thread['replies'] ? $thread['replies'] : 1);
$upnavlink = 'forumdisplay.php?fid=' . $fid . ($extra ? '&amp;' . preg_replace("/^(&amp;)*/", '', $extra) : '');
$navigation = ' &raquo; <a href="' . $upnavlink . '">' . (strip_tags($forum['name']) ? strip_tags($forum['name']) : $forum['name']) . '</a> &raquo; ' . $thread['subject'];
if ($thread['digest'] == '-2') {
    $campaign = $db->fetch_first("SELECT id, type, status, url, autoupdate, lastupdated FROM {$tablepre}campaigns WHERE tid='{$tid}'");
    if (!$campaign || $campaign['status'] != 2) {
        showmessage('thread_nonexistence');
    }
    $insenz = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='insenz'");
    $insenz = $insenz ? unserialize($insenz) : array();
    if (empty($insenz['authkey'])) {
        showmessage('thread_nonexistence');
    }
    require_once DISCUZ_ROOT . './include/insenz.func.php';
    $member = $db->fetch_first("SELECT regdate FROM {$tablepre}members WHERE uid='{$discuz_uid}'");
    $iframeurl = $campaign[url] . "siteid={$insenz['siteid']}&cid={$campaign['id']}&s=" . urlencode(insenz_authcode("sitename={$bbname}&siteurl={$boardurl}&username={$discuz_userss}&uid={$discuz_uid}&email={$email}&grouptitle={$grouptitle}&regdate={$member['regdate']}&ppp={$ppp}&tid={$tid}", 'ENCODE', $insenz['authkey'])) . '&' . $_SERVER['QUERY_STRING'];
    $update = $campaign['autoupdate'] && $timestamp - $campaign['lastupdated'] < 600 ? FALSE : TRUE;
    include template('viewthread_iframe');
    exit;
}
$navtitle = $thread['subject'] . ' - ' . strip_tags($forum['name']);
if ($forum['type'] == 'sub') {
    $fup = $sdb->fetch_first("SELECT fid, name FROM {$tablepre}forums WHERE fid='{$forum['fup']}'");
    $navigation = '&raquo; <a href="forumdisplay.php?fid=' . $fup['fid'] . '">' . (strip_tags($fup['name']) ? strip_tags($fup['name']) : $fup['name']) . '</a> ' . $navigation;
    $navtitle = $navtitle . ' - ' . strip_tags($fup['name']);
}
$navtitle .= ' - ';
$forum['typemodels'] = $forum['typemodels'] ? unserialize($forum['typemodels']) : array();
$threadsort = isset($forum['threadsorts']['types'][$thread['sortid']]) ? 1 : 0;
$typetemplate = $tagscript = '';
$optiondata = $optionlist = array();
示例#3
0
function insenz_request($data, $return = TRUE, $fp = '')
{
    global $insenz, $timestamp, $msglang;
    @(include_once DISCUZ_ROOT . './discuz_version.php');
    $authkey = !empty($insenz['authkey']) ? $insenz['authkey'] : 'Discuz!INSENZ';
    $t_hex = sprintf("%08x", $timestamp);
    $postdata = '<?xml version="1.0" encoding="UTF' . '-8"?><request insenz_version="' . INSENZ_VERSION . '" discuz_version="' . DISCUZ_VERSION . ' - ' . DISCUZ_RELEASE . '">' . $data . '</request>';
    $postdata = insenz_authcode($t_hex . md5($authkey . $postdata . $t_hex) . $postdata, 'ENCODE', $authkey);
    if (!$fp && !($fp = @fsockopen($insenz['host'], 80))) {
        if (!$return) {
            return;
        } else {
            return array('status' => 1, 'data' => $msglang['insenz_connect_failed']);
        }
    }
    $insenz['siteid'] = intval($insenz['siteid']);
    @fwrite($fp, "POST http://{$insenz['url']}/discuz.php?s_id={$insenz['siteid']} HTTP/1.0\r\n");
    @fwrite($fp, "Host: {$insenz['host']}\r\n");
    @fwrite($fp, "Content-Type: file\r\n");
    @fwrite($fp, "Content-Length: " . strlen($postdata) . "\r\n\r\n");
    @fwrite($fp, $postdata);
    if (!$return) {
        @fclose($fp);
        return;
    }
    $res = '';
    $isheader = 1;
    while (!feof($fp)) {
        $buffer = @fgets($fp, 1024);
        if (!$isheader) {
            $res .= $buffer;
        } elseif (trim($buffer) == '') {
            $isheader = 0;
        }
    }
    @fclose($fp);
    if (empty($res)) {
        return array('status' => 1, 'data' => $msglang['insenz_connect_failed']);
    }
    if (!($response = insenz_authcode($res, 'DECODE', $authkey))) {
        return array('status' => 1, 'data' => $msglang['insenz_transport_failed']);
    }
    $checkKey = substr($response, 0, 40);
    $response = substr($response, 40);
    $t_hex = substr($checkKey, 0, 8);
    $t = base_convert($t_hex, 16, 10);
    if (abs($timestamp - $t) > 1200) {
        return array('status' => 1, 'data' => $msglang['insenz_connect_timeout']);
    } elseif ($checkKey != $t_hex . md5($authkey . $response . $t_hex)) {
        return array('status' => 1, 'data' => 'Invalid Key or Data');
    }
    require_once DISCUZ_ROOT . './include/xmlparser.class.php';
    $xmlparse = new XMLParser();
    $xmlparseddata = $xmlparse->getXMLTree($response);
    if (!is_array($xmlparseddata) || !is_array($xmlparseddata['response'])) {
        return array('status' => 1, 'data' => $msglang['insenz_transport_failed']);
    }
    return array('status' => 0, 'data' => $xmlparseddata);
}
示例#4
0
function insenz_request($script, $data)
{
    global $timestamp, $insenz;
    @(include_once DISCUZ_ROOT . './discuz_version.php');
    $authkey = $insenz['authkey'];
    $t_hex = sprintf("%08x", $timestamp);
    $postdata = '<?xml version="1.0" encoding="UTF' . '-8"?><request insenz_version="' . INSENZ_VERSION . '" discuz_version="' . DISCUZ_VERSION . ' - ' . DISCUZ_RELEASE . '">' . $data . '</request>';
    $postdata = insenz_authcode($t_hex . md5($authkey . $postdata . $t_hex) . $postdata, 'ENCODE', $authkey);
    if (!($fp = @fsockopen($insenz['host'], 80))) {
        exit;
    }
    @fwrite($fp, "POST http://{$insenz['url']}/{$script}?s_id={$insenz['siteid']} HTTP/1.0\r\n");
    @fwrite($fp, "Host: {$insenz['host']}\r\n");
    @fwrite($fp, "Content-Type: file\r\n");
    @fwrite($fp, "Content-Length: " . strlen($postdata) . "\r\n\r\n");
    @fwrite($fp, $postdata);
    $res = '';
    $isheader = 1;
    while (!feof($fp)) {
        $buffer = @fgets($fp, 1024);
        if (!$isheader) {
            $res .= $buffer;
        } elseif (trim($buffer) == '') {
            $isheader = 0;
        }
    }
    @fclose($fp);
    if (empty($res)) {
        exit;
    }
    if (!($response = insenz_authcode($res, 'DECODE', $authkey))) {
        exit;
    }
    $checkKey = substr($response, 0, 40);
    $response = substr($response, 40);
    $t_hex = substr($checkKey, 0, 8);
    $t = base_convert($t_hex, 16, 10);
    if (abs($timestamp - $t) > 1200) {
        exit;
    } elseif ($checkKey != $t_hex . md5($authkey . $response . $t_hex)) {
        exit;
    }
    require_once DISCUZ_ROOT . './include/xmlparser.class.php';
    $xmlparse = new XMLParser();
    $xmlparseddata = $xmlparse->getXMLTree($response);
    unset($response);
    if (!is_array($xmlparseddata) || !is_array($xmlparseddata['response'])) {
        exit;
    }
    return $xmlparseddata['response'];
}