我们时刻把握互联网流行趋势!

传递业内动态,探讨互联网热门话题,我们与您分享网站建设心得及职业生涯感悟,让您把握网络流行趋势,占据互联网时代前沿!

新闻资讯企业动态前沿探索技术分享

ISite地图生成错误修复

技术分享 2014-12-11 

Bug描述:生成地图链接有误,且关闭模版调试模式时,无法生成网站地图。


此bug修复方法如下:

打开文件 admin/SiteMap.asp

分别将99行、214行、238行、259行代码

cURL=Server.HTMLEncode(Replace(Fk_Site_Url&cURL,"//","/"))

替换为以下代码

cURL=Server.HTMLEncode(Replace(Replace(Fk_Site_Url&CURL,"//","/"),"http:/","http://"))

保存文件,这4处替换是解决生成的链接有误(http:/替换为http://)。


接着,我们来解决关闭模版调试模式时,无法生成网站地图的问题。

将第64行代码

    Dim c_Rs,cURL

替换为

    Dim mRs,c_Rs,cURL

将第67行代码

    Set c_Rs=Server.Createobject("Adodb.RecordSet")

替换为以下代码

    Set mRs=Server.Createobject("Adodb.RecordSet")
    Set c_Rs=Server.Createobject("Adodb.RecordSet")

将第91行-230行代码

    '生成栏目页
    Sqlstr="Select Fk_Module_Id,Fk_Module_Type,Fk_Module_Model,Fk_Module_FixedUrl,Fk_Module_Url,Fk_Module_LinkType,Fk_Module_PageSize,Fk_Module_Menu,Fk_Module_GBookReply,Fk_Module_Template From [Fk_Module] Where Fk_Module_State=1 Order By Fk_Module_Id Asc"
    Rs.Open Sqlstr,Conn,1,1
    If Not Rs.Eof Then
        While Not Rs.Eof
            If (Rs("Fk_Module_LinkType")=1 And Rs("Fk_Module_Type")=4) Or Instr(",0,2,",","&Rs("Fk_Module_Type")&",")>0 Then
                cURL=FKTemplate.GetUrl(FullSiteDir,"",Rs("Fk_Module_Url")&"Index","",PageSuffix,1,Rs("Fk_Module_Id"),Rs("Fk_Module_FixedUrl"))
                '生成
                cURL=Replace(cURL,"Index"&PageSuffix,"")
                cURL=Server.HTMLEncode(Replace(Fk_Site_Url&cURL,"//","/"))
                CreateHtml=CreateHtml&"<url>"&vbLf
                CreateHtml=CreateHtml&"<loc>"&cURL&"</loc>"&vbLf
                If CreateType=1 Then
                    CreateHtml=CreateHtml&"<lastmod>"&Date()&"</lastmod>"&vbLf
                    CreateHtml=CreateHtml&"<changefreq>daily</changefreq>"&vbLf
                    CreateHtml=CreateHtml&"<priority>0.7</priority>"&vbLf
                End If
                CreateHtml=CreateHtml&"</url>"&vbLf
            ElseIf Instr(",1,3,",","&Rs("Fk_Module_Type")&",")>0 Then
                '读取每页数量
                PageSizes=Fk_Site_PageSize
                If Rs("Fk_Module_PageSize")>0 Then
                    PageSizes=Rs("Fk_Module_PageSize")
                End If
                
                '读取模型绑定模板
                If Rs("Fk_Module_Type")=1 Then
                    Sqlstr="Select Fk_Model_Template From [Fk_Model] Where Fk_Model_Id="&Rs("Fk_Module_Model")&""
                    c_Rs.Open Sqlstr,Conn,1,1
                    If Not c_Rs.Eof Then
                        mModelTemplate=c_Rs("Fk_Model_Template")
                    Else
                        mModelTemplate=""
                    End If
                    c_Rs.Close
                Else
                    mModelTemplate=""
                End If

                If Rs("Fk_Module_Type")=1 Then
                    PageTemplate="viewlist"
                ElseIf Rs("Fk_Module_Type")=3 Then
                    PageTemplate="gbook"
                End If
                
                If Rs("Fk_Module_Template")<>"" Then
                    PageTemplate=Rs("Fk_Module_Template")
                ElseIf mModelTemplate<>"" Then
                    PageTemplate=mModelTemplate
                End If
                                
                '菜单信息读取
                Sqlstr="Select Fk_Menu_Dir,Fk_Menu_Template From [Fk_Menu] Where Fk_Menu_Id=" & Rs("Fk_Module_Menu")
                c_Rs.Open Sqlstr,Conn,1,1
                If Not c_Rs.Eof Then
                    MenuDir=c_Rs("Fk_Menu_Dir")
                    MenuTemplate=c_Rs("Fk_Menu_Template")
                Else
                    c_Rs.Close
                    Call FKFun.ShowErr("error:菜单不存在!",0)
                End If
                c_Rs.Close
                
                '目录模板方案_默认模板组合
                If MenuTemplate<>"" Then
                    If Instr(DisTemplate,","&PageTemplate&",")>0 Then
                        PageTemplate=MenuTemplate&"/"&PageTemplate
                    End If
                End If
                
                '模板标签解析
                PageCode=FKTemplate.GetTemplate(PageTemplate)
                
                PageCounts=1
                '读取页数
                If Instr(PageCode,"{$ModulePageCode(")>0 Then
                    '内容模块
                    If Rs("Fk_Module_Type")=1 Then
                        Sqlstr="Select Fk_View_Id From [Fk_View] Where Fk_View_Show=1 And Fk_View_Module="&Rs("Fk_Module_Id")&""
                        c_Rs.Open Sqlstr,Conn,1,1
                        c_Rs.PageSize=PageSizes
                        If c_Rs.PageCount>0 Then
                            PageCounts=c_Rs.PageCount
                        End If
                        c_Rs.Close
                    '留言模块
                    ElseIf Rs("Fk_Module_Type")=3 And Rs("Fk_Module_GBookReply")<>3 Then
                        Sqlstr="Select Fk_GBook_Id From [Fk_GBook] Where Fk_GBook_Module="&Rs("Fk_Module_Id")&""
                        If Rs("Fk_Module_GBookReply")=1 Then
                            Sqlstr=Sqlstr&" And Fk_GBook_ReIp<>''"
                        ElseIf Rs("Fk_Module_GBookReply")=2 Then
                            Sqlstr=Sqlstr&" And (Fk_GBook_ReIp='' Or Fk_GBook_ReIp Is Null)"
                        End If
                        c_Rs.Open Sqlstr,Conn,1,1
                        c_Rs.PageSize=PageSizes
                        If c_Rs.PageCount>0 Then
                            PageCounts=c_Rs.PageCount
                        End If
                        c_Rs.Close
                    Else
                        PageCounts=1
                    End If
                    '循环生成
                    For PageNow=1 To PageCounts
                        '链接地址获取
                        If Rs("Fk_Module_FixedUrl")<>"" Then '绝对链接
                            If Instr(Rs("Fk_Module_FixedUrl"),".")>0 Then '绝对链接带后缀
                                cURL=FKTemplate.GetUrl(FullSiteDir,"","","",PageSuffix,1,Rs("Fk_Module_Id"),Rs("Fk_Module_FixedUrl"))
                            Else '绝对链接不带后缀
                                If PageNow=1 Then
                                    cURL=FKTemplate.GetUrl(FullSiteDir,"","","",PageSuffix,1,Rs("Fk_Module_Id"),Rs("Fk_Module_FixedUrl")&"Index")
                                Else
                                    cURL=FKTemplate.GetUrl(FullSiteDir,"","","",PageSuffix,1,Rs("Fk_Module_Id"),Rs("Fk_Module_FixedUrl")&"Index_"&PageNow)
                                End If
                            End If
                        Else '非绝对链接
                            If PageNow=1 Then
                                cURL=FKTemplate.GetUrl(FullSiteDir,"",Rs("Fk_Module_Url")&"Index","",PageSuffix,1,Rs("Fk_Module_Id"),"")
                            Else
                                cURL=FKTemplate.GetUrl(FullSiteDir,"",Rs("Fk_Module_Url")&"Index_"&PageNow,"",PageSuffix,1,Rs("Fk_Module_Id"),"")
                            End If
                        End If
                        '生成
                        cURL=Replace(cURL,"Index"&PageSuffix,"")
                        cURL=Server.HTMLEncode(Replace(Fk_Site_Url&cURL,"//","/"))
                        CreateHtml=CreateHtml&"<url>"&vbLf
                        CreateHtml=CreateHtml&"<loc>"&cURL&"</loc>"&vbLf
                        If CreateType=1 Then
                            CreateHtml=CreateHtml&"<lastmod>"&Date()&"</lastmod>"&vbLf
                            CreateHtml=CreateHtml&"<changefreq>daily</changefreq>"&vbLf
                            CreateHtml=CreateHtml&"<priority>0.7</priority>"&vbLf
                        End If
                        CreateHtml=CreateHtml&"</url>"&vbLf
                    Next
                End If
            End If
            Rs.MoveNext
        Wend
    End If
    Rs.Close

替换为以下代码

    '生成栏目页
    Sqlstr="Select Fk_Module_Id,Fk_Module_Type,Fk_Module_Model,Fk_Module_FixedUrl,Fk_Module_Url,Fk_Module_LinkType,Fk_Module_PageSize,Fk_Module_Menu,Fk_Module_GBookReply,Fk_Module_Template From [Fk_Module] Where Fk_Module_State=1 Order By Fk_Module_Id Asc"
    mRs.Open Sqlstr,Conn,1,1
    If Not mRs.Eof Then
        While Not mRs.Eof
            If (mRs("Fk_Module_LinkType")=1 And mRs("Fk_Module_Type")=4) Or Instr(",0,2,",","&mRs("Fk_Module_Type")&",")>0 Then
                cURL=FKTemplate.GetUrl(FullSiteDir,"",mRs("Fk_Module_Url")&"Index","",PageSuffix,1,mRs("Fk_Module_Id"),mRs("Fk_Module_FixedUrl"))
                '生成
                cURL=Replace(cURL,"Index"&PageSuffix,"")
                cURL=Server.HTMLEncode(Replace(Replace(Fk_Site_Url&CURL,"//","/"),"http:/","http://"))
                CreateHtml=CreateHtml&"<url>"&vbLf
                CreateHtml=CreateHtml&"<loc>"&cURL&"</loc>"&vbLf
                If CreateType=1 Then
                    CreateHtml=CreateHtml&"<lastmod>"&Date()&"</lastmod>"&vbLf
                    CreateHtml=CreateHtml&"<changefreq>daily</changefreq>"&vbLf
                    CreateHtml=CreateHtml&"<priority>0.7</priority>"&vbLf
                End If
                CreateHtml=CreateHtml&"</url>"&vbLf
            ElseIf Instr(",1,3,",","&mRs("Fk_Module_Type")&",")>0 Then
                '读取每页数量
                PageSizes=Fk_Site_PageSize
                If mRs("Fk_Module_PageSize")>0 Then
                    PageSizes=mRs("Fk_Module_PageSize")
                End If
                
                '读取模型绑定模板
                If mRs("Fk_Module_Type")=1 Then
                    Sqlstr="Select Fk_Model_Template From [Fk_Model] Where Fk_Model_Id="& mRs("Fk_Module_Model")&""
                    c_Rs.Open Sqlstr,Conn,1,1
                    If Not c_Rs.Eof Then
                        mModelTemplate=c_Rs("Fk_Model_Template")
                    Else
                        mModelTemplate=""
                    End If
                    c_Rs.Close
                Else
                    mModelTemplate=""
                End If

                If mRs("Fk_Module_Type")=1 Then
                    PageTemplate="viewlist"
                ElseIf mRs("Fk_Module_Type")=3 Then
                    PageTemplate="gbook"
                End If
                
                If mRs("Fk_Module_Template")<>"" Then
                    PageTemplate=mRs("Fk_Module_Template")
                ElseIf mModelTemplate<>"" Then
                    PageTemplate=mModelTemplate
                End If
                                
                '菜单信息读取
                Sqlstr="Select Fk_Menu_Dir,Fk_Menu_Template From [Fk_Menu] Where Fk_Menu_Id=" & mRs("Fk_Module_Menu")
                c_Rs.Open Sqlstr,Conn,1,1
                If Not c_Rs.Eof Then
                    MenuDir=c_Rs("Fk_Menu_Dir")
                    MenuTemplate=c_Rs("Fk_Menu_Template")
                Else
                    c_Rs.Close
                    Call FKFun.ShowErr("error:菜单不存在!",0)
                End If
                c_Rs.Close
                
                '目录模板方案_默认模板组合
                If MenuTemplate<>"" Then
                    If Instr(DisTemplate,","&PageTemplate&",")>0 Then
                        PageTemplate=MenuTemplate&"/"&PageTemplate
                    End If
                End If
                
                '模板标签解析
                PageCode=FKTemplate.GetTemplate(PageTemplate)
                
                PageCounts=1
                '读取页数
                If Instr(PageCode,"{$ModulePageCode(")>0 Then
                    '内容模块
                    If mRs("Fk_Module_Type")=1 Then
                        Sqlstr="Select Fk_View_Id From [Fk_View] Where Fk_View_Show=1 And Fk_View_Module="&mRs("Fk_Module_Id")&""
                        c_Rs.Open Sqlstr,Conn,1,1
                        c_Rs.PageSize=PageSizes
                        If c_Rs.PageCount>0 Then
                            PageCounts=c_Rs.PageCount
                        End If
                        c_Rs.Close
                    '留言模块
                    ElseIf mRs("Fk_Module_Type")=3 And mRs("Fk_Module_GBookReply")<>3 Then
                        Sqlstr="Select Fk_GBook_Id From [Fk_GBook] Where Fk_GBook_Module="&mRs("Fk_Module_Id")&""
                        If mRs("Fk_Module_GBookReply")=1 Then
                            Sqlstr=Sqlstr&" And Fk_GBook_ReIp<>''"
                        ElseIf mRs("Fk_Module_GBookReply")=2 Then
                            Sqlstr=Sqlstr&" And (Fk_GBook_ReIp='' Or Fk_GBook_ReIp Is Null)"
                        End If
                        c_Rs.Open Sqlstr,Conn,1,1
                        c_Rs.PageSize=PageSizes
                        If c_Rs.PageCount>0 Then
                            PageCounts=c_Rs.PageCount
                        End If
                        c_Rs.Close
                    Else
                        PageCounts=1
                    End If
                    '循环生成
                    For PageNow=1 To PageCounts
                        '链接地址获取
                        If mRs("Fk_Module_FixedUrl")<>"" Then '绝对链接
                            If Instr(mRs("Fk_Module_FixedUrl"),".")>0 Then '绝对链接带后缀
                                cURL=FKTemplate.GetUrl(FullSiteDir,"","","",PageSuffix,1,mRs("Fk_Module_Id"),mRs("Fk_Module_FixedUrl"))
                            Else '绝对链接不带后缀
                                If PageNow=1 Then
                                    cURL=FKTemplate.GetUrl(FullSiteDir,"","","",PageSuffix,1,mRs("Fk_Module_Id"),mRs("Fk_Module_FixedUrl")&"Index")
                                Else
                                    cURL=FKTemplate.GetUrl(FullSiteDir,"","","",PageSuffix,1,mRs("Fk_Module_Id"),mRs("Fk_Module_FixedUrl")&"Index_"&PageNow)
                                End If
                            End If
                        Else '非绝对链接
                            If PageNow=1 Then
                                cURL=FKTemplate.GetUrl(FullSiteDir,"",mRs("Fk_Module_Url")&"Index","",PageSuffix,1,mRs("Fk_Module_Id"),"")
                            Else
                                cURL=FKTemplate.GetUrl(FullSiteDir,"",mRs("Fk_Module_Url")&"Index_"&PageNow,"",PageSuffix,1,mRs("Fk_Module_Id"),"")
                            End If
                        End If
                        '生成
                        cURL=Replace(cURL,"Index"&PageSuffix,"")
                        cURL=Server.HTMLEncode(Replace(Replace(Fk_Site_Url&CURL,"//","/"),"http:/","http://"))
                        CreateHtml=CreateHtml&"<url>"&vbLf
                        CreateHtml=CreateHtml&"<loc>"&cURL&"</loc>"&vbLf
                        If CreateType=1 Then
                            CreateHtml=CreateHtml&"<lastmod>"&Date()&"</lastmod>"&vbLf
                            CreateHtml=CreateHtml&"<changefreq>daily</changefreq>"&vbLf
                            CreateHtml=CreateHtml&"<priority>0.7</priority>"&vbLf
                        End If
                        CreateHtml=CreateHtml&"</url>"&vbLf
                    Next
                End If
            End If
            mRs.MoveNext
        Wend
    End If
    mRs.Close

保存文件,修复完成。

本文网址:http://www.daguweb.com/News/Col9/18.html

分享到:


© 2008-2017 daguweb.com All Rights Reserved.