<!-- #include file="Setup.asp" --><%
BlogUserName=HTMLEncode(Request("BlogUserName"))
BlogID=int(Request("BlogID"))
BlogDate=HTMLEncode(request("BlogDate"))
content=ContentEncode(Request("content"))
TextContent=HTMLEncode(Request("TextContent"))
Subject=HTMLEncode(Request("Subject"))
Category=HTMLEncode(Request("Category"))
UpFileID=int(Request("UpFileID"))
top

sql="select * from [BBSXP_Users] where UserName='"&BlogUserName&"'"
Set Rs=Conn.Execute(sql)
if Rs.eof then error("<li>该用户资料不存在")
select case Rs("UserSex")
case "male"
UserSex="男"
case "female"
UserSex="女"
end select

if IsDate(Rs("birthday")) then birthyear=year(now)-split(cDate(Rs("birthday")),"-")(0)

UserFace=Rs("UserFace")
UserInfo=split(Rs("UserInfo"),"\")
realname=UserInfo(0)
country=UserInfo(1)
province=UserInfo(2)
city=UserInfo(3)
Postcode=UserInfo(4)
blood=UserInfo(5)
belief=UserInfo(6)
occupation=UserInfo(7)
marital=UserInfo(8)
education=UserInfo(9)
college=UserInfo(10)
address=UserInfo(11)
phone=UserInfo(12)
character=UserInfo(13)
personal=UserInfo(14)
UserFriend=Rs("UserFriend")
Rs.close

sql="select * from [BBSXP_BlogSettings] where UserName='"&BlogUserName&"'"
rs.Open sql,Conn,1,3
if RS.EOF then
Rs.addNew
Rs("BlogTitle")=BlogUserName&"的共享空间"
Rs("UserName")=BlogUserName
Rs.update
end if
BlogTitle=Rs("BlogTitle")
BlogTagline=Rs("BlogTagline")
BlogComments=Rs("BlogComments")
NumBlogs=Rs("NumBlogs")
BlogUserName=Rs("UserName")
BlogBgcolor=Rs("BlogBgcolor")
BlogBackground=Rs("BlogBackground")
BlogAudio=Rs("BlogAudio")
BlogPermissions=Rs("BlogPermissions")
Rs.close
''''''''''''''''''''''''''''''''''''''''''''''''''''''

if BestRole<>1 then 
if BlogPermissions="friends" then
if instr("|"&UserFriend&"|","|"&CookieUserName&"|")<1 and BlogUserName<>CookieUserName and CookieUserName<>"" then error("<li>该空间为授权访问模式，必须是空间主人的朋友才可以访问")
elseif BlogPermissions="username" then
if CookieUserName="" then error("<li>该空间必须登录后才可以访问")
elseif BlogPermissions="Close" then
error("<li>该空间已被管理员关闭")
end if
end if

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
select case Request("menu")
case "Del"

CheckPOST

sql="Select * From [BBSXP_Blogs] where id="&BlogID&""
Set Rs=Conn.Execute(sql)
BolgUserName=Rs("UserName")
ParentID=Rs("ParentID")
Set Rs = Nothing

'检查博客主题作者
if ParentID<>0 then BolgUserName=conn.Execute("Select UserName From [BBSXP_Blogs] where id="&ParentID&"")(0)
if BolgUserName<>CookieUserName then error("<li>只有博客主人才有删除权限")

Conn.execute("Delete From [BBSXP_Blogs] where ID="&BlogID&" or ParentID="&BlogID&"")

if ParentID<>0 then '更新统计
TotalReplies=conn.Execute("Select count(ID) From [BBSXP_Blogs] where ParentID="&ParentID&"")(0)
Conn.execute("update [BBSXP_Blogs] set TotalReplies="&TotalReplies&" where id="&ParentID&"")
response.redirect "?BlogUserName="&BlogUserName&"&BlogID="&ParentID&"&menu=Loading"
end if

Message="<li>删除成功<li><a href=?BlogUserName="&BlogUserName&">返回日志</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url=?BlogUserName="&BlogUserName&">")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
case "AddUp"
if Content="" then error("<li>内容不能为空")
sql="select * from [BBSXP_Blogs] where UserName='"&CookieUserName&"' and ID="&BlogID&""
Rs.Open sql,Conn,1,3
if Rs.eof then
Rs.addNew
Rs("BlogDate")=""&year(now)&"-"&month(now)&""
end if
Rs("Subject")=""&Subject&""
Rs("Content")=""&Content&""
Rs("UserName")=CookieUserName
Rs("Category")=""&Category&""
Rs.update
Rs.close
Message="<li>添加/编辑成功<li><a href=?BlogUserName="&BlogUserName&">返回日志</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url=?BlogUserName="&BlogUserName&">")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
case "AddPhotoUp"
UpFileID=int(Request("UpFileID"))
FileName=HTMLEncode(request("FileName"))
Description=HTMLEncode(request("Description"))

Conn.execute("update [BBSXP_UpFiles] set FileName='"&FileName&"',Category='"&Category&"',Description='"&Description&"' where UserName='"&CookieUserName&"' and id="&UpFileID&"")

