PHP: Tracking incoming and outgoing its

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DirtyRider
    Confirmed User
    • Feb 2003
    • 819

    #1

    PHP: Tracking incoming and outgoing its

    I've seen $_SERVER['HTTP_REFERER'] used to track incoming hits. Is their anything more reliable then this?

    Also, I was wondering if theirs a way to track outgoing hits some how? I don't want to use anything like out.php?s=domain.com. Maybe some Javascript onclick? Not sure how traffic trading scripts are really doing it.

    Any help would be greatly appreciated Thanks.
    hello
  • Sexgenoten
    Registered User
    • Dec 2010
    • 85

    #2
    I have no experience with trade scripts but if i would want to check on outgoing links i'd would do something like the following:

    I'd have a href as a link with an id and a onmousedown function.

    When the href is clicked, the onmousedown function would be triggered.

    In this javascript function i'd retrieve the link and would use jquerys $.post to sent the information to an api page.

    On the api page you would retrieve the information from the $_POST array and subsequently insert it into a database.

    Make sure your api page only accepts incoming arrays from ur own domain.

    GL!
    Last edited by Sexgenoten; 03-13-2011, 03:26 PM. Reason: grammar

    Comment

    • daniel_webcams
      Confirmed User
      • Nov 2008
      • 2491

      #3
      you could use this java script : http://forum.lrytas.lt/topic_show.pl?tid=83254 works together with a small php code, not sure if the code work, but here's another another one as back up http://www.experts-exchange.com/Prog..._21661004.html

      I think this is exactly what you need.
      Daniel,

      Skype: [email protected]
      ICQ: 354-220-339
      Email: daniel@adultforce[dot]com


      Comment

      • Dappz
        Confirmed User
        • Dec 2009
        • 997

        #4
        not sure about this


        Hentai Artist * Draw My Anime *
        HentaiLovers * hentaiG4H * ICQ : 657458

        Comment

        • robber
          Web Developer
          • Jan 2011
          • 264

          #5
          incoming would work as a refferer, but you could log them as incomings, but also record your ip for the current day and have a limitation as to how often someone will be logged on the system in the timeframe this would stop the same person repeatedly clicking a link, or produce a link code which ties into your system, thus meaning the trader would get nothing off a straight link they need to go through the link code

          Rob

          Comment

          • Sexgenoten
            Registered User
            • Dec 2010
            • 85

            #6
            Well, i figured i too needed to track my outgoing traffic, so here is a fast and simpel javascript/jquery solution that works for me:

            Code:
            function outboudTraffic( obj ){
            	
                    // obj comes from a ahref
                    // get the src of the ahref object
            	var link = $( "#" + obj.id ).attr( "href");
            
            	// post the link value as an clicked_link post variable ( $_POST['clicked_link'] )
            	$.post("api.php",	{ 
            		
            		clicked_link		: link
            	
            	
            		},  function(data){
            	
            		//i use this to alert debugging information
            		//i turn it off when going live
            		alert( data);			
            	});
            	
            }
            On the api.php:

            // make sure that the $_POST is coming from your domain and that you are not being
            // spammed.
            if ( isset( $_POST['clicked_link'] ) && !empty( $_POST['clicked_link'] ) ){

            // insert it into a database
            //

            }

            Comment

            • robber
              Web Developer
              • Jan 2011
              • 264

              #7
              You need to watch the script as:

              On the api.php:

              // make sure that the $_POST is coming from your domain and that you are not being
              // spammed.
              if ( isset( $_POST['clicked_link'] ) && !empty( $_POST['clicked_link'] ) ){

              // insert it into a database
              //

              }
              could be easily spammed by being posted to by a cURL process :D, you need some sort of check for the requester to make sure it is your server

              Otherwise, nice bit of code

              Rob

              Comment

              • Sexgenoten
                Registered User
                • Dec 2010
                • 85

                #8
                Originally posted by robber
                could be easily spammed by being posted to by a cURL process :D, you need some sort of check for the requester to make sure it is your server
                Very true. As i havent implement security yet, i have no example code but i can tell what im going to do.

                I think there are 2 options ( i might implement both ):

                1. Check de $_SERVER array on the api page. I'm not sure if the desired information will be there as its a jquery post, but i think it will be.

                2. Have hidden input array with session_id, logged_in_status encrypted with a set key and use base64_encode on it ( server side ). This much i already have ;)

                Make an active table in the db and have javascript send a $.post every 15 min to the api to update the active table.

                Then, when a request comes in to insert a new link, you can check if the last active entry in the table of the session, is within 15 min. If so, insert the link, if not, no action. ( perhaps log it, so you can see whose trying to screw u over or to check if your code isnt screwed up ;) )

                I'll prolly end up implementing both ;)

                Comment

                Working...