近日无意中偶遇一网站后台登陆界面,于是,扒之、改之,使之和可用于dedecmsv4上,并作了一些人性化的小改动如:打开登录页面鼠标自动聚焦到用户名输入框。(V5的请参照自行修改)界面如下图:
修改方法:
1、修改 dede/login.php 为以下内容(把原来的全换成下面的):
<?php
require_once(dirname(__FILE__)."/../include/config_base.php");
require_once(dirname(__FILE__)."/../include/inc_userlogin.php");
if(empty($dopost)) $dopost="";
//--------------------------------
//登录检测
//--------------------------------
if($dopost=="login")
{
if(empty($validate)) $validate="";
else $validate = strtolower($validate);
$svali = GetCkVdValue();
if(($validate=="" || $validate!=$svali) && $cfg_use_vdcode=='是'){
ShowMsg("验证码不正确!","");
}else{
$cuserLogin = new userLogin();
if(!empty($userid)&&!empty($pwd))
{
$res = $cuserLogin->checkUser($userid,$pwd);
//成功登录
if($res==1){
$cuserLogin->keepUser();
if(!empty($gotopage)){
ShowMsg("成功登录,正在转向管理管理主页!",$gotopage);
exit();
}
else{
ShowMsg("成功登录,正在转向管理管理主页!","index.php");
exit();
}
}
else if($res==-1){
ShowMsg("你的用户名不存在!","");
}
else{
ShowMsg("你的密码错误!","");
}
}//<-密码不为空
else{
ShowMsg("用户和密码没填写完整!","");
}
}//<-验证用户
}
?>
<script language=javascript>
<!--
function SetFocus()
{
if (document.form1.userid.value=="")
document.form1.userid.focus();
else
document.form1.userid.select();
}
//-->
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>内容管理系统</title>
<style type="text/css">
<!--
body { font-size: 12px; line-height: 130%; color: #000; background: #fff; }
td { font-size: 12px; }
input { color: 333333; }
.input { color: #333333; height: 20px; padding-top: 2px; padding-left: 3px; border: 1px #999999 solid; background-image: url("images/inputbg.gif");}
.button {border: 2px outset; height: 25px; color: 333333; }
-->
</style>
</head>
<body>
<br><br><br><br>
<table border="0" cellspacing="1" cellpadding="1" align="center" bgcolor="#CCCCCC" width="500">
<tr bgcolor="#FFFFFF">
<td>
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><img src="images/1.jpg" width="500" height="129"></td>
</tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center" background="images/3.jpg" height="153">
<tr>
<td width="10"></td>
<td width="158" background="images/2.jpg"> </td>
<td align="center">
<table width="260" border="0" cellspacing="3" cellpadding="0">
<form name="form1" method="post" action="login.php">
<input type="hidden" name="gotopage" value="<?php if(!empty($gotopage)) echo $gotopage;?>">
<input type="hidden" name="dopost" value="login">
<tr>
<td align="right" width="100">用户名:</td>
<td rowspan="4" width="3"></td>
<td><font color="#FFFFFF">
<input type="text" name="userid" size="18" class="input" style="width:108px" onfocus="this.style.borderColor='#44C5F4'" onblur="this.style.borderColor='#888'" />
</font></td>
</tr>
<tr>
<td align="right" width="100">密 码:</td>
<td><font color="#FFFFFF">
<input type="password" name="pwd" size="18" class="input" style="width:108px" onfocus="this.style.borderColor='#44C5F4'" onblur="this.style.borderColor='#888'" />
</font></td>
</tr>
<?php
if($cfg_use_vdcode=='是'){
?>
<tr>
<td width="100" align="right">验证码:</td>
<td><font color="#FFFFFF"> </font>
<table border="0" cellspacing="0" cellpadding="0" height="20">
<tr>
<td width="1"><font color="#FFFFFF">
<input type="text" name="validate" style="width:51px" class="input" onfocus="this.style.borderColor='#44C5F4'" onblur="this.style.borderColor='#888'" />
</font></td>
<td width="5"></td>
<td>
<table width="30" border="0" cellspacing="1" cellpadding="0" bgcolor="#cccccc">
<tr bgcolor="#FFFFFF">
<td><font color="#FFFFFF"><img src="../include/vdimgck.php" width="50" height="20"></font></td>
</tr>
</table>
</td>
</tr>
<?php
}else{
echo "<tr><td colspan='2'> <font color='red'>为了使程序有更大程度的兼容,后台默认关闭了验证码,为了你的登录更安全,请确认你的系统支持GD后,在后台参数中开启。</font></td></tr>\r\n";
}
?>
</table>
<font color="#FFFFFF"> </font></td>
</tr>
<tr>
<td width="100"> </td>
<td height="28" valign="bottom">
<input type="submit" name="sm1" value=" 登 录 " class="button" onClick="this.form.submit();" style="width:108px" />
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script language="JavaScript" type="text/JavaScript">
SetFocus();
</script>
</body></html>
2、解压下面的 images.rar 文件,把 images 文件夹放在 dede/ 下。
下载:images.rar
3、OK,一个漂亮的登陆后台完成。




