true,'login' => 1)); } $kgaiming = $_G['cache']['plugin']['k_gaiming']; $kgaiming['usergroups'] = unserialize($kgaiming['usergroups']); $kgaiming['creditunit'] = $kgaiming['creditunit'] ? $kgaiming['creditunit'] : 2; foreach ($kgaiming['usergroups'] as $k => $v){ $grouptitle[] = $_G['cache']['usergroups'][$v]['grouptitle']; } $allowgroup['num'] = count($grouptitle); $c = getuserprofile('extcredits'.$kgaiming['creditunit']); $isAppbyme = stripos($_SERVER['HTTP_USER_AGENT'], 'Appbyme') !== false ? true : false; $isMagapp = stripos($_SERVER['HTTP_USER_AGENT'], 'Magapp') !== false ? true : false; $isQFapp = stripos($_SERVER['HTTP_USER_AGENT'], 'QianFan') !== false ? true : false; $isWechat = stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ? true : false; $isQQapp = stripos($_SERVER['HTTP_USER_AGENT'], 'QQ') !== false ? true : false; $isInapp = $isAppbyme || $isMagapp || $isQFapp || $isWechat || $isQQapp; require_once libfile('function/core', 'plugin/k_gaiming'); require_once libfile('data/field', 'plugin/k_gaiming'); $re = ''; $hash = formhash(); if(submitcheck('formhash')){ if($extend['wsq'] && defined('IN_MOBILE')){ require_once libfile('extend/mobile', 'plugin/k_gaiming'); }else{ if(!in_array($_G['member']['groupid'], $kgaiming['usergroups'])){ showmessage(lang('plugin/k_gaiming', 'notp')); } $lastlog = DB::fetch_first("SELECT * FROM ".DB::table("plugin_k_gaiming_log")." WHERE uid='".$_G['uid']."' ORDER BY dateline DESC LIMIT 1"); if($lastlog['dateline'] && ($_G['timestamp'] - $lastlog['dateline'] < 60*60*$kgaiming['jianxie']) ){ showmessage(lang('plugin/k_gaiming', 'notp2').$kgaiming['jianxie'].lang('plugin/k_gaiming', 'notp2_unit')); } if($kgaiming['maxtimes']){ $times = DB::result_first("SELECT count(*) FROM ".DB::table("plugin_k_gaiming_log")." WHERE uid='".$_G['uid']."'"); if($times >= $kgaiming['maxtimes']){ showmessage(lang('plugin/k_gaiming', 'overmaxtimes')); } } loaducenter(); $oldusername = $_G['username']; $olduserid = $_G['uid']; if($_G['charset'] == 'gbk'){ $newusername = addslashes(dhtmlspecialchars($_GET['newname'],ENT_COMPAT,'GB2312')); }else{ $newusername = addslashes(dhtmlspecialchars($_GET['newname'],ENT_COMPAT,'utf-8')); } if ($newusername == '') { $re = lang('plugin/k_gaiming', 'nonewusername'); } else { $censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($_G['setting']['censoruser'] = trim($_G['setting']['censoruser'])), '/')).')$/i'; if($_G['setting']['censoruser'] && @preg_match($censorexp, $newusername)) { showmessage('profile_username_protect'); } $check = uc_user_checkname($newusername); $error_info = array( '-1' => lang('plugin/k_gaiming', 'error_1'), '-2' => lang('plugin/k_gaiming', 'error_2'), '-3' => lang('plugin/k_gaiming', 'error_3') ); if ($check != 1) { $re = $error_info[$check]; }else{ if($kgaiming['creditunit'] && $kgaiming['creditnum']){ if($kgaiming['creditnum'] && $c < $kgaiming['creditnum']){ showmessage(lang('plugin/k_gaiming', 'nocredit')); } } if($kgaiming['unsettables']){ $tables = explode("\n", $kgaiming['unsettables']); foreach($tables as $table){ unset($dz_update_field[$table]); } } changename($olduserid, $newusername, $dz_update_field); changename_for_uc($olduserid, $newusername, $uc_update_field); if($kgaiming['tables']){ $tables = explode("\n", $kgaiming['tables']); foreach($tables as $value){ $table = explode(",", $value); if($table[0]){ $tablelist[$table[0]] = array('uid' => $table[1], 'username' => $table[2]); } } } foreach($tablelist as $table => $v) { DB::query('UPDATE %t SET '.$v['username'].'=%s WHERE '.$v['uid'].'=%d', array($table, $newusername, $olduserid), 'SILENT'); } if($kgaiming['creditunit'] && $kgaiming['creditnum']){ updatemembercount($_G['uid'], array('extcredits'.$kgaiming['creditunit'] => '-'.$kgaiming['creditnum']), true, 'KGM', $_G['uid'], '', lang('plugin/k_gaiming', 'title')); } $logdata = array( 'uid' => $_G['uid'], 'creditunit' => $kgaiming['creditunit'], 'creditnum' => $kgaiming['creditnum'], 'oldname' => addslashes($oldusername), 'newname' => addslashes($newusername), 'dateline' => $_G['timestamp'], ); DB::insert('plugin_k_gaiming_log', $logdata); C::memory()->clear(); $re = ''.lang('plugin/k_gaiming', 'success').''; } } } }else{ @include_once DISCUZ_ROOT.'./source/discuz_version.php'; if($kgaiming['mobile_header'] && defined('IN_MOBILE')){ include template('k_gaiming:k_gaiming'); } } function changename($olduid = 0, $newname = '', $dz_update_field){ foreach ($dz_update_field as $table => $conf) { DB::query("UPDATE ".DB::table($table)." SET `".$conf['name']."`=%s WHERE `".$conf['id']."`=%d", array($newname, $olduid)); } return true; } function changename_for_uc($olduid = 0, $newname = '', $uc_update_field){ foreach ($uc_update_field as $table => $conf) { DB::query("UPDATE ".UC_DBTABLEPRE.$table." SET `".$conf['name']."`=%s WHERE `".$conf['id']."`=%d", array($newname, $olduid)); } return true; }