📄 user.php
字号:
<?php
// ------------------------------ -------- ------------------------------ //
require ("../include/config.inc.php");
require ("./global.php");
// ------------------------------ -------- ------------------------------ //
mysql_connect($dbhost,$dbuser,$dbpasswd) or die ("数据库连接失败");
// check cookie
islogin($HTTP_COOKIE_VARS[$cookie_name][1],$HTTP_COOKIE_VARS[$cookie_name][2]);
$cookie_user = $HTTP_COOKIE_VARS[$cookie_name][1];
// ------------------------------ -------- ------------------------------
include ("../include/header.inc.php");
// ------------------------------ -------- ------------------------------
// logout
if ($action == "logout"):
logout_user($HTTP_COOKIE_VARS[$cookie_name][1],$HTTP_COOKIE_VARS[$cookie_name][2]);
exit;
endif;
// get mygroupid
$sql = "SELECT groupid FROM $ym_article_user_table WHERE username='$cookie_user'";
$result = mysql_db_query($dbname, $sql);
$objresult = mysql_fetch_object($result);
$mygroupid = $objresult->groupid;
echo "<title>控制面板</title>\n";
echo "<center><br>\n";
// 搜索跳转 ------------------------------
echo "<center><br>\n";
echo "<br><table border=0 cellpadding=3 cellspacing=0 style='border-collapse:collapse' bordercolor=#efefef width=735>\n";
echo "<tr>\n";
echo "<td class=shadow2 width=190 valign=bottom>\n";
// 本类/总数 ------------------------------
all_and_this();
// 搜索表单 ------------------------------
$typesql = "SELECT COUNT(*) AS rcnt FROM $ym_article_sort_table ORDER BY id";
$typeresult = mysql_db_query($dbname, $typesql);
$typerow = mysql_fetch_array($typeresult);
$typesql = "SELECT * FROM $ym_article_sort_table ORDER BY id";
$typeresult = mysql_db_query($dbname, $typesql);
echo "</td>\n";
echo "<form method=POST action=list.php>\n";
echo "<td width=405 align=center valign=bottom>\n";
echo "<img src='../images/search.gif' width=16 heigth=16> ";
echo "标题<input type=checkbox name=title value='1' ";
echo ($name == 0 ? '' : checked);
echo ">\n";
echo "内容<input type=checkbox name=text value='1' ";
echo ($brief == 0 ? '' : checked);
echo ">\n";
echo "<input class=border type=text name=keyword size=12 style='color:#000000; background-color:#efefef'>\n";
echo "<select size=1 name=searchtype style='color:#000000; border-style:solid; border-width:1; background-color:#efefef'>\n";
echo "<option value=0 selected>所有文章</option>\n";
while ($typerow=mysql_fetch_array($typeresult)) {
echo "<option value=".$typerow[id].">".$typerow[name]."</option>\n";
}
echo "</select> \n";
echo "<input class=border type=submit value=搜索 name=search style='color: #000000; background-color: #efefef'>\n";
echo "</td></form>";
// 跳转分类 -----------------------------
goto($type);
echo "</tr>\n";
echo "</table>\n";
echo "<br>\n";
// ---------------------------------------
echo "<table border=0 cellspacing=0 style='border-collapse:collapse' width=735 height=233 cellpadding=3>\n";
echo "<tr>\n";
// 栏目菜单 ------------------------------
echo "<td width=185 valign=top>\n";
adminmenu();
echo "</td>\n";
// ---------------------------------------
echo "<td width=550 height=233 valign=top>\n";
// 转到搜索 ------------------------------
if ($search):
search($keyword,$searchtype,$title,$text);
end;
else:
// ------------------------- 修改密码 -------------------------
if ($useredit):
editpass($newusername,$oldpassword,$newpassword,$repassword);
echo "<br><center><a href=list.php>已修改</a><br>";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=list.php'>";
end;
else:
// ------------------------- 删除用户 -------------------------
if (!$delete == "" && $mygroupid == "1"):
deluser($delete);
echo "<br><center><a href=user.php>已删除</a><br>";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=user.php'>";
end;
else:
// ------------------------- 编辑用户发送 -------------------------
if ($sendedit):
edituser($username,$password,$groupid);
echo "<br><center><a href=user.php>已编辑</a><br>";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=user.php'>";
end;
else:
// ------------------------- 编辑用户 -------------------------
if (!$edit == "" && $mygroupid == "1"):
$sql = "SELECT * FROM $ym_article_user_table WHERE id=$edit";
$result = mysql_db_query($dbname, $sql);
$obj = mysql_fetch_object($result);
$username = $obj->username;
$password = $obj->password;
$groupid = $obj->groupid;
echo "<br><center><br><br><br><br>";
echo "<form action=user.php method=POST>";
echo "编号: <input type=text name=edit size=3 value='".$edit."' readonly class=border style='color:#000000; background-color:#efefef'> \n";
echo "用户名: <input type=text name=username size=12 value='".$username."' class=border style='color:#000000; background-color:#efefef'> \n";
echo "密码: <input type=text name=password size=12 value='".$password."' class=border style='color:#000000; background-color:#efefef'> \n";
echo "<select size=1 name=groupid style='color:#000000; border-style:solid; border-width:1; background-color:#efefef'>";
echo "<option ";
if ($groupid == 1):
echo "selected";
endif;
echo " value='1'> 超级管理员 </option><option ";
if ($groupid == 2):
echo "selected";
endif;
echo " value='2'> 普通管理员 </option></select> \n";
echo "<input type=submit value=提交 name=sendedit class=border style='color: #000000; background-color: #efefef'> \n";
echo "<input type=reset value=重填 class=border style='color: #000000; background-color: #efefef'>";
echo "</form>";
end;
else:
// ------------------------- 添加用户发送 -------------------------
if ($sendadd):
adduser($username,$password,$groupid);
echo "<br><center><a href=user.php>已添加</a><br>";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=user.php'>";
end;
else:
// ------------------------------ 超级管理员 ------------------------------
if ($mygroupid == 1):
echo "<center><br><table border=0 cellspacing=0 cellpadding=3 width=90%>\n";
echo "<tr><form action=user.php method=POST><td class=shadow2>\n";
echo "<b>添加用户:</b><br>\n";
echo "</td></tr><tr><td>\n";
echo "用户名 \n";
echo "<input type=text name=username size=12 class=border style='color:#000000; background-color:#efefef'> \n";
echo "密码 \n";
echo "<input type=text name=password size=12 class=border style='color:#000000; background-color:#efefef'> \n";
echo "<select size=1 name=groupid style='color:#000000; border-style:solid; border-width:1; background-color:#efefef'><option value='1'> 超级管理员 </option><option selected value='2'> 普通管理员 </option></select> \n";
echo "<input type=submit value=提交 name=sendadd class=border style='color: #000000; background-color: #efefef'> \n";
echo "<input type=reset value=重填 class=border style='color: #000000; background-color: #efefef'>";
echo "</td></form></tr></table><br>\n";
$sql = "SELECT COUNT(*) AS rcnt FROM $ym_article_user_table ORDER BY id";
$result = mysql_db_query($dbname, $sql);
$row = mysql_fetch_array($result);
$num = $row[rcnt];
if (empty($setid)):
$setid = 0;
endif;
$sql = "SELECT * FROM $ym_article_user_table ORDER BY id LIMIT $setid, 10";
$result = mysql_db_query($dbname, $sql);
// 显示返回记录
echo "<br><table border=0 cellspacing=0 cellpadding=3 width=90%>";
echo "<tr>";
echo "<td colspan=6><b>管理用户:</b></td>";
echo "</tr>\n";
echo "<tr bgcolor=#efefef>";
echo "<td width=10%>编号</td>";
echo "<td width=20%>用户名</td>";
echo "<td width=20%>密码</td>";
echo "<td width=20%>用户组</td>";
echo "<td width=15%> </td>";
echo "<td width=15%> </td>";
echo "</tr>\n";
while ($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row[id]."</td>";
echo "<td>".$row[username]."</a></td>";
echo "<td>".$row[password]."</td>";
echo "<td>".$row[groupid]."</td>";
echo "<td><a href='user.php?edit=".$row[id]."'>编辑</a></td>";
echo "<td><a href='user.php?delete=".$row[id]."'>删除</a></td>";
echo "</tr>\n";
}
echo "</table><br>";
echo "<table border=0 cellspacing=0 cellpadding=3 width=500>\n";
echo "<tr><td align=center>\n";
// 页面的链接
if($setid>0):
$presetid=$setid-$list_num;
echo "<a href=\"user.php?setid=$presetid\">[<]</a> \n";
endif;
// 计算总页数
$pages=ceil($num/$list_num);
for ($i=0; $i < $pages; $i++)
{
$userid=$list_num*$i;
echo "<a href=\"user.php?setid=$userid\">[".($i+1)."]</a> \n";
}
if ($pages!=0 && ($setid/$list_num+1)!=$pages && ($setid/$list_num+1)<=$pages||$setid==1):
$userid=$setid+$list_num;
echo "<a href=\"user.php?setid=$userid\">[>]</a>\n";
endif;
echo "</tr></td></table>\n";
echo "<br><br>";
// ------------------------------ 普通管理员 ------------------------------
else:
$sql = "SELECT * FROM $ym_article_user_table WHERE username='$cookie_user'";
$result = mysql_db_query($dbname, $sql);
$objresult = mysql_fetch_object($result);
$id = $objresult->id;
echo "<br><center><br><br><br>";
echo "<b>修改密码</b><br>";
echo "<form action=user.php method=POST>";
echo "编 号:<input type=text name=id size=20 value='".$id."' readonly class=border style='color: #000000; background-color: #efefef'><br>";
echo "用户名:<input type=text name=newusername size=20 value='".$cookie_user."' class=border style='color: #000000; background-color: #efefef'><br>";
echo "原密码:<input type=password name=oldpassword size=20 value='' class=border style='color: #000000; background-color: #efefef'><br>";
echo "新密码:<input type=password name=newpassword size=20 value='' class=border style='color: #000000; background-color: #efefef'><br>";
echo "新密码:<input type=password name=repassword size=20 value='' class=border style='color: #000000; background-color: #efefef'><br>";
echo "用户组:普通管理员<br>\n";
echo "<input type=submit value=提交 name=useredit class=border style='color: #000000; background-color: #efefef'> \n";
echo "<input type=reset value=重填 class=border style='color: #000000; background-color: #efefef'>";
echo "</form>";
endif; // if mygroupid
// ------------------------------ 结束显示 ------------------------------ //
endif; // if sendadd
endif; // if edit
endif; // if sendedit
endif; // if delete
endif; // if useredit
endif; // if search
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><hr width=735>\n";
mysql_close();
// ------------------------------ -------- ------------------------------ //
include ("../include/footer.inc.php");
// ------------------------------ -------- ------------------------------ //
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -