PHP people...quick question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Young
    Bland for life
    • Nov 2004
    • 10468

    #1

    PHP people...quick question

    What's the best way to approach easily creating expiring links?

    Links that expire after the first click? Or after a certain amount of clicks or time. Whichever is easier.
    ★★★
  • V_RocKs
    Damn Right I Kiss Ass!
    • Nov 2003
    • 32449

    #2
    And by expire you mean?

    Comment

    • Young
      Bland for life
      • Nov 2004
      • 10468

      #3
      1 click. link gone.
      ★★★

      Comment

      • psili
        Confirmed User
        • Apr 2003
        • 5526

        #4
        Never tried it but maybe a CSS thing:

        a:visited { display: none; }

        ?
        Your post count means nothing.

        Comment

        • Young
          Bland for life
          • Nov 2004
          • 10468

          #5
          Originally posted by psili
          Never tried it but maybe a CSS thing:

          a:visited { display: none; }

          ?
          Thats a cosmetic way of doing it (which I had never thought of) but I'm going to be sending this links via email.

          What I want to do is after a potential client visits a page. I don't want them to be able to go to that page again. Unless I send them a fresh link.
          ★★★

          Comment

          • psili
            Confirmed User
            • Apr 2003
            • 5526

            #6
            Originally posted by Young
            Thats a cosmetic way of doing it (which I had never thought of) but I'm going to be sending this links via email.

            What I want to do is after a potential client visits a page. I don't want them to be able to go to that page again. Unless I send them a fresh link.
            I suck at this, but:
            <?php
            // on page being hit
            if(isset($_COOKIE["alreadyhere"]))
            {
            header("Location: /another/uri");
            }
            else
            {
            setcookie( "alreadyhere", 1, (time()*100000), $_SERVER["REQUEST_URI"] );
            }
            ?>

            -- or some shit. basically, store something of the URI they already visited, test and send somewhere else.

            someone else has a more elegant solution that's bug-checked, so I'll just bump this for ya
            Your post count means nothing.

            Comment

            • Young
              Bland for life
              • Nov 2004
              • 10468

              #7
              Originally posted by psili
              I suck at this, but:
              <?php
              // on page being hit
              if(isset($_COOKIE["alreadyhere"]))
              {
              header("Location: /another/uri");
              }
              else
              {
              setcookie( "alreadyhere", 1, (time()*100000), $_SERVER["REQUEST_URI"] );
              }
              ?>

              -- or some shit. basically, store something of the URI they already visited, test and send somewhere else.

              someone else has a more elegant solution that's bug-checked, so I'll just bump this for ya
              thanks i can play around with that.

              ill take anything else anyone can throw at me though.
              ★★★

              Comment

              • FightThisPatent
                Confirmed User
                • Aug 2003
                • 4090

                #8
                Originally posted by Young
                What's the best way to approach easily creating expiring links?

                Links that expire after the first click? Or after a certain amount of clicks or time. Whichever is easier.

                if you want to do it with a database, rather than a cookie... in the email, you have an ID like ID=12 that is unique to the person.. or the ID is for a particular URL and after so many incremental clicks, you do something else.

                when they land on your page, you mark in the database that they visited via the unique ID (so this helps you to confirm they clicked through), and the next time they click through on the email, your database lookup will see they were already there, and then redirect to another URL or display some message.


                Fight the tips & tricks!

                http://www.t3report.com
                (where's the traffic?) v5.0 is out! |
                http://www.FightThePatent.com
                | ICQ 52741957

                Comment

                • Pipecrew
                  Master of Gfy.com
                  • Feb 2002
                  • 14888

                  #9
                  i am not a php pro by any means, i have my own threads on here asking for help ;) but what if you set a status for the links? on the main page it only shows "active links" and when they click, you have a variable that sets it inactive, thus it wont be shown on the main page anymore after a click. Just an idea

                  Comment

                  • Swish
                    Confirmed User
                    • Mar 2006
                    • 1421

                    #10
                    Do this in a database. Store a unique id for each link sent (i.e. md5($email . time()); ) using the md5 hash prevents people guessing for someone else's link (by incrementing a numeric value like id=5 as suggested above).

                    In your db table also have a field for date_clicked which you update when the url is loaded. You could also have a campaign_id or something to track multiple links mailed in the same table, maybe the email address as well, whatever suits your needs.

                    Then you send a link like : http://www.someurl.com/somepage.html...23456789abcedf

                    When the link is loaded you check the db for that hash and whether date_clicked has been set or not. Redirect or load the one time link page based on those conditions and then update the db.


                    Naughty America - Director of Technology
                    It's a CELEBRATION bitches!! For the hottest content promote Naughty America!
                    swish at naughtyamerica dot com | ICQ: 226 737 620 | See Who I Am At AdultWhosWho.com!

                    Comment

                    • Young
                      Bland for life
                      • Nov 2004
                      • 10468

                      #11
                      Thanks Swish and Fight This Patent, I think I'll mesh your two ideas hash + lookup

                      thanks to you too pipecrew. good to see you still posting around here. hows miami treating you?
                      ★★★

                      Comment

                      • rowan
                        Too lazy to set a custom title
                        • Mar 2002
                        • 17393

                        #12
                        Originally posted by Swish
                        Do this in a database. Store a unique id for each link sent (i.e. md5($email . time()); ) using the md5 hash prevents people guessing for someone else's link (by incrementing a numeric value like id=5 as suggested above).
                        If you use hashes then there's a small chance that they will not be unique across two or more messages. Better to generate an array of hashes, weed out any dupes, and then allocate IDs from that.

                        Comment

                        • dissipate
                          The Dirty Frenchman
                          • Nov 2005
                          • 8904

                          #13
                          Use PHP's APC Cache.

                          Put the link URL in a key in apc cache, once it's been accessed, destroy the key.

                          http://us.php.net/apc

                          Comment

                          • tom3k
                            Confirmed User
                            • Nov 2007
                            • 105

                            #14
                            database + unique hashes is the only sure shot way to go at this.

                            it what i would do.

                            Comment

                            • brandonstills
                              Confirmed User
                              • Dec 2007
                              • 1964

                              #15
                              href="myScript.php?linkID=xxxx"

                              then the myScript.php redirects and removes the link as a valid option

                              you can probably use a database as the easiest way to keep track of it

                              Brandon Stills
                              Industry and programming veteran
                              [email protected] | skype: brandonstills | ICQ #495-171-318

                              Comment

                              • fris
                                Too lazy to set a custom title
                                • Aug 2002
                                • 55679

                                #16
                                do you still need this?

                                i know its a very old thread, but i use something like this, you can make the url expire after certain amount of time. bind it to an ip address, etc.
                                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                                Comment

                                Working...