Need a script that only loads a PHP JS or HTML file on unique IP's only

Discussion in 'Programming' started by chriswick, Dec 18, 2007.

  1. #1
    This can be with any of the following codes .js , .php or .html if you can help it try and avoid databases!

    + Rep for the first person that posts a script.

    Thanks!
     
    chriswick, Dec 18, 2007 IP
  2. NsaneNoob

    NsaneNoob Peon

    Messages:
    2,103
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Your question isn't clear enough. Are you looking for a script that will load a file to a certain IP one time? Then this is not possible (since you don't know if the user closed the browser or not).

    But if you are talking about file download per ip, then it is a different story.

    Also you are not allowed to offer reps for answers.

    Peace,
     
    Barti1987, Dec 18, 2007 IP
  4. NsaneNoob

    NsaneNoob Peon

    Messages:
    2,103
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think he meant : per good answer (helpful)
     
    NsaneNoob, Dec 18, 2007 IP
  5. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok people, this is what I'm after. I'm after a script that will only load a script once per browsing session. The reason I want this is because I want to show an advert to unique IP's only as there isn't much point in showing the same advert over and over again this is a layered advert so would come over the page once you enter the website from anywhere on the site, after that you wouldn't see that advert again for the rest of your time browsing the site as long as the user dosn't close there browser.

    What I ment by Rep is if someone posts me a script and it works I will give you a Rep.

    Thanks!
     
    chriswick, Dec 19, 2007 IP
  6. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #6
    edit: misunderstood the question.
     
    live-cms_com, Dec 19, 2007 IP
  7. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #7
    What part of the question do you not understand?
     
    chriswick, Dec 19, 2007 IP
  8. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #8
    I was going to say it could be done with .htaccess, but that was because I though you wanted to restrict access to certain IPs.
     
    live-cms_com, Dec 19, 2007 IP
  9. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #9
    lol no alittle bit more complex that that. Does anyone even know if it can be done even if I do have to use a database SQL or whatever to store the IP's for browsing sessions.

    I think it could be done with cookies but not sure how to put it together E.g. the cookie tells the server not to show a script untill it can't find the cookie again, because each time the browser is closed the cookie is deleted?
     
    chriswick, Dec 19, 2007 IP
  10. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #10
    Cookies can be set to time dependant rather than session dependant. So you could make a cookie last 100 years if you like.

    It could be done quite easily with cookies if you know PHP. Just display the ad once and create the cookie saying RepeatVisitor = 'true' then in PHP display the ad only if that cookie isn't set.
     
    live-cms_com, Dec 19, 2007 IP
  11. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Right ok all I need know is some PHP that will show a value if it can't find the IP on that persons computer, anyone know how it would work?
     
    chriswick, Dec 19, 2007 IP
  12. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #12
    I already told you how it would work and it has nothing to do with IP, just a single cookie.

    1. check for the cookie. It doesn't exist so...
    2. display the ad + create the cookie.

    1. check for the cookie. It does exist so...
    2. do nothing.
     
    live-cms_com, Dec 19, 2007 IP
  13. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #13
    How would I put that together it would be a .js Javascript file I want to show, I know how to put a simple cookie together and but that's about it.
     
    chriswick, Dec 19, 2007 IP