예제 #1
0
function insenz_register($type)
{
    global $insenz, $db, $tablepre, $_DCACHE, $boardurl, $timestamp, $authkey, $discuz_uid, $discuz_user, $response;
    checkip();
    if ($type == 1) {
        @extract($insenz['profile']);
        foreach (array('username', 'password', 'name', 'idcard', 'email1', 'email2', 'qq', 'msn', 'tel1', 'tel2', 'tel3', 'mobile', 'fax1', 'fax2', 'fax3', 'country', 'province', 'city', 'address', 'postcode', 'alipay') as $item) {
            ${$item} = stripslashes(${$item});
        }
    } else {
        $username = $insenz['profile']['username'];
        $password = $insenz['profile']['password'];
    }
    $insenz['notify'] = is_array($insenz['notify']) ? $insenz['notify'] : array(2);
    $insenz['hardadstatus'] = is_array($insenz['hardadstatus']) ? $insenz['hardadstatus'] : array(1, 2, 3, 4, 5);
    $query = $db->query("SELECT COUNT(*) FROM {$tablepre}members");
    $members = $db->result($query, 0);
    $query = $db->query("SELECT COUNT(*) FROM {$tablepre}members WHERE posts>0");
    $post_members = $db->result($query, 0);
    $query = $db->query("SELECT COUNT(*) FROM {$tablepre}threads WHERE displayorder>='0'");
    $threads = $db->result($query, 0);
    $query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts WHERE invisible='0'");
    $posts = $db->result($query, 0);
    $date = getdate($timestamp);
    $yesterday_end = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']);
    $lastweek_start = $yesterday_end - 7 * 86400;
    $lastweek_pertopics = $lastweek_perposts = $forumstats = array();
    $query = $db->query("SELECT DISTINCT(fid) AS fid, COUNT(tid) AS topics FROM {$tablepre}threads WHERE dateline BETWEEN {$lastweek_start} AND {$yesterday_end} GROUP BY fid ORDER BY topics DESC");
    while ($p = $db->fetch_array($query)) {
        $lastweek_pertopics[$p['fid']] = ceil($p['topics'] / 7);
    }
    $query = $db->query("SELECT DISTINCT(fid) AS fid, COUNT(pid) AS posts FROM {$tablepre}posts WHERE dateline BETWEEN {$lastweek_start} AND {$yesterday_end} GROUP BY fid ORDER BY posts DESC");
    while ($p = $db->fetch_array($query)) {
        $lastweek_perposts[$p['fid']] = ceil($p['posts'] / 7);
    }
    $query = $db->query("SELECT f.fid, f.fup, f.type, f.name, f.threads, f.posts, f.displayorder, f.status, f.simple, ff.description, ff.redirect FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff ON f.fid=ff.fid");
    while ($forum = $db->fetch_array($query)) {
        $fid = $forum['fid'];
        unset($forum['fid']);
        $forum['lastweek_pertopics'] = intval($lastweek_pertopics[$fid]);
        $forum['lastweek_perposts'] = intval($lastweek_perposts[$fid]);
        $forumstats[$fid] = $forum;
    }
    $postdata = '<cmd id="register"><handle>' . insenz_convert($username) . '</handle>
		<passwd>' . $password . '</passwd>';
    if ($type == 1) {
        $postdata .= '<name>' . insenz_convert($name) . '</name>
			<idcard>' . $idcard . '</idcard>
			<tel>' . $tel1 . '-' . $tel2 . '-' . $tel3 . '</tel>
			<mobile>' . $mobile . '</mobile>
			<fax>' . $fax1 . '-' . $fax2 . '-' . $fax3 . '</fax>
			<email>' . $email1 . '</email>
			<email2>' . $email2 . '</email2>
			<qq>' . $qq . '</qq>
			<msn>' . $msn . '</msn>
			<alipay>' . $alipay . '</alipay>
			<country>' . $country . '</country>
			<province>' . $province . '</province>
			<city>' . $city . '</city>
			<addr>' . insenz_convert($address) . '</addr>
			<postcode>' . $postcode . '</postcode>';
    }
    $postdata .= '<url>' . $boardurl . '</url>
		<s_key>' . md5($authkey . 'Discuz!INSENZ') . '</s_key>
		<bbname>' . insenz_convert($_DCACHE['settings']['bbname']) . '</bbname>
		<members>' . $members . '</members>
		<post_members>' . $post_members . '</post_members>
		<topics>' . $threads . '</topics>
		<posts>' . $posts . '</posts>
		<softadstatus>' . intval($insenz['softadstatus']) . '</softadstatus>
		<notify>' . implode(',', $insenz['notify']) . '</notify>
		<autoextend>' . intval($insenz['autoextend']) . '</autoextend>
		<hardadstatus>' . implode(',', $insenz['hardadstatus']) . '</hardadstatus>
		<relatedadstatus>' . intval($insenz['relatedadstatus']) . '</relatedadstatus>
		<virtualforumstatus>' . intval($insenz['virtualforumstatus']) . '</virtualforumstatus>';
    foreach ($forumstats as $fid => $forum) {
        $postdata .= '<board>
			<board_id>' . $fid . '</board_id>
			<parent_id>' . $forum['fup'] . '</parent_id>
			<board_type>' . $forum['type'] . '</board_type>
			<name>' . insenz_convert($forum['name']) . '</name>
			<topics>' . $forum['threads'] . '</topics>
			<posts>' . $forum['posts'] . '</posts>
			<lastweek_pertopics>' . $forum['lastweek_pertopics'] . '</lastweek_pertopics>
			<lastweek_perposts>' . $forum['lastweek_perposts'] . '</lastweek_perposts>
			<description>' . insenz_convert($forum['description']) . '</description>
			<status>' . $forum['status'] . '</status>
			<simple>' . $forum['simple'] . '</simple>
			<redirect>' . insenz_convert($forum['redirect']) . '</redirect>
			<displayorder>' . $forum['displayorder'] . '</displayorder></board>';
    }
    $postdata .= '<type>' . ($type == 1 ? 'register' : 'bind') . '</type></cmd>';
    unset($insenz['siteid']);
    $response = insenz_request($postdata);
    if ($response['status']) {
        insenz_alert($response['data']);
    } else {
        $response = $response['data'];
    }
    $status = $response['response'][0]['status'][0]['VALUE'];
    if ($status == 0) {
        $insenz['authkey'] = $response['response'][0]['authkey'][0]['VALUE'];
        $insenz['siteid'] = $response['response'][0]['site_id'][0]['VALUE'];
        $insenz['uid'] = $discuz_uid;
        $insenz['username'] = $discuz_userss;
        insenz_updatesettings();
        unset($insenz['profile'], $insenz['step']);
        $db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '" . addslashes(serialize($insenz)) . "')");
        require_once DISCUZ_ROOT . './include/cache.func.php';
        updatecache('settings');
        insenz_cpmsg('insenz_register_succeed');
    } else {
        $response['reason'] = insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0);
        unset($insenz['authkey'], $insenz['siteid']);
        $db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '" . addslashes(serialize($insenz)) . "')");
        insenz_alert('insenz_register_failed');
    }
}
예제 #2
0
                    showtype('', 'bottom');
                    echo '<br /><center><input type="submit" class="button" name="bindingsubmit" value="' . $lang['insenz_binding_top'] . '" onclick="this.form.target=\'binding\';"><iframe name="binding" style="display: none"></iframe> &nbsp; <input type="button" class="button" value="' . $lang['cancel'] . '" onclick="window.location=\'admincp.php?action=insenz\'"></center></form>';
                } else {
                    $insenz['profile']['username'] = htmlspecialchars($username);
                    $insenz['profile']['password'] = htmlspecialchars($password);
                    $softadstatus = $softadstatus1 ? $softadstatus2 ? 2 : 1 : 0;
                    $softadstatus && checkmasks();
                    $hardadstatus = is_array($hardadstatus) ? array_keys($hardadstatus) : array();
                    $msgtoid = 0;
                    if ($softadstatus && is_array($notify) && $notify[1]) {
                        if (empty($msgto)) {
                            insenz_alert('insenz_msgtonone', 'msgto');
                        } else {
                            $query = $db->query("SELECT uid FROM {$tablepre}members WHERE username='******'");
                            if (!($msgtoid = $db->result($query, 0))) {
                                insenz_alert('insenz_msgtonone', 'msgto');
                            }
                        }
                    }
                    foreach (array('softadstatus', 'hardadstatus', 'relatedadstatus', 'notify', 'msgtoid', 'autoextend', 'virtualforumstatus') as $item) {
                        $insenz[$item] = ${$item};
                    }
                    insenz_register(!empty($type) && $type == 2 ? '2' : '3');
                }
            }
        }
    } else {
        insenz_shownav('insenz_nav_regorbind');
        //showtips('insenz_tips_register');
        echo '<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="tableborder">
			<tr class="header"><td colspan="2">' . $lang['insenz_nav_regorbind'] . '</td></tr>