<%
if guestpic<>"yes" and UserLogined<>True then
call guesterror()
response.end
end if

dim pic_id,piccat_id,onpic,suitpic,titlepic
dim founderr,errmsg

if request.querystring("pic_id")<>"" then
    if not isInteger(request.querystring("pic_id")) then
    Response.Redirect "show_error.asp?eid=传值参数非法!"
    Response.End
    end if
	pic_id=CLng(request("pic_id"))
else
	pic_id=0
end if

if request.querystring("piccat_id")<>"" then
  if not isInteger(request.querystring("piccat_id")) then
    Response.Redirect "show_error.asp?eid=传值参数非法!"
    Response.End
  end if
  piccat_id=CLng(request("piccat_id"))
else
  piccat_id=0
end if

if pic_id>0 then
   sql="select * from pic where pic_id="&pic_id
   set rs=server.createobject("adodb.recordset")
   rs.open sql,conn,1,3
	if rs.bof and rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>你要找的图片不存在，或者已经被管理员删除！</li>"
	else	
		if rs("Passed")=1 then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>你要找的图片尚未被管理员审核！</li>"
		else
			start="精美图片 - "&rs("pic_name")&""
			titlepic=rs("pic_name")
                        piccat_id=CLng(rs("piccat_id"))
                        onpic=rs("pic_pic")
                        suitpic=rs("pic_pic1")
                        rs("pic_count")=rs("pic_count")+1
			rs.update
		end if
	end if
end if

'=================================================
if FoundErr=True then
	Call HxErrMsg()
	response.end
end if

'=================================================
'过程名：main_pic
'作  用：显示图片版面位置导航
'参  数：无
'=================================================
sub main_pic()
if piccat_id>0 then
  Response.Write "&nbsp;&nbsp;您的位置： <a href='index.asp'>"&webname&"</a> >> <a href='pic.asp'>精美图片</a>" & vbCrLf
  sql="select * from piccat where piccat_id="&piccat_id
  set rs3=conn.execute(sql)
  if rs3.eof then
  Response.Redirect "show_error.asp?eid=参数错误，找不到相关的记录!"
  Response.End
  End IF
  if rs3("sid")<>"0" then
     sql="select * from piccat where piccat_id="&rs3("sid")
     set rs4=conn.execute(sql)
     Response.Write " >> <a href=""pic.asp?piccat_id="&rs4("piccat_id")&""">"&rs4("piccat_name")&"</a>" 
     rs4.close
     set rs4=nothing
  end if
  Response.Write " >> <a href=""pic.asp?piccat_id="&rs3("piccat_id")&""">"&rs3("piccat_name")&"</a>" 
  rs3.close
  set rs3=nothing 
else
  Response.Write "&nbsp;&nbsp;您的位置： <a href='index.asp'>"&webname&"</a> >> <a href='pic.asp'>精美图片</a>" & vbCrLf
end if
end sub

'=================================================
'过程名：top_pic
'作  用：热门排行
'参  数：n-调用条数,nn-显示长度
'        NewWindows-----是否新窗打开，True为是，False为否
'=================================================
sub top_pic(n,nn,NewWindows)
dim nnn
if NewWindows=True then
nnn="target='_blank'"
else
nnn=""				
end if
Response.Write "<TABLE width='100%' cellSpacing=0 cellPadding=0 border=0 align='center'>" & vbCrLf
set rs=server.createobject("adodb.recordset")
set rs=conn.execute("SELECT top "&n&" * FROM pic where passed=0 ORDER by pic_count DESC,pic_id DESC")
do while not rs.eof
Response.Write "<tr><td height=22 class=table-xia>&nbsp;·<a href='showpic.asp?pic_id="&rs("pic_id")&"' Title='图片名称："&rs("pic_name")&"&#13&#10点击次数："&rs("pic_count")&"&#13&#10上传时间："&rs("pic_date")&"' "& nnn &">"&gotTopic(rs("pic_name"),nn)&"</a></td></tr>" & vbCrLf
rs.movenext
loop
if rs.bof and rs.eof then
Response.Write "<tr><td align='center' valign='middle'>当前没有图片！</td></tr>"
end if
rs.close
set rs=nothing
Response.Write "</TABLE>" & vbCrLf
end sub

