<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
picpath =Application("picpath")
If InStr(picpath,"http://") = 1 Then
	SaveFileName = "/upfiles/image/a/s/" & GetRndFileName(Right(picpath,3))
	Call SaveRemoteFile(SaveFileName, picpath)
	
	Dim Jpeg
	Set Jpeg = Server.CreateObject("Persits.Jpeg")
	Jpeg.Open Server.MapPath(SaveFileName)
	
	Jpeg.Width = 120
	Jpeg.Height = Cdbl(Jpeg.OriginalHeight * (120 / Jpeg.OriginalWidth))
	
	h = Jpeg.Height
	
	If h < 90 Then
		Jpeg.Height = 90
		Jpeg.Width = Cdbl(120 * (90 / h))
	End If
	
	Jpeg.Crop 0, 0, 120,90
	Jpeg.Save Server.MapPath(SaveFileName)
	
	Set Jpeg = Nothing
	picpath = SaveFileName
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎÄµµ</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="../Article_Edit.asp?ChannelId=1&action=auto&rnd=<%=Now()%>">
  <p>
    <input name="Title" type="text" id="Title" value="<%=Application("Title")%>" />
    <input name="ClassID" type="hidden" id="ClassID" value="<%=Application("ClassID")%>" />
    <input name="picpath" type="hidden" id="picpath" value="<%=picpath%>" />
  </p>
  <p>
    <textarea name="Content"><%=Server.HTMLEncode(Application("Content"))%></textarea>
  </p>
</form>
<script type="text/javascript">
<%If Trim(Request.QueryString("action"))="click" Then%>
form1.submit();
<%Else%>
parent.Form.Title.value = form1.Title.value;
parent.Content___Frame.frames[0].document.body.innerHTML = form1.Content.value;
parent.Form.Title.focus();
<%End If%>
</script>
</body>
</html>
<%
Function SaveRemoteFile(s_LocalFileName, s_RemoteFileUrl)
	Dim Ads, Retrieval, GetRemoteData

	Set Retrieval = Server.CreateObject("Microsoft" & ".XMLHTTP")
	With Retrieval
		.Open "Get", s_RemoteFileUrl, False, "", ""
		.Send
		GetRemoteData = .ResponseBody
	End With
	Set Retrieval = Nothing
	
	Set Ads = Server.CreateObject("Adodb." & "Stream")
	With Ads
		.Type = 1
		.Open
		.Write GetRemoteData
		.SaveToFile Server.MapPath(s_LocalFileName), 2
		.Cancel()
		.Close()
	End With
	Set Ads=nothing
End Function

Function GetRndFileName(sExt)
	Dim sRnd
	Randomize
	sRnd = Int(900 * Rnd) + 100
	GetRndFileName = FormatTime(Now(), 5) & sRnd & "." & sExt
End Function

Function FormatTime(s_Time, n_Flag)
	Dim y, m, d, h, mi, s
	FormatTime = ""
	If IsDate(s_Time) = False Then Exit Function
	y = cstr(year(s_Time))
	m = cstr(month(s_Time))
	If len(m) = 1 Then m = "0" & m
	d = cstr(day(s_Time))
	If len(d) = 1 Then d = "0" & d
	h = cstr(hour(s_Time))
	If len(h) = 1 Then h = "0" & h
	mi = cstr(minute(s_Time))
	If len(mi) = 1 Then mi = "0" & mi
	s = cstr(second(s_Time))
	If len(s) = 1 Then s = "0" & s
	Select Case n_Flag
		Case 0
			FormatTime = y & m
		Case 1
			FormatTime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
		Case 2
			FormatTime = y & "-" & m & "-" & d
		Case 3
			FormatTime = h & ":" & mi & ":" & s
		Case 4
			FormatTime = y & m & d
		Case 5
			FormatTime = y & m & d & h & mi & s
	End Select
End Function
%>