Message="<li>添加成功<li><a href=?BlogUserName="&BlogUserName&"&menu=Photo>返回相册</a><li><a href=?BlogUserName="&BlogUserName&">返回日志</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url=?BlogUserName="&BlogUserName&"&menu=Photo>")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
case "comment"
if TextContent="" then error("<li>内容不能为空")
sql="insert into [BBSXP_Blogs](ParentID,Content,UserName) values ('"&BlogID&"','"&TextContent&"','"&CookieUserName&"')"
conn.Execute(SQL)
Conn.execute("update [BBSXP_Blogs] set TotalReplies=TotalReplies+1 where id="&BlogID&"")
response.redirect "?BlogUserName="&BlogUserName&"&BlogID="&BlogID&"&menu=Loading"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
case "MyBlogSettingUp"
Rs.Open "[BBSXP_BlogSettings] where UserName='"&CookieUserName&"' ",Conn,1,3
if Rs.eof then Rs.addNew
Rs("BlogTitle")=HTMLEncode(Request("BlogTitle"))
Rs("BlogTagline")=HTMLEncode(Request("BlogTagline"))
Rs("BlogComments")=int(Request("BlogComments"))
Rs("NumBlogs")=int(Request("NumBlogs"))
Rs("BlogBgcolor")=HTMLEncode(Request("BlogBgcolor"))
Rs("BlogBackground")=HTMLEncode(Request("BlogBackground"))
Rs("BlogAudio")=HTMLEncode(Request("BlogAudio"))
Rs("BlogPermissions")=HTMLEncode(Request("BlogPermissions"))
Rs.update
Rs.close
Message="<li>设置成功<li><a href=?BlogUserName="&CookieUserName&">返回日志</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url=?BlogUserName="&CookieUserName&">")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
case "Loading"
sql="select * from [BBSXP_Blogs] where ParentID="&BlogID&" order by id Desc"
Set Rs=Conn.Execute(sql)
TotalCount=conn.Execute("Select count(ID) From [BBSXP_Blogs] where ParentID="&BlogID&"")(0) '获取数据数量
PageSetup=10 '设定每页的显示数量
TotalPage=Abs(Int(TotalCount/PageSetup*(-1))) '总页数
PageCount = cint(Request.QueryString("PageIndex")) '获取当前页
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage>1 then RS.Move (PageCount-1) * pagesetup

if PageCount<2 then
PagePrevious="上一页"
else
PagePrevious="<a target=hiddenframe href=?BlogUserName="&BlogUserName&"&menu=Loading&BlogID="&BlogID&"&PageIndex="&PageCount-1&">上一页</a>"
end if

if PageCount=TotalPage  then
PageNext="下一页"
else
PageNext="<a target=hiddenframe href=?BlogUserName="&BlogUserName&"&menu=Loading&BlogID="&BlogID&"&PageIndex="&PageCount+1&">下一页</a>"
end if

i=0
Do While Not RS.EOF and i<pagesetup
i=i+1

if BlogUserName=CookieUserName then IsDelReplie="<a target=hiddenframe href=?BlogUserName="&BlogUserName&"&menu=Del&BlogID="&Rs("ID")&">删除</a>"

comment=comment&"<tr class=a3><td>"&Rs("Content")&"<br><br><table border=0 width=100% ><tr><td>发布者：<a href=?BlogUserName="&Rs("UserName")&">"&Rs("UserName")&"</a> - "&Rs("DateCreated")&"</td><td align=right>"&IsDelReplie&"</td></tr></table></td></tr>"
Rs.MoveNext
loop

Set Rs = Nothing



if CookieUserName<>empty then comment=comment&"<tr class=a3><td colspan=2><form name=form method=POST target=hiddenframe action=?BlogUserName="&BlogUserName&"&menu=comment><input type=hidden name=BlogID value="&BlogID&"><textarea name=TextContent style=width:100% rows=6 onkeyup=ValidateTextboxAdd(this,'btnadd"&BlogID&"') onpropertychange=ValidateTextboxAdd(this,'btnadd"&BlogID&"')></textarea><input  id='btnadd"&BlogID&"' disabled type=submit value='发布评论'> <input onclick='loadBlogFollow("&BlogID&");' type=button value='取消'></td></form></tr> "
%>
<script>
var parentfollowTd=parent.document.getElementById("followTd<%=BlogID%>")
parentfollowTd.innerHTML="<table cellspacing=1 cellpadding=5 width=100% border=0 class=a2><tr class=a4><td><table cellspacing=0 cellpadding=0 width=100% border=0><tr><td><b>评论</b></td><td align=right><%=PagePrevious%> | <%=PageNext%> | <a onclick='loadBlogFollow(<%=BlogID%>);return false;' href=# style=cursor:hand>关闭</a></td></tr></table></td></tr><%=comment%></table>";
</script>
<%
Response.End
case "PermissionSettings"
CheckPOST
state=HTMLEncode(request("state"))
if CookieUserName=empty then error2("非法操作！")
if BestRole=1 then Conn.execute("update [BBSXP_BlogSettings] set BlogPermissions='"&state&"' where UserName='"&BlogUserName&"'")
Message="<li>设置成功<li><a href=?BlogUserName="&CookieUserName&">返回日志</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url=?BlogUserName="&CookieUserName&">")

end select