'=================================================
'过程名：best_pic
'作  用：推荐图片
'参  数：n-调用条数,nn-显示长度
'        NewWindows-----是否新窗打开，True为是，False为否
'=================================================
sub best_pic(n,nn,NewWindows)
dim nnn
if NewWindows=True then
nnn="target='_blank'"
else
nnn=""				
end if
Response.Write "<TABLE width='100%' cellSpacing=0 cellPadding=0 border=0 align='center'>" & vbCrLf
set rs=server.createobject("adodb.recordset")
set rs=conn.execute("SELECT top "&n&" * FROM pic where isbest = 1 order by pic_id desc")
do while not rs.eof
Response.Write "<tr><td height=22 class=table-xia>&nbsp;·<a href='showpic.asp?pic_id="&rs("pic_id")&"' Title='图片名称："&rs("pic_name")&"&#13&#10点击次数："&rs("pic_count")&"&#13&#10上传时间："&rs("pic_date")&"' "& nnn &">"&gotTopic(rs("pic_name"),nn)&"</a></td></tr>" & vbCrLf
rs.movenext
loop
if rs.bof and rs.eof then
Response.Write "<tr><td align='center' valign='middle'>没有推荐图片！</td></tr>"
end if
rs.close
set rs=nothing
Response.Write "</TABLE>" & vbCrLf
end sub

'=================================================
'过程名：class_pic
'作  用：图片分类——纵排
'参  数：无
'=================================================
sub class_pic()
sql="select * from piccat where sid=0"
set rs1=conn.execute(sql)
do while not rs1.eof
if request("piccat_id")=cstr(rs1("piccat_id")) then
response.write "&nbsp;<font color=""#FF0000"">·"&rs1("piccat_name")&"</font><BR>"
else
response.write "&nbsp;<font color=""#FF0000"">·</font><a href='pic.asp?piccat_id="&rs1("piccat_id")&"'>"&rs1("piccat_name")&"</a><BR>"
end if
sql="select * from piccat where sid="&rs1("piccat_id") 
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
do while not rs2.eof
if request("piccat_id")=cstr(rs2("piccat_id")) then
response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=""#FF0000"">├ "&rs2("piccat_name")&"</a></font><BR>"
else
response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='pic.asp?piccat_id="&rs2("piccat_id")&"'>├ "&rs2("piccat_name")&"</a><BR>"
end if
rs2.movenext
loop
rs1.movenext
loop
rs2.close
set rs2=nothing
rs1.close
set rs1=nothing
end sub

'=================================================
'过程名：class1_pic
'作  用：图片分类——横排
'参  数：无
'=================================================
sub class1_pic(n)
sql="select top "&n&" * from piccat where sid=0"
set rs1=conn.execute(sql)
do while not rs1.eof
if request("piccat_id")=cstr(rs1("piccat_id")) then
response.write "<font color=""#FF0000""></font>"
else
response.write "<a href='pic.asp?piccat_id="&rs1("piccat_id")&"'></a>"
end if
sql="select top "&n&" * from piccat where sid="&rs1("piccat_id") 
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
do while not rs2.eof
if request("piccat_id")=cstr(rs2("piccat_id")) then
response.write "&nbsp;<font color=""#FF0000"">·"&rs2("piccat_name")&"</a></font>"
else
response.write "&nbsp;·<a href='pic.asp?piccat_id="&rs2("piccat_id")&"'>"&rs2("piccat_name")&"</a>"
end if
rs2.movenext
loop
rs1.movenext
loop
rs2.close
set rs2=nothing
rs1.close
set rs1=nothing
end sub

'=================================================
'过程名：search_pic
'作  用：显示图片搜索表单
'参  数：无
'=================================================
sub search_pic()
Response.Write "<form name='form2' method='post' action='pic.asp'><div align=center><input type='radio' name='select' value='pic_name' checked>名称&nbsp;<input type='radio' name='select' value='pic_desc'>简介&nbsp;<input type='radio' name='select' value='review'>评论<br><input type='text' name='keyword'  size='15' value='搜索关键字' maxlength='50' onfocus=""this.value=''"" class='input'>&nbsp;<input type='submit' name='search'  value='搜索' onmouseover=""this.className='boton'"" onmouseout=""this.className='botoff'""></div></form>" & vbCrLf
end sub

'=================================================
'过程名：displayList_pic
'作  用：带分页功能的图片列表
'参  数：nn-标题长度,poppicnum-热门点击数,Hxperpage-每页显示条数
'=================================================
sub displayList_pic(nn,Hxperpage)
Dim CurPage,Url_Add
Url_Add="?"
If Request.QueryString("Page")<>"" Then
   Curpage=Request.QueryString("Page")
   If IsInteger(Curpage)=False Then Curpage=1
Else
   Curpage=1
End If
dim nnn
if NewWindows=True then
nnn="target='_blank'"
else
nnn=""				
end if
if request("keyword")<>"" then
  if instr(request("keyword"),"'")>0 then
    Response.Write "<script language=javascript>alert('搜索参数非法');javascript:history.back();</script>"
    Response.End
  end if
