<%@ Language=VBScript%>
<!-- #include file="../dsn.asp" -->
<!-- #include file="../links.asp" -->
<%
Response.Buffer=true
Response.Expires=0
%>
<%
if session("adminusername")="" then
		session("xhy")=1
		Response.Redirect linkwarn
end if
id=cint(Request.QueryString("id"))
pid=cint(Request.QueryString("pid"))
ppid=cint(Request.QueryString("ppid"))
pageno=Request.QueryString ("pageno")
backhtml=linkadminreferuser&"?pid="&pid&"&ppid="&ppid&"&pageno="&pageno
set cn=Server.CreateObject("ADODB.Connection")
set rs1=Server.CreateObject("ADODB.Recordset")
set rs2=Server.CreateObject("ADODB.Recordset")
set rs=Server.CreateObject("ADODB.Recordset")
cn.Open mycnstr
if ppid<>"" then
		sqltext="select title from scool where id="&ppid
		rs1.Open sqltext,cn,1,1
		if not rs1.EOF then
				scoolname=rs1("title")
		end if
		rs1.Close 
end if
if pid<>"" then
		sqltext="select title from classes where id="&pid
		rs1.Open sqltext,cn,1,1
		if not rs1.EOF then
				classname=rs1("title")
		end if
		rs1.Close 
end if
%>
<%
if Request.ServerVariables("REQUEST_METHOD")="POST" then
		username=trim(Request.Form("username"))
		password=trim(Request.Form("password"))
		namecn=trim(Request.Form("namecn"))
		if err<>1 and id<>0 then
			sqltext="select * from refer_user where enable=1 and id="&id
			rs.Open sqltext,cn,1,3
			if not rs.EOF then
				rs("username")=trim(username)
				rs("password")=trim(password)
				rs("namecn")=trim(namecn)
				rs("sex")=trim(Request.Form ("sex"))
				nd=Request.Form("nd")
				yf=Request.Form("yf")
				dd=Request.Form("dd")
				birthday=nd+"-"+yf+"-"+dd
				if IsDate(birthday) then
					rs("birthday")=cdate(birthday)			
				end if
				rs("codenum")=trim(Request.Form("certcode"))
				rs("codetxt")=trim(Request.Form("certclass"))
				rs("crop")=trim(Request.Form ("corpname"))
				rs("telphone")=trim(Request.Form ("phone"))
				rs("msnicq")=trim(Request.Form("qq"))
				rs("email")=trim(Request.Form ("email"))
				rs("address")=trim(Request.Form ("address"))
				rs("myweb")=trim(Request.Form ("website"))          
				rs("upupdate")=now()
				rs.Update 
				rs.Close 
				Response.Redirect backhtml
			end if	
		end if
end if

if id<>0 then
		sqltext1="select * from refer_user where id="&id
		rs1.Open sqltext1,cn,1,1
	if not rs1.EOF then	
		cdanweiname=trim(rs1("username"))
		username=trim(rs1("username"))
		yxx=rs1("enable")
		creatdate=rs1("creatdate")
		logincount=rs1("logincount")
		talk=rs1("talk")
		loginlastdate=rs1("loginlast")
		loginlastip=trim(rs1("loginlastip"))
		password=trim(rs1("password"))
		namecn=trim(rs1("namecn"))
		email=trim(rs1("email"))
		sex=trim(rs1("sex"))
		nd=year(rs1("birthday"))
		yf=month(rs1("birthday"))
		dd=day(rs1("birthday"))
		certclass=trim(rs1("codetxt"))
		certcode=trim(rs1("codenum"))
		corpname=trim(rs1("crop"))
		phone=trim(rs1("telphone"))
		address=trim(rs1("address"))
		qq=trim(rs1("msnicq"))
		website=trim(rs1("myweb"))
		rs1.Close
		if len(danweiname)>18 then
				danweiname=left(danweiname,18)&"..."
		end if
	end if	
	else
	    'danweiname="增加新帐号"
		yxx=1