%><title><%=BlogTitle%></title>
<script>Logo.innerHTML="<font size=4><%=BlogTitle%></font><br><b><%=BlogTagline%></b>"</script>
<%if BestRole=1 then%>
<div class="mainnav">
<table border="0" width="100%">
	<tr>
		<td align="right">
		<a onmouseover="showmenu(event,'&lt;div class=menuitems&gt;&lt;a href=?BlogUserName=<%=BlogUserName%>&amp;Menu=PermissionSettings&amp;state=everyone&gt;公共&lt;/a&gt;&lt;/div&gt;&lt;div class=menuitems&gt;&lt;a href=?BlogUserName=<%=BlogUserName%>&amp;Menu=PermissionSettings&amp;state=username&gt;注册用户&lt;/a&gt;&lt;/div&gt;&lt;div class=menuitems&gt;&lt;a href=?BlogUserName=<%=BlogUserName%>&amp;Menu=PermissionSettings&amp;state=friends&gt;我的好友&lt;/a&gt;&lt;/div&gt;&lt;div class=menuitems&gt;&lt;a href=?BlogUserName=<%=BlogUserName%>&amp;Menu=PermissionSettings&amp;state=Close&gt;关闭空间&lt;/a&gt;&lt;/div&gt;')" style="cursor:default">
		访问权限： <%
if BlogPermissions="Close" then
response.write "关闭"
elseif BlogPermissions="username" then
response.write "注册用户"
elseif BlogPermissions="friends" then
response.write "我的好友"
else
response.write "公共"
End if
%> </a><a href="Rss.asp?BlogUserName=<%=BlogUserName%>">
		<img src="images/rss_button.gif" border="0" title="订阅 RSS 源"></a> </td>
	</tr>
</table>
<%End if%>
<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2">
	<tr class="a3">
		<td colspan="5">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td>&nbsp;<img src="images/Forum_nav.gif">&nbsp; <%ClubTree%> →
				<a href="?BlogUserName=<%=BlogUserName%>"><%=BlogTitle%></a></td>
				<td align="right">
				<script>document.write("<a target=_blank href='Mailto:?subject="+document.title+"&body="+location.href+"'>");</script>
				告诉朋友</a> |
				<a href="#" onclick="javascript:OpenFriendWindow('MyFriend.asp?menu=Post&amp;incept=<%=BlogUserName%>&amp;IsPublish=1')">
				给我留言</a> |
				<a href="?BlogUserName=<%=BlogUserName%>&menu=ShowBlog">网络日志</a> 
				| <a href="?BlogUserName=<%=BlogUserName%>&menu=Photo">相册</a> |
				<a href="?BlogUserName=<%=BlogUserName%>&menu=GuestBook">留言簿</a>
				<%if BlogUserName=CookieUserName then%> |
				<a onmouseover="showmenu(event,'&lt;div class=menuitems&gt;&lt;a href=?BlogUserName=<%=BlogUserName%>&amp;Menu=Add&gt;添加日志&lt;/a&gt;&lt;/div&gt;&lt;div class=menuitems&gt;&lt;a href=?BlogUserName=<%=BlogUserName%>&amp;Menu=AddPhoto&gt;上传照片&lt;/a&gt;&lt;/div&gt;&lt;div class=menuitems&gt;&lt;a href=?BlogUserName=<%=BlogUserName%>&amp;menu=MyBlogSetting&gt;设置我的共享空间&lt;/a&gt;&lt;/div&gt;')" style="cursor:default">
				管理</a> <%End if%> </td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<br>
<%
select case Request("menu")
case ""
Default
case "Add"
Add
case "MyBlogSetting"
MyBlogSetting
case "GuestBook"
GuestBook
case "Photo"
Photo
case "ShowPhoto"
ShowPhoto

case "ShowBlog"
ShowBlog
case "AddPhoto"
AddPhoto

end select

Sub GuestBook


sql="[BBSXP_Messages] where Incept='"&BlogUserName&"' and IsPublish=1"

TotalCount=conn.Execute("Select count(ID) From "&sql&" ")(0) '获取数据数量

PageSetup=10 '设定每页的显示数量
TotalPage=Abs(Int(TotalCount/PageSetup*(-1))) '总页数
PageCount = cint(Request.QueryString("PageIndex")) '获取当前页
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
Set Rs=Conn.Execute(""&sql&" order by id Desc")
if TotalPage>1 then RS.Move (PageCount-1) * pagesetup


%>
<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2">
	<tr class="a1">
		<td align="center">留言人</td>
		<td align="center">留言内容 </td>
	</tr>
	<%
i=0
Do While Not RS.EOF and i<pagesetup
i=i+1
%>
	<tr class="a3">
		<td width="150" align="center" valign="top"><%
Set Rs1=Conn.Execute("[BBSXP_Users] where UserName='"&Rs("UserName")&"'")
%><br>
		<img src="<%=Rs1("Userface")%>" onload="javascript:if(this.width&gt;120)this.width=120;if(this.height&gt;120)this.height=120;">
		<br>
		<a href="Profile.asp?UserName=<%=Rs("UserName")%>"><%=Rs("UserName")%></a>
		<%