end if
dim mtyid,hx01,hx66010
mtyid=int(piccat_id)
set hx01=conn.execute("select piccat_id,piccat_name,sid from piccat order by piccat_id")
do while not hx01.eof
if mtyid=hx01("sid") then
hx66010=hx66010+" or piccat_id="&hx01("piccat_id") '显示页所需变量pic.asp
end if
hx01.movenext
loop
hx01.close
set hx01=nothing
if request.querystring("piccat_id")<>"" then
   sql="select * from pic where (piccat_id="&piccat_id&hx66010&") and passed=0 order by pic_id DESC"
   Url_Add=Url_Add&"piccat_id="&piccat_id&"&"
elseif request("keyword")<>"" and (request("select")="pic_name" or request("select")="pic_desc" or request("select")="review" or request("select")="tjuser") then
   sql="select * from pic where passed=0 and "&request("select")&" like '%"&Jencode(checkspace(request("keyword")))&"%' order by pic_id DESC"
   Url_Add=Url_Add&"select="&request("select")&"&keyword="&Server.URLEncode(request("keyword"))&"&"
else
sql="select * from pic where passed=0 order by pic_id DESC"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
Response.Write "<table width='100%' border='1' align='center' cellspacing='0' cellpadding='0' bgcolor='#FFFFFF' bordercolor='#f0f0f0' style='border-collapse: collapse'>" & vbCrLf
Response.Write "<tr>" & vbCrLf
Response.Write "<td height=30 colSpan=4><FONT color=#b70000>&nbsp;<B>·</B></FONT>"
if request("piccat_id")<> "" then
Response.Write "本分类共有"
elseif request("select")<>"" then
Response.Write "共搜索到"
else
Response.Write "当前共有"
end if
Response.Write "<span>"&rs.recordcount&"</span>张图片</td>" & vbCrLf
Response.Write "</tr><tr>" & vbCrLf
if not rs.eof then
   Dim Hx_Nums,MultiPages,i
   Rs.PageSize=Hxperpage
   Rs.AbsolutePage=CurPage
   Hx_Nums=Rs.RecordCount
   MultiPages="<tr><td colspan=""4"" height='28' align=""center"">"&MultiPage(Hx_Nums,Hxperpage,CurPage,Url_Add)&"</td></tr>"
Do Until Rs.EOF OR i=Hxperpage
Response.Write "<TD style=""PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; PADDING-TOP: 5px"" align=middle><SCRIPT type=text/javascript>hx66img('"&rs("pic_spic")&"','showpic.asp?pic_id="&rs("pic_id")&"','图片名称："&rs("pic_name")&"&#13&#10点击次数："&rs("pic_count")&"&#13&#10文件大小："&rs("pic_url")&"&#13&#10上传时间："&rs("pic_date")&"');</SCRIPT><div>"&gotTopic(rs("pic_name"),nn)&"</div></TD>"
i=i+1
if i mod 4 = 0 then
Response.Write "</tr>"
end if
rs.movenext
loop
else
if rs.eof and rs.bof then
Response.Write "<tr align='center'>" & vbCrLf
Response.Write "<td align=middle height='60' colSpan=4>"
if request("piccat_id")<> "" then
Response.Write "该分类暂时没有图片"
elseif request("keyword")<>"" then
Response.Write "没有找到包含[<b><font color=red>"&request("keyword")&"</font></b>]的图片！"
else
Response.Write "没有任何图片，请管理员到后台添加！"
end if
Response.Write "</td></tr>" & vbCrLf
end if
end if
Response.Write(MultiPages)
Response.Write "</table>" & vbCrLf
rs.close
set rs=nothing
end sub

'=================================================
'过程名：content_pic
'作  用：显示图片标题、内容
'参  数：无
'=================================================
sub content_pic()
if request.querystring("pic_id")="" then
  Response.Write "<script language=javascript>alert('请指定操作的对象！');javascript:history.back();</script>"
  Response.End
else
  if not isInteger(request.querystring("pic_id")) then
    Response.Write "<script language=javascript>alert('非法的id参数。');javascript:history.back();</script>"
    Response.End
  end if
