大概在九九年做游戏网站的时候,就对文章的发布感到麻烦,不过那会儿玩asp不精。只是将就用着。在遇到长文件 10000 字时网页就是一大片长了。
去年,做一个通用的文章与新闻管理系统时,曾写了一段代码,用来分离。现在贴出来。
要说明的是:
我的文章 录入界面是基于web的hemleditor,就像这里的abc代码差不多。所以实际提交的是html格式的文 本。
对html做了相应的处理,不会由html代码中切开。
这里另一位兄弟曾发表过一个,原理一样,不过我没仔细看过,不知有啥不同。
代码如下:
————————————–
request form item
i_forder = request.form ("i_folder")
i_topic = request.form ("i_topic")
i_title = htmlencode(request.form ("i_title"))
i_body = request.form ("body")
i_source = request.form ("i_source")
i_keyword= htmlencode(request.form ("i_keyword"))
i_ishot = request.form("ishot")
if i_ishot = "" then i_ishot="n"
i_ispic = request.form("ispic")
if i_ispic = "" then i_ispic ="n"
i_pic = request.form("insertimage")
i_body = replace(i_body,"contenteditable=true","contenteditable=false")
check input
……
get pages ,b = body
b_len = len(i_body)
b_pages = 1
t = temp
t_loop = true
do while t_loop 这里loop多次,每4000分一页,算出页码并加入库。
if b_len > 4000 then
n_body = left(i_body,4000) n = new
if "
" in n_body
if instrrev(n_body,"
0 and (len(n_body) – instrrev(n_body,"
n_body = left(n_body,instrrev(n_body,"
else if instrrev(n_body," ") > 0 and (len(n_body) – instrrev(n_body," "))< 400 then
n_body = left(n_body,instrrev(n_body," ")-1)
else if instrrev(n_body,"。") > 0 and (len(n_body) – instrrev(n_body,"。"))< 400 then
n_body = left(n_body,instrrev(n_body,"。"))
else if instrrev(n_body,";") > 0 and (len(n_body) – instrrev(n_body,";"))< 400 then
n_body = left(n_body,instrrev(n_body,";"))
else if instrrev(n_body,",") > 0 and (len(n_body) – instrrev(n_body,","))< 400 then
n_body = left(n_body,instrrev(n_body,","))
else if instrrev(n_body,".") > 0 and (len(n_body) – instrrev(n_body,"."))< 400 then
n_body = left(n_body,instrrev(n_body,"."))
end if
end if
end if
end if
end if
end if
n_len = len(n_body)
i_body = mid(i_body,n_len+1)
b_len = len(i_body)
else
n_body = i_body
t_loop = false
end if
add to database
exec_prc_content_ins i_forder,i_topic,i_title,i_source,n_body,i_ispic,i_pic,i_ishot,i_keyword,b_pages
这里一个function,你可以自己处理,反正结果有两个,一个是body,一个是b_pages,就是页码。
b_pages = b_pages + 1
loop
%>
新建网页 1录入成功 |
此文章共分页 |
top.main_top.location.reload();