Set Rs1 = Nothing
%> 　</td>
		<td valign="top">
		<table border="0" width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td><img border="0" src="Images/jt.gif"> <%=Rs("DateCreated")%></td>
				<td align="right"><%if BlogUserName=CookieUserName then%>
				<a class="CommonImageTextButton" style="BACKGROUND-IMAGE:url(images/NewPost.gif)" href="#" onclick="javascript:OpenFriendWindow('MyFriend.asp?menu=Post&amp;incept=<%=Rs("UserName")%>&amp;ParentID=<%=Rs("id")%>');return false;">
				回复</a>
				<a onclick="return confirm('您确定要删除该留言?')" class="CommonImageTextButton" style="BACKGROUND-IMAGE:url(images/delete.gif)" href="MyMessage.asp?menu=Del&id=<%=Rs("id")%>">
				删除</a> <%end if%> </td>
			</tr>
		</table>
		<br>
		<%=Rs("Content")%>
		<ul>
			<%
sql="select * from [BBSXP_Messages] where ParentID="&Rs("id")&" order by id Desc"
Set Rs1=Conn.Execute(sql)
Do While Not Rs1.EOF
%><li><a href="Profile.asp?UserName=<%=Rs1("UserName")%>"><%=Rs1("UserName")%></a>
			<i><%=Rs1("DateCreated")%></i>： <br>
			<%=Rs1("Content")%><br>
			<br>
			</li>
			<%
Rs1.MoveNext
loop
Set Rs1 = Nothing
%> </li>
		</ul>
		</td>
	</tr>
	<%
Rs.MoveNext
loop
Set Rs = Nothing
%>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td><%ShowPage()%> </td>
		</td>
	</tr>
</table>
<%
End Sub

Sub Add

if BlogID<>empty then
sql="select * from [BBSXP_Blogs] where id="&BlogID&""
Set Rs=Conn.Execute(sql)
BlogID=Rs("ID")
Content=Rs("Content")
Subject=Rs("Subject")
Category=Rs("Category")
Set Rs = Nothing
end if

%>
<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2">
	<form method="POST" name="form" action="?BlogUserName=<%=BlogUserName%>&menu=AddUp" onsubmit="return CheckForm(this);">
		<input name="content" type="hidden" value='<%=content%>'>
		<input type="hidden" name="BlogID" value="<%=BlogID%>">
		<tr class="a1">
			<td width="100%" colspan="2" align="center"><b>添加/编辑日志</b></td>
		</tr>
		<tr class="a3">
			<td width="14%"><b>日志标题：</b></td>
			<td width="83%">
			<input maxlength="30" name="Subject" style="width:80%" value="<%=Subject%>">
			</td>
		</tr>
		<tr class="a3">
			<td width="14%"><b>类别：</b></td>
			<td width="83%"><select name="Category" size="1">
			<option value>无</option>
			<%
sql="select DISTINCT Category from [BBSXP_Blogs] where UserName='"&CookieUserName&"'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then
%>
			<option value="<%=Rs("Category")%>" <%if category=rs("category") then%>selected<%end if%>>
			<%=Rs("Category")%></option>
			<%
end if
Rs.MoveNext
loop
Set Rs = Nothing	
%></select> <a onclick="ChangeCategory('#');return false;" href="#">添加类别</a></td>
		</tr>
		<tr class="a3">
			<td width="14%"><b>日志内容：</b></td>
			<td width="83%" height="200">
			<script src="inc/post.js"></script>
			</td>
		</tr>
		<tr class="a3">
			<td colspan="2" align="center">
<INPUT type=submit value=" 发表 " name=EditSubmit>　<input type="Button" value=" 预览 " onclick="Preview()">　<INPUT onclick="history.back()" type="button" value=" 取消 ">
</TD></TR></FORM>
</TABLE>
<form name=preview action=preview.asp method=post target=preview_page><input name="content" type="hidden"></form>
<%
End Sub



Sub Default
%>
<table cellspacing="0" cellpadding="5" border="0" width="100%" bgcolor="<%=BlogBgcolor%>" background="<%=BlogBackground%>">
	<tr>
		<td valign="top" width="170">
		<table class="a2" width="100%" cellspacing="1" cellpadding="5" border="0">
			<tr class="a1">
				<td align="center"><b>档案文件</b></td>
			</tr>
			<tr align="center" class="a3">
				<td><img src="<%=UserFace%>" border="0">
				<table cellspacing="1" width="100%" border="0" style="TABLE-LAYOUT:fixed">
					<tr>
						<td valign="top" width="30%">姓名：</td>
						<td width="70%"><%=BlogUserName%></td>
					</tr>
					<tr>
						<td valign="top">年龄：</td>
						<td><%=birthyear%></td>
					</tr>
					<tr>
						<td valign="top">性别：</td>
						<td><%=UserSex%></td>
					</tr>
					<tr>
						<td valign="top">职业：</td>
						<td><%=occupation%></td>
					</tr>
					<tr>
						<td valign="top">位置：</td>
						<td><%=country%><br>
						<%=province%><br>
						<%=city%></td>
					</tr>
					<tr>
						<td colspan="2"><%=personal%></td>
					</tr>
				</table>
				</td>
			</tr>
			<tr align="center" class="a3">
				<td align="right">
				<a href="Profile.asp?UserName=<%=BlogUserName%>">查看档案文件详细信息</a></td>
			</tr>
		</table>
		<%
