?? user.php
字號(hào):
<?
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 ++;
}
//分頁(yè)信息
if($setid>0)
{
$presetid=$setid - $this->set[listnumUser];
$outPages .= "<a href=\"admin.php?modules=user?setid=$presetid\">[<]</a> \n";
}
// 計(jì)算總頁(yè)數(shù)
$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("對(duì)不起,您要修改的用戶ID非法!", "");
//用戶組處理
if($aUser->groupid == "1") $optionGroup = "<option value=1 selected>超級(jí)管理員</option>\n<option value=2>一般管理員</option>";
else $optionGroup = "<option value=1>超級(jí)管理員</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("對(duì)不起,您要修改的用戶名非法!", "");
//用戶組處理
$userid = $aUser->getAbsolutePosition();
if($aUser->groupid == "1") $group = "超級(jí)管理員";
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("對(duì)不起,您輸入的用戶名不存在,請(qǐng)重新輸入!", "");
$user_password = $aUser->password;
$aUser->close();
if ($this->input[username] == "" || $this->input[password] == "") $this->showMsg("對(duì)不起,用戶與密碼不可為空,請(qǐng)重新輸入!", "");
if (($this->input[password]) != $user_password) $this->showMsg("對(duì)不起,您輸入的密碼不正確,請(qǐng)重新輸入!", "");
setcookie ("PDUserName", $this->input[username], time()+(1*24*3600));
setcookie ("PDPassword", $this->input[password], time()+(1*24*3600));
$this->showMsg("恭喜!您已成功登錄本系統(tǒng)……", "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("對(duì)不起,用戶的\"名稱\"、\"密碼\"、\"用戶組\"不可為空,請(qǐng)重新輸入!", "");
$aUser = new CUser;
$aUser->open();
if($aUser->findByName($this->input[username])) $this->showMsg("對(duì)不起,您想用的用戶名已被使用,換一個(gè)吧!", "");
$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("對(duì)不起,您要?jiǎng)h除的用戶ID非法!", "");
$aUser->delete();
$this->showMsg("恭喜,用戶已成功刪除!!", "admin.php?modules=user");
}
function modifyProfile()
{
if($this->input[username] == "" || $this->input[password] == "" || $this->input[groupid] == "")
$this->showMsg("對(duì)不起,用戶的\"名稱\"、\"密碼\"、\"用戶組\"不可為空,請(qǐng)重新輸入!", "");
$aUser = new CUser;
$aUser->open();
//if($aUser->findByName($this->input[username])) $this->showMsg("對(duì)不起,您想用的用戶名已被使用,換一個(gè)吧!", "");
if(!$aUser->find($this->input[userid])) $this->showMsg("對(duì)不起,您要修改的用戶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("對(duì)不起,您要修改密碼的用戶ID非法!", "");
$password = $aUser->password;
$oldpassword = $this->input[oldpassword];
$newpassword = $this->input[newpassword];
$repassword = $this->input[repassword];
if ($oldpassword != $password) $this->showMsg("對(duì)不起,您輸入的舊密碼與原密碼不符,您無(wú)法修改!", "");
if ($this->input[username] == "" || $this->input[newpassword] == "") $this->showMsg("對(duì)不起,用戶名和密碼不可為空!", "");
if ($newpassword != $repassword) $this->showMsg("對(duì)不起,兩次輸入的密碼不符,您無(wú)法修改!", "");
$aUser->username = $this->input[username];
$aUser->password = $this->input[newpassword];
$aUser->update();
$aUser->close();
$this->showMsg("恭喜,您的密碼已成功修改!", "admin.php?modules=user");
}
}//end class
?>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -