在帝国CMS后台增加手动添加会员功能
2018-04-02 站长 站长日志
由于帝国CMS后台没有增加会员的功能,所以做了此教程!请有需要的小伙伴备份文件然后测试修改!
后台手动增加会员的功能
具体修改了两个文件,AddMember.php和ListMember.php(在e/admin/member/目录)
一、修改方法:
1、在ListMember.php添加代码
①、查找" //修改会员 " 在其上面添加以下代码:
001 |
//增加会员函数 |
002 |
003 |
function admin_AddMember( $add , $logininid , $loginin ){ |
004 |
005 |
global $empire , $dbtbpre ; |
006 |
007 |
if (!trim( $add [username])) |
008 |
009 |
{ |
010 |
011 |
printerror( "用户名不能为空" , "history.go(-1)" ,1,0,1); |
012 |
013 |
} |
014 |
015 |
else |
016 |
017 |
{ |
018 |
019 |
$num = $empire ->gettotal( "select count(*) as total from " .eReturnMemberTable(). " where " .egetmf( 'username' ). "='$add[username]' limit 1" ); |
020 |
021 |
if ( $num ) |
022 |
023 |
{ |
024 |
025 |
printerror( "ReUsername" , "history.go(-1)" ); |
026 |
027 |
} |
028 |
029 |
} |
030 |
031 |
if (!trim( $add [password])) |
032 |
033 |
{ |
034 |
035 |
printerror( "密码不能为空" , "history.go(-1)" ,1,0,1); |
036 |
037 |
} |
038 |
039 |
else |
040 |
{ |
041 |
042 |
$salt =eReturnMemberSalt(); |
043 |
044 |
$add [password]=eDoMemberPw( $add [password], $salt ); |
045 |
046 |
} |
047 |
048 |
if (!trim( $add [email])) |
049 |
050 |
{ |
051 |
052 |
printerror( "邮箱不能为空" , "history.go(-1)" ,1,0,1); |
053 |
054 |
} |
055 |
056 |
CheckLevel( $logininid , $loginin , $classid , "member" ); //验证权限 |
057 |
058 |
$checked =1; |
059 |
060 |
//变量 |
061 |
062 |
$add [groupid]=(int) $add [groupid]; |
063 |
064 |
//$registertime=time(); |
065 |
066 |
$registertime =eReturnAddMemberRegtime(); |
067 |
068 |
$rnd =make_password(20); //产生随机密码 |
069 |
070 |
$userkey =eReturnMemberUserKey(); |
071 |
072 |
//写入数据库 |
073 |
074 |
$sql = $empire ->query( "insert into {$dbtbpre}enewsmember(userid,username,password,rnd,email,registertime,groupid,checked,salt,userkey) values(NULL,'" . addslashes ( $add [username]). "','" . addslashes ( $add [password]). "','$rnd','" . addslashes ( $add [email]). "','$registertime','" . addslashes ( $add [groupid]). "','$checked','$salt','$userkey');" ); |
075 |
076 |
if ( $sql ) |
077 |
078 |
{ |
079 |
080 |
insert_dolog( "添加会员" . $add [username]); //操作日志 |
081 |
082 |
printerror( "添加会员成功" , "ListMember.php" ,1,0,1); |
083 |
084 |
} |
085 |
else |
086 |
087 |
{ |
088 |
089 |
printerror( "DbError" , "history.go(-1)" ); |
090 |
091 |
} |
092 |
093 |
} |
094 |
095 |
--------------------------------------------------------------------- |
096 |
097 |
②、查找 " //删除会员 " 在其上面添加以下代码: |
098 |
099 |
//增加会员 |
100 |
101 |
if ( $enews == "AddMember" ) |
102 |
103 |
{ |
104 |
105 |
$add = $_POST [ 'add' ]; |
106 |
107 |
admin_AddMember( $add , $logininid , $loginin ); |
108 |
109 |
} |
-------------------------------------------------------------------------
③、查找" 位置 " ,找到后继续向下看有"注册会员"或"前台会员列表"
<input type="button" name="Submit5" value="注册会员" onclick="window.open('../../member/register/');">
或
<input type="button" name="Submit5" value="前台会员列表" onclick="window.open('../../member/list/');">
在"注册会员"或"前台会员列表",他两个的任意一个上面添加以下代码:
1 |
< input type = "button" name = "Submit5" value = "增加会员" onclick = "self.location.href='AddMember.php?enews=AddMember';" > |
=======================================================================
2、在AddMember.php添加代码
①、查找" //取得表单 " 在其上面添加以下代码
1 |
?> |
2 |
<?php |
3 |
if ( $enews == "EditMember" ) |
4 |
{ |
------------------------------------------------------------------------
②、在最下面查找" <?php " 或 " db_close() " 在其上面添加以下代码:
001 |
<?php |
002 |
003 |
} |
004 |
005 |
elseif ( $enews == "AddMember" ) |
006 |
007 |
{ |
008 |
009 |
?> |
010 |
011 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > |
012 |
013 |
<html> |
014 |
015 |
<head> |
016 |
017 |
<meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" > |
018 |
019 |
<title>增加会员</title> |
020 |
021 |
<link href= "../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel= "stylesheet" type= "text/css" > |
022 |
023 |
</head> |
024 |
025 |
<body> |
026 |
027 |
<table width= "100%" border= "0" align= "center" cellpadding= "3" cellspacing= "1" > |
028 |
029 |
<tr> |
030 |
031 |
<td>位置:<?= $url ?></td> |
032 |
033 |
</tr> |
034 |
035 |
</table> |
036 |
037 |
<form name= "form1" method= "post" action= "ListMember.php" enctype= "multipart/form-data" > |
038 |
039 |
<table width= "100%" border= "0" align= "center" cellpadding= "3" cellspacing= "1" class = "tableborder" > |
040 |
041 |
<tr class = "header" > |
042 |
043 |
<td height= "25" colspan= "2" >增加会员 |
044 |
045 |
<input name= "enews" type= "hidden" id= "enews" value= "<?=$enews?>" > |
046 |
047 |
</td> |
048 |
049 |
</tr> |
050 |
|
051 |
<tr bgcolor= "#FFFFFF" > |
052 |
053 |
<td width= "25%" height= "25" >用户名</td> |
054 |
055 |
<td width= "75%" height= "25" ><input name= "add[username]" type=text id= "add[username]" ></td> |
056 |
057 |
</tr> |
058 |
059 |
<tr bgcolor= "#FFFFFF" > |
060 |
061 |
<td height= "25" >密码</td> |
062 |
063 |
<td height= "25" ><input name= "add[password]" type= "password" id= "add[password]" > |
064 |
065 |
</td> |
066 |
067 |
</tr> |
068 |
069 |
<tr bgcolor= "#FFFFFF" > |
070 |
071 |
<td height= "25" valign= "top" >所属会员组<br> <br> <input type= "button" name= "Submit3" value= "管理会员组" onclick= "window.open('ListMemberGroup.php');" > |
072 |
073 |
</td> |
074 |
075 |
<td height= "25" ><select name= "add[groupid]" size= "6" id= "add[groupid]" onchange= "self.location.href='AddMember.php?enews=AddMember&changegroupid='+this.options[this.selectedIndex].value;" > |
076 |
077 |
<?= $group ?> |
078 |
079 |
</select></td> |
080 |
081 |
</tr> |
082 |
083 |
<tr bgcolor= "#FFFFFF" > |
084 |
085 |
<td height= "25" >邮箱</td> |
086 |
087 |
<td height= "25" ><input name= "add[email]" type= "text" id= "add[email]" size= "35" ></td> |
088 |
089 |
</tr> |
090 |
091 |
<tr bgcolor= "#FFFFFF" > |
092 |
093 |
<td height= "25" > </td> |
094 |
095 |
<td height= "25" ><input type= "submit" name= "Submit" value= "提交" > <input type= "reset" name= "Submit2" value= "重置" ></td> |
096 |
097 |
</tr> |
098 |
099 |
</table> |
100 |
101 |
</form> |
102 |
103 |
</body> |
104 |
105 |
</html> |
106 |
107 |
<?php |
108 |
109 |
} |
110 |
111 |
?> |
二、使用方法:
后台--用户--会员管理--管理会员--增加会员