end if
txtname="用户帐号"	
%>
<html>
<head>
<title>网站管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {font-size: 12px; color: #000000; font-family: 宋体}
td {font-size: 12px; color: #000000; font-family: 宋体;line-height:130%}
.t1 {font:12px 宋体;color=000000} 
.t2 {font:12px 宋体;color:ffffff} 
.t3 {font:12px 宋体;color:336699} 
.t4 {font:12px 宋体;color:ff0000} 
.t5 {font:12px 宋体;color:ff6600} 


.bt1 {font:14px 宋体;color=000000} 
.bt2 {font:12px 宋体;color:ffffff} 
.bt3 {font:14px 宋体;color:336699} 
.bt4 {font:14px 宋体;color:ff0000} 
.bt5 {font:14px 宋体;color:0000ff}
.bt10 {font:14px 宋体;color:0000ff}

.td1 {font-size:12px;background-color:#3388bb;color:#ffffff}
.td2 {font-size:12px;background-color:#ffffff;color:#000000;}

A:link {color: #000077}
A:visited {color: #000077}
A:hover {color: #ff0000}

A.r1:link {text-decoration:none;color:#304556;}
A.r1:visited {text-decoration:none;color:#304556;}
A.r1:hover {text-decoration:underline;color:ff6600;}

A.r2:link {text-decoration:none;color:#ffffff;}
A.r2:visited {text-decoration:none;color:#ffffff;}
A.r2:hover {text-decoration:underline;color:cccc00;}

-->
</style>
</head>

<body bgcolor=#ffffff topmargin=10>
<form action="<%=linkadminedituser%>?id=<%=id%>&pid=<%=pid%>&ppid=<%=ppid%>" method=post name=editform onsubmit="return checkeditform(editform)">
 
 <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr><td><font class=t5>当前位置:<%=scoolname%>→　<%=classname%>→　<%=danweiname%></b></font>
		← <a href="<%=backhtml%>">返回列表</a></td>
	</tr>
	<tr><td><hr size=1></td></tr>
	<tr bgcolor="#666669"><td height=20><font class=bt2>具体内容</font><br>
	</td></tr>
	<tr><td height=5></td></tr>
 </table>
 <div align=center class=t1><font color="red" size=2><b><%=errtxt%></b></font></div>
 <table width="100%" border="0" cellspacing="1" cellpadding="0" align="center">
	<tr><td width=70 align=right>是否有效：</td>
		<td>
			<%if yxx=1 then%>
					<input type="checkbox" checked name="c1" value=1>
				<%else%>
					<input type="checkbox" name="c1" value=1>
			<%end if%>					  	
		&nbsp;&nbsp;（注册时间：<font color=000000><%=creatdate%></font>
		&nbsp;&nbsp;发表数量：<font color=ff6600><%=talk%></font>）
	<tr><td width=70 align=right>登录情况：</td>
		<td>	
		上次登录时间：<font color=ff6600><%=loginlastdate%></font>
		&nbsp;&nbsp;上次登录IP地址：<font color=ff6600><%=loginlastip%></font>
		</td></tr>
	<tr><td width=70 align=right><%=txtname%>：</td>
		<td><input type="text" value="<%=username%>" name=username maxlength=60 size=30><font color=red>*</font></td></tr>
	<tr><td width=70 align=right>登录密码：</td>
		<td><input type="password" value="<%=password%>" name= password maxlength=60 size=30><font color=red>*</font></td></tr>	
	<tr><td width=70 align=right>验证密码：</td>
		<td><input type="password" value="<%=password%>" name=password2 maxlength=60 size=30><font color=red>*</font></td></tr>			
	<tr><td width=70 align=right>真实姓名：</td>
		<td><input type="namecn" value="<%=namecn%>" name=namecn maxlength=60 size=35><font color=red>*</font></td></tr>			
</table>	
 <table width="100%" border="0" cellspacing="1" cellpadding="0" align="center">
			<tr><td align=right height=20 width=80>性别：</td>
				<td>
					<input type=radio name=sex value="男" <%if sex="男" then Response.Write ("checked")%>>男
					<input type=radio name=sex value="女" <%if sex="女" then Response.Write ("checked")%>>女&nbsp;&nbsp;&nbsp;&nbsp;
					出生日期：
					<input type=text name=nd size=4 maxlength=4 value="<%=nd%>">年
					<input type=text name=yf size=2 maxlength=2 value="<%=yf%>">月
					<input type=text name=dd size=2 maxlength=2 value="<%=dd%>">日
			</td></tr>
			<tr><td align=right height=20>证件号码：</td>
				<td>
					<input type=text name=certcode size=20 maxlength=20 value="<%=certcode%>">&nbsp;<font color=ff4500>*</font>
					<select name="certclass">
						<option value=01 <%if certclass="01" then Response.Write("selected")%>>身份证
						<option value=04 <%if certclass="04" then Response.Write("selected")%>>学生证
						<option value=02 <%if certclass="02" then Response.Write("selected")%>>护照
						<option value=03 <%if certclass="03" then Response.Write("selected")%>>军人证
						<option value=09 <%if certclass="09" then Response.Write("selected")%>>其它
					</select>
			</td></tr>
			<tr><td align=right height=20>工作单位：</td>
				<td>
			        <input type=text name=corpname size=50 value='<%=corpname%>' maxlength=50>
			</td></tr>
			<tr><td align=right height=20>联系电话：</td>
				<td>
				  <input type=text name=phone size=30 maxlength=20 value="<%=phone%>">
			</td></tr>
			<tr><td align=right height=20>联系地址：</td>
				<td>
				  <input type=text name=address size=50 maxlength=80 value="<%=address%>">
			</td></tr>
			<tr><td align=right height=20>电子信箱：</td>
				<td>
				  <input type=text name=email size=30 maxlength=60 value="<%=email%>">&nbsp;<font color=ff4500>*</font>
			</td></tr>
			<tr><td align=right height=20>QQ等：</td>
				<td>
				  <input type=text name=qq size=20 maxlength=30 value="<%=qq%>">
				  也可填入OICQ或MSN,请注明
			</td></tr>
			<tr><td align=right height=20>个人主页：</td>
				<td>
				  <input type=text name=website size=30 maxlength=80 value="<%=website%>">
			</td></tr>					
</table>			
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr><td width=200></td><td height=10></td></tr>
	<tr>
	<td width=200></td>
	<td align=left>
		<input type="submit" name="ss1" value="确认提交">&nbsp;&nbsp;&nbsp;&nbsp;
	</td></tr>
	<tr><td width=200></td><td height=10></td></tr>
</table>
</form>
<form name=preview method=post action="<%=linkbodyview%>" target=winview>
	<input type=hidden name=viewtitle value=""><input type=hidden name=viewbody value="">
</form>

</body>
</html>
<script language=Javascript>

	function format(flag)
	{
		switch(flag){
			case "bold":
				begintxt="<b>";
				endtxt="</b>";
				break;
			case "italic":
				begintxt="<i>";
				endtxt="</i>";
				break;
			case "underline":
				begintxt="<u>";
				endtxt="</u>";
				break;
			case "center":
				begintxt="<center>";
				endtxt="</center>";
				break;
			case "space":
				begintxt="&nbsp;";
				endtxt="";
				break;
		}
		dealcontent()
	}

	function formatpic(newvalue)
	{
		if(newvalue!=0){
		begintxt="<table width=100% border=0 cellspacing=0 cellpadding=0 align=center><tr><td align=center><img src=./jpg.asp?tabname=danweipic&id="+newvalue+"></td></tr></table>"
		endtxt="";
		dealcontent()}
	}

	function formaturl(newvalue)
	{
		var urladd=window.prompt ("请在输入链接地址！","http://")
		begintxt="<a href="+urladd+">"
		endtxt="</a>";
		dealcontent()
	}
	
	function formatcolor(newvalue)
	{
		begintxt="<font color="+newvalue+">"
		endtxt="</font>";
		dealcontent()
	}

	function formatfont(newvalue)
	{
		begintxt="<font face="+newvalue+">"
		endtxt="</font>";
		dealcontent()
	}

	function formatsize(newvalue)
	{
		begintxt="<font size="+newvalue+">"
		endtxt="</font>";
		dealcontent()
	}

	function dealcontent()
	{
		
		if ((document.selection)&&(document.selection.type == "Text"))
		{
		var range = document.selection.createRange();
		var ch_text=range.text;
		range.text = begintxt + ch_text + endtxt;
		} 
		else 
		{
		document.editform.content.value=begintxt+document.editform.content.value+endtxt;
		document.editform.content.focus();
		}
	}


	function gopreview()
	{
	document.preview.viewtitle.value=document.editform.title.value;
	document.preview.viewbody.value=document.editform.content.value;
	window.open('<%=linkbodyview%>', 'winview', 'scrollbars=yes,width=500,height=400');
	document.preview.submit()
	}



	function checkeditform(form)
	{
		var flag=true;
		if(form("username").value=="")
			{alert("请输入用户帐号!");form("username").focus();flag=false;return flag}else{flag=true}	
		if(form("namecn").value=="")
			{alert("请输入真实名称!");form("namecn").focus();flag=false;return flag}else{flag=true}
		if(form("password").value=="")
			{alert("密码不能为空!");form("password").focus();flag=false;return flag}else{flag=true}
		if(form("password2").value!=form("password").value)
			{alert("两次密码不一致!");
			form("password").value="";
			form("password2").value="";
			form("password").focus();flag=false;return flag}else{flag=true}
		return flag;
			
	}	
</script>
<%
function checkstring(str)
	if str<>"" then
			a=instr(str,"http://")
			if a<>1 then
					checkstring="http://"&str
				else
					checkstring=str
			end if
	end if
end function
%>
