>>> 帝国网站管理系统5.1开源测试版下载
帝国CMS进入开源时代
 帝国论坛技术交流区网络编程谁能把这个asp的函数转换成php的啊 【本版专题贴子】  
主题:谁能把这个asp的函数转换成php的啊 [加入收藏夹]   

sunlang
用户头衔:举人

精华贴   :1
发贴数   :514
经验值   :1764
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 1 楼]
谁能把这个asp的函数转换成php的啊
'=================================================
'过程名:ManualPagination
'作  用:采用手动分页方式显示文章具体的内容
'参  数:无
'=================================================
sub ManualPagination()
        dim ArticleID,strContent,CurrentPage
        dim ContentLen,MaxPerPage,pages,i
        dim arrContent
        ArticleID=rs("ArticleID")
        strContent=rs("Content")
        ContentLen=len(strContent)
        CurrentPage=trim(request("ArticlePage"))
        if Instr(strContent,"[NextPage]")<=0 then
                response.write strContent
                response.write "</p><p align='center'><font color='red'><b>[1]</b></font></p>"
        else
                arrContent=split(strContent,"[NextPage]")

                pages=Ubound(arrContent)+1
                if CurrentPage="" then
                        CurrentPage=1
                else
                        CurrentPage=Cint(CurrentPage)
                end if
                if CurrentPage<1 then CurrentPage=1
                if CurrentPage>pages then CurrentPage=pages

                response.write arrContent(CurrentPage-1)

                response.write "</p><p align='center'><b>"
                if CurrentPage>1 then
                        response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage-1 & "'>上一页</a>&nbsp;&nbsp;"
                end if
                for i=1 to pages
                        if i=CurrentPage then
                                response.write "<font color='red'>[" & cstr(i) & "]</font>&nbsp;"
                        else
                                response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & i & "'>[" & i & "]</a>&nbsp;"
                        end if
                next
                if CurrentPage<pages then
                        response.write "&nbsp;<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage+1 & "'>下一页</a>"
                end if
                response.write "</b></p>"
               
        end if

end sub




2003-09-24 13:53:37 已设置保密 顶部 回复 引用 报告 编辑 删除

sunlang
用户头衔:举人

精华贴   :1
发贴数   :514
经验值   :1764
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 2 楼]

