ad_network.php file needs updating - in ASP

Discussion in 'Co-op Advertising Network' started by ColumbusOnline, Jan 27, 2005.

  1. #1
    I am trying to get this set up in my ASP environment. I tried to follow the instructions at:
    http://forums.digitalpoint.com/showthread.php?t=5789

    and I am getting the error: ad_network.php file needs updating and I was wondering how do I get an updated version for ASP?

    In case I did something else wrong, I put the ad_network.asp and the ad_network_ads.txt in the same root directory. I changed the ad_network_ads.txt file to write privleges and changed the root_path to Const root_path="/" which I wasnt sure was right but that's the only time I have gotten anything to show up, even though it was "ad_network.php file needs updating "

    My URL is http://www.ColumbusOhioRealEstateOnline.com and the code I used was:

    <%
    'ASP Port of Coop Ad Network
    'http://www.digitalpoint.com/tools/ad-network
    'Credits: l0cke
    'Coded by Zinho 3-12-2004 - http://www.hackerscenter.com


    on error resume next '<- avoids nasty errors to appear on your page in the case requests for ads times out for any reason

    Private Function GetHTTPFile(File)
    Dim gHTTP
    Set gHTTP = server.CreateObject("WinHttp.WinHttpRequest.5.1")
    ghttp.settimeouts 30000,30000,30000,30000
    gHTTP.Open "GET", File, false
    gHTTP.Send
    If gHTTP.WaitForResponse(5) = True Then
    GetHTTPFile =gHTTP.ResponseText
    End If
    Set gHTTP=nothing
    end function




    public Sub SaveFile(FileName, Data)
    set fso=server.createobject("Scripting.FileSystemObject")
    set stream=fso.opentextfile(filename,2,true)
    stream.write data
    stream.close
    set fso=nothing


    End sub












    Function ad_network()
    Dim objFSO, objTextStreamR, objTextStreamW, ads, strData, count, i


    Const root_path="/" 'the (writable) path to ad_network_ads.txt
    Const fsoForReading = 1
    Const fsoForWriting = 2

    ad_type="link" '"link" for text link | "text" for text banner | "" (empty) for graphical banner

    ad_file = Server.MapPath("/") & root_path & "ad_network_ads.txt" 'it must be a path with write privileges

    ad_url = "http://ads.digitalpoint.com/network.php?s=" & Request.ServerVariables("SERVER_NAME") & "&type=" & ad_type

    Randomize()

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objTextStreamR = objFSO.OpenTextFile(ad_file, fsoForReading,true) 'IT THE FILE DOESN'T EXIST : CREATE IT

    redim preserve ad_result(1)

    If objTextStreamR.AtEndOfStream Then

    new_ad=getHTTPFile(ad_url)

    SaveFile ad_file,Now() & "<ad_break>" & new_ad

    ad_result(0)=new_ad
    ads_all = split(objTextStreamR.ReadAll ,"<ad_break>")
    Else





    ads_all = split(objTextStreamR.ReadAll ,"<ad_break>")
    ads_date=ads_all(0) 'takes the ads age

    objTextStreamR.close

    ad_result(0)=ads_all(ubound(ads_all))



    If UBOUND(ads_all)<401 or datediff("n",ads_date,now())>15 Then


    new_ad=getHTTPFile(ad_url)

    ad_result(0)=new_ad

    redim preserve ads_all(ubound(ads_all)+1)
    ads_all(0)=now()
    ads_all(ubound(ads_all))=new_ad




    'rebuilds the array keeping: deletes oldest link to make place for the new entry

    Set objTextStreamW = objFSO.OpenTextFile(ad_file, fsoForWriting)
    If ubound(ads_all)=401 then


    i=0
    redim preserve ads_all(401)

    while i <= 400
    if i=1 then
    ads_all(i)=ads_all(i+1)
    else
    ads_all(i)=ads_all(i)
    end if
    i=i+1
    wend



    End If

    i=0
    Do While i <= UBound(ads_all)
    objTextStreamW.Write( ads_all(i) )
    if not i=UBound(ads_all) then objTextStreamW.Write "<ad_break>"
    i = i + 1
    Loop



    End If
    End If

    i=1

    'builds the results
    while i<=4 and i<ubound(ads_all)-1
    redim preserve ad_result(i+1)

    random_item=cint((ubound(ads_all)-1)*Rnd()+1)
    ad_result(i) = ads_all(random_item)

    i=i+1


    wend

    ad_network=ad_result

    Set objTextStreamR = Nothing
    Set objTextStreamW = Nothing
    Set objFSO = Nothing

    End Function %>

    Thanks
     
    ColumbusOnline, Jan 27, 2005 IP
  2. ColumbusOnline

    ColumbusOnline Guest

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Never Mind, I found it...
     
    ColumbusOnline, Jan 27, 2005 IP
  3. xstream

    xstream Guest

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I just got the same error using the asp method.
     
    xstream, Jan 30, 2005 IP