sql="select DISTINCT Category from [BBSXP_Favorites] where UserName='"&BlogUserName&"'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then
%><br>
		<table class="a2" width="100%" cellspacing="1" cellpadding="5" border="0">
			<tr>
				<td class=a1 align=center><b><%=Rs("Category")%></b></td>
			</tr>
			<tr class="a3">
				<td><hr><%
sql="select * from [BBSXP_Favorites] where UserName='"&BlogUserName&"' and Category='"&RS("Category")&"'"
Set Rs1=Conn.Execute(sql)
Do While Not RS1.EOF
				
response.write "<a target=_blank href="&Rs1("URL")&">"&Rs1("Name")&"</a><br>"&Rs1("Description")&"<hr>"
				
Rs1.MoveNext
loop
Set Rs1 = Nothing
%> </td>
			</tr>
		</table>
		<%
end if
Rs.MoveNext
loop
Set Rs = Nothing

%> </td>
		<td valign="top"><%
ShowBlog
%></td>
		<td width="170" align="right" valign="top"><%if BlogAudio<>"" then%>
		<table class="a2" width="100%" cellspacing="1" cellpadding="5" border="0">
			<tr>
				<td class=a1 align=center><b>Windows Media Player</b></td>
			</tr>
			<tr class="a3">
				<td>
				<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="100%">
					<param name="URL" value="<%=BlogAudio%>">
					<param name="uiMode" value="mini">
					<param name="stretchToFit" value="1">
				</object>
				</td>
			</tr>
		</table>
		<br>
		<%end if%>
		<table class="a2" width="100%" cellspacing="1" cellpadding="5" border="0">
			<tr>
				<td class=a1 align=center><b>类别</b></td>
			</tr>
			<tr class="a3">
				<td>
				<li><a href="?BlogUserName=<%=BlogUserName%>">全部类别</a></li> <%
sql="select DISTINCT Category from [BBSXP_Blogs] where UserName='"&BlogUserName&"'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then response.write "<li><a href=?BlogUserName="&BlogUserName&"&Category="&Rs("Category")&">"&Rs("Category")&"</a></li> "
Rs.MoveNext
loop
Set Rs = Nothing
%> </li>
				</td>
			</tr>
		</table>
		<br>
		<table class="a2" width="100%" cellspacing="1" cellpadding="5" border="0">
			<tr>
				<td class=a1 align=center><b>最新日志</b></td>
			</tr>
			<tr class="a3">
				<td><%
sql="select top 10 * from [BBSXP_Blogs] where UserName='"&BlogUserName&"' and ParentID=0 order by id Desc"
Set Rs=Conn.Execute(sql)
Do While Not Rs.EOF
%><li><a href="?BlogUserName=<%=BlogUserName%>&menu=ShowBlog&BlogID=<%=Rs("id")%>">
				<%=Rs("Subject")%></a></li><%
Rs.MoveNext
loop
Rs.Close   
%> </li>
				</td>
			</tr>
		</table>
		<br>
		<table class="a2" width="100%" cellspacing="1" cellpadding="5" border="0">
			<tr>
				<td class=a1 align=center><b>存档</b></td>
			</tr>
			<tr class="a3">
				<td><%
sql="select DISTINCT BlogDate from [BBSXP_Blogs] where UserName='"&BlogUserName&"'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("BlogDate")<>empty then response.write "<li><a href=?BlogUserName="&BlogUserName&"&BlogDate="&Rs("BlogDate")&">"&Replace(Rs("BlogDate"),"-","年")&"月</a></li> "
Rs.MoveNext
loop
Set Rs = Nothing
%> </td>
			</tr>
		</table>
		<br>
		<table class="a2" width="100%" cellspacing="1" cellpadding="5" border="0">
			<form name="form" method="post" action="?BlogUserName=<%=BlogUserName%>">
				<tr>
					<td class=a1 align=center><b>搜索文章内容</b></td>
				</tr>
				<tr class="a3">
					<td align="center"><input size="15" name="TextContent"><br>
					<input type="submit" value="提 交"> </td>
				</tr>
			</form>
		</table></td>
	</tr>
</table>
<%
End Sub


Sub ShowBlog


if Request("menu")="ShowBlog" then Response.Write "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td>"
%>
<script>
function loadBlogFollow(ino){
var targetDiv =document.getElementById("follow" + ino);
if (targetDiv.style.display!='block'){
frames["hiddenframe"].location.replace("?BlogUserName=<%=BlogUserName%>&BlogID="+ino+"&menu=Loading");
targetDiv.style.display="block";
}else{
targetDiv.style.display="none";
}
}</script>
<table class="a2" cellspacing="1" cellpadding="5" border="0" width="100%">
	<tr>
		<td class=a1 align=center><b>网络日志</b></td>
	</tr>
	<tr align="center" class="a3">
		<td align="Left" height="100"><%
if BlogID<>empty then SQLID=" and id="&BlogID&""
if Category<>empty then SQLCategory=" and Category='"&Category&"'"
if BlogDate<>empty then SQLBlogDate=" and BlogDate='"&BlogDate&"'"
if TextContent<>empty then SQLSearch="and content like '%"&TextContent&"%'"

sql="[BBSXP_Blogs] where UserName='"&BlogUserName&"' and ParentID=0 "&SQLID&" "&SQLBlogDate&" "&SQLCategory&" "&SQLSearch&""
Set Rs=Conn.Execute(""&sql&" order by id Desc")

TotalCount=conn.Execute("Select count(ID) From "&sql&" ")(0) '获取数据数量
PageSetup=NumBlogs'设定每页的显示数量
TotalPage=Abs(Int(TotalCount/PageSetup*(-1))) '总页数
PageCount = cint(Request.QueryString("PageIndex")) '获取当前页
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage >1 then RS.Move (PageCount-1) * pagesetup

i=0
Do While Not Rs.EOF and i<PageSetup
i=i+1
UserName=Rs("UserName")
content=Rs("content")
MyBlogDate=FormatDateTime(Rs("DateCreated"),1)
MyWeekDayName = WeekDayName(Weekday(MyBlogDate)) 

%>
		<table border="0" width="100%" cellspacing="10" style="TABLE-LAYOUT:fixed">
			<tr>
				<td colspan="2"><font size="2"><b><%=MyBlogDate%> <%=MyWeekDayName%></b></font>
				<hr size="1" color="#000000"><b><font size="2"><%=Rs("Subject")%></font></b><br>
				<br><div style="OVERFLOW:auto;WIDTH:100%;">
				<%=content%><br><br></div>
				<%if BlogComments=1 then%>
				<a onclick="loadBlogFollow('<%=Rs("id")%>');return false;" href="#">
				评论(<%=Rs("TotalReplies")%>)</a> | <%end if%> <%if BlogUserName=CookieUserName then%>
				<a href="?BlogUserName=<%=Rs("UserName")%>&Menu=Add&BlogID=<%=Rs("id")%>">
				编辑</a> |
				<a href="?BlogUserName=<%=BlogUserName%>&menu=Del&BlogID=<%=Rs("id")%>">
				删除</a> | <%end if%> <br>
				<%=FormatDateTime(Rs("DateCreated"),3)%> |
				<a title="单击显示此项的固定链接" href="?BlogUserName=<%=BlogUserName%>&menu=ShowBlog&BlogID=<%=Rs("id")%>">
				固定链接</a> | <%if Rs("Category")<>"" then%>
				<a title="单击显示此类别的所有项" href="?BlogUserName=<%=BlogUserName%>&Category=<%=Rs("Category")%>">
				<%=Rs("Category")%></a> | <%end if%> </td>
			</tr>
			</table>
			<div style="display:none" id="follow<%=Rs("id")%>"><table width="100%">
			<tr>
				<td colspan="2"><span id="followTd<%=Rs("id")%>">
				<img src="images/loading.gif">正在加载...</span></td>
			</tr></table></div>
		
		<hr size="1" color="#CECECE"><%
Rs.MoveNext
loop
Set Rs = Nothing

%></td>
	</tr>
</table>
<%
ShowPage()
if Request("menu")="ShowBlog" then Response.Write "</td></tr></table>"

End Sub








Sub AddPhoto
%>
<script>
function CheckFormPhoto(form){
if(document.form.UpFileID.value.length<1){alert("你的照片还未上传！");return false;}
if(document.form.FileName.value.length<1){alert("照片名称不能没有填写！");return false;}
}
</script>
<form name="form" method="post" action="?BlogUserName=<%=BlogUserName%>&menu=AddPhotoUp" onsubmit="return CheckFormPhoto(this);">
	<input name="UpFileID" type="hidden">
	<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2">
		<tr class="a1">
			<td colspan="2" align="center"><b>上传照片</b></td>
		</tr>
		<tr class="a3">
			<td width="20%" align="right"><b>照片名称：</b></td>
			<td><input name="FileName"></td>
		</tr>
		<tr class="a3">
			<td width="20%" align="right"><b>照片类别：</b></td>
			<td><select name="Category" size="1">
			<option value>无</option>
			<%
sql="select DISTINCT Category from [BBSXP_UpFiles] where UserName='"&CookieUserName&"' and Class='Photo'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then response.write "<option value="&Rs("Category")&">"&Rs("Category")&"</option>"
Rs.MoveNext
loop
Set Rs = Nothing
%></select> <a onclick="ChangeCategory();return false;" href="#">添加类别</a> </td>
		</tr>
		<tr class="a3">
			<td width="20%" align="right"><b>照片描述：</b></td>
			<td><input name="Description" size="40"></td>
		</tr>
		<tr class="a3">
			<td width="20%" align="right"><b>选择照片：</b></td>
			<td>
			<iframe src="PostUpPhoto.asp" frameborder="0" width="80%" height="21" scrolling="no">
			</iframe></td>
		</tr>
		<tr class="a3">
			<td colspan="2" align="center">
			<input type="submit" value=" 提 交 " name="Submit"></td>
		</tr>
	</table>
</form>
<%
End Sub


Sub Photo
%>
<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2" style="TABLE-LAYOUT:fixed">
	<tr class="a1">
		<td colspan="6" align="center">相册</td>
	</tr>
	<tr class="a3">
		<td colspan="6">
		<select onchange="javascript:window.location.href='Blog.asp?BlogUserName=<%=BlogUserName%>&amp;menu=Photo&amp;Category='+this.options[this.selectedIndex].value">
		<option value>相册首页</option>
		<%
sql="select DISTINCT Category from [BBSXP_UpFiles] where UserName='"&BlogUserName&"' and Class='Photo'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then
%>
		<option value="<%=Rs("Category")%>" <%if rs("category")=""&category&"" then%>selected<%end if%>>
		<%=Rs("Category")%></option>
		<%
end if
Rs.MoveNext
loop
Set Rs = Nothing
%></select> </td>
	</tr>
	<tr class="a3">
		<%
if Category="" then
sql="select DISTINCT Category from [BBSXP_UpFiles] where UserName='"&BlogUserName&"' and Class='Photo'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then
i=i+1
%><td align="center" width="15%" valign="top">
		<table onmouseover="this.style.borderColor='#000000'" style="BORDER-RIGHT: #c9c9c9 1px solid; BORDER-TOP: #c9c9c9 1px solid; BORDER-LEFT: #c9c9c9 1px solid; BORDER-BOTTOM: #c9c9c9 1px solid" onmouseout="this.style.borderColor='#C9C9C9'" cellspacing="0" cellpadding="0" height="100" width="100" align="center" border="0">
			<tr>
				<td valign="center" align="center">
				<table border="0" cellspacing="0" cellpadding="0" width="92" height="92">
					<tr>
						<td align="center" background="images/album.gif">
						<a href="?BlogUserName=<%=BlogUserName%>&menu=Photo&Category=<%=Rs("Category")%>">
						<img border="0" src="<%=Conn.Execute("Select FilePath From [BBSXP_UpFiles] where Category='"&Rs("Category")&"' and UserName='"&BlogUserName&"' and Class='Photo' order by id Desc")(0)%>" width="75" height="75"></a>
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<%=Rs("Category")%></td>
		<%
end if
if i>5 then
response.write "</TR><TR class=a3>"
i=0
end if
Rs.MoveNext
loop
Set Rs = Nothing
end if


sql="select * from [BBSXP_UpFiles] where UserName='"&BlogUserName&"' and Class='Photo' and Category='"&Category&"' order by id"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
i=i+1
%><td align="center" width="15%" valign="top">
		<table onmouseover="this.style.borderColor='#000000'" style="BORDER-RIGHT: #c9c9c9 1px solid; BORDER-TOP: #c9c9c9 1px solid; BORDER-LEFT: #c9c9c9 1px solid; BORDER-BOTTOM: #c9c9c9 1px solid" onmouseout="this.style.borderColor='#C9C9C9'" cellspacing="0" cellpadding="0" height="100" width="100" align="center" border="0">
			<tr>
				<td valign="center" align="center">
				<a href="?BlogUserName=<%=BlogUserName%>&Category=<%=Rs("Category")%>&menu=ShowPhoto&UpFileID=<%=rs("id")%>">
				<img title="<%=RS("Description")%>" border="0" src="<%=RS("FilePath")%>" onload="javascript:if(this.width&gt;80)this.width=80;if(this.height&gt;80)this.height=80"></a>
				</td>
			</tr>
		</table>
		<%=Rs("FileName")%> </td>
		<%
if i>5 then
response.write "</TR><TR class=a3>"
i=0
end if

Rs.MoveNext
loop
Set Rs = Nothing





For i=i To 5 
response.write "<td align=center width='15%'></TD>"
Next 

%>
	</tr>
</table>
<%
End Sub





Sub ShowPhoto

%>
<script>function yuzi_img(e, o)
{
var zoom = parseInt(o.style.zoom, 10) || 100;
zoom += event.wheelDelta / 12;
if (zoom > 0) o.style.zoom = zoom + '%';
return false;
}
</script>
<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2" style="TABLE-LAYOUT:fixed">
	<tr class="a1" id="TableTitleLink">
		<td align="center">相册</td>
	</tr>
	<tr class="a3">
		<td width="99%" align="center">
		<table border="0" width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td>
				<select onchange="javascript:window.location.href='Blog.asp?BlogUserName=<%=BlogUserName%>&amp;menu=Photo&amp;Category='+this.options[this.selectedIndex].value">
				<option value>相册首页</option>
				<%
sql="select DISTINCT Category from [BBSXP_UpFiles] where UserName='"&BlogUserName&"' and Class='Photo'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then
%>
				<option value="<%=Rs("Category")%>" <%if rs("category")=""&category&"" then%>selected<%end if%>>
				<%=Rs("Category")%></option>
				<%