'=================================================
'过程名:AutoPagination
'作  用:采用自动分页方式显示文章具体的内容
'参  数:无
'=================================================
sub AutoPagination()
        dim ArticleID,strContent,CurrentPage
        dim ContentLen,MaxPerPage,pages,i,lngBound
        dim BeginPoint,EndPoint
        ArticleID=rs("ArticleID")
        strContent=rs("Content")
        ContentLen=len(strContent)
        CurrentPage=trim(request("ArticlePage"))
        if ContentLen<=rs("MaxCharPerPage") then
                response.write strContent
                response.write "</p><p align='center'><font color='red'><b>[1]</b></font></p>"
        else
                if CurrentPage="" then
                        CurrentPage=1
                else
                        CurrentPage=Cint(CurrentPage)
                end if
                pages=ContentLenrs("MaxCharPerPage")
                if rs("MaxCharPerPage")*pages<ContentLen then
                        pages=pages+1
                end if
                lngBound=ContentLen          '最大误差范围
                if CurrentPage<1 then CurrentPage=1
                if CurrentPage>pages then CurrentPage=pages

                dim lngTemp
                dim lngTemp1,lngTemp1_1,lngTemp1_2,lngTemp1_1_1,lngTemp1_1_2,lngTemp1_1_3,lngTemp1_2_1,lngTemp1_2_2,lngTemp1_2_3
                dim lngTemp2,lngTemp2_1,lngTemp2_2,lngTemp2_1_1,lngTemp2_1_2,lngTemp2_2_1,lngTemp2_2_2
                dim lngTemp3,lngTemp3_1,lngTemp3_2,lngTemp3_1_1,lngTemp3_1_2,lngTemp3_2_1,lngTemp3_2_2
                dim lngTemp4,lngTemp4_1,lngTemp4_2,lngTemp4_1_1,lngTemp4_1_2,lngTemp4_2_1,lngTemp4_2_2
                dim lngTemp5,lngTemp5_1,lngTemp5_2
                dim lngTemp6,lngTemp6_1,lngTemp6_2
               
                if CurrentPage=1 then
                        BeginPoint=1
                else
                        BeginPoint=rs("MaxCharPerPage")*(CurrentPage-1)+1
                       
                        lngTemp1_1_1=instr(BeginPoint,strContent,"</table>",1)
                        lngTemp1_1_2=instr(BeginPoint,strContent,"</TABLE>",1)
                        lngTemp1_1_3=instr(BeginPoint,strContent,"</Table>",1)
                        if lngTemp1_1_1>0 then
                                lngTemp1_1=lngTemp1_1_1
                        elseif lngTemp1_1_2>0 then
                                lngTemp1_1=lngTemp1_1_2
                        elseif lngTemp1_1_3>0 then
                                lngTemp1_1=lngTemp1_1_3
                        else
                                lngTemp1_1=0
                        end if
                                                       
                        lngTemp1_2_1=instr(BeginPoint,strContent,"<table",1)
                        lngTemp1_2_2=instr(BeginPoint,strContent,"<TABLE",1)
                        lngTemp1_2_3=instr(BeginPoint,strContent,"<Table",1)
                        if lngTemp1_2_1>0 then
                                lngTemp1_2=lngTemp1_2_1
                        elseif lngTemp1_2_2>0 then
                                lngTemp1_2=lngTemp1_2_2
                        elseif lngTemp1_2_3>0 then
                                lngTemp1_2=lngTemp1_2_3
                        else
                                lngTemp1_2=0
                        end if
                       
                        if lngTemp1_1=0 and lngTemp1_2=0 then
                                lngTemp1=BeginPoint
                        else
                                if lngTemp1_1>lngTemp1_2 then
                                        lngtemp1=lngTemp1_2
                                else
                                        lngTemp1=lngTemp1_1+8
                                end if
                        end if

                        lngTemp2_1_1=instr(BeginPoint,strContent,"</p>",1)
                        lngTemp2_1_2=instr(BeginPoint,strContent,"</P>",1)
                        if lngTemp2_1_1>0 then
                                lngTemp2_1=lngTemp2_1_1
                        elseif lngTemp2_1_2>0 then
                                lngTemp2_1=lngTemp2_1_2
                        else
                                lngTemp2_1=0
                        end if
                                               
                        lngTemp2_2_1=instr(BeginPoint,strContent,"<p",1)
                        lngTemp2_2_2=instr(BeginPoint,strContent,"<P",1)
                        if lngTemp2_2_1>0 then
                                lngTemp2_2=lngTemp2_2_1
                        elseif lngTemp2_2_2>0 then
                                lngTemp2_2=lngTemp2_2_2
                        else
                                lngTemp2_2=0
                        end if
                       
                        if lngTemp2_1=0 and lngTemp2_2=0 then
                                lngTemp2=BeginPoint
                        else
                                if lngTemp2_1>lngTemp2_2 then
                                        lngtemp2=lngTemp2_2
                                else
                                        lngTemp2=lngTemp2_1+4
                                end if
                        end if

                        lngTemp3_1_1=instr(BeginPoint,strContent,"</ur>",1)
                        lngTemp3_1_2=instr(BeginPoint,strContent,"</UR>",1)
                        if lngTemp3_1_1>0 then
                                lngTemp3_1=lngTemp3_1_1
                        elseif lngTemp3_1_2>0 then
                                lngTemp3_1=lngTemp3_1_2
                        else
                                lngTemp3_1=0
                        end if
                       
                        lngTemp3_2_1=instr(BeginPoint,strContent,"<ur",1)
                        lngTemp3_2_2=instr(BeginPoint,strContent,"<UR",1)
                        if lngTemp3_2_1>0 then
                                lngTemp3_2=lngTemp3_2_1
                        elseif lngTemp3_2_2>0 then
                                lngTemp3_2=lngTemp3_2_2
                        else
                                lngTemp3_2=0
                        end if
                                       
                        if lngTemp3_1=0 and lngTemp3_2=0 then
                                lngTemp3=BeginPoint
                        else
                                if lngTemp3_1>lngTemp3_2 then
                                        lngtemp3=lngTemp3_2
                                else
                                        lngTemp3=lngTemp3_1+5
                                end if
                        end if
                       
                        if lngTemp1<lngTemp2 then
                                lngTemp=lngTemp2
                        else
                                lngTemp=lngTemp1
                        end if
                        if lngTemp<lngTemp3 then
                                lngTemp=lngTemp3
                        end if

                        if lngTemp>BeginPoint and lngTemp<=BeginPoint+lngBound then
                                BeginPoint=lngTemp
                        else
                                lngTemp4_1_1=instr(BeginPoint,strContent,"</li>",1)
                                lngTemp4_1_2=instr(BeginPoint,strContent,"</LI>",1)
                                if lngTemp4_1_1>0 then
                                        lngTemp4_1=lngTemp4_1_1
                                elseif lngTemp4_1_2>0 then
                                        lngTemp4_1=lngTemp4_1_2
                                else
                                        lngTemp4_1=0
                                end if
                               
                                lngTemp4_2_1=instr(BeginPoint,strContent,"<li",1)
                                lngTemp4_2_1=instr(BeginPoint,strContent,"<LI",1)
                                if lngTemp4_2_1>0 then
                                        lngTemp4_2=lngTemp4_2_1
                                elseif lngTemp4_2_2>0 then
                                        lngTemp4_2=lngTemp4_2_2
                                else
                                        lngTemp4_2=0
                                end if
                               
                                if lngTemp4_1=0 and lngTemp4_2=0 then
                                        lngTemp4=BeginPoint
                                else
                                        if lngTemp4_1>lngTemp4_2 then
                                                lngtemp4=lngTemp4_2
                                        else
                                                lngTemp4=lngTemp4_1+5
                                        end if
                                end if
                               
                                if lngTemp4>BeginPoint and lngTemp4<=BeginPoint+lngBound then
                                        BeginPoint=lngTemp4
                                else                                       
                                        lngTemp5_1=instr(BeginPoint,strContent,"<img",1)
                                        lngTemp5_2=instr(BeginPoint,strContent,"<IMG",1)
                                        if lngTemp5_1>0 then
                                                lngTemp5=lngTemp5_1
                                        elseif lngTemp5_2>0 then
                                                lngTemp5=lngTemp5_2
                                        else
                                                lngTemp5=BeginPoint
                                        end if
                                       
                                        if lngTemp5>BeginPoint and lngTemp5<BeginPoint+lngBound then
                                                BeginPoint=lngTemp5
                                        else
                                                lngTemp6_1=instr(BeginPoint,strContent,"<br>",1)
                                                lngTemp6_2=instr(BeginPoint,strContent,"<BR>",1)
                                                if lngTemp6_1>0 then
                                                        lngTemp6=lngTemp6_1
                                                elseif lngTemp6_2>0 then
                                                        lngTemp6=lngTemp6_2
                                                else
                                                        lngTemp6=0
                                                end if
                                       
                                                if lngTemp6>BeginPoint and lngTemp6<BeginPoint+lngBound then
                                                        BeginPoint=lngTemp6+4
                                                end if
                                        end if
                                end if
                        end if
                end if

                if CurrentPage=pages then
                        EndPoint=ContentLen
                else
                  EndPoint=rs("MaxCharPerPage")*CurrentPage
                  if EndPoint>=ContentLen then
                        EndPoint=ContentLen
                  else
                        lngTemp1_1_1=instr(EndPoint,strContent,"</table>",1)
                        lngTemp1_1_2=instr(EndPoint,strContent,"</TABLE>",1)
                        lngTemp1_1_3=instr(EndPoint,strContent,"</Table>",1)
                        if lngTemp1_1_1>0 then
                                lngTemp1_1=lngTemp1_1_1
                        elseif lngTemp1_1_2>0 then
                                lngTemp1_1=lngTemp1_1_2
                        elseif lngTemp1_1_3>0 then
                                lngTemp1_1=lngTemp1_1_3
                        else
                                lngTemp1_1=0
                        end if
                                                       
                        lngTemp1_2_1=instr(EndPoint,strContent,"<table",1)
                        lngTemp1_2_2=instr(EndPoint,strContent,"<TABLE",1)
                        lngTemp1_2_3=instr(EndPoint,strContent,"<Table",1)
                        if lngTemp1_2_1>0 then
                                lngTemp1_2=lngTemp1_2_1
                        elseif lngTemp1_2_2>0 then
                                lngTemp1_2=lngTemp1_2_2
                        elseif lngTemp1_2_3>0 then
                                lngTemp1_2=lngTemp1_2_3
                        else
                                lngTemp1_2=0
                        end if
                       
                        if lngTemp1_1=0 and lngTemp1_2=0 then
                                lngTemp1=EndPoint
                        else
                                if lngTemp1_1>lngTemp1_2 then
                                        lngtemp1=lngTemp1_2-1
                                else
                                        lngTemp1=lngTemp1_1+7
                                end if
                        end if

                        lngTemp2_1_1=instr(EndPoint,strContent,"</p>",1)
                        lngTemp2_1_2=instr(EndPoint,strContent,"</P>",1)
                        if lngTemp2_1_1>0 then
                                lngTemp2_1=lngTemp2_1_1
                        elseif lngTemp2_1_2>0 then
                                lngTemp2_1=lngTemp2_1_2
                        else
                                lngTemp2_1=0
                        end if
                                               
                        lngTemp2_2_1=instr(EndPoint,strContent,"<p",1)
                        lngTemp2_2_2=instr(EndPoint,strContent,"<P",1)
                        if lngTemp2_2_1>0 then
                                lngTemp2_2=lngTemp2_2_1
                        elseif lngTemp2_2_2>0 then
                                lngTemp2_2=lngTemp2_2_2
                        else
                                lngTemp2_2=0
                        end if
                       
                        if lngTemp2_1=0 and lngTemp2_2=0 then
                                lngTemp2=EndPoint
                        else
                                if lngTemp2_1>lngTemp2_2 then
                                        lngTemp2=lngTemp2_2-1
                                else
                                        lngTemp2=lngTemp2_1+3
                                end if
                        end if

                        lngTemp3_1_1=instr(EndPoint,strContent,"</ur>",1)
                        lngTemp3_1_2=instr(EndPoint,strContent,"</UR>",1)
                        if lngTemp3_1_1>0 then
                                lngTemp3_1=lngTemp3_1_1
                        elseif lngTemp3_1_2>0 then
                                lngTemp3_1=lngTemp3_1_2
                        else
                                lngTemp3_1=0
                        end if
                       
                        lngTemp3_2_1=instr(EndPoint,strContent,"<ur",1)
                        lngTemp3_2_2=instr(EndPoint,strContent,"<UR",1)
                        if lngTemp3_2_1>0 then
                                lngTemp3_2=lngTemp3_2_1
                        elseif lngTemp3_2_2>0 then
                                lngTemp3_2=lngTemp3_2_2
                        else
                                lngTemp3_2=0
                        end if
                                       
                        if lngTemp3_1=0 and lngTemp3_2=0 then
                                lngTemp3=EndPoint
                        else
                                if lngTemp3_1>lngTemp3_2 then
                                        lngtemp3=lngTemp3_2-1
                                else
                                        lngTemp3=lngTemp3_1+4
                                end if
                        end if
                       
                        if lngTemp1<lngTemp2 then
                                lngTemp=lngTemp2
                        else
                                lngTemp=lngTemp1
                        end if
                        if lngTemp<lngTemp3 then
                                lngTemp=lngTemp3
                        end if

                        if lngTemp>EndPoint and lngTemp<=EndPoint+lngBound then
                                EndPoint=lngTemp
                        else
                                lngTemp4_1_1=instr(EndPoint,strContent,"</li>",1)
                                lngTemp4_1_2=instr(EndPoint,strContent,"</LI>",1)
                                if lngTemp4_1_1>0 then
                                        lngTemp4_1=lngTemp4_1_1
                                elseif lngTemp4_1_2>0 then
                                        lngTemp4_1=lngTemp4_1_2
                                else
                                        lngTemp4_1=0
                                end if
                               
                                lngTemp4_2_1=instr(EndPoint,strContent,"<li",1)
                                lngTemp4_2_1=instr(EndPoint,strContent,"<LI",1)
                                if lngTemp4_2_1>0 then
                                        lngTemp4_2=lngTemp4_2_1
                                elseif lngTemp4_2_2>0 then
                                        lngTemp4_2=lngTemp4_2_2
                                else
                                        lngTemp4_2=0
                                end if
                               
                                if lngTemp4_1=0 and lngTemp4_2=0 then
                                        lngTemp4=EndPoint
                                else
                                        if lngTemp4_1>lngTemp4_2 then
                                                lngtemp4=lngTemp4_2-1
                                        else
                                                lngTemp4=lngTemp4_1+4
                                        end if
                                end if
                               
                                if lngTemp4>EndPoint and lngTemp4<=EndPoint+lngBound then
                                        EndPoint=lngTemp4
                                else                                       
                                        lngTemp5_1=instr(EndPoint,strContent,"<img",1)
                                        lngTemp5_2=instr(EndPoint,strContent,"<IMG",1)
                                        if lngTemp5_1>0 then
                                                lngTemp5=lngTemp5_1-1
                                        elseif lngTemp5_2>0 then
                                                lngTemp5=lngTemp5_2-1
                                        else
                                                lngTemp5=EndPoint
                                        end if
                                       
                                        if lngTemp5>EndPoint and lngTemp5<EndPoint+lngBound then
                                                EndPoint=lngTemp5
                                        else
                                                lngTemp6_1=instr(EndPoint,strContent,"<br>",1)
                                                lngTemp6_2=instr(EndPoint,strContent,"<BR>",1)
                                                if lngTemp6_1>0 then
                                                        lngTemp6=lngTemp6_1+3
                                                elseif lngTemp6_2>0 then
                                                        lngTemp6=lngTemp6_2+3
                                                else
                                                        lngTemp6=EndPoint
                                                end if
                                       
                                                if lngTemp6>EndPoint and lngTemp6<EndPoint+lngBound then
                                                        EndPoint=lngTemp6
                                                end if
                                        end if
                                end if
                        end if
                  end if
                end if
                response.write mid(strContent,BeginPoint,EndPoint-BeginPoint)
               
                response.write "</p><p align='center'><b>"
                if CurrentPage>1 then
                        response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage-1 & "'>上一页</a>&nbsp;&nbsp;"
                end if
                for i=1 to pages
                        if i=CurrentPage then
                                response.write "<font color='red'>[" & cstr(i) & "]</font>&nbsp;"
                        else
                                response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & i & "'>[" & i & "]</a>&nbsp;"
                        end if
                next
                if CurrentPage<pages then
                        response.write "&nbsp;<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage+1 & "'>下一页</a>"
                end if
                response.write "</b></p>"
        end if

