ASP教程之用文本+ASP打造旧事公布体系
楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。//图片上传
<SCRIPTRUNAT=SERVERLANGUAGE=VBSCRIPT>
FunctionGetUpload(FormData)
DimDataStart,DivStr,DivLen,DataSize,FormFieldData
分开标记串(+CRLF)
DivStr=LeftB(FormData,InStrB(FormData,str2bin(VbCrLf))+1)
分开标记串长度
DivLen=LenB(DivStr)
PosOpenBoundary=InStrB(FormData,DivStr)
PosCloseBoundary=InStrB(PosOpenBoundary+1,FormData,DivStr)
SetFields=CreateObject("Scripting.Dictionary")
WhilePosOpenBoundary>0AndPosCloseBoundary>0
name肇端地位(name="xxxxx"),加6是由于长度为6
FieldNameStart=InStrB(PosOpenBoundary,FormData,str2bin("name="))+6
FieldNameSize=InStrB(FieldNameStart,FormData,ChrB(34))-FieldNameStart(")的ASC值=34
FormFieldName=bin2str(MidB(FormData,FieldNameStart,FieldNameSize))
filename肇端地位(filename="xxxxx")
FieldFileNameStart=InStrB(PosOpenBoundary,FormData,str2bin("filename="))+10
IfFieldFileNameStart<PosCloseBoundaryAndFieldFileNameStart>PosopenBoundaryThen
FieldFileNameSize=InStrB(FieldFileNameStart,FormData,ChrB(34))-FieldFileNameStart(")的ASC值=34
FormFileName=bin2str(MidB(FormData,FieldFileNameStart,FieldFileNameSize))
Else
FormFileName=""
EndIf
Content-Type肇端地位(Content-Type:xxxxx)
FieldFileCTStart=InStrB(PosOpenBoundary,FormData,str2bin("Content-Type:"))+14
IfFieldFileCTStart<PosCloseBoundaryAndFieldFileCTStart>PosOpenBoundaryThen
FieldFileCTSize=InStrB(FieldFileCTStart,FormData,str2bin(VbCrLf&VbCrLf))-FieldFileCTStart
FormFileCT=bin2str(MidB(FormData,FieldFileCTStart,FieldFileCTSize))
Else
FormFileCT=""
EndIf
数据肇端地位:2个CRLF入手下手
DataStart=InStrB(PosOpenBoundary,FormData,str2bin(VbCrLf&VbCrLf))+4
IfFormFileName""Then
数据长度,减1是由于数据文件的存取字节数成绩(多是AppendChunk办法的成绩):
因为字节数为奇数的图像存到数据库时会往失落最初一个字符招致图像不克不及准确显现,
字节数为偶数的数据文件就不会呈现这个成绩,因而必需坚持字节数为偶数。
DataSize=InStrB(DataStart,FormData,DivStr)-DataStart-1
FormFieldData=MidB(FormData,DataStart,DataSize)
Else
数据长度,减2是由于分开标记串前有一个CRLF
DataSize=InStrB(DataStart,FormData,DivStr)-DataStart-2
FormFieldData=bin2str(MidB(FormData,DataStart,DataSize))
EndIf
创建一个Dictionary集存储Form中各个Field的相干数据
SetField=CreateUploadField()
Field.Name=FormFieldName
Field.FilePath=FormFileName
Field.FileName=GetFileName(FormFileName)
Field.ContentType=FormFileCT
Field.Length=LenB(FormFieldData)
Field.Value=FormFieldData
Fields.AddFormFieldName,Field
PosOpenBoundary=PosCloseBoundary
PosCloseBoundary=InStrB(PosOpenBoundary+1,FormData,DivStr)
Wend
SetGetUpload=Fields
EndFunction
把二进制字符串转换成一般字符串函数
Functionbin2str(binstr)
Dimvarlen,clow,ccc,skipflag
中笔墨符Skip标记
skipflag=0
ccc=""
IfNotIsNull(binstr)Then
varlen=LenB(binstr)
Fori=1Tovarlen
Ifskipflag=0Then
clow=MidB(binstr,i,1)
判别是不是中文的字符
IfAscB(clow)>127Then
AscW会把二进制的中文双字节字符高位和低位反转,以是要先把中文的上下位反转
ccc=ccc&Chr(AscW(MidB(binstr,i+1,1)&clow))
skipflag=1
Else
ccc=ccc&Chr(AscB(clow))
EndIf
Else
skipflag=0
EndIf
Next
EndIf
bin2str=ccc
EndFunction
把一般字符串转成二进制字符串函数
Functionstr2bin(varstr)
str2bin=""
Fori=1ToLen(varstr)
varchar=mid(varstr,i,1)
varasc=Asc(varchar)
asc对中笔墨符求出来的值大概为正数,
加上65536便可求出它的无标记数值
-1在呆板内是用补码暗示的0xffff,
其无标记值为65535,65535=-1+65536
其他正数顺次类推。
Ifvarasc<0Then
varasc=varasc+65535
EndIf
对中文的处置:把双字节低位和高位分隔
Ifvarasc>255Then
varlow=Left(Hex(Asc(varchar)),2)
varhigh=right(Hex(Asc(varchar)),2)
str2bin=str2bin&chrB("&H"&varlow)&chrB("&H"&varhigh)
Else
str2bin=str2bin&chrB(AscB(varchar))
EndIf
Next
EndFunction
获得文件名(往失落Path)
FunctionGetFileName(FullPath)
IfFullPath""Then
FullPath=StrReverse(FullPath)
FullPath=Left(FullPath,InStr(1,FullPath,"")-1)
GetFileName=StrReverse(FullPath)
Else
GetFileName=""
EndIf
EndFunction
</SCRIPT>
<SCRIPTRUNAT=SERVERLANGUAGE=JSCRIPT>
functionCreateUploadField(){returnnewuf_Init()}
functionuf_Init(){
this.Name=null
this.FileName=null
this.FilePath=null
this.ContentType=null
this.Value=null
this.Length=null
}
</SCRIPT>
//旧事增加
<!--#includefile="news_session.asp"-->
<html>
<head>
<metahttp-equiv="Content-Language"content="zh-cn">
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<styletype="text/css">
.buttonface{
BACKGROUND-COLOR:#0079F2;BORDER-BOTTOM:#3333331pxoutset;BORDER-LEFT:#3333331pxoutset;BORDER-RIGHT:#ffffff1pxoutset;BORDER-TOP:#ffffff1pxoutset;COLOR:#ffffff;FONT-SIZE:9pta{color:#000000;text-decoration:none}
</style>
<SCRIPTID=clientEventHandlersJSLANGUAGE=javascript>
<!--
functionclient_onblur(ii){
server=eval("form1.server"+ii)
if(server.value==""){
client=eval("form1.client"+ii)
clientvalue=client.value+""
varlen=clientvalue.length
a=clientvalue.lastIndexOf()
clientvalue=clientvalue.substring(a+1)
//alert(clientvalue);
server.value=clientvalue
}
}
functionform1_onsubmit(){
for(i=1;i<1;i++){
client=eval("form1.client"+i)
server=eval("form1.server"+i)
if(client.value!=""&&server.value==""){alert("上传后的文件名不克不及空!");server.focus();returnfalse}
}
}
//-->
</SCRIPT>
<title>旧事公布体系</title>
</head>
<bodybgcolor=#EDF0F5topmargin=10marginheight=5leftmargin=4marginwidth=0>
<formmethod="POST"action="news_input.asp"name="form1"enctype="multipart/form-data"LANGUAGE=javascript>
<divalign="left">
<tableborder="1"width="754"height="404">
<tralign="center">
<tdwidth="754"height="28"colspan="3"style="font-size:11pt"><strong>旧事公布体系背景办理--旧事增加</strong></td>
</tr>
<tr>
<tdwidth="121"height="16"align="center"style="font-size:9pt">旧事题目</td>
<tdwidth="617"height="16"colspan="2">
<inputtype="text"name="news_title"size="87"></td>
</tr>
<tr>
<tdwidth="121"height="165"align="center"style="font-size:9pt">旧事内容</td>
<tdwidth="617"height="165"colspan="2"><textarearows="11"name="news_content"cols="85"></textarea></td>
</tr>
<tr>
<tdwidth="121"height="21"align="center"style="font-size:9pt">旧事来历</td>
<tdwidth="617"height="21"colspan="2">
<inputtype="text"name="news_src"size="87"></td>
</tr>
<tr>
<tdwidth="121"height="20"align="center"style="font-size:9pt">图片上传</td>
<tdwidth="617"height="20"colspan="2">
<inputtype="file"name="client1"size="20"readonlyLANGUAGE=javascript>
<spanstyle="font-size:9pt"></span><INPUTtype="hidden"name="server1"><inputtype="hidden"value="mysession"name="mysession"></td>
</tr>
</table>
</div>
<p>
<inputtype="submit"value="递交"name="B1"class="buttonface"><inputtype="reset"value="全体重写"name="B2"class="buttonface">
<inputtype="button"value="帐号修正"name="B2"style="font-size:10pt;color:#000000;"class="buttonface">
<inputtype="button"value="旧事修正"name="B2"style="font-size:10pt;color:#000000;"class="buttonface"></p>
</form>
</body>
</html>
###################
news_input.asp
<!--#includefile="upload.inc"-->
<%
Fields("xxx").Name获得Form中xxx(FormObject)的名字
Fields("xxx").FilePath假如是fileObject获得文件的完全路径
Fields("xxx").FileName假如是fileObject获得文件名
Fields("xxx").ContentType假如是fileObject获得文件的范例
Fields("xxx").Length获得Form中xxx(FormObject)的数据长度
Fields("xxx").Value获得Form中xxx(FormObject)的数据内容
DimFormData,FormSize,gnote,bnote,notes,binlen,binstr
FormSize=Request.TotalBytes
FormData=Request.BinaryRead(FormSize)
SetFields=GetUpload(FormData)
############判别输出毛病
dimnews_title,news_content,news_src,mysession
mysession=Fields("mysession").value
iflen(mysession)=0then
Response.Write"不法上岸或超时请从头上岸"
Response.End
endif
news_title=Fields("news_title").value
news_title=replace(news_title,"|","|")
news_content=Fields("news_content").value
news_src=Fields("news_src").value
news_src=replace(news_src,"|","|")
iflen(news_title)=0then%>
<script>
alert("堕落!旧事题目不克不及为空");
history.go(-1);
//window.location="news_add.asp";
</script>
<%Response.end
endif
iflen(news_content)=0then%>
<script>
alert("堕落!旧事内容不克不及为空");
history.go(-1);
</script>
<%endif
iflen(news_src)=0then%>
<script>
alert("堕落!旧事来历不克不及为空");
history.go(-1);
</script>
<%Response.end
endif
dimvarchar
varchar=right(Fields("server1").value,3)
iflen(varchar)0then
ifvarchar"gif"andvarchar"jpg"then
%>
<script>
alert("堕落!不克不及上传该图片范例");
history.go(-1);
</script>
<%Response.end
else
endif
endif
###########将图片写进文件夹
setfile_O=Server.CreateObject("Scripting.FileSystemObject")
##########以后工夫做图片名
dimnewname,mytime,newfile,filename,id,image
endname=right(fields("server1").value,4)
mytime=now()
id=Year(mytime)&Month(mytime)&Day(mytime)&Hour(mytime)&Minute(MyTime)&Second(MyTime)
imageid=id&endname
#############写进图片
newfile="client1"
filename=Fields("server1").value
IfFields(newfile).FileName""Then
file_name=Server.MapPath("./images/"&imageid&"")
setoutstream=file_O.CreateTextFile(file_name,true,false)
binstr=Fields(newfile).Value
binlen=1
varlen=lenb(binstr)
fori=1tovarlen
clow=MidB(binstr,i,1)
IfAscB(clow)=255then
outstream.writechr(255)
binlen=binlen+1
if(imod2)=0then
notes=gnote
exitfor
endif
elseifAscB(clow)>128then
clow1=MidB(binstr,i+1,1)
ifAscB(clow1)<64orAscB(clow1)=127orAscB(clow1)=255then
binlen=binlen+1
if(binlenmod2)=0then
binlen=binlen+1
outstream.writeChr(AscW(ChrB(128)&clow))
endif
notes=bnote
exitfor
else
outstream.writeChr(AscW(clow1&clow))
binlen=binlen+2
i=i+1
if(imod2)=0then
notes=gnote
exitfor
endif
endif
else
outstream.writechr(AscB(clow))
binlen=binlen+1
if(imod2)=0then
notes=gnote
exitfor
endif
endif
next
outstream.close
setoutstream=file_O.OpenTextFile(file_name,8,false,-1)
outstream.writemidb(Fields(newfile).Value,binlen)
outstream.close
ifnotes=bnotethennotes=notes&(binlen-1)&"字节处。"
EndIf
######################################################################################把旧事数据布局写进newslist文件
dimmappath,mytext,myfso,contenttext,news_addtime,news_point
news_point=1
news_addtime=mytime
setmyfso=createobject("scripting.filesystemobject")
mappath=server.mappath("./")
setmytext=myfso.opentextfile(mappath&"
ew_list.asp",8,-1)
dimmytext2
iflen(varchar)0then
mytext2=trim(id&","&news_title&","&id&".txt"&","&news_src&","&news_point&","&news_addtime&","&imageid&"|")
else
mytext2=trim(id&","&news_title&","&id&".txt"&","&news_src&","&news_point&","&news_addtime&"|")
endif
mytext.writeline(mytext2)
mytext.close
##############把旧事内容写进响应的文件中
setcontenttext=myfso.OpenTextFile(mappath&"
ews_content"&id&".txt",8,-1)
functionhtmlencode2(str)#############字符处置函数
dimresult
diml
l=len(str)
result=""
dimi
fori=1tol
selectcasemid(str,i,1)
casechr(34)
result=result+""
case"&"
result=result+"&"
casechr(13)
result=result+"<br>"
case""
result=result+""
casechr(9)
result=result+""
casechr(32)
ifi+1<=landi-1>0then
ifmid(str,i+1,1)=chr(32)ormid(str,i+1,1)=chr(9)ormid(str,i-1,1)=chr(32)ormid(str,i-1,1)=chr(9)then
result=result+""
else
result=result+""
endif
else
result=result+""
endif
caseelse
result=result+mid(str,i,1)
endselect
next
htmlencode2=result
endfunction
############################################################################
contenttext.writehtmlencode2(news_content)
contenttext.close
setmyfso=nothing
%>
<script>
alert("公布乐成");
window.location="news_add.asp";
</script>
//旧事列表显现
<%
dimmyfso,myread
setmyfso=createobject("scripting.filesystemobject")
setmyread=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
ifmyread.atendofstreamthen
Response.Write"今朝没有增加旧事"
Response.End
else
dimmytext,listarray
mytext=myread.readall
listarray=split(mytext,"|")#######把一切纪录支解成一个数组a
dimrecordcount,pagecount,pagesize,pagenum
recordcount=ubound(listarray)############纪录条数
pagesize=2
pagecount=recordcount/pagesize#######获得页面数
ifinstr(1,pagecount,".")=nullorinstr(1,pagecount,".")=0then
pagenum=pagecount
else
pagenum=int(pagecount)+1
endif
dimtopage
topage=cint(Request.QueryString("topage"))########获得要显现的页面
iftopage<=0then
topage=1
endif
iftopage>pagenumthen
topage=pagenum
endif
dimi,j,n
b=listarray
fori=0torecordcount-1########把每笔记录构成一个数组
j=split(listarray(i),",")
ifubound(j)=6then
b(i)="<SPANstyle=COLOR:#ffbd00;FONT-SIZE:7px><li></SPAN><spanstyle=font-size:10pt><ahref=news_view.asp?id="&j(0)&"target=blank>"&j(1)&"(图)</a>点击:"&j(4)&"次最初公布工夫:"&j(5)&"</span>"
else
b(i)="<SPANstyle=COLOR:#ffbd00;FONT-SIZE:7px><li></SPAN><spanstyle=font-size:10pt><ahref=news_view.asp?id="&j(0)&"target=blank>"&j(1)&"</a>点击:"&j(4)&"次最初公布工夫:"&j(5)&"</span>"
endif
next
########把纪录反排序存储在新的数组完成定时间反排序
dimc(100)
n=0
fori=recordcountto0step-1
c(n)=b(i)
n=n+1
next
dimcurrentrecord
currentrecord=pagesize*(topage-1)+1#########显现每页
fork=1topagesize
iflen(c(currentrecord))=0then
exitfor
endif
Response.Writec(currentrecord)&"<br>"
currentrecord=currentrecord+1
next
Response.Write"<bodybgcolor=#EDF0F5topmargin=10marginheight=5leftmargin=4marginwidth=0>"
form=1topagenum
response.write"<spanstyle=font-size:10pt><ahref=news_list.asp?topage="&m&">"&m&"</a></span>"
next
endif
%>
//旧事删除
<!--#includefile="news_session.asp"-->
<%
dimid
id=Request.QueryString("id")
dimmyfso
setmyfso=createobject("scripting.filesystemobject")
ifmyfso.FileExists(server.mappath("./news_content/"&id&".txt"))then
myfso.DeleteFile(server.mappath("./news_content/"&id&".txt"))#############删除旧事内容
endif
dimmytext2,myread2
setmyread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
ifmyread2.atendofstreamthen
Response.Write"没有旧事内容"
myread2.close
Response.End
endif
mytext2=myread2.readall
myread2.close
dimlistarray,i,h,count,sf,title
listarray=split(mytext2,"|")#########读取纪录并以#支解成listarray数组
count=ubound(listarray)
fori=0tocount###########依据ID找到该旧事完成删除功效
sf=split(listarray(i),",")
ifright(sf(0),7)=right(id,7)then
dimthisid
thisid=i
#######为6申明上传了图片,删除旧事图片和该列表纪录
ifubound(sf)=6then
myfso.deletefile(server.MapPath("./images/"&sf(6)))
endif
exitfor
endif
next
dimmytext,mappath
mappath=server.mappath("./")
setmytext=myfso.createtextfile(mappath&"
ew_list.asp",-1,0)
fori=0tothisid-1##########把一切数据从头写进文件
mytext.writelistarray(i)&"|"
next
fori=thisid+1toubound(listarray)
ifi=ubound(listarray)then
mytext.writelistarray(i)
exitfor
else
mytext.writelistarray(i)&"|"
endif
next
mytext.close
%>
<scriptlanguage="javascript">
alert("删除乐成");
location.href=("news_admin1.asp");
</script>
---------------
news_view.asp
<%Response.Expires=0
dimmyid,myfso,myread,mytext1
myid=request.querystring("id")
iflen(myid)=0then
Response.Write"没有该旧事"
Response.End
endif
setmyfso=createobject("scripting.filesystemobject")
setmyread=myfso.opentextfile(server.mappath("./news_content/"&myid&".txt"),1,0)
ifmyread.atendofstreamthen
Response.Write"没有旧事内容"
Response.End
else
mytext1=myread.readall#######翻开对应的旧事内容文件,并读取用变量存储
functionhtmlencode2(str)###########字符处置函数
dimresult
diml
l=len(str)
result=""
dimi
fori=1tol
selectcasemid(str,i,1)
casechr(34)
result=result+""""
case"&"
result=result+"&"
casechr(13)
result=result+"<br>"
case""
result=result+""
casechr(9)
result=result+""
casechr(32)
result=result+""
ifi+1<=landi-1>0then
ifmid(str,i+1,1)=chr(32)ormid(str,i+1,1)=chr(9)ormid(str,i-1,1)=chr(32)ormid(str,i-1,1)=chr(9)then
result=result+""
else
result=result+""
endif
else
result=result+""
endif
caseelse
result=result+mid(str,i,1)
endselect
next
htmlencode2=result
endfunction
myread.close
endif
dimmytext2,myread2
setmyread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
ifmyread2.atendofstreamthen
Response.Write"没有旧事内容"
Response.End
else
mytext2=myread2.readall
myread2.close
dimlistarray,i,h
listarray=split(mytext2,"|")#########读取纪录并以#支解成listarray数组
dimcount,sf,title,src
count=ubound(listarray)
fori=0tocount###########依据ID找到该旧事并把文章点击次数加1
sf=split(listarray(i),",")
ifright(sf(0),7)=right(myid,7)then
title=sf(1)
src=sf(3)
sf(4)=sf(4)+1
#######为6申明上传了图片,存储为新的数组
ifubound(sf)=6then
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)&","&sf(6)
dimmypic
mypic=sf(6)
else
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)
endif
##################
exitfor
endif
next
dimk,mytext,mappath
mappath=server.mappath("./")
setmytext=myfso.createtextfile(mappath&"
ew_list.asp",-1,0)
fori=0toubound(listarray)##########把一切数据从头写进文件
ifi=ubound(listarray)then
mytext.writelistarray(i)
else
mytext.writelistarray(i)&"|"
endif
next
Response.Write"<bodybgcolor=#EDF0F5topmargin=10marginheight=5leftmargin=4marginwidth=0>"
Response.Write"<divalign=centerstyle=font-size:13pt><strong>"&title&"</strong><span></div><br>"
Response.Write"<hrsize=1>"
iflen(mypic)0then
Response.write"<center>
<head>
<style>
td{font-size:9pt}
INPUT.buttonface{
BACKGROUND-COLOR:#0079F2;BORDER-BOTTOM:#3333331pxoutset;BORDER-LEFT:#3333331pxoutset;BORDER-RIGHT:#ffffff1pxoutset;BORDER-TOP:#ffffff1pxinset;COLOR:black;FONT-SIZE:9pta{color:#000000;text-decoration:none}
.text{font-size:11pt}
INPUT.buttonface2{
BACKGROUND-COLOR:#EDF0F5;COLOR:black;FONT-SIZE:9pta{color:#000000;text-decoration:none}
a:hover{color:white;text-decoration:underlineoverline;background:#007EBB}
.text{font-size:11pt}
</style>
</head>
<bodybgcolor=#EDF0F5topmargin=10marginheight=5leftmargin=4marginwidth=0>
<formmethod="POST"action="news_updateing.asp"name="form1"enctype="multipart/form-data"onsubmit="returnform1_onsubmit()">
<divalign="left">
<tableborder="1"width="752"height="240"cellspacing="0"cellpadding="0">
<tr>
<tdcolspan="2"height="12"align="center"width="800"style="font-size:12pt"><strong>旧事公布体系背景办理--旧事修正</strong></td>
</tr>
<tr>
<tdwidth="119"height="12"style="font-size:9pt">旧事题目</td>
<tdwidth="675"height="12">
<inputtype="text"name="newtitle"size="94"value="<%=title%>"class="buttonface2">
</td>
</tr>
<tr>
<tdwidth="119"height="213"style="font-size:9pt">
新<br>
闻<br>
内<br>
容</td>
<tdwidth="675"height="213">
<textarearows="14"name="newcontent"cols="93"style="BACKGROUND-COLOR:#EDF0F5"><%=newscontent%></textarea>
<br>
</td>
</tr>
<tr>
<tdwidth="119"height="4"style="font-size:9pt">旧事来历</td>
<tdwidth="675"height="4">
<inputtype=textname="newssrc"value="<%=src%>"size="93"class="buttonface2">
</td>
</tr>
<tr>
<tdwidth="119"height="5"style="font-size:9pt">图片上传</td>
<tdwidth="675"height="5"><inputtype="file"name="client1"size="20"readonlyLANGUAGE=javascriptonblur="returnclient_onblur(1)"></td>
</tr>
</table>
</div>
<p>
<inputtype="submit"value="确认"name="B1"style="font-size:10pt;color:#000000;"class="buttonface">
<inputtype="reset"value="全体重写"name="B2"style="font-size:10pt;color:#000000;"class="buttonface">
<inputtype="button"value="帐号修正"onclick="location.href=admin/news_chadmin.asp"name="B2"style="font-size:10pt;color:#000000;"class="buttonface">
<inputtype="button"value="旧事增加"onclick="location.href=news_add.asp"name="B2"style="font-size:10pt;color:#000000;"class="buttonface"></p>
<inputtype=hiddenname="myid"value="<%=myid%>">
<INPUTtype="hidden"name="server1">
<inputtype="hidden"name="mysession"value="mysession">
</form>
##########
news_updating.asp
<!--#includefile="news_session.asp"-->
<!--#includefile="upload.inc"-->
<%
Fields("xxx").Name获得Form中xxx(FormObject)的名字
Fields("xxx").FilePath假如是fileObject获得文件的完全路径
Fields("xxx").FileName假如是fileObject获得文件名
Fields("xxx").ContentType假如是fileObject获得文件的范例
Fields("xxx").Length获得Form中xxx(FormObject)的数据长度
Fields("xxx").Value获得Form中xxx(FormObject)的数据内容
DimFormData,FormSize,gnote,bnote,notes,binlen,binstr
FormSize=Request.TotalBytes
FormData=Request.BinaryRead(FormSize)
SetFields=GetUpload(FormData)
############判别输出毛病
dimmytitle,content,src,id,mysession
mysession=Fields("newtitle").value
iflen(mysession)=0then
Response.Write"不法上岸或超工夫,请从头上岸"
Response.End
endif
mytitle=Fields("newtitle").value
mytitle=replace(mytitle,"|","|")
mytitle=replace(mytitle,"<br>","")
content=Fields("newcontent").value
src=Fields("newssrc").value
src=replace(src,"|","|")
src=replace(src,"<br>","")
id=trim(right(Fields("myid").value,12))
iflen(mytitle)=0then
Response.Write"<script>"
Response.Write"alert(堕落!旧事题目不克不及为空!);"
Response.Write"location.href=history.go(-1);"
Response.Write"</script>"
endif
iflen(content)=0then
Response.Write"<script>"
Response.Write"alert(堕落!旧事内容不克不及为空!);"
Response.Write"location.href=history.go(-1);"
Response.Write"</script>"
endif
iflen(src)=0then
Response.Write"<script>"
Response.Write"alert(堕落!旧事来历不克不及为空!);"
Response.Write"location.href=history.go(-1);"
Response.Write"</script>"
endif
############################################################################################图片更该功效的完成
newfile="client1"
IfFields(newfile).FileName""Then
setfile_0=Server.CreateObject("Scripting.FileSystemObject")
dimcontextname
contextname=right(Fields("client1").FileName,4)
imageid=id&contextname
ifcontextname".gif"andcontextname".jpg"then#########判别上传文件格局
Response.Write"<script>"
Response.Write"alert(堕落!上传文件格局不合错误只能为jpg/gif图片格局!);"
Response.Write"location.href=history.go(-1);"
Response.Write"</script>"
endif
file_name=Server.MapPath("./images/"&imageid&"")
#####################################假如本来有图片文件主名为id的则删除该图片
iffile_0.fileexists(server.MapPath("./images/"&id&".gif"))then
Setf3=file_0.GetFile(server.MapPath("./images/"&id&".gif"))
f3.Delete
endif
iffile_0.fileexists(server.MapPath("./images/"&id&".jpg"))then
Setf3=file_0.GetFile(server.MapPath("./images/"&id&".jpg"))
f3.Delete
endif
########################################写进图片
setoutstream=file_0.openTextFile(file_name,8,-1)
binstr=Fields("client1").Value
binlen=1
varlen=lenb(binstr)
fori=1tovarlen
clow=MidB(binstr,i,1)
IfAscB(clow)=255then
outstream.writechr(255)
binlen=binlen+1
if(imod2)=0then
notes=gnote
exitfor
endif
elseifAscB(clow)>128then
clow1=MidB(binstr,i+1,1)
ifAscB(clow1)<64orAscB(clow1)=127orAscB(clow1)=255then
binlen=binlen+1
if(binlenmod2)=0then
binlen=binlen+1
outstream.writeChr(AscW(ChrB(128)&clow))
endif
notes=bnote
exitfor
else
outstream.writeChr(AscW(clow1&clow))
binlen=binlen+2
i=i+1
if(imod2)=0then
notes=gnote
exitfor
endif
endif
else
outstream.writechr(AscB(clow))
binlen=binlen+1
if(imod2)=0then
notes=gnote
exitfor
endif
endif
next
outstream.close
setoutstream=file_0.OpenTextFile(file_name,8,false,-1)
outstream.writemidb(Fields(newfile).Value,binlen)
outstream.close
ifnotes=bnotethennotes=notes&(binlen-1)&"字节处。"
EndIf
#######################################################################################################
dimmyfso,mywrite#######修正旧事具体内容
setmyfso=createobject("scripting.filesystemobject")
ifmyfso.FileExists(server.mappath("./news_content/"&id&".txt"))then
myfso.DeleteFile(server.mappath("./news_content/"&id&".txt"))
endif
setmywrite=myfso.createtextfile(server.mappath("./news_content/"&id&".txt"),-1,0)
mywrite.writecontent
dimmytext2,myread2#########修正旧事的题目来历
setmyread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
mytext2=myread2.readall
dimlistarray,i,h,count,sf
listarray=split(mytext2,"|")#########读取纪录并以#支解成listarray数组
count=ubound(listarray)
fori=0tocount###########依据ID找到该旧事纪录
sf=split(listarray(i),",")
ifright(sf(0),7)=right(id,7)then
sf(1)=mytitle
sf(3)=src
#######为6申明上传了图片,存储新的数组完成检察纪录点击次数加1
ifubound(sf)=6then
IfFields(newfile).FileName""Then
sf(6)=imageid
endif
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)&","&sf(6)
else
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)
endif
##################
exitfor
endif
next
functionhtmlencode2(str)#############字符处置函数
dimresult
diml
l=len(str)
result=""
dimi
fori=1tol
selectcasemid(str,i,1)
casechr(34)
result=result+""
case"&"
result=result+"&"
casechr(13)
result=result+"<br>"
case""
result=result+""
casechr(9)
result=result+""
casechr(32)
ifi+1<=landi-1>0then
ifmid(str,i+1,1)=chr(32)ormid(str,i+1,1)=chr(9)ormid(str,i-1,1)=chr(32)ormid(str,i-1,1)=chr(9)then
result=result+""
else
result=result+""
endif
else
result=result+""
endif
caseelse
result=result+mid(str,i,1)
endselect
next
htmlencode2=result
endfunction
##########################
dimk,mytext,mappath
mappath=server.mappath("./")
setmytext=myfso.createtextfile(mappath&"
ew_list.asp",-1,0)
fori=0toubound(listarray)##########把一切数据从头写进文件
ifi=ubound(listarray)then
mytext.writehtmlencode2(listarray(i))
else
mytext.writehtmlencode2(listarray(i)&"|")
endif
next
%>
<scriptlanguage="javascript">
alert("变动乐成");
window.location=("news_admin1.asp");
</script>
在实现ERP等高端的ASP应用时,用户需要提供核心的经营资料,需要ASP商有很高的信用度。楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。 他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。 封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变,业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高。 多看多学多思。多看一些关于ASP的书籍,一方面可以扩展知识面一方面可以鉴借别人是如何掌握、运用ASP的;多学善于关注别人,向同学老师多多学习,不论知识的大小;多思则是要将学到的知识灵活运用。 还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。 下载一个源代码,然后再下载一个VBScript帮助,在源代码中遇到不认识的函数或是其他什么程序,都可以查帮助进行解决,这样学习效率很高。 不能只是将它停留在纸上谈兵的程度上。 我可以结合自己的经验大致给你说一说,希望对你有所帮助,少走些弯路。 如何更好的使自己的东西看上去很不错等等。其实这些都不是问题的实质,我们可以在实践中不断提升自己,不断充实自己。
页:
[1]