end if
Rs.MoveNext
loop
Set Rs = Nothing
%></select> <%
if Request("action")="Next" then
sql="select top 1 * from [BBSXP_UpFiles] where UserName='"&BlogUserName&"' and Class='Photo' and Category='"&Category&"' and ID > "&UpFileID&" order by id"
elseif Request("action")="Previous" then
sql="select top 1 * from [BBSXP_UpFiles] where UserName='"&BlogUserName&"' and Class='Photo' and Category='"&Category&"' and ID < "&UpFileID&" order by id Desc"
else
sql="select * from [BBSXP_UpFiles] where UserName='"&BlogUserName&"' and Class='Photo' and Category='"&Category&"' and id="&UpFileID&""
end if
Set Rs=Conn.Execute(sql)
if Rs.eof or Rs.bof then error2"已经没有图片了"
%> </td>
				<td align="right">
				<a href="?BlogUserName=<%=BlogUserName%>&Category=<%=Rs("Category")%>&menu=ShowPhoto&action=Previous&UpFileID=<%=RS("id")%>">
				上一张</a>
				<a href="?BlogUserName=<%=BlogUserName%>&Category=<%=Rs("Category")%>&menu=ShowPhoto&action=Next&UpFileID=<%=RS("id")%>">
				下一张</a>　</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr class="a3">
		<td align="center"><a target="_blank" href="<%=RS("FilePath")%>">
		<img border="0" src="<%=RS("FilePath")%>" onmousewheel="return yuzi_img(event,this)" onload="javascript:if(this.width&gt;body.clientHeight)this.width=body.clientHeight" title="<%=RS("Description")%>"></a>
		<table cellspacing="1" cellpadding="5" border="0" align="center" class="a2" width="400">
			<tr class="a3">
				<td width="80" align="right">照片名称：</td>
				<td><%=Rs("FileName")%></td>
			</tr>
			<tr class="a3">
				<td align="right">照片格式：</td>
				<td><%=Rs("ContentType")%></td>
			</tr>
			<tr class="a3">
				<td align="right">照片大小：</td>
				<td><%=CheckSize(RS("ContentSize"))%></td>
			</tr>
			<tr class="a3">
				<td align="right">上传时间：</td>
				<td><%=RS("Created")%></td>
			</tr>
			<tr class="a3">
				<td align="right">照片描述：</td>
				<td><%=Rs("Description")%></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<%
Set Rs = Nothing
End Sub


Sub MyBlogSetting
%>
<script>
function foreColor()
{
  var arr = showModalDialog("inc/selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em;");
  if (arr != null) {
form.BlogBgcolor.value=arr;
document.tus.style.backgroundColor=arr;
}
}</script>
<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2">
	<form method="POST" name="form" action="?BlogUserName=<%=BlogUserName%>&menu=MyBlogSettingUp">
		<input name="BlogBgcolor" type="hidden" value="<%=BlogBgcolor%>">
		<tr class="a1">
			<td valign="bottom" colspan="2"><b>标题和标志行</b></td>
		</tr>
		<tr class="a3">
			<td colspan="2">您的共享空间的标题告诉其他人他们查看的是什么共享空间。<br>
			您可以用标志行告诉其他人您的共享空间的创建目的、您的心情或者任何您想分享的东西。</td>
		</tr>
		<tr class="a3">
			<td width="40%">共享空间标题：</td>
			<td><input name="BlogTitle" size="20" value="<%=BlogTitle%>"></td>
		</tr>
		<tr class="a3">
			<td>共享空间标志行：</td>
			<td><input name="BlogTagline" size="40" value="<%=BlogTagline%>"></td>
		</tr>
		<tr class="a1">
			<td colspan="2"><b>评论</b></td>
		</tr>
		<tr class="a3">
			<td>选择是否允许访问者在您的共享空间上添加评论。 </td>
			<td>
			<input type="checkbox" <%if blogcomments=1 then%>checked<%end if%> value="1" name="BlogComments">允许在网络日志上添加评论</td>
		</tr>
		<tr class="a1">
			<td colspan="2"><b>网络日志项数目</b></td>
		</tr>
		<tr class="a3">
			<td>选择显示给访问者的网络日志项的数目。 </td>
			<td><select size="1" name="NumBlogs">
			<option value="5" <%if numblogs=5 then%>selected<%end if%>>5
			</option>
			<option value="10" <%if numblogs=10 then%>selected<%end if%>>10
			</option>
			<option value="15" <%if numblogs=15 then%>selected<%end if%>>15
			</option>
			<option value="20" <%if numblogs=20 then%>selected<%end if%>>20
			</option>
			<option value="25" <%if numblogs=25 then%>selected<%end if%>>25
			</option>
			</select></td>
		</tr>
		<tr class="a1">
			<td colspan="2"><b>权限</b></td>
		</tr>
		<tr class="a3">
			<td>权限决定谁可以查看您的共享空间。您可以选择让所有人或者只有您认识的人查看您的共享空间。</td>
			<td><select size="1" name="BlogPermissions">
			<option value="everyone" <%if blogpermissions="everyone" then%>selected<%end if%>>
			公共</option>
			<option value="username" <%if blogpermissions="username" then%>selected<%end if%>>
			注册用户</option>
			<option value="friends" <%if blogpermissions="friends" then%>selected<%end if%>>
			我的好友</option>
			</select></td>
		</tr>
		<tr class="a1">
			<td colspan="2"><b>风格</b></td>
		</tr>
		<tr class="a3">
			<td>背景颜色</td>
			<td>
			<img title="选取颜色!" name="tus" onclick="foreColor()" style="CURSOR:pointer;BACKGROUND-COLOR:<%=BlogBgcolor%>" src="images/rect.gif">
			</td>
		</tr>
		<tr class="a3">
			<td>背景图片URL</td>
			<td>
			<input name="BlogBackground" size="40" value="<%=BlogBackground%>"></td>
		</tr>
		<tr class="a3">
			<td>音乐影片URL</td>
			<td><input name="BlogAudio" size="40" value="<%=BlogAudio%>"></td>
		</tr>
		<tr class="a3">
			<td colspan="2" align="center"><input type="submit" value=" 保 存 "></td>
		</tr>
	</form>
</table></div>
<%
End Sub
htmlend

%>