end sub




2003-09-24 13:57:00 已设置保密 顶部 回复 引用 报告 编辑 删除

wm_chief
用户头衔:管理员

精华贴   :21
发贴数   :47888
经验值   :109431
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 3 楼]

第二种方法太麻烦了吧。。
我觉得用第一种分隔法会更好些



[零基础入门教程] [模板制作教程] [采集使用教程]
2003-09-24 14:01:19 已设置保密 顶部 回复 引用 报告 编辑 删除

sunlang
用户头衔:举人

精华贴   :1
发贴数   :514
经验值   :1764
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 4 楼]

关键他们要自动这种啊




2003-09-24 14:02:08 已设置保密 顶部 回复 引用 报告 编辑 删除

shengjie
用户头衔:嘉宾

精华贴   :0
发贴数   :1095
经验值   :3634
注册时间:2003-01-15
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 5 楼]

可以这样偷懒呀。

建立两个表,一个存文章标题、作者、点击次数等等。

在建立一个表。存文章内容,先分页之后在存入。

假设有N条记录。

在前台就显示共有N条记录1 2 3 ...N

不知道这样行不



买商品,上偶评http://www.openping.com/
2003-09-24 15:13:16 已设置保密 顶部 回复 引用 报告 编辑 删除

wm_chief
用户头衔:管理员

