修改论坛密码同时修改游戏密码

Discuz论坛

本插件作用为注册论坛帐号的同时,程序自动注册游戏帐号

[复制到剪切板]
CODE:
修改config.inc.php
查找

本帖隐藏的内容需要回复才可以浏览
$admincp
['dbimport'] = 1;// 是否允许后台恢复论坛数据1=是 0=否[安全]
复制代码在其后面插入 // [CH] 99game_Ascent_For_Discuz系列数据库配置 By 99GameTeam_Whads

$dbhost1 'localhost';// MYSQL服务器地址

$dbuser1 'root';// 数据库用户名

$dbpw1 '99game.org';// 数据库密码

$dbname1 'as_character';// 帐号数据库

// [CH] 99game_Ascent_For_Discuz系列注册激活配置 By 99GameTeam_Whads

$Ascentgm 0;// 注册时赠送的游戏权限 az=GM权限 0=普通权限

$Ascentvip 0;// 注册时赠送的会员等级

$Ascentintegral 0;// 注册时赠送的游戏积分值

$Ascentflags 8;//注册时是否为燃烧的远征帐户 0=普通帐户 8=燃烧远征帐户
复制代码修改include\common.inc.php
查找 $dbuser 
$dbpw $dbname $pconnect NULL;
复制代码在其后面加入 $db1 = new dbstuff;

$db1->connect($dbhost1$dbuser1$dbpw1$dbname1);

$dbuser1 $dbpw1 $dbname1 NULL;
复制代码修改register.php
查找 $password 
md5($password);
复制代码在其前面插入 $pw $password;
复制代码查找 $db->query("INSERT INTO {$tablepre}members (username, password, secques, gender, adminid, groupid, regip, regdate, lastvisit, lastactivity, posts, credits, extcredits1, extcredits2, extcredits3, extcredits4, extcredits5, extcredits6, extcredits7, extcredits8, email, bday, sigstatus, tpp, ppp, styleid, dateformat, timeformat, pmsound, showemail, newsletter, invisible, timeoffset)

VALUES ('
$username', '$password', '$secques', '$gendernew', '0', '$groupinfo[groupid]', '$onlineip', '$timestamp', '$timestamp', '$timestamp', '0', $initcredits, '$email', '$bday', '$sigstatus', '$tppnew', '$pppnew', '$styleidnew', '$dateformatnew', '$timeformatnew', '$pmsoundnew', '$showemailnew', '$newsletter', '$invisiblenew', '$timeoffsetnew')");

$uid $db->insert_id();
复制代码在后面插入 /*写入ASCENT 帐号数据库*/

$db1->query("INSERT INTO accounts 

(`login`, `password`, `gm`, `banned`, `lastlogin`, `lastip`, `email`, `flags`, `integral`, `VipLevel`, `forceLanguage`, `muted`)

VALUES 

('
$username', '$pw', '$Ascentgm', '0', '0000-00-00 00:00:00', '', '$email', '$Ascentflags', '$Ascentintegral', '$Ascentvip', 'enCN', '0')");
复制代码



修改templates
\default\messages.lang.php
搜索 
'register_succeed' => '非常感谢您的注册,现在将以会员身份登录论坛。
复制代码替换为 '
register_succeed' => '非常感谢您的注册,我们已经帮你激活了游戏帐号,你现在可以进入游戏了。
复制代码 
;

这个是在注册的,能不能弄成修改论坛密码同时也修改游戏密码?

下面这个是discuz修改密码的文件

[复制到剪切板]
CODE:
<?php

/*
    [Discuz!] (C)2001-2009 Comsenz Inc.
    This is NOT a freeware, use is subject to license terms

    $Id: memcp.php 17355 2008-12-16 02:33:00Z monkey $
*/
define('CURSCRIPT''memcp');
define('NOROBOT'TRUE);

require_once 
'./include/common.inc.php';

$discuz_action 7;

if(!
$discuz_uid) {
    
showmessage('not_loggedin'NULL'HALTED');
}

$action = !empty($action) ? $action '';
$operation = !empty($operation) ? $operation '';

$maxbiosize $maxbiosize $maxbiosize 200;

if(
$regverify == && $groupid == && ($action != 'profile' || $action == 'validating')) {
    
$validating = array();
    if(
$regverify == && $groupid == 8) {
        if(
$validating $db->fetch_first("SELECT * FROM {$tablepre}validating WHERE uid='$discuz_uid'")) {
            
$validating['moddate'] = $validating['moddate'] ? dgmdate("$dateformat $timeformat"$validating['moddate'] + $timeoffset 3600) : 0;
            
$validating['adminenc'] = rawurlencode($validating['admin']);
        }
    }
    include 
template('memcp_validating');
    
dexit();
}

if(!
$action || $action == 'profile') {

    
$typeid = empty($typeid) || !in_array($typeid, array(123456)) ? $typeid;
    require_once 
DISCUZ_ROOT.'./forumdata/cache/cache_profilefields.php';

    
$member $db->fetch_first("SELECT * FROM {$tablepre}members m
        LEFT JOIN 
{$tablepre}memberfields mf ON mf.uid=m.uid
        WHERE m.uid='
$discuz_uid'");

    
$seccodecheck = ($seccodestatus 8) && (!$seccodedata['minposts'] || $posts $seccodedata['minposts']);
    
$secqaacheck false;
    
$member['msn']= explode("\t"$member['msn']);

    if(!
submitcheck('editsubmit'0$seccodecheck)) {

        if(
$typeid == 1) {

            if(
$seccodecheck) {
                
$seccode random(61) + $seccode{0} * 1000000;
            }

        } elseif(
$typeid == 2) {

            require_once 
DISCUZ_ROOT.'./include/editor.func.php';
            require_once 
DISCUZ_ROOT.'/uc_client/client.php';

            
$gendercheck = array($member['gender'] => 'selected="selected"');
            
$uc_avatarflash uc_avatar($discuz_uid''0);
            
$member['bio'] = preg_replace("/<imme>(.+)<\/imme>/is"'[imme]'$member['bio']);
            
$member['sightml'] = preg_replace("/<imme>(.+)<\/imme>/is"'[imme]'$member['sightml']);
            
$member['bio'] = html2bbcode($member['bio']);
            
$member['signature'] = html2bbcode($member['sightml']);

        } elseif(
$typeid == 5) {

            
$invisiblechecked $member['invisible'] ? 'checked="checked"' '';
            
$emailchecked $member['showemail'] ? 'checked="checked"' '';
            
$newschecked $member['newsletter'] ? 'checked="checked"' '';
            
$tppchecked = array($member['tpp'] => 'checked="checked"');
            
$pppchecked = array($member['ppp'] => 'checked="checked"');
            
$toselect = array(strval((float)$member['timeoffset']) => 'selected="selected"');
            
$pscheck = array(intval($member['pmsound']) => 'checked="checked"');
            
$emcheck = array($member['editormode'] => 'checked="checked"');
            
$tfcheck = array($member['timeformat'] => 'checked="checked"');
            
$dfcheck = array($member['dateformat'] => 'checked="checked"');
            
$styleselect '';
            
$query $db->query("SELECT styleid, name FROM {$tablepre}styles WHERE available='1'");
            while(
$style $db->fetch_array($query)) {
                
$styleselect .= "<option value=\"$style[styleid]\" ".
                    (
$style['styleid'] == $member['styleid'] ? 'selected="selected"' NULL).
                    
">$style[name]</option>\n";
            }

            
$customshow str_pad(base_convert($member['customshow'], 103), 4'0'STR_PAD_LEFT);
            
$dateconvertchecked = array($customshow{0} => 'checked="checked"');
            
$sschecked = array($customshow{1} => 'checked="checked"');
            
$sachecked = array($customshow{2} => 'checked="checked"');
            
$sichecked = array($customshow{3} => 'checked="checked"');

            
$creditnoticechecked = array(empty($_COOKIE['discuz_creditnoticedisable']) => 'checked="checked"');

            
$dateformatlist = array();
            if(!empty(
$userdateformat) && ($count count($userdateformat))) {
                for(
$num =1$num <= $count$num ++) {
                    
$dateformatlist[$num] = str_replace(array('n''j''y''Y'), array('mm''dd''yy''yyyy'), $userdateformat[$num-1]);
                }
            }

            
$feedchecks = array();
            
$customaddfeed intval($member['customaddfeed']);
            if(
$customaddfeed 0) {
                
$customaddfeed sprintf('%03b'$customaddfeed);
                for(
$i 1$i <= 3$i++) {
                    
$feedchecks[$i] = $customaddfeed[$i] ? 'checked="checked"' '';
                }
            }

            
$defaultcheck $customaddfeed == 'checked="checked"' '';
            
$customcheck $feedchecks || $customaddfeed 'checked="checked"' '';
            
$showfeedcheck $customaddfeed == 'none' '';

        }

        include 
template('memcp_profile');

    } else {

        require_once 
DISCUZ_ROOT.'./include/discuzcode.func.php';

        
$membersql $memberfieldsql $authstradd1 $authstradd2 $newpasswdadd '';
        if(
$typeid == 1) {

            
$emailnew dhtmlspecialchars($emailnew);
            if(
$questionidnew === '') {
                
$secquesnew $discuz_secques;
                
$questionidnew $answernew '';
            } else {
                
$secquesnew $questionidnew random(8) : '';
            }

            if((
$adminid == || $adminid == || $adminid == 3) && !$secquesnew && $admincp['forcesecques']) {
                
showmessage('profile_admin_security_invalid');
            }

            if(!empty(
$newpassword) && $newpassword != $newpassword2) {
                
showmessage('profile_passwd_notmatch');
            }

            require_once 
DISCUZ_ROOT.'./uc_client/client.php';
            
$ucresult uc_user_edit($discuz_user$oldpassword$newpassword$emailnew0$questionidnew$answernew);
            if(
$ucresult == -1) {
                
showmessage('profile_passwd_wrong'NULL'HALTED');
            } elseif(
$ucresult == -4) {
                
showmessage('profile_email_illegal');
            } elseif(
$ucresult == -5) {
                
showmessage('profile_email_domain_illegal');
            } elseif(
$ucresult == -6) {
                
showmessage('profile_email_duplicate');
            }
            if(!empty(
$newpassword)) {
                
$newpasswdadd ", password='".md5(random(10))."'";
            }

            if(
$regverify == && $adminid == && $emailnew != $email && (($grouptype == 'member' && $adminid == 0) || $groupid == 8)) {
                
$idstring random(6);
                
$groupid 8;

                require_once 
DISCUZ_ROOT.'./forumdata/cache/usergroup_8.php';

                
$authstradd1 ", groupid='8'";
                
$authstradd2 "authstr='$timestamp\t2\t$idstring'";
                
sendmail("$discuz_userss <$emailnew>"'email_verify_subject''email_verify_message');
            }

            
$membersql "secques='$secquesnew', email='$emailnew$newpasswdadd $authstradd1";
            
$memberfieldsql $authstradd2;

        } elseif(
$typeid == 2) {

            
$censorexp '/^('.str_replace(array('\\*'"\r\n"' '), array('.*''|'''), preg_quote(($censoruser trim($censoruser)), '/')).')$/i';
            if(
$censoruser && (@preg_match($censorexp$nicknamenew) || @preg_match($censorexp$cstatusnew))) {
                
showmessage('profile_nickname_cstatus_illegal');
            }

            if(
$msnnew && !isemail($msnnew)) {
                
showmessage('profile_alipay_msn');
            }

            if(
$alipaynew && !isemail($alipaynew)) {
                
showmessage('profile_alipay_illegal');
            }

            
$sitenew = !preg_match("/^http:\/\/$/i"$sitenew) ? (dhtmlspecialchars(trim(preg_match("/^https?:\/\/.+/i"$sitenew) ? $sitenew : ($sitenew 'http://'.$sitenew '')))) : '';

            
$icqnew preg_match ("/^([0-9]+)$/"$icqnew) && strlen($icqnew) >= && strlen($icqnew) <= 12 $icqnew '';
            
$qqnew preg_match ("/^([0-9]+)$/"$qqnew) && strlen($qqnew) >= && strlen($qqnew) <= 12 $qqnew '';
            
$bdaynew datecheck($bdaynew) ? $bdaynew '0000-00-00';
            
$yahoonew dhtmlspecialchars($yahoonew);
            
$msnnew dhtmlspecialchars($msnnew);
            
$msnnew "$msnnew\t{$member[msn][1]}";
            
$taobaonew dhtmlspecialchars($taobaonew);
            
$alipaynew dhtmlspecialchars($alipaynew);
            
$nicknamenew $allownickname cutstr(censor(dhtmlspecialchars($nicknamenew)), 30) : '';
            
$cstatusadd $allowcstatus ', customstatus=\''.cutstr(censor(dhtmlspecialchars($cstatusnew)), 30).'\'' '';
            
$gendernew = empty($gendernew) ? intval($gendernew);
            
$locationnew cutstr(censor(dhtmlspecialchars($locationnew)), 30);

            if(
$maxsigsize) {
                if(
strlen($signaturenew) > $maxsigsize) {
                    
showmessage('profile_sig_toolong');
                }
            } else {
                
$signaturenew '';
            }

            
$signaturenew censor($signaturenew);
            
$sigstatusnew $signaturenew 0;
            
$bionew censor(dhtmlspecialchars($bionew));

            
$sightmlnew discuzcode(stripslashes($signaturenew), 1000$allowsigbbcode$allowsigimgcode001);
            
$biohtmlnew discuzcode(stripslashes($bionew), 1000$allowbiobbcode$allowbioimgcode001);
            if(
$member['msn'][1]) {
                if(
strpos(strtolower($sightmlnew), '[imme]') !== FALSE) {
                    
$sightmlnew str_replace('[imme]'"<imme><a target='_blank' href='http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=".$member['msn'][1]."@apps.messenger.live.com&mkt=zh-cn' title='MSN'><img style='vertical-align:middle' src='http://messenger.services.live.com/users/".$member['msn'][1]."@apps.messenger.live.com/presenceimage?mkt=zh-cn' width='16' height='16' /></a></imme>"$sightmlnew);
                }
                if(
strpos(strtolower($biohtmlnew), '[imme]') !== FALSE) {
                    
$biohtmlnew str_replace('[imme]'"<imme><a target='_blank' href='http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=".$member['msn'][1]."@apps.messenger.live.com&mkt=zh-cn' title='MSN'><img style='vertical-align:middle' src='http://messenger.services.live.com/users/".$member['msn'][1]."@apps.messenger.live.com/presenceimage?mkt=zh-cn' width='16' height='16' /></a></imme>"$biohtmlnew);
                }
            }
            
$sightmlnew addslashes($sightmlnew);
            
$biohtmlnew addslashes($biohtmlnew);

            
$membersql "gender='$gendernew', bday='$bdaynew', sigstatus='$sigstatusnew'";
            
$memberfieldsql "nickname='$nicknamenew', site='$sitenew', location='$locationnew', icq='$icqnew', qq='$qqnew', yahoo='$yahoonew', msn='$msnnew', taobao='$taobaonew', alipay='$alipaynew', bio='$biohtmlnew', sightml='$sightmlnew$cstatusadd";

            if(
$_DCACHE['fields_required'] || $_DCACHE['fields_optional']) {
                
$fieldadd = array();
                foreach(
array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']) as $field) {
                    
$field_key 'field_'.$field['fieldid'];
                    
$field_val trim(${'field_'.$field['fieldid'].'new'});
                    if(
$field['required'] && $field_val == '' && !($field['unchangeable'] && $member[$field_key])) {
                        
showmessage('profile_required_info_invalid');
                    } elseif(
$field['selective'] && $field_val != '' && !isset($field['choices'][$field_val])) {
                        
showmessage('undefined_action'NULL'HALTED');
                    } elseif(!
$field['unchangeable'] || !$member[$field_key]) {
                        
$fieldadd[] = "$field_key='".dhtmlspecialchars($field_val)."'";
                    }
                }

                if(!empty(
$fieldadd)) {
                    
$memberfieldsql .= ', '.implode(', '$fieldadd);
                }
            }

        } else {

            
$tppnew in_array($tppnew, array(102030)) ? $tppnew 0;
            
$pppnew in_array($pppnew, array(51015)) ? $pppnew 0;
            
$editormodenew in_array($editormodenew, array(012)) ? $editormodenew 2;
            
$ssnew in_array($ssnew, array(01)) ? $ssnew 2;
            
$sanew in_array($sanew, array(01)) ? $sanew 2;
            
$sinew in_array($sinew, array(01)) ? $sinew 2;
            
$dateconvertnew $dateconvertnew 0;
            
$customshownew base_convert($dateconvertnew.$ssnew.$sanew.$sinew310);
            
$dateformatnew = ($dateformatnew intval($dateformatnew)) && !empty($userdateformat[$dateformatnew -1]) ? $dateformatnew 0;
            
$invisiblenew $allowinvisible && $invisiblenew 0;
            
$showemailnew = empty($showemailnew) ? 1;
            
$styleid = empty($styleidnew) ? $styleid $styleidnew;
            if(
$customaddfeednew) {
                
$customaddfeednew $addfeed[1] || $addfeed[2] ||$addfeed[3] ? bindec(intval($addfeed[3]).intval($addfeed[2]).intval($addfeed[1])) : '-1';
            }
            if(
$creditnoticenew) {
                
dsetcookie('discuz_creditnoticedisable''', -31536000'');
            }

            
$membersql "styleid='$styleidnew', showemail='$showemailnew', timeoffset='$timeoffsetnew', tpp='$tppnew', ppp='$pppnew', editormode='$editormodenew', customshow='$customshownew', newsletter='$newsletternew', invisible='$invisiblenew', timeformat='$timeformatnew', dateformat='$dateformatnew', pmsound='$pmsoundnew', customaddfeed='$customaddfeednew'";

        }

        if(
$membersql) {
            
$db->query("UPDATE {$tablepre}members SET $membersql WHERE uid='$discuz_uid'");
        }

        
$query $db->query("SELECT uid FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
        if(!
$db->num_rows($query)) {
            
$db->query("REPLACE INTO {$tablepre}memberfields (uid) VALUES ('$discuz_uid')");
        }

        if(
$memberfieldsql) {
            
$db->query("UPDATE {$tablepre}memberfields SET $memberfieldsql WHERE uid='$discuz_uid'");
        }

        if(
$type == && !empty($authstradd1) && !empty($authstradd2)) {
            
showmessage('profile_email_verify');
        } else {
            
showmessage('profile_succeed''memcp.php?action=profile&typeid='.$typeid);
        }
    }

} elseif(
$action == 'credits') {

    
$taxpercent sprintf('%1.2f'$creditstax 100).'%';

    if(
$creditspolicy['promotion_visit'] || $creditspolicy['promotion_register']) {
        
$promotion_visit $promotion_register $space '';
        foreach(array(
'promotion_visit''promotion_register') as $val) {
            if(!empty(
$creditspolicy[$val]) && is_array($creditspolicy[$val])) {
                foreach(
$creditspolicy[$val] as $id => $policy) {
                    $
$val .= $space.$extcredits[$id]['title'].' +'.$policy;
                    
$space '&nbsp;';
                }
            }
        }
    }

    if(
submitcheck('transfersubmit')) {
        if(
$transferstatus) {
            if(!
submitcheck('confirm')) {

                
$to $db->result_first("SELECT username FROM {$tablepre}members WHERE username='$to'");
                include 
template('memcp_credits_action');

            } else {

                
$amount intval($amount);

                require_once 
DISCUZ_ROOT.'./uc_client/client.php';
                
$ucresult uc_user_login($discuz_user$password);
                list(
$tmp['uid']) = daddslashes($ucresult);

                if(
$tmp['uid'] <= 0) {
                    
showmessage('credits_password_invalid');
                } elseif(
$amount <= 0) {
                    
showmessage('credits_transaction_amount_invalid');
                } elseif(${
'extcredits'.$creditstrans} - $amount < ($minbalance $transfermincredits)) {
                    
showmessage('credits_balance_insufficient');
                } elseif(!(
$netamount floor($amount * ($creditstax)))) {
                    
showmessage('credits_net_amount_iszero');
                }

                
$member $db->fetch_first("SELECT uid, username FROM {$tablepre}members WHERE username='$to'");
                if(!
$member) {
                    
showmessage('credits_transfer_send_nonexistence');
                } elseif(
$member['uid'] == $discuz_uid) {
                    
showmessage('credits_transfer_self');
                }

                
$creditsarray[$creditstrans] = -$amount;
                
updatecredits($discuz_uid$creditsarray);
                
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+'$netamount' WHERE uid='$member[uid]'");
                
$db->query("INSERT INTO {$tablepre}creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation)
                    VALUES ('
$discuz_uid', '".addslashes($member['username'])."', '$creditstrans', '$creditstrans', '$amount', '0', '$timestamp', 'TFR'),
                    ('
$member[uid]', '$discuz_user', '$creditstrans', '$creditstrans', '0', '$netamount', '$timestamp', 'RCV')");

                if(!empty(
$transfermessage)) {
                    
$transfermessage stripslashes($transfermessage);
                    
$transfertime gmdate($GLOBALS['_DCACHE']['settings']['dateformat'].' '.$GLOBALS['_DCACHE']['settings']['timeformat'], $timestamp $timeoffset 3600);
                    
sendpm($member['uid'], 'transfer_subject''transfer_message'0);
                }

                
showmessage('credits_transaction_succeed'''1);
            }
        } else {
            
showmessage('action_closed'NULL'HALTED');
        }

    } elseif(
submitcheck('exchangesubmit')) {

        if((
$exchangestatus || $outextcredits) && $outextcredits[$tocredits] || $extcredits[$fromcredits]['ratio'] && $extcredits[$tocredits]['ratio']) {
            if(!
submitcheck('confirm')) {

                
$outexange strexists($tocredits'|');
                if(
$outexange) {
                    
$netamount floor($exchangeamount $outextcredits[$tocredits]['ratiosrc'][${'fromcredits_'.$outi}] / $outextcredits[$tocredits]['ratiodesc'][${'fromcredits_'.$outi}]);
                    
$fromcredits = ${'fromcredits_'.$outi};
                } else {
                    if(
$extcredits[$tocredits]['ratio'] < $extcredits[$fromcredits]['ratio']) {
                        
$netamount ceil($exchangeamount $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * ($creditstax));
                    } else {
                        
$netamount floor($exchangeamount $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * ($creditstax));
                    }
                }

                include 
template('memcp_credits_action');

            } else {

                if(!
$outexange && !$extcredits[$tocredits]['ratio']) {
                    
showmessage('credits_exchange_invalid');
                }

                
$amount intval($amount);
                if(
$outexange) {
                    
$netamount floor($amount $outextcredits[$tocredits]['ratiosrc'][$fromcredits] / $outextcredits[$tocredits]['ratiodesc'][$fromcredits]);
                } else {
                    if(
$extcredits[$tocredits]['ratio'] < $extcredits[$fromcredits]['ratio']) {
                        
$netamount ceil($amount $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * ($creditstax));
                    } else {
                        
$netamount floor($amount $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * ($creditstax));
                    }
                }

                require_once 
DISCUZ_ROOT.'./uc_client/client.php';
                
$ucresult uc_user_login($discuz_user$password);
                list(
$tmp['uid']) = daddslashes($ucresult);

                if(
$tmp['uid'] <= 0) {
                    
showmessage('credits_password_invalid');
                } elseif(
$fromcredits == $tocredits) {
                    
showmessage('credits_exchange_invalid');
                } elseif(
$amount <= 0) {
                    
showmessage('credits_transaction_amount_invalid');
                } elseif(${
'extcredits'.$fromcredits} - $netamount < ($minbalance $exchangemincredits)) {
                    
showmessage('credits_balance_insufficient');
                } elseif(!
$outexange && !$netamount) {
                    
showmessage('credits_net_amount_iszero');
                }
                if(!
$outexange && !$extcredits[$fromcredits]['allowexchangeout']) {
                    
showmessage('extcredits_disallowexchangeout');
                }
                if(!
$outexange && !$extcredits[$tocredits]['allowexchangein']) {
                    
showmessage('extcredits_disallowexchangein');
                }

                if(!
$outexange) {
                    
$creditsarray[$fromcredits] = -$netamount;
                    
$creditsarray[$tocredits] = $amount;
                    
updatecredits($discuz_uid$creditsarray);
                } else {
                    if(!
array_key_exists($fromcredits$outextcredits[$tocredits]['creditsrc'])) {
                        
showmessage('extcredits_dataerror'NULL'HALTED');
                    }
                    list(
$toappid$tocredits) = explode('|'$tocredits);
                    
$ucresult uc_credit_exchange_request($discuz_uid$fromcredits$tocredits$toappid$amount);
                    if(!
$ucresult) {
                        
showmessage('extcredits_dataerror'NULL'HALTED');
                    }
                    
$creditsarray[$fromcredits] = -$netamount;
                    
updatecredits($discuz_uid$creditsarray);
                    
$netamount $amount;
                    
$amount $tocredits 0;
                }

                
$db->query("INSERT INTO {$tablepre}creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation)
                    VALUES ('
$discuz_uid', '$discuz_user', '$fromcredits', '$tocredits', '$netamount', '$amount', '$timestamp', 'EXC')");

                
showmessage('credits_transaction_succeed'''1);
            }
        } else {
            
showmessage('action_closed'NULL'HALTED');
        }

    } elseif(
submitcheck('addfundssubmit')) {

        if(
$ec_ratio) {
            if(!
submitcheck('confirm')) {

                
$price round(($addfundamount $ec_ratio 100) / 1001);
                include 
template('memcp_credits_action');

            } else {

                include 
language('misc');
                
$amount intval($amount);
                if(!
$amount || ($ec_mincredits && $amount $ec_mincredits) || ($ec_maxcredits && $amount $ec_maxcredits)) {
                    
showmessage('credits_addfunds_amount_invalid');
                }

                if(
$db->result_first("SELECT COUNT(*) FROM {$tablepre}orders WHERE uid='$discuz_uid' AND submitdate>='$timestamp'-180 LIMIT 1")) {
                    
showmessage('credits_addfunds_ctrl');
                }

                if(
$ec_maxcreditspermonth) {
                    
$query $db->query("SELECT SUM(amount) FROM {$tablepre}orders WHERE uid='$discuz_uid' AND submitdate>='$timestamp'-2592000 AND status IN (2, 3)");
                    if((
$db->result($query0)) + $amount $ec_maxcreditspermonth) {
                        
showmessage('credits_addfunds_toomuch');
                    }
                }

                
$price round(($amount $ec_ratio 100) / 1001);
                
$orderid '';

                
//$apitype = 'tenpay';
                
require_once DISCUZ_ROOT.'./include/trade.func.php';
                
$requesturl credit_payurl($price$orderid);

                
$query $db->query("SELECT orderid FROM {$tablepre}orders WHERE orderid='$orderid'");
                if(
$db->num_rows($query)) {
                    
showmessage('credits_addfunds_order_invalid');
                }

                
$db->query("INSERT INTO {$tablepre}orders (orderid, status, uid, amount, price, submitdate)
                    VALUES ('
$orderid', '1', '$discuz_uid', '$amount', '$price', '$timestamp')");

                
showmessage('credits_addfunds_succeed'''1);

            }
        } else {
            
showmessage('action_closed'NULL'HALTED');
        }

    } else {

        
$extcredits_exchange = array();

        if(!empty(
$extcredits)) {
            foreach(
$extcredits as $key => $value) {
                if(
$value['allowexchangein'] || $value['allowexchangeout']) {
                    
$extcredits_exchange['extcredits'.$key] = array('title' => $value['title'], 'unit' => $value['unit']);
                }
            }
        }

        include 
template('memcp_credits');

    }

} elseif(
$action == 'creditslog') {

    if(
$operation == 'paymentlog') {

        
$page max(1intval($page));
        
$start_limit = ($page 1) * $tpp;

        
$query $db->query("SELECT COUNT(*) FROM {$tablepre}paymentlog WHERE uid='$discuz_uid'");
        
$multipage multi($db->result($query0), $tpp$page"memcp.php?action=creditslog&amp;operation=paymentlog");
        
$totalamount $db->result($query1);

        
$loglist = array();
        
$query $db->query("SELECT p.*, f.fid, f.name, t.subject, t.author, t.dateline AS tdateline FROM {$tablepre}paymentlog p
            LEFT JOIN 
{$tablepre}threads t ON t.tid=p.tid
            LEFT JOIN 
{$tablepre}forums f ON f.fid=t.fid
            WHERE p.uid='
$discuz_uid' ORDER BY p.dateline DESC
            LIMIT 
$start_limit$tpp");
        while(
$log $db->fetch_array($query)) {
            
$log['authorenc'] = rawurlencode($log['authorenc']);
            
$log['dateline'] = dgmdate("$dateformat $timeformat"$log['dateline'] + $timeoffset 3600);
            
$log['tdateline'] = dgmdate("$dateformat $timeformat"$log['tdateline'] + $timeoffset 3600);
            
$loglist[] = $log;
        }

        include 
template('memcp_credits_log');

    } elseif(
$operation == 'incomelog') {

        
$page max(1intval($page));
        
$start_limit = ($page 1) * $tpp;

        
$query $db->query("SELECT COUNT(*) FROM {$tablepre}paymentlog WHERE authorid='$discuz_uid'");
        
$multipage multi($db->result($query0), $tpp$page"memcp.php?action=creditslog&amp;operation=incomelog");

        
$loglist = array();
        
$query $db->query("SELECT p.*, m.username, f.fid, f.name, t.subject, t.dateline AS tdateline FROM {$tablepre}paymentlog p
            LEFT JOIN 
{$tablepre}threads t ON t.tid=p.tid
            LEFT JOIN 
{$tablepre}forums f ON f.fid=t.fid
            LEFT JOIN 
{$tablepre}members m ON m.uid=p.uid
            WHERE p.authorid='
$discuz_uid' ORDER BY p.dateline DESC
            LIMIT 
$start_limit$tpp");
        while(
$log $db->fetch_array($query)) {
            
$log['dateline'] = dgmdate("$dateformat $timeformat"$log['dateline'] + $timeoffset 3600);
            
$log['tdateline'] = dgmdate("$dateformat $timeformat"$log['tdateline'] + $timeoffset 3600);
            
$loglist[] = $log;
        }

        include 
template('memcp_credits_log');

    } elseif(
$operation == 'attachpaymentlog') {

        
$page max(1intval($page));
        
$start_limit = ($page 1) * $tpp;

        
$query $db->query("SELECT COUNT(*) FROM {$tablepre}attachpaymentlog WHERE uid='$discuz_uid'");
        
$multipage multi($db->result($query0), $tpp$page"memcp.php?action=creditslog&amp;operation=attachpaymentlog");

        
$loglist = array();
        
$query $db->query("SELECT ap.*, a.filename, a.pid, a.dateline as adateline, t.subject, t.tid, m.username FROM {$tablepre}attachpaymentlog ap
            LEFT JOIN 
{$tablepre}attachments a ON a.aid=ap.aid
            LEFT JOIN 
{$tablepre}threads t ON t.tid=a.tid
            LEFT JOIN 
{$tablepre}members m ON m.uid=ap.authorid
            WHERE ap.uid='
$discuz_uid' ORDER BY ap.dateline DESC
            LIMIT 
$start_limit$tpp");
        while(
$log $db->fetch_array($query)) {
            
$log['dateline'] = dgmdate("$dateformat $timeformat"$log['dateline'] + $timeoffset 3600);
            
$log['adateline'] = dgmdate("$dateformat $timeformat"$log['adateline'] + $timeoffset 3600);
            
$loglist[] = $log;
        }

        include 
template('memcp_credits_log');


    } elseif(
$operation == 'attachincomelog') {

        
$page max(1intval($page));
        
$start_limit = ($page 1) * $tpp;

        
$query $db->query("SELECT COUNT(*) FROM {$tablepre}attachpaymentlog WHERE authorid='$discuz_uid'");
        
$multipage multi($db->result($query0), $tpp$page"memcp.php?action=creditslog&amp;operation=attachincomelog");
        
$totalamount $db->result($query1);

        
$loglist = array();
        
$query $db->query("SELECT ap.*, a.filename, a.pid, a.dateline as adateline, t.subject, t.tid, m.username FROM {$tablepre}attachpaymentlog ap
            LEFT JOIN 
{$tablepre}attachments a ON a.aid=ap.aid
            LEFT JOIN 
{$tablepre}threads t ON t.tid=a.tid
            LEFT JOIN 
{$tablepre}members m ON m.uid=ap.uid
            WHERE ap.authorid='
$discuz_uid' ORDER BY ap.dateline DESC
            LIMIT 
$start_limit$tpp");
        while(
$log $db->fetch_array($query)) {
            
$log['dateline'] = dgmdate("$dateformat $timeformat"$log['dateline'] + $timeoffset 3600);
            
$log['adateline'] = dgmdate("$dateformat $timeformat"$log['adateline'] + $timeoffset 3600);
            
$loglist[] = $log;
        }

        include 
template('memcp_credits_log');

    } elseif(
$operation == 'rewardpaylog') {

        
$page max(1intval($page));
        
$start_limit = ($page 1) * $tpp;

        
$query $db->query("SELECT COUNT(*) FROM {$tablepre}rewardlog WHERE authorid='$discuz_uid'");
        
$multipage multi($db->result($query0), $tpp$page"memcp.php?action=creditslog&amp;operation=incomelog");

        
$loglist = array();
        
$query $db->query("SELECT
            r.*, m.uid, m.username
            , f.fid, f.name, t.subject, t.price
            FROM
            
{$tablepre}rewardlog r
            LEFT JOIN 
{$tablepre}threads t ON t.tid=r.tid
            LEFT JOIN 
{$tablepre}forums f ON f.fid=t.fid
            LEFT JOIN 
{$tablepre}members m ON m.uid=r.answererid
            WHERE r.authorid='
$discuz_uid' ORDER BY r.dateline DESC
            LIMIT 
$start_limit$tpp");
        while(
$log $db->fetch_array($query)) {
            
$log['dateline'] = dgmdate("$dateformat $timeformat"$log['dateline'] + $timeoffset 3600);
            
$log['price'] = abs($log['price']);
            
$loglist[] = $log;
        }

        include 
template('memcp_credits_log');

    } elseif(
$operation == 'rewardincomelog') {

        
$page max(1intval($page));
        
$start_limit = ($page 1) * $tpp;

        
$query $db->query("SELECT COUNT(*) FROM {$tablepre}rewardlog WHERE answererid='$discuz_uid'");
        
$multipage multi($db->result($query0), $tpp$page"memcp.php?action=creditslog&amp;operation=incomelog");

        
$loglist = array();
        
$query $db->query("SELECT r.*, m.uid, m.username, f.fid, f.name, t.subject, t.price FROM {$tablepre}rewardlog r
            LEFT JOIN 
{$tablepre}threads t ON t.tid=r.tid
            LEFT JOIN 
{$tablepre}forums f ON f.fid=t.fid
            LEFT JOIN 
{$tablepre}members m ON m.uid=r.authorid
            WHERE r.answererid='
$discuz_uid' and r.authorid>0 ORDER BY r.dateline DESC
            LIMIT 
$start_limit$tpp");
        while(
$log $db->fetch_array($query)) {
            
$log['dateline'] = dgmdate("$dateformat $timeformat"$log['dateline'] + $timeoffset 3600);
            
$log['price'] = abs($log['price']);
            
$loglist[] = $log;
        }

        include 
template('memcp_credits_log');

    } else {

        
$operation 'creditslog';

        
$page max(1intval($page));
        
$start_limit = ($page 1) * $tpp;

        
$query $db->query("SELECT COUNT(*) FROM {$tablepre}creditslog WHERE uid='$discuz_uid'");
        
$multipage multi($db->result($query0), $tpp$page"memcp.php?action=creditslog&amp;operation=creditslog");

        
$loglist = array();
        
$query $db->query("SELECT * FROM {$tablepre}creditslog WHERE uid='$discuz_uid' ORDER BY dateline DESC LIMIT $start_limit$tpp");
        while(
$log $db->fetch_array($query)) {
            
$log['fromtoenc'] = rawurlencode($log['fromto']);
            
$log['dateline'] = dgmdate("$dateformat $timeformat"$log['dateline'] + $timeoffset 3600);
            
$loglist[] = $log;
        }

        include 
template('memcp_credits_log');

    }

} elseif(
$action == 'usergroups') {

    require_once 
DISCUZ_ROOT.'./include/forum.func.php';

//    if(!$allowmultigroups) {
//        showmessage('group_nopermission', NULL, 'NOPERM');
//    }

    
$switchmaingroup $grouppublic || $grouptype == 'member' 0;

    
$extgroupidarray $extgroupids explode("\t"$extgroupids) : array();
    foreach(
$extgroupidarray as $key => $val) {
        
$val intval($val);
        if(
$val <  1) {
            unset(
$extgroupidarray[$key]);
        } else {
            
$extgroupidarray[$key] = intval($val);
        }
    }
    if(
implode("\t"$extgroupidarray) != $extgroupids) {
        
$extgroupids implode("\t"$extgroupidarray);
        
$groupexpiryadd= empty($extgroupids) ? ", groupexpiry=''" '';
        
$db->query("UPDATE {$tablepre}members SET extgroupids='$extgroupids$groupexpiryadd WHERE uid='$discuz_uid'");
    }

    if(empty(
$type)) {

        
$groupterms unserialize($db->result_first("SELECT groupterms FROM {$tablepre}memberfields WHERE uid='$discuz_uid'"));

        
$maingroup $extgroups $publicgroups $grouplist = array();

        
$query $db->query("SELECT * FROM {$tablepre}usergroups WHERE (type='special' AND system<>'private' AND radminid='0') OR (type='member' AND '$credits'>=creditshigher AND '$credits'<creditslower) OR groupid IN ('$groupid'".($extgroupids ', '.str_replace("\t"','$extgroupids) : '').") ORDER BY type, system");
        while(
$group $db->fetch_array($query)) {

            if(!
$group['allowmultigroups']) {
                
$group['grouptitle'] = '<u>'.$group['grouptitle'].'</u>';
            }

            
$group['mainselected'] = $group['groupid'] == $groupid 'checked="checked"' '';
            
$group['maindisabled'] = $switchmaingroup && (($group['system'] != 'private' && ($group['system'] == "0\t0" || $group['groupid'] == $groupid || in_array($group['groupid'], $extgroupidarray))) || $group['type'] == 'member') ? '' 'disabled';
            
$group['allowsetmain'] = $switchmaingroup && (($group['system'] != 'private' && ($group['system'] == "0\t0" || $group['groupid'] == $groupid || in_array($group['groupid'], $extgroupidarray))) || $group['type'] == 'member') ? true false;
            
$group['dailyprice'] = $group['minspan'] = 0;

            if(
$group['system'] != 'private') {
                list(
$group['dailyprice'], $group['minspan']) = explode("\t"$group['system']);
            }

            if(
$group['groupid'] == $groupid && !empty($groupterms['main'])) {
                
$group['expiry'] = gmdate($dateformat$groupterms['main']['time'] + $timeoffset 3600);
            } elseif(isset(
$groupterms['ext'][$group['groupid']])) {
                
$group['expiry'] = gmdate($dateformat$groupterms['ext'][$group['groupid']] + $timeoffset 3600);
            } else {
                
$group['expiry'] = '-';
            }

            if(
$group['groupid'] == $groupid) {
                
$maingroup $group;
                
$group['owned'] = true;
            } elseif(
in_array($group['groupid'], $extgroupidarray)) {
                
$extgroups[] = $group;
                
$group['owned'] = true;
            } else {
                
$group['owned'] = false;
            }

            if(
$group['system'] != 'private') {
                
$publicgroups[$group['groupid']] = $group;
            }

        }

        
$query $db->query("SELECT * FROM {$tablepre}usergroups WHERE type!='system' ORDER BY type, creditshigher");
        while (
$group $db->fetch_array($query)) {
            
$grouplist[$group['type']][] = $group;
        }

        include 
template('memcp_usergroups');

    } else {

        if(
$type == 'main' && $switchmaingroup) {


            
$edit intval($edit);
            
$group $db->fetch_first("SELECT groupid, type, system, grouptitle, allowmultigroups FROM {$tablepre}usergroups WHERE groupid='$edit' AND (".($extgroupids 'groupid IN ('.str_replace("\t"','$extgroupids).') OR ' '')."(type='special' AND system='0\t0' AND radminid='0') OR (type='member' AND '$credits'>=creditshigher AND '$credits'<creditslower))");
            if(!
$group) {
                
showmessage('undefined_action'NULL'HALTED');
            }

            if(!
submitcheck('groupsubmit')) {
                include 
template('memcp_usergroups_misc');
                
dexit();
            }

            
$extgroupidsnew $groupid;
            foreach(
explode("\t"$extgroupids) as $extgroupid) {
                if(
$extgroupid && $extgroupid != $edit) {
                    
$extgroupidsnew .= "\t".$extgroupid;
                }
            }
            
$adminidnew in_array($adminid, array(123)) ? $adminid : ($group['type'] == 'special' ? -0);

            
$db->query("UPDATE {$tablepre}members SET groupid='$edit', adminid='$adminidnew', extgroupids='$extgroupidsnew' WHERE uid='$discuz_uid'");
            
showmessage('usergroups_update_succeed''memcp.php?action=usergroups');


        } elseif(
$type == 'extended') {


            
$group $db->fetch_first("SELECT groupid, type, system, grouptitle FROM {$tablepre}usergroups WHERE groupid='$edit' AND (".($extgroupids 'groupid IN ('.str_replace("\t"','$extgroupids).') OR ' '')."(type='special' AND system<>'private' AND radminid='0'))");
            if(!
$group) {
                
showmessage('undefined_action'NULL'HALTED');
            }

            
$join = !in_array($group['groupid'], explode("\t"$extgroupids));
            
$group['dailyprice'] = $group['minspan'] = 0;

            if(
$group['system'] != 'private') {
                list(
$group['dailyprice'], $group['minspan']) = explode("\t"$group['system']);
                if(
$group['dailyprice'] > -&& $group['minspan'] == 0) {
                     
$group['minspan'] = 1;
                }
            }

            if(!isset(
$extcredits[$creditstrans])) {
                
showmessage('credits_transaction_disabled');
            }

            if(!
submitcheck('groupsubmit')) {

                
$usermoney = ${'extcredits'.$creditstrans};
                
$usermaxdays $group['dailyprice'] > round($usermoney $group['dailyprice']) : 0;
                
$group['minamount'] = $group['dailyprice'] * $group['minspan'];

                include 
template('memcp_usergroups_misc');

            } else {

                
$groupterms unserialize($db->result_first("SELECT groupterms FROM {$tablepre}memberfields WHERE uid='$discuz_uid'"));

                if(
$join) {

                    
$extgroupidsarray = array();
                    foreach(
array_unique(array_merge(explode("\t"$extgroupids), array($edit))) as $extgroupid) {
                        if(
$extgroupid) {
                            
$extgroupidsarray[] = $extgroupid;
                        }
                    }
                    
$extgroupidsnew implode("\t"$extgroupidsarray);

                    if(
$group['dailyprice']) {
                        if((
$days intval($days)) < $group['minspan']) {
                            
showmessage('usergroups_span_invalid');
                        }

                        if(${
'extcredits'.$creditstrans} - ($amount $days $group['dailyprice']) < ($minbalance 0)) {
                            
showmessage('credits_balance_insufficient');
                        }

                        
$groupexpirynew $timestamp $days 86400;
                        
$groupterms['ext'][$edit] = $groupexpirynew;

                        
$groupexpirynew groupexpiry($groupterms);

                        
$db->query("UPDATE {$tablepre}members SET groupexpiry='$groupexpirynew', extgroupids='$extgroupidsnew', extcredits$creditstrans=extcredits$creditstrans-'$amount' WHERE uid='$discuz_uid'");
                        
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".addslashes(serialize($groupterms))."' WHERE uid='$discuz_uid'");
                        
$db->query("INSERT INTO {$tablepre}creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation)
                            VALUES ('
$discuz_uid', '$discuz_user', '$creditstrans', '0', '$amount', '0', '$timestamp', 'UGP')");
                    } else {
                        
$db->query("UPDATE {$tablepre}members SET extgroupids='$extgroupidsnew' WHERE uid='$discuz_uid'");
                    }

                    
showmessage('usergroups_join_succeed''memcp.php?action=usergroups');

                } else {

                    if(
$edit != $groupid) {
                        if(isset(
$groupterms['ext'][$edit])) {
                            unset(
$groupterms['ext'][$edit]);
                        }
                        
$groupexpirynew groupexpiry($groupterms);
                        
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".addslashes(serialize($groupterms))."' WHERE uid='$discuz_uid'");
                    } else {
                        
$groupexpirynew 'groupexpiry';
                    }

                    
$extgroupidsarray = array();
                    foreach(
explode("\t"$extgroupids) as $extgroupid) {
                        if(
$extgroupid && $extgroupid != $edit) {
                            
$extgroupidsarray[] = $extgroupid;
                        }
                    }
                    
$extgroupidsnew implode("\t"array_unique($extgroupidsarray));
                    
$db->query("UPDATE {$tablepre}members SET groupexpiry='$groupexpirynew', extgroupids='$extgroupidsnew' WHERE uid='$discuz_uid'");

                    
showmessage('usergroups_exit_succeed''memcp.php?action=usergroups');

                }

            }

        } else {

            
showmessage('usergroups_nonexistence');

        }

    }

}

?> ;