end if
Response.Write "<table width=""100%"" align=""center"" cellspacing=""0"" cellpadding=""0""" & vbCrLf
Response.Write "style=""word-break:break-all;table-layout:fixed;text-align:left"">" & vbCrLf
Response.Write "<tr><td valign=""top"">" & vbCrLf
Response.Write "<br><div align=""center""><font style=""font-size:16px""><b>"&titlepic&"</b></font></div><br>" & vbCrLf
Response.Write "<table width='96%' border='0' cellpadding='0' cellspacing='0' align='center'>" & vbCrLf
Response.Write "<tr>" & vbCrLf 
Response.Write "<td align='center'><a id='pichref' href='pic_view.asp?url="&onpic&"' target='_blank'><img src='"&onpic&"' id='mainpic' alt='点击新窗口查看' onmouseover=""javascript:if(this.width>700){this.width=700;}"" onload=""javascript:if(this.width>700){this.width=700;}"" border=0></a>"
Response.Write "</td>" & vbCrLf
Response.Write "</tr></table><BR>" & vbCrLf
if suitpic<>"" then
Response.Write "<table cellpadding='4' cellspacing='2' bgcolor='#f7f7f7' width='90%' height='30' align=center style='border:1px dashed #808080;padding:0px'>" & vbCrLf
Response.Write "<tr>" & vbCrLf 
dim sUitImg
sUitImg=split(suitpic,"|")
for i=1 to ubound(sUitImg)
Response.Write "<td align='center'><img src='"&sUitImg(i)&"' width=86 height=65 style=""cursor:hand"" onclick=""javascript:replaceImgp('"&sUitImg(i)&"')"" border=1><img src='"&sUitImg(i)&"' width=0 height=0 border=0></td>" & vbCrLf
if i mod 7 = 0 then
Response.Write "</tr><tr>" & vbCrLf
end if
next
Response.Write "</tr></table>" & vbCrLf
end if
Response.Write "<BR>" & vbCrLf
Response.Write "<table width='96%' border='0' cellspacing='1' align='center' class='table-shangxia1'>" & vbCrLf
Response.Write "<tr>" & vbCrLf
Response.Write "<td height='40' bgcolor=""#FFFFFF"" Valign='TOP' style=""LINE-HEIGHT: 150%;padding: 5;"">" & vbCrLf
Response.Write "浏览指数："&rs("pic_count")&" ｜ 上传时间："&rs("pic_date")&"  ｜ 上传会员："&rs("tjuser")&"<BR>图片说明："&rs("pic_desc")&"</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Response.Write "</td></tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
end sub

'=================================================
'过程名：contextual_pic
'作  用：显示图片上下张
'参  数：无
'=================================================
sub contextual_pic()
set RelationArt = conn.execute("select top 1 pic_id,pic_name from pic where pic_id<"&request.querystring("pic_id")&" and passed=0 order by pic_date desc")
IF RelationArt.eof and relationArt.bof Then
Response.Write "<font color=red>·上张图片：</font>已经没有了<BR> "    
else
Response.Write "<font color=red>·上张图片：</font><a href=""showpic.asp?pic_id=" & RelationArt(0) & """>" & relationArt(1) & "</a><BR>"   
end if   
Set RelationArt=Nothing
set RelationArt = conn.execute("select top 1 pic_id,pic_name from pic where pic_id>"&request.querystring("pic_id")&" and passed=0 order by pic_id")
IF RelationArt.eof and relationArt.bof Then
Response.Write "<font color=red>·下张图片：</font>已经没有了"   
else
Response.Write "<font color=red>·下张图片：</font><a href=""showpic.asp?pic_id=" & RelationArt(0) & """>" & relationArt(1) & "</a></td>"  
end if  
 RelationArt.close
Set RelationArt=Nothing 
end sub

'=================================================
'过程名：review_pic
'作  用：显示相关图片评论
'参  数：n-显示条数；point_pic-评论开关,1-开启，0-关闭
'=================================================
sub review_pic(n)
dim temp,i,j
if point_pic="1" then
Response.Write "<table align=""center"" width=""98%"" cellspacing=""0"" cellpadding=""0"" style=""word-break:break-all;table-layout:fixed;text-align:left"">" & vbCrLf
if rs("review")<>"" then
temp=split(Trim(rs("review")),"|")
if n>=ubound(temp) then
j=ubound(temp)
else
j=n
end if
for i=1 to j
Response.Write "<tr><td style=""display:block;padding:0px 10px;LINE-HEIGHT: 180%"">"& temp(i) &"</td></tr>"
next
else
Response.Write "<tr><td style=""display:block;padding:0px 10px;LINE-HEIGHT: 180%"">当前没有评论</td></tr>"
end if
Response.Write "<tr><td align=""right"">相关评论<font color=#CC0000> "&rs("reviewcount")&" </font>篇，当前显示最新的<font color=#CC0000> "&n&" </font>篇。&nbsp;&nbsp;<a href=""view.asp?action=pic&pic_id="&rs("pic_id")&"""> [查看更多评论] [发表我的评论]</a>&nbsp;&nbsp;</td></tr>"
Response.Write "</table>"
elseif point_pic="0" then
Response.Write "<table width=""100%"" cellpadding=""5"" cellspacing=""0"" border=""0"">"
Response.Write "<tr><td  align=""center"">【图片评论已关闭】"
Response.Write "</td></tr>"
Response.Write "</table>"
End If
rs.close
set rs=nothing
end sub
%>