精华贴   :21
发贴数   :47888
经验值   :109431
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 6 楼]

第一种就是你这个方法了。。。
他非要自动了。。。。。没办法噢,晚上帮他想想



[零基础入门教程] [模板制作教程] [采集使用教程]
2003-09-24 15:20:20 已设置保密 顶部 回复 引用 报告 编辑 删除

shengjie
用户头衔:嘉宾

精华贴   :0
发贴数   :1095
经验值   :3634
注册时间:2003-01-15
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 7 楼]

晕。

楼主老板是不是变态??



买商品,上偶评http://www.openping.com/
2003-09-24 15:21:55 已设置保密 顶部 回复 引用 报告 编辑 删除

wm_chief
用户头衔:管理员

精华贴   :21
发贴数   :47888
经验值   :109431
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 8 楼]

就怕是有病,哈哈



[零基础入门教程] [模板制作教程] [采集使用教程]
2003-09-24 15:26:32 已设置保密 顶部 回复 引用 报告 编辑 删除

wm_chief
用户头衔:管理员

精华贴   :21
发贴数   :47888
经验值   :109431
注册时间:2002-10-30
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 9 楼]

分析结果:最好用第一种的噢。。。。



[零基础入门教程] [模板制作教程] [采集使用教程]
2003-09-25 09:24:02 已设置保密 顶部 回复 引用 报告 编辑 删除

shengjie
用户头衔:嘉宾

精华贴   :0
发贴数   :1095
经验值   :3634
注册时间:2003-01-15
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 10 楼]

没有帮楼主转化过来。失败了



买商品,上偶评http://www.openping.com/
2003-09-26 14:36:31 已设置保密 顶部 回复 引用 报告 编辑 删除

快速回复
内容

表情
使用EBB代码 使用smile代码 显示签名 自动分析url 自动分析img
     【进入高级模式】   (按 Ctrl+Enter 直接提交)
    顶部  加入收藏夹
关于帝国 | 广告服务 | 联系我们 | 法律声明 | 隐私条款 | 许可协议
Powered by: EBB Version 2.2.1