● 插件名称:会员收费改名
● 适用版本:Discuz! 4.1(注:同样适用 Discuz! 4.0.0)
● 安装难度:还可以吧``
● FOR4.0原作者: 魔焰男孩
● 改正,测试:折翼の天使♂
● 演示:http://www.fazai.cn/memcp.php?action=changename
PS:改过 FOR D4 的··发现··For 4.1也能用··×_×
-------------------------------------------------------------------------------------------------------------------
1、新建一个模版,名称是:
将此模版放在templates/default目录里
内容:
- {template header}
- {template memcp_navbar}
- <form name="reg" method="post" action="memcp.php?action=changename">
- <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">
- <tr>
- <td colspan="2" class="header">改名</td>
- </tr>
- <tr>
- <td class="altbg1" width="20%">您的用户名:</td>
- <td class="altbg2">$discuz_user [<a href="logging.php?action=logout">退出登录</a>]</td>
- </tr>
- <tr>
- <td class="altbg1">改名手续费:</td>
- <td class="altbg2">$change_credit 点积分 (您共有 {$credit_num[$change_creditid]} 点积分)</td>
- </tr>
- <tr>
- <td class="altbg1">新的用户名:</td>
- <td class="altbg2"><input type="text" name="username" size="20" maxlength="15"> 请输入您需要的用户名<input type="button" value="{lang register_check_username}" onclick="window.open('member.php?action=check&username='+this.form.username.value);"></td>
- </tr>
- <tr>
- <td class="altbg1">改名原因:</td>
- <td class="altbg2"><input type="text" name="because" size="50" maxlength="100"> 请输入您更名的理由</td>
- </tr>
- </table><br>
- <center><input type="submit" name="changesubmit" value="{lang submit}"></center>
- </form>
- {template footer}
复制代码
2、打开文件 memcp.php ,找到最后的:
之前加上:
- } elseif($action == 'changename') {
- $change_credit = 500; // 改名要花的积分
- $change_creditid = 'extcredits2'; // 扣除的积分所在的序列
- $change_annuct = 1; // 是否发布改名通知
-
- if(!submitcheck('changesubmit', 1)) {
- $credit_num = $db->fetch_array($db->query("SELECT {$change_creditid} FROM {$tablepre}members WHERE uid='{$discuz_uid}'"));
- if($credit_num[$change_creditid] < $change_credit) {
- showmessage('您的积分不足够支付改名所需的费用。');
- } else {
- include template('memcp_changename');
- }
- } else {
- $guestexp = '\xA1\xA1|\xAC\xA3|^Guest|^\xD3\xCE\xBF\xCD|\xB9\x43\xAB\xC8';
- $censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($censoruser = trim($censoruser)), '/')).')$/i';
- if(preg_match("/^\s*$|^c:\\con\\con$|[%,\*"\s\t\<\>\&]|$guestexp/is", $username) || ($censoruser && @preg_match($censorexp, $username))) {
- showmessage('您输入的用户名无效,请返回重新输入。');
- }
- if($username == $discuz_user) showmessage('您到底是要改名还是玩哪?');
- if(trim($because) == '') showmessage('请没有输入更名原因,请返回修改。');
- $chk = $db->fetch_array($db->query("SELECT uid FROM {$tablepre}members WHERE username='". addslashes($username) . "'"));
- if($chk) showmessage('您输别人的用户名干啥?赶快返回换个别的。');
- $db->query("UPDATE {$tablepre}members SET username='" . addslashes($username) . "', {$change_creditid}={$change_creditid}-{$change_credit} WHERE uid='$discuz_uid'");
- if($change_annuct) {
- $db->query("INSERT INTO {$tablepre}announcements VALUES(0, '$discuz_user', '会员「{$discuz_user}」改名通知', '0', '$timestamp', '0', '" . date('Y年m月d日 H:i') . " - 会员: [color=blue]{$discuz_user}[/color] 更名为: [color=red]{$username}[/color]" . "\n\n" . "更名原因: [color=purple]" . addslashes($because) . "[/color]" . "\n\n" . "会员 [color=red]{$username}[/color] - 改名手续费: [color=blue]积分 {$change_credit} 点[/color] 。如有问题,请PM管理员。')");
- }
- showmessage('恭喜您,改名成功!', 'index.php');
- }
复制代码
3、打开模版 memcp_navbar.htm,找:
- <!--{elseif $action == 'viewavatars'}-->{lang memcp_avatar_list}
复制代码
在下面加上:
- <!--{elseif $action == 'changename'}-->用户改名
复制代码
找到:
- <td class="altbg2"><a href="pm.php" target="_blank" width="13%">{lang pm}</a></td>
复制代码
在上面加上:
- <!--{if $action == 'changename'}--><td class="altbg1" width="11%">用户更名</td><!--{else}--><td width="11%" class="altbg2"><a href="memcp.php?action=changename">用户更名</a></td><!--{/if}-->
复制代码
为了美观,把这个文件里的所有的:
替换成:
完成! |