📄 user.php
字号:
<?
class CModule extends CUserApp
{
function execute()
{
if($this->input[action] != "login" && $this->input[action] != "logined") $this->checkLogin();
switch ($this->input['action'])
{
case "register":
$this->Register();
break;
case "login":
$this->showLogin();
break;
case "logined":
$this->logined();
break;
case "logout":
$this->logout();
break;
case "delete":
$this->deleteUser();
break;
case "profile":
$this->showProfile();
break;
case "modPass":
$this->modifyPassword();
break;
case "modProfile":
$this->modifyProfile();
break;
case "showPass":
$this->showPassword();
break;
default:
$this->showRegister();
break;
}
}
function getUserInfo(&$outPages)
{
$setid = $this->input[setid];
if (empty($setid)) $setid = 0;
$aUser = new CUser;
$aUser->open();
$flag = $aUser->moveTo($setid);
$num = $aUser->getRecordCount();
$count = 0;
while($flag && $count < $this->set[listnumUser])
{
$userid = $aUser->getAbsolutePosition();
eval ("\$result .= \"".$this->getTemplate("adminUserBody")."\";");
$flag = $aUser->moveNext();
$count ++;
}
//分页信息
if($setid>0)
{
$presetid=$setid - $this->set[listnumUser];
$outPages .= "<a href=\"admin.php?modules=user?setid=$presetid\">[<]</a> \n";
}
// 计算总页数
$pages=ceil($num/$this->set[listnumUser]);
for ($i=0; $i < $pages; $i++)
{
$downetid = $this->set[listnumUser]*$i;
$outPages .= "<a href=\"admin.php?modules=user&setid=$downetid\">[".($i+1)."]</a> \n";
}
if ($pages != 0 && ($setid / $this->set[listnumUser] + 1) != $pages && ($setid / $this->set[listnumUser] + 1) <= $pages || $setid== 1)
{
$downetid=$setid + $this->set[listnumUser];
$outPages .= "<a href=\"admin.php?modules=user&setid=$downetid\">[>]</a>\n";
}
$aUser->close();
return $result;
}
function showRegister()
{
$header = $this->Header("用户管理");
$banner = $this->printBanner($this->input[categoryid], $this->input[classid], "admin.php?modules=main");
$adminMenu = $this->getAdminMenu();
$userInfo = $this->getUserInfo($pages);
eval("\$this->output(\"".$this->getTemplate("adminUser")."\");");
}
function showLogin()
{
$header = $this->Header("管理员登录");
eval("\$this->output(\"".$this->getTemplate("login")."\");");
}
function showProfile()
{
$aUser = new CUser;
$aUser->open();
if(!$aUser->find($this->input[userid])) $this->showMsg("对不起,您要修改的用户ID非法!", "");
//用户组处理
if($aUser->groupid == "1") $optionGroup = "<option value=1 selected>超级管理员</option>\n<option value=2>一般管理员</option>";
else $optionGroup = "<option value=1>超级管理员</option>\n<option value=2 selected>一般管理员</option>";
$header = $this->Header("用户管理[信息修改]");
$banner = $this->printBanner($this->input[categoryid], $this->input[classid], "admin.php?modules=main");
$adminMenu = $this->getAdminMenu();
eval("\$this->output(\"".$this->getTemplate("adminUserProfile")."\");");
$aUser->close();
}
function showPassword()
{
$aUser = new CUser;
$aUser->open();
if(!$aUser->findByName($this->sess[PDUserName])) $this->showMsg("对不起,您要修改的用户名非法!", "");
//用户组处理
$userid = $aUser->getAbsolutePosition();
if($aUser->groupid == "1") $group = "超级管理员";
else $group = "普通管理员";
$header = $this->Header("用户管理");
$banner = $this->printBanner($this->input[categoryid], $this->input[classid], "admin.php?modules=main");
$adminMenu = $this->getAdminMenu();
eval("\$this->output(\"".$this->getTemplate("adminUserPass")."\");");
$aUser->close();
}
function logined()
{
$aUser = new CUser;
$aUser->open();
if(!$aUser->findByName($this->input[username])) $this->showMsg("对不起,您输入的用户名不存在,请重新输入!", "");
$user_password = $aUser->password;
$aUser->close();
if ($this->input[username] == "" || $this->input[password] == "") $this->showMsg("对不起,用户与密码不可为空,请重新输入!", "");
if (($this->input[password]) != $user_password) $this->showMsg("对不起,您输入的密码不正确,请重新输入!", "");
setcookie ("PDUserName", $this->input[username], time()+(1*24*3600));
setcookie ("PDPassword", $this->input[password], time()+(1*24*3600));
$this->showMsg("恭喜!您已成功登录本系统……", "admin.php");
}
function logout()
{
setcookie ("PDUserName","");
setcookie ("PDPassword","");
$this->showMsg("恭喜!您已成功注销。", "index.php");
}
function Register()
{
if($this->input[username] == "" || $this->input[password] == "" || $this->input[groupid] == "")
$this->showMsg("对不起,用户的\"名称\"、\"密码\"、\"用户组\"不可为空,请重新输入!", "");
$aUser = new CUser;
$aUser->open();
if($aUser->findByName($this->input[username])) $this->showMsg("对不起,您想用的用户名已被使用,换一个吧!", "");
$aUser->appendNew();
$aUser->username = $this->input[username];
$aUser->password = $this->input[password];
$aUser->groupid = $this->input[groupid];
$aUser->update();
$aUser->close();
$this->showMsg("恭喜,您的用户已成功添加!", "admin.php?modules=user");
}
function deleteUser()
{
$aUser = new CUser;
$aUser->open();
if(!$aUser->find($this->input[userid])) $this->showMsg("对不起,您要删除的用户ID非法!", "");
$aUser->delete();
$this->showMsg("恭喜,用户已成功删除!!", "admin.php?modules=user");
}
function modifyProfile()
{
if($this->input[username] == "" || $this->input[password] == "" || $this->input[groupid] == "")
$this->showMsg("对不起,用户的\"名称\"、\"密码\"、\"用户组\"不可为空,请重新输入!", "");
$aUser = new CUser;
$aUser->open();
//if($aUser->findByName($this->input[username])) $this->showMsg("对不起,您想用的用户名已被使用,换一个吧!", "");
if(!$aUser->find($this->input[userid])) $this->showMsg("对不起,您要修改的用户ID非法!", "");
$aUser->username = $this->input[username];
$aUser->password = $this->input[password];
$aUser->groupid = $this->input[groupid];
$aUser->update();
$aUser->close();
$this->showMsg("恭喜,您的用户已修改成功!", "admin.php?modules=user");
}
function modifyPassword()
{
$aUser = new CUser;
$aUser->open();
if(!$aUser->find($this->input[userid])) $this->showMsg("对不起,您要修改密码的用户ID非法!", "");
$password = $aUser->password;
$oldpassword = $this->input[oldpassword];
$newpassword = $this->input[newpassword];
$repassword = $this->input[repassword];
if ($oldpassword != $password) $this->showMsg("对不起,您输入的旧密码与原密码不符,您无法修改!", "");
if ($this->input[username] == "" || $this->input[newpassword] == "") $this->showMsg("对不起,用户名和密码不可为空!", "");
if ($newpassword != $repassword) $this->showMsg("对不起,两次输入的密码不符,您无法修改!", "");
$aUser->username = $this->input[username];
$aUser->password = $this->input[newpassword];
$aUser->update();
$aUser->close();
$this->showMsg("恭喜,您的密码已成功修改!", "admin.php?modules=user");
}
